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