@adaline/anthropic 1.4.2 → 1.4.3

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
@@ -3,7 +3,7 @@
3
3
  var zod = require('zod');
4
4
 
5
5
  var bn=Object.defineProperty,Cn=Object.defineProperties;var Mn=Object.getOwnPropertyDescriptors;var Kt=Object.getOwnPropertySymbols;var kn=Object.prototype.hasOwnProperty,Rn=Object.prototype.propertyIsEnumerable;var pe=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),Sn=n=>{throw TypeError(n)};var Gt=(n,t,o)=>t in n?bn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,b=(n,t)=>{for(var o in t||(t={}))kn.call(t,o)&&Gt(n,o,t[o]);if(Kt)for(var o of Kt(t))Rn.call(t,o)&&Gt(n,o,t[o]);return n},me=(n,t)=>Cn(n,Mn(t));var O=(n,t,o)=>new Promise((a,i)=>{var l=m=>{try{r(o.next(m));}catch(h){i(h);}},s=m=>{try{r(o.throw(m));}catch(h){i(h);}},r=m=>m.done?a(m.value):Promise.resolve(m.value).then(l,s);r((o=o.apply(n,t)).next());}),Jt=function(n,t){this[0]=n,this[1]=t;},ze=(n,t,o)=>{var a=(s,r,m,h)=>{try{var f=o[s](r),V=(r=f.value)instanceof Jt,I=f.done;Promise.resolve(V?r[0]:r).then(u=>V?a(s==="return"?s:"next",r[1]?{done:u.done,value:u.value}:u,m,h):m({value:u,done:I})).catch(u=>a("throw",u,m,h));}catch(u){h(u);}},i=s=>l[s]=r=>new Promise((m,h)=>a(s,r,m,h)),l={};return o=o.apply(n,t),l[pe("asyncIterator")]=()=>l,i("next"),i("throw"),i("return"),l},Zt=n=>{var t=n[pe("asyncIterator")],o=!1,a,i={};return t==null?(t=n[pe("iterator")](),a=l=>i[l]=s=>t[l](s)):(t=t.call(n),a=l=>i[l]=s=>{if(o){if(o=!1,l==="throw")throw s;return s}return o=!0,{done:!1,value:new Jt(new Promise(r=>{var m=t[l](s);m instanceof Object||Sn("Object expected"),r(m);}),1)}}),i[pe("iterator")]=()=>i,a("next"),"throw"in t?a("throw"):i.throw=l=>{throw l},"return"in t&&a("return"),i};var ee="system",Z="user",E="assistant",ie="tool",xn=[ee,Z,E,ie],Ke=zod.z.enum(xn),En=[E],vn=zod.z.enum(En),z="image",Ge="base64",On=["png","jpeg","webp","gif"],An=zod.z.object({type:zod.z.literal(Ge),base64:zod.z.string(),mediaType:zod.z.enum(On)}),Pn="url",wn=zod.z.object({type:zod.z.literal(Pn),url:zod.z.string()}),_n=zod.z.discriminatedUnion("type",[An,wn]),qn=["low","medium","high","auto"],In=zod.z.enum(qn),jn=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(z),detail:In,value:_n,metadata:n}),F="reasoning",ce="partial-reasoning",ue="thinking",Je="redacted",He=zod.z.object({type:zod.z.literal(ue),thinking:zod.z.string(),signature:zod.z.string()}),Qt=zod.z.object({type:zod.z.literal(Je),data:zod.z.string()}),Ln=zod.z.discriminatedUnion("type",[He,Qt]),Ze=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(F),value:Ln,metadata:n}),Bn=zod.z.object({type:zod.z.literal(ue),thinking:He.shape.thinking.optional(),signature:He.shape.signature.optional()}),Nn=zod.z.discriminatedUnion("type",[Bn,Qt]),We=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ce),value:Nn,metadata:n}),x="text",eo=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(x),value:zod.z.string(),metadata:n}),Xe="partial-text",to=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Xe),value:zod.z.string(),metadata:n}),w="tool-call",oo=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(w),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),metadata:n}),Ye="partial-tool-call",no=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ye),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),metadata:n}),H="tool-response",Un=(n=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:n}),Dn=[x,z,w,H,F],ao=zod.z.enum(Dn),Vn=(n=zod.z.undefined(),t=zod.z.undefined(),o=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[eo(n),jn(t),oo(o),Un(a),Ze(i)]),$n=[Xe,Ye,ce];zod.z.enum($n);var zn=(n=zod.z.undefined(),t=zod.z.undefined(),o=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[to(n),no(t),We(o)]);var Qe=(n=Ke,t=zod.z.undefined(),o=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined(),l=zod.z.undefined(),s=zod.z.undefined())=>zod.z.object({role:n,content:zod.z.array(Vn(t,o,a,i,s)),metadata:l}),se=(n=vn,t=zod.z.undefined(),o=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined())=>zod.z.object({role:n,partialContent:zn(t,o,a),metadata:i}),Fn=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Wt=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),Hn=Wt.extend({topLogProbs:zod.z.array(Wt)}),io=zod.z.array(Hn);zod.z.object({messages:zod.z.array(Qe()),usage:Fn.optional(),logProbs:io.optional()});var Kn=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:Kn.optional(),logProbs:io.optional()});var ge=(n=zod.z.record(zod.z.string(),zod.z.any()).optional())=>n,Gn=["object","array","number","string","boolean","enum"],Xt=zod.z.enum(Gn),Jn=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Xt,zod.z.array(zod.z.union([Xt,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()}),Zn=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(Jn),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:Zn}).optional();var W="text",so="token",Wn=[W,so],ro=zod.z.enum(Wn),Xn=zod.z.array(zod.z.string().min(1)),Yn=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),lo=(n=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(W),metadata:n,requests:Xn}),zod.z.object({modality:zod.z.literal(so),metadata:n,requests:Yn})]),et="float",Qn=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),tt="base64",ea=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Yt=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(et),embeddings:zod.z.array(Qn),usage:Yt.optional()}),zod.z.object({encodingFormat:zod.z.literal(tt),embeddings:zod.z.array(ea),usage:Yt.optional()})]);var ta=n=>{let t=new WeakSet;return JSON.stringify(n,(o,a)=>{if(typeof a=="object"&&a!==null){if(t.has(a))return;t.add(a);}return a})},oa=n=>n==null?"unknown error":typeof n=="string"?n:n instanceof Error?n.message:ta(n),Fe="GatewayBaseError",X=class po extends Error{constructor({info:t,cause:o},a){super(`[${a!=null?a:Fe}]: ${t}
6
- Message: ${oa(o)}`),this.name=Fe,this.info=t,this.cause=o,this.name=a!=null?a:Fe,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof po}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},na=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."),aa=zod.z.object({base:na.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),ia=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:aa.describe("Price categories and rates for this specific token range.")}).refine(n=>n.maxTokens===null||typeof n.maxTokens=="number"&&n.maxTokens>n.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");zod.z.object({modelName:zod.z.string().describe("Model name this schedule applies to."),currency:zod.z.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:zod.z.array(ia).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((n,t)=>{let{tokenRanges:o}=n;o[0].minTokens!==0&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let i=1;i<o.length;i++){let l=o[i-1],s=o[i];if(l.maxTokens===null){t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",i-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}s.minTokens!==l.maxTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",i,"minTokens"],message:`Tier ${i} minTokens (${s.minTokens}) must equal previous tier's maxTokens (${l.maxTokens}) for contiguity.`}),s.minTokens<l.minTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",i,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${i} (${s.minTokens}) starts before Tier ${i-1} (${l.minTokens}).`});}let a=o[o.length-1];o.every(i=>i.maxTokens!==null||i===a)&&a.maxTokens!==null&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",o.length-1,"maxTokens"],message:"The final tier must have maxTokens = null (representing infinity)."});}).describe("Complete pricing schedule for a single chat model, including all its token-based tiers.");var sa="function";var ra=zod.z.enum(["object","array","number","string","boolean","null"]),la=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:ra.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(la).optional(),required:zod.z.array(zod.z.string()).optional()});var da=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 pa=zod.z.enum(["function"]),ma=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),ca=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:ma.optional()}),ua=zod.z.discriminatedUnion("type",[ca]),ga=zod.z.object({type:pa,definition:zod.z.object({schema:da}),apiSettings:ua.optional()}),ha=[sa];zod.z.enum(ha);var mo=(n=zod.z.undefined())=>zod.z.discriminatedUnion("type",[ga.extend({metadata:n})]),co=n=>eo().parse({modality:x,value:n}),uo=(n,t,o,a)=>oo().parse({modality:w,index:n,id:t,name:o,arguments:a});var ot=(n,t)=>se().parse({role:n,partialContent:to().parse({modality:Xe,value:t})}),nt=(n,t,o,a,i)=>se().parse({role:n,partialContent:no().parse({modality:Ye,index:t,id:o,name:a,arguments:i})}),go=(n,t)=>Ze().parse({modality:F,value:{type:ue,thinking:n,signature:t}});var ho=n=>Ze().parse({modality:F,value:{type:Je,data:n}});var he=(n,t,o)=>se().parse({role:n,partialContent:We().parse({modality:ce,value:{type:ue,thinking:t,signature:o}})}),yo=(n,t)=>se().parse({role:n,partialContent:We().parse({modality:ce,value:{type:Je,data:t}})});var ya=Object.defineProperty,fo=Object.getOwnPropertySymbols,fa=Object.prototype.hasOwnProperty,Ta=Object.prototype.propertyIsEnumerable,To=(n,t,o)=>t in n?ya(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,ye=(n,t)=>{for(var o in t||(t={}))fa.call(t,o)&&To(n,o,t[o]);if(fo)for(var o of fo(t))Ta.call(t,o)&&To(n,o,t[o]);return n},bo="ProviderError",at=class Eo extends X{constructor({info:t,cause:o}){super({info:t,cause:o},bo),this.name=bo,this.info=t,this.cause=o;}static isProviderError(t){return t instanceof Eo}};var Co="ModelResponseError",$=class vo extends X{constructor({info:t,cause:o}){super({info:t,cause:o},Co),this.name=Co,this.cause=o,this.info=t;}static isModelResponseError(t){return t instanceof vo}},Mo="InvalidModelRequestError",re=class Oo extends X{constructor({info:t,cause:o}){super({info:t,cause:o},Mo),this.name=Mo,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof Oo}},ko="InvalidConfigError",K=class Ao extends X{constructor({info:t,cause:o}){super({info:t,cause:o},ko),this.name=ko,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof Ao}},Ro="InvalidMessagesError",_=class Po extends X{constructor({info:t,cause:o}){super({info:t,cause:o},Ro),this.name=Ro,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof Po}},So="InvalidToolsError",it=class wo extends X{constructor({info:t,cause:o}){super({info:t,cause:o},So),this.name=So,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof wo}},xo="InvalidEmbeddingRequestsError",st=class _o extends X{constructor({info:t,cause:o}){super({info:t,cause:o},xo),this.name=xo,this.info=t,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof _o}},rt="multi-string",qo=zod.z.object({type:zod.z.literal(rt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),max:zod.z.number().int().positive()}),ba=n=>zod.z.array(zod.z.string()).max(n).default([]).optional(),Io=n=>({def:qo.parse(ye({type:rt},n)),schema:ba(n.max)}),jo="object-schema",Ca=zod.z.object({type:zod.z.literal(jo),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 lt="range",Lo=zod.z.object({type:zod.z.literal(lt),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()}),Ma=(n,t,o,a)=>zod.z.number().min(n).max(t).step(o).default(a).optional(),te=n=>({def:Lo.parse(ye({type:lt},n)),schema:Ma(n.min,n.max,n.step,n.default)}),dt="select-boolean",Bo=zod.z.object({type:zod.z.literal(dt),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()}),ka=n=>zod.z.boolean().nullable().default(n).optional(),fe=n=>({def:Bo.parse(ye({type:dt},n)),schema:ka(n.default)}),pt="select-string",No=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),default:zod.z.string(),choices:zod.z.array(zod.z.string())}),Ra=(n,t)=>zod.z.enum(t).nullable().default(n).optional(),le=n=>({def:No.parse(ye({type:pt},n)),schema:Ra(n.default,n.choices)}),Sa=[lt,rt,pt,jo,dt];zod.z.enum(Sa);var Uo=zod.z.discriminatedUnion("type",[Lo,qo,No,Bo,Ca]),M=(n=Ke,t=ao)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(n,zod.z.string().min(1).optional()),modalities:zod.z.array(t).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),maxReasoningTokens:zod.z.number().int().positive().min(1).optional(),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Uo),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var a,i;let l=Object.keys(o.def),s=Object.keys((i=(a=o.schema)==null?void 0:a.shape)!=null?i:{});return l.every(r=>s.includes(r))&&s.every(r=>l.includes(r))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()}),j=(n=ro)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(n).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Uo),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var o,a;let i=Object.keys(t.def),l=Object.keys((a=(o=t.schema)==null?void 0:o.shape)!=null?a:{});return i.every(s=>l.includes(s))&&l.every(s=>i.includes(s))},{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 xa={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."},Ea={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."},va={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},Oa=n=>({type:"multi",title:"Stop sequence",description:`Enter up to ${n} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Aa={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."},Pa={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."},wa={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."},_a={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."},qa={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."},Ia={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."},ja={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."},La={type:"range",title:"Repetition penalty",description:"Reduces the likelihood of repeating tokens from the input. Increasing this value makes the model less prone to repetition, but setting it too high may lead to less coherent output, often resulting in run-on sentences missing smaller words. The token penalty is scaled according to the original token's probability."},Ba={type:"boolean",title:"Log probs",description:"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned."},Na={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."},Ua={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},Da={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."},Va={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."},$a={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."},A={TEMPERATURE:xa,MAX_TOKENS:Ea,STOP:Oa,TOP_A:Aa,TOP_P:Pa,TOP_K:wa,MIN_P:_a,FREQUENCY_PENALTY:qa,PRESENCE_PENALTY:Ia,REPETITION_PENALTY:La,SEED:ja,LOG_PROBS:Ba,TOP_LOG_PROBS:Na,ECHO:Ua,RESPONSE_FORMAT:Da,RESPONSE_FORMAT_WITH_SCHEMA:Va,RESPONSE_SCHEMA:$a,MAX_REASONING_TOKENS:va};var Te=n=>Object.fromEntries(Object.entries(n).filter(([t,o])=>o!=null));var oe=n=>n==null?void 0:n.replace(/\/$/,"");var mt=te({param:"temperature",title:A.TEMPERATURE.title,description:A.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),ct=n=>te({param:"max_tokens",title:A.MAX_TOKENS.title,description:A.MAX_TOKENS.description,min:0,max:n,step:1,default:0}),ut=n=>Io({param:"stop_sequences",title:A.STOP(n).title,description:A.STOP(n).description,max:n}),gt=te({param:"top_p",title:A.TOP_P.title,description:A.TOP_P.description,min:0,max:1,step:.01,default:1}),ht=te({param:"top_k",title:A.TOP_K.title,description:A.TOP_K.description,min:0,max:1,step:.01,default:1}),yt=le({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"]});var be=(n,t)=>zod.z.object({temperature:mt.schema,maxTokens:ct(n).schema,stop:ut(t).schema,topP:gt.schema,topK:ht.schema,toolChoice:yt.schema}),Ce=(n,t)=>({temperature:mt.def,maxTokens:ct(n).def,stop:ut(t).def,topP:gt.def,topK:ht.def,toolChoice:yt.def});var Do=(n,t)=>te({param:"max_reasoning_tokens",title:A.MAX_REASONING_TOKENS.title,description:A.MAX_REASONING_TOKENS.description,min:n,max:t,step:1,default:0}),Vo=fe({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.
6
+ Message: ${oa(o)}`),this.name=Fe,this.info=t,this.cause=o,this.name=a!=null?a:Fe,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof po}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},na=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."),aa=zod.z.object({base:na.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),ia=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:aa.describe("Price categories and rates for this specific token range.")}).refine(n=>n.maxTokens===null||typeof n.maxTokens=="number"&&n.maxTokens>n.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");zod.z.object({modelName:zod.z.string().describe("Model name this schedule applies to."),currency:zod.z.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:zod.z.array(ia).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((n,t)=>{let{tokenRanges:o}=n;o[0].minTokens!==0&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let i=1;i<o.length;i++){let l=o[i-1],s=o[i];if(l.maxTokens===null){t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",i-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}s.minTokens!==l.maxTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",i,"minTokens"],message:`Tier ${i} minTokens (${s.minTokens}) must equal previous tier's maxTokens (${l.maxTokens}) for contiguity.`}),s.minTokens<l.minTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",i,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${i} (${s.minTokens}) starts before Tier ${i-1} (${l.minTokens}).`});}let a=o[o.length-1];o.every(i=>i.maxTokens!==null||i===a)&&a.maxTokens!==null&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",o.length-1,"maxTokens"],message:"The final tier must have maxTokens = null (representing infinity)."});}).describe("Complete pricing schedule for a single chat model, including all its token-based tiers.");var sa="function";var ra=zod.z.enum(["object","array","number","string","boolean","null"]),la=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:ra.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(la).optional(),required:zod.z.array(zod.z.string()).optional()});var da=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 pa=zod.z.enum(["function"]),ma=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),ca=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:ma.optional()}),ua=zod.z.discriminatedUnion("type",[ca]),ga=zod.z.object({type:pa,definition:zod.z.object({schema:da}),request:ua.optional()}),ha=[sa];zod.z.enum(ha);var mo=(n=zod.z.undefined())=>zod.z.discriminatedUnion("type",[ga.extend({metadata:n})]),co=n=>eo().parse({modality:x,value:n}),uo=(n,t,o,a)=>oo().parse({modality:w,index:n,id:t,name:o,arguments:a});var ot=(n,t)=>se().parse({role:n,partialContent:to().parse({modality:Xe,value:t})}),nt=(n,t,o,a,i)=>se().parse({role:n,partialContent:no().parse({modality:Ye,index:t,id:o,name:a,arguments:i})}),go=(n,t)=>Ze().parse({modality:F,value:{type:ue,thinking:n,signature:t}});var ho=n=>Ze().parse({modality:F,value:{type:Je,data:n}});var he=(n,t,o)=>se().parse({role:n,partialContent:We().parse({modality:ce,value:{type:ue,thinking:t,signature:o}})}),yo=(n,t)=>se().parse({role:n,partialContent:We().parse({modality:ce,value:{type:Je,data:t}})});var ya=Object.defineProperty,fo=Object.getOwnPropertySymbols,fa=Object.prototype.hasOwnProperty,Ta=Object.prototype.propertyIsEnumerable,To=(n,t,o)=>t in n?ya(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,ye=(n,t)=>{for(var o in t||(t={}))fa.call(t,o)&&To(n,o,t[o]);if(fo)for(var o of fo(t))Ta.call(t,o)&&To(n,o,t[o]);return n},bo="ProviderError",at=class Eo extends X{constructor({info:t,cause:o}){super({info:t,cause:o},bo),this.name=bo,this.info=t,this.cause=o;}static isProviderError(t){return t instanceof Eo}};var Co="ModelResponseError",$=class vo extends X{constructor({info:t,cause:o}){super({info:t,cause:o},Co),this.name=Co,this.cause=o,this.info=t;}static isModelResponseError(t){return t instanceof vo}},Mo="InvalidModelRequestError",re=class Oo extends X{constructor({info:t,cause:o}){super({info:t,cause:o},Mo),this.name=Mo,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof Oo}},ko="InvalidConfigError",K=class Ao extends X{constructor({info:t,cause:o}){super({info:t,cause:o},ko),this.name=ko,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof Ao}},Ro="InvalidMessagesError",_=class Po extends X{constructor({info:t,cause:o}){super({info:t,cause:o},Ro),this.name=Ro,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof Po}},So="InvalidToolsError",it=class wo extends X{constructor({info:t,cause:o}){super({info:t,cause:o},So),this.name=So,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof wo}},xo="InvalidEmbeddingRequestsError",st=class _o extends X{constructor({info:t,cause:o}){super({info:t,cause:o},xo),this.name=xo,this.info=t,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof _o}},rt="multi-string",qo=zod.z.object({type:zod.z.literal(rt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),max:zod.z.number().int().positive()}),ba=n=>zod.z.array(zod.z.string()).max(n).default([]).optional(),Io=n=>({def:qo.parse(ye({type:rt},n)),schema:ba(n.max)}),jo="object-schema",Ca=zod.z.object({type:zod.z.literal(jo),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 lt="range",Lo=zod.z.object({type:zod.z.literal(lt),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()}),Ma=(n,t,o,a)=>zod.z.number().min(n).max(t).step(o).default(a).optional(),te=n=>({def:Lo.parse(ye({type:lt},n)),schema:Ma(n.min,n.max,n.step,n.default)}),dt="select-boolean",Bo=zod.z.object({type:zod.z.literal(dt),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()}),ka=n=>zod.z.boolean().nullable().default(n).optional(),fe=n=>({def:Bo.parse(ye({type:dt},n)),schema:ka(n.default)}),pt="select-string",No=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),default:zod.z.string(),choices:zod.z.array(zod.z.string())}),Ra=(n,t)=>zod.z.enum(t).nullable().default(n).optional(),le=n=>({def:No.parse(ye({type:pt},n)),schema:Ra(n.default,n.choices)}),Sa=[lt,rt,pt,jo,dt];zod.z.enum(Sa);var Uo=zod.z.discriminatedUnion("type",[Lo,qo,No,Bo,Ca]),M=(n=Ke,t=ao)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(n,zod.z.string().min(1).optional()),modalities:zod.z.array(t).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),maxReasoningTokens:zod.z.number().int().positive().min(1).optional(),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Uo),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var a,i;let l=Object.keys(o.def),s=Object.keys((i=(a=o.schema)==null?void 0:a.shape)!=null?i:{});return l.every(r=>s.includes(r))&&s.every(r=>l.includes(r))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()}),j=(n=ro)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(n).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Uo),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var o,a;let i=Object.keys(t.def),l=Object.keys((a=(o=t.schema)==null?void 0:o.shape)!=null?a:{});return i.every(s=>l.includes(s))&&l.every(s=>i.includes(s))},{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 xa={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."},Ea={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."},va={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},Oa=n=>({type:"multi",title:"Stop sequence",description:`Enter up to ${n} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Aa={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."},Pa={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."},wa={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."},_a={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."},qa={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."},Ia={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."},ja={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."},La={type:"range",title:"Repetition penalty",description:"Reduces the likelihood of repeating tokens from the input. Increasing this value makes the model less prone to repetition, but setting it too high may lead to less coherent output, often resulting in run-on sentences missing smaller words. The token penalty is scaled according to the original token's probability."},Ba={type:"boolean",title:"Log probs",description:"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned."},Na={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."},Ua={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},Da={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."},Va={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."},$a={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."},A={TEMPERATURE:xa,MAX_TOKENS:Ea,STOP:Oa,TOP_A:Aa,TOP_P:Pa,TOP_K:wa,MIN_P:_a,FREQUENCY_PENALTY:qa,PRESENCE_PENALTY:Ia,REPETITION_PENALTY:La,SEED:ja,LOG_PROBS:Ba,TOP_LOG_PROBS:Na,ECHO:Ua,RESPONSE_FORMAT:Da,RESPONSE_FORMAT_WITH_SCHEMA:Va,RESPONSE_SCHEMA:$a,MAX_REASONING_TOKENS:va};var Te=n=>Object.fromEntries(Object.entries(n).filter(([t,o])=>o!=null));var oe=n=>n==null?void 0:n.replace(/\/$/,"");var mt=te({param:"temperature",title:A.TEMPERATURE.title,description:A.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),ct=n=>te({param:"max_tokens",title:A.MAX_TOKENS.title,description:A.MAX_TOKENS.description,min:0,max:n,step:1,default:0}),ut=n=>Io({param:"stop_sequences",title:A.STOP(n).title,description:A.STOP(n).description,max:n}),gt=te({param:"top_p",title:A.TOP_P.title,description:A.TOP_P.description,min:0,max:1,step:.01,default:1}),ht=te({param:"top_k",title:A.TOP_K.title,description:A.TOP_K.description,min:0,max:1,step:.01,default:1}),yt=le({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"]});var be=(n,t)=>zod.z.object({temperature:mt.schema,maxTokens:ct(n).schema,stop:ut(t).schema,topP:gt.schema,topK:ht.schema,toolChoice:yt.schema}),Ce=(n,t)=>({temperature:mt.def,maxTokens:ct(n).def,stop:ut(t).def,topP:gt.def,topK:ht.def,toolChoice:yt.def});var Do=(n,t)=>te({param:"max_reasoning_tokens",title:A.MAX_REASONING_TOKENS.title,description:A.MAX_REASONING_TOKENS.description,min:n,max:t,step:1,default:0}),Vo=fe({param:"reasoning_enabled",title:"Reasoning Enabled",description:`Controls whether the model is allowed to think for a longer period of time before generating a response.
7
7
  This can be useful for complex tasks that require more time to think.`,default:!1}),$o=(n,t,o,a)=>me(b({},Ce(n,t)),{reasoningEnabled:Vo.def,maxReasoningTokens:Do(o,a).def}),zo=(n,t,o,a)=>be(n,t).extend({reasoningEnabled:Vo.schema,maxReasoningTokens:Do(o,a).schema});var ft=le({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"",choices:["base64",""]}),Tt=le({param:"input_type",title:"Input type",description:"Select the input type for the word embedding.",default:"",choices:["query","document",""]}),bt=fe({param:"truncation",title:"Truncation",description:"Select the truncation for the word embedding.",default:!0});var Fo=()=>zod.z.object({encodingFormat:ft.schema,inputType:Tt.schema,truncation:bt.schema}),Ho=()=>({encodingFormat:ft.def,inputType:Tt.def,truncation:bt.def});var g={base:(n,t)=>({def:Ce(n,t),schema:be(n,t)}),extendedThinking:(n,t,o,a)=>({def:$o(n,t,o,a),schema:zo(n,t,o,a)})},k={base:()=>({def:Ho(),schema:Fo()})};var Ha="anthropic",Y=class{constructor(){this.version="v1";this.name=Ha;this.chatModelFactories={[xt]:{model:we,modelOptions:Xo,modelSchema:Et},[Pt]:{model:je,modelOptions:en,modelSchema:wt},[Ot]:{model:Ie,modelOptions:Qo,modelSchema:At},[xe]:{model:Ee,modelOptions:Jo,modelSchema:kt},[ve]:{model:Oe,modelOptions:Zo,modelSchema:Rt},[_e]:{model:qe,modelOptions:Yo,modelSchema:vt},[Ae]:{model:Pe,modelOptions:Wo,modelSchema:St},[Re]:{model:Se,modelOptions:Go,modelSchema:Mt},[Me]:{model:ke,modelOptions:Ko,modelSchema:Ct}};this.embeddingModelFactories={[$t]:{model:Ve,modelOptions:rn,modelSchema:zt},[Dt]:{model:De,modelOptions:sn,modelSchema:Vt},[_t]:{model:Le,modelOptions:tn,modelSchema:qt},[It]:{model:Be,modelOptions:on,modelSchema:jt},[Lt]:{model:Ne,modelOptions:nn,modelSchema:Bt},[Nt]:{model:Ue,modelOptions:an,modelSchema:Ut}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((t,o)=>(t[o]=this.chatModelFactories[o].modelSchema,t),{})}chatModel(t){let o=t.modelName;if(!(o in this.chatModelFactories))throw new at({info:`Anthropic chat model: ${o} not found`,cause:new Error(`Anthropic chat model: ${o} not found, available chat models:
8
8
  ${this.chatModelLiterals().join(", ")}`)});let a=this.chatModelFactories[o].model,i=this.chatModelFactories[o].modelOptions.parse(t);return new a(i)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((t,o)=>(t[o]=this.embeddingModelFactories[o].modelSchema,t),{})}embeddingModel(t){let o=t.modelName;if(!(o in this.embeddingModelFactories))throw new at({info:`Anthropic embedding model: ${o} not found`,cause:new Error(`Anthropic embedding model: ${o} not found, available embedding models:
9
9
  ${this.embeddingModelLiterals().join(", ")}`)});let a=this.embeddingModelFactories[o].model,i=this.embeddingModelFactories[o].modelOptions.parse(t);return new a(i)}};Y.chatBaseUrl="https://api.anthropic.com/v1",Y.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}}}]}};var R=zod.z.enum([ee,Z,E,ie]),S={system:ee,user:Z,assistant:E,tool:Z};var L=[x,z,w,H],B=zod.z.enum([x,z,w,H]),ne=[x,z,w,H,F],ae=zod.z.enum([x,z,w,H,F]);var Ja=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),Za=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.record(zod.z.any())}),Wa=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string(),signature:zod.z.string()}),Xa=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),dn=zod.z.object({content:zod.z.array(zod.z.discriminatedUnion("type",[Ja,Za,Wa,Xa])),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()})}),pn=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()})})}),mn=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()})}),Ya=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),Qa=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.object({})}),ei=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string()}),ti=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),cn=zod.z.object({type:zod.z.literal("content_block_start"),index:zod.z.number(),content_block:zod.z.discriminatedUnion("type",[Ya,Qa,ei,ti])}),oi=zod.z.object({type:zod.z.literal("text_delta"),text:zod.z.string()}),ni=zod.z.object({type:zod.z.literal("input_json_delta"),partial_json:zod.z.string()}),ai=zod.z.object({type:zod.z.literal("thinking_delta"),thinking:zod.z.string()}),ii=zod.z.object({type:zod.z.literal("signature_delta"),signature:zod.z.string()}),un=zod.z.object({type:zod.z.literal("content_block_delta"),index:zod.z.number(),delta:zod.z.discriminatedUnion("type",[oi,ni,ai,ii])});var si=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string().optional(),signature:zod.z.string().optional()}),ri=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),li=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),input_schema:zod.z.any()}),di=zod.z.object({type:zod.z.enum(["auto","any"])}),pi=zod.z.object({type:zod.z.literal("tool"),name:zod.z.string().min(1)}),Ft=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),gn=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()})}),ws=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())}),hn=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([Ft,gn])).min(1))}),mi=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([Ft,gn,hn])).min(1))}),ci=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([Ft,hn,si,ri])).min(1))}),ui=zod.z.union([mi,ci]),yn=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(ui).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([di,pi]).optional(),tools:zod.z.array(li).min(1).optional(),top_p:zod.z.number().min(0).max(1).optional(),top_k:zod.z.number().min(0).optional()});var C=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional()}),T=class{constructor(t,o){this.version="v1";let a=C.parse(o);this.modelSchema=t,this.modelName=a.modelName,this.apiKey=a.apiKey,this.baseUrl=oe(Y.chatBaseUrl),this.completeChatUrl=oe(a.completeChatUrl||`${this.baseUrl}/messages`),this.streamChatUrl=oe(a.streamChatUrl||`${this.baseUrl}/messages`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"x-api-key":`${this.apiKey}`,"anthropic-version":"2023-06-01","content-type":"application/json","anthropic-dangerous-direct-browser-access":"true"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(t){let o=0,a=!0;return t["x-should-retry"]&&(a=t["x-should-retry"].toLowerCase()!=="false"),t["retry-after"]&&(o=parseInt(t["retry-after"])*1e3),{shouldRetry:a,delayMs:o}}getTokenCount(t){return t.reduce((o,a)=>o+a.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(t){let o=yn.safeParse(t);if(!o.success)throw new re({info:"Invalid model request",cause:o.error});let a=o.data,i=a.model;if(a.tool_choice&&(!a.tools||a.tools.length===0))throw new re({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let l={};a.tool_choice&&(a.tool_choice.type==="tool"?l.toolChoice=a.tool_choice.name:l.toolChoice=a.tool_choice.type),l.maxTokens=a.max_tokens,l.temperature=a.temperature,l.topP=a.top_p,l.topK=a.top_k,l.stop=a.stop_sequences;let s=ge().parse(Te(l)),r=[],m={};a.system&&r.push({role:ee,content:[{modality:x,value:a.system}]}),a.messages.forEach(f=>{let V=f.role;switch(V){case"user":{let I=f.content;if(typeof I=="string")r.push({role:V,content:[{modality:x,value:I}]});else {let u=I.map(y=>{if(y.type==="text")return {modality:x,value:y.text};if(y.type==="image"){let G="auto",J=y.source.media_type.split("/")[1];return {modality:z,detail:G,value:{type:Ge,mediaType:J,base64:y.source.data}}}else return {modality:H,id:y.tool_use_id,index:m[y.tool_use_id].index,name:m[y.tool_use_id].name,data:typeof y.content=="string"?y.content:JSON.stringify(y.content)}});r.push({role:V,content:u});}}break;case"assistant":{let I=f.content;if(typeof I=="string")r.push({role:V,content:[{modality:x,value:I}]});else {let u=I.map((y,G)=>{if(y.type==="text")return {modality:x,value:y.text};{let J={modality:w,id:y.id,index:G,name:y.name,arguments:JSON.stringify(y.input)};return m[y.id]=J,J}});r.push({role:V,content:u});}}break}});let h=[];return a.tools&&a.tools.forEach(f=>{h.push({type:"function",definition:{schema:{name:f.name,description:f.description||"",parameters:f.input_schema}}});}),{modelName:i,config:s,messages:r,tools:h.length>0?h:void 0}}transformConfig(t,o,a){let i=t.toolChoice,l=t.reasoningEnabled,s=t.maxReasoningTokens,r=b({},t);delete r.toolChoice,delete r.reasoningEnabled,delete r.maxReasoningTokens;let m=this.modelSchema.config.schema.safeParse(r);if(!m.success)throw new K({info:`Invalid config for model : '${this.modelName}'`,cause:m.error});let h=m.data;i!==void 0&&(h.toolChoice=i),Object.keys(h).forEach(u=>{if(!(u in this.modelSchema.config.def))throw new K({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${u}',