UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

3 lines • 6.6 kB
var e=`vercel.ai.error`,t=Symbol.for(e),n,r,i=class i extends (r=Error,n=t,r){constructor({name:e,message:t,cause:r}){super(t),this[n]=!0,this.name=e,this.cause=r}static isInstance(t){return i.hasMarker(t,e)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},ee=`AI_APICallError`,a=`vercel.ai.error.${ee}`,o=Symbol.for(a),te,s,c=class extends (s=i,te=o,s){constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:ee,message:e,cause:o}),this[te]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return i.hasMarker(e,a)}},l=`AI_EmptyResponseBodyError`,u=`vercel.ai.error.${l}`,ne=Symbol.for(u),d,f,re=class extends (f=i,d=ne,f){constructor({message:e=`Empty response body`}={}){super({name:l,message:e}),this[d]=!0}static isInstance(e){return i.hasMarker(e,u)}},p=`AI_EvaluationUnsupportedQuestionTypeError`,m=`vercel.ai.error.${p}`,ie=Symbol.for(m),h,g,ae=class extends (g=i,h=ie,g){constructor({questionId:e,questionType:t,provider:n,modelId:r,message:i=`Question "${e}" has type "${t}", which is not supported by provider "${n}" and model "${r}".`}){super({name:p,message:i}),this[h]=!0,this.questionId=e,this.questionType=t,this.provider=n,this.modelId=r}static isInstance(e){return i.hasMarker(e,m)}};function _(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}var v=`AI_InvalidArgumentError`,y=`vercel.ai.error.${v}`,oe=Symbol.for(y),b,x,se=class extends (x=i,b=oe,x){constructor({message:e,cause:t,argument:n}){super({name:v,message:e,cause:t}),this[b]=!0,this.argument=n}static isInstance(e){return i.hasMarker(e,y)}},S=`AI_InvalidPromptError`,C=`vercel.ai.error.${S}`,ce=Symbol.for(C),w,T,le=class extends (T=i,w=ce,T){constructor({prompt:e,message:t,cause:n}){super({name:S,message:`Invalid prompt: ${t}`,cause:n}),this[w]=!0,this.prompt=e}static isInstance(e){return i.hasMarker(e,C)}},E=`AI_InvalidResponseDataError`,D=`vercel.ai.error.${E}`,ue=Symbol.for(D),O,k,de=class extends (k=i,O=ue,k){constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:E,message:t}),this[O]=!0,this.data=e}static isInstance(e){return i.hasMarker(e,D)}},A=`AI_JSONParseError`,j=`vercel.ai.error.${A}`,fe=Symbol.for(j),M,N,pe=class extends (N=i,M=fe,N){constructor({text:e,cause:t}){super({name:A,message:`JSON parsing failed: Text: ${e}. Error message: ${_(t)}`,cause:t}),this[M]=!0,this.text=e}static isInstance(e){return i.hasMarker(e,j)}},P=`AI_LoadAPIKeyError`,F=`vercel.ai.error.${P}`,me=Symbol.for(F),I,L,he=class extends (L=i,I=me,L){constructor({message:e}){super({name:P,message:e}),this[I]=!0}static isInstance(e){return i.hasMarker(e,F)}},R=`AI_LoadSettingError`,z=`vercel.ai.error.${R}`,ge=Symbol.for(z),B,_e,ve=class extends (_e=i,B=ge,_e){constructor({message:e}){super({name:R,message:e}),this[B]=!0}static isInstance(e){return i.hasMarker(e,z)}},V=`AI_NoContentGeneratedError`,H=`vercel.ai.error.${V}`,ye=Symbol.for(H),U,W,be=class extends (W=i,U=ye,W){constructor({message:e=`No content generated.`}={}){super({name:V,message:e}),this[U]=!0}static isInstance(e){return i.hasMarker(e,H)}},G=`AI_NoSuchModelError`,K=`vercel.ai.error.${G}`,xe=Symbol.for(K),q,J,Se=class extends (J=i,q=xe,J){constructor({errorName:e=G,modelId:t,modelType:n,message:r=`No such ${n}: ${t}`}){super({name:e,message:r}),this[q]=!0,this.modelId=t,this.modelType=n}static isInstance(e){return i.hasMarker(e,K)}},Y=`AI_NoSuchProviderReferenceError`,X=`vercel.ai.error.${Y}`,Ce=Symbol.for(X),Z,we,Te=class extends (we=i,Z=Ce,we){constructor({provider:e,reference:t,message:n=`No provider reference found for provider '${e}'. Available providers: ${Object.keys(t).join(`, `)}`}){super({name:Y,message:n}),this[Z]=!0,this.provider=e,this.reference=t}static isInstance(e){return i.hasMarker(e,X)}},Ee=`AI_TooManyEmbeddingValuesForCallError`,De=`vercel.ai.error.${Ee}`,Oe=Symbol.for(De),ke,Ae,je=class extends (Ae=i,ke=Oe,Ae){constructor(e){super({name:Ee,message:`Too many values for a single embedding call. The ${e.provider} model "${e.modelId}" can only embed up to ${e.maxEmbeddingsPerCall} values per call, but ${e.values.length} values were provided.`}),this[ke]=!0,this.provider=e.provider,this.modelId=e.modelId,this.maxEmbeddingsPerCall=e.maxEmbeddingsPerCall,this.values=e.values}static isInstance(e){return i.hasMarker(e,De)}},Me=`AI_TypeValidationError`,Ne=`vercel.ai.error.${Me}`,Pe=Symbol.for(Ne),Fe,Q,Ie=class e extends (Q=i,Fe=Pe,Q){constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:Me,message:`${r}: Value: ${JSON.stringify(e)}. Error message: ${_(t)}`,cause:t}),this[Fe]=!0,this.value=e,this.context=n}static isInstance(e){return i.hasMarker(e,Ne)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},Le=`AI_UnsupportedFunctionalityError`,Re=`vercel.ai.error.${Le}`,ze=Symbol.for(Re),Be,Ve,He=class extends (Ve=i,Be=ze,Ve){constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:Le,message:t}),this[Be]=!0,this.functionality=e}static isInstance(e){return i.hasMarker(e,Re)}};function $(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?!0:Array.isArray(e)?e.every($):typeof e==`object`&&Object.entries(e).every(([e,t])=>typeof e==`string`&&(t===void 0||$(t)))}function Ue(e){return Array.isArray(e)&&e.every($)}function We(e){return typeof e==`object`&&!!e&&Object.entries(e).every(([e,t])=>typeof e==`string`&&(t===void 0||$(t)))}export{i as AISDKError,c as APICallError,re as EmptyResponseBodyError,ae as Experimental_EvaluationUnsupportedQuestionTypeError,se as InvalidArgumentError,le as InvalidPromptError,de as InvalidResponseDataError,pe as JSONParseError,he as LoadAPIKeyError,ve as LoadSettingError,be as NoContentGeneratedError,Se as NoSuchModelError,Te as NoSuchProviderReferenceError,je as TooManyEmbeddingValuesForCallError,Ie as TypeValidationError,He as UnsupportedFunctionalityError,_ as getErrorMessage,Ue as isJSONArray,We as isJSONObject,$ as isJSONValue};