@adaline/bedrock 2.2.0 → 2.2.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
@@ -5,65 +5,68 @@ var sha256Js = require('@aws-crypto/sha256-js');
5
5
  var protocolHttp = require('@smithy/protocol-http');
6
6
  var signatureV4 = require('@smithy/signature-v4');
7
7
 
8
- var Ca=Object.defineProperty,va=Object.defineProperties;var Ta=Object.getOwnPropertyDescriptors;var Ht=Object.getOwnPropertySymbols,Ma=Object.getPrototypeOf,xa=Object.prototype.hasOwnProperty,Sa=Object.prototype.propertyIsEnumerable,wa=Reflect.get;var he=(t,n)=>(n=Symbol[t])?n:Symbol.for("Symbol."+t),Oa=t=>{throw TypeError(t)};var Ft=(t,n,o)=>n in t?Ca(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,E=(t,n)=>{for(var o in n||(n={}))xa.call(n,o)&&Ft(t,o,n[o]);if(Ht)for(var o of Ht(n))Sa.call(n,o)&&Ft(t,o,n[o]);return t},z=(t,n)=>va(t,Ta(n));var ge=(t,n,o)=>wa(Ma(t),o,n);var $=(t,n,o)=>new Promise((i,s)=>{var r=c=>{try{d(o.next(c));}catch(m){s(m);}},l=c=>{try{d(o.throw(c));}catch(m){s(m);}},d=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,l);d((o=o.apply(t,n)).next());}),fe=function(t,n){this[0]=t,this[1]=n;},Je=(t,n,o)=>{var i=(l,d,c,m)=>{try{var h=o[l](d),g=(d=h.value)instanceof fe,P=h.done;Promise.resolve(g?d[0]:d).then(u=>g?i(l==="return"?l:"next",d[1]?{done:u.done,value:u.value}:u,c,m):c({value:u,done:P})).catch(u=>i("throw",u,c,m));}catch(u){m(u);}},s=l=>r[l]=d=>new Promise((c,m)=>i(l,d,c,m)),r={};return o=o.apply(t,n),r[he("asyncIterator")]=()=>r,s("next"),s("throw"),s("return"),r},ye=t=>{var n=t[he("asyncIterator")],o=!1,i,s={};return n==null?(n=t[he("iterator")](),i=r=>s[r]=l=>n[r](l)):(n=n.call(t),i=r=>s[r]=l=>{if(o){if(o=!1,r==="throw")throw l;return l}return o=!0,{done:!1,value:new fe(new Promise(d=>{var c=n[r](l);c instanceof Object||Oa("Object expected"),d(c);}),1)}}),s[he("iterator")]=()=>s,i("next"),"throw"in n?i("throw"):s.throw=r=>{throw r},"return"in n&&i("return"),s};var Pa=Object.defineProperty,Ra=Object.defineProperties,_a=Object.getOwnPropertyDescriptors,zt=Object.getOwnPropertySymbols,ja=Object.prototype.hasOwnProperty,Ea=Object.prototype.propertyIsEnumerable,be=(t,n)=>(n=Symbol[t])?n:Symbol.for("Symbol."+t),Ia=t=>{throw TypeError(t)},Kt=(t,n,o)=>n in t?Pa(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,S=(t,n)=>{for(var o in n||(n={}))ja.call(n,o)&&Kt(t,o,n[o]);if(zt)for(var o of zt(n))Ea.call(n,o)&&Kt(t,o,n[o]);return t},Y=(t,n)=>Ra(t,_a(n)),B=(t,n,o)=>new Promise((i,s)=>{var r=c=>{try{d(o.next(c));}catch(m){s(m);}},l=c=>{try{d(o.throw(c));}catch(m){s(m);}},d=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,l);d((o=o.apply(t,n)).next());}),mn=function(t,n){this[0]=t,this[1]=n;},Vt=(t,n,o)=>{var i=(l,d,c,m)=>{try{var h=o[l](d),g=(d=h.value)instanceof mn,P=h.done;Promise.resolve(g?d[0]:d).then(u=>g?i(l==="return"?l:"next",d[1]?{done:u.done,value:u.value}:u,c,m):c({value:u,done:P})).catch(u=>i("throw",u,c,m));}catch(u){m(u);}},s=l=>r[l]=d=>new Promise((c,m)=>i(l,d,c,m)),r={};return o=o.apply(t,n),r[be("asyncIterator")]=()=>r,s("next"),s("throw"),s("return"),r},Ba=t=>{var n=t[be("asyncIterator")],o=!1,i,s={};return n==null?(n=t[be("iterator")](),i=r=>s[r]=l=>n[r](l)):(n=n.call(t),i=r=>s[r]=l=>{if(o){if(o=!1,r==="throw")throw l;return l}return o=!0,{done:!1,value:new mn(new Promise(d=>{var c=n[r](l);c instanceof Object||Ia("Object expected"),d(c);}),1)}}),s[be("iterator")]=()=>s,i("next"),"throw"in n?i("throw"):s.throw=r=>{throw r},"return"in n&&i("return"),s},me="system",ne="user",R="assistant",st="tool",Aa=[me,ne,R,st],pn=zod.z.enum(Aa),Na=[R],Ua=zod.z.enum(Na),W="image",un="base64",La=["png","jpeg","webp","gif"],$a=zod.z.object({type:zod.z.literal(un),base64:zod.z.string(),mediaType:zod.z.enum(La)}),qa="url",Da=zod.z.object({type:zod.z.literal(qa),url:zod.z.string()}),Ha=zod.z.discriminatedUnion("type",[$a,Da]),Fa=["low","medium","high","auto"],za=zod.z.enum(Fa),Ka=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(W),detail:za,value:Ha,metadata:t}),hn="pdf",Va="base64",Ja=zod.z.object({type:zod.z.literal(Va),base64:zod.z.string()}),Ga="url",Za=zod.z.object({type:zod.z.literal(Ga),url:zod.z.string()}),Wa=zod.z.discriminatedUnion("type",[Ja,Za]),Xa=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(hn),value:Wa,file:zod.z.object({name:zod.z.string(),id:zod.z.string(),size:zod.z.number().optional()}),metadata:t}),X="reasoning",Ce="partial-reasoning",ve="thinking",rt="redacted",Xe=zod.z.object({type:zod.z.literal(ve),thinking:zod.z.string(),signature:zod.z.string()}),gn=zod.z.object({type:zod.z.literal(rt),data:zod.z.string()}),Ya=zod.z.discriminatedUnion("type",[Xe,gn]),lt=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(X),value:Ya,metadata:t}),Qa=zod.z.object({type:zod.z.literal(ve),thinking:Xe.shape.thinking.optional(),signature:Xe.shape.signature.optional()}),ei=zod.z.discriminatedUnion("type",[Qa,gn]),dt=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ce),value:ei,metadata:t}),_="text",fn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(_),value:zod.z.string(),metadata:t}),ct="partial-text",yn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ct),value:zod.z.string(),metadata:t}),q="tool-call",bn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(q),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:t}),mt="partial-tool-call",kn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(mt),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:t}),H="tool-response",Cn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(H),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:t}),vn="partial-tool-response",Tn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(vn),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:t}),ti=[_,W,hn,q,H,X],ni=zod.z.enum(ti),oi=(t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[fn(t),Ka(n),Xa(o),bn(i),Cn(s),lt(r)]),ai=[ct,mt,Ce];zod.z.enum(ai);var ii=(t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[yn(t),kn(n),dt(o),Tn(i)]),Mn=(t=pn,n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined(),l=zod.z.undefined(),d=zod.z.undefined())=>zod.z.object({role:t,content:zod.z.array(oi(n,o,i,s,l,r)),metadata:d}),ae=(t=Ua,n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.object({role:t,partialContent:ii(n,o,i,r),metadata:s}),si=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Jt=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),ri=Jt.extend({topLogProbs:zod.z.array(Jt)}),xn=zod.z.array(ri);zod.z.object({messages:zod.z.array(Mn()),usage:si.optional(),logProbs:xn.optional()});var li=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(ae()),usage:li.optional(),logProbs:xn.optional()});var Sn=(t=zod.z.record(zod.z.string(),zod.z.any()).optional())=>t,di=zod.z.object({enabled:zod.z.boolean().default(!0),allowedTools:zod.z.array(zod.z.string().min(1))}),ci=zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(t=>t.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),toolConfiguration:di.optional(),authorizationToken:zod.z.string().min(1).optional()}),mi=["object","array","number","string","boolean","enum"],Gt=zod.z.enum(mi),pi=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Gt,zod.z.array(zod.z.union([Gt,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()}),ui=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(pi),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:ui}).optional();var oe="text",wn="token",hi=[oe,wn],gi=zod.z.enum(hi),fi=zod.z.array(zod.z.string().min(1)),yi=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),bi=(t=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(oe),metadata:t,requests:fi}),zod.z.object({modality:zod.z.literal(wn),metadata:t,requests:yi})]),On="float",ki=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),Pn="base64",Ci=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Zt=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(On),embeddings:zod.z.array(ki),usage:Zt.optional()}),zod.z.object({encodingFormat:zod.z.literal(Pn),embeddings:zod.z.array(Ci),usage:Zt.optional()})]);var vi=t=>{let n=new WeakSet;return JSON.stringify(t,(o,i)=>{if(typeof i=="object"&&i!==null){if(n.has(i))return;n.add(i);}return i})},Ti=t=>t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:vi(t),Ge="GatewayBaseError",Q=class Rn extends Error{constructor({info:n,cause:o},i){super(`[${i!=null?i:Ge}]: ${n}
9
- Message: ${Ti(o)}`),this.name=Ge,this.info=n,this.cause=o,this.name=i!=null?i:Ge,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(n){return n instanceof Rn}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Mi=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."),xi=zod.z.object({base:Mi.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),Si=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:xi.describe("Price categories and rates for this specific token range.")}).refine(t=>t.maxTokens===null||typeof t.maxTokens=="number"&&t.maxTokens>t.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");zod.z.object({modelName:zod.z.string().describe("Model name this schedule applies to."),currency:zod.z.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:zod.z.array(Si).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((t,n)=>{let{tokenRanges:o}=t;o[0].minTokens!==0&&n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let s=1;s<o.length;s++){let r=o[s-1],l=o[s];if(r.maxTokens===null){n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}l.minTokens!==r.maxTokens&&n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s,"minTokens"],message:`Tier ${s} minTokens (${l.minTokens}) must equal previous tier's maxTokens (${r.maxTokens}) for contiguity.`}),l.minTokens<r.minTokens&&n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${s} (${l.minTokens}) starts before Tier ${s-1} (${r.minTokens}).`});}let i=o[o.length-1];o.every(s=>s.maxTokens!==null||s===i)&&i.maxTokens!==null&&n.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 wi="function",Oi=zod.z.enum(["object","array","number","string","boolean","null"]),Pi=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:Oi.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(Pi).optional(),required:zod.z.array(zod.z.string()).optional()});var Ri=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()}),_i=zod.z.enum(["function"]),ji=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),Ei=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:ji.optional()}),Ii=zod.z.discriminatedUnion("type",[Ei]),Bi=zod.z.object({type:_i,definition:zod.z.object({schema:Ri}),request:Ii.optional()}),Ai=[wi];zod.z.enum(Ai);var Ni=(t=zod.z.undefined())=>zod.z.discriminatedUnion("type",[Bi.extend({metadata:t})]),Ui=t=>fn().parse({modality:_,value:t}),Wt=(t,n,o,i,s)=>bn().parse({modality:q,index:t,id:n,name:o,arguments:i,serverName:s}),Li=(t,n,o,i,s,r)=>Cn().parse({modality:H,index:t,id:n,name:o,data:i,apiResponse:s,metadata:r}),Xt=(t,n)=>ae().parse({role:t,partialContent:yn().parse({modality:ct,value:n})}),Ze=(t,n,o,i,s,r)=>ae().parse({role:t,partialContent:kn().parse({modality:mt,index:n,id:o,name:i,arguments:s,serverName:r})}),$i=(t,n,o,i,s)=>ae().parse({role:t,partialContent:Tn().parse({modality:vn,index:n,id:o,name:i,data:s})}),qi=(t,n)=>lt().parse({modality:X,value:{type:ve,thinking:t,signature:n}}),Di=t=>lt().parse({modality:X,value:{type:rt,data:t}}),We=(t,n,o)=>ae().parse({role:t,partialContent:dt().parse({modality:Ce,value:{type:ve,thinking:n,signature:o}})}),Hi=(t,n)=>ae().parse({role:t,partialContent:dt().parse({modality:Ce,value:{type:rt,data:n}})}),Fi=Object.defineProperty,Yt=Object.getOwnPropertySymbols,zi=Object.prototype.hasOwnProperty,Ki=Object.prototype.propertyIsEnumerable,Qt=(t,n,o)=>n in t?Fi(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,pe=(t,n)=>{for(var o in n||(n={}))zi.call(n,o)&&Qt(t,o,n[o]);if(Yt)for(var o of Yt(n))Ki.call(n,o)&&Qt(t,o,n[o]);return t},en="ProviderError",tn=class _n extends Q{constructor({info:n,cause:o}){super({info:n,cause:o},en),this.name=en,this.info=n,this.cause=o;}static isProviderError(n){return n instanceof _n}},nn="ModelResponseError",K=class jn extends Q{constructor({info:n,cause:o}){super({info:n,cause:o},nn),this.name=nn,this.cause=o,this.info=n;}static isModelResponseError(n){return n instanceof jn}},on="InvalidModelRequestError",Ye=class En extends Q{constructor({info:n,cause:o}){super({info:n,cause:o},on),this.name=on,this.cause=o,this.info=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(n){return n instanceof En}},an="InvalidConfigError",Z=class In extends Q{constructor({info:n,cause:o}){super({info:n,cause:o},an),this.name=an,this.cause=o,this.info=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(n){return n instanceof In}},sn="InvalidMessagesError",N=class Bn extends Q{constructor({info:n,cause:o}){super({info:n,cause:o},sn),this.name=sn,this.cause=o,this.info=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(n){return n instanceof Bn}},rn="InvalidToolsError",ln=class An extends Q{constructor({info:n,cause:o}){super({info:n,cause:o},rn),this.name=rn,this.cause=o,this.info=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(n){return n instanceof An}},dn="InvalidEmbeddingRequestsError",cn=class Nn extends Q{constructor({info:n,cause:o}){super({info:n,cause:o},dn),this.name=dn,this.info=n,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(n){return n instanceof Nn}},pt="multi-string",Un=zod.z.object({type:zod.z.literal(pt),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()}),Vi=t=>zod.z.array(zod.z.string()).max(t).default([]).optional(),Ji=t=>({def:Un.parse(pe({type:pt},t)),schema:Vi(t.max)}),ut="object-schema",Ln=zod.z.object({type:zod.z.literal(ut),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),Gi=t=>t.optional(),Zi=t=>({def:Ln.parse(pe({type:ut},t)),schema:Gi(t.objectSchema)}),ht="range",$n=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),min:zod.z.number().int(),max:zod.z.number().int(),step:zod.z.number().positive(),default:zod.z.number()}),Wi=(t,n,o,i)=>zod.z.number().min(t).max(n).step(o).default(i).optional(),ue=t=>({def:$n.parse(pe({type:ht},t)),schema:Wi(t.min,t.max,t.step,t.default)}),gt="select-boolean",qn=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),default:zod.z.boolean().nullable()}),Xi=t=>zod.z.boolean().nullable().default(t).optional(),ft=t=>({def:qn.parse(pe({type:gt},t)),schema:Xi(t.default)}),yt="select-string",Dn=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),default:zod.z.string(),choices:zod.z.array(zod.z.string())}),Yi=(t,n)=>zod.z.enum(n).nullable().default(t).optional(),bt=t=>({def:Dn.parse(pe({type:yt},t)),schema:Yi(t.default,t.choices)}),Qi=[ht,pt,yt,ut,gt];zod.z.enum(Qi);var Hn=zod.z.discriminatedUnion("type",[$n,Un,Dn,qn,Ln]),F=(t=pn,n=ni)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(t,zod.z.string().min(1).optional()),modalities:zod.z.array(n).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),Hn),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var i,s;let r=Object.keys(o.def),l=Object.keys((s=(i=o.schema)==null?void 0:i.shape)!=null?s:{});return r.every(d=>l.includes(d))&&l.every(d=>r.includes(d))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()}),ie=(t=gi)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(t).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Hn),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(n=>{var o,i;let s=Object.keys(n.def),r=Object.keys((i=(o=n.schema)==null?void 0:o.shape)!=null?i:{});return s.every(l=>r.includes(l))&&r.every(l=>s.includes(l))},{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 es={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."},ts={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."},ns={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},os=t=>({type:"multi",title:"Stop sequence",description:`Enter up to ${t} sequences that will halt additional text output. The generated text will exclude these sequences.`}),as={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."},is={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."},ss={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."},rs={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."},ls={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."},ds={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."},cs={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."},ms={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."},ps={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."},us={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."},hs={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},gs={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."},fs={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."},ys={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."},bs={type:"object",title:"MCP servers",description:"MCP servers to use for the model."},I={TEMPERATURE:es,MAX_TOKENS:ts,STOP:os,TOP_A:as,TOP_P:is,TOP_K:ss,MIN_P:rs,FREQUENCY_PENALTY:ls,PRESENCE_PENALTY:ds,REPETITION_PENALTY:ms,SEED:cs,LOG_PROBS:ps,TOP_LOG_PROBS:us,ECHO:hs,RESPONSE_FORMAT:gs,RESPONSE_FORMAT_WITH_SCHEMA:fs,RESPONSE_SCHEMA:ys,MAX_REASONING_TOKENS:ns,MCP_SERVERS:bs},Fn=t=>Object.fromEntries(Object.entries(t).filter(([n,o])=>o!=null)),ce=t=>t==null?void 0:t.replace(/\/$/,""),zn=ue({param:"temperature",title:I.TEMPERATURE.title,description:I.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),Kn=t=>ue({param:"max_tokens",title:I.MAX_TOKENS.title,description:I.MAX_TOKENS.description,min:0,max:t,step:1,default:0}),Vn=t=>Ji({param:"stop_sequences",title:I.STOP(t).title,description:I.STOP(t).description,max:t}),Jn=ue({param:"top_p",title:I.TOP_P.title,description:I.TOP_P.description,min:0,max:1,step:.01,default:1}),Gn=ue({param:"top_k",title:I.TOP_K.title,description:I.TOP_K.description,min:0,max:1,step:.01,default:1}),Zn=bt({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"]}),Wn=ft({param:"mcp",title:"MCP",description:"Enable or disable Model Context Protocol (MCP) functionality for this model.",default:!1}),Xn=Zi({param:"mcp_servers",title:I.MCP_SERVERS.title,description:I.MCP_SERVERS.description,objectSchema:zod.z.array(ci)}),Te=(t,n)=>zod.z.object({temperature:zn.schema,maxTokens:Kn(t).schema,stop:Vn(n).schema,topP:Jn.schema,topK:Gn.schema,toolChoice:Zn.schema,mcp:Wn.schema,mcpServers:Xn.schema}),Me=(t,n)=>({temperature:zn.def,maxTokens:Kn(t).def,stop:Vn(n).def,topP:Jn.def,topK:Gn.def,toolChoice:Zn.def,mcp:Wn.def,mcpServers:Xn.def}),Yn=(t,n)=>ue({param:"max_reasoning_tokens",title:I.MAX_REASONING_TOKENS.title,description:I.MAX_REASONING_TOKENS.description,min:t,max:n,step:1,default:0}),Qn=ft({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.
10
- This can be useful for complex tasks that require more time to think.`,default:!1}),ks=(t,n,o,i)=>Y(S({},Me(t,n)),{reasoningEnabled:Qn.def,maxReasoningTokens:Yn(o,i).def}),Cs=(t,n,o,i)=>Te(t,n).extend({reasoningEnabled:Qn.schema,maxReasoningTokens:Yn(o,i).schema}),eo=bt({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"",choices:["base64",""]}),to=bt({param:"input_type",title:"Input type",description:"Select the input type for the word embedding.",default:"",choices:["query","document",""]}),no=ft({param:"truncation",title:"Truncation",description:"Select the truncation for the word embedding.",default:!0}),vs=()=>zod.z.object({encodingFormat:eo.schema,inputType:to.schema,truncation:no.schema}),Ts=()=>({encodingFormat:eo.def,inputType:to.def,truncation:no.def}),w={base:(t,n)=>({def:Me(t,n),schema:Te(t,n)}),extendedThinking:(t,n,o,i)=>({def:ks(t,n,o,i),schema:Cs(t,n,o,i)})},U={base:()=>({def:Ts(),schema:vs()})},Ms="anthropic",ke=class{constructor(){this.version="v1",this.name=Ms,this.chatModelFactories={[po]:{model:Tr,modelOptions:vr,modelSchema:uo},[yo]:{model:jr,modelOptions:_r,modelSchema:bo},[go]:{model:Pr,modelOptions:Or,modelSchema:fo},[nt]:{model:ur,modelOptions:pr,modelSchema:lo},[ot]:{model:fr,modelOptions:gr,modelSchema:co},[it]:{model:Sr,modelOptions:xr,modelSchema:ho},[at]:{model:kr,modelOptions:br,modelSchema:mo},[et]:{model:rr,modelOptions:sr,modelSchema:so},[tt]:{model:cr,modelOptions:dr,modelSchema:ro},[Qe]:{model:ar,modelOptions:or,modelSchema:io}},this.embeddingModelFactories={[Ro]:{model:Yr,modelOptions:Xr,modelSchema:_o},[Oo]:{model:Zr,modelOptions:Gr,modelSchema:Po},[ko]:{model:Ur,modelOptions:Nr,modelSchema:Co},[vo]:{model:qr,modelOptions:$r,modelSchema:To},[Mo]:{model:Fr,modelOptions:Hr,modelSchema:xo},[So]:{model:Vr,modelOptions:Kr,modelSchema:wo}};}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 tn({info:`Anthropic chat model: ${n} not found`,cause:new Error(`Anthropic chat model: ${n} not found, available chat models:
11
- ${this.chatModelLiterals().join(", ")}`)});let o=this.chatModelFactories[n].model,i=this.chatModelFactories[n].modelOptions.parse(t);return new o(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 tn({info:`Anthropic embedding model: ${n} not found`,cause:new Error(`Anthropic embedding model: ${n} not found, available embedding models:
12
- ${this.embeddingModelLiterals().join(", ")}`)});let o=this.embeddingModelFactories[n].model,i=this.embeddingModelFactories[n].modelOptions.parse(t);return new o(i)}};ke.chatBaseUrl="https://api.anthropic.com/v1",ke.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}}}]}},f=zod.z.enum([me,ne,R,st]),y={system:me,user:ne,assistant:R,tool:ne},k=[_,W,q,H],C=zod.z.enum([_,W,q,H]),xe=[_,W,q,H,X],Se=zod.z.enum([_,W,q,H,X]),xs=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),Ss=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.record(zod.z.any())}),ws=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string(),signature:zod.z.string()}),Os=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),Ps=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())}),Rs=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())}),_s=zod.z.object({content:zod.z.array(zod.z.discriminatedUnion("type",[xs,Ss,ws,Os,Ps,Rs])),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()})}),js=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()})})}),Es=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()})}),Is=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),Bs=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.object({})}),As=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string()}),Ns=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),Us=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())}),Ls=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())}),$s=zod.z.object({type:zod.z.literal("content_block_start"),index:zod.z.number(),content_block:zod.z.discriminatedUnion("type",[Is,Bs,As,Ns,Us,Ls])}),qs=zod.z.object({type:zod.z.literal("text_delta"),text:zod.z.string()}),Ds=zod.z.object({type:zod.z.literal("input_json_delta"),partial_json:zod.z.string()}),Hs=zod.z.object({type:zod.z.literal("thinking_delta"),thinking:zod.z.string()}),Fs=zod.z.object({type:zod.z.literal("signature_delta"),signature:zod.z.string()}),zs=zod.z.object({type:zod.z.literal("content_block_delta"),index:zod.z.number(),delta:zod.z.discriminatedUnion("type",[qs,Ds,Hs,Fs])}),Ks=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string().optional(),signature:zod.z.string().optional()}),Vs=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),Js=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),input_schema:zod.z.any()}),Gs=zod.z.object({type:zod.z.enum(["auto","any"])}),Zs=zod.z.object({type:zod.z.literal("tool"),name:zod.z.string().min(1)}),kt=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),oo=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()})});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())});var ao=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([kt,oo])).min(1))});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())});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())});var Ws=zod.z.object({enabled:zod.z.boolean().default(!0),allowed_tools:zod.z.array(zod.z.string().min(1)).optional()}),Xs=zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(t=>t.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),tool_configuration:Ws.optional(),authorization_token:zod.z.string().min(1).optional()}),Ys=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([kt,oo,ao])).min(1))}),Qs=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([kt,ao,Ks,Vs])).min(1))}),er=zod.z.union([Ys,Qs]),tr=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(er).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([Gs,Zs]).optional(),tools:zod.z.array(Js).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(Xs).min(1).optional()}),D=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional()}),L=class{constructor(t,n){this.version="v1";let o=D.parse(n);this.modelSchema=t,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=ce(ke.chatBaseUrl),this.completeChatUrl=ce(o.completeChatUrl||`${this.baseUrl}/messages`),this.streamChatUrl=ce(o.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,o=!0;return t["x-should-retry"]&&(o=t["x-should-retry"].toLowerCase()!=="false"),t["retry-after"]&&(n=parseInt(t["retry-after"])*1e3),{shouldRetry:o,delayMs:n}}getTokenCount(t){return t.reduce((n,o)=>n+o.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(t){let n=tr.safeParse(t);if(!n.success)throw new Ye({info:"Invalid model request",cause:n.error});let o=n.data,i=o.model;if(o.tool_choice&&(!o.tools||o.tools.length===0))throw new Ye({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let s={};o.tool_choice&&(o.tool_choice.type==="tool"?s.toolChoice=o.tool_choice.name:s.toolChoice=o.tool_choice.type),s.maxTokens=o.max_tokens,s.temperature=o.temperature,s.topP=o.top_p,s.topK=o.top_k,s.stop=o.stop_sequences;let r=Sn().parse(Fn(s)),l=[],d={};o.system&&l.push({role:me,content:[{modality:_,value:o.system}]}),o.messages.forEach(m=>{let h=m.role;switch(h){case"user":{let g=m.content;if(typeof g=="string")l.push({role:h,content:[{modality:_,value:g}]});else {let P=g.map(u=>{if(u.type==="text")return {modality:_,value:u.text};if(u.type==="image"){let T="auto",j=u.source.media_type.split("/")[1];return {modality:W,detail:T,value:{type:un,mediaType:j,base64:u.source.data}}}else return {modality:H,id:u.tool_use_id,index:d[u.tool_use_id].index,name:d[u.tool_use_id].name,data:typeof u.content=="string"?u.content:JSON.stringify(u.content)}});l.push({role:h,content:P});}}break;case"assistant":{let g=m.content;if(typeof g=="string")l.push({role:h,content:[{modality:_,value:g}]});else {let P=g.map((u,T)=>{if(u.type==="text")return {modality:_,value:u.text};{let j={modality:q,id:u.id,index:T,name:u.name,arguments:JSON.stringify(u.input)};return d[u.id]=j,j}});l.push({role:h,content:P});}}break}});let c=[];return o.tools&&o.tools.forEach(m=>{c.push({type:"function",definition:{schema:{name:m.name,description:m.description||"",parameters:m.input_schema}}});}),{modelName:i,config:r,messages:l,tools:c.length>0?c:void 0}}transformConfig(t,n,o){let i=t.toolChoice,s=t.reasoningEnabled,r=t.maxReasoningTokens,l=t.mcp,d=t.mcpServers,c=S({},t);delete c.toolChoice,delete c.reasoningEnabled,delete c.maxReasoningTokens,delete c.mcp,delete c.mcpServers;let m=this.modelSchema.config.schema.safeParse(c);if(!m.success)throw new Z({info:`Invalid config for model : '${this.modelName}'`,cause:m.error});let h=m.data;i!==void 0&&(h.toolChoice=i),Object.keys(h).forEach(T=>{if(!(T in this.modelSchema.config.def))throw new Z({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${T}',
13
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let g=Object.keys(h).reduce((T,j)=>{let J=this.modelSchema.config.def[j],G=J.param,te=h[j];return G==="max_tokens"&&J.type==="range"&&te===0?T[G]=J.max:T[G]=te,T},{});if(!g.max_tokens){let T=this.modelSchema.config.def.maxTokens;g.max_tokens=T.max;}if("tool_choice"in g&&g.tool_choice!==void 0){let T=g.tool_choice;if(!o||o&&o.length===0)throw new Z({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(o&&o.length>0){let j=this.modelSchema.config.def.toolChoice;if(j.choices.includes(T))g.tool_choice={type:T};else if(o.map(J=>J.definition.schema.name).includes(T))g.tool_choice={type:"tool",name:T};else throw new Z({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${T}' is not part of provided 'tools' names or
14
- one of [${j.choices.join(", ")}]`)})}}let P=s!==void 0,u=r!==void 0;if(P!==u)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&&u){let T=g.max_tokens;if(s)if(r<T)g.thinking={type:"enabled",budget_tokens:r};else throw new Z({info:`Invalid extended thinking token budget for model: '${this.modelName}'`,cause:new Error(`maxReasoningTokens (${r}) must be less than max_tokens (${T})`)})}return l&&d&&(g.mcp_servers=d),g}transformMessages(t){if(!t||t&&t.length===0)return {messages:[]};let n=r=>{let l=r.match(/^data:image\/[a-zA-Z]+;base64,/);return l?r.substring(l[0].length):r},o=t.map(r=>{let l=Mn().safeParse(r);if(!l.success)throw new N({info:"Invalid messages",cause:l.error});return l.data});o.forEach(r=>{r.content.forEach(l=>{if(!this.modelSchema.modalities.includes(l.modality))throw new N({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${l.modality}', available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),o.forEach(r=>{if(!Object.keys(this.modelSchema.roles).includes(r.role))throw new N({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${r.role}', available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let i="",s=[];if(o.forEach(r=>{switch(r.role){case me:{r.content.forEach(l=>{if(l.modality===_)i+=l.value;else throw new N({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${l.modality}'`)})});break}case R:{let l=[];r.content.forEach(d=>{if(d.modality===_)l.push({type:"text",text:d.value});else if(d.modality===q)d.serverName?l.push({type:"mcp_tool_use",id:d.id,name:d.name,server_name:d.serverName,input:JSON.parse(d.arguments)}):l.push({type:"tool_use",id:d.id,name:d.name,input:JSON.parse(d.arguments)});else if(d.modality===X&&d.value.type==="thinking")l.push({type:"thinking",thinking:d.value.thinking,signature:d.value.signature});else if(d.modality===X&&d.value.type==="redacted")l.push({type:"redacted_thinking",data:d.value.data});else if(d.modality===H)l.push({type:"mcp_tool_result",tool_use_id:d.id,content:JSON.parse(d.data),is_error:d.apiResponse&&d.apiResponse.statusCode!==200||!1});else throw new N({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${d.modality}'`)})}),s.push({role:this.modelSchema.roles[r.role],content:l});break}case ne:{let l=[];r.content.forEach(d=>{if(d.modality===_)l.push({type:"text",text:d.value});else if(d.modality===W){if(d.value.type==="base64"){let c=d.value.base64;c=n(c),l.push({type:"image",source:{type:"base64",media_type:`image/${d.value.mediaType}`,data:c}});}else if(d.value.type==="url")throw new N({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${d.value.type}'`)})}else throw new N({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${d.modality}'`)})}),s.push({role:this.modelSchema.roles[r.role],content:l});break}case st:{let l=[];r.content.forEach(d=>{if(d.modality===H)l.push({type:"tool_result",tool_use_id:d.id,content:d.data});else throw new N({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${d.modality}'`)})}),s.push({role:this.modelSchema.roles[r.role],content:l});break}default:throw new N({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' is not supported,
15
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),s[0].role!==this.modelSchema.roles[ne])throw new N({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:s}}transformTools(t){if(!this.modelSchema.modalities.includes(q))throw new ln({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${q}'`)});return !t||t&&t.length===0?{tools:[]}:{tools:t.map(n=>{let o=Ni().safeParse(n);if(!o.success)throw new ln({info:"Invalid tools",cause:o.error});return o.data}).map(n=>({name:n.definition.schema.name,description:n.definition.schema.description,input_schema:n.definition.schema.parameters}))}}getCompleteChatUrl(t,n,o){return B(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(t,n,o){return B(this,null,function*(){let i=this.getDefaultHeaders();if(t&&t.mcp&&t.mcpServers){let s=i["anthropic-beta"],r="mcp-client-2025-04-04";s?i=Y(S({},i),{"anthropic-beta":`${s},${r}`}):i=Y(S({},i),{"anthropic-beta":r});}return new Promise(s=>{s(i);})})}getCompleteChatData(t,n,o){return B(this,null,function*(){let i=this.transformConfig(t,n,o),s=this.transformMessages(n);if(s.messages&&s.messages.length===0)throw new N({info:"Messages are required",cause:new Error("Messages are required")});let r=o?this.transformTools(o):{};return new Promise(l=>{l(S(S(S(S({},this.getDefaultParams()),i),s),r));})})}transformCompleteChatResponse(t){let n=_s.safeParse(t);if(n.success){let o=n.data,i=o.content.map((l,d)=>{if(l.type==="text")return Ui(l.text);if(l.type==="tool_use")return Wt(d,l.id,l.name,JSON.stringify(l.input));if(l.type==="thinking")return qi(l.thinking,l.signature);if(l.type==="redacted_thinking")return Di(l.data);if(l.type==="mcp_tool_use")return Wt(d,l.id,l.name,JSON.stringify(l.input),l.server_name);if(l.type==="mcp_tool_result")return Li(d,l.tool_use_id,"mcp_tool_result",JSON.stringify(l.content),{statusCode:l.is_error?500:200})}),s=[{role:R,content:i}],r={promptTokens:o.usage.input_tokens,completionTokens:o.usage.output_tokens,totalTokens:o.usage.input_tokens+o.usage.output_tokens};return {messages:s,usage:r,logProbs:[]}}throw new K({info:"Invalid response from model",cause:n.error})}getStreamChatUrl(t,n,o){return B(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(t,n,o){return B(this,null,function*(){let i=this.getDefaultHeaders();if(t&&t.mcp&&t.mcpServers){let s=i["anthropic-beta"],r="mcp-client-2025-04-04";s?i=Y(S({},i),{"anthropic-beta":`${s},${r}`}):i=Y(S({},i),{"anthropic-beta":r});}return new Promise(s=>{s(i);})})}getStreamChatData(t,n,o){return B(this,null,function*(){let i=this.transformConfig(t,n,o),s=this.transformMessages(n);if(s.messages&&s.messages.length===0)throw new N({info:"Messages are required",cause:new Error("Messages are required")});let r=o?this.transformTools(o):{};return new Promise(l=>{l(S(S(S(S({stream:!0},this.getDefaultParams()),i),s),r));})})}transformStreamChatResponseChunk(t,n){return Vt(this,null,function*(){let o=n+t,i=[],s="",r=0;for(;r<o.length;){let l=o.indexOf(`
16
- `,r);if(l===-1){s=o.substring(r);break}else {let d=o.substring(r,l).trim();d&&i.push(d),r=l+1;}}for(let l of i)if(l.startsWith("data: {")&&l.endsWith("}")){let d;try{d=JSON.parse(l.substring(6));}catch(c){throw new K({info:`Malformed JSON received in stream : ${d}`,cause:c})}if("type"in d){if(d.type==="message_stop")return;if(d.type==="message_start"){let c=js.safeParse(d);if(c.success){let m=c.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:m.message.usage.input_tokens,completionTokens:m.message.usage.output_tokens,totalTokens:m.message.usage.input_tokens+m.message.usage.output_tokens}},buffer:n};}else throw new K({info:"Invalid response from model",cause:c.error})}else if(d.type==="message_delta"){let c=Es.safeParse(d);if(c.success){let m=c.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:void 0,completionTokens:m.usage.output_tokens,totalTokens:m.usage.output_tokens}},buffer:n};}else throw new K({info:"Invalid response from model",cause:c.error})}else if(d.type==="content_block_start"){let c=$s.safeParse(d);if(c.success){let m=c.data,h=[];m.content_block.type==="text"?h.push(Xt(R,m.content_block.text)):m.content_block.type==="tool_use"?h.push(Ze(R,m.index,m.content_block.id,m.content_block.name,"")):m.content_block.type==="thinking"?h.push(We(R,m.content_block.thinking)):m.content_block.type==="redacted_thinking"?h.push(Hi(R,m.content_block.data)):m.content_block.type==="mcp_tool_use"?h.push(Ze(R,m.index,m.content_block.id,m.content_block.name,JSON.stringify(m.content_block.input),m.content_block.server_name)):m.content_block.type==="mcp_tool_result"&&h.push($i(R,m.index,m.content_block.tool_use_id,"mcp_tool_result",JSON.stringify(m.content_block.content))),yield {partialResponse:{partialMessages:h},buffer:n};}else throw new K({info:"Invalid response from model",cause:c.error})}else if(d.type==="content_block_delta"){let c=zs.safeParse(d);if(c.success){let m=c.data,h=[];m.delta.type==="text_delta"?h.push(Xt(R,m.delta.text)):m.delta.type==="input_json_delta"?h.push(Ze(R,m.index,"","",m.delta.partial_json)):m.delta.type==="thinking_delta"?h.push(We(R,m.delta.thinking)):m.delta.type==="signature_delta"&&h.push(We(R,void 0,m.delta.signature)),yield {partialResponse:{partialMessages:h},buffer:n};}else throw new K({info:"Invalid response from model",cause:c.error})}}else throw new K({info:"Invalid JSON received in stream",cause:new Error(`Invalid JSON received in stream, expected 'type' property, received: ${JSON.stringify(d)}`)})}yield {partialResponse:{partialMessages:[]},buffer:s};})}transformProxyStreamChatResponseChunk(t,n,o,i,s){return Vt(this,null,function*(){yield*ye(Ba(this.transformStreamChatResponseChunk(t,n)));})}getProxyStreamChatUrl(t,n,o){return B(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getProxyCompleteChatUrl(t,n,o){return B(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyCompleteChatHeaders(t,n,o){return B(this,null,function*(){if(!n)return {};let i=S({},n);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(t,n,o){return B(this,null,function*(){return yield this.getProxyCompleteChatHeaders(t,n,o)})}getModelPricing(){if(!(this.modelName in V))throw new K({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return V[this.modelName]}},Qe="claude-4-opus-20250514",nr="Our high-performance model with exceptional reasoning and efficiency. Training cutoff: March 2025.",io=F(f,Se).parse({name:Qe,description:nr,maxInputTokens:2e5,maxOutputTokens:32e3,maxReasoningTokens:32e3,roles:y,modalities:xe,config:{def:w.extendedThinking(32e3,4,1024,32e3).def,schema:w.extendedThinking(32e3,4,1024,32e3).schema},price:V[Qe]}),or=D,ar=class extends L{constructor(t){super(io,t);}},et="claude-4-sonnet-20250514",ir="Our most capable and intelligent model yet. Training cutoff: March 2025.",so=F(f,Se).parse({name:et,description:ir,maxInputTokens:2e5,maxOutputTokens:64e3,maxReasoningTokens:64e3,roles:y,modalities:xe,config:{def:w.extendedThinking(64e3,4,1024,64e3).def,schema:w.extendedThinking(64e3,4,1024,64e3).schema},price:V[et]}),sr=D,rr=class extends L{constructor(t){super(so,t);}},tt="claude-sonnet-4-5-20250929",lr="Our best model for complex agents and coding, with the highest intelligence across most tasks. Training cutoff: July 2025.",ro=F(f,Se).parse({name:tt,description:lr,maxInputTokens:2e5,maxOutputTokens:64e3,maxReasoningTokens:64e3,roles:y,modalities:xe,config:{def:w.extendedThinking(64e3,4,1024,64e3).def,schema:w.extendedThinking(64e3,4,1024,64e3).schema},price:V[tt]}),dr=D,cr=class extends L{constructor(t){super(ro,t);}},nt="claude-3-5-sonnet-20240620",mr="Most intelligent model. Highest level of intelligence and capability.",lo=F(f,C).parse({name:nt,description:mr,maxInputTokens:2e5,maxOutputTokens:8192,roles:y,modalities:k,config:{def:w.base(8192,4).def,schema:w.base(8192,4).schema},price:V[nt]}),pr=D,ur=class extends L{constructor(t){super(lo,t);}},ot="claude-3-5-sonnet-20241022",hr="Most intelligent model. Highest level of intelligence and capability.",co=F(f,C).parse({name:ot,description:hr,maxInputTokens:2e5,maxOutputTokens:8192,roles:y,modalities:k,config:{def:w.base(8192,4).def,schema:w.base(8192,4).schema},price:V[ot]}),gr=D,fr=class extends L{constructor(t){super(co,t);}},at="claude-3-7-sonnet-20250219",yr="Most intelligent model. Highest level of intelligence and capability.",mo=F(f,Se).parse({name:at,description:yr,maxInputTokens:2e5,maxOutputTokens:128e3,maxReasoningTokens:64e3,roles:y,modalities:xe,config:{def:w.extendedThinking(128e3,4,1024,64e3).def,schema:w.extendedThinking(128e3,4,1024,64e3).schema},price:V[at]}),br=D,kr=class extends L{constructor(t){super(mo,t);}getDefaultHeaders(){let t=super.getDefaultHeaders(),n=t["anthropic-beta"],o="output-128k-2025-02-19";return n?t=Y(S({},t),{"anthropic-beta":`${n},${o}`}):t=Y(S({},t),{"anthropic-beta":o}),t}},po="claude-3-haiku-20240307",Cr="Fastest and most compact model for near-instant responsiveness. Quick and accurate targeted performance.",uo=F(f,C).parse({name:po,description:Cr,maxInputTokens:2e5,maxOutputTokens:4096,roles:y,modalities:k,config:{def:w.base(4096,4).def,schema:w.base(4096,4).schema}}),vr=D,Tr=class extends L{constructor(t){super(uo,t);}},it="claude-3-5-haiku-20241022",Mr="Our fastest model with intelligence at blazing speeds.",ho=F(f,C).parse({name:it,description:Mr,maxInputTokens:2e5,maxOutputTokens:8192,roles:y,modalities:k,config:{def:w.base(8192,4).def,schema:w.base(8192,4).schema},price:V[it]}),xr=D,Sr=class extends L{constructor(t){super(ho,t);}},go="claude-3-opus-20240229",wr="Powerful model for highly complex tasks. Top-level performance, intelligence, fluency, and understanding.",fo=F(f,C).parse({name:go,description:wr,maxInputTokens:2e5,maxOutputTokens:4096,roles:y,modalities:k,config:{def:w.base(4096,4).def,schema:w.base(4096,4).schema}}),Or=D,Pr=class extends L{constructor(t){super(fo,t);}},yo="claude-3-sonnet-20240229",Rr="Balance of intelligence and speed. Strong utility, balanced for scaled deployments.",bo=F(f,C).parse({name:yo,description:Rr,maxInputTokens:2e5,maxOutputTokens:4096,roles:y,modalities:k,config:{def:w.base(4096,4).def,schema:w.base(4096,4).schema}}),_r=D,jr=class extends L{constructor(t){super(bo,t);}},se=[oe],re=zod.z.enum([oe]),Er=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()})}),Ir=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)),Br=zod.z.object({model:zod.z.string().min(1).optional(),input:Ir,encoding_format:zod.z.enum(["base64"]).nullable().optional(),input_type:zod.z.enum(["query","document"]).nullable().optional(),truncation:zod.z.boolean().optional()}),ee=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),getEmbeddingsUrl:zod.z.string().url().optional()}),le=class{constructor(t,n){this.version="v1";let o=ee.parse(n);this.modelSchema=t,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=ce(ke.embeddingBaseUrl),this.getEmbeddingsUrl=ce(o.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,o)=>n+o.length,0)}getRetryDelay(t){return {shouldRetry:!0,delayMs:0}}transformModelRequest(t){let n=Br.safeParse(t);if(!n.success)throw new Ye({info:"Invalid model request",cause:n.error});let o=n.data,i=o.model,s={encodingFormat:o.encoding_format,inputType:o.input_type,truncation:o.truncation},r=Sn().parse(Fn(s)),l;return typeof o.input=="string"?l={modality:oe,requests:[o.input]}:l={modality:oe,requests:o.input},{modelName:i,config:r,embeddingRequests:l}}transformConfig(t,n){"inputType"in t&&t.inputType===""&&delete t.inputType,"encodingFormat"in t&&t.encodingFormat===""&&delete t.encodingFormat;let o=this.modelSchema.config.schema.safeParse(t);if(!o.success)throw new Z({info:`Invalid config for model : '${this.modelName}'`,cause:o.error});let i=o.data;return Object.keys(i).forEach(s=>{if(!this.modelSchema.config.def[s])throw new Z({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${s}',
17
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((s,r)=>{let l=this.modelSchema.config.def[r].param,d=i[r];return s[l]=d,s},{})}transformEmbeddingRequests(t){let n=bi().safeParse(t);if(!n.success)throw new cn({info:"Invalid embedding requests",cause:n.error});if(n.data.requests.length>128)throw new cn({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 B(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,n){return B(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,n){return B(this,null,function*(){return new Promise(o=>{o(S(S(S({},this.getDefaultParams()),this.transformConfig(t,n)),this.transformEmbeddingRequests(n)));})})}transformGetEmbeddingsResponse(t){let n,o=Er.safeParse(t);if(o.success){let i=o.data;n=typeof i.data[0].embedding=="string"?Pn:On;let s=i.data.map(r=>typeof r.embedding=="string"?{index:r.index,embedding:r.embedding}:{index:r.index,embedding:r.embedding});return {encodingFormat:n,embeddings:s,usage:{totalTokens:i.usage.total_tokens}}}throw new K({info:"Invalid response from model",cause:o.error})}},ko="voyage-code-2",Ar="Optimized for code retrieval.",Co=ie(re).parse({name:ko,description:Ar,modalities:se,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:U.base().def,schema:U.base().schema}}),Nr=ee,Ur=class extends le{constructor(t){super(Co,t);}},vo="voyage-law-2",Lr="Optimized for legal and long-context retrieval and RAG. Also improved performance across all domains.",To=ie(re).parse({name:vo,description:Lr,modalities:se,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:U.base().def,schema:U.base().schema}}),$r=ee,qr=class extends le{constructor(t){super(To,t);}},Mo="voyage-multilingual-2",Dr="Optimized for multilingual retrieval and RAG.",xo=ie(re).parse({name:Mo,description:Dr,modalities:se,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:U.base().def,schema:U.base().schema}}),Hr=ee,Fr=class extends le{constructor(t){super(xo,t);}},So="voyage-finance-2",zr="Optimized for finance retrieval and RAG.",wo=ie(re).parse({name:So,description:zr,modalities:se,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:U.base().def,schema:U.base().schema}}),Kr=ee,Vr=class extends le{constructor(t){super(wo,t);}},Oo="voyage-3-lite",Jr="Optimized for latency and cost.",Po=ie(re).parse({name:Oo,description:Jr,modalities:se,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:U.base().def,schema:U.base().schema}}),Gr=ee,Zr=class extends le{constructor(t){super(Po,t);}},Ro="voyage-3",Wr="Optimized for quality.",_o=ie(re).parse({name:Ro,description:Wr,modalities:se,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:U.base().def,schema:U.base().schema}}),Xr=ee,Yr=class extends le{constructor(t){super(_o,t);}};var Qr="system",el="user",Bo="assistant",tl="tool",nl=[Qr,el,Bo,tl],Tt=zod.z.enum(nl),ol=[Bo],al=zod.z.enum(ol),Ao="image",il="base64",sl=["png","jpeg","webp","gif"],rl=zod.z.object({type:zod.z.literal(il),base64:zod.z.string(),mediaType:zod.z.enum(sl)}),ll="url",dl=zod.z.object({type:zod.z.literal(ll),url:zod.z.string()}),cl=zod.z.discriminatedUnion("type",[rl,dl]),ml=["low","medium","high","auto"],pl=zod.z.enum(ml),ul=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ao),detail:pl,value:cl,metadata:t}),No="pdf",hl="base64",gl=zod.z.object({type:zod.z.literal(hl),base64:zod.z.string()}),fl="url",yl=zod.z.object({type:zod.z.literal(fl),url:zod.z.string()}),bl=zod.z.discriminatedUnion("type",[gl,yl]),kl=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(No),value:bl,file:zod.z.object({name:zod.z.string(),id:zod.z.string(),size:zod.z.number().optional()}),metadata:t}),Uo="reasoning",Lo="partial-reasoning",$o="thinking",Cl="redacted",vt=zod.z.object({type:zod.z.literal($o),thinking:zod.z.string(),signature:zod.z.string()}),qo=zod.z.object({type:zod.z.literal(Cl),data:zod.z.string()}),vl=zod.z.discriminatedUnion("type",[vt,qo]),Tl=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Uo),value:vl,metadata:t}),Ml=zod.z.object({type:zod.z.literal($o),thinking:vt.shape.thinking.optional(),signature:vt.shape.signature.optional()}),xl=zod.z.discriminatedUnion("type",[Ml,qo]),Sl=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Lo),value:xl,metadata:t}),Do="text",wl=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Do),value:zod.z.string(),metadata:t}),Ho="partial-text",Ol=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ho),value:zod.z.string(),metadata:t}),Fo="tool-call",Pl=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Fo),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:t}),zo="partial-tool-call",Rl=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(zo),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:t}),Ko="tool-response",_l=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ko),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:t}),jl="partial-tool-response",El=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(jl),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:t}),Il=[Do,Ao,No,Fo,Ko,Uo],Vo=zod.z.enum(Il),Bl=(t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[wl(t),ul(n),kl(o),Pl(i),_l(s),Tl(r)]),Al=[Ho,zo,Lo];zod.z.enum(Al);var Nl=(t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Ol(t),Rl(n),Sl(o),El(i)]);var Ul=(t=Tt,n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined(),l=zod.z.undefined(),d=zod.z.undefined())=>zod.z.object({role:t,content:zod.z.array(Bl(n,o,i,s,l,r)),metadata:d}),Ll=(t=al,n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.object({role:t,partialContent:Nl(n,o,i,r),metadata:s}),$l=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),jo=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),ql=jo.extend({topLogProbs:zod.z.array(jo)}),Jo=zod.z.array(ql);zod.z.object({messages:zod.z.array(Ul()),usage:$l.optional(),logProbs:Jo.optional()});var Dl=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(Ll()),usage:Dl.optional(),logProbs:Jo.optional()});var Hl=zod.z.object({enabled:zod.z.boolean().default(!0),allowedTools:zod.z.array(zod.z.string().min(1))});zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(t=>t.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),toolConfiguration:Hl.optional(),authorizationToken:zod.z.string().min(1).optional()});var Fl=["object","array","number","string","boolean","enum"],Eo=zod.z.enum(Fl),zl=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Eo,zod.z.array(zod.z.union([Eo,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()}),Kl=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(zl),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:Kl}).optional();var Vl="text",Jl="token",Gl=[Vl,Jl];zod.z.enum(Gl);zod.z.array(zod.z.string().min(1));zod.z.array(zod.z.array(zod.z.number().int().nonnegative()));var Wl="float",Xl=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),Yl="base64",Ql=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Io=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(Wl),embeddings:zod.z.array(Xl),usage:Io.optional()}),zod.z.object({encodingFormat:zod.z.literal(Yl),embeddings:zod.z.array(Ql),usage:Io.optional()})]);var ed=t=>{let n=new WeakSet;return JSON.stringify(t,(o,i)=>{if(typeof i=="object"&&i!==null){if(n.has(i))return;n.add(i);}return i})},td=t=>t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:ed(t),Ct="GatewayBaseError",Mt=class Go extends Error{constructor({info:n,cause:o},i){super(`[${i!=null?i:Ct}]: ${n}
18
- Message: ${td(o)}`),this.name=Ct,this.info=n,this.cause=o,this.name=i!=null?i:Ct,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(n){return n instanceof Go}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},nd=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."),od=zod.z.object({base:nd.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),ad=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:od.describe("Price categories and rates for this specific token range.")}).refine(t=>t.maxTokens===null||typeof t.maxTokens=="number"&&t.maxTokens>t.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");zod.z.object({modelName:zod.z.string().describe("Model name this schedule applies to."),currency:zod.z.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:zod.z.array(ad).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((t,n)=>{let{tokenRanges:o}=t;o[0].minTokens!==0&&n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let s=1;s<o.length;s++){let r=o[s-1],l=o[s];if(r.maxTokens===null){n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}l.minTokens!==r.maxTokens&&n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s,"minTokens"],message:`Tier ${s} minTokens (${l.minTokens}) must equal previous tier's maxTokens (${r.maxTokens}) for contiguity.`}),l.minTokens<r.minTokens&&n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${s} (${l.minTokens}) starts before Tier ${s-1} (${r.minTokens}).`});}let i=o[o.length-1];o.every(s=>s.maxTokens!==null||s===i)&&i.maxTokens!==null&&n.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 id="function";var sd=zod.z.enum(["object","array","number","string","boolean","null"]),rd=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:sd.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(rd).optional(),required:zod.z.array(zod.z.string()).optional()});var ld=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 dd=zod.z.enum(["function"]),cd=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),md=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:cd.optional()}),pd=zod.z.discriminatedUnion("type",[md]);zod.z.object({type:dd,definition:zod.z.object({schema:ld}),request:pd.optional()});var ud=[id];zod.z.enum(ud);var hd=Object.defineProperty,Zo=Object.getOwnPropertySymbols,gd=Object.prototype.hasOwnProperty,fd=Object.prototype.propertyIsEnumerable,Wo=(t,n,o)=>n in t?hd(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,yd=(t,n)=>{for(var o in n||(n={}))gd.call(n,o)&&Wo(t,o,n[o]);if(Zo)for(var o of Zo(n))fd.call(n,o)&&Wo(t,o,n[o]);return t},Xo="ProviderError",xt=class Qo extends Mt{constructor({info:n,cause:o}){super({info:n,cause:o},Xo),this.name=Xo,this.info=n,this.cause=o;}static isProviderError(n){return n instanceof Qo}};var Yo="ModelResponseError",St=class ea extends Mt{constructor({info:n,cause:o}){super({info:n,cause:o},Yo),this.name=Yo,this.cause=o,this.info=n;}static isModelResponseError(n){return n instanceof ea}};var ta="multi-string",bd=zod.z.object({type:zod.z.literal(ta),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()});var na="object-schema",kd=zod.z.object({type:zod.z.literal(na),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()});var oa="range",Cd=zod.z.object({type:zod.z.literal(oa),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()});var aa="select-boolean",vd=zod.z.object({type:zod.z.literal(aa),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()});var wt="select-string",ia=zod.z.object({type:zod.z.literal(wt),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())}),Td=(t,n)=>zod.z.enum(n).nullable().default(t).optional(),sa=t=>({def:ia.parse(yd({type:wt},t)),schema:Td(t.default,t.choices)}),Md=[oa,ta,wt,na,aa];zod.z.enum(Md);var xd=zod.z.discriminatedUnion("type",[Cd,bd,ia,vd,kd]),O=(t=Tt,n=Vo)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(t,zod.z.string().min(1).optional()),modalities:zod.z.array(n).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),xd),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var i,s;let r=Object.keys(o.def),l=Object.keys((s=(i=o.schema)==null?void 0:i.shape)!=null?s:{});return r.every(d=>l.includes(d))&&l.every(d=>r.includes(d))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()});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 Sd=()=>typeof window!="undefined"&&typeof window.document!="undefined"&&typeof navigator!="undefined";var ra=t=>{if(Sd()){let n=atob(t),o=new Uint8Array(n.length);for(let i=0;i<n.length;i++)o[i]=n.charCodeAt(i);return new TextDecoder("utf-8").decode(o)}else return Buffer.from(t,"base64").toString("utf-8")};var Ot=sa({param:"awsRegion",title:"AWS Region",description:"Controls which region the model will use to call AWS services.",default:"us-east-1",choices:["af-south-1","ap-east-1","ap-northeast-1","ap-northeast-2","ap-northeast-3","ap-south-1","ap-south-2","ap-southeast-1","ap-southeast-2","ap-southeast-3","ap-southeast-4","ca-central-1","ca-west-1","cn-north-1","cn-northwest-1","eu-central-1","eu-central-2","eu-north-1","eu-south-1","eu-south-2","eu-west-1","eu-west-2","eu-west-3","il-central-1","me-central-1","me-south-1","mx-central-1","sa-east-1","us-east-1","us-east-2","us-west-1","us-west-2"]});var la=(t,n)=>Te(t,n).extend({awsRegion:Ot.schema}),da=(t,n)=>z(E({},Me(t,n)),{awsRegion:Ot.def});var b={base:(t,n)=>({def:da(t,n),schema:la(t,n)})};var wd="bedrock",de=class de{constructor(){this.version="v1";this.name=wd;this.chatModelFactories={[Be]:{model:Ae,modelOptions:ha,modelSchema:Et},[Le]:{model:$e,modelOptions:fa,modelSchema:Bt},[Ne]:{model:Ue,modelOptions:ga,modelSchema:It},[Pe]:{model:Re,modelOptions:ma,modelSchema:Rt},[_e]:{model:je,modelOptions:pa,modelSchema:_t},[we]:{model:Oe,modelOptions:ca,modelSchema:Pt},[Ee]:{model:Ie,modelOptions:ua,modelSchema:jt},[He]:{model:Fe,modelOptions:ba,modelSchema:Nt},[ze]:{model:Ke,modelOptions:ka,modelSchema:Ut},[qe]:{model:De,modelOptions:ya,modelSchema:At}};this.embeddingModelFactories={};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((n,o)=>(n[o]=this.chatModelFactories[o].modelSchema,n),{})}chatModel(n){let o=n.modelName;if(!(o in this.chatModelFactories))throw new xt({info:`Bedrock chat model: ${o} not found`,cause:new Error(`Bedrock chat model: ${o} not found, available chat models:
19
- ${this.chatModelLiterals().join(", ")}`)});let i=this.chatModelFactories[o].model,s=this.chatModelFactories[o].modelOptions.parse(n);return new i(s)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((n,o)=>(n[o]=this.embeddingModelFactories[o].modelSchema,n),{})}embeddingModel(n){throw new xt({info:"Adaline Bedrock provider does not support embedding models yet",cause:new Error("Adaline Bedrock provider does not support embedding models yet")})}};de.awsService="bedrock",de.awsDefaultRegion="us-east-1",de.awsUrl=n=>`https://bedrock-runtime.${n!=null?n:de.awsDefaultRegion}.amazonaws.com`;var A=de;var M=zod.z.object({modelName:zod.z.string(),awsAccessKeyId:zod.z.string(),awsSecretAccessKey:zod.z.string()});var v={"anthropic.claude-3-5-haiku-20241022-v1:0":{modelName:"anthropic.claude-3-5-haiku-20241022-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1,outputPricePerMillion:5}}}]},"anthropic.claude-3-5-sonnet-20240620-v1:0":{modelName:"anthropic.claude-3-5-sonnet-20240620-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"anthropic.claude-3-5-sonnet-20241022-v2:0":{modelName:"anthropic.claude-3-5-sonnet-20241022-v2:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"anthropic.claude-3-haiku-20240307-v1:0":{modelName:"anthropic.claude-3-haiku-20240307-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.25,outputPricePerMillion:1.25}}}]},"anthropic.claude-3-opus-20240229-v1:0":{modelName:"anthropic.claude-3-opus-20240229-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:75}}}]},"anthropic.claude-3-sonnet-20240229-v1:0":{modelName:"anthropic.claude-3-sonnet-20240229-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"anthropic.claude-opus-4-20250514-v1:0":{modelName:"anthropic.claude-opus-4-20250514-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:75}}}]},"anthropic.claude-sonnet-4-20250514-v1:0":{modelName:"anthropic.claude-sonnet-4-20250514-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"anthropic.claude-sonnet-4-5-20250929-v1:0":{modelName:"anthropic.claude-sonnet-4-5-20250929-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"anthropic.claude-3-7-sonnet-20250219-v1:0":{modelName:"anthropic.claude-3-7-sonnet-20250219-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]}};var x=class t extends L{constructor(o,i){let s=M.parse(i);super(o,{apiKey:"random-api-key",modelName:s.modelName});this.version="v1";this.modelSchema=o,this.modelName=s.modelName,this.awsService=A.awsService,this.awsAccessKeyId=s.awsAccessKeyId,this.awsSecretAccessKey=s.awsSecretAccessKey;}getDefaultBaseUrl(){return A.awsUrl()}getDefaultHeaders(){return {Accept:"application/json","Content-Type":"application/json"}}getDefaultParams(){return {anthropic_version:"bedrock-2023-05-31"}}getCompleteChatUrl(o,i,s){let r=A.awsUrl(o==null?void 0:o.awsRegion);return new Promise(l=>{l(`${r}/model/${this.modelName}/invoke`);})}transformConfig(o,i,s){let r=E({},o);return delete r.awsRegion,super.transformConfig(r,i,s)}getCompleteChatHeaders(o,i,s){return $(this,null,function*(){let r=new URL(yield this.getCompleteChatUrl(o,i,s)),l={accessKeyId:this.awsAccessKeyId,secretAccessKey:this.awsSecretAccessKey},d=(o==null?void 0:o.awsRegion)||A.awsDefaultRegion,c=this.getDefaultHeaders();c=z(E({},c),{host:A.awsUrl(d).split("://")[1]});let m=yield this.getCompleteChatData(o||{},i||[],s),h=new protocolHttp.HttpRequest({hostname:r.hostname,path:r.pathname,protocol:r.protocol,method:"POST",body:JSON.stringify(m),headers:c});return (yield new signatureV4.SignatureV4({credentials:l,service:this.awsService,region:d,sha256:sha256Js.Sha256}).sign(h)).headers})}getCompleteChatData(o,i,s){return $(this,null,function*(){let r=E(E({},this.getDefaultParams()),yield ge(t.prototype,this,"getCompleteChatData").call(this,o,i,s));return new Promise(l=>{l(r);})})}getStreamChatUrl(o,i,s){return $(this,null,function*(){let r=A.awsUrl(o==null?void 0:o.awsRegion);return new Promise(l=>{l(`${r}/model/${this.modelName}/invoke-with-response-stream`);})})}getStreamChatHeaders(o,i,s){return $(this,null,function*(){let r=new URL(yield this.getStreamChatUrl(o,i,s)),l={accessKeyId:this.awsAccessKeyId,secretAccessKey:this.awsSecretAccessKey},d=(o==null?void 0:o.awsRegion)||A.awsDefaultRegion,c=this.getDefaultHeaders();c=z(E({},c),{host:A.awsUrl(d).split("://")[1]});let m=yield this.getCompleteChatData(o||{},i||[],s),h=new protocolHttp.HttpRequest({hostname:r.hostname,path:r.pathname,protocol:r.protocol,method:"POST",body:JSON.stringify(m),headers:c});return (yield new signatureV4.SignatureV4({credentials:l,service:this.awsService,region:d,sha256:sha256Js.Sha256}).sign(h)).headers})}getStreamChatData(o,i,s){return $(this,null,function*(){let r=E(E({},this.getDefaultParams()),yield ge(t.prototype,this,"getStreamChatData").call(this,o,i,s));return "stream"in r&&delete r.stream,r})}transformStreamChatResponseChunk(o,i){return Je(this,null,function*(){let s=o.toString(),r=/{\s*"bytes"\s*:\s*"[\w=+/]+".*?}/g,l=s.match(r)||[];for(let d of l){let c=d.indexOf("{"),m=d.indexOf("}");if(c!==-1&&m!==-1&&c<m){let h;try{h=JSON.parse(d.slice(c,m+1));}catch(u){throw new St({info:`Malformed JSON received in stream : ${h}`,cause:u})}let g=ra(h.bytes),P=(yield new fe(ge(t.prototype,this,"transformStreamChatResponseChunk").call(this,`data: ${g}`,i).next())).value;P&&(yield P);}}})}transformProxyStreamChatResponseChunk(o,i,s,r,l){return Je(this,null,function*(){yield*ye(this.transformStreamChatResponseChunk(o,i));})}getRegionHelper(o){var s;let i=o["aws-region"];if(!i){let r=(s=o.authorization)==null?void 0:s.match(/Credential=[^/]+\/\d+\/([^/]+)\/bedrock/);r&&(i=r[1]);}return i}getProxyStreamChatUrl(o,i,s){return $(this,null,function*(){let r=this.getRegionHelper(i||{}),l=A.awsUrl(r);return new Promise(d=>{d(`${l}/model/${this.modelName}/invoke-with-response-stream`);})})}getProxyChatHeaders(o,i,s,r){return $(this,null,function*(){let l=new URL(yield o());if(!s)return {};let d=s["aws-access-key-id"],c=s["aws-secret-access-key"],m=this.getRegionHelper(s);if(!d||!c)return {};let h={accessKeyId:d,secretAccessKey:c};s=z(E({},s),{host:l.host,"content-type":"application/json",accept:"application/json"}),delete s["content-length"];let g=s.authorization||s.Authorization;if(g){let j=g.match(/SignedHeaders=([^,]+)/);if(j&&j[1]){let J=j[1].split(";").map(G=>G.trim().toLowerCase());J.push("authorization"),s=Object.keys(s).reduce((G,te)=>{var Dt;return J.includes(te.toLowerCase())&&(G[te]=(Dt=s==null?void 0:s[te])!=null?Dt:""),G},{});}}let P=new protocolHttp.HttpRequest({hostname:l.hostname,path:l.pathname,protocol:l.protocol,method:"POST",body:JSON.stringify(i),headers:s});return (yield new signatureV4.SignatureV4({credentials:h,service:this.awsService,region:m,sha256:sha256Js.Sha256}).sign(P)).headers})}getProxyCompleteChatUrl(o,i,s){return $(this,null,function*(){let r=this.getRegionHelper(i||{}),l=A.awsUrl(r);return new Promise(d=>{d(`${l}/model/${this.modelName}/invoke`);})})}getProxyCompleteChatHeaders(o,i,s){return $(this,null,function*(){return this.getProxyChatHeaders(()=>this.getProxyCompleteChatUrl(o,i,s),o,i,s)})}getProxyStreamChatHeaders(o,i,s){return $(this,null,function*(){return this.getProxyChatHeaders(()=>this.getProxyStreamChatUrl(o,i,s),o,i,s)})}getModelPricing(){if(!(this.modelName in v))throw new St({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return v[this.modelName]}};var we="anthropic.claude-3-5-haiku-20241022-v1:0",Pd="Our fastest model with intelligence at blazing speeds.",Pt=O(f,C).parse({name:we,description:Pd,maxInputTokens:2e5,maxOutputTokens:8192,roles:y,modalities:k,config:{def:b.base(8192,4).def,schema:b.base(8192,4).schema},price:v[we]}),ca=M,Oe=class extends x{constructor(n){super(Pt,n);}};var Pe="anthropic.claude-3-5-sonnet-20240620-v1:0",Rd="Most intelligent model. Highest level of intelligence and capability.",Rt=O(f,C).parse({name:Pe,description:Rd,maxInputTokens:2e5,maxOutputTokens:8192,roles:y,modalities:k,config:{def:b.base(8192,4).def,schema:b.base(8192,4).schema},price:v[Pe]}),ma=M,Re=class extends x{constructor(n){super(Rt,n);}};var _e="anthropic.claude-3-5-sonnet-20241022-v2:0",_d="Most intelligent model. Highest level of intelligence and capability.",_t=O(f,C).parse({name:_e,description:_d,maxInputTokens:2e5,maxOutputTokens:8192,roles:y,modalities:k,config:{def:b.base(8192,4).def,schema:b.base(8192,4).schema},price:v[_e]}),pa=M,je=class extends x{constructor(n){super(_t,n);}};var Ee="anthropic.claude-3-7-sonnet-20250219-v1:0",jd="Most intelligent model. Highest level of intelligence and capability.",jt=O(f,C).parse({name:Ee,description:jd,maxInputTokens:2e5,maxOutputTokens:128e3,roles:y,modalities:k,config:{def:b.base(128e3,4).def,schema:b.base(128e3,4).schema},price:v[Ee]}),ua=M,Ie=class extends x{constructor(n){super(jt,n);}getDefaultHeaders(){let n=super.getDefaultHeaders(),o=n["anthropic-beta"],i="output-128k-2025-02-19";return o?n=z(E({},n),{"anthropic-beta":`${o},${i}`}):n=z(E({},n),{"anthropic-beta":i}),n}};var Be="anthropic.claude-3-haiku-20240307-v1:0",Ed="Claude 3 Haiku is a large-scale multimodal model trained by Anthropic. It is the successor to Claude 3 and is designed to be more powerful and capable than its predecessor.",Et=O(f,C).parse({name:Be,description:Ed,maxInputTokens:2e5,maxOutputTokens:4096,roles:y,modalities:k,config:{def:b.base(4096,4).def,schema:b.base(4096,4).schema},price:v[Be]}),ha=M,Ae=class extends x{constructor(n){super(Et,n);}};var Ne="anthropic.claude-3-opus-20240229-v1:0",Id="Powerful model for highly complex tasks. Top-level performance, intelligence, fluency, and understanding.",It=O(f,C).parse({name:Ne,description:Id,maxInputTokens:2e5,maxOutputTokens:4096,roles:y,modalities:k,config:{def:b.base(4096,4).def,schema:b.base(4096,4).schema},price:v[Ne]}),ga=M,Ue=class extends x{constructor(n){super(It,n);}};var Le="anthropic.claude-3-sonnet-20240229-v1:0",Bd="Balance of intelligence and speed. Strong utility, balanced for scaled deployments.",Bt=O(f,C).parse({name:Le,description:Bd,maxInputTokens:2e5,maxOutputTokens:4096,roles:y,modalities:k,config:{def:b.base(4096,4).def,schema:b.base(4096,4).schema},price:v[Le]}),fa=M,$e=class extends x{constructor(n){super(Bt,n);}};var qe="anthropic.claude-opus-4-20250514-v1:0",Ad="Our high-performance model with exceptional reasoning and efficiency. Training cutoff: March 2025.",At=O(f,C).parse({name:qe,description:Ad,maxInputTokens:2e5,maxOutputTokens:32e3,roles:y,modalities:k,config:{def:b.base(32e3,4).def,schema:b.base(32e3,4).schema},price:v[qe]}),ya=M,De=class extends x{constructor(n){super(At,n);}};var He="anthropic.claude-sonnet-4-20250514-v1:0",Nd="Our most capable and intelligent model yet. Training cutoff: March 2025.",Nt=O(f,C).parse({name:He,description:Nd,maxInputTokens:2e5,maxOutputTokens:64e3,roles:y,modalities:k,config:{def:b.base(64e3,4).def,schema:b.base(64e3,4).schema},price:v[He]}),ba=M,Fe=class extends x{constructor(n){super(Nt,n);}};var ze="anthropic.claude-sonnet-4-5-20250929-v1:0",Ud="Our best model for complex agents and coding, with the highest intelligence across most tasks. Training cutoff: July 2025.",Ut=O(f,C).parse({name:ze,description:Ud,maxInputTokens:2e5,maxOutputTokens:64e3,roles:y,modalities:k,config:{def:b.base(64e3,4).def,schema:b.base(64e3,4).schema},price:v[ze]}),ka=M,Ke=class extends x{constructor(n){super(Ut,n);}};
8
+ var va=Object.defineProperty,Ta=Object.defineProperties;var Ma=Object.getOwnPropertyDescriptors;var Ht=Object.getOwnPropertySymbols,xa=Object.getPrototypeOf,Sa=Object.prototype.hasOwnProperty,wa=Object.prototype.propertyIsEnumerable,Oa=Reflect.get;var oe=(t,n)=>(n=Symbol[t])?n:Symbol.for("Symbol."+t),Pa=t=>{throw TypeError(t)};var Ft=(t,n,o)=>n in t?va(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,_=(t,n)=>{for(var o in n||(n={}))Sa.call(n,o)&&Ft(t,o,n[o]);if(Ht)for(var o of Ht(n))wa.call(n,o)&&Ft(t,o,n[o]);return t},H=(t,n)=>Ta(t,Ma(n));var ye=(t,n,o)=>Oa(xa(t),o,n);var F=(t,n,o)=>new Promise((i,s)=>{var r=c=>{try{d(o.next(c));}catch(m){s(m);}},l=c=>{try{d(o.throw(c));}catch(m){s(m);}},d=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,l);d((o=o.apply(t,n)).next());}),pe=function(t,n){this[0]=t,this[1]=n;},Ze=(t,n,o)=>{var i=(l,d,c,m)=>{try{var h=o[l](d),g=(d=h.value)instanceof pe,P=h.done;Promise.resolve(g?d[0]:d).then(u=>g?i(l==="return"?l:"next",d[1]?{done:u.done,value:u.value}:u,c,m):c({value:u,done:P})).catch(u=>i("throw",u,c,m));}catch(u){m(u);}},s=l=>r[l]=d=>new Promise((c,m)=>i(l,d,c,m)),r={};return o=o.apply(t,n),r[oe("asyncIterator")]=()=>r,s("next"),s("throw"),s("return"),r},be=t=>{var n=t[oe("asyncIterator")],o=!1,i,s={};return n==null?(n=t[oe("iterator")](),i=r=>s[r]=l=>n[r](l)):(n=n.call(t),i=r=>s[r]=l=>{if(o){if(o=!1,r==="throw")throw l;return l}return o=!0,{done:!1,value:new pe(new Promise(d=>{var c=n[r](l);c instanceof Object||Pa("Object expected"),d(c);}),1)}}),s[oe("iterator")]=()=>s,i("next"),"throw"in n?i("throw"):s.throw=r=>{throw r},"return"in n&&i("return"),s},zt=(t,n,o)=>(n=t[oe("asyncIterator")])?n.call(t):(t=t[oe("iterator")](),n={},o=(i,s)=>(s=t[i])&&(n[i]=r=>new Promise((l,d,c)=>(r=s.call(t,r),c=r.done,Promise.resolve(r.value).then(m=>l({value:m,done:c}),d)))),o("next"),o("return"),n);var Ra=Object.defineProperty,_a=Object.defineProperties,ja=Object.getOwnPropertyDescriptors,Kt=Object.getOwnPropertySymbols,Ea=Object.prototype.hasOwnProperty,Ia=Object.prototype.propertyIsEnumerable,ke=(t,n)=>(n=Symbol[t])?n:Symbol.for("Symbol."+t),Ba=t=>{throw TypeError(t)},Vt=(t,n,o)=>n in t?Ra(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,S=(t,n)=>{for(var o in n||(n={}))Ea.call(n,o)&&Vt(t,o,n[o]);if(Kt)for(var o of Kt(n))Ia.call(n,o)&&Vt(t,o,n[o]);return t},ee=(t,n)=>_a(t,ja(n)),B=(t,n,o)=>new Promise((i,s)=>{var r=c=>{try{d(o.next(c));}catch(m){s(m);}},l=c=>{try{d(o.throw(c));}catch(m){s(m);}},d=c=>c.done?i(c.value):Promise.resolve(c.value).then(r,l);d((o=o.apply(t,n)).next());}),pn=function(t,n){this[0]=t,this[1]=n;},Jt=(t,n,o)=>{var i=(l,d,c,m)=>{try{var h=o[l](d),g=(d=h.value)instanceof pn,P=h.done;Promise.resolve(g?d[0]:d).then(u=>g?i(l==="return"?l:"next",d[1]?{done:u.done,value:u.value}:u,c,m):c({value:u,done:P})).catch(u=>i("throw",u,c,m));}catch(u){m(u);}},s=l=>r[l]=d=>new Promise((c,m)=>i(l,d,c,m)),r={};return o=o.apply(t,n),r[ke("asyncIterator")]=()=>r,s("next"),s("throw"),s("return"),r},Aa=t=>{var n=t[ke("asyncIterator")],o=!1,i,s={};return n==null?(n=t[ke("iterator")](),i=r=>s[r]=l=>n[r](l)):(n=n.call(t),i=r=>s[r]=l=>{if(o){if(o=!1,r==="throw")throw l;return l}return o=!0,{done:!1,value:new pn(new Promise(d=>{var c=n[r](l);c instanceof Object||Ba("Object expected"),d(c);}),1)}}),s[ke("iterator")]=()=>s,i("next"),"throw"in n?i("throw"):s.throw=r=>{throw r},"return"in n&&i("return"),s},he="system",ae="user",j="assistant",lt="tool",Na=[he,ae,j,lt],un=zod.z.enum(Na),Ua=[j],$a=zod.z.enum(Ua),Y="image",hn="base64",La=["png","jpeg","webp","gif"],Da=zod.z.object({type:zod.z.literal(hn),base64:zod.z.string(),mediaType:zod.z.enum(La)}),qa="url",Ha=zod.z.object({type:zod.z.literal(qa),url:zod.z.string()}),Fa=zod.z.discriminatedUnion("type",[Da,Ha]),za=["low","medium","high","auto"],Ka=zod.z.enum(za),Va=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Y),detail:Ka,value:Fa,metadata:t}),gn="pdf",Ja="base64",Ga=zod.z.object({type:zod.z.literal(Ja),base64:zod.z.string()}),Za="url",Wa=zod.z.object({type:zod.z.literal(Za),url:zod.z.string()}),Xa=zod.z.discriminatedUnion("type",[Ga,Wa]),Ya=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(gn),value:Xa,file:zod.z.object({name:zod.z.string(),id:zod.z.string(),size:zod.z.number().optional()}),metadata:t}),Q="reasoning",ve="partial-reasoning",Te="thinking",dt="redacted",Qe=zod.z.object({type:zod.z.literal(Te),thinking:zod.z.string(),signature:zod.z.string()}),fn=zod.z.object({type:zod.z.literal(dt),data:zod.z.string()}),Qa=zod.z.discriminatedUnion("type",[Qe,fn]),ct=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Q),value:Qa,metadata:t}),ei=zod.z.object({type:zod.z.literal(Te),thinking:Qe.shape.thinking.optional(),signature:Qe.shape.signature.optional()}),ti=zod.z.discriminatedUnion("type",[ei,fn]),mt=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ve),value:ti,metadata:t}),E="text",yn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(E),value:zod.z.string(),metadata:t}),pt="partial-text",bn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(pt),value:zod.z.string(),metadata:t}),z="tool-call",kn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(z),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:t}),ut="partial-tool-call",Cn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ut),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:t}),V="tool-response",vn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(V),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:t}),Tn="partial-tool-response",Mn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Tn),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:t}),ni=[E,Y,gn,z,V,Q],oi=zod.z.enum(ni),ai=(t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[yn(t),Va(n),Ya(o),kn(i),vn(s),ct(r)]),ii=[pt,ut,ve];zod.z.enum(ii);var si=(t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[bn(t),Cn(n),mt(o),Mn(i)]),xn=(t=un,n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined(),l=zod.z.undefined(),d=zod.z.undefined())=>zod.z.object({role:t,content:zod.z.array(ai(n,o,i,s,l,r)),metadata:d}),se=(t=$a,n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.object({role:t,partialContent:si(n,o,i,r),metadata:s}),ri=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Gt=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),li=Gt.extend({topLogProbs:zod.z.array(Gt)}),Sn=zod.z.array(li);zod.z.object({messages:zod.z.array(xn()),usage:ri.optional(),logProbs:Sn.optional()});var di=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:di.optional(),logProbs:Sn.optional()});var wn=(t=zod.z.record(zod.z.string(),zod.z.any()).optional())=>t,ci=zod.z.object({enabled:zod.z.boolean().default(!0),allowedTools:zod.z.array(zod.z.string().min(1))}),mi=zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(t=>t.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),toolConfiguration:ci.optional(),authorizationToken:zod.z.string().min(1).optional()}),pi=["object","array","number","string","boolean","enum"],Zt=zod.z.enum(pi),ui=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Zt,zod.z.array(zod.z.union([Zt,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()}),hi=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(ui),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:hi}).optional();var ie="text",On="token",gi=[ie,On],fi=zod.z.enum(gi),yi=zod.z.array(zod.z.string().min(1)),bi=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),ki=(t=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(ie),metadata:t,requests:yi}),zod.z.object({modality:zod.z.literal(On),metadata:t,requests:bi})]),Pn="float",Ci=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),Rn="base64",vi=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Wt=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(Pn),embeddings:zod.z.array(Ci),usage:Wt.optional()}),zod.z.object({encodingFormat:zod.z.literal(Rn),embeddings:zod.z.array(vi),usage:Wt.optional()})]);var Ti=t=>{let n=new WeakSet;return JSON.stringify(t,(o,i)=>{if(typeof i=="object"&&i!==null){if(n.has(i))return;n.add(i);}return i})},Mi=t=>t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:Ti(t),We="GatewayBaseError",te=class _n extends Error{constructor({info:n,cause:o},i){super(`[${i!=null?i:We}]: ${n}
9
+ Message: ${Mi(o)}`),this.name=We,this.info=n,this.cause=o,this.name=i!=null?i:We,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(n){return n instanceof _n}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},xi=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."),Si=zod.z.object({base:xi.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),wi=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:Si.describe("Price categories and rates for this specific token range.")}).refine(t=>t.maxTokens===null||typeof t.maxTokens=="number"&&t.maxTokens>t.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");zod.z.object({modelName:zod.z.string().describe("Model name this schedule applies to."),currency:zod.z.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:zod.z.array(wi).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((t,n)=>{let{tokenRanges:o}=t;o[0].minTokens!==0&&n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let s=1;s<o.length;s++){let r=o[s-1],l=o[s];if(r.maxTokens===null){n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}l.minTokens!==r.maxTokens&&n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s,"minTokens"],message:`Tier ${s} minTokens (${l.minTokens}) must equal previous tier's maxTokens (${r.maxTokens}) for contiguity.`}),l.minTokens<r.minTokens&&n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${s} (${l.minTokens}) starts before Tier ${s-1} (${r.minTokens}).`});}let i=o[o.length-1];o.every(s=>s.maxTokens!==null||s===i)&&i.maxTokens!==null&&n.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 Oi="function",Pi=zod.z.enum(["object","array","number","string","boolean","null"]),Ri=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:Pi.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(Ri).optional(),required:zod.z.array(zod.z.string()).optional()});var _i=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()}),ji=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()}),Ii=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()}),Bi=zod.z.discriminatedUnion("type",[Ii]),Ai=zod.z.object({type:ji,definition:zod.z.object({schema:_i}),request:Bi.optional()}),Ni=[Oi];zod.z.enum(Ni);var Ui=(t=zod.z.undefined())=>zod.z.discriminatedUnion("type",[Ai.extend({metadata:t})]),$i=t=>yn().parse({modality:E,value:t}),Xt=(t,n,o,i,s)=>kn().parse({modality:z,index:t,id:n,name:o,arguments:i,serverName:s}),Li=(t,n,o,i,s,r)=>vn().parse({modality:V,index:t,id:n,name:o,data:i,apiResponse:s,metadata:r}),Yt=(t,n)=>se().parse({role:t,partialContent:bn().parse({modality:pt,value:n})}),Xe=(t,n,o,i,s,r)=>se().parse({role:t,partialContent:Cn().parse({modality:ut,index:n,id:o,name:i,arguments:s,serverName:r})}),Di=(t,n,o,i,s)=>se().parse({role:t,partialContent:Mn().parse({modality:Tn,index:n,id:o,name:i,data:s})}),qi=(t,n)=>ct().parse({modality:Q,value:{type:Te,thinking:t,signature:n}}),Hi=t=>ct().parse({modality:Q,value:{type:dt,data:t}}),Ye=(t,n,o)=>se().parse({role:t,partialContent:mt().parse({modality:ve,value:{type:Te,thinking:n,signature:o}})}),Fi=(t,n)=>se().parse({role:t,partialContent:mt().parse({modality:ve,value:{type:dt,data:n}})}),zi=Object.defineProperty,Qt=Object.getOwnPropertySymbols,Ki=Object.prototype.hasOwnProperty,Vi=Object.prototype.propertyIsEnumerable,en=(t,n,o)=>n in t?zi(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,ge=(t,n)=>{for(var o in n||(n={}))Ki.call(n,o)&&en(t,o,n[o]);if(Qt)for(var o of Qt(n))Vi.call(n,o)&&en(t,o,n[o]);return t},tn="ProviderError",nn=class jn extends te{constructor({info:n,cause:o}){super({info:n,cause:o},tn),this.name=tn,this.info=n,this.cause=o;}static isProviderError(n){return n instanceof jn}},on="ModelResponseError",G=class En extends te{constructor({info:n,cause:o}){super({info:n,cause:o},on),this.name=on,this.cause=o,this.info=n;}static isModelResponseError(n){return n instanceof En}},an="InvalidModelRequestError",et=class In extends te{constructor({info:n,cause:o}){super({info:n,cause:o},an),this.name=an,this.cause=o,this.info=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(n){return n instanceof In}},sn="InvalidConfigError",X=class Bn extends te{constructor({info:n,cause:o}){super({info:n,cause:o},sn),this.name=sn,this.cause=o,this.info=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(n){return n instanceof Bn}},rn="InvalidMessagesError",$=class An extends te{constructor({info:n,cause:o}){super({info:n,cause:o},rn),this.name=rn,this.cause=o,this.info=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(n){return n instanceof An}},ln="InvalidToolsError",dn=class Nn extends te{constructor({info:n,cause:o}){super({info:n,cause:o},ln),this.name=ln,this.cause=o,this.info=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(n){return n instanceof Nn}},cn="InvalidEmbeddingRequestsError",mn=class Un extends te{constructor({info:n,cause:o}){super({info:n,cause:o},cn),this.name=cn,this.info=n,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(n){return n instanceof Un}},ht="multi-string",$n=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),max:zod.z.number().int().positive()}),Ji=t=>zod.z.array(zod.z.string()).max(t).default([]).optional(),Gi=t=>({def:$n.parse(ge({type:ht},t)),schema:Ji(t.max)}),gt="object-schema",Ln=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),objectSchema:zod.z.any()}),Zi=t=>t.optional(),Wi=t=>({def:Ln.parse(ge({type:gt},t)),schema:Zi(t.objectSchema)}),ft="range",Dn=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),min:zod.z.number().int(),max:zod.z.number().int(),step:zod.z.number().positive(),default:zod.z.number()}),Xi=(t,n,o,i)=>zod.z.number().min(t).max(n).step(o).default(i).optional(),fe=t=>({def:Dn.parse(ge({type:ft},t)),schema:Xi(t.min,t.max,t.step,t.default)}),yt="select-boolean",qn=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),default:zod.z.boolean().nullable()}),Yi=t=>zod.z.boolean().nullable().default(t).optional(),bt=t=>({def:qn.parse(ge({type:yt},t)),schema:Yi(t.default)}),kt="select-string",Hn=zod.z.object({type:zod.z.literal(kt),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())}),Qi=(t,n)=>zod.z.enum(n).nullable().default(t).optional(),Ct=t=>({def:Hn.parse(ge({type:kt},t)),schema:Qi(t.default,t.choices)}),es=[ft,ht,kt,gt,yt];zod.z.enum(es);var Fn=zod.z.discriminatedUnion("type",[Dn,$n,Hn,qn,Ln]),J=(t=un,n=oi)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(t,zod.z.string().min(1).optional()),modalities:zod.z.array(n).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),Fn),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var i,s;let r=Object.keys(o.def),l=Object.keys((s=(i=o.schema)==null?void 0:i.shape)!=null?s:{});return r.every(d=>l.includes(d))&&l.every(d=>r.includes(d))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()}),re=(t=fi)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(t).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Fn),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(n=>{var o,i;let s=Object.keys(n.def),r=Object.keys((i=(o=n.schema)==null?void 0:o.shape)!=null?i:{});return s.every(l=>r.includes(l))&&r.every(l=>s.includes(l))},{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 ts={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."},ns={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."},os={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},as=t=>({type:"multi",title:"Stop sequence",description:`Enter up to ${t} sequences that will halt additional text output. The generated text will exclude these sequences.`}),is={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."},ss={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."},rs={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."},ls={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."},ds={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."},cs={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."},ms={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."},ps={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."},us={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."},hs={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."},gs={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},fs={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."},ys={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."},bs={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."},ks={type:"object",title:"MCP servers",description:"MCP servers to use for the model."},I={TEMPERATURE:ts,MAX_TOKENS:ns,STOP:as,TOP_A:is,TOP_P:ss,TOP_K:rs,MIN_P:ls,FREQUENCY_PENALTY:ds,PRESENCE_PENALTY:cs,REPETITION_PENALTY:ps,SEED:ms,LOG_PROBS:us,TOP_LOG_PROBS:hs,ECHO:gs,RESPONSE_FORMAT:fs,RESPONSE_FORMAT_WITH_SCHEMA:ys,RESPONSE_SCHEMA:bs,MAX_REASONING_TOKENS:os,MCP_SERVERS:ks},zn=t=>Object.fromEntries(Object.entries(t).filter(([n,o])=>o!=null)),ue=t=>t==null?void 0:t.replace(/\/$/,""),Kn=fe({param:"temperature",title:I.TEMPERATURE.title,description:I.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),Vn=t=>fe({param:"max_tokens",title:I.MAX_TOKENS.title,description:I.MAX_TOKENS.description,min:0,max:t,step:1,default:0}),Jn=t=>Gi({param:"stop_sequences",title:I.STOP(t).title,description:I.STOP(t).description,max:t}),Gn=fe({param:"top_p",title:I.TOP_P.title,description:I.TOP_P.description,min:0,max:1,step:.01,default:1}),Zn=fe({param:"top_k",title:I.TOP_K.title,description:I.TOP_K.description,min:0,max:1,step:.01,default:1}),Wn=Ct({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"]}),Xn=bt({param:"mcp",title:"MCP",description:"Enable or disable Model Context Protocol (MCP) functionality for this model.",default:!1}),Yn=Wi({param:"mcp_servers",title:I.MCP_SERVERS.title,description:I.MCP_SERVERS.description,objectSchema:zod.z.array(mi)}),Me=(t,n)=>zod.z.object({temperature:Kn.schema,maxTokens:Vn(t).schema,stop:Jn(n).schema,topP:Gn.schema,topK:Zn.schema,toolChoice:Wn.schema,mcp:Xn.schema,mcpServers:Yn.schema}),xe=(t,n)=>({temperature:Kn.def,maxTokens:Vn(t).def,stop:Jn(n).def,topP:Gn.def,topK:Zn.def,toolChoice:Wn.def,mcp:Xn.def,mcpServers:Yn.def}),Qn=(t,n)=>fe({param:"max_reasoning_tokens",title:I.MAX_REASONING_TOKENS.title,description:I.MAX_REASONING_TOKENS.description,min:t,max:n,step:1,default:0}),eo=bt({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.
10
+ This can be useful for complex tasks that require more time to think.`,default:!1}),Cs=(t,n,o,i)=>ee(S({},xe(t,n)),{reasoningEnabled:eo.def,maxReasoningTokens:Qn(o,i).def}),vs=(t,n,o,i)=>Me(t,n).extend({reasoningEnabled:eo.schema,maxReasoningTokens:Qn(o,i).schema}),to=Ct({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"",choices:["base64",""]}),no=Ct({param:"input_type",title:"Input type",description:"Select the input type for the word embedding.",default:"",choices:["query","document",""]}),oo=bt({param:"truncation",title:"Truncation",description:"Select the truncation for the word embedding.",default:!0}),Ts=()=>zod.z.object({encodingFormat:to.schema,inputType:no.schema,truncation:oo.schema}),Ms=()=>({encodingFormat:to.def,inputType:no.def,truncation:oo.def}),w={base:(t,n)=>({def:xe(t,n),schema:Me(t,n)}),extendedThinking:(t,n,o,i)=>({def:Cs(t,n,o,i),schema:vs(t,n,o,i)})},L={base:()=>({def:Ms(),schema:Ts()})},xs="anthropic",Ce=class{constructor(){this.version="v1",this.name=xs,this.chatModelFactories={[uo]:{model:Mr,modelOptions:Tr,modelSchema:ho},[bo]:{model:Er,modelOptions:jr,modelSchema:ko},[fo]:{model:Rr,modelOptions:Pr,modelSchema:yo},[at]:{model:hr,modelOptions:ur,modelSchema:co},[it]:{model:yr,modelOptions:fr,modelSchema:mo},[rt]:{model:wr,modelOptions:Sr,modelSchema:go},[st]:{model:Cr,modelOptions:kr,modelSchema:po},[nt]:{model:lr,modelOptions:rr,modelSchema:ro},[ot]:{model:mr,modelOptions:cr,modelSchema:lo},[tt]:{model:ir,modelOptions:ar,modelSchema:so}},this.embeddingModelFactories={[_o]:{model:Qr,modelOptions:Yr,modelSchema:jo},[Po]:{model:Wr,modelOptions:Zr,modelSchema:Ro},[Co]:{model:$r,modelOptions:Ur,modelSchema:vo},[To]:{model:qr,modelOptions:Dr,modelSchema:Mo},[xo]:{model:zr,modelOptions:Fr,modelSchema:So},[wo]:{model:Jr,modelOptions:Vr,modelSchema:Oo}};}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 nn({info:`Anthropic chat model: ${n} not found`,cause:new Error(`Anthropic chat model: ${n} not found, available chat models:
11
+ ${this.chatModelLiterals().join(", ")}`)});let o=this.chatModelFactories[n].model,i=this.chatModelFactories[n].modelOptions.parse(t);return new o(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 nn({info:`Anthropic embedding model: ${n} not found`,cause:new Error(`Anthropic embedding model: ${n} not found, available embedding models:
12
+ ${this.embeddingModelLiterals().join(", ")}`)});let o=this.embeddingModelFactories[n].model,i=this.embeddingModelFactories[n].modelOptions.parse(t);return new o(i)}};Ce.chatBaseUrl="https://api.anthropic.com/v1",Ce.embeddingBaseUrl="https://api.voyageai.com/v1";var Z={"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}}}]}},f=zod.z.enum([he,ae,j,lt]),y={system:he,user:ae,assistant:j,tool:ae},k=[E,Y,z,V],C=zod.z.enum([E,Y,z,V]),Se=[E,Y,z,V,Q],we=zod.z.enum([E,Y,z,V,Q]),Ss=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),ws=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.record(zod.z.any())}),Os=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string(),signature:zod.z.string()}),Ps=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),Rs=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())}),_s=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())}),js=zod.z.object({content:zod.z.array(zod.z.discriminatedUnion("type",[Ss,ws,Os,Ps,Rs,_s])),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()})}),Es=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()})})}),Is=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()})}),Bs=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),As=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.object({})}),Ns=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string()}),Us=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),$s=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())}),Ls=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())}),Ds=zod.z.object({type:zod.z.literal("content_block_start"),index:zod.z.number(),content_block:zod.z.discriminatedUnion("type",[Bs,As,Ns,Us,$s,Ls])}),qs=zod.z.object({type:zod.z.literal("text_delta"),text:zod.z.string()}),Hs=zod.z.object({type:zod.z.literal("input_json_delta"),partial_json:zod.z.string()}),Fs=zod.z.object({type:zod.z.literal("thinking_delta"),thinking:zod.z.string()}),zs=zod.z.object({type:zod.z.literal("signature_delta"),signature:zod.z.string()}),Ks=zod.z.object({type:zod.z.literal("content_block_delta"),index:zod.z.number(),delta:zod.z.discriminatedUnion("type",[qs,Hs,Fs,zs])}),Vs=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string().optional(),signature:zod.z.string().optional()}),Js=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),Gs=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),input_schema:zod.z.any()}),Zs=zod.z.object({type:zod.z.enum(["auto","any"])}),Ws=zod.z.object({type:zod.z.literal("tool"),name:zod.z.string().min(1)}),vt=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),ao=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()})});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())});var io=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([vt,ao])).min(1))});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())});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())});var Xs=zod.z.object({enabled:zod.z.boolean().default(!0),allowed_tools:zod.z.array(zod.z.string().min(1)).optional()}),Ys=zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(t=>t.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),tool_configuration:Xs.optional(),authorization_token:zod.z.string().min(1).optional()}),Qs=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([vt,ao,io])).min(1))}),er=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([vt,io,Vs,Js])).min(1))}),tr=zod.z.union([Qs,er]),nr=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(tr).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([Zs,Ws]).optional(),tools:zod.z.array(Gs).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(Ys).min(1).optional()}),K=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional()}),D=class{constructor(t,n){this.version="v1";let o=K.parse(n);this.modelSchema=t,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=ue(Ce.chatBaseUrl),this.completeChatUrl=ue(o.completeChatUrl||`${this.baseUrl}/messages`),this.streamChatUrl=ue(o.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,o=!0;return t["x-should-retry"]&&(o=t["x-should-retry"].toLowerCase()!=="false"),t["retry-after"]&&(n=parseInt(t["retry-after"])*1e3),{shouldRetry:o,delayMs:n}}getTokenCount(t){return t.reduce((n,o)=>n+o.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(t){let n=nr.safeParse(t);if(!n.success)throw new et({info:"Invalid model request",cause:n.error});let o=n.data,i=o.model;if(o.tool_choice&&(!o.tools||o.tools.length===0))throw new et({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let s={};o.tool_choice&&(o.tool_choice.type==="tool"?s.toolChoice=o.tool_choice.name:s.toolChoice=o.tool_choice.type),s.maxTokens=o.max_tokens,s.temperature=o.temperature,s.topP=o.top_p,s.topK=o.top_k,s.stop=o.stop_sequences;let r=wn().parse(zn(s)),l=[],d={};o.system&&l.push({role:he,content:[{modality:E,value:o.system}]}),o.messages.forEach(m=>{let h=m.role;switch(h){case"user":{let g=m.content;if(typeof g=="string")l.push({role:h,content:[{modality:E,value:g}]});else {let P=g.map(u=>{if(u.type==="text")return {modality:E,value:u.text};if(u.type==="image"){let v="auto",R=u.source.media_type.split("/")[1];return {modality:Y,detail:v,value:{type:hn,mediaType:R,base64:u.source.data}}}else return {modality:V,id:u.tool_use_id,index:d[u.tool_use_id].index,name:d[u.tool_use_id].name,data:typeof u.content=="string"?u.content:JSON.stringify(u.content)}});l.push({role:h,content:P});}}break;case"assistant":{let g=m.content;if(typeof g=="string")l.push({role:h,content:[{modality:E,value:g}]});else {let P=g.map((u,v)=>{if(u.type==="text")return {modality:E,value:u.text};{let R={modality:z,id:u.id,index:v,name:u.name,arguments:JSON.stringify(u.input)};return d[u.id]=R,R}});l.push({role:h,content:P});}}break}});let c=[];return o.tools&&o.tools.forEach(m=>{c.push({type:"function",definition:{schema:{name:m.name,description:m.description||"",parameters:m.input_schema}}});}),{modelName:i,config:r,messages:l,tools:c.length>0?c:void 0}}transformConfig(t,n,o){let i=t.toolChoice,s=t.reasoningEnabled,r=t.maxReasoningTokens,l=t.mcp,d=t.mcpServers,c=S({},t);delete c.toolChoice,delete c.reasoningEnabled,delete c.maxReasoningTokens,delete c.mcp,delete c.mcpServers;let m=this.modelSchema.config.schema.safeParse(c);if(!m.success)throw new X({info:`Invalid config for model : '${this.modelName}'`,cause:m.error});let h=m.data;i!==void 0&&(h.toolChoice=i),Object.keys(h).forEach(v=>{if(!(v in this.modelSchema.config.def))throw new X({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${v}',
13
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let g=Object.keys(h).reduce((v,R)=>{let N=this.modelSchema.config.def[R],q=N.param,W=h[R];return q==="max_tokens"&&N.type==="range"&&W===0?v[q]=N.max:v[q]=W,v},{});if(!g.max_tokens){let v=this.modelSchema.config.def.maxTokens;g.max_tokens=v.max;}if("tool_choice"in g&&g.tool_choice!==void 0){let v=g.tool_choice;if(!o||o&&o.length===0)throw new X({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(o&&o.length>0){let R=this.modelSchema.config.def.toolChoice;if(R.choices.includes(v))g.tool_choice={type:v};else if(o.map(N=>N.definition.schema.name).includes(v))g.tool_choice={type:"tool",name:v};else throw new X({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${v}' is not part of provided 'tools' names or
14
+ one of [${R.choices.join(", ")}]`)})}}let P=s!==void 0,u=r!==void 0;if(P!==u)throw new X({info:`Invalid extended thinking config for model: '${this.modelName}'`,cause:new Error("Both 'reasoningEnabled' and 'maxReasoningTokens' must be defined together.")});if(P&&u){let v=g.max_tokens;if(s)if(r<v)g.thinking={type:"enabled",budget_tokens:r};else throw new X({info:`Invalid extended thinking token budget for model: '${this.modelName}'`,cause:new Error(`maxReasoningTokens (${r}) must be less than max_tokens (${v})`)})}return l&&d&&(g.mcp_servers=d),g}transformMessages(t){if(!t||t&&t.length===0)return {messages:[]};let n=r=>{let l=r.match(/^data:image\/[a-zA-Z]+;base64,/);return l?r.substring(l[0].length):r},o=t.map(r=>{let l=xn().safeParse(r);if(!l.success)throw new $({info:"Invalid messages",cause:l.error});return l.data});o.forEach(r=>{r.content.forEach(l=>{if(!this.modelSchema.modalities.includes(l.modality))throw new $({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${l.modality}', available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),o.forEach(r=>{if(!Object.keys(this.modelSchema.roles).includes(r.role))throw new $({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${r.role}', available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let i="",s=[];if(o.forEach(r=>{switch(r.role){case he:{r.content.forEach(l=>{if(l.modality===E)i+=l.value;else throw new $({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${l.modality}'`)})});break}case j:{let l=[];r.content.forEach(d=>{if(d.modality===E)l.push({type:"text",text:d.value});else if(d.modality===z)d.serverName?l.push({type:"mcp_tool_use",id:d.id,name:d.name,server_name:d.serverName,input:JSON.parse(d.arguments)}):l.push({type:"tool_use",id:d.id,name:d.name,input:JSON.parse(d.arguments)});else if(d.modality===Q&&d.value.type==="thinking")l.push({type:"thinking",thinking:d.value.thinking,signature:d.value.signature});else if(d.modality===Q&&d.value.type==="redacted")l.push({type:"redacted_thinking",data:d.value.data});else if(d.modality===V)l.push({type:"mcp_tool_result",tool_use_id:d.id,content:JSON.parse(d.data),is_error:d.apiResponse&&d.apiResponse.statusCode!==200||!1});else throw new $({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${d.modality}'`)})}),s.push({role:this.modelSchema.roles[r.role],content:l});break}case ae:{let l=[];r.content.forEach(d=>{if(d.modality===E)l.push({type:"text",text:d.value});else if(d.modality===Y){if(d.value.type==="base64"){let c=d.value.base64;c=n(c),l.push({type:"image",source:{type:"base64",media_type:`image/${d.value.mediaType}`,data:c}});}else if(d.value.type==="url")throw new $({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${d.value.type}'`)})}else throw new $({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${d.modality}'`)})}),s.push({role:this.modelSchema.roles[r.role],content:l});break}case lt:{let l=[];r.content.forEach(d=>{if(d.modality===V)l.push({type:"tool_result",tool_use_id:d.id,content:d.data});else throw new $({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${d.modality}'`)})}),s.push({role:this.modelSchema.roles[r.role],content:l});break}default:throw new $({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' is not supported,
15
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),s[0].role!==this.modelSchema.roles[ae])throw new $({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:s}}transformTools(t){if(!this.modelSchema.modalities.includes(z))throw new dn({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${z}'`)});return !t||t&&t.length===0?{tools:[]}:{tools:t.map(n=>{let o=Ui().safeParse(n);if(!o.success)throw new dn({info:"Invalid tools",cause:o.error});return o.data}).map(n=>({name:n.definition.schema.name,description:n.definition.schema.description,input_schema:n.definition.schema.parameters}))}}getCompleteChatUrl(t,n,o){return B(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(t,n,o){return B(this,null,function*(){let i=this.getDefaultHeaders();if(t&&t.mcp&&t.mcpServers){let s=i["anthropic-beta"],r="mcp-client-2025-04-04";s?i=ee(S({},i),{"anthropic-beta":`${s},${r}`}):i=ee(S({},i),{"anthropic-beta":r});}return new Promise(s=>{s(i);})})}getCompleteChatData(t,n,o){return B(this,null,function*(){let i=this.transformConfig(t,n,o),s=this.transformMessages(n);if(s.messages&&s.messages.length===0)throw new $({info:"Messages are required",cause:new Error("Messages are required")});let r=o?this.transformTools(o):{};return new Promise(l=>{l(S(S(S(S({},this.getDefaultParams()),i),s),r));})})}transformCompleteChatResponse(t){let n=js.safeParse(t);if(n.success){let o=n.data,i=o.content.map((l,d)=>{if(l.type==="text")return $i(l.text);if(l.type==="tool_use")return Xt(d,l.id,l.name,JSON.stringify(l.input));if(l.type==="thinking")return qi(l.thinking,l.signature);if(l.type==="redacted_thinking")return Hi(l.data);if(l.type==="mcp_tool_use")return Xt(d,l.id,l.name,JSON.stringify(l.input),l.server_name);if(l.type==="mcp_tool_result")return Li(d,l.tool_use_id,"mcp_tool_result",JSON.stringify(l.content),{statusCode:l.is_error?500:200})}),s=[{role:j,content:i}],r={promptTokens:o.usage.input_tokens,completionTokens:o.usage.output_tokens,totalTokens:o.usage.input_tokens+o.usage.output_tokens};return {messages:s,usage:r,logProbs:[]}}throw new G({info:"Invalid response from model",cause:n.error})}getStreamChatUrl(t,n,o){return B(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(t,n,o){return B(this,null,function*(){let i=this.getDefaultHeaders();if(t&&t.mcp&&t.mcpServers){let s=i["anthropic-beta"],r="mcp-client-2025-04-04";s?i=ee(S({},i),{"anthropic-beta":`${s},${r}`}):i=ee(S({},i),{"anthropic-beta":r});}return new Promise(s=>{s(i);})})}getStreamChatData(t,n,o){return B(this,null,function*(){let i=this.transformConfig(t,n,o),s=this.transformMessages(n);if(s.messages&&s.messages.length===0)throw new $({info:"Messages are required",cause:new Error("Messages are required")});let r=o?this.transformTools(o):{};return new Promise(l=>{l(S(S(S(S({stream:!0},this.getDefaultParams()),i),s),r));})})}transformStreamChatResponseChunk(t,n){return Jt(this,null,function*(){let o=n+t,i=[],s="",r=0;for(;r<o.length;){let l=o.indexOf(`
16
+ `,r);if(l===-1){s=o.substring(r);break}else {let d=o.substring(r,l).trim();d&&i.push(d),r=l+1;}}for(let l of i)if(l.startsWith("data: {")&&l.endsWith("}")){let d;try{d=JSON.parse(l.substring(6));}catch(c){throw new G({info:`Malformed JSON received in stream : ${d}`,cause:c})}if("type"in d){if(d.type==="message_stop")return;if(d.type==="message_start"){let c=Es.safeParse(d);if(c.success){let m=c.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:m.message.usage.input_tokens,completionTokens:m.message.usage.output_tokens,totalTokens:m.message.usage.input_tokens+m.message.usage.output_tokens}},buffer:n};}else throw new G({info:"Invalid response from model",cause:c.error})}else if(d.type==="message_delta"){let c=Is.safeParse(d);if(c.success){let m=c.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:void 0,completionTokens:m.usage.output_tokens,totalTokens:m.usage.output_tokens}},buffer:n};}else throw new G({info:"Invalid response from model",cause:c.error})}else if(d.type==="content_block_start"){let c=Ds.safeParse(d);if(c.success){let m=c.data,h=[];m.content_block.type==="text"?h.push(Yt(j,m.content_block.text)):m.content_block.type==="tool_use"?h.push(Xe(j,m.index,m.content_block.id,m.content_block.name,"")):m.content_block.type==="thinking"?h.push(Ye(j,m.content_block.thinking)):m.content_block.type==="redacted_thinking"?h.push(Fi(j,m.content_block.data)):m.content_block.type==="mcp_tool_use"?h.push(Xe(j,m.index,m.content_block.id,m.content_block.name,JSON.stringify(m.content_block.input),m.content_block.server_name)):m.content_block.type==="mcp_tool_result"&&h.push(Di(j,m.index,m.content_block.tool_use_id,"mcp_tool_result",JSON.stringify(m.content_block.content))),yield {partialResponse:{partialMessages:h},buffer:n};}else throw new G({info:"Invalid response from model",cause:c.error})}else if(d.type==="content_block_delta"){let c=Ks.safeParse(d);if(c.success){let m=c.data,h=[];m.delta.type==="text_delta"?h.push(Yt(j,m.delta.text)):m.delta.type==="input_json_delta"?h.push(Xe(j,m.index,"","",m.delta.partial_json)):m.delta.type==="thinking_delta"?h.push(Ye(j,m.delta.thinking)):m.delta.type==="signature_delta"&&h.push(Ye(j,void 0,m.delta.signature)),yield {partialResponse:{partialMessages:h},buffer:n};}else throw new G({info:"Invalid response from model",cause:c.error})}}else throw new G({info:"Invalid JSON received in stream",cause:new Error(`Invalid JSON received in stream, expected 'type' property, received: ${JSON.stringify(d)}`)})}yield {partialResponse:{partialMessages:[]},buffer:s};})}transformProxyStreamChatResponseChunk(t,n,o,i,s){return Jt(this,null,function*(){yield*be(Aa(this.transformStreamChatResponseChunk(t,n)));})}getProxyStreamChatUrl(t,n,o){return B(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getProxyCompleteChatUrl(t,n,o){return B(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyCompleteChatHeaders(t,n,o){return B(this,null,function*(){if(!n)return {};let i=S({},n);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(t,n,o){return B(this,null,function*(){return yield this.getProxyCompleteChatHeaders(t,n,o)})}getModelPricing(){if(!(this.modelName in Z))throw new G({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return Z[this.modelName]}},tt="claude-4-opus-20250514",or="Our high-performance model with exceptional reasoning and efficiency. Training cutoff: March 2025.",so=J(f,we).parse({name:tt,description:or,maxInputTokens:2e5,maxOutputTokens:32e3,maxReasoningTokens:32e3,roles:y,modalities:Se,config:{def:w.extendedThinking(32e3,4,1024,32e3).def,schema:w.extendedThinking(32e3,4,1024,32e3).schema},price:Z[tt]}),ar=K,ir=class extends D{constructor(t){super(so,t);}},nt="claude-4-sonnet-20250514",sr="Our most capable and intelligent model yet. Training cutoff: March 2025.",ro=J(f,we).parse({name:nt,description:sr,maxInputTokens:2e5,maxOutputTokens:64e3,maxReasoningTokens:64e3,roles:y,modalities:Se,config:{def:w.extendedThinking(64e3,4,1024,64e3).def,schema:w.extendedThinking(64e3,4,1024,64e3).schema},price:Z[nt]}),rr=K,lr=class extends D{constructor(t){super(ro,t);}},ot="claude-sonnet-4-5-20250929",dr="Our best model for complex agents and coding, with the highest intelligence across most tasks. Training cutoff: July 2025.",lo=J(f,we).parse({name:ot,description:dr,maxInputTokens:2e5,maxOutputTokens:64e3,maxReasoningTokens:64e3,roles:y,modalities:Se,config:{def:w.extendedThinking(64e3,4,1024,64e3).def,schema:w.extendedThinking(64e3,4,1024,64e3).schema},price:Z[ot]}),cr=K,mr=class extends D{constructor(t){super(lo,t);}},at="claude-3-5-sonnet-20240620",pr="Most intelligent model. Highest level of intelligence and capability.",co=J(f,C).parse({name:at,description:pr,maxInputTokens:2e5,maxOutputTokens:8192,roles:y,modalities:k,config:{def:w.base(8192,4).def,schema:w.base(8192,4).schema},price:Z[at]}),ur=K,hr=class extends D{constructor(t){super(co,t);}},it="claude-3-5-sonnet-20241022",gr="Most intelligent model. Highest level of intelligence and capability.",mo=J(f,C).parse({name:it,description:gr,maxInputTokens:2e5,maxOutputTokens:8192,roles:y,modalities:k,config:{def:w.base(8192,4).def,schema:w.base(8192,4).schema},price:Z[it]}),fr=K,yr=class extends D{constructor(t){super(mo,t);}},st="claude-3-7-sonnet-20250219",br="Most intelligent model. Highest level of intelligence and capability.",po=J(f,we).parse({name:st,description:br,maxInputTokens:2e5,maxOutputTokens:128e3,maxReasoningTokens:64e3,roles:y,modalities:Se,config:{def:w.extendedThinking(128e3,4,1024,64e3).def,schema:w.extendedThinking(128e3,4,1024,64e3).schema},price:Z[st]}),kr=K,Cr=class extends D{constructor(t){super(po,t);}getDefaultHeaders(){let t=super.getDefaultHeaders(),n=t["anthropic-beta"],o="output-128k-2025-02-19";return n?t=ee(S({},t),{"anthropic-beta":`${n},${o}`}):t=ee(S({},t),{"anthropic-beta":o}),t}},uo="claude-3-haiku-20240307",vr="Fastest and most compact model for near-instant responsiveness. Quick and accurate targeted performance.",ho=J(f,C).parse({name:uo,description:vr,maxInputTokens:2e5,maxOutputTokens:4096,roles:y,modalities:k,config:{def:w.base(4096,4).def,schema:w.base(4096,4).schema}}),Tr=K,Mr=class extends D{constructor(t){super(ho,t);}},rt="claude-3-5-haiku-20241022",xr="Our fastest model with intelligence at blazing speeds.",go=J(f,C).parse({name:rt,description:xr,maxInputTokens:2e5,maxOutputTokens:8192,roles:y,modalities:k,config:{def:w.base(8192,4).def,schema:w.base(8192,4).schema},price:Z[rt]}),Sr=K,wr=class extends D{constructor(t){super(go,t);}},fo="claude-3-opus-20240229",Or="Powerful model for highly complex tasks. Top-level performance, intelligence, fluency, and understanding.",yo=J(f,C).parse({name:fo,description:Or,maxInputTokens:2e5,maxOutputTokens:4096,roles:y,modalities:k,config:{def:w.base(4096,4).def,schema:w.base(4096,4).schema}}),Pr=K,Rr=class extends D{constructor(t){super(yo,t);}},bo="claude-3-sonnet-20240229",_r="Balance of intelligence and speed. Strong utility, balanced for scaled deployments.",ko=J(f,C).parse({name:bo,description:_r,maxInputTokens:2e5,maxOutputTokens:4096,roles:y,modalities:k,config:{def:w.base(4096,4).def,schema:w.base(4096,4).schema}}),jr=K,Er=class extends D{constructor(t){super(ko,t);}},le=[ie],de=zod.z.enum([ie]),Ir=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()})}),Br=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)),Ar=zod.z.object({model:zod.z.string().min(1).optional(),input:Br,encoding_format:zod.z.enum(["base64"]).nullable().optional(),input_type:zod.z.enum(["query","document"]).nullable().optional(),truncation:zod.z.boolean().optional()}),ne=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),getEmbeddingsUrl:zod.z.string().url().optional()}),ce=class{constructor(t,n){this.version="v1";let o=ne.parse(n);this.modelSchema=t,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=ue(Ce.embeddingBaseUrl),this.getEmbeddingsUrl=ue(o.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,o)=>n+o.length,0)}getRetryDelay(t){return {shouldRetry:!0,delayMs:0}}transformModelRequest(t){let n=Ar.safeParse(t);if(!n.success)throw new et({info:"Invalid model request",cause:n.error});let o=n.data,i=o.model,s={encodingFormat:o.encoding_format,inputType:o.input_type,truncation:o.truncation},r=wn().parse(zn(s)),l;return typeof o.input=="string"?l={modality:ie,requests:[o.input]}:l={modality:ie,requests:o.input},{modelName:i,config:r,embeddingRequests:l}}transformConfig(t,n){"inputType"in t&&t.inputType===""&&delete t.inputType,"encodingFormat"in t&&t.encodingFormat===""&&delete t.encodingFormat;let o=this.modelSchema.config.schema.safeParse(t);if(!o.success)throw new X({info:`Invalid config for model : '${this.modelName}'`,cause:o.error});let i=o.data;return Object.keys(i).forEach(s=>{if(!this.modelSchema.config.def[s])throw new X({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${s}',
17
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((s,r)=>{let l=this.modelSchema.config.def[r].param,d=i[r];return s[l]=d,s},{})}transformEmbeddingRequests(t){let n=ki().safeParse(t);if(!n.success)throw new mn({info:"Invalid embedding requests",cause:n.error});if(n.data.requests.length>128)throw new mn({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 B(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,n){return B(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,n){return B(this,null,function*(){return new Promise(o=>{o(S(S(S({},this.getDefaultParams()),this.transformConfig(t,n)),this.transformEmbeddingRequests(n)));})})}transformGetEmbeddingsResponse(t){let n,o=Ir.safeParse(t);if(o.success){let i=o.data;n=typeof i.data[0].embedding=="string"?Rn:Pn;let s=i.data.map(r=>typeof r.embedding=="string"?{index:r.index,embedding:r.embedding}:{index:r.index,embedding:r.embedding});return {encodingFormat:n,embeddings:s,usage:{totalTokens:i.usage.total_tokens}}}throw new G({info:"Invalid response from model",cause:o.error})}},Co="voyage-code-2",Nr="Optimized for code retrieval.",vo=re(de).parse({name:Co,description:Nr,modalities:le,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:L.base().def,schema:L.base().schema}}),Ur=ne,$r=class extends ce{constructor(t){super(vo,t);}},To="voyage-law-2",Lr="Optimized for legal and long-context retrieval and RAG. Also improved performance across all domains.",Mo=re(de).parse({name:To,description:Lr,modalities:le,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:L.base().def,schema:L.base().schema}}),Dr=ne,qr=class extends ce{constructor(t){super(Mo,t);}},xo="voyage-multilingual-2",Hr="Optimized for multilingual retrieval and RAG.",So=re(de).parse({name:xo,description:Hr,modalities:le,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:L.base().def,schema:L.base().schema}}),Fr=ne,zr=class extends ce{constructor(t){super(So,t);}},wo="voyage-finance-2",Kr="Optimized for finance retrieval and RAG.",Oo=re(de).parse({name:wo,description:Kr,modalities:le,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:L.base().def,schema:L.base().schema}}),Vr=ne,Jr=class extends ce{constructor(t){super(Oo,t);}},Po="voyage-3-lite",Gr="Optimized for latency and cost.",Ro=re(de).parse({name:Po,description:Gr,modalities:le,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:L.base().def,schema:L.base().schema}}),Zr=ne,Wr=class extends ce{constructor(t){super(Ro,t);}},_o="voyage-3",Xr="Optimized for quality.",jo=re(de).parse({name:_o,description:Xr,modalities:le,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:L.base().def,schema:L.base().schema}}),Yr=ne,Qr=class extends ce{constructor(t){super(jo,t);}};var el="system",tl="user",Ao="assistant",nl="tool",ol=[el,tl,Ao,nl],xt=zod.z.enum(ol),al=[Ao],il=zod.z.enum(al),No="image",sl="base64",rl=["png","jpeg","webp","gif"],ll=zod.z.object({type:zod.z.literal(sl),base64:zod.z.string(),mediaType:zod.z.enum(rl)}),dl="url",cl=zod.z.object({type:zod.z.literal(dl),url:zod.z.string()}),ml=zod.z.discriminatedUnion("type",[ll,cl]),pl=["low","medium","high","auto"],ul=zod.z.enum(pl),hl=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(No),detail:ul,value:ml,metadata:t}),Uo="pdf",gl="base64",fl=zod.z.object({type:zod.z.literal(gl),base64:zod.z.string()}),yl="url",bl=zod.z.object({type:zod.z.literal(yl),url:zod.z.string()}),kl=zod.z.discriminatedUnion("type",[fl,bl]),Cl=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Uo),value:kl,file:zod.z.object({name:zod.z.string(),id:zod.z.string(),size:zod.z.number().optional()}),metadata:t}),$o="reasoning",Lo="partial-reasoning",Do="thinking",vl="redacted",Mt=zod.z.object({type:zod.z.literal(Do),thinking:zod.z.string(),signature:zod.z.string()}),qo=zod.z.object({type:zod.z.literal(vl),data:zod.z.string()}),Tl=zod.z.discriminatedUnion("type",[Mt,qo]),Ml=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal($o),value:Tl,metadata:t}),xl=zod.z.object({type:zod.z.literal(Do),thinking:Mt.shape.thinking.optional(),signature:Mt.shape.signature.optional()}),Sl=zod.z.discriminatedUnion("type",[xl,qo]),wl=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Lo),value:Sl,metadata:t}),Ho="text",Ol=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ho),value:zod.z.string(),metadata:t}),Fo="partial-text",Pl=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Fo),value:zod.z.string(),metadata:t}),zo="tool-call",Rl=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(zo),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:t}),Ko="partial-tool-call",_l=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ko),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:t}),Vo="tool-response",jl=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Vo),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:t}),El="partial-tool-response",Il=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(El),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:t}),Bl=[Ho,No,Uo,zo,Vo,$o],Jo=zod.z.enum(Bl),Al=(t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Ol(t),hl(n),Cl(o),Rl(i),jl(s),Ml(r)]),Nl=[Fo,Ko,Lo];zod.z.enum(Nl);var Ul=(t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Pl(t),_l(n),wl(o),Il(i)]);var $l=(t=xt,n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined(),l=zod.z.undefined(),d=zod.z.undefined())=>zod.z.object({role:t,content:zod.z.array(Al(n,o,i,s,l,r)),metadata:d}),Ll=(t=il,n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.object({role:t,partialContent:Ul(n,o,i,r),metadata:s}),Dl=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Eo=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),ql=Eo.extend({topLogProbs:zod.z.array(Eo)}),Go=zod.z.array(ql);zod.z.object({messages:zod.z.array($l()),usage:Dl.optional(),logProbs:Go.optional()});var Hl=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(Ll()),usage:Hl.optional(),logProbs:Go.optional()});var Fl=zod.z.object({enabled:zod.z.boolean().default(!0),allowedTools:zod.z.array(zod.z.string().min(1))});zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(t=>t.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),toolConfiguration:Fl.optional(),authorizationToken:zod.z.string().min(1).optional()});var zl=["object","array","number","string","boolean","enum"],Io=zod.z.enum(zl),Kl=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Io,zod.z.array(zod.z.union([Io,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()}),Vl=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(Kl),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:Vl}).optional();var Jl="text",Gl="token",Zl=[Jl,Gl];zod.z.enum(Zl);zod.z.array(zod.z.string().min(1));zod.z.array(zod.z.array(zod.z.number().int().nonnegative()));var Xl="float",Yl=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),Ql="base64",ed=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Bo=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(Xl),embeddings:zod.z.array(Yl),usage:Bo.optional()}),zod.z.object({encodingFormat:zod.z.literal(Ql),embeddings:zod.z.array(ed),usage:Bo.optional()})]);var td=t=>{let n=new WeakSet;return JSON.stringify(t,(o,i)=>{if(typeof i=="object"&&i!==null){if(n.has(i))return;n.add(i);}return i})},nd=t=>t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:td(t),Tt="GatewayBaseError",St=class Zo extends Error{constructor({info:n,cause:o},i){super(`[${i!=null?i:Tt}]: ${n}
18
+ Message: ${nd(o)}`),this.name=Tt,this.info=n,this.cause=o,this.name=i!=null?i:Tt,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(n){return n instanceof Zo}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},od=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."),ad=zod.z.object({base:od.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),id=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:ad.describe("Price categories and rates for this specific token range.")}).refine(t=>t.maxTokens===null||typeof t.maxTokens=="number"&&t.maxTokens>t.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");zod.z.object({modelName:zod.z.string().describe("Model name this schedule applies to."),currency:zod.z.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:zod.z.array(id).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((t,n)=>{let{tokenRanges:o}=t;o[0].minTokens!==0&&n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let s=1;s<o.length;s++){let r=o[s-1],l=o[s];if(r.maxTokens===null){n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}l.minTokens!==r.maxTokens&&n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s,"minTokens"],message:`Tier ${s} minTokens (${l.minTokens}) must equal previous tier's maxTokens (${r.maxTokens}) for contiguity.`}),l.minTokens<r.minTokens&&n.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${s} (${l.minTokens}) starts before Tier ${s-1} (${r.minTokens}).`});}let i=o[o.length-1];o.every(s=>s.maxTokens!==null||s===i)&&i.maxTokens!==null&&n.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 sd="function";var rd=zod.z.enum(["object","array","number","string","boolean","null"]),ld=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:rd.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(ld).optional(),required:zod.z.array(zod.z.string()).optional()});var dd=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 cd=zod.z.enum(["function"]),md=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),pd=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:md.optional()}),ud=zod.z.discriminatedUnion("type",[pd]);zod.z.object({type:cd,definition:zod.z.object({schema:dd}),request:ud.optional()});var hd=[sd];zod.z.enum(hd);var gd=Object.defineProperty,Wo=Object.getOwnPropertySymbols,fd=Object.prototype.hasOwnProperty,yd=Object.prototype.propertyIsEnumerable,Xo=(t,n,o)=>n in t?gd(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,bd=(t,n)=>{for(var o in n||(n={}))fd.call(n,o)&&Xo(t,o,n[o]);if(Wo)for(var o of Wo(n))yd.call(n,o)&&Xo(t,o,n[o]);return t},Yo="ProviderError",wt=class ea extends St{constructor({info:n,cause:o}){super({info:n,cause:o},Yo),this.name=Yo,this.info=n,this.cause=o;}static isProviderError(n){return n instanceof ea}};var Qo="ModelResponseError",Oe=class ta extends St{constructor({info:n,cause:o}){super({info:n,cause:o},Qo),this.name=Qo,this.cause=o,this.info=n;}static isModelResponseError(n){return n instanceof ta}};var na="multi-string",kd=zod.z.object({type:zod.z.literal(na),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()});var oa="object-schema",Cd=zod.z.object({type:zod.z.literal(oa),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()});var aa="range",vd=zod.z.object({type:zod.z.literal(aa),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()});var ia="select-boolean",Td=zod.z.object({type:zod.z.literal(ia),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()});var Ot="select-string",sa=zod.z.object({type:zod.z.literal(Ot),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.string(),choices:zod.z.array(zod.z.string())}),Md=(t,n)=>zod.z.enum(n).nullable().default(t).optional(),ra=t=>({def:sa.parse(bd({type:Ot},t)),schema:Md(t.default,t.choices)}),xd=[aa,na,Ot,oa,ia];zod.z.enum(xd);var Sd=zod.z.discriminatedUnion("type",[vd,kd,sa,Td,Cd]),O=(t=xt,n=Jo)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(t,zod.z.string().min(1).optional()),modalities:zod.z.array(n).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),Sd),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var i,s;let r=Object.keys(o.def),l=Object.keys((s=(i=o.schema)==null?void 0:i.shape)!=null?s:{});return r.every(d=>l.includes(d))&&l.every(d=>r.includes(d))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()});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 wd=()=>typeof window!="undefined"&&typeof window.document!="undefined"&&typeof navigator!="undefined";var la=t=>{if(wd()){let n=atob(t),o=new Uint8Array(n.length);for(let i=0;i<n.length;i++)o[i]=n.charCodeAt(i);return new TextDecoder("utf-8").decode(o)}else return Buffer.from(t,"base64").toString("utf-8")};var Pt=ra({param:"awsRegion",title:"AWS Region",description:"Controls which region the model will use to call AWS services.",default:"us-east-1",choices:["af-south-1","ap-east-1","ap-northeast-1","ap-northeast-2","ap-northeast-3","ap-south-1","ap-south-2","ap-southeast-1","ap-southeast-2","ap-southeast-3","ap-southeast-4","ca-central-1","ca-west-1","cn-north-1","cn-northwest-1","eu-central-1","eu-central-2","eu-north-1","eu-south-1","eu-south-2","eu-west-1","eu-west-2","eu-west-3","il-central-1","me-central-1","me-south-1","mx-central-1","sa-east-1","us-east-1","us-east-2","us-west-1","us-west-2"]});var da=(t,n)=>Me(t,n).extend({awsRegion:Pt.schema}),ca=(t,n)=>H(_({},xe(t,n)),{awsRegion:Pt.def});var b={base:(t,n)=>({def:ca(t,n),schema:da(t,n)})};var Od="bedrock",me=class me{constructor(){this.version="v1";this.name=Od;this.chatModelFactories={[Ne]:{model:Ue,modelOptions:ga,modelSchema:It},[De]:{model:qe,modelOptions:ya,modelSchema:At},[$e]:{model:Le,modelOptions:fa,modelSchema:Bt},[_e]:{model:je,modelOptions:pa,modelSchema:_t},[Ee]:{model:Ie,modelOptions:ua,modelSchema:jt},[Pe]:{model:Re,modelOptions:ma,modelSchema:Rt},[Be]:{model:Ae,modelOptions:ha,modelSchema:Et},[ze]:{model:Ke,modelOptions:ka,modelSchema:Ut},[Ve]:{model:Je,modelOptions:Ca,modelSchema:$t},[He]:{model:Fe,modelOptions:ba,modelSchema:Nt}};this.embeddingModelFactories={};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((n,o)=>(n[o]=this.chatModelFactories[o].modelSchema,n),{})}chatModel(n){let o=n.modelName,i=/^(global|us|eu|ap|me|sa|af|an)\./,s=i.test(o)?o.replace(i,""):o;if(!(s in this.chatModelFactories))throw new wt({info:`Bedrock chat model: ${s} not found`,cause:new Error(`Bedrock chat model: ${s} not found, available chat models:
19
+ ${this.chatModelLiterals().join(", ")}`)});let r=this.chatModelFactories[s].model,l=this.chatModelFactories[s].modelOptions.parse(n);return new r(H(_({},l),{modelName:o}))}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((n,o)=>(n[o]=this.embeddingModelFactories[o].modelSchema,n),{})}embeddingModel(n){throw new wt({info:"Adaline Bedrock provider does not support embedding models yet",cause:new Error("Adaline Bedrock provider does not support embedding models yet")})}};me.awsService="bedrock",me.awsDefaultRegion="us-east-1",me.awsUrl=n=>`https://bedrock-runtime.${n!=null?n:me.awsDefaultRegion}.amazonaws.com`;var A=me;var M=zod.z.object({modelName:zod.z.string(),awsAccessKeyId:zod.z.string(),awsSecretAccessKey:zod.z.string()});var T={"anthropic.claude-3-5-haiku-20241022-v1:0":{modelName:"anthropic.claude-3-5-haiku-20241022-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1,outputPricePerMillion:5}}}]},"anthropic.claude-3-5-sonnet-20240620-v1:0":{modelName:"anthropic.claude-3-5-sonnet-20240620-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"anthropic.claude-3-5-sonnet-20241022-v2:0":{modelName:"anthropic.claude-3-5-sonnet-20241022-v2:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"anthropic.claude-3-haiku-20240307-v1:0":{modelName:"anthropic.claude-3-haiku-20240307-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.25,outputPricePerMillion:1.25}}}]},"anthropic.claude-3-opus-20240229-v1:0":{modelName:"anthropic.claude-3-opus-20240229-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:75}}}]},"anthropic.claude-3-sonnet-20240229-v1:0":{modelName:"anthropic.claude-3-sonnet-20240229-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"anthropic.claude-opus-4-20250514-v1:0":{modelName:"anthropic.claude-opus-4-20250514-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:75}}}]},"anthropic.claude-sonnet-4-20250514-v1:0":{modelName:"anthropic.claude-sonnet-4-20250514-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"anthropic.claude-sonnet-4-5-20250929-v1:0":{modelName:"anthropic.claude-sonnet-4-5-20250929-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"anthropic.claude-3-7-sonnet-20250219-v1:0":{modelName:"anthropic.claude-3-7-sonnet-20250219-v1:0",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]}};var x=class t extends D{constructor(o,i){let s=M.parse(i);super(o,{apiKey:"random-api-key",modelName:s.modelName});this.version="v1";this.modelSchema=o,this.modelName=s.modelName,this.awsService=A.awsService,this.awsAccessKeyId=s.awsAccessKeyId,this.awsSecretAccessKey=s.awsSecretAccessKey;}getDefaultBaseUrl(){return A.awsUrl()}getDefaultHeaders(){return {Accept:"application/json","Content-Type":"application/json"}}getDefaultParams(){return {anthropic_version:"bedrock-2023-05-31"}}getCompleteChatUrl(o,i,s){let r=A.awsUrl(o==null?void 0:o.awsRegion);return new Promise(l=>{l(`${r}/model/${this.modelName}/invoke`);})}transformConfig(o,i,s){let r=_({},o);return delete r.awsRegion,super.transformConfig(r,i,s)}getCompleteChatHeaders(o,i,s){return F(this,null,function*(){let r=new URL(yield this.getCompleteChatUrl(o,i,s)),l={accessKeyId:this.awsAccessKeyId,secretAccessKey:this.awsSecretAccessKey},d=(o==null?void 0:o.awsRegion)||A.awsDefaultRegion,c=this.getDefaultHeaders();c=H(_({},c),{host:A.awsUrl(d).split("://")[1]});let m=yield this.getCompleteChatData(o||{},i||[],s),h=new protocolHttp.HttpRequest({hostname:r.hostname,path:r.pathname,protocol:r.protocol,method:"POST",body:JSON.stringify(m),headers:c});return (yield new signatureV4.SignatureV4({credentials:l,service:this.awsService,region:d,sha256:sha256Js.Sha256}).sign(h)).headers})}getCompleteChatData(o,i,s){return F(this,null,function*(){let r=_(_({},this.getDefaultParams()),yield ye(t.prototype,this,"getCompleteChatData").call(this,o,i,s));return new Promise(l=>{l(r);})})}getStreamChatUrl(o,i,s){return F(this,null,function*(){let r=A.awsUrl(o==null?void 0:o.awsRegion);return new Promise(l=>{l(`${r}/model/${this.modelName}/invoke-with-response-stream`);})})}getStreamChatHeaders(o,i,s){return F(this,null,function*(){let r=new URL(yield this.getStreamChatUrl(o,i,s)),l={accessKeyId:this.awsAccessKeyId,secretAccessKey:this.awsSecretAccessKey},d=(o==null?void 0:o.awsRegion)||A.awsDefaultRegion,c=this.getDefaultHeaders();c=H(_({},c),{host:A.awsUrl(d).split("://")[1]});let m=yield this.getCompleteChatData(o||{},i||[],s),h=new protocolHttp.HttpRequest({hostname:r.hostname,path:r.pathname,protocol:r.protocol,method:"POST",body:JSON.stringify(m),headers:c});return (yield new signatureV4.SignatureV4({credentials:l,service:this.awsService,region:d,sha256:sha256Js.Sha256}).sign(h)).headers})}getStreamChatData(o,i,s){return F(this,null,function*(){let r=_(_({},this.getDefaultParams()),yield ye(t.prototype,this,"getStreamChatData").call(this,o,i,s));return "stream"in r&&delete r.stream,r})}transformStreamChatResponseChunk(o,i){return Ze(this,null,function*(){let s=o.toString(),r=/{\s*"bytes"\s*:\s*"[\w=+/]+".*?}/g,l=s.match(r)||[];if(l.length!==0)for(let g of l){let P=g.indexOf("{"),u=g.indexOf("}");if(P===-1||u===-1||P>=u)continue;let v,R=g.slice(P,u+1);try{v=JSON.parse(R);}catch(U){throw new Oe({info:`Malformed JSON received in stream : ${R}`,cause:U})}let N=la(v.bytes),q="message_delta";try{let U=JSON.parse(N);U.type&&(q=U.type);}catch(U){throw new Oe({info:`Malformed JSON received in stream : ${N}`,cause:U})}let W=`event: ${q}
20
+ data: ${N}
21
+
22
+ `;try{for(var d=zt(ye(t.prototype,this,"transformStreamChatResponseChunk").call(this,W,i)),c,m,h;c=!(m=yield new pe(d.next())).done;c=!1){let U=m.value;i=U.buffer,yield U;}}catch(m){h=[m];}finally{try{c&&(m=d.return)&&(yield new pe(m.call(d)));}finally{if(h)throw h[0]}}}})}transformProxyStreamChatResponseChunk(o,i,s,r,l){return Ze(this,null,function*(){yield*be(this.transformStreamChatResponseChunk(o,i));})}getRegionHelper(o){var s;let i=o["aws-region"];if(!i){let r=(s=o.authorization)==null?void 0:s.match(/Credential=[^/]+\/\d+\/([^/]+)\/bedrock/);r&&(i=r[1]);}return i}getProxyStreamChatUrl(o,i,s){return F(this,null,function*(){let r=this.getRegionHelper(i||{}),l=A.awsUrl(r);return new Promise(d=>{d(`${l}/model/${this.modelName}/invoke-with-response-stream`);})})}getProxyChatHeaders(o,i,s,r){return F(this,null,function*(){let l=new URL(yield o());if(!s)return {};let d=s["aws-access-key-id"],c=s["aws-secret-access-key"],m=this.getRegionHelper(s);if(!d||!c)return {};let h={accessKeyId:d,secretAccessKey:c};s=H(_({},s),{host:l.host,"content-type":"application/json",accept:"application/json"}),delete s["content-length"];let g=s.authorization||s.Authorization;if(g){let R=g.match(/SignedHeaders=([^,]+)/);if(R&&R[1]){let N=R[1].split(";").map(q=>q.trim().toLowerCase());N.push("authorization"),s=Object.keys(s).reduce((q,W)=>{var U;return N.includes(W.toLowerCase())&&(q[W]=(U=s==null?void 0:s[W])!=null?U:""),q},{});}}let P=new protocolHttp.HttpRequest({hostname:l.hostname,path:l.pathname,protocol:l.protocol,method:"POST",body:JSON.stringify(i),headers:s});return (yield new signatureV4.SignatureV4({credentials:h,service:this.awsService,region:m,sha256:sha256Js.Sha256}).sign(P)).headers})}getProxyCompleteChatUrl(o,i,s){return F(this,null,function*(){let r=this.getRegionHelper(i||{}),l=A.awsUrl(r);return new Promise(d=>{d(`${l}/model/${this.modelName}/invoke`);})})}getProxyCompleteChatHeaders(o,i,s){return F(this,null,function*(){return this.getProxyChatHeaders(()=>this.getProxyCompleteChatUrl(o,i,s),o,i,s)})}getProxyStreamChatHeaders(o,i,s){return F(this,null,function*(){return this.getProxyChatHeaders(()=>this.getProxyStreamChatUrl(o,i,s),o,i,s)})}getModelPricing(){if(!(this.modelName in T))throw new Oe({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return T[this.modelName]}};var Pe="anthropic.claude-3-5-haiku-20241022-v1:0",Rd="Our fastest model with intelligence at blazing speeds.",Rt=O(f,C).parse({name:Pe,description:Rd,maxInputTokens:2e5,maxOutputTokens:8192,roles:y,modalities:k,config:{def:b.base(8192,4).def,schema:b.base(8192,4).schema},price:T[Pe]}),ma=M,Re=class extends x{constructor(n){super(Rt,n);}};var _e="anthropic.claude-3-5-sonnet-20240620-v1:0",_d="Most intelligent model. Highest level of intelligence and capability.",_t=O(f,C).parse({name:_e,description:_d,maxInputTokens:2e5,maxOutputTokens:8192,roles:y,modalities:k,config:{def:b.base(8192,4).def,schema:b.base(8192,4).schema},price:T[_e]}),pa=M,je=class extends x{constructor(n){super(_t,n);}};var Ee="anthropic.claude-3-5-sonnet-20241022-v2:0",jd="Most intelligent model. Highest level of intelligence and capability.",jt=O(f,C).parse({name:Ee,description:jd,maxInputTokens:2e5,maxOutputTokens:8192,roles:y,modalities:k,config:{def:b.base(8192,4).def,schema:b.base(8192,4).schema},price:T[Ee]}),ua=M,Ie=class extends x{constructor(n){super(jt,n);}};var Be="anthropic.claude-3-7-sonnet-20250219-v1:0",Ed="Most intelligent model. Highest level of intelligence and capability.",Et=O(f,C).parse({name:Be,description:Ed,maxInputTokens:2e5,maxOutputTokens:128e3,roles:y,modalities:k,config:{def:b.base(128e3,4).def,schema:b.base(128e3,4).schema},price:T[Be]}),ha=M,Ae=class extends x{constructor(n){super(Et,n);}getDefaultHeaders(){let n=super.getDefaultHeaders(),o=n["anthropic-beta"],i="output-128k-2025-02-19";return o?n=H(_({},n),{"anthropic-beta":`${o},${i}`}):n=H(_({},n),{"anthropic-beta":i}),n}};var Ne="anthropic.claude-3-haiku-20240307-v1:0",Id="Claude 3 Haiku is a large-scale multimodal model trained by Anthropic. It is the successor to Claude 3 and is designed to be more powerful and capable than its predecessor.",It=O(f,C).parse({name:Ne,description:Id,maxInputTokens:2e5,maxOutputTokens:4096,roles:y,modalities:k,config:{def:b.base(4096,4).def,schema:b.base(4096,4).schema},price:T[Ne]}),ga=M,Ue=class extends x{constructor(n){super(It,n);}};var $e="anthropic.claude-3-opus-20240229-v1:0",Bd="Powerful model for highly complex tasks. Top-level performance, intelligence, fluency, and understanding.",Bt=O(f,C).parse({name:$e,description:Bd,maxInputTokens:2e5,maxOutputTokens:4096,roles:y,modalities:k,config:{def:b.base(4096,4).def,schema:b.base(4096,4).schema},price:T[$e]}),fa=M,Le=class extends x{constructor(n){super(Bt,n);}};var De="anthropic.claude-3-sonnet-20240229-v1:0",Ad="Balance of intelligence and speed. Strong utility, balanced for scaled deployments.",At=O(f,C).parse({name:De,description:Ad,maxInputTokens:2e5,maxOutputTokens:4096,roles:y,modalities:k,config:{def:b.base(4096,4).def,schema:b.base(4096,4).schema},price:T[De]}),ya=M,qe=class extends x{constructor(n){super(At,n);}};var He="anthropic.claude-opus-4-20250514-v1:0",Nd="Our high-performance model with exceptional reasoning and efficiency. Training cutoff: March 2025.",Nt=O(f,C).parse({name:He,description:Nd,maxInputTokens:2e5,maxOutputTokens:32e3,roles:y,modalities:k,config:{def:b.base(32e3,4).def,schema:b.base(32e3,4).schema},price:T[He]}),ba=M,Fe=class extends x{constructor(n){super(Nt,n);}};var ze="anthropic.claude-sonnet-4-20250514-v1:0",Ud="Our most capable and intelligent model yet. Training cutoff: March 2025.",Ut=O(f,C).parse({name:ze,description:Ud,maxInputTokens:2e5,maxOutputTokens:64e3,roles:y,modalities:k,config:{def:b.base(64e3,4).def,schema:b.base(64e3,4).schema},price:T[ze]}),ka=M,Ke=class extends x{constructor(n){super(Ut,n);}};var Ve="anthropic.claude-sonnet-4-5-20250929-v1:0",$d="Our best model for complex agents and coding, with the highest intelligence across most tasks. Training cutoff: July 2025.",$t=O(f,C).parse({name:Ve,description:$d,maxInputTokens:2e5,maxOutputTokens:64e3,roles:y,modalities:k,config:{def:b.base(64e3,4).def,schema:b.base(64e3,4).schema},price:T[Ve]}),Ca=M,Je=class extends x{constructor(n){super($t,n);}};
20
23
 
21
24
  exports.BaseChatModelAnthropic = x;
22
25
  exports.BaseChatModelOptions = M;
23
26
  exports.Bedrock = A;
24
- exports.BedrockAnthropicChatModelBaseConfigDef = da;
25
- exports.BedrockAnthropicChatModelBaseConfigSchema = la;
27
+ exports.BedrockAnthropicChatModelBaseConfigDef = ca;
28
+ exports.BedrockAnthropicChatModelBaseConfigSchema = da;
26
29
  exports.BedrockAnthropicChatModelConfigs = b;
27
- exports.BedrockClaude3Haiku20240307 = Ae;
28
- exports.BedrockClaude3Haiku20240307Literal = Be;
29
- exports.BedrockClaude3Haiku20240307Options = ha;
30
- exports.BedrockClaude3Haiku20240307Schema = Et;
31
- exports.BedrockClaude3Opus20240229 = Ue;
32
- exports.BedrockClaude3Opus20240229Literal = Ne;
33
- exports.BedrockClaude3Opus20240229Options = ga;
34
- exports.BedrockClaude3Opus20240229Schema = It;
35
- exports.BedrockClaude3Sonnet20240229 = $e;
36
- exports.BedrockClaude3Sonnet20240229Literal = Le;
37
- exports.BedrockClaude3Sonnet20240229Options = fa;
38
- exports.BedrockClaude3Sonnet20240229Schema = Bt;
39
- exports.BedrockClaude3_5Haiku20241022 = Oe;
40
- exports.BedrockClaude3_5Haiku20241022Literal = we;
41
- exports.BedrockClaude3_5Haiku20241022Options = ca;
42
- exports.BedrockClaude3_5Haiku20241022Schema = Pt;
43
- exports.BedrockClaude3_5Sonnet20240620 = Re;
44
- exports.BedrockClaude3_5Sonnet20240620Literal = Pe;
45
- exports.BedrockClaude3_5Sonnet20240620Options = ma;
46
- exports.BedrockClaude3_5Sonnet20240620Schema = Rt;
47
- exports.BedrockClaude3_5Sonnet20241022 = je;
48
- exports.BedrockClaude3_5Sonnet20241022Literal = _e;
49
- exports.BedrockClaude3_5Sonnet20241022Options = pa;
50
- exports.BedrockClaude3_5Sonnet20241022Schema = _t;
51
- exports.BedrockClaude3_7Sonnet20250219 = Ie;
52
- exports.BedrockClaude3_7Sonnet20250219Literal = Ee;
53
- exports.BedrockClaude3_7Sonnet20250219Options = ua;
54
- exports.BedrockClaude3_7Sonnet20250219Schema = jt;
55
- exports.BedrockClaude4Opus20250514 = De;
56
- exports.BedrockClaude4Opus20250514Literal = qe;
57
- exports.BedrockClaude4Opus20250514Options = ya;
58
- exports.BedrockClaude4Opus20250514Schema = At;
59
- exports.BedrockClaude4Sonnet20250514 = Fe;
60
- exports.BedrockClaude4Sonnet20250514Literal = He;
61
- exports.BedrockClaude4Sonnet20250514Options = ba;
62
- exports.BedrockClaude4Sonnet20250514Schema = Nt;
63
- exports.BedrockClaudeSonnet4_520250929 = Ke;
64
- exports.BedrockClaudeSonnet4_520250929Literal = ze;
65
- exports.BedrockClaudeSonnet4_520250929Options = ka;
66
- exports.BedrockClaudeSonnet4_520250929Schema = Ut;
67
- exports.awsRegionChoice = Ot;
30
+ exports.BedrockClaude3Haiku20240307 = Ue;
31
+ exports.BedrockClaude3Haiku20240307Literal = Ne;
32
+ exports.BedrockClaude3Haiku20240307Options = ga;
33
+ exports.BedrockClaude3Haiku20240307Schema = It;
34
+ exports.BedrockClaude3Opus20240229 = Le;
35
+ exports.BedrockClaude3Opus20240229Literal = $e;
36
+ exports.BedrockClaude3Opus20240229Options = fa;
37
+ exports.BedrockClaude3Opus20240229Schema = Bt;
38
+ exports.BedrockClaude3Sonnet20240229 = qe;
39
+ exports.BedrockClaude3Sonnet20240229Literal = De;
40
+ exports.BedrockClaude3Sonnet20240229Options = ya;
41
+ exports.BedrockClaude3Sonnet20240229Schema = At;
42
+ exports.BedrockClaude3_5Haiku20241022 = Re;
43
+ exports.BedrockClaude3_5Haiku20241022Literal = Pe;
44
+ exports.BedrockClaude3_5Haiku20241022Options = ma;
45
+ exports.BedrockClaude3_5Haiku20241022Schema = Rt;
46
+ exports.BedrockClaude3_5Sonnet20240620 = je;
47
+ exports.BedrockClaude3_5Sonnet20240620Literal = _e;
48
+ exports.BedrockClaude3_5Sonnet20240620Options = pa;
49
+ exports.BedrockClaude3_5Sonnet20240620Schema = _t;
50
+ exports.BedrockClaude3_5Sonnet20241022 = Ie;
51
+ exports.BedrockClaude3_5Sonnet20241022Literal = Ee;
52
+ exports.BedrockClaude3_5Sonnet20241022Options = ua;
53
+ exports.BedrockClaude3_5Sonnet20241022Schema = jt;
54
+ exports.BedrockClaude3_7Sonnet20250219 = Ae;
55
+ exports.BedrockClaude3_7Sonnet20250219Literal = Be;
56
+ exports.BedrockClaude3_7Sonnet20250219Options = ha;
57
+ exports.BedrockClaude3_7Sonnet20250219Schema = Et;
58
+ exports.BedrockClaude4Opus20250514 = Fe;
59
+ exports.BedrockClaude4Opus20250514Literal = He;
60
+ exports.BedrockClaude4Opus20250514Options = ba;
61
+ exports.BedrockClaude4Opus20250514Schema = Nt;
62
+ exports.BedrockClaude4Sonnet20250514 = Ke;
63
+ exports.BedrockClaude4Sonnet20250514Literal = ze;
64
+ exports.BedrockClaude4Sonnet20250514Options = ka;
65
+ exports.BedrockClaude4Sonnet20250514Schema = Ut;
66
+ exports.BedrockClaudeSonnet4_520250929 = Je;
67
+ exports.BedrockClaudeSonnet4_520250929Literal = Ve;
68
+ exports.BedrockClaudeSonnet4_520250929Options = Ca;
69
+ exports.BedrockClaudeSonnet4_520250929Schema = $t;
70
+ exports.awsRegionChoice = Pt;
68
71
  //# sourceMappingURL=index.js.map
69
72
  //# sourceMappingURL=index.js.map