opik 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- 'use strict';var ansiEscapes=require('ansi-escapes'),tslog=require('tslog'),pi=require('fs'),xn=require('ini'),ls=require('qs'),uuid=require('uuid'),async_hooks=require('async_hooks');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var pi__default=/*#__PURE__*/_interopDefault(pi);var xn__default=/*#__PURE__*/_interopDefault(xn);var ls__default=/*#__PURE__*/_interopDefault(ls);var hn=Object.defineProperty;var Ro=(s,t)=>()=>(s&&(t=s(s=0)),t);var T=(s,t)=>{for(var r in t)hn(s,r,{get:t[r],enumerable:true});};var Ri={};T(Ri,{Node18UniversalStreamWrapper:()=>jo});var jo,Ai=Ro(()=>{jo=class s{constructor(t){this.readableStream=t,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=false,this.resumeCallback=null,this.encoding=null;}on(t,r){var o;(o=this.events[t])==null||o.push(r);}off(t,r){var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(a=>a!==r);}pipe(t){return this.on("data",async r=>{if(t instanceof s)t._write(r);else if(t instanceof WritableStream){let o=t.getWriter();o.write(r).then(()=>o.releaseLock());}else t.write(r);}),this.on("end",async()=>{t instanceof s?t._end():t instanceof WritableStream?t.getWriter().close():t.end();}),this.on("error",async r=>{t instanceof s?t._error(r):t instanceof WritableStream?t.getWriter().abort(r):t.destroy(r);}),this._startReading(),t}pipeTo(t){return this.pipe(t)}unpipe(t){this.off("data",async r=>{if(t instanceof s)t._write(r);else if(t instanceof WritableStream){let o=t.getWriter();o.write(r).then(()=>o.releaseLock());}else t.write(r);}),this.off("end",async()=>{t instanceof s?t._end():t instanceof WritableStream?t.getWriter().close():t.end();}),this.off("error",async r=>{t instanceof s?t._error(r):t instanceof WritableStream?t.getWriter().abort(r):t.destroy(r);});}destroy(t){this.reader.cancel(t).then(()=>{this._emit("close");}).catch(r=>{this._emit("error",r);});}pause(){this.paused=true,this._emit("pause");}resume(){this.paused&&(this.paused=false,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null));}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:r}=await this.reader.read();if(!t)return r}setEncoding(t){this.encoding=t;}async text(){let t=[];for(;;){let{done:o,value:a}=await this.reader.read();if(o)break;a&&t.push(a);}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(t).arrayBuffer())}async json(){let t=await this.text();return JSON.parse(t)}_write(t){this._emit("data",t);}_end(){this._emit("end");}_error(t){this._emit("error",t);}_emit(t,r){if(this.events[t])for(let o of this.events[t]||[])o(r);}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:r}=await this.reader.read();if(t){this._emit("end"),this._emit("close");break}r&&this._emit("data",r);}}catch(t){this._emit("error",t);}}[Symbol.asyncIterator](){return {next:async()=>{this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:r}=await this.reader.read();return t?{done:true,value:void 0}:{done:false,value:r}},[Symbol.asyncIterator](){return this}}}};});var _i={};T(_i,{UndiciStreamWrapper:()=>Io});var Io,Ti=Ro(()=>{Io=class s{constructor(t){this.readableStream=t,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=false,this.resumeCallback=null,this.encoding=null;}on(t,r){var o;(o=this.events[t])==null||o.push(r);}off(t,r){var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(a=>a!==r);}pipe(t){return this.on("data",r=>{if(t instanceof s)t._write(r);else {let o=t.getWriter();o.write(r).then(()=>o.releaseLock());}}),this.on("end",()=>{t instanceof s?t._end():t.getWriter().close();}),this.on("error",r=>{t instanceof s?t._error(r):t.getWriter().abort(r);}),this._startReading(),t}pipeTo(t){return this.pipe(t)}unpipe(t){this.off("data",r=>{if(t instanceof s)t._write(r);else {let o=t.getWriter();o.write(r).then(()=>o.releaseLock());}}),this.off("end",()=>{t instanceof s?t._end():t.getWriter().close();}),this.off("error",r=>{t instanceof s?t._error(r):t.getWriter().abort(r);});}destroy(t){this.reader.cancel(t).then(()=>{this._emit("close");}).catch(r=>{this._emit("error",r);});}pause(){this.paused=true,this._emit("pause");}resume(){this.paused&&(this.paused=false,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null));}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:r}=await this.reader.read();if(!t)return r}setEncoding(t){this.encoding=t;}async text(){let t=[];for(;;){let{done:o,value:a}=await this.reader.read();if(o)break;a&&t.push(a);}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(t).arrayBuffer())}async json(){let t=await this.text();return JSON.parse(t)}_write(t){this._emit("data",t);}_end(){this._emit("end");}_error(t){this._emit("error",t);}_emit(t,r){if(this.events[t])for(let o of this.events[t]||[])o(r);}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:r}=await this.reader.read();if(t){this._emit("end"),this._emit("close");break}r&&this._emit("data",r);}}catch(t){this._emit("error",t);}}[Symbol.asyncIterator](){return {next:async()=>{this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:r}=await this.reader.read();return t?{done:true,value:void 0}:{done:false,value:r}},[Symbol.asyncIterator](){return this}}}};});var Pi={};T(Pi,{NodePre18StreamWrapper:()=>Uo});var Uo,Ei=Ro(()=>{Uo=class{constructor(t){this.readableStream=t;}on(t,r){this.readableStream.on(t,r);}off(t,r){this.readableStream.off(t,r);}pipe(t){return this.readableStream.pipe(t),t}pipeTo(t){return this.pipe(t)}unpipe(t){t?this.readableStream.unpipe(t):this.readableStream.unpipe();}destroy(t){this.readableStream.destroy(t);}pause(){this.readableStream.pause();}resume(){this.readableStream.resume();}get isPaused(){return this.readableStream.isPaused()}async read(){return new Promise((t,r)=>{let o=this.readableStream.read();o?t(o):(this.readableStream.once("readable",()=>{let a=this.readableStream.read();t(a);}),this.readableStream.once("error",r));})}setEncoding(t){this.readableStream.setEncoding(t),this.encoding=t;}async text(){let t=[],r=new TextEncoder;this.readableStream.setEncoding(this.encoding||"utf-8");for await(let a of this.readableStream)t.push(r.encode(a));return new TextDecoder(this.encoding||"utf-8").decode(Buffer.concat(t))}async json(){let t=await this.text();return JSON.parse(t)}[Symbol.asyncIterator](){let r=this.readableStream[Symbol.asyncIterator]();return {async next(){let{value:o,done:a}=await r.next();return {value:o,done:a}},[Symbol.asyncIterator](){return this}}}};});var Sn={SILLY:0,TRACE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,FATAL:6};function ci(s,t=s){return ansiEscapes.link(t,s)}var C=new tslog.Logger({hideLogPositionForProduction:true,prettyLogTemplate:"{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}} {{logLevelName}} "}),zn=s=>{C.settings.minLevel=Sn[s];};zn(process.env.OPIK_LOG_LEVEL||"INFO");var Rn="~/.opik.config",An={apiKey:"",apiUrl:"http://localhost:5173/api",projectName:"Default Project",workspaceName:"default"};function li(s){return Object.fromEntries(Object.entries(s).filter(([,t])=>t!==void 0))}function _n(){return li({apiKey:process.env.OPIK_API_KEY,apiUrl:process.env.OPIK_URL_OVERRIDE,projectName:process.env.OPIK_PROJECT_NAME,workspaceName:process.env.OPIK_WORKSPACE})}function Tn(){let s=process.env.OPIK_CONFIG_PATH||Rn;if(!pi__default.default.existsSync(s)){if(process.env.OPIK_CONFIG_PATH)throw new Error(`Config file not found at ${s}`);return {}}try{let t=xn__default.default.parse(pi__default.default.readFileSync(s,"utf8"));return t.opik?li({apiKey:t.opik.api_key,apiUrl:t.opik.url_override,projectName:t.opik.project_name,workspaceName:t.opik.workspace}):{}}catch(t){return C.error(`Error loading config file ${s}: ${t}`),{}}}function mi(s){let t=_n(),r=Tn();return Pn({...An,...r,...t,...s})}function Pn(s){if(!s.apiUrl)throw new Error("OPIK_URL_OVERRIDE is not set");let t=En(s.apiUrl);if(t&&!s.apiKey)throw new Error("OPIK_API_KEY is not set");if(t&&(!s.workspaceName||s.workspaceName==="default"))throw new Error("OPIK_WORKSPACE is not set");return s}function En(s){return new URL(s).hostname.endsWith("comet.com")}var W={};T(W,{AssistantMessageRole:()=>Dn,BadRequestError:()=>U,ColumnCompareTypesItem:()=>Jn,ColumnPublicTypesItem:()=>Gn,ColumnTypesItem:()=>Hn,ConflictError:()=>X,DatasetItemCompareSource:()=>Kn,DatasetItemPublicSource:()=>On,DatasetItemSource:()=>Ln,DatasetItemWriteSource:()=>Wn,DeltaRole:()=>Mn,FeedbackScoreBatchItemSource:()=>ss,FeedbackScoreCompareSource:()=>Xn,FeedbackScorePublicSource:()=>is,FeedbackScoreSource:()=>Vn,FindFeedbackDefinitionsRequestType:()=>di,FindFeedbackScoreNames1RequestType:()=>hi,ForbiddenError:()=>Y,GetSpanStatsRequestType:()=>yi,GetSpansByProjectRequestType:()=>wi,LlmAsJudgeMessagePublicRole:()=>Un,LlmAsJudgeMessageRole:()=>vn,LlmAsJudgeMessageWriteRole:()=>jn,LlmAsJudgeOutputSchemaPublicType:()=>Nn,LlmAsJudgeOutputSchemaType:()=>Cn,LlmAsJudgeOutputSchemaWriteType:()=>In,LogItemLevel:()=>Fn,NotFoundError:()=>_,NotImplementedError:()=>ge,ProjectMetricRequestPublicInterval:()=>fi,ProjectMetricRequestPublicMetricType:()=>gi,ProjectMetricResponsePublicInterval:()=>Zn,ProjectMetricResponsePublicMetricType:()=>Yn,PromptType:()=>qn,PromptVersionDetailType:()=>rs,PromptVersionPublicType:()=>os,PromptVersionType:()=>es,PromptWriteType:()=>bi,ProviderApiKeyProvider:()=>Qn,ProviderApiKeyPublicProvider:()=>$n,ProviderApiKeyWriteProvider:()=>ui,ResponseFormatType:()=>Bn,SpanFilterPublicOperator:()=>cs,SpanPublicType:()=>ns,SpanSearchStreamRequestPublicType:()=>ki,SpanType:()=>ts,SpanWriteType:()=>as,UnauthorizedError:()=>Q,UnprocessableEntityError:()=>B,automationRuleEvaluators:()=>To,chatCompletions:()=>Po,check:()=>_o,datasets:()=>Eo,experiments:()=>vo,feedbackDefinitions:()=>Sr,llmProviderKey:()=>zr,projects:()=>xr,prompts:()=>Rr,spans:()=>Ar,systemUsage:()=>Ao,traces:()=>Co});var Sr={};T(Sr,{FindFeedbackDefinitionsRequestType:()=>di});var di={Numerical:"numerical",Categorical:"categorical"};var zr={};T(zr,{ProviderApiKeyWriteProvider:()=>ui});var ui={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini"};var xr={};T(xr,{ProjectMetricRequestPublicInterval:()=>fi,ProjectMetricRequestPublicMetricType:()=>gi});var gi={FeedbackScores:"FEEDBACK_SCORES",TraceCount:"TRACE_COUNT",TokenUsage:"TOKEN_USAGE",Duration:"DURATION",Cost:"COST"};var fi={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var Rr={};T(Rr,{PromptWriteType:()=>bi});var bi={Mustache:"mustache",Jinja2:"jinja2"};var Ar={};T(Ar,{FindFeedbackScoreNames1RequestType:()=>hi,GetSpanStatsRequestType:()=>yi,GetSpansByProjectRequestType:()=>wi,SpanSearchStreamRequestPublicType:()=>ki});var wi={General:"general",Tool:"tool",Llm:"llm"};var hi={General:"general",Tool:"tool",Llm:"llm"};var yi={General:"general",Tool:"tool",Llm:"llm"};var ki={General:"general",Tool:"tool",Llm:"llm"};var Ao={};var _o={};var To={};var Po={};var Eo={};var vo={};var Co={};var vn={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT"};var Cn={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var jn={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT"};var In={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var Un={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT"};var Nn={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var Fn={Info:"INFO",Warn:"WARN",Error:"ERROR",Debug:"DEBUG",Trace:"TRACE"};var Dn={System:"system",User:"user",Assistant:"assistant",Tool:"tool",Function:"function"};var Mn={System:"system",User:"user",Assistant:"assistant",Tool:"tool",Function:"function"};var Bn={Text:"text",JsonObject:"json_object",JsonSchema:"json_schema"};var Ln={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Vn={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Wn={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Jn={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var Kn={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Xn={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var On={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Gn={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var Hn={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var $n={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini"};var Qn={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini"};var Yn={FeedbackScores:"FEEDBACK_SCORES",TraceCount:"TRACE_COUNT",TokenUsage:"TOKEN_USAGE",Duration:"DURATION",Cost:"COST"};var Zn={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var qn={Mustache:"mustache",Jinja2:"jinja2"};var es={Mustache:"mustache",Jinja2:"jinja2"};var rs={Mustache:"mustache",Jinja2:"jinja2"};var os={Mustache:"mustache",Jinja2:"jinja2"};var ts={General:"general",Tool:"tool",Llm:"llm"};var as={General:"general",Tool:"tool",Llm:"llm"};var is={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var ns={General:"general",Tool:"tool",Llm:"llm"};var ss={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var cs={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<="};var ie=(s,t,r)=>JSON.stringify(s,t,r);var c=class s extends Error{constructor({message:t,statusCode:r,body:o}){super(ps({message:t,statusCode:r,body:o})),Object.setPrototypeOf(this,s.prototype),r!=null&&(this.statusCode=r),o!==void 0&&(this.body=o);}};function ps({message:s,statusCode:t,body:r}){let o=[];return s!=null&&o.push(s),t!=null&&o.push(`Status code: ${t.toString()}`),r!=null&&o.push(`Body: ${ie(r,void 0,2)}`),o.join(`
2
- `)}var g=class s extends Error{constructor(t){super(t),Object.setPrototypeOf(this,s.prototype);}};var Q=class s extends c{constructor(t){super({message:"UnauthorizedError",statusCode:401,body:t}),Object.setPrototypeOf(this,s.prototype);}};var Y=class s extends c{constructor(t){super({message:"ForbiddenError",statusCode:403,body:t}),Object.setPrototypeOf(this,s.prototype);}};var _=class s extends c{constructor(t){super({message:"NotFoundError",statusCode:404,body:t}),Object.setPrototypeOf(this,s.prototype);}};var U=class s extends c{constructor(t){super({message:"BadRequestError",statusCode:400,body:t}),Object.setPrototypeOf(this,s.prototype);}};var B=class s extends c{constructor(t){super({message:"UnprocessableEntityError",statusCode:422,body:t}),Object.setPrototypeOf(this,s.prototype);}};var X=class s extends c{constructor(t){super({message:"ConflictError",statusCode:409,body:t}),Object.setPrototypeOf(this,s.prototype);}};var ge=class s extends c{constructor(t){super({message:"NotImplementedError",statusCode:501,body:t}),Object.setPrototypeOf(this,s.prototype);}};var b={Default:"http://localhost:5173/api"};function Si(s,t){return Object.keys(t!=null?t:{}).length>0?`${s}?${ls__default.default.stringify(t,{arrayFormat:"repeat"})}`:s}var m=ms();function ms(){var u,f,y,k,z;return typeof window!="undefined"&&typeof window.document!="undefined"?{type:"browser",version:window.navigator.userAgent}:typeof globalThis!="undefined"&&((u=globalThis==null?void 0:globalThis.navigator)==null?void 0:u.userAgent)==="Cloudflare-Workers"?{type:"workerd"}:typeof EdgeRuntime=="string"?{type:"edge-runtime"}:typeof self=="object"&&typeof(self==null?void 0:self.importScripts)=="function"&&(((f=self.constructor)==null?void 0:f.name)==="DedicatedWorkerGlobalScope"||((y=self.constructor)==null?void 0:y.name)==="ServiceWorkerGlobalScope"||((k=self.constructor)==null?void 0:k.name)==="SharedWorkerGlobalScope")?{type:"web-worker"}:typeof Deno!="undefined"&&typeof Deno.version!="undefined"&&typeof Deno.version.deno!="undefined"?{type:"deno",version:Deno.version.deno}:typeof Bun!="undefined"&&typeof Bun.version!="undefined"?{type:"bun",version:Bun.version}:typeof process!="undefined"&&"version"in process&&!!process.version&&"versions"in process&&!!((z=process.versions)!=null&&z.node)?{type:"node",version:process.versions.node,parsedVersion:Number(process.versions.node.split(".")[0])}:typeof navigator!="undefined"&&(navigator==null?void 0:navigator.product)==="ReactNative"?{type:"react-native"}:{type:"unknown"}}async function zi(){return m.type==="node"&&m.parsedVersion!=null&&m.parsedVersion>=18?fetch:m.type==="node"?(await import('node-fetch')).default:typeof fetch=="function"?fetch:(await import('node-fetch')).default}async function xi({body:s,type:t}){return t.includes("json")?ie(s):s}async function vi(s){return m.type==="node"&&m.parsedVersion!=null&&m.parsedVersion>=18?new(await Promise.resolve().then(()=>(Ai(),Ri))).Node18UniversalStreamWrapper(s):m.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(Ti(),_i))).UndiciStreamWrapper(s):new(await Promise.resolve().then(()=>(Ei(),Pi))).NodePre18StreamWrapper(s)}async function Ci(s,t){if(s.body!=null&&t==="blob")return await s.blob();if(s.body!=null&&t==="arrayBuffer")return await s.arrayBuffer();if(s.body!=null&&t==="sse")return s.body;if(s.body!=null&&t==="streaming")return vi(s.body);if(s.body!=null&&t==="text")return await s.text();{let r=await s.text();if(r.length>0)try{return JSON.parse(r)}catch{return {ok:false,error:{reason:"non-json",statusCode:s.status,rawBody:r}}}else return}}var ds="timeout";function ji(s){let t=new AbortController,r=setTimeout(()=>t.abort(ds),s);return {signal:t.signal,abortId:r}}function Ii(...s){let t=s.length===1&&Array.isArray(s[0])?s[0]:s,r=new AbortController;for(let o of t){if(o.aborted){r.abort(o==null?void 0:o.reason);break}o.addEventListener("abort",()=>r.abort(o==null?void 0:o.reason),{signal:r.signal});}return r.signal}var Ui=async(s,t,r,o,a,i,p,d,u)=>{let f=[],y;if(i!=null){let{signal:K,abortId:ee}=ji(i);y=ee,f.push(K);}p!=null&&f.push(p);let k=Ii(f),z=await s(t,{method:r,headers:o,body:a,signal:k,credentials:d?"include":void 0,duplex:u});return y!=null&&clearTimeout(y),z};function us(s){let t=1+(Math.random()*2-1)*.2;return s*t}async function Ni(s,t=2){let r=await s();for(let o=0;o<t&&([408,429].includes(r.status)||r.status>=500);++o){let a=Math.min(1e3*Math.pow(2,o),6e4),i=us(a);await new Promise(p=>setTimeout(p,i)),r=await s();}return r}async function gs(s){let t={};if(s.body!==void 0&&s.contentType!=null&&(t["Content-Type"]=s.contentType),s.headers!=null)for(let[i,p]of Object.entries(s.headers))p!=null&&(t[i]=p);let r=Si(s.url,s.queryParameters),o=await xi({body:s.body,type:s.requestType==="json"?"json":"other"}),a=await zi();try{let i=await Ni(async()=>Ui(a,r,s.method,t,o,s.timeoutMs,s.abortSignal,s.withCredentials,s.duplex),s.maxRetries),p=await Ci(i,s.responseType);return i.status>=200&&i.status<400?{ok:!0,body:p,headers:i.headers}:{ok:!1,error:{reason:"status-code",statusCode:i.status,body:p}}}catch(i){return s.abortSignal!=null&&s.abortSignal.aborted?{ok:false,error:{reason:"unknown",errorMessage:"The user aborted a request"}}:i instanceof Error&&i.name==="AbortError"?{ok:false,error:{reason:"timeout"}}:i instanceof Error?{ok:false,error:{reason:"unknown",errorMessage:i.message}}:{ok:false,error:{reason:"unknown",errorMessage:ie(i)}}}}var w=gs;var n={get:async s=>typeof s=="function"?s():s};var e={};T(e,{JsonError:()=>ne,ParseError:()=>se,any:()=>Qi,bigint:()=>Di,boolean:()=>Yi,booleanLiteral:()=>$i,date:()=>Mi,discriminant:()=>sn,enum_:()=>Tr,getObjectLikeUtils:()=>L,getObjectUtils:()=>re,getSchemaUtils:()=>A,isProperty:()=>q,lazy:()=>Bi,lazyObject:()=>Oi,list:()=>Er,number:()=>Zi,object:()=>Pr,objectWithoutOptionalProperties:()=>Xi,optional:()=>No,property:()=>Vi,record:()=>on,set:()=>tn,string:()=>qi,stringLiteral:()=>Hi,transform:()=>Fo,undiscriminatedUnion:()=>nn,union:()=>pn,unknown:()=>en,withParsedProperties:()=>Mo});var S={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function R(s,t){return `Expected ${t}. Received ${fs(s)}.`}function fs(s){if(Array.isArray(s))return "list";if(s===null)return "null";if(s instanceof BigInt)return "BigInt";switch(typeof s){case "string":return `"${s}"`;case "bigint":case "number":case "boolean":case "undefined":return `${s}`}return typeof s}function v(s){return {...s,json:Fi(s.json),parse:Fi(s.parse)}}function Fi(s){return (t,r)=>{let o=s(t,r),{skipValidation:a=false}=r!=null?r:{};return !o.ok&&a?(console.warn(["Failed to validate.",...o.errors.map(i=>" - "+(i.path.length>0?`${i.path.join(".")}: ${i.message}`:i.message))].join(`
3
- `)),{ok:true,value:t}):o}}function _r(s){return s.path.length===0?s.message:`${s.path.join(" -> ")}: ${s.message}`}var ne=class s extends Error{constructor(r){super(r.map(_r).join("; "));this.errors=r;Object.setPrototypeOf(this,s.prototype);}};var se=class s extends Error{constructor(r){super(r.map(_r).join("; "));this.errors=r;Object.setPrototypeOf(this,s.prototype);}};function A(s){return {nullable:()=>bs(s),optional:()=>No(s),optionalNullable:()=>ws(s),transform:t=>Fo(s,t),parseOrThrow:(t,r)=>{let o=s.parse(t,r);if(o.ok)return o.value;throw new se(o.errors)},jsonOrThrow:(t,r)=>{let o=s.json(t,r);if(o.ok)return o.value;throw new ne(o.errors)}}}function bs(s){let t={parse:(r,o)=>r==null?{ok:true,value:null}:s.parse(r,o),json:(r,o)=>r==null?{ok:true,value:null}:s.json(r,o),getType:()=>S.NULLABLE};return {...t,...A(t)}}function No(s){let t={parse:(r,o)=>r==null?{ok:true,value:void 0}:s.parse(r,o),json:(r,o)=>o!=null&&o.omitUndefined&&r===void 0?{ok:true,value:void 0}:r==null?{ok:true,value:null}:s.json(r,o),getType:()=>S.OPTIONAL};return {...t,...A(t)}}function ws(s){let t={parse:(r,o)=>r===void 0?{ok:true,value:void 0}:r===null?{ok:true,value:null}:s.parse(r,o),json:(r,o)=>r===void 0?{ok:true,value:void 0}:r===null?{ok:true,value:null}:s.json(r,o),getType:()=>S.OPTIONAL_NULLABLE};return {...t,...A(t)}}function Fo(s,t){let r={parse:(o,a)=>{let i=s.parse(o,a);return i.ok?{ok:true,value:t.transform(i.value)}:i},json:(o,a)=>{let i=t.untransform(o);return s.json(i,a)},getType:()=>s.getType()};return {...r,...A(r)}}function Di(){let s={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:true,value:t}:typeof t=="number"?{ok:true,value:BigInt(t)}:{ok:false,errors:[{path:r,message:R(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="bigint"?{ok:false,errors:[{path:r,message:R(t,"bigint")}]}:{ok:true,value:t},getType:()=>S.BIGINT};return {...v(s),...A(s)}}var hs=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function Mi(){let s={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:false,errors:[{path:r,message:R(t,"string")}]}:hs.test(t)?{ok:true,value:new Date(t)}:{ok:false,errors:[{path:r,message:R(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:true,value:t.toISOString()}:{ok:false,errors:[{path:r,message:R(t,"Date object")}]},getType:()=>S.DATE};return {...v(s),...A(s)}}function I(s,t){return ()=>{let r={parse:t,json:t,getType:()=>s};return {...v(r),...A(r)}}}function Tr(s){let t=new Set(s);return I(S.ENUM,(o,{allowUnrecognizedEnumValues:a,breadcrumbsPrefix:i=[]}={})=>typeof o!="string"?{ok:false,errors:[{path:i,message:R(o,"string")}]}:!t.has(o)&&!a?{ok:false,errors:[{path:i,message:R(o,"enum")}]}:{ok:true,value:o})()}function Bi(s){let t=Do(s);return {...t,...A(t)}}function Do(s){return {parse:(t,r)=>ce(s).parse(t,r),json:(t,r)=>ce(s).json(t,r),getType:()=>ce(s).getType()}}function ce(s){let t=s;return t.__zurg_memoized==null&&(t.__zurg_memoized=s()),t.__zurg_memoized}function fe(s){return Object.entries(s)}function be(s,t){let r=new Set(t);return Object.entries(s).reduce((o,[a,i])=>(r.has(a)&&(o[a]=i),o),{})}function Z(s){if(typeof s!="object"||s===null)return false;if(Object.getPrototypeOf(s)===null)return true;let t=s;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(s)===t}function we(s){return Object.keys(s)}function Li(s,t){let r=[],o=[];for(let a of s)t(a)?r.push(a):o.push(a);return [r,o]}function L(s){return {withParsedProperties:t=>Mo(s,t)}}function Mo(s,t){let r={parse:(o,a)=>{let i=s.parse(o,a);if(!i.ok)return i;let p=Object.entries(t).reduce((d,[u,f])=>({...d,[u]:typeof f=="function"?f(i.value):f}),{});return {ok:true,value:{...i.value,...p}}},json:(o,a)=>{var d;if(!Z(o))return {ok:false,errors:[{path:(d=a==null?void 0:a.breadcrumbsPrefix)!=null?d:[],message:R(o,"object")}]};let i=new Set(Object.keys(t)),p=be(o,Object.keys(o).filter(u=>!i.has(u)));return s.json(p,a)},getType:()=>s.getType()};return {...r,...A(r),...L(r)}}function Vi(s,t){return {rawKey:s,valueSchema:t,isProperty:true}}function q(s){return s.isProperty}function Pr(s){let t={_getRawProperties:()=>Object.entries(s).map(([r,o])=>q(o)?o.rawKey:r),_getParsedProperties:()=>we(s),parse:(r,o)=>{let a={},i=[];for(let[p,d]of fe(s)){let u=q(d)?d.rawKey:p,f=q(d)?d.valueSchema:d,y={rawKey:u,parsedKey:p,valueSchema:f};a[u]=y,Ki(f)&&i.push(u);}return Wi({value:r,requiredKeys:i,getProperty:p=>{let d=a[p];if(d!=null)return {transformedKey:d.parsedKey,transform:u=>{var f;return d.valueSchema.parse(u,{...o,breadcrumbsPrefix:[...(f=o==null?void 0:o.breadcrumbsPrefix)!=null?f:[],p]})}}},unrecognizedObjectKeys:o==null?void 0:o.unrecognizedObjectKeys,skipValidation:o==null?void 0:o.skipValidation,breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix,omitUndefined:o==null?void 0:o.omitUndefined})},json:(r,o)=>{let a=[];for(let[i,p]of fe(s)){let d=q(p)?p.valueSchema:p;Ki(d)&&a.push(i);}return Wi({value:r,requiredKeys:a,getProperty:i=>{let p=s[i];if(p!=null)return q(p)?{transformedKey:p.rawKey,transform:d=>{var u;return p.valueSchema.json(d,{...o,breadcrumbsPrefix:[...(u=o==null?void 0:o.breadcrumbsPrefix)!=null?u:[],i]})}}:{transformedKey:i,transform:d=>{var u;return p.json(d,{...o,breadcrumbsPrefix:[...(u=o==null?void 0:o.breadcrumbsPrefix)!=null?u:[],i]})}}},unrecognizedObjectKeys:o==null?void 0:o.unrecognizedObjectKeys,skipValidation:o==null?void 0:o.skipValidation,breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix,omitUndefined:o==null?void 0:o.omitUndefined})},getType:()=>S.OBJECT};return {...v(t),...A(t),...L(t),...re(t)}}function Wi({value:s,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:o="fail",skipValidation:a=false,breadcrumbsPrefix:i=[]}){if(!Z(s))return {ok:false,errors:[{path:i,message:R(s,"object")}]};let p=new Set(t),d=[],u={};for(let[f,y]of Object.entries(s)){let k=r(f);if(k!=null){p.delete(f);let z=k.transform(y);z.ok?u[k.transformedKey]=z.value:(u[f]=y,d.push(...z.errors));}else switch(o){case "fail":d.push({path:[...i,f],message:`Unexpected key "${f}"`});break;case "strip":break;case "passthrough":u[f]=y;break}}return d.push(...t.filter(f=>p.has(f)).map(f=>({path:i,message:`Missing required key "${f}"`}))),d.length===0||a?{ok:true,value:u}:{ok:false,errors:d}}function re(s){return {extend:t=>{let r={_getParsedProperties:()=>[...s._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...s._getRawProperties(),...t._getRawProperties()],parse:(o,a)=>Ji({extensionKeys:t._getRawProperties(),value:o,transformBase:i=>s.parse(i,a),transformExtension:i=>t.parse(i,a)}),json:(o,a)=>Ji({extensionKeys:t._getParsedProperties(),value:o,transformBase:i=>s.json(i,a),transformExtension:i=>t.json(i,a)}),getType:()=>S.OBJECT};return {...r,...A(r),...L(r),...re(r)}},passthrough:()=>{let t={_getParsedProperties:()=>s._getParsedProperties(),_getRawProperties:()=>s._getRawProperties(),parse:(r,o)=>{let a=s.parse(r,{...o,unrecognizedObjectKeys:"passthrough"});return a.ok?{ok:true,value:{...r,...a.value}}:a},json:(r,o)=>{let a=s.json(r,{...o,unrecognizedObjectKeys:"passthrough"});return a.ok?{ok:true,value:{...r,...a.value}}:a},getType:()=>S.OBJECT};return {...t,...A(t),...L(t),...re(t)}}}}function Ji({extensionKeys:s,value:t,transformBase:r,transformExtension:o}){let a=new Set(s),[i,p]=Li(we(t),f=>a.has(f)),d=r(be(t,p)),u=o(be(t,i));return d.ok&&u.ok?{ok:true,value:{...d.value,...u.value}}:{ok:false,errors:[...d.ok?[]:d.errors,...u.ok?[]:u.errors]}}function Ki(s){return !ys(s)}function ys(s){switch(s.getType()){case S.ANY:case S.UNKNOWN:case S.OPTIONAL:case S.OPTIONAL_NULLABLE:return true;default:return false}}function Xi(s){return Pr(s)}function Oi(s){let t={...Do(s),_getRawProperties:()=>ce(s)._getRawProperties(),_getParsedProperties:()=>ce(s)._getParsedProperties()};return {...t,...A(t),...L(t),...re(t)}}function Er(s){let t={parse:(r,o)=>Gi(r,(a,i)=>{var p;return s.parse(a,{...o,breadcrumbsPrefix:[...(p=o==null?void 0:o.breadcrumbsPrefix)!=null?p:[],`[${i}]`]})}),json:(r,o)=>Gi(r,(a,i)=>{var p;return s.json(a,{...o,breadcrumbsPrefix:[...(p=o==null?void 0:o.breadcrumbsPrefix)!=null?p:[],`[${i}]`]})}),getType:()=>S.LIST};return {...v(t),...A(t)}}function Gi(s,t){return Array.isArray(s)?s.map((o,a)=>t(o,a)).reduce((o,a)=>{if(o.ok&&a.ok)return {ok:true,value:[...o.value,a.value]};let i=[];return o.ok||i.push(...o.errors),a.ok||i.push(...a.errors),{ok:false,errors:i}},{ok:true,value:[]}):{ok:false,errors:[{message:R(s,"list"),path:[]}]}}function Hi(s){return I(S.STRING_LITERAL,(r,{breadcrumbsPrefix:o=[]}={})=>r===s?{ok:true,value:s}:{ok:false,errors:[{path:o,message:R(r,`"${s}"`)}]})()}function $i(s){return I(S.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:o=[]}={})=>r===s?{ok:true,value:s}:{ok:false,errors:[{path:o,message:R(r,`${s.toString()}`)}]})()}var Qi=I(S.ANY,s=>({ok:true,value:s}));var Yi=I(S.BOOLEAN,(s,{breadcrumbsPrefix:t=[]}={})=>typeof s=="boolean"?{ok:true,value:s}:{ok:false,errors:[{path:t,message:R(s,"boolean")}]});var Zi=I(S.NUMBER,(s,{breadcrumbsPrefix:t=[]}={})=>typeof s=="number"?{ok:true,value:s}:{ok:false,errors:[{path:t,message:R(s,"number")}]});var qi=I(S.STRING,(s,{breadcrumbsPrefix:t=[]}={})=>typeof s=="string"?{ok:true,value:s}:{ok:false,errors:[{path:t,message:R(s,"string")}]});var en=I(S.UNKNOWN,s=>({ok:true,value:s}));function on(s,t){let r={parse:(o,a)=>rn({value:o,isKeyNumeric:s.getType()===S.NUMBER,transformKey:i=>{var p;return s.parse(i,{...a,breadcrumbsPrefix:[...(p=a==null?void 0:a.breadcrumbsPrefix)!=null?p:[],`${i} (key)`]})},transformValue:(i,p)=>{var d;return t.parse(i,{...a,breadcrumbsPrefix:[...(d=a==null?void 0:a.breadcrumbsPrefix)!=null?d:[],`${p}`]})},breadcrumbsPrefix:a==null?void 0:a.breadcrumbsPrefix}),json:(o,a)=>rn({value:o,isKeyNumeric:s.getType()===S.NUMBER,transformKey:i=>{var p;return s.json(i,{...a,breadcrumbsPrefix:[...(p=a==null?void 0:a.breadcrumbsPrefix)!=null?p:[],`${i} (key)`]})},transformValue:(i,p)=>{var d;return t.json(i,{...a,breadcrumbsPrefix:[...(d=a==null?void 0:a.breadcrumbsPrefix)!=null?d:[],`${p}`]})},breadcrumbsPrefix:a==null?void 0:a.breadcrumbsPrefix}),getType:()=>S.RECORD};return {...v(r),...A(r)}}function rn({value:s,isKeyNumeric:t,transformKey:r,transformValue:o,breadcrumbsPrefix:a=[]}){return Z(s)?fe(s).reduce((i,[p,d])=>{if(d===void 0)return i;let u=i,f=p;if(t){let K=p.length>0?Number(p):NaN;isNaN(K)||(f=K);}let y=r(f),k=o(d,f);if(u.ok&&y.ok&&k.ok)return {ok:true,value:{...u.value,[y.value]:k.value}};let z=[];return u.ok||z.push(...u.errors),y.ok||z.push(...y.errors),k.ok||z.push(...k.errors),{ok:false,errors:z}},{ok:true,value:{}}):{ok:false,errors:[{path:a,message:R(s,"object")}]}}function tn(s){let t=Er(s),r={parse:(o,a)=>{let i=t.parse(o,a);return i.ok?{ok:true,value:new Set(i.value)}:i},json:(o,a)=>{var p;return o instanceof Set?t.json([...o],a):{ok:false,errors:[{path:(p=a==null?void 0:a.breadcrumbsPrefix)!=null?p:[],message:R(o,"Set")}]}},getType:()=>S.SET};return {...v(r),...A(r)}}function nn(s){let t={parse:(r,o)=>an((a,i)=>a.parse(r,i),s,o),json:(r,o)=>an((a,i)=>a.json(r,i),s,o),getType:()=>S.UNDISCRIMINATED_UNION};return {...v(t),...A(t)}}function an(s,t,r){let o=[];for(let[a,i]of t.entries()){let p=s(i,{...r,skipValidation:false});if(p.ok)return p;for(let d of p.errors)o.push({path:d.path,message:`[Variant ${a}] ${d.message}`});}return {ok:false,errors:o}}function sn(s,t){return {parsedDiscriminant:s,rawDiscriminant:t}}function pn(s,t){let r=typeof s=="string"?s:s.rawDiscriminant,o=typeof s=="string"?s:s.parsedDiscriminant,a=Tr(we(t)),i={parse:(p,d)=>cn({value:p,discriminant:r,transformedDiscriminant:o,transformDiscriminantValue:u=>{var f;return a.parse(u,{allowUnrecognizedEnumValues:d==null?void 0:d.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(f=d==null?void 0:d.breadcrumbsPrefix)!=null?f:[],r]})},getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:d==null?void 0:d.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,f)=>f.parse(u,d),breadcrumbsPrefix:d==null?void 0:d.breadcrumbsPrefix}),json:(p,d)=>cn({value:p,discriminant:o,transformedDiscriminant:r,transformDiscriminantValue:u=>{var f;return a.json(u,{allowUnrecognizedEnumValues:d==null?void 0:d.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(f=d==null?void 0:d.breadcrumbsPrefix)!=null?f:[],o]})},getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:d==null?void 0:d.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,f)=>f.json(u,d),breadcrumbsPrefix:d==null?void 0:d.breadcrumbsPrefix}),getType:()=>S.UNION};return {...v(i),...A(i),...L(i)}}function cn({value:s,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:o,getAdditionalPropertiesSchema:a,allowUnrecognizedUnionMembers:i=false,transformAdditionalProperties:p,breadcrumbsPrefix:d=[]}){if(!Z(s))return {ok:false,errors:[{path:d,message:R(s,"object")}]};let{[t]:u,...f}=s;if(u==null)return {ok:false,errors:[{path:d,message:`Missing discriminant ("${t}")`}]};let y=o(u);if(!y.ok)return {ok:false,errors:y.errors};let k=a(y.value);if(k==null)return i?{ok:true,value:{[r]:y.value,...f}}:{ok:false,errors:[{path:[...d,t],message:"Unexpected discriminant value"}]};let z=p(f,k);return z.ok?{ok:true,value:{[r]:u,...z.value}}:z}function ks(s){var t=[];if(s.length===0)return "";if(typeof s[0]!="string")throw new TypeError("Url must be a string. Received "+s[0]);if(s[0].match(/^[^/:]+:\/*$/)&&s.length>1){var r=s.shift();s[0]=r+s[0];}s[0].match(/^file:\/\/\//)?s[0]=s[0].replace(/^([^/:]+):\/*/,"$1:///"):s[0]=s[0].replace(/^([^/:]+):\/*/,"$1://");for(var o=0;o<s.length;o++){var a=s[o];if(typeof a!="string")throw new TypeError("Url must be a string. Received "+a);a!==""&&(o>0&&(a=a.replace(/^[\/]+/,"")),o<s.length-1?a=a.replace(/[\/]+$/,""):a=a.replace(/[\/]+$/,"/"),t.push(a));}var i=t.join("/");i=i.replace(/\/(\?|&|#[^!])/g,"$1");var p=i.split("?");return i=p.shift()+(p.length>0?"?":"")+p.join("&"),i}function h(){var s;return typeof arguments[0]=="object"?s=arguments[0]:s=[].slice.call(arguments),ks(s)}var N={};T(N,{AssistantMessage:()=>_t,AssistantMessageRole:()=>At,AuthDetailsHolder:()=>ot,AutomationRuleEvaluator:()=>As,AutomationRuleEvaluatorLlmAsJudge:()=>ct,AutomationRuleEvaluatorLlmAsJudgePublic:()=>rr,AutomationRuleEvaluatorLlmAsJudgeWrite:()=>ft,AutomationRuleEvaluatorObjectPublic:()=>zt,AutomationRuleEvaluatorPagePublic:()=>Yr,AutomationRuleEvaluatorPublic:()=>Zr,AutomationRuleEvaluatorUpdate:()=>eo,AutomationRuleEvaluatorWrite:()=>Qr,AvgValueStatPublic:()=>$a,BatchDelete:()=>E,BiInformation:()=>qo,BiInformationResponse:()=>qe,CategoricalFeedbackDefinition:()=>oa,CategoricalFeedbackDefinitionCreate:()=>na,CategoricalFeedbackDefinitionPublic:()=>ir,CategoricalFeedbackDefinitionUpdate:()=>ba,CategoricalFeedbackDetail:()=>ra,CategoricalFeedbackDetailCreate:()=>ia,CategoricalFeedbackDetailPublic:()=>la,CategoricalFeedbackDetailUpdate:()=>fa,ChatCompletionChoice:()=>Et,ChatCompletionRequest:()=>Xe,ChatCompletionResponse:()=>jt,ChunkedOutputJsonNode:()=>Cs,ChunkedOutputJsonNodePublic:()=>Vs,ChunkedOutputJsonNodePublicType:()=>ti,ChunkedOutputJsonNodeType:()=>Zt,Column:()=>Qt,ColumnCompare:()=>Ft,ColumnCompareTypesItem:()=>Nt,ColumnPublic:()=>Gt,ColumnPublicTypesItem:()=>Ot,ColumnTypesItem:()=>$t,Comment:()=>j,CommentCompare:()=>Dt,CommentPublic:()=>te,CompletionTokensDetails:()=>vt,CountValueStatPublic:()=>Qa,CreatePromptVersionDetail:()=>Ae,DataPointNumberPublic:()=>Aa,Dataset:()=>Es,DatasetIdentifier:()=>$e,DatasetIdentifierPublic:()=>Ye,DatasetItem:()=>Ut,DatasetItemBatch:()=>vs,DatasetItemBatchWrite:()=>Ge,DatasetItemCompare:()=>Wt,DatasetItemCompareSource:()=>Mt,DatasetItemPageCompare:()=>Jt,DatasetItemPagePublic:()=>Ht,DatasetItemPublic:()=>ar,DatasetItemPublicSource:()=>Xt,DatasetItemSource:()=>It,DatasetItemStreamRequest:()=>Ze,DatasetItemWrite:()=>Zo,DatasetItemWriteSource:()=>Yo,DatasetItemsDelete:()=>Qe,DatasetPagePublic:()=>Kt,DatasetPublic:()=>de,DatasetUpdate:()=>He,DatasetWrite:()=>Oe,DeleteFeedbackScore:()=>lr,Delta:()=>Pt,DeltaRole:()=>Tt,ErrorInfo:()=>G,ErrorInfoPublic:()=>mr,ErrorInfoWrite:()=>Pe,ErrorMessage:()=>$,ErrorMessageDetail:()=>Bs,ErrorMessageDetailed:()=>Ds,ErrorMessagePublic:()=>Is,Experiment:()=>js,ExperimentItem:()=>Ue,ExperimentItemCompare:()=>Vt,ExperimentItemPublic:()=>tr,ExperimentItemStreamRequest:()=>Be,ExperimentItemsBatch:()=>Ne,ExperimentItemsDelete:()=>Fe,ExperimentPagePublic:()=>ea,ExperimentPublic:()=>ue,ExperimentWrite:()=>Ie,ExperimentsDelete:()=>De,Feedback:()=>Us,FeedbackCreate:()=>pa,FeedbackDefinitionPagePublic:()=>ua,FeedbackObjectPublic:()=>da,FeedbackPublic:()=>ga,FeedbackScore:()=>V,FeedbackScoreAverage:()=>oe,FeedbackScoreAverageDetailed:()=>ja,FeedbackScoreAveragePublic:()=>qt,FeedbackScoreBatch:()=>fr,FeedbackScoreBatchItem:()=>oi,FeedbackScoreBatchItemSource:()=>ri,FeedbackScoreCompare:()=>Lt,FeedbackScoreCompareSource:()=>Bt,FeedbackScoreNames:()=>Ra,FeedbackScorePublic:()=>dr,FeedbackScorePublicSource:()=>Oa,FeedbackScoreSource:()=>Ko,FeedbackUpdate:()=>ya,FindFeedbackDefinitionsRequestType:()=>vr,FindFeedbackScoreNames1RequestType:()=>Lr,Function:()=>Ke,FunctionCall:()=>H,GetSpanStatsRequestType:()=>Vr,GetSpansByProjectRequestType:()=>Br,IdentifierPublic:()=>Me,JsonNode:()=>x,JsonNodeCompare:()=>ro,JsonNodeDetail:()=>Bo,JsonNodePublic:()=>M,JsonNodeWrite:()=>D,JsonObjectSchema:()=>Je,JsonSchema:()=>Ho,JsonSchemaElement:()=>Gr,LlmAsJudgeCode:()=>er,LlmAsJudgeCodePublic:()=>St,LlmAsJudgeCodeWrite:()=>gt,LlmAsJudgeMessage:()=>it,LlmAsJudgeMessagePublic:()=>ht,LlmAsJudgeMessagePublicRole:()=>wt,LlmAsJudgeMessageRole:()=>at,LlmAsJudgeMessageWrite:()=>mt,LlmAsJudgeMessageWriteRole:()=>lt,LlmAsJudgeModelParameters:()=>tt,LlmAsJudgeModelParametersPublic:()=>bt,LlmAsJudgeModelParametersWrite:()=>pt,LlmAsJudgeOutputSchema:()=>st,LlmAsJudgeOutputSchemaPublic:()=>kt,LlmAsJudgeOutputSchemaPublicType:()=>yt,LlmAsJudgeOutputSchemaType:()=>nt,LlmAsJudgeOutputSchemaWrite:()=>ut,LlmAsJudgeOutputSchemaWriteType:()=>dt,LogItem:()=>Rt,LogItemLevel:()=>xt,LogPage:()=>qr,Message:()=>Xo,NumericalFeedbackDefinition:()=>aa,NumericalFeedbackDefinitionCreate:()=>ca,NumericalFeedbackDefinitionPublic:()=>nr,NumericalFeedbackDefinitionUpdate:()=>ha,NumericalFeedbackDetail:()=>ta,NumericalFeedbackDetailCreate:()=>sa,NumericalFeedbackDetailPublic:()=>ma,NumericalFeedbackDetailUpdate:()=>wa,PageColumns:()=>Yt,PercentageValueStatPublic:()=>Za,PercentageValues:()=>pr,PercentageValuesDetailed:()=>Ia,PercentageValuesPublic:()=>Ya,Project:()=>Fs,ProjectDetailed:()=>Ua,ProjectMetricRequestPublic:()=>ze,ProjectMetricRequestPublicInterval:()=>Nr,ProjectMetricRequestPublicMetricType:()=>Ur,ProjectMetricResponsePublic:()=>Ea,ProjectMetricResponsePublicInterval:()=>Ta,ProjectMetricResponsePublicMetricType:()=>_a,ProjectPagePublic:()=>cr,ProjectPublic:()=>sr,ProjectRetrieveDetailed:()=>xe,ProjectStatItemObjectPublic:()=>ei,ProjectStatsPublic:()=>gr,ProjectStatsSummary:()=>Ca,ProjectStatsSummaryItem:()=>va,ProjectUpdate:()=>Se,ProjectWrite:()=>ke,Prompt:()=>Ms,PromptDetail:()=>Ma,PromptPagePublic:()=>Ja,PromptPublic:()=>Wa,PromptType:()=>Na,PromptUpdatable:()=>_e,PromptVersion:()=>Da,PromptVersionDetail:()=>O,PromptVersionDetailType:()=>Lo,PromptVersionLink:()=>oo,PromptVersionLinkPublic:()=>to,PromptVersionLinkWrite:()=>Xr,PromptVersionPagePublic:()=>Va,PromptVersionPublic:()=>La,PromptVersionPublicType:()=>Ba,PromptVersionRetrieveDetail:()=>Te,PromptVersionType:()=>Fa,PromptWrite:()=>Re,PromptWriteType:()=>Dr,ProviderApiKey:()=>Ns,ProviderApiKeyProvider:()=>za,ProviderApiKeyPublic:()=>Sa,ProviderApiKeyPublicProvider:()=>ka,ProviderApiKeyUpdate:()=>ye,ProviderApiKeyWrite:()=>he,ProviderApiKeyWriteProvider:()=>jr,ResponseFormat:()=>$o,ResponseFormatType:()=>Go,ResultsNumberPublic:()=>Pa,ScoreName:()=>xa,Span:()=>Xa,SpanBatch:()=>Ls,SpanBatchWrite:()=>ve,SpanFilterPublic:()=>Jo,SpanFilterPublicOperator:()=>Wo,SpanPagePublic:()=>Ha,SpanPublic:()=>ur,SpanPublicType:()=>Ga,SpanSearchStreamRequestPublic:()=>je,SpanSearchStreamRequestPublicType:()=>Wr,SpanType:()=>Ka,SpanUpdate:()=>Ce,SpanWrite:()=>Ee,SpanWriteType:()=>Vo,StreamOptions:()=>Oo,Tool:()=>Qo,ToolCall:()=>or,Trace:()=>ai,TraceBatch:()=>Ws,TraceBatchWrite:()=>Ve,TraceCountResponse:()=>rt,TracePagePublic:()=>ii,TracePublic:()=>br,TraceUpdate:()=>We,TraceWrite:()=>Le,Usage:()=>Ct,WorkspaceTraceCount:()=>et,chatCompletions:()=>Hr,datasets:()=>$r,experiments:()=>le,feedbackDefinitions:()=>Cr,llmProviderKey:()=>Ir,projects:()=>Fr,prompts:()=>Mr,spans:()=>pe,traces:()=>me});var Cr={};T(Cr,{FindFeedbackDefinitionsRequestType:()=>vr});var vr=e.enum_(["numerical","categorical"]);var Ir={};T(Ir,{ProviderApiKeyUpdate:()=>ye,ProviderApiKeyWrite:()=>he,ProviderApiKeyWriteProvider:()=>jr});var jr=e.enum_(["openai","anthropic","gemini"]);var he=e.object({provider:jr,apiKey:e.property("api_key",e.string()),name:e.string().optional()});var ye=e.object({apiKey:e.property("api_key",e.string()),name:e.string().optional()});var Fr={};T(Fr,{ProjectMetricRequestPublic:()=>ze,ProjectMetricRequestPublicInterval:()=>Nr,ProjectMetricRequestPublicMetricType:()=>Ur,ProjectRetrieveDetailed:()=>xe,ProjectUpdate:()=>Se,ProjectWrite:()=>ke});var Ur=e.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST"]);var Nr=e.enum_(["HOURLY","DAILY","WEEKLY"]);var ke=e.object({name:e.string(),description:e.string().optional()});var Se=e.object({name:e.string().optional(),description:e.string().optional()});var ze=e.object({metricType:e.property("metric_type",Ur.optional()),interval:Nr.optional(),intervalStart:e.property("interval_start",e.date().optional()),intervalEnd:e.property("interval_end",e.date().optional())});var xe=e.object({name:e.string()});var Mr={};T(Mr,{CreatePromptVersionDetail:()=>Ae,PromptUpdatable:()=>_e,PromptVersionRetrieveDetail:()=>Te,PromptWrite:()=>Re,PromptWriteType:()=>Dr});var Dr=e.enum_(["mustache","jinja2"]);var D=e.record(e.string(),e.unknown());var Re=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),template:e.string().optional(),metadata:D.optional(),changeDescription:e.property("change_description",e.string().optional()),type:Dr.optional()});var Bo=e.record(e.string(),e.unknown());var Lo=e.enum_(["mustache","jinja2"]);var O=e.object({id:e.string().optional(),promptId:e.property("prompt_id",e.string().optional()),commit:e.string().optional(),template:e.string(),metadata:Bo.optional(),type:Lo.optional(),changeDescription:e.property("change_description",e.string().optional()),variables:e.list(e.string()).optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional())});var Ae=e.object({name:e.string(),version:O});var _e=e.object({name:e.string(),description:e.string().optional()});var Te=e.object({name:e.string(),commit:e.string().optional()});var pe={};T(pe,{FindFeedbackScoreNames1RequestType:()=>Lr,GetSpanStatsRequestType:()=>Vr,GetSpansByProjectRequestType:()=>Br,SpanBatchWrite:()=>ve,SpanSearchStreamRequestPublic:()=>je,SpanSearchStreamRequestPublicType:()=>Wr,SpanUpdate:()=>Ce,findFeedbackScoreNames1:()=>Jr});var Br=e.enum_(["general","tool","llm"]);var Lr=e.enum_(["general","tool","llm"]);var Vr=e.enum_(["general","tool","llm"]);var Wr=e.enum_(["general","tool","llm"]);var Jr={};T(Jr,{Response:()=>Ss});var Ss=e.list(e.string());var Vo=e.enum_(["general","tool","llm"]);var Pe=e.object({exceptionType:e.property("exception_type",e.string()),message:e.string().optional(),traceback:e.string()});var Ee=e.object({id:e.string().optional(),projectName:e.property("project_name",e.string().optional()),traceId:e.property("trace_id",e.string()),parentSpanId:e.property("parent_span_id",e.string().optional()),name:e.string(),type:Vo,startTime:e.property("start_time",e.date()),endTime:e.property("end_time",e.date().optional()),input:D.optional(),output:D.optional(),metadata:D.optional(),model:e.string().optional(),provider:e.string().optional(),tags:e.list(e.string()).optional(),usage:e.record(e.string(),e.number()).optional(),errorInfo:e.property("error_info",Pe.optional()),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),totalEstimatedCostVersion:e.property("total_estimated_cost_version",e.string().optional())});var ve=e.object({spans:e.list(Ee)});var x=e.record(e.string(),e.unknown());var G=e.object({exceptionType:e.property("exception_type",e.string()),message:e.string().optional(),traceback:e.string()});var Ce=e.object({projectName:e.property("project_name",e.string().optional()),projectId:e.property("project_id",e.string().optional()),traceId:e.property("trace_id",e.string()),parentSpanId:e.property("parent_span_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),input:x.optional(),output:x.optional(),metadata:x.optional(),model:e.string().optional(),provider:e.string().optional(),tags:e.list(e.string()).optional(),usage:e.record(e.string(),e.number()).optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),errorInfo:e.property("error_info",G.optional())});var Wo=e.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<="]);var Jo=e.object({field:e.string().optional(),operator:Wo.optional(),key:e.string().optional(),value:e.string().optional()});var je=e.object({traceId:e.property("trace_id",e.string().optional()),projectName:e.property("project_name",e.string().optional()),projectId:e.property("project_id",e.string().optional()),type:Wr.optional(),filters:e.list(Jo).optional(),limit:e.number().optional(),lastRetrievedId:e.property("last_retrieved_id",e.string().optional()),truncate:e.boolean().optional()});var le={};T(le,{ExperimentItemStreamRequest:()=>Be,ExperimentItemsBatch:()=>Ne,ExperimentItemsDelete:()=>Fe,ExperimentWrite:()=>Ie,ExperimentsDelete:()=>De,IdentifierPublic:()=>Me,findFeedbackScoreNames:()=>Kr});var Kr={};T(Kr,{Response:()=>zs});var zs=e.list(e.string());var Xr=e.object({id:e.string()});var Ie=e.object({id:e.string().optional(),datasetName:e.property("dataset_name",e.string()),name:e.string().optional(),metadata:D.optional(),promptVersion:e.property("prompt_version",Xr.optional()),promptVersions:e.property("prompt_versions",e.list(Xr).optional())});var Ko=e.enum_(["ui","sdk","online_scoring"]);var V=e.object({name:e.string(),categoryName:e.property("category_name",e.string().optional()),value:e.number(),reason:e.string().optional(),source:Ko,createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var j=e.object({id:e.string().optional(),text:e.string(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Ue=e.object({id:e.string().optional(),experimentId:e.property("experiment_id",e.string()),datasetItemId:e.property("dataset_item_id",e.string()),traceId:e.property("trace_id",e.string()),input:x.optional(),output:x.optional(),feedbackScores:e.property("feedback_scores",e.list(V).optional()),comments:e.list(j).optional(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Ne=e.object({experimentItems:e.property("experiment_items",e.list(Ue))});var Fe=e.object({ids:e.list(e.string())});var De=e.object({ids:e.list(e.string())});var Me=e.object({name:e.string()});var Be=e.object({experimentName:e.property("experiment_name",e.string()),limit:e.number().optional(),lastRetrievedId:e.property("last_retrieved_id",e.string().optional()),truncate:e.boolean().optional()});var me={};T(me,{TraceBatchWrite:()=>Ve,TraceUpdate:()=>We,findFeedbackScoreNames2:()=>Or});var Or={};T(Or,{Response:()=>xs});var xs=e.list(e.string());var Le=e.object({id:e.string().optional(),projectName:e.property("project_name",e.string().optional()),name:e.string(),startTime:e.property("start_time",e.date()),endTime:e.property("end_time",e.date().optional()),input:D.optional(),output:D.optional(),metadata:D.optional(),tags:e.list(e.string()).optional(),errorInfo:e.property("error_info",Pe.optional())});var Ve=e.object({traces:e.list(Le)});var We=e.object({projectName:e.property("project_name",e.string().optional()),projectId:e.property("project_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),input:x.optional(),output:x.optional(),metadata:x.optional(),tags:e.list(e.string()).optional(),errorInfo:e.property("error_info",G.optional())});var Hr={};T(Hr,{ChatCompletionRequest:()=>Xe});var Xo=e.record(e.string(),e.unknown());var Oo=e.object({includeUsage:e.property("include_usage",e.boolean().optional())});var Go=e.enum_(["text","json_object","json_schema"]);var Gr=e.object({type:e.string().optional()});var Je=e.object({type:e.string().optional(),description:e.string().optional(),properties:e.record(e.string(),Gr).optional(),required:e.list(e.string()).optional(),additionalProperties:e.boolean().optional(),defs:e.property("$defs",e.record(e.string(),Gr).optional())});var Ho=e.object({name:e.string().optional(),strict:e.boolean().optional(),schema:Je.optional()});var $o=e.object({type:Go.optional(),jsonSchema:e.property("json_schema",Ho.optional())});var Ke=e.object({name:e.string().optional(),description:e.string().optional(),strict:e.boolean().optional(),parameters:Je.optional()});var Qo=e.object({type:e.stringLiteral("function").optional(),function:Ke.optional()});var H=e.object({name:e.string().optional(),arguments:e.string().optional()});var Xe=e.object({model:e.string().optional(),messages:e.list(Xo).optional(),temperature:e.number().optional(),topP:e.property("top_p",e.number().optional()),n:e.number().optional(),stream:e.boolean().optional(),streamOptions:e.property("stream_options",Oo.optional()),stop:e.list(e.string()).optional(),maxTokens:e.property("max_tokens",e.number().optional()),maxCompletionTokens:e.property("max_completion_tokens",e.number().optional()),presencePenalty:e.property("presence_penalty",e.number().optional()),frequencyPenalty:e.property("frequency_penalty",e.number().optional()),logitBias:e.property("logit_bias",e.record(e.string(),e.number()).optional()),user:e.string().optional(),responseFormat:e.property("response_format",$o.optional()),seed:e.number().optional(),tools:e.list(Qo).optional(),toolChoice:e.property("tool_choice",e.record(e.string(),e.unknown()).optional()),parallelToolCalls:e.property("parallel_tool_calls",e.boolean().optional()),functions:e.list(Ke).optional(),functionCall:e.property("function_call",H.optional())});var $r={};T($r,{DatasetIdentifier:()=>$e,DatasetIdentifierPublic:()=>Ye,DatasetItemBatchWrite:()=>Ge,DatasetItemStreamRequest:()=>Ze,DatasetItemsDelete:()=>Qe,DatasetUpdate:()=>He,DatasetWrite:()=>Oe});var Oe=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional()});var Yo=e.enum_(["manual","trace","span","sdk"]);var Zo=e.object({id:e.string().optional(),traceId:e.property("trace_id",e.string().optional()),spanId:e.property("span_id",e.string().optional()),source:Yo,data:x});var Ge=e.object({datasetName:e.property("dataset_name",e.string().optional()),datasetId:e.property("dataset_id",e.string().optional()),items:e.list(Zo)});var He=e.object({name:e.string(),description:e.string().optional()});var $e=e.object({datasetName:e.property("dataset_name",e.string())});var Qe=e.object({itemIds:e.property("item_ids",e.list(e.string()))});var Ye=e.object({datasetName:e.property("dataset_name",e.string())});var Ze=e.object({datasetName:e.property("dataset_name",e.string()),lastRetrievedId:e.property("last_retrieved_id",e.string().optional()),steamLimit:e.property("steam_limit",e.number().optional())});var qo=e.object({workspaceId:e.property("workspace_id",e.string().optional()),user:e.string().optional(),count:e.number().optional()});var qe=e.object({biInformation:e.property("bi_information",e.list(qo).optional())});var et=e.object({workspace:e.string().optional(),traceCount:e.property("trace_count",e.number().optional())});var rt=e.object({workspacesTracesCount:e.property("workspaces_traces_count",e.list(et).optional())});var $=e.object({code:e.number().optional(),message:e.string().optional(),details:e.string().optional()});var ot=e.record(e.string(),e.unknown());var tt=e.object({name:e.string(),temperature:e.number()});var at=e.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT"]);var it=e.object({role:at,content:e.string()});var nt=e.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var st=e.object({name:e.string(),type:nt,description:e.string()});var er=e.object({model:tt,messages:e.list(it),variables:e.record(e.string(),e.string()),schema:e.list(st)});var ct=e.object({code:er.optional()});var Rs=e.object({id:e.string().optional(),projectId:e.property("project_id",e.string().optional()),name:e.string(),samplingRate:e.property("sampling_rate",e.number().optional()),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),action:e.stringLiteral("evaluator").optional()}),As=e.union("type",{llm_as_judge:ct.extend(Rs)}).transform({transform:s=>s,untransform:s=>s});var pt=e.object({name:e.string(),temperature:e.number()});var lt=e.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT"]);var mt=e.object({role:lt,content:e.string()});var dt=e.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var ut=e.object({name:e.string(),type:dt,description:e.string()});var gt=e.object({model:pt,messages:e.list(mt),variables:e.record(e.string(),e.string()),schema:e.list(ut)});var ft=e.object({code:gt.optional()});var _s=e.object({projectId:e.property("project_id",e.string().optional()),name:e.string(),samplingRate:e.property("sampling_rate",e.number().optional()),action:e.stringLiteral("evaluator").optional()}),Qr=e.union("type",{llm_as_judge:ft.extend(_s)}).transform({transform:s=>s,untransform:s=>s});var E=e.object({ids:e.list(e.string())});var bt=e.object({name:e.string(),temperature:e.number()});var wt=e.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT"]);var ht=e.object({role:wt,content:e.string()});var yt=e.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var kt=e.object({name:e.string(),type:yt,description:e.string()});var St=e.object({model:bt,messages:e.list(ht),variables:e.record(e.string(),e.string()),schema:e.list(kt)});var rr=e.object({code:St.optional()});var Ts=e.object({id:e.string().optional(),projectId:e.property("project_id",e.string().optional()),name:e.string(),samplingRate:e.property("sampling_rate",e.number().optional()),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),action:e.stringLiteral("evaluator").optional()}),zt=e.union("type",{llm_as_judge:rr.extend(Ts)}).transform({transform:s=>s,untransform:s=>s});var Yr=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(zt).optional()});var Ps=e.object({id:e.string().optional(),projectId:e.property("project_id",e.string().optional()),name:e.string(),samplingRate:e.property("sampling_rate",e.number().optional()),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),action:e.stringLiteral("evaluator").optional()}),Zr=e.union("type",{llm_as_judge:rr.extend(Ps)}).transform({transform:s=>s,untransform:s=>s});var xt=e.enum_(["INFO","WARN","ERROR","DEBUG","TRACE"]);var Rt=e.object({timestamp:e.date().optional(),ruleId:e.property("rule_id",e.string().optional()),level:xt.optional(),message:e.string().optional(),markers:e.record(e.string(),e.string()).optional()});var qr=e.object({content:e.list(Rt).optional(),page:e.number().optional(),size:e.number().optional(),total:e.number().optional()});var eo=e.object({name:e.string(),code:er,samplingRate:e.property("sampling_rate",e.number()),projectId:e.property("project_id",e.string().optional())});var At=e.enum_(["system","user","assistant","tool","function"]);var or=e.object({id:e.string().optional(),index:e.number().optional(),type:e.stringLiteral("function").optional(),function:H.optional()});var _t=e.object({role:At.optional(),content:e.string().optional(),name:e.string().optional(),toolCalls:e.property("tool_calls",e.list(or).optional()),refusal:e.boolean().optional(),functionCall:e.property("function_call",H.optional())});var Tt=e.enum_(["system","user","assistant","tool","function"]);var Pt=e.object({role:Tt.optional(),content:e.string().optional(),toolCalls:e.property("tool_calls",e.list(or).optional()),functionCall:e.property("function_call",H.optional())});var Et=e.object({index:e.number().optional(),message:_t.optional(),delta:Pt.optional(),finishReason:e.property("finish_reason",e.string().optional())});var vt=e.object({reasoningTokens:e.property("reasoning_tokens",e.number().optional())});var Ct=e.object({totalTokens:e.property("total_tokens",e.number().optional()),promptTokens:e.property("prompt_tokens",e.number().optional()),completionTokens:e.property("completion_tokens",e.number().optional()),completionTokensDetails:e.property("completion_tokens_details",vt.optional())});var jt=e.object({id:e.string().optional(),created:e.number().optional(),model:e.string().optional(),choices:e.list(Et).optional(),usage:Ct.optional(),systemFingerprint:e.property("system_fingerprint",e.string().optional())});var Es=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),experimentCount:e.property("experiment_count",e.number().optional()),datasetItemsCount:e.property("dataset_items_count",e.number().optional()),mostRecentExperimentAt:e.property("most_recent_experiment_at",e.date().optional()),lastCreatedExperimentAt:e.property("last_created_experiment_at",e.date().optional())});var It=e.enum_(["manual","trace","span","sdk"]);var Ut=e.object({id:e.string().optional(),traceId:e.property("trace_id",e.string().optional()),spanId:e.property("span_id",e.string().optional()),source:It,data:x,experimentItems:e.property("experiment_items",e.list(Ue).optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var vs=e.object({datasetName:e.property("dataset_name",e.string().optional()),datasetId:e.property("dataset_id",e.string().optional()),items:e.list(Ut)});var Nt=e.enum_(["string","number","object","boolean","array","null"]);var Ft=e.object({name:e.string().optional(),types:e.list(Nt).optional(),filterFieldPrefix:e.property("filter_field_prefix",e.string().optional()),filterField:e.string().optional()});var Dt=e.object({id:e.string().optional(),text:e.string(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Mt=e.enum_(["manual","trace","span","sdk"]);var ro=e.record(e.string(),e.unknown());var Bt=e.enum_(["ui","sdk","online_scoring"]);var Lt=e.object({name:e.string(),categoryName:e.property("category_name",e.string().optional()),value:e.number(),reason:e.string().optional(),source:Bt,createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Vt=e.object({id:e.string().optional(),experimentId:e.property("experiment_id",e.string()),datasetItemId:e.property("dataset_item_id",e.string()),traceId:e.property("trace_id",e.string()),input:ro.optional(),output:ro.optional(),feedbackScores:e.property("feedback_scores",e.list(Lt).optional()),comments:e.list(Dt).optional(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Wt=e.object({id:e.string().optional(),traceId:e.property("trace_id",e.string().optional()),spanId:e.property("span_id",e.string().optional()),source:Mt,data:x,experimentItems:e.property("experiment_items",e.list(Vt).optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Jt=e.object({content:e.list(Wt).optional(),page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),columns:e.list(Ft).optional()});var de=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),experimentCount:e.property("experiment_count",e.number().optional()),datasetItemsCount:e.property("dataset_items_count",e.number().optional()),mostRecentExperimentAt:e.property("most_recent_experiment_at",e.date().optional()),lastCreatedExperimentAt:e.property("last_created_experiment_at",e.date().optional())});var Kt=e.object({content:e.list(de).optional(),page:e.number().optional(),size:e.number().optional(),total:e.number().optional()});var Xt=e.enum_(["manual","trace","span","sdk"]);var tr=e.object({id:e.string().optional(),experimentId:e.property("experiment_id",e.string()),datasetItemId:e.property("dataset_item_id",e.string()),traceId:e.property("trace_id",e.string()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var ar=e.object({id:e.string().optional(),traceId:e.property("trace_id",e.string().optional()),spanId:e.property("span_id",e.string().optional()),source:Xt,data:x,experimentItems:e.property("experiment_items",e.list(tr).optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Ot=e.enum_(["string","number","object","boolean","array","null"]);var Gt=e.object({name:e.string().optional(),types:e.list(Ot).optional(),filterFieldPrefix:e.property("filter_field_prefix",e.string().optional()),filterField:e.string().optional()});var Ht=e.object({content:e.list(ar).optional(),page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),columns:e.list(Gt).optional()});var $t=e.enum_(["string","number","object","boolean","array","null"]);var Qt=e.object({name:e.string().optional(),types:e.list($t).optional(),filterFieldPrefix:e.property("filter_field_prefix",e.string().optional()),filterField:e.string().optional()});var Yt=e.object({columns:e.list(Qt).optional()});var Zt=e.object({typeName:e.string().optional()});var Cs=e.object({type:Zt.optional(),closed:e.boolean().optional()});var oe=e.object({name:e.string(),value:e.number()});var oo=e.object({id:e.string(),commit:e.string().optional(),promptId:e.property("prompt_id",e.string().optional())});var js=e.object({id:e.string().optional(),datasetName:e.property("dataset_name",e.string()),datasetId:e.property("dataset_id",e.string().optional()),name:e.string().optional(),metadata:x.optional(),feedbackScores:e.property("feedback_scores",e.list(oe).optional()),comments:e.list(j).optional(),traceCount:e.property("trace_count",e.number().optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),promptVersion:e.property("prompt_version",oo.optional()),promptVersions:e.property("prompt_versions",e.list(oo).optional())});var te=e.object({id:e.string().optional(),text:e.string(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var M=e.record(e.string(),e.unknown());var qt=e.object({name:e.string(),value:e.number()});var to=e.object({id:e.string(),commit:e.string().optional(),promptId:e.property("prompt_id",e.string().optional())});var ue=e.object({id:e.string().optional(),datasetName:e.property("dataset_name",e.string()),datasetId:e.property("dataset_id",e.string().optional()),name:e.string().optional(),metadata:M.optional(),feedbackScores:e.property("feedback_scores",e.list(qt).optional()),comments:e.list(te).optional(),traceCount:e.property("trace_count",e.number().optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),promptVersion:e.property("prompt_version",to.optional()),promptVersions:e.property("prompt_versions",e.list(to).optional())});var ea=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(ue).optional()});var Is=e.object({code:e.number().optional(),message:e.string().optional(),details:e.string().optional()});var ra=e.object({categories:e.record(e.string(),e.number())});var oa=e.object({details:ra.optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var ta=e.object({max:e.number(),min:e.number()});var aa=e.object({details:ta.optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var ln=e.object({id:e.string().optional(),name:e.string(),createdAt:e.date().optional(),createdBy:e.string().optional(),lastUpdatedAt:e.date().optional(),lastUpdatedBy:e.string().optional()}),Us=e.union("type",{numerical:aa.extend(ln),categorical:oa.extend(ln)}).transform({transform:s=>s,untransform:s=>s});var ia=e.object({categories:e.record(e.string(),e.number())});var na=e.object({details:ia.optional()});var sa=e.object({max:e.number(),min:e.number()});var ca=e.object({details:sa.optional()});var mn=e.object({id:e.string().optional(),name:e.string()}),pa=e.union("type",{numerical:ca.extend(mn),categorical:na.extend(mn)}).transform({transform:s=>s,untransform:s=>s});var la=e.object({categories:e.record(e.string(),e.number())});var ir=e.object({details:la.optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var ma=e.object({max:e.number(),min:e.number()});var nr=e.object({details:ma.optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var dn=e.object({id:e.string().optional(),name:e.string(),createdAt:e.date().optional(),createdBy:e.string().optional(),lastUpdatedAt:e.date().optional(),lastUpdatedBy:e.string().optional()}),da=e.union("type",{numerical:nr.extend(dn),categorical:ir.extend(dn)}).transform({transform:s=>s,untransform:s=>s});var ua=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(da).optional()});var un=e.object({id:e.string().optional(),name:e.string(),createdAt:e.date().optional(),createdBy:e.string().optional(),lastUpdatedAt:e.date().optional(),lastUpdatedBy:e.string().optional()}),ga=e.union("type",{numerical:nr.extend(un),categorical:ir.extend(un)}).transform({transform:s=>s,untransform:s=>s});var fa=e.object({categories:e.record(e.string(),e.number())});var ba=e.object({details:fa.optional()});var wa=e.object({max:e.number(),min:e.number()});var ha=e.object({details:wa.optional()});var gn=e.object({id:e.string().optional(),name:e.string()}),ya=e.union("type",{numerical:ha.extend(gn),categorical:ba.extend(gn)}).transform({transform:s=>s,untransform:s=>s});var sr=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),lastUpdatedTraceAt:e.property("last_updated_trace_at",e.date().optional())});var cr=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(sr).optional(),sortableBy:e.list(e.string()).optional()});var ka=e.enum_(["openai","anthropic","gemini"]);var Sa=e.object({id:e.string().optional(),provider:ka,apiKey:e.property("api_key",e.string()),name:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var za=e.enum_(["openai","anthropic","gemini"]);var Ns=e.object({id:e.string().optional(),provider:za,apiKey:e.property("api_key",e.string()),name:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var pr=e.object({p50:e.number().optional(),p90:e.number().optional(),p99:e.number().optional()});var Fs=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),lastUpdatedTraceAt:e.property("last_updated_trace_at",e.date().optional()),feedbackScores:e.property("feedback_scores",e.list(oe).optional()),duration:pr.optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),usage:e.record(e.string(),e.number()).optional()});var xa=e.object({name:e.string().optional()});var Ra=e.object({scores:e.list(xa).optional()});var Aa=e.object({time:e.date(),value:e.number().optional()});var _a=e.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST"]);var Ta=e.enum_(["HOURLY","DAILY","WEEKLY"]);var Pa=e.object({name:e.string().optional(),data:e.list(Aa).optional()});var Ea=e.object({projectId:e.property("project_id",e.string().optional()),metricType:e.property("metric_type",_a.optional()),interval:Ta.optional(),results:e.list(Pa).optional()});var va=e.object({projectId:e.property("project_id",e.string().optional()),feedbackScores:e.property("feedback_scores",e.list(oe).optional()),duration:pr.optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),usage:e.record(e.string(),e.number()).optional()});var Ca=e.object({content:e.list(va).optional()});var ja=e.object({name:e.string(),value:e.number()});var Ia=e.object({p50:e.number().optional(),p90:e.number().optional(),p99:e.number().optional()});var Ua=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),lastUpdatedTraceAt:e.property("last_updated_trace_at",e.date().optional()),feedbackScores:e.property("feedback_scores",e.list(ja).optional()),duration:Ia.optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),usage:e.record(e.string(),e.number()).optional()});var Ds=e.object({errors:e.list(e.string()).optional()});var Na=e.enum_(["mustache","jinja2"]);var Fa=e.enum_(["mustache","jinja2"]);var Da=e.object({id:e.string().optional(),promptId:e.property("prompt_id",e.string().optional()),commit:e.string().optional(),template:e.string(),metadata:x.optional(),type:Fa.optional(),changeDescription:e.property("change_description",e.string().optional()),variables:e.list(e.string()).optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional())});var Ms=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),template:e.string().optional(),metadata:x.optional(),changeDescription:e.property("change_description",e.string().optional()),type:Na.optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),versionCount:e.property("version_count",e.number().optional()),latestVersion:e.property("latest_version",Da.optional())});var Bs=e.object({code:e.number().optional(),message:e.string().optional(),details:e.string().optional()});var Ma=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),versionCount:e.property("version_count",e.number().optional()),latestVersion:e.property("latest_version",O.optional())});var Ba=e.enum_(["mustache","jinja2"]);var La=e.object({id:e.string().optional(),promptId:e.property("prompt_id",e.string().optional()),commit:e.string().optional(),template:e.string(),metadata:M.optional(),type:Ba.optional(),changeDescription:e.property("change_description",e.string().optional()),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional())});var Va=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(La).optional()});var Wa=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),versionCount:e.property("version_count",e.number().optional())});var Ja=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(Wa).optional()});var Ka=e.enum_(["general","tool","llm"]);var Xa=e.object({id:e.string().optional(),projectName:e.property("project_name",e.string().optional()),projectId:e.property("project_id",e.string().optional()),traceId:e.property("trace_id",e.string()),parentSpanId:e.property("parent_span_id",e.string().optional()),name:e.string(),type:Ka,startTime:e.property("start_time",e.date()),endTime:e.property("end_time",e.date().optional()),input:x.optional(),output:x.optional(),metadata:x.optional(),model:e.string().optional(),provider:e.string().optional(),tags:e.list(e.string()).optional(),usage:e.record(e.string(),e.number()).optional(),errorInfo:e.property("error_info",G.optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),feedbackScores:e.property("feedback_scores",e.list(V).optional()),comments:e.list(j).optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),totalEstimatedCostVersion:e.property("total_estimated_cost_version",e.string().optional()),duration:e.number().optional()});var Ls=e.object({spans:e.list(Xa)});var lr=e.object({name:e.string()});var mr=e.object({exceptionType:e.property("exception_type",e.string()),message:e.string().optional(),traceback:e.string()});var Oa=e.enum_(["ui","sdk","online_scoring"]);var dr=e.object({name:e.string(),categoryName:e.property("category_name",e.string().optional()),value:e.number(),reason:e.string().optional(),source:Oa,createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Ga=e.enum_(["general","tool","llm"]);var ur=e.object({id:e.string().optional(),projectId:e.property("project_id",e.string().optional()),traceId:e.property("trace_id",e.string()),parentSpanId:e.property("parent_span_id",e.string().optional()),name:e.string(),type:Ga,startTime:e.property("start_time",e.date()),endTime:e.property("end_time",e.date().optional()),input:M.optional(),output:M.optional(),metadata:M.optional(),model:e.string().optional(),provider:e.string().optional(),tags:e.list(e.string()).optional(),usage:e.record(e.string(),e.number()).optional(),errorInfo:e.property("error_info",mr.optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),feedbackScores:e.property("feedback_scores",e.list(dr).optional()),comments:e.list(te).optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),totalEstimatedCostVersion:e.property("total_estimated_cost_version",e.string().optional()),duration:e.number().optional()});var Ha=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(ur).optional()});var $a=e.object({value:e.number().optional()});var Qa=e.object({value:e.number().optional()});var Ya=e.object({p50:e.number().optional(),p90:e.number().optional(),p99:e.number().optional()});var Za=e.object({value:Ya.optional()});var qa=e.object({name:e.string().optional()}),ei=e.union("type",{PERCENTAGE:Za.extend(qa),COUNT:Qa.extend(qa),AVG:$a.extend(qa)}).transform({transform:s=>s,untransform:s=>s});var gr=e.object({stats:e.list(ei).optional()});var ri=e.enum_(["ui","sdk","online_scoring"]);var oi=e.object({id:e.string(),projectName:e.property("project_name",e.string().optional()),name:e.string(),categoryName:e.property("category_name",e.string().optional()),value:e.number(),reason:e.string().optional(),source:ri});var fr=e.object({scores:e.list(oi)});var ti=e.object({typeName:e.string().optional()});var Vs=e.object({type:ti.optional(),closed:e.boolean().optional()});var ai=e.object({id:e.string().optional(),projectName:e.property("project_name",e.string().optional()),projectId:e.property("project_id",e.string().optional()),name:e.string(),startTime:e.property("start_time",e.date()),endTime:e.property("end_time",e.date().optional()),input:x.optional(),output:x.optional(),metadata:x.optional(),tags:e.list(e.string()).optional(),errorInfo:e.property("error_info",G.optional()),usage:e.record(e.string(),e.number()).optional(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),feedbackScores:e.property("feedback_scores",e.list(V).optional()),comments:e.list(j).optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),duration:e.number().optional()});var Ws=e.object({traces:e.list(ai)});var br=e.object({id:e.string().optional(),projectId:e.property("project_id",e.string().optional()),name:e.string(),startTime:e.property("start_time",e.date()),endTime:e.property("end_time",e.date().optional()),input:M.optional(),output:M.optional(),metadata:M.optional(),tags:e.list(e.string()).optional(),errorInfo:e.property("error_info",mr.optional()),usage:e.record(e.string(),e.number()).optional(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),feedbackScores:e.property("feedback_scores",e.list(dr).optional()),comments:e.list(te).optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),duration:e.number().optional()});var ii=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(br).optional()});var ao=class{constructor(t={}){this._options=t;}async getDatasetBiInfo(t){var o,a;let r=await w({url:h((a=(o=await n.get(this._options.baseUrl))!=null?o:await n.get(this._options.environment))!=null?a:b.Default,"v1/internal/usage/bi-datasets"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return qe.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/internal/usage/bi-datasets.");case "unknown":throw new c({message:r.error.errorMessage})}}async getExperimentBiInfo(t){var o,a;let r=await w({url:h((a=(o=await n.get(this._options.baseUrl))!=null?o:await n.get(this._options.environment))!=null?a:b.Default,"v1/internal/usage/bi-experiments"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return qe.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/internal/usage/bi-experiments.");case "unknown":throw new c({message:r.error.errorMessage})}}async getTracesBiInfo(t){var o,a;let r=await w({url:h((a=(o=await n.get(this._options.baseUrl))!=null?o:await n.get(this._options.environment))!=null?a:b.Default,"v1/internal/usage/bi-traces"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return qe.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/internal/usage/bi-traces.");case "unknown":throw new c({message:r.error.errorMessage})}}async getTracesCountForWorkspaces(t){var o,a;let r=await w({url:h((a=(o=await n.get(this._options.baseUrl))!=null?o:await n.get(this._options.environment))!=null?a:b.Default,"v1/internal/usage/workspace-trace-counts"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return rt.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/internal/usage/workspace-trace-counts.");case "unknown":throw new c({message:r.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var io=class{constructor(t={}){this._options=t;}async access(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/auth"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:ot.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Q($.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}));case 403:throw new Y($.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}));default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/auth.");case "unknown":throw new c({message:o.error.errorMessage})}}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var no=class{constructor(t={}){this._options=t;}async findEvaluators(t={},r){var f,y;let{projectId:o,name:a,page:i,size:p}=t,d={};o!=null&&(d.project_id=o),a!=null&&(d.name=a),i!=null&&(d.page=i.toString()),p!=null&&(d.size=p.toString());let u=await w({url:h((y=(f=await n.get(this._options.baseUrl))!=null?f:await n.get(this._options.environment))!=null?y:b.Default,"v1/private/automations/evaluators"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(u.ok)return Yr.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(u.error.reason==="status-code")throw new c({statusCode:u.error.statusCode,body:u.error.body});switch(u.error.reason){case "non-json":throw new c({statusCode:u.error.statusCode,body:u.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/automations/evaluators.");case "unknown":throw new c({message:u.error.errorMessage})}}async createAutomationRuleEvaluator(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/automations/evaluators"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Qr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/automations/evaluators.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteAutomationRuleEvaluatorBatch(t,r){var d,u;let{projectId:o,body:a}=t,i={};i.project_id=o;let p=await w({url:h((u=(d=await n.get(this._options.baseUrl))!=null?d:await n.get(this._options.environment))!=null?u:b.Default,"v1/private/automations/evaluators/delete"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:i,requestType:"json",body:E.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!p.ok){if(p.error.reason==="status-code")throw new c({statusCode:p.error.statusCode,body:p.error.body});switch(p.error.reason){case "non-json":throw new c({statusCode:p.error.statusCode,body:p.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/automations/evaluators/delete.");case "unknown":throw new c({message:p.error.errorMessage})}}}async getEvaluatorById(t,r={},o){var d,u;let{projectId:a}=r,i={};a!=null&&(i.project_id=a);let p=await w({url:h((u=(d=await n.get(this._options.baseUrl))!=null?d:await n.get(this._options.environment))!=null?u:b.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(p.ok)return Zr.parseOrThrow(p.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(p.error.reason==="status-code")throw new c({statusCode:p.error.statusCode,body:p.error.body});switch(p.error.reason){case "non-json":throw new c({statusCode:p.error.statusCode,body:p.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/automations/evaluators/{id}.");case "unknown":throw new c({message:p.error.errorMessage})}}async updateAutomationRuleEvaluator(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:eo.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/automations/evaluators/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async getEvaluatorLogsById(t,r={},o){var d,u;let{size:a}=r,i={};a!=null&&(i.size=a.toString());let p=await w({url:h((u=(d=await n.get(this._options.baseUrl))!=null?d:await n.get(this._options.environment))!=null?u:b.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}/logs`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(p.ok)return qr.parseOrThrow(p.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(p.error.reason==="status-code")throw new c({statusCode:p.error.statusCode,body:p.error.body});switch(p.error.reason){case "non-json":throw new c({statusCode:p.error.statusCode,body:p.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/automations/evaluators/{id}/logs.");case "unknown":throw new c({message:p.error.errorMessage})}}async findEvaluatorsDeprecated(t,r={},o){var f,y;let{name:a,page:i,size:p}=r,d={};a!=null&&(d.name=a),i!=null&&(d.page=i.toString()),p!=null&&(d.size=p.toString());let u=await w({url:h((y=(f=await n.get(this._options.baseUrl))!=null?f:await n.get(this._options.environment))!=null?y:b.Default,`v1/private/automations/projects/${encodeURIComponent(t)}/evaluators`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(u.ok)return Yr.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(u.error.reason==="status-code")throw new c({statusCode:u.error.statusCode,body:u.error.body});switch(u.error.reason){case "non-json":throw new c({statusCode:u.error.statusCode,body:u.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/automations/projects/{projectId}/evaluators.");case "unknown":throw new c({message:u.error.errorMessage})}}async createAutomationRuleEvaluatorDeprecated(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/automations/projects/${encodeURIComponent(t)}/evaluators`),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Qr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/automations/projects/{projectId}/evaluators.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteAutomationRuleEvaluatorBatchDeprecated(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/automations/projects/${encodeURIComponent(t)}/evaluators/delete`),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/automations/projects/{projectId}/evaluators/delete.");case "unknown":throw new c({message:a.error.errorMessage})}}}async getEvaluatorByIdDeprecated(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/automations/projects/${encodeURIComponent(t)}/evaluators/${encodeURIComponent(r)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(a.ok)return Zr.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/automations/projects/{projectId}/evaluators/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}async updateAutomationRuleEvaluatorDeprecated(t,r,o,a){var p,d;let i=await w({url:h((d=(p=await n.get(this._options.baseUrl))!=null?p:await n.get(this._options.environment))!=null?d:b.Default,`v1/private/automations/projects/${encodeURIComponent(r)}/evaluators/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...a==null?void 0:a.headers},contentType:"application/json",requestType:"json",body:eo.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}),timeoutMs:(a==null?void 0:a.timeoutInSeconds)!=null?a.timeoutInSeconds*1e3:6e4,maxRetries:a==null?void 0:a.maxRetries,withCredentials:true,abortSignal:a==null?void 0:a.abortSignal});if(!i.ok){if(i.error.reason==="status-code")throw new c({statusCode:i.error.statusCode,body:i.error.body});switch(i.error.reason){case "non-json":throw new c({statusCode:i.error.statusCode,body:i.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/automations/projects/{projectId}/evaluators/{id}.");case "unknown":throw new c({message:i.error.errorMessage})}}}async getEvaluatorLogsByIdDeprecated(t,r,o={},a){var u,f;let{size:i}=o,p={};i!=null&&(p.size=i.toString());let d=await w({url:h((f=(u=await n.get(this._options.baseUrl))!=null?u:await n.get(this._options.environment))!=null?f:b.Default,`v1/private/automations/projects/${encodeURIComponent(t)}/evaluators/${encodeURIComponent(r)}/logs`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...a==null?void 0:a.headers},contentType:"application/json",queryParameters:p,requestType:"json",timeoutMs:(a==null?void 0:a.timeoutInSeconds)!=null?a.timeoutInSeconds*1e3:6e4,maxRetries:a==null?void 0:a.maxRetries,withCredentials:true,abortSignal:a==null?void 0:a.abortSignal});if(d.ok)return qr.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(d.error.reason==="status-code")throw new c({statusCode:d.error.statusCode,body:d.error.body});switch(d.error.reason){case "non-json":throw new c({statusCode:d.error.statusCode,body:d.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/automations/projects/{projectId}/evaluators/{id}/logs.");case "unknown":throw new c({message:d.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var so=class{constructor(t={}){this._options=t;}async createChatCompletions(t={},r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/chat/completions"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Xe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return jt.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/chat/completions.");case "unknown":throw new c({message:o.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var co=class{constructor(t={}){this._options=t;}async findDatasets(t={},r){var k,z;let{page:o,size:a,withExperimentsOnly:i,promptId:p,name:d,sorting:u}=t,f={};o!=null&&(f.page=o.toString()),a!=null&&(f.size=a.toString()),i!=null&&(f.with_experiments_only=i.toString()),p!=null&&(f.prompt_id=p),d!=null&&(f.name=d),u!=null&&(f.sorting=u);let y=await w({url:h((z=(k=await n.get(this._options.baseUrl))!=null?k:await n.get(this._options.environment))!=null?z:b.Default,"v1/private/datasets"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:f,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(y.ok)return Kt.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(y.error.reason==="status-code")throw new c({statusCode:y.error.statusCode,body:y.error.body});switch(y.error.reason){case "non-json":throw new c({statusCode:y.error.statusCode,body:y.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/datasets.");case "unknown":throw new c({message:y.error.errorMessage})}}async createDataset(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/datasets"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Oe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/datasets.");case "unknown":throw new c({message:o.error.errorMessage})}}}async createOrUpdateDatasetItems(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/datasets/items"),method:"PUT",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ge.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/datasets/items.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getDatasetById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return de.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/datasets/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async updateDataset(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:He.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/datasets/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteDataset(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling DELETE /v1/private/datasets/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteDatasetByName(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/datasets/delete"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:$e.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/datasets/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteDatasetItems(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/datasets/items/delete"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Qe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/datasets/items/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteDatasetsBatch(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/datasets/delete-batch"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/datasets/delete-batch.");case "unknown":throw new c({message:o.error.errorMessage})}}}async findDatasetItemsWithExperimentItems(t,r,o){var k,z;let{page:a,size:i,experimentIds:p,filters:d,truncate:u}=r,f={};a!=null&&(f.page=a.toString()),i!=null&&(f.size=i.toString()),f.experiment_ids=p,d!=null&&(f.filters=d),u!=null&&(f.truncate=u.toString());let y=await w({url:h((z=(k=await n.get(this._options.baseUrl))!=null?k:await n.get(this._options.environment))!=null?z:b.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:f,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(y.ok)return Jt.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(y.error.reason==="status-code")throw new c({statusCode:y.error.statusCode,body:y.error.body});switch(y.error.reason){case "non-json":throw new c({statusCode:y.error.statusCode,body:y.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items.");case "unknown":throw new c({message:y.error.errorMessage})}}async getDatasetByIdentifier(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/datasets/retrieve"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ye.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return de.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/datasets/retrieve.");case "unknown":throw new c({message:o.error.errorMessage})}}async getDatasetItemById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/datasets/items/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return ar.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/datasets/items/{itemId}.");case "unknown":throw new c({message:o.error.errorMessage})}}async getDatasetItems(t,r={},o){var f,y;let{page:a,size:i,truncate:p}=r,d={};a!=null&&(d.page=a.toString()),i!=null&&(d.size=i.toString()),p!=null&&(d.truncate=p.toString());let u=await w({url:h((y=(f=await n.get(this._options.baseUrl))!=null?f:await n.get(this._options.environment))!=null?y:b.Default,`v1/private/datasets/${encodeURIComponent(t)}/items`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(u.ok)return Ht.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(u.error.reason==="status-code")throw new c({statusCode:u.error.statusCode,body:u.error.body});switch(u.error.reason){case "non-json":throw new c({statusCode:u.error.statusCode,body:u.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/datasets/{id}/items.");case "unknown":throw new c({message:u.error.errorMessage})}}async getDatasetItemsOutputColumns(t,r={},o){var d,u;let{experimentIds:a}=r,i={};a!=null&&(i.experiment_ids=a);let p=await w({url:h((u=(d=await n.get(this._options.baseUrl))!=null?d:await n.get(this._options.environment))!=null?u:b.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items/output/columns`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(p.ok)return Yt.parseOrThrow(p.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(p.error.reason==="status-code")throw new c({statusCode:p.error.statusCode,body:p.error.body});switch(p.error.reason){case "non-json":throw new c({statusCode:p.error.statusCode,body:p.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items/output/columns.");case "unknown":throw new c({message:p.error.errorMessage})}}async streamDatasetItems(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/datasets/items/stream"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ze.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return o.body;if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/datasets/items/stream.");case "unknown":throw new c({message:o.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var po=class{constructor(t={}){this._options=t;}async findExperiments(t={},r){var k,z;let{page:o,size:a,datasetId:i,name:p,datasetDeleted:d,promptId:u}=t,f={};o!=null&&(f.page=o.toString()),a!=null&&(f.size=a.toString()),i!=null&&(f.datasetId=i),p!=null&&(f.name=p),d!=null&&(f.dataset_deleted=d.toString()),u!=null&&(f.prompt_id=u);let y=await w({url:h((z=(k=await n.get(this._options.baseUrl))!=null?k:await n.get(this._options.environment))!=null?z:b.Default,"v1/private/experiments"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:f,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(y.ok)return ea.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(y.error.reason==="status-code")throw new c({statusCode:y.error.statusCode,body:y.error.body});switch(y.error.reason){case "non-json":throw new c({statusCode:y.error.statusCode,body:y.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/experiments.");case "unknown":throw new c({message:y.error.errorMessage})}}async createExperiment(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/experiments"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ie.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/experiments.");case "unknown":throw new c({message:o.error.errorMessage})}}}async createExperimentItems(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/experiments/items"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ne.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/experiments/items.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteExperimentItems(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/experiments/items/delete"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Fe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/experiments/items/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteExperimentsById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/experiments/delete"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:De.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/experiments/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async findFeedbackScoreNames(t={},r){var p,d;let{experimentIds:o}=t,a={};o!=null&&(a.experiment_ids=o);let i=await w({url:h((d=(p=await n.get(this._options.baseUrl))!=null?p:await n.get(this._options.environment))!=null?d:b.Default,"v1/private/experiments/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(i.ok)return le.findFeedbackScoreNames.Response.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(i.error.reason==="status-code")throw new c({statusCode:i.error.statusCode,body:i.error.body});switch(i.error.reason){case "non-json":throw new c({statusCode:i.error.statusCode,body:i.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/experiments/feedback-scores/names.");case "unknown":throw new c({message:i.error.errorMessage})}}async getExperimentById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/experiments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return ue.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/experiments/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async getExperimentByName(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/experiments/retrieve"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Me.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return ue.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/experiments/retrieve.");case "unknown":throw new c({message:o.error.errorMessage})}}async getExperimentItemById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/experiments/items/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return tr.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/experiments/items/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async streamExperimentItems(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/experiments/items/stream"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Be.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return o.body;if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/experiments/items/stream.");case "unknown":throw new c({message:o.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var lo=class{constructor(t={}){this._options=t;}async findFeedbackDefinitions(t={},r){var f,y;let{page:o,size:a,name:i,type:p}=t,d={};o!=null&&(d.page=o.toString()),a!=null&&(d.size=a.toString()),i!=null&&(d.name=i),p!=null&&(d.type=vr.jsonOrThrow(p,{unrecognizedObjectKeys:"strip"}));let u=await w({url:h((y=(f=await n.get(this._options.baseUrl))!=null?f:await n.get(this._options.environment))!=null?y:b.Default,"v1/private/feedback-definitions"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(u.ok)return ua.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(u.error.reason==="status-code")throw new c({statusCode:u.error.statusCode,body:u.error.body});switch(u.error.reason){case "non-json":throw new c({statusCode:u.error.statusCode,body:u.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/feedback-definitions.");case "unknown":throw new c({message:u.error.errorMessage})}}async createFeedbackDefinition(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/feedback-definitions"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:pa.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/feedback-definitions.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getFeedbackDefinitionById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return ga.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/feedback-definitions/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async updateFeedbackDefinition(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:ya.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/feedback-definitions/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteFeedbackDefinitionById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling DELETE /v1/private/feedback-definitions/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteFeedbackDefinitionsBatch(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/feedback-definitions/delete"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/feedback-definitions/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var mo=class{constructor(t={}){this._options=t;}async deleteLlmProviderApiKeysBatch(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/llm-provider-key/delete"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/llm-provider-key/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async findLlmProviderKeys(t){var o,a;let r=await w({url:h((a=(o=await n.get(this._options.baseUrl))!=null?o:await n.get(this._options.environment))!=null?a:b.Default,"v1/private/llm-provider-key"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return cr.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/llm-provider-key.");case "unknown":throw new c({message:r.error.errorMessage})}}async storeLlmProviderApiKey(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/llm-provider-key"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:he.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Q($.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}));case 403:throw new Y($.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}));default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/llm-provider-key.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getLlmProviderApiKeyById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/llm-provider-key/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return Sa.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/llm-provider-key/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async updateLlmProviderApiKey(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/llm-provider-key/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:ye.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Q($.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}));case 403:throw new Y($.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}));case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/llm-provider-key/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var uo=class{constructor(t={}){this._options=t;}async findProjects(t={},r){var f,y;let{page:o,size:a,name:i,sorting:p}=t,d={};o!=null&&(d.page=o.toString()),a!=null&&(d.size=a.toString()),i!=null&&(d.name=i),p!=null&&(d.sorting=p);let u=await w({url:h((y=(f=await n.get(this._options.baseUrl))!=null?f:await n.get(this._options.environment))!=null?y:b.Default,"v1/private/projects"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(u.ok)return cr.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(u.error.reason==="status-code")throw new c({statusCode:u.error.statusCode,body:u.error.body});switch(u.error.reason){case "non-json":throw new c({statusCode:u.error.statusCode,body:u.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/projects.");case "unknown":throw new c({message:u.error.errorMessage})}}async createProject(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/projects"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:ke.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new U(o.error.body);case 422:throw new B(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/projects.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getProjectById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return sr.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/projects/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async deleteProjectById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new X(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling DELETE /v1/private/projects/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}}async updateProject(t,r={},o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Se.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new U(a.error.body);case 422:throw new B(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/projects/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteProjectsBatch(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/projects/delete"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/projects/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async findFeedbackScoreNamesByProjectIds(t={},r){var p,d;let{projectIds:o}=t,a={};o!=null&&(a.project_ids=o);let i=await w({url:h((d=(p=await n.get(this._options.baseUrl))!=null?p:await n.get(this._options.environment))!=null?d:b.Default,"v1/private/projects/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(i.ok)return Ra.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(i.error.reason==="status-code")throw new c({statusCode:i.error.statusCode,body:i.error.body});switch(i.error.reason){case "non-json":throw new c({statusCode:i.error.statusCode,body:i.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/projects/feedback-scores/names.");case "unknown":throw new c({message:i.error.errorMessage})}}async getProjectMetrics(t,r={},o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/projects/${encodeURIComponent(t)}/metrics`),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:ze.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(a.ok)return Ea.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new U(a.error.body);case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/projects/{id}/metrics.");case "unknown":throw new c({message:a.error.errorMessage})}}async getProjectStats(t={},r){var f,y;let{page:o,size:a,name:i,sorting:p}=t,d={};o!=null&&(d.page=o.toString()),a!=null&&(d.size=a.toString()),i!=null&&(d.name=i),p!=null&&(d.sorting=p);let u=await w({url:h((y=(f=await n.get(this._options.baseUrl))!=null?f:await n.get(this._options.environment))!=null?y:b.Default,"v1/private/projects/stats"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(u.ok)return Ca.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(u.error.reason==="status-code")throw new c({statusCode:u.error.statusCode,body:u.error.body});switch(u.error.reason){case "non-json":throw new c({statusCode:u.error.statusCode,body:u.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/projects/stats.");case "unknown":throw new c({message:u.error.errorMessage})}}async retrieveProject(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/projects/retrieve"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:xe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return Ua.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new U(o.error.body);case 404:throw new _(o.error.body);case 422:throw new B(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/projects/retrieve.");case "unknown":throw new c({message:o.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var go=class{constructor(t={}){this._options=t;}async getPrompts(t={},r){var u,f;let{page:o,size:a,name:i}=t,p={};o!=null&&(p.page=o.toString()),a!=null&&(p.size=a.toString()),i!=null&&(p.name=i);let d=await w({url:h((f=(u=await n.get(this._options.baseUrl))!=null?u:await n.get(this._options.environment))!=null?f:b.Default,"v1/private/prompts"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:p,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(d.ok)return Ja.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(d.error.reason==="status-code")throw new c({statusCode:d.error.statusCode,body:d.error.body});switch(d.error.reason){case "non-json":throw new c({statusCode:d.error.statusCode,body:d.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/prompts.");case "unknown":throw new c({message:d.error.errorMessage})}}async createPrompt(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/prompts"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Re.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new U(o.error.body);case 409:throw new X(o.error.body);case 422:throw new B(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/prompts.");case "unknown":throw new c({message:o.error.errorMessage})}}}async createPromptVersion(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/prompts/versions"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ae.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return O.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new U(o.error.body);case 409:throw new X(o.error.body);case 422:throw new B(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/prompts/versions.");case "unknown":throw new c({message:o.error.errorMessage})}}async getPromptById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return Ma.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/prompts/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async updatePrompt(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:_e.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new U(a.error.body);case 404:throw new _(a.error.body);case 409:throw new X(a.error.body);case 422:throw new B(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/prompts/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deletePrompt(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling DELETE /v1/private/prompts/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deletePromptsBatch(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/prompts/delete"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/prompts/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getPromptVersionById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/prompts/versions/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return O.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/prompts/versions/{versionId}.");case "unknown":throw new c({message:o.error.errorMessage})}}async getPromptVersions(t,r={},o){var u,f;let{page:a,size:i}=r,p={};a!=null&&(p.page=a.toString()),i!=null&&(p.size=i.toString());let d=await w({url:h((f=(u=await n.get(this._options.baseUrl))!=null?u:await n.get(this._options.environment))!=null?f:b.Default,`v1/private/prompts/${encodeURIComponent(t)}/versions`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:p,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(d.ok)return Va.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(d.error.reason==="status-code")throw new c({statusCode:d.error.statusCode,body:d.error.body});switch(d.error.reason){case "non-json":throw new c({statusCode:d.error.statusCode,body:d.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/prompts/{id}/versions.");case "unknown":throw new c({message:d.error.errorMessage})}}async retrievePromptVersion(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/prompts/versions/retrieve"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Te.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return O.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new U(o.error.body);case 404:throw new _(o.error.body);case 422:throw new B(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/prompts/versions/retrieve.");case "unknown":throw new c({message:o.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var fo=class{constructor(t={}){this._options=t;}async addSpanComment(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/spans/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:j.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/spans/{id}/comments.");case "unknown":throw new c({message:a.error.errorMessage})}}}async addSpanFeedbackScore(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/spans/${encodeURIComponent(t)}/feedback-scores`),method:"PUT",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:V.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/spans/{id}/feedback-scores.");case "unknown":throw new c({message:a.error.errorMessage})}}}async getSpansByProject(t={},r){var K,ee;let{page:o,size:a,projectName:i,projectId:p,traceId:d,type:u,filters:f,truncate:y}=t,k={};o!=null&&(k.page=o.toString()),a!=null&&(k.size=a.toString()),i!=null&&(k.project_name=i),p!=null&&(k.project_id=p),d!=null&&(k.trace_id=d),u!=null&&(k.type=Br.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"})),f!=null&&(k.filters=f),y!=null&&(k.truncate=y.toString());let z=await w({url:h((ee=(K=await n.get(this._options.baseUrl))!=null?K:await n.get(this._options.environment))!=null?ee:b.Default,"v1/private/spans"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:k,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(z.ok)return Ha.parseOrThrow(z.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(z.error.reason==="status-code")throw new c({statusCode:z.error.statusCode,body:z.error.body});switch(z.error.reason){case "non-json":throw new c({statusCode:z.error.statusCode,body:z.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/spans.");case "unknown":throw new c({message:z.error.errorMessage})}}async createSpan(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/spans"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ee.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/spans.");case "unknown":throw new c({message:o.error.errorMessage})}}}async createSpans(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/spans/batch"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:ve.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/spans/batch.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getSpanById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return ur.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/spans/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async deleteSpanById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")switch(o.error.statusCode){case 501:throw new ge(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling DELETE /v1/private/spans/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}}async updateSpan(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Ce.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/spans/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteSpanComments(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/spans/comments/delete"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/spans/comments/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteSpanFeedbackScore(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/spans/${encodeURIComponent(t)}/feedback-scores/delete`),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:lr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/spans/{id}/feedback-scores/delete.");case "unknown":throw new c({message:a.error.errorMessage})}}}async findFeedbackScoreNames1(t={},r){var d,u;let{projectId:o,type:a}=t,i={};o!=null&&(i.project_id=o),a!=null&&(i.type=Lr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}));let p=await w({url:h((u=(d=await n.get(this._options.baseUrl))!=null?d:await n.get(this._options.environment))!=null?u:b.Default,"v1/private/spans/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(p.ok)return pe.findFeedbackScoreNames1.Response.parseOrThrow(p.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(p.error.reason==="status-code")throw new c({statusCode:p.error.statusCode,body:p.error.body});switch(p.error.reason){case "non-json":throw new c({statusCode:p.error.statusCode,body:p.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/spans/feedback-scores/names.");case "unknown":throw new c({message:p.error.errorMessage})}}async getSpanComment(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/spans/${encodeURIComponent(r)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(a.ok)return j.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/spans/{spanId}/comments/{commentId}.");case "unknown":throw new c({message:a.error.errorMessage})}}async getSpanStats(t={},r){var y,k;let{projectId:o,projectName:a,traceId:i,type:p,filters:d}=t,u={};o!=null&&(u.project_id=o),a!=null&&(u.project_name=a),i!=null&&(u.trace_id=i),p!=null&&(u.type=Vr.jsonOrThrow(p,{unrecognizedObjectKeys:"strip"})),d!=null&&(u.filters=d);let f=await w({url:h((k=(y=await n.get(this._options.baseUrl))!=null?y:await n.get(this._options.environment))!=null?k:b.Default,"v1/private/spans/stats"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(f.ok)return gr.parseOrThrow(f.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(f.error.reason==="status-code")throw new c({statusCode:f.error.statusCode,body:f.error.body});switch(f.error.reason){case "non-json":throw new c({statusCode:f.error.statusCode,body:f.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/spans/stats.");case "unknown":throw new c({message:f.error.errorMessage})}}async scoreBatchOfSpans(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/spans/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:fr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/spans/feedback-scores.");case "unknown":throw new c({message:o.error.errorMessage})}}}async searchSpans(t={},r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/spans/search"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:je.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return o.body;if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new U(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/spans/search.");case "unknown":throw new c({message:o.error.errorMessage})}}async updateSpanComment(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/spans/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:j.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/spans/comments/{commentId}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var bo=class{constructor(t={}){this._options=t;}async addTraceComment(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/traces/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:j.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces/{id}/comments.");case "unknown":throw new c({message:a.error.errorMessage})}}}async addTraceFeedbackScore(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/traces/${encodeURIComponent(t)}/feedback-scores`),method:"PUT",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:V.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/traces/{id}/feedback-scores.");case "unknown":throw new c({message:a.error.errorMessage})}}}async getTracesByProject(t={},r){var k,z;let{page:o,size:a,projectName:i,projectId:p,filters:d,truncate:u}=t,f={};o!=null&&(f.page=o.toString()),a!=null&&(f.size=a.toString()),i!=null&&(f.project_name=i),p!=null&&(f.project_id=p),d!=null&&(f.filters=d),u!=null&&(f.truncate=u.toString());let y=await w({url:h((z=(k=await n.get(this._options.baseUrl))!=null?k:await n.get(this._options.environment))!=null?z:b.Default,"v1/private/traces"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:f,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(y.ok)return ii.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(y.error.reason==="status-code")throw new c({statusCode:y.error.statusCode,body:y.error.body});switch(y.error.reason){case "non-json":throw new c({statusCode:y.error.statusCode,body:y.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/traces.");case "unknown":throw new c({message:y.error.errorMessage})}}async createTrace(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/traces"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Le.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces.");case "unknown":throw new c({message:o.error.errorMessage})}}}async createTraces(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/traces/batch"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ve.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces/batch.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getTraceById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return br.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/traces/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async deleteTraceById(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling DELETE /v1/private/traces/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}}async updateTrace(t,r={},o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:We.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/traces/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteTraceComments(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/traces/comments/delete"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces/comments/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteTraceFeedbackScore(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/traces/${encodeURIComponent(t)}/feedback-scores/delete`),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:lr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces/{id}/feedback-scores/delete.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteTraces(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/traces/delete"),method:"POST",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async findFeedbackScoreNames2(t={},r){var p,d;let{projectId:o}=t,a={};o!=null&&(a.project_id=o);let i=await w({url:h((d=(p=await n.get(this._options.baseUrl))!=null?p:await n.get(this._options.environment))!=null?d:b.Default,"v1/private/traces/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(i.ok)return me.findFeedbackScoreNames2.Response.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(i.error.reason==="status-code")throw new c({statusCode:i.error.statusCode,body:i.error.body});switch(i.error.reason){case "non-json":throw new c({statusCode:i.error.statusCode,body:i.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/traces/feedback-scores/names.");case "unknown":throw new c({message:i.error.errorMessage})}}async getTraceStats(t={},r){var u,f;let{projectId:o,projectName:a,filters:i}=t,p={};o!=null&&(p.project_id=o),a!=null&&(p.project_name=a),i!=null&&(p.filters=i);let d=await w({url:h((f=(u=await n.get(this._options.baseUrl))!=null?u:await n.get(this._options.environment))!=null?f:b.Default,"v1/private/traces/stats"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:p,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(d.ok)return gr.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(d.error.reason==="status-code")throw new c({statusCode:d.error.statusCode,body:d.error.body});switch(d.error.reason){case "non-json":throw new c({statusCode:d.error.statusCode,body:d.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/traces/stats.");case "unknown":throw new c({message:d.error.errorMessage})}}async getTraceComment(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/traces/${encodeURIComponent(r)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(a.ok)return j.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/traces/{traceId}/comments/{commentId}.");case "unknown":throw new c({message:a.error.errorMessage})}}async scoreBatchOfTraces(t,r){var a,i;let o=await w({url:h((i=(a=await n.get(this._options.baseUrl))!=null?a:await n.get(this._options.environment))!=null?i:b.Default,"v1/private/traces/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:fr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/traces/feedback-scores.");case "unknown":throw new c({message:o.error.errorMessage})}}}async updateTraceComment(t,r,o){var i,p;let a=await w({url:h((p=(i=await n.get(this._options.baseUrl))!=null?i:await n.get(this._options.environment))!=null?p:b.Default,`v1/private/traces/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:j.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/traces/comments/{commentId}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var wr=class{constructor(t={}){this._options=t;}get systemUsage(){var t;return (t=this._systemUsage)!=null?t:this._systemUsage=new ao(this._options)}get check(){var t;return (t=this._check)!=null?t:this._check=new io(this._options)}get automationRuleEvaluators(){var t;return (t=this._automationRuleEvaluators)!=null?t:this._automationRuleEvaluators=new no(this._options)}get chatCompletions(){var t;return (t=this._chatCompletions)!=null?t:this._chatCompletions=new so(this._options)}get datasets(){var t;return (t=this._datasets)!=null?t:this._datasets=new co(this._options)}get experiments(){var t;return (t=this._experiments)!=null?t:this._experiments=new po(this._options)}get feedbackDefinitions(){var t;return (t=this._feedbackDefinitions)!=null?t:this._feedbackDefinitions=new lo(this._options)}get llmProviderKey(){var t;return (t=this._llmProviderKey)!=null?t:this._llmProviderKey=new mo(this._options)}get projects(){var t;return (t=this._projects)!=null?t:this._projects=new uo(this._options)}get prompts(){var t;return (t=this._prompts)!=null?t:this._prompts=new go(this._options)}get spans(){var t;return (t=this._spans)!=null?t:this._spans=new fo(this._options)}get traces(){var t;return (t=this._traces)!=null?t:this._traces=new bo(this._options)}async isAlive(t){var o,a;let r=await w({url:h((a=(o=await n.get(this._options.baseUrl))!=null?o:await n.get(this._options.environment))!=null?a:b.Default,"is-alive/ping"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return r.body;if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /is-alive/ping.");case "unknown":throw new c({message:r.error.errorMessage})}}async version(t){var o,a;let r=await w({url:h((a=(o=await n.get(this._options.baseUrl))!=null?o:await n.get(this._options.environment))!=null?a:b.Default,"is-alive/ver"),method:"GET",headers:{"Comet-Workspace":await n.get(this._options.workspaceName)!=null?await n.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return r.body;if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /is-alive/ver.");case "unknown":throw new c({message:r.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await n.get(this._options.apiKey)}}};var hr=()=>uuid.v7();var wo=class{constructor(t,r){this.data=t;this.opik=r;this.end=()=>this.update({endTime:new Date});this.score=t=>{var r;this.opik.spanFeedbackScoresBatchQueue.create({...t,projectName:(r=this.data.projectName)!=null?r:this.opik.config.projectName,id:this.data.id,source:"sdk"});};this.update=t=>{var o;let r={parentSpanId:this.data.parentSpanId,projectName:(o=this.data.projectName)!=null?o:this.opik.config.projectName,traceId:this.data.traceId,...t};return this.opik.spanBatchQueue.update(this.data.id,r),this.data={...this.data,...t},this};}};var ho=class{constructor(t,r){this.data=t;this.opik=r;this.spans=[];this.end=()=>this.update({endTime:new Date});this.score=t=>{var r;this.opik.traceFeedbackScoresBatchQueue.create({...t,projectName:(r=this.data.projectName)!=null?r:this.opik.config.projectName,id:this.data.id,source:"sdk"});};this.span=t=>{var i,p;let r=(p=(i=this.data.projectName)!=null?i:t.projectName)!=null?p:this.opik.config.projectName,o={id:hr(),startTime:new Date,...t,projectName:r,traceId:this.data.id};this.opik.spanBatchQueue.create(o);let a=new wo(o,this.opik);return this.spans.push(a),a};this.update=t=>{var o;let r={projectName:(o=this.data.projectName)!=null?o:this.opik.config.projectName,...t};return this.opik.traceBatchQueue.update(this.data.id,r),this.data={...this.data,...r},this};}};var Ks=s=>s.replace("/api",""),fn=({apiUrl:s,projectName:t,workspaceName:r})=>{let o=encodeURIComponent(t);return `${Ks(s)}/${r}/redirect/projects?name=${o}`};var Xs=300,Os=100,yr=class{constructor({action:t,batchSize:r=Os,delay:o,enableBatch:a,name:i="ActionQueue"}){this.timerId=null;this.promise=Promise.resolve();this.queue=new Map;this.debounceFlush=()=>{this.timerId&&clearTimeout(this.timerId),this.timerId=setTimeout(()=>this.flush(),this.delay);};this.add=(t,r)=>{if(this.queue.set(t,r),!this.enableBatch){this.flush();return}if(this.queue.size>=this.batchSize){this.flush();return}this.debounceFlush();};this.update=(t,r)=>{let o=this.queue.get(t);o&&(this.queue.set(t,{...o,...r}),this.debounceFlush());};this.flush=async()=>{if(this.queue.size===0)return this.promise;let t=new Map(this.queue);this.queue.clear(),C.debug(`Adding ${t.size} items to ${this.name} promise:`,t),this.promise=this.promise.finally(()=>(C.debug(`Flushing ${this.name}:`,t),this.action(t))).catch(r=>{C.error(`Failed to flush ${this.name}:`,r,t);}),await this.promise;};this.action=t,this.batchSize=r,this.delay=o,this.enableBatch=a,this.name=i;}},J=class{constructor({delay:t=Xs,enableCreateBatch:r=true,enableDeleteBatch:o=true,name:a="BatchQueue"}){this.create=t=>{let r=this.getId(t);this.createQueue.add(r,t);};this.get=async t=>{let r=this.createQueue.queue.get(t);return r||this.getEntity(t)};this.update=(t,r)=>{if(this.createQueue.queue.get(t)){this.createQueue.update(t,r);return}this.updateQueue.add(t,r);};this.delete=t=>{if(this.createQueue.queue.has(t)){this.createQueue.queue.delete(t);return}this.deleteQueue.add(t);};this.flush=async()=>{await this.createQueue.flush(),await this.updateQueue.flush(),await this.deleteQueue.flush();};this.name=a,this.createQueue=new yr({action:async i=>{await this.createEntities(Array.from(i.values()));},delay:t,enableBatch:r,name:`${a}:createQueue`}),this.updateQueue=new yr({action:async i=>{await this.createQueue.flush();let p=Array.from(i.entries());for(let[d,u]of p)await this.updateEntity(d,u);},delay:t,enableBatch:false,name:`${a}:updateQueue`}),this.deleteQueue=new yr({action:async i=>{await this.createQueue.flush(),await this.updateQueue.flush(),await this.deleteEntities(Array.from(i.keys()));},delay:t,enableBatch:o,name:`${a}:deleteQueue`});}};var yo=class extends J{constructor(r,o){super({delay:o,enableDeleteBatch:false,name:"SpanBatchQueue"});this.api=r;}getId(r){return r.id}async createEntities(r){await this.api.spans.createSpans({spans:r});}async getEntity(r){return await this.api.spans.getSpanById(r)}async updateEntity(r,o){await this.api.spans.updateSpan(r,o);}async deleteEntities(r){for(let o of r)await this.api.spans.deleteSpanById(o);}};var ko=class extends J{constructor(r,o){super({delay:o,enableDeleteBatch:false,name:"SpanFeedbackScoresBatchQueue"});this.api=r;}getId(r){return {id:r.id,name:r.name}}async createEntities(r){await this.api.spans.scoreBatchOfSpans({scores:r});}async getEntity(){throw new Error("Not implemented")}async updateEntity(){throw new Error("Not implemented")}async deleteEntities(r){for(let o of r)await this.api.spans.deleteSpanFeedbackScore(o.id,{name:o.name});}};var So=class extends J{constructor(r,o){super({delay:o,name:"TraceBatchQueue"});this.api=r;}getId(r){return r.id}async createEntities(r){await this.api.traces.createTraces({traces:r});}async getEntity(r){return await this.api.traces.getTraceById(r)}async updateEntity(r,o){await this.api.traces.updateTrace(r,o);}async deleteEntities(r){await this.api.traces.deleteTraces({ids:r});}};var zo=class extends J{constructor(r,o){super({delay:o,enableDeleteBatch:false,name:"TraceFeedbackScoresBatchQueue"});this.api=r;}getId(r){return {id:r.id,name:r.name}}async createEntities(r){await this.api.traces.scoreBatchOfTraces({scores:r});}async getEntity(){throw new Error("Not implemented")}async updateEntity(){throw new Error("Not implemented")}async deleteEntities(r){for(let o of r)await this.api.traces.deleteTraceFeedbackScore(o.id,{name:o.name});}};var ae=class{constructor(t){this.displayTraceLog=t=>{if(t===this.lastProjectNameLogged||!this.config.apiUrl)return;let r=fn({apiUrl:this.config.apiUrl,projectName:t,workspaceName:this.config.workspaceName});C.info(`Started logging traces to the "${t}" project at ${ci(r)}`),this.lastProjectNameLogged=t;};this.trace=t=>{var a;C.debug("Creating new trace with data:",t);let r=(a=t.projectName)!=null?a:this.config.projectName,o=new ho({id:hr(),startTime:new Date,...t,projectName:r},this);return this.traceBatchQueue.create(o.data),C.debug("Trace added to the queue with ID:",o.data.id),this.displayTraceLog(r),o};this.flush=async()=>{C.debug("Starting flush operation");try{await this.traceBatchQueue.flush(),await this.spanBatchQueue.flush(),await this.traceFeedbackScoresBatchQueue.flush(),await this.spanFeedbackScoresBatchQueue.flush(),C.info("Successfully flushed all data to Opik");}catch(t){C.error("Error during flush operation:",{error:t instanceof Error?t.message:t});}};C.debug("Initializing OpikClient with config:",t),this.config=mi(t),this.api=new wr({apiKey:this.config.apiKey,environment:this.config.apiUrl,workspaceName:this.config.workspaceName}),this.spanBatchQueue=new yo(this.api),this.traceBatchQueue=new So(this.api),this.spanFeedbackScoresBatchQueue=new ko(this.api),this.traceFeedbackScoresBatchQueue=new zo(this.api);}};new async_hooks.AsyncLocalStorage;new ae;var kr;(function(s){s[s.SUCCESS=0]="SUCCESS",s[s.FAILED=1]="FAILED";})(kr||(kr={}));var Hs=new ae,si=class{constructor({client:t=Hs}={}){this.traces=new Map;this.spans=new Map;this.getSpanInput=t=>{let r={},{attributes:o}=t;return Object.keys(o).forEach(i=>{if(i==="ai.prompt"||i==="gen_ai.request"){let p=Qs(o[i]);p&&(r={...r,...p});}if(i.startsWith("ai.prompt.")){let p=i.replace("ai.prompt.","");r[p]=ni(o[i]);}if(i.startsWith("gen_ai.request.")){let p=i.replace("gen_ai.request.","");r[p]=ni(o[i]);}}),Object.keys(r).length>0||("ai.toolCall.name"in o&&(r.toolName=o["ai.toolCall.name"]),"ai.toolCall.args"in o&&(r.args=o["ai.toolCall.args"])),r};this.getSpanOutput=t=>{let{attributes:r}=t;return r["ai.response.text"]?{text:r["ai.response.text"]}:r["ai.toolCall.result"]?{result:r["ai.toolCall.result"]}:r["ai.response.toolCalls"]?{toolCalls:ni(r["ai.response.toolCalls"])}:{}};this.getSpanMetadata=t=>{let{attributes:r}=t,o={};return r["gen_ai.response.model"]&&(o.model=r["gen_ai.response.model"]),r["gen_ai.system"]&&(o.system=r["gen_ai.system"]),o};this.getSpanUsage=t=>{let{attributes:r}=t,o={};return "ai.usage.promptTokens"in r&&(o.prompt_tokens=r["ai.usage.promptTokens"]),"gen_ai.usage.input_tokens"in r&&(o.prompt_tokens=r["gen_ai.usage.input_tokens"]),"ai.usage.completionTokens"in r&&(o.completion_tokens=r["ai.usage.completionTokens"]),"gen_ai.usage.output_tokens"in r&&(o.completion_tokens=r["gen_ai.usage.output_tokens"]),("prompt_tokens"in o||"completion_tokens"in o)&&(o.total_tokens=(o.prompt_tokens||0)+(o.completion_tokens||0)),o};this.processSpan=({otelSpan:t,parentSpan:r,trace:o})=>o.span({name:t.name,startTime:new Date(xo(t.startTime)),endTime:new Date(xo(t.endTime)),parentSpanId:r==null?void 0:r.data.id,input:this.getSpanInput(t),output:this.getSpanOutput(t),metadata:this.getSpanMetadata(t),usage:this.getSpanUsage(t),type:"llm"});this.shutdown=async()=>{await this.client.flush();};this.forceFlush=async()=>{await this.client.flush();};this.export=(t,r)=>{let o=$s(t);Object.entries(o).forEach(([a,i])=>{var f,y;let[p,...d]=i,u=this.client.trace({startTime:new Date(xo(p.startTime)),endTime:new Date(xo(p.endTime)),name:(y=(f=p.attributes["ai.telemetry.metadata.traceName"])==null?void 0:f.toString())!=null?y:p.name,input:this.getSpanInput(p),output:this.getSpanOutput(p),metadata:this.getSpanMetadata(p),usage:this.getSpanUsage(p)});this.traces.set(a,u),d.forEach(k=>{var ee;let z=this.spans.get((ee=k.parentSpanId)!=null?ee:""),K=this.processSpan({parentSpan:z,otelSpan:k,trace:u});this.spans.set(k.spanContext().spanId,K);});}),r({code:kr.SUCCESS});};this.client=t;}static getSettings(t){var o,a,i;let r={...t.metadata};return t.name&&(r.traceName=t.name),{isEnabled:(o=t.isEnabled)!=null?o:true,recordInputs:(a=t.recordInputs)!=null?a:true,recordOutputs:(i=t.recordOutputs)!=null?i:true,functionId:t.functionId,metadata:r}}};function $s(s){let t={};return s.forEach(r=>{let o=r.spanContext();t[o.traceId]||(t[o.traceId]=[]),t[o.traceId].push(r);}),Object.values(t).forEach(r=>{r.sort((o,a)=>{if(!o.parentSpanId&&a.parentSpanId)return -1;if(o.parentSpanId&&!a.parentSpanId)return 1;if(o.parentSpanId&&a.parentSpanId){if(o.parentSpanId===a.spanContext().spanId)return 1;if(a.parentSpanId===o.spanContext().spanId)return -1}return 0});}),t}function xo(s){return s[0]*1e3+s[1]/1e6}function ni(s){try{return JSON.parse(s)}catch{return s}}function Qs(s){if(typeof s=="string")try{let t=JSON.parse(s);if(t!==null&&typeof t=="object"&&!Array.isArray(t))return t}catch{return}}
4
- exports.OpikExporter=si;
1
+ 'use strict';var ansiEscapes=require('ansi-escapes'),tslog=require('tslog'),fi=require('fs'),vn=require('ini'),bs=require('qs'),uuid=require('uuid'),async_hooks=require('async_hooks');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var fi__default=/*#__PURE__*/_interopDefault(fi);var vn__default=/*#__PURE__*/_interopDefault(vn);var bs__default=/*#__PURE__*/_interopDefault(bs);var An=Object.defineProperty;var Ao=(s,t)=>()=>(s&&(t=s(s=0)),t);var T=(s,t)=>{for(var r in t)An(s,r,{get:t[r],enumerable:true});};var Ei={};T(Ei,{Node18UniversalStreamWrapper:()=>No});var No,Ci=Ao(()=>{No=class s{constructor(t){this.readableStream=t,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=false,this.resumeCallback=null,this.encoding=null;}on(t,r){var o;(o=this.events[t])==null||o.push(r);}off(t,r){var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(a=>a!==r);}pipe(t){return this.on("data",async r=>{if(t instanceof s)t._write(r);else if(t instanceof WritableStream){let o=t.getWriter();o.write(r).then(()=>o.releaseLock());}else t.write(r);}),this.on("end",async()=>{t instanceof s?t._end():t instanceof WritableStream?t.getWriter().close():t.end();}),this.on("error",async r=>{t instanceof s?t._error(r):t instanceof WritableStream?t.getWriter().abort(r):t.destroy(r);}),this._startReading(),t}pipeTo(t){return this.pipe(t)}unpipe(t){this.off("data",async r=>{if(t instanceof s)t._write(r);else if(t instanceof WritableStream){let o=t.getWriter();o.write(r).then(()=>o.releaseLock());}else t.write(r);}),this.off("end",async()=>{t instanceof s?t._end():t instanceof WritableStream?t.getWriter().close():t.end();}),this.off("error",async r=>{t instanceof s?t._error(r):t instanceof WritableStream?t.getWriter().abort(r):t.destroy(r);});}destroy(t){this.reader.cancel(t).then(()=>{this._emit("close");}).catch(r=>{this._emit("error",r);});}pause(){this.paused=true,this._emit("pause");}resume(){this.paused&&(this.paused=false,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null));}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:r}=await this.reader.read();if(!t)return r}setEncoding(t){this.encoding=t;}async text(){let t=[];for(;;){let{done:o,value:a}=await this.reader.read();if(o)break;a&&t.push(a);}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(t).arrayBuffer())}async json(){let t=await this.text();return JSON.parse(t)}_write(t){this._emit("data",t);}_end(){this._emit("end");}_error(t){this._emit("error",t);}_emit(t,r){if(this.events[t])for(let o of this.events[t]||[])o(r);}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:r}=await this.reader.read();if(t){this._emit("end"),this._emit("close");break}r&&this._emit("data",r);}}catch(t){this._emit("error",t);}}[Symbol.asyncIterator](){return {next:async()=>{this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:r}=await this.reader.read();return t?{done:true,value:void 0}:{done:false,value:r}},[Symbol.asyncIterator](){return this}}}};});var ji={};T(ji,{UndiciStreamWrapper:()=>Fo});var Fo,Ii=Ao(()=>{Fo=class s{constructor(t){this.readableStream=t,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=false,this.resumeCallback=null,this.encoding=null;}on(t,r){var o;(o=this.events[t])==null||o.push(r);}off(t,r){var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(a=>a!==r);}pipe(t){return this.on("data",r=>{if(t instanceof s)t._write(r);else {let o=t.getWriter();o.write(r).then(()=>o.releaseLock());}}),this.on("end",()=>{t instanceof s?t._end():t.getWriter().close();}),this.on("error",r=>{t instanceof s?t._error(r):t.getWriter().abort(r);}),this._startReading(),t}pipeTo(t){return this.pipe(t)}unpipe(t){this.off("data",r=>{if(t instanceof s)t._write(r);else {let o=t.getWriter();o.write(r).then(()=>o.releaseLock());}}),this.off("end",()=>{t instanceof s?t._end():t.getWriter().close();}),this.off("error",r=>{t instanceof s?t._error(r):t.getWriter().abort(r);});}destroy(t){this.reader.cancel(t).then(()=>{this._emit("close");}).catch(r=>{this._emit("error",r);});}pause(){this.paused=true,this._emit("pause");}resume(){this.paused&&(this.paused=false,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null));}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:r}=await this.reader.read();if(!t)return r}setEncoding(t){this.encoding=t;}async text(){let t=[];for(;;){let{done:o,value:a}=await this.reader.read();if(o)break;a&&t.push(a);}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(t).arrayBuffer())}async json(){let t=await this.text();return JSON.parse(t)}_write(t){this._emit("data",t);}_end(){this._emit("end");}_error(t){this._emit("error",t);}_emit(t,r){if(this.events[t])for(let o of this.events[t]||[])o(r);}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:r}=await this.reader.read();if(t){this._emit("end"),this._emit("close");break}r&&this._emit("data",r);}}catch(t){this._emit("error",t);}}[Symbol.asyncIterator](){return {next:async()=>{this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:r}=await this.reader.read();return t?{done:true,value:void 0}:{done:false,value:r}},[Symbol.asyncIterator](){return this}}}};});var Ui={};T(Ui,{NodePre18StreamWrapper:()=>Do});var Do,Ni=Ao(()=>{Do=class{constructor(t){this.readableStream=t;}on(t,r){this.readableStream.on(t,r);}off(t,r){this.readableStream.off(t,r);}pipe(t){return this.readableStream.pipe(t),t}pipeTo(t){return this.pipe(t)}unpipe(t){t?this.readableStream.unpipe(t):this.readableStream.unpipe();}destroy(t){this.readableStream.destroy(t);}pause(){this.readableStream.pause();}resume(){this.readableStream.resume();}get isPaused(){return this.readableStream.isPaused()}async read(){return new Promise((t,r)=>{let o=this.readableStream.read();o?t(o):(this.readableStream.once("readable",()=>{let a=this.readableStream.read();t(a);}),this.readableStream.once("error",r));})}setEncoding(t){this.readableStream.setEncoding(t),this.encoding=t;}async text(){let t=[],r=new TextEncoder;this.readableStream.setEncoding(this.encoding||"utf-8");for await(let a of this.readableStream)t.push(r.encode(a));return new TextDecoder(this.encoding||"utf-8").decode(Buffer.concat(t))}async json(){let t=await this.text();return JSON.parse(t)}[Symbol.asyncIterator](){let r=this.readableStream[Symbol.asyncIterator]();return {async next(){let{value:o,done:a}=await r.next();return {value:o,done:a}},[Symbol.asyncIterator](){return this}}}};});var Pn={SILLY:0,TRACE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,FATAL:6};function ui(s,t=s){return ansiEscapes.link(t,s)}var P=new tslog.Logger({hideLogPositionForProduction:true,prettyLogTemplate:"{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}} {{logLevelName}} "}),gi=s=>{P.settings.minLevel=Pn[s];};gi(process.env.OPIK_LOG_LEVEL||"INFO");var En="~/.opik.config",Cn={apiKey:"",apiUrl:"http://localhost:5173/api",projectName:"Default Project",workspaceName:"default"};function bi(s){return Object.fromEntries(Object.entries(s).filter(([,t])=>t!==void 0))}function jn(){return bi({apiKey:process.env.OPIK_API_KEY,apiUrl:process.env.OPIK_URL_OVERRIDE,projectName:process.env.OPIK_PROJECT_NAME,workspaceName:process.env.OPIK_WORKSPACE})}function In(){let s=process.env.OPIK_CONFIG_PATH||En;if(!fi__default.default.existsSync(s)){if(process.env.OPIK_CONFIG_PATH)throw new Error(`Config file not found at ${s}`);return {}}try{let t=vn__default.default.parse(fi__default.default.readFileSync(s,"utf8"));return t.opik?bi({apiKey:t.opik.api_key,apiUrl:t.opik.url_override,projectName:t.opik.project_name,workspaceName:t.opik.workspace}):{}}catch(t){return P.error(`Error loading config file ${s}: ${t}`),{}}}function wi(s){let t=jn(),r=In();return Un({...Cn,...r,...t,...s})}function Un(s){if(!s.apiUrl)throw new Error("OPIK_URL_OVERRIDE is not set");let t=Nn(s.apiUrl);if(t&&!s.apiKey)throw new Error("OPIK_API_KEY is not set");if(t&&(!s.workspaceName||s.workspaceName==="default"))throw new Error("OPIK_WORKSPACE is not set");return s}function Nn(s){return new URL(s).hostname.endsWith("comet.com")}var V={};T(V,{AssistantMessageRole:()=>Jn,BadRequestError:()=>N,ColumnCompareTypesItem:()=>$n,ColumnPublicTypesItem:()=>qn,ColumnTypesItem:()=>es,ConflictError:()=>X,DatasetItemCompareSource:()=>Qn,DatasetItemPublicSource:()=>Zn,DatasetItemSource:()=>On,DatasetItemWriteSource:()=>Hn,DeltaRole:()=>Kn,FeedbackScoreBatchItemSource:()=>us,FeedbackScoreCompareSource:()=>Yn,FeedbackScorePublicSource:()=>ms,FeedbackScoreSource:()=>Gn,FindFeedbackDefinitionsRequestType:()=>hi,FindFeedbackScoreNames1RequestType:()=>Ri,ForbiddenError:()=>Y,GetSpanStatsRequestType:()=>Ai,GetSpansByProjectRequestType:()=>xi,LlmAsJudgeMessagePublicRole:()=>Ln,LlmAsJudgeMessageRole:()=>Fn,LlmAsJudgeMessageWriteRole:()=>Mn,LlmAsJudgeOutputSchemaPublicType:()=>Vn,LlmAsJudgeOutputSchemaType:()=>Dn,LlmAsJudgeOutputSchemaWriteType:()=>Bn,LogItemLevel:()=>Wn,NotFoundError:()=>_,NotImplementedError:()=>ge,ProjectMetricRequestPublicInterval:()=>Si,ProjectMetricRequestPublicMetricType:()=>ki,ProjectMetricResponsePublicInterval:()=>as,ProjectMetricResponsePublicMetricType:()=>ts,PromptType:()=>is,PromptVersionDetailType:()=>ss,PromptVersionPublicType:()=>cs,PromptVersionType:()=>ns,PromptWriteType:()=>zi,ProviderApiKeyProvider:()=>os,ProviderApiKeyPublicProvider:()=>rs,ProviderApiKeyWriteProvider:()=>yi,ResponseFormatType:()=>Xn,SpanFilterPublicOperator:()=>gs,SpanPublicType:()=>ds,SpanSearchStreamRequestPublicType:()=>_i,SpanType:()=>ps,SpanWriteType:()=>ls,UnauthorizedError:()=>Q,UnprocessableEntityError:()=>L,automationRuleEvaluators:()=>Po,chatCompletions:()=>vo,check:()=>To,datasets:()=>Eo,experiments:()=>Co,feedbackDefinitions:()=>xr,llmProviderKey:()=>Rr,openTelemetryIngestion:()=>jo,projects:()=>Ar,prompts:()=>_r,spans:()=>Tr,systemUsage:()=>_o,traces:()=>Io,workspaces:()=>Uo});var xr={};T(xr,{FindFeedbackDefinitionsRequestType:()=>hi});var hi={Numerical:"numerical",Categorical:"categorical"};var Rr={};T(Rr,{ProviderApiKeyWriteProvider:()=>yi});var yi={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter"};var Ar={};T(Ar,{ProjectMetricRequestPublicInterval:()=>Si,ProjectMetricRequestPublicMetricType:()=>ki});var ki={FeedbackScores:"FEEDBACK_SCORES",TraceCount:"TRACE_COUNT",TokenUsage:"TOKEN_USAGE",Duration:"DURATION",Cost:"COST"};var Si={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var _r={};T(_r,{PromptWriteType:()=>zi});var zi={Mustache:"mustache",Jinja2:"jinja2"};var Tr={};T(Tr,{FindFeedbackScoreNames1RequestType:()=>Ri,GetSpanStatsRequestType:()=>Ai,GetSpansByProjectRequestType:()=>xi,SpanSearchStreamRequestPublicType:()=>_i});var xi={General:"general",Tool:"tool",Llm:"llm"};var Ri={General:"general",Tool:"tool",Llm:"llm"};var Ai={General:"general",Tool:"tool",Llm:"llm"};var _i={General:"general",Tool:"tool",Llm:"llm"};var _o={};var To={};var Po={};var vo={};var Eo={};var Co={};var jo={};var Io={};var Uo={};var Fn={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT"};var Dn={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var Mn={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT"};var Bn={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var Ln={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT"};var Vn={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var Wn={Info:"INFO",Warn:"WARN",Error:"ERROR",Debug:"DEBUG",Trace:"TRACE"};var Jn={System:"system",User:"user",Assistant:"assistant",Tool:"tool",Function:"function"};var Kn={System:"system",User:"user",Assistant:"assistant",Tool:"tool",Function:"function"};var Xn={Text:"text",JsonObject:"json_object",JsonSchema:"json_schema"};var On={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Gn={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Hn={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var $n={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var Qn={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Yn={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Zn={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var qn={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var es={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var rs={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter"};var os={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter"};var ts={FeedbackScores:"FEEDBACK_SCORES",TraceCount:"TRACE_COUNT",TokenUsage:"TOKEN_USAGE",Duration:"DURATION",Cost:"COST"};var as={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var is={Mustache:"mustache",Jinja2:"jinja2"};var ns={Mustache:"mustache",Jinja2:"jinja2"};var ss={Mustache:"mustache",Jinja2:"jinja2"};var cs={Mustache:"mustache",Jinja2:"jinja2"};var ps={General:"general",Tool:"tool",Llm:"llm"};var ls={General:"general",Tool:"tool",Llm:"llm"};var ms={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var ds={General:"general",Tool:"tool",Llm:"llm"};var us={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var gs={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<="};var ie=(s,t,r)=>JSON.stringify(s,t,r);var c=class s extends Error{constructor({message:t,statusCode:r,body:o}){super(fs({message:t,statusCode:r,body:o})),Object.setPrototypeOf(this,s.prototype),r!=null&&(this.statusCode=r),o!==void 0&&(this.body=o);}};function fs({message:s,statusCode:t,body:r}){let o=[];return s!=null&&o.push(s),t!=null&&o.push(`Status code: ${t.toString()}`),r!=null&&o.push(`Body: ${ie(r,void 0,2)}`),o.join(`
2
+ `)}var g=class s extends Error{constructor(t){super(t),Object.setPrototypeOf(this,s.prototype);}};var Q=class s extends c{constructor(t){super({message:"UnauthorizedError",statusCode:401,body:t}),Object.setPrototypeOf(this,s.prototype);}};var Y=class s extends c{constructor(t){super({message:"ForbiddenError",statusCode:403,body:t}),Object.setPrototypeOf(this,s.prototype);}};var _=class s extends c{constructor(t){super({message:"NotFoundError",statusCode:404,body:t}),Object.setPrototypeOf(this,s.prototype);}};var N=class s extends c{constructor(t){super({message:"BadRequestError",statusCode:400,body:t}),Object.setPrototypeOf(this,s.prototype);}};var L=class s extends c{constructor(t){super({message:"UnprocessableEntityError",statusCode:422,body:t}),Object.setPrototypeOf(this,s.prototype);}};var X=class s extends c{constructor(t){super({message:"ConflictError",statusCode:409,body:t}),Object.setPrototypeOf(this,s.prototype);}};var ge=class s extends c{constructor(t){super({message:"NotImplementedError",statusCode:501,body:t}),Object.setPrototypeOf(this,s.prototype);}};var f={Default:"http://localhost:5173/api"};function Ti(s,t){return Object.keys(t!=null?t:{}).length>0?`${s}?${bs__default.default.stringify(t,{arrayFormat:"repeat"})}`:s}var m=ws();function ws(){var u,h,y,k,S;return typeof window!="undefined"&&typeof window.document!="undefined"?{type:"browser",version:window.navigator.userAgent}:typeof globalThis!="undefined"&&((u=globalThis==null?void 0:globalThis.navigator)==null?void 0:u.userAgent)==="Cloudflare-Workers"?{type:"workerd"}:typeof EdgeRuntime=="string"?{type:"edge-runtime"}:typeof self=="object"&&typeof(self==null?void 0:self.importScripts)=="function"&&(((h=self.constructor)==null?void 0:h.name)==="DedicatedWorkerGlobalScope"||((y=self.constructor)==null?void 0:y.name)==="ServiceWorkerGlobalScope"||((k=self.constructor)==null?void 0:k.name)==="SharedWorkerGlobalScope")?{type:"web-worker"}:typeof Deno!="undefined"&&typeof Deno.version!="undefined"&&typeof Deno.version.deno!="undefined"?{type:"deno",version:Deno.version.deno}:typeof Bun!="undefined"&&typeof Bun.version!="undefined"?{type:"bun",version:Bun.version}:typeof process!="undefined"&&"version"in process&&!!process.version&&"versions"in process&&!!((S=process.versions)!=null&&S.node)?{type:"node",version:process.versions.node,parsedVersion:Number(process.versions.node.split(".")[0])}:typeof navigator!="undefined"&&(navigator==null?void 0:navigator.product)==="ReactNative"?{type:"react-native"}:{type:"unknown"}}async function Pi(){return m.type==="node"&&m.parsedVersion!=null&&m.parsedVersion>=18?fetch:m.type==="node"?(await import('node-fetch')).default:typeof fetch=="function"?fetch:(await import('node-fetch')).default}async function vi({body:s,type:t}){return t.includes("json")?ie(s):s}async function Fi(s){return m.type==="node"&&m.parsedVersion!=null&&m.parsedVersion>=18?new(await Promise.resolve().then(()=>(Ci(),Ei))).Node18UniversalStreamWrapper(s):m.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(Ii(),ji))).UndiciStreamWrapper(s):new(await Promise.resolve().then(()=>(Ni(),Ui))).NodePre18StreamWrapper(s)}async function Di(s,t){if(s.body!=null&&t==="blob")return await s.blob();if(s.body!=null&&t==="arrayBuffer")return await s.arrayBuffer();if(s.body!=null&&t==="sse")return s.body;if(s.body!=null&&t==="streaming")return Fi(s.body);if(s.body!=null&&t==="text")return await s.text();{let r=await s.text();if(r.length>0)try{return JSON.parse(r)}catch{return {ok:false,error:{reason:"non-json",statusCode:s.status,rawBody:r}}}else return}}var hs="timeout";function Mi(s){let t=new AbortController,r=setTimeout(()=>t.abort(hs),s);return {signal:t.signal,abortId:r}}function Bi(...s){let t=s.length===1&&Array.isArray(s[0])?s[0]:s,r=new AbortController;for(let o of t){if(o.aborted){r.abort(o==null?void 0:o.reason);break}o.addEventListener("abort",()=>r.abort(o==null?void 0:o.reason),{signal:r.signal});}return r.signal}var Li=async(s,t,r,o,a,n,p,d,u)=>{let h=[],y;if(n!=null){let{signal:D,abortId:ae}=Mi(n);y=ae,h.push(D);}p!=null&&h.push(p);let k=Bi(h),S=await s(t,{method:r,headers:o,body:a,signal:k,credentials:d?"include":void 0,duplex:u});return y!=null&&clearTimeout(y),S};function ys(s){let t=1+(Math.random()*2-1)*.2;return s*t}async function Vi(s,t=2){let r=await s();for(let o=0;o<t&&([408,429].includes(r.status)||r.status>=500);++o){let a=Math.min(1e3*Math.pow(2,o),6e4),n=ys(a);await new Promise(p=>setTimeout(p,n)),r=await s();}return r}async function ks(s){let t={};if(s.body!==void 0&&s.contentType!=null&&(t["Content-Type"]=s.contentType),s.headers!=null)for(let[n,p]of Object.entries(s.headers))p!=null&&(t[n]=p);let r=Ti(s.url,s.queryParameters),o=await vi({body:s.body,type:s.requestType==="json"?"json":"other"}),a=await Pi();try{let n=await Vi(async()=>Li(a,r,s.method,t,o,s.timeoutMs,s.abortSignal,s.withCredentials,s.duplex),s.maxRetries),p=await Di(n,s.responseType);return n.status>=200&&n.status<400?{ok:!0,body:p,headers:n.headers}:{ok:!1,error:{reason:"status-code",statusCode:n.status,body:p}}}catch(n){return s.abortSignal!=null&&s.abortSignal.aborted?{ok:false,error:{reason:"unknown",errorMessage:"The user aborted a request"}}:n instanceof Error&&n.name==="AbortError"?{ok:false,error:{reason:"timeout"}}:n instanceof Error?{ok:false,error:{reason:"unknown",errorMessage:n.message}}:{ok:false,error:{reason:"unknown",errorMessage:ie(n)}}}}var b=ks;var i={get:async s=>typeof s=="function"?s():s};var e={};T(e,{JsonError:()=>ne,ParseError:()=>se,any:()=>on,bigint:()=>Ji,boolean:()=>tn,booleanLiteral:()=>rn,date:()=>Ki,discriminant:()=>un,enum_:()=>vr,getObjectLikeUtils:()=>W,getObjectUtils:()=>ee,getSchemaUtils:()=>A,isProperty:()=>q,lazy:()=>Xi,lazyObject:()=>Zi,list:()=>Cr,number:()=>an,object:()=>Er,objectWithoutOptionalProperties:()=>Yi,optional:()=>Mo,property:()=>Gi,record:()=>pn,set:()=>ln,string:()=>nn,stringLiteral:()=>en,transform:()=>Bo,undiscriminatedUnion:()=>dn,union:()=>fn,unknown:()=>sn,withParsedProperties:()=>Vo});var z={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function R(s,t){return `Expected ${t}. Received ${Ss(s)}.`}function Ss(s){if(Array.isArray(s))return "list";if(s===null)return "null";if(s instanceof BigInt)return "BigInt";switch(typeof s){case "string":return `"${s}"`;case "bigint":case "number":case "boolean":case "undefined":return `${s}`}return typeof s}function C(s){return {...s,json:Wi(s.json),parse:Wi(s.parse)}}function Wi(s){return (t,r)=>{let o=s(t,r),{skipValidation:a=false}=r!=null?r:{};return !o.ok&&a?(console.warn(["Failed to validate.",...o.errors.map(n=>" - "+(n.path.length>0?`${n.path.join(".")}: ${n.message}`:n.message))].join(`
3
+ `)),{ok:true,value:t}):o}}function Pr(s){return s.path.length===0?s.message:`${s.path.join(" -> ")}: ${s.message}`}var ne=class s extends Error{constructor(r){super(r.map(Pr).join("; "));this.errors=r;Object.setPrototypeOf(this,s.prototype);}};var se=class s extends Error{constructor(r){super(r.map(Pr).join("; "));this.errors=r;Object.setPrototypeOf(this,s.prototype);}};function A(s){return {nullable:()=>zs(s),optional:()=>Mo(s),optionalNullable:()=>xs(s),transform:t=>Bo(s,t),parseOrThrow:(t,r)=>{let o=s.parse(t,r);if(o.ok)return o.value;throw new se(o.errors)},jsonOrThrow:(t,r)=>{let o=s.json(t,r);if(o.ok)return o.value;throw new ne(o.errors)}}}function zs(s){let t={parse:(r,o)=>r==null?{ok:true,value:null}:s.parse(r,o),json:(r,o)=>r==null?{ok:true,value:null}:s.json(r,o),getType:()=>z.NULLABLE};return {...t,...A(t)}}function Mo(s){let t={parse:(r,o)=>r==null?{ok:true,value:void 0}:s.parse(r,o),json:(r,o)=>o!=null&&o.omitUndefined&&r===void 0?{ok:true,value:void 0}:r==null?{ok:true,value:null}:s.json(r,o),getType:()=>z.OPTIONAL};return {...t,...A(t)}}function xs(s){let t={parse:(r,o)=>r===void 0?{ok:true,value:void 0}:r===null?{ok:true,value:null}:s.parse(r,o),json:(r,o)=>r===void 0?{ok:true,value:void 0}:r===null?{ok:true,value:null}:s.json(r,o),getType:()=>z.OPTIONAL_NULLABLE};return {...t,...A(t)}}function Bo(s,t){let r={parse:(o,a)=>{let n=s.parse(o,a);return n.ok?{ok:true,value:t.transform(n.value)}:n},json:(o,a)=>{let n=t.untransform(o);return s.json(n,a)},getType:()=>s.getType()};return {...r,...A(r)}}function Ji(){let s={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:true,value:t}:typeof t=="number"?{ok:true,value:BigInt(t)}:{ok:false,errors:[{path:r,message:R(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="bigint"?{ok:false,errors:[{path:r,message:R(t,"bigint")}]}:{ok:true,value:t},getType:()=>z.BIGINT};return {...C(s),...A(s)}}var Rs=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function Ki(){let s={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:false,errors:[{path:r,message:R(t,"string")}]}:Rs.test(t)?{ok:true,value:new Date(t)}:{ok:false,errors:[{path:r,message:R(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:true,value:t.toISOString()}:{ok:false,errors:[{path:r,message:R(t,"Date object")}]},getType:()=>z.DATE};return {...C(s),...A(s)}}function I(s,t){return ()=>{let r={parse:t,json:t,getType:()=>s};return {...C(r),...A(r)}}}function vr(s){let t=new Set(s);return I(z.ENUM,(o,{allowUnrecognizedEnumValues:a,breadcrumbsPrefix:n=[]}={})=>typeof o!="string"?{ok:false,errors:[{path:n,message:R(o,"string")}]}:!t.has(o)&&!a?{ok:false,errors:[{path:n,message:R(o,"enum")}]}:{ok:true,value:o})()}function Xi(s){let t=Lo(s);return {...t,...A(t)}}function Lo(s){return {parse:(t,r)=>ce(s).parse(t,r),json:(t,r)=>ce(s).json(t,r),getType:()=>ce(s).getType()}}function ce(s){let t=s;return t.__zurg_memoized==null&&(t.__zurg_memoized=s()),t.__zurg_memoized}function fe(s){return Object.entries(s)}function be(s,t){let r=new Set(t);return Object.entries(s).reduce((o,[a,n])=>(r.has(a)&&(o[a]=n),o),{})}function Z(s){if(typeof s!="object"||s===null)return false;if(Object.getPrototypeOf(s)===null)return true;let t=s;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(s)===t}function we(s){return Object.keys(s)}function Oi(s,t){let r=[],o=[];for(let a of s)t(a)?r.push(a):o.push(a);return [r,o]}function W(s){return {withParsedProperties:t=>Vo(s,t)}}function Vo(s,t){let r={parse:(o,a)=>{let n=s.parse(o,a);if(!n.ok)return n;let p=Object.entries(t).reduce((d,[u,h])=>({...d,[u]:typeof h=="function"?h(n.value):h}),{});return {ok:true,value:{...n.value,...p}}},json:(o,a)=>{var d;if(!Z(o))return {ok:false,errors:[{path:(d=a==null?void 0:a.breadcrumbsPrefix)!=null?d:[],message:R(o,"object")}]};let n=new Set(Object.keys(t)),p=be(o,Object.keys(o).filter(u=>!n.has(u)));return s.json(p,a)},getType:()=>s.getType()};return {...r,...A(r),...W(r)}}function Gi(s,t){return {rawKey:s,valueSchema:t,isProperty:true}}function q(s){return s.isProperty}function Er(s){let t={_getRawProperties:()=>Object.entries(s).map(([r,o])=>q(o)?o.rawKey:r),_getParsedProperties:()=>we(s),parse:(r,o)=>{let a={},n=[];for(let[p,d]of fe(s)){let u=q(d)?d.rawKey:p,h=q(d)?d.valueSchema:d,y={rawKey:u,parsedKey:p,valueSchema:h};a[u]=y,Qi(h)&&n.push(u);}return Hi({value:r,requiredKeys:n,getProperty:p=>{let d=a[p];if(d!=null)return {transformedKey:d.parsedKey,transform:u=>{var h;return d.valueSchema.parse(u,{...o,breadcrumbsPrefix:[...(h=o==null?void 0:o.breadcrumbsPrefix)!=null?h:[],p]})}}},unrecognizedObjectKeys:o==null?void 0:o.unrecognizedObjectKeys,skipValidation:o==null?void 0:o.skipValidation,breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix,omitUndefined:o==null?void 0:o.omitUndefined})},json:(r,o)=>{let a=[];for(let[n,p]of fe(s)){let d=q(p)?p.valueSchema:p;Qi(d)&&a.push(n);}return Hi({value:r,requiredKeys:a,getProperty:n=>{let p=s[n];if(p!=null)return q(p)?{transformedKey:p.rawKey,transform:d=>{var u;return p.valueSchema.json(d,{...o,breadcrumbsPrefix:[...(u=o==null?void 0:o.breadcrumbsPrefix)!=null?u:[],n]})}}:{transformedKey:n,transform:d=>{var u;return p.json(d,{...o,breadcrumbsPrefix:[...(u=o==null?void 0:o.breadcrumbsPrefix)!=null?u:[],n]})}}},unrecognizedObjectKeys:o==null?void 0:o.unrecognizedObjectKeys,skipValidation:o==null?void 0:o.skipValidation,breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix,omitUndefined:o==null?void 0:o.omitUndefined})},getType:()=>z.OBJECT};return {...C(t),...A(t),...W(t),...ee(t)}}function Hi({value:s,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:o="fail",skipValidation:a=false,breadcrumbsPrefix:n=[]}){if(!Z(s))return {ok:false,errors:[{path:n,message:R(s,"object")}]};let p=new Set(t),d=[],u={};for(let[h,y]of Object.entries(s)){let k=r(h);if(k!=null){p.delete(h);let S=k.transform(y);S.ok?u[k.transformedKey]=S.value:(u[h]=y,d.push(...S.errors));}else switch(o){case "fail":d.push({path:[...n,h],message:`Unexpected key "${h}"`});break;case "strip":break;case "passthrough":u[h]=y;break}}return d.push(...t.filter(h=>p.has(h)).map(h=>({path:n,message:`Missing required key "${h}"`}))),d.length===0||a?{ok:true,value:u}:{ok:false,errors:d}}function ee(s){return {extend:t=>{let r={_getParsedProperties:()=>[...s._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...s._getRawProperties(),...t._getRawProperties()],parse:(o,a)=>$i({extensionKeys:t._getRawProperties(),value:o,transformBase:n=>s.parse(n,a),transformExtension:n=>t.parse(n,a)}),json:(o,a)=>$i({extensionKeys:t._getParsedProperties(),value:o,transformBase:n=>s.json(n,a),transformExtension:n=>t.json(n,a)}),getType:()=>z.OBJECT};return {...r,...A(r),...W(r),...ee(r)}},passthrough:()=>{let t={_getParsedProperties:()=>s._getParsedProperties(),_getRawProperties:()=>s._getRawProperties(),parse:(r,o)=>{let a=s.parse(r,{...o,unrecognizedObjectKeys:"passthrough"});return a.ok?{ok:true,value:{...r,...a.value}}:a},json:(r,o)=>{let a=s.json(r,{...o,unrecognizedObjectKeys:"passthrough"});return a.ok?{ok:true,value:{...r,...a.value}}:a},getType:()=>z.OBJECT};return {...t,...A(t),...W(t),...ee(t)}}}}function $i({extensionKeys:s,value:t,transformBase:r,transformExtension:o}){let a=new Set(s),[n,p]=Oi(we(t),h=>a.has(h)),d=r(be(t,p)),u=o(be(t,n));return d.ok&&u.ok?{ok:true,value:{...d.value,...u.value}}:{ok:false,errors:[...d.ok?[]:d.errors,...u.ok?[]:u.errors]}}function Qi(s){return !As(s)}function As(s){switch(s.getType()){case z.ANY:case z.UNKNOWN:case z.OPTIONAL:case z.OPTIONAL_NULLABLE:return true;default:return false}}function Yi(s){return Er(s)}function Zi(s){let t={...Lo(s),_getRawProperties:()=>ce(s)._getRawProperties(),_getParsedProperties:()=>ce(s)._getParsedProperties()};return {...t,...A(t),...W(t),...ee(t)}}function Cr(s){let t={parse:(r,o)=>qi(r,(a,n)=>{var p;return s.parse(a,{...o,breadcrumbsPrefix:[...(p=o==null?void 0:o.breadcrumbsPrefix)!=null?p:[],`[${n}]`]})}),json:(r,o)=>qi(r,(a,n)=>{var p;return s.json(a,{...o,breadcrumbsPrefix:[...(p=o==null?void 0:o.breadcrumbsPrefix)!=null?p:[],`[${n}]`]})}),getType:()=>z.LIST};return {...C(t),...A(t)}}function qi(s,t){return Array.isArray(s)?s.map((o,a)=>t(o,a)).reduce((o,a)=>{if(o.ok&&a.ok)return {ok:true,value:[...o.value,a.value]};let n=[];return o.ok||n.push(...o.errors),a.ok||n.push(...a.errors),{ok:false,errors:n}},{ok:true,value:[]}):{ok:false,errors:[{message:R(s,"list"),path:[]}]}}function en(s){return I(z.STRING_LITERAL,(r,{breadcrumbsPrefix:o=[]}={})=>r===s?{ok:true,value:s}:{ok:false,errors:[{path:o,message:R(r,`"${s}"`)}]})()}function rn(s){return I(z.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:o=[]}={})=>r===s?{ok:true,value:s}:{ok:false,errors:[{path:o,message:R(r,`${s.toString()}`)}]})()}var on=I(z.ANY,s=>({ok:true,value:s}));var tn=I(z.BOOLEAN,(s,{breadcrumbsPrefix:t=[]}={})=>typeof s=="boolean"?{ok:true,value:s}:{ok:false,errors:[{path:t,message:R(s,"boolean")}]});var an=I(z.NUMBER,(s,{breadcrumbsPrefix:t=[]}={})=>typeof s=="number"?{ok:true,value:s}:{ok:false,errors:[{path:t,message:R(s,"number")}]});var nn=I(z.STRING,(s,{breadcrumbsPrefix:t=[]}={})=>typeof s=="string"?{ok:true,value:s}:{ok:false,errors:[{path:t,message:R(s,"string")}]});var sn=I(z.UNKNOWN,s=>({ok:true,value:s}));function pn(s,t){let r={parse:(o,a)=>cn({value:o,isKeyNumeric:s.getType()===z.NUMBER,transformKey:n=>{var p;return s.parse(n,{...a,breadcrumbsPrefix:[...(p=a==null?void 0:a.breadcrumbsPrefix)!=null?p:[],`${n} (key)`]})},transformValue:(n,p)=>{var d;return t.parse(n,{...a,breadcrumbsPrefix:[...(d=a==null?void 0:a.breadcrumbsPrefix)!=null?d:[],`${p}`]})},breadcrumbsPrefix:a==null?void 0:a.breadcrumbsPrefix}),json:(o,a)=>cn({value:o,isKeyNumeric:s.getType()===z.NUMBER,transformKey:n=>{var p;return s.json(n,{...a,breadcrumbsPrefix:[...(p=a==null?void 0:a.breadcrumbsPrefix)!=null?p:[],`${n} (key)`]})},transformValue:(n,p)=>{var d;return t.json(n,{...a,breadcrumbsPrefix:[...(d=a==null?void 0:a.breadcrumbsPrefix)!=null?d:[],`${p}`]})},breadcrumbsPrefix:a==null?void 0:a.breadcrumbsPrefix}),getType:()=>z.RECORD};return {...C(r),...A(r)}}function cn({value:s,isKeyNumeric:t,transformKey:r,transformValue:o,breadcrumbsPrefix:a=[]}){return Z(s)?fe(s).reduce((n,[p,d])=>{if(d===void 0)return n;let u=n,h=p;if(t){let D=p.length>0?Number(p):NaN;isNaN(D)||(h=D);}let y=r(h),k=o(d,h);if(u.ok&&y.ok&&k.ok)return {ok:true,value:{...u.value,[y.value]:k.value}};let S=[];return u.ok||S.push(...u.errors),y.ok||S.push(...y.errors),k.ok||S.push(...k.errors),{ok:false,errors:S}},{ok:true,value:{}}):{ok:false,errors:[{path:a,message:R(s,"object")}]}}function ln(s){let t=Cr(s),r={parse:(o,a)=>{let n=t.parse(o,a);return n.ok?{ok:true,value:new Set(n.value)}:n},json:(o,a)=>{var p;return o instanceof Set?t.json([...o],a):{ok:false,errors:[{path:(p=a==null?void 0:a.breadcrumbsPrefix)!=null?p:[],message:R(o,"Set")}]}},getType:()=>z.SET};return {...C(r),...A(r)}}function dn(s){let t={parse:(r,o)=>mn((a,n)=>a.parse(r,n),s,o),json:(r,o)=>mn((a,n)=>a.json(r,n),s,o),getType:()=>z.UNDISCRIMINATED_UNION};return {...C(t),...A(t)}}function mn(s,t,r){let o=[];for(let[a,n]of t.entries()){let p=s(n,{...r,skipValidation:false});if(p.ok)return p;for(let d of p.errors)o.push({path:d.path,message:`[Variant ${a}] ${d.message}`});}return {ok:false,errors:o}}function un(s,t){return {parsedDiscriminant:s,rawDiscriminant:t}}function fn(s,t){let r=typeof s=="string"?s:s.rawDiscriminant,o=typeof s=="string"?s:s.parsedDiscriminant,a=vr(we(t)),n={parse:(p,d)=>gn({value:p,discriminant:r,transformedDiscriminant:o,transformDiscriminantValue:u=>{var h;return a.parse(u,{allowUnrecognizedEnumValues:d==null?void 0:d.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(h=d==null?void 0:d.breadcrumbsPrefix)!=null?h:[],r]})},getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:d==null?void 0:d.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,h)=>h.parse(u,d),breadcrumbsPrefix:d==null?void 0:d.breadcrumbsPrefix}),json:(p,d)=>gn({value:p,discriminant:o,transformedDiscriminant:r,transformDiscriminantValue:u=>{var h;return a.json(u,{allowUnrecognizedEnumValues:d==null?void 0:d.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(h=d==null?void 0:d.breadcrumbsPrefix)!=null?h:[],o]})},getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:d==null?void 0:d.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,h)=>h.json(u,d),breadcrumbsPrefix:d==null?void 0:d.breadcrumbsPrefix}),getType:()=>z.UNION};return {...C(n),...A(n),...W(n)}}function gn({value:s,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:o,getAdditionalPropertiesSchema:a,allowUnrecognizedUnionMembers:n=false,transformAdditionalProperties:p,breadcrumbsPrefix:d=[]}){if(!Z(s))return {ok:false,errors:[{path:d,message:R(s,"object")}]};let{[t]:u,...h}=s;if(u==null)return {ok:false,errors:[{path:d,message:`Missing discriminant ("${t}")`}]};let y=o(u);if(!y.ok)return {ok:false,errors:y.errors};let k=a(y.value);if(k==null)return n?{ok:true,value:{[r]:y.value,...h}}:{ok:false,errors:[{path:[...d,t],message:"Unexpected discriminant value"}]};let S=p(h,k);return S.ok?{ok:true,value:{[r]:u,...S.value}}:S}function _s(s){var t=[];if(s.length===0)return "";if(typeof s[0]!="string")throw new TypeError("Url must be a string. Received "+s[0]);if(s[0].match(/^[^/:]+:\/*$/)&&s.length>1){var r=s.shift();s[0]=r+s[0];}s[0].match(/^file:\/\/\//)?s[0]=s[0].replace(/^([^/:]+):\/*/,"$1:///"):s[0]=s[0].replace(/^([^/:]+):\/*/,"$1://");for(var o=0;o<s.length;o++){var a=s[o];if(typeof a!="string")throw new TypeError("Url must be a string. Received "+a);a!==""&&(o>0&&(a=a.replace(/^[\/]+/,"")),o<s.length-1?a=a.replace(/[\/]+$/,""):a=a.replace(/[\/]+$/,"/"),t.push(a));}var n=t.join("/");n=n.replace(/\/(\?|&|#[^!])/g,"$1");var p=n.split("?");return n=p.shift()+(p.length>0?"?":"")+p.join("&"),n}function w(){var s;return typeof arguments[0]=="object"?s=arguments[0]:s=[].slice.call(arguments),_s(s)}var U={};T(U,{AssistantMessage:()=>Pt,AssistantMessageRole:()=>Tt,AuthDetailsHolder:()=>it,AutomationRuleEvaluatorLlmAsJudge:()=>Es,AutomationRuleEvaluatorLlmAsJudgePublic:()=>Us,AutomationRuleEvaluatorLlmAsJudgeWrite:()=>js,AutomationRuleEvaluatorPagePublic:()=>Zr,AutomationRuleEvaluatorUpdateLlmAsJudge:()=>Fs,AutomationRuleEvaluatorUpdateUserDefinedMetricPython:()=>Ds,AutomationRuleEvaluatorUserDefinedMetricPython:()=>Cs,AutomationRuleEvaluatorUserDefinedMetricPythonPublic:()=>Ns,AutomationRuleEvaluatorUserDefinedMetricPythonWrite:()=>Is,AvgValueStatPublic:()=>Ya,BatchDelete:()=>E,BiInformation:()=>ot,BiInformationResponse:()=>rr,CategoricalFeedbackDefinition:()=>aa,CategoricalFeedbackDefinitionCreate:()=>ca,CategoricalFeedbackDefinitionPublic:()=>sr,CategoricalFeedbackDefinitionUpdate:()=>ha,CategoricalFeedbackDetail:()=>ta,CategoricalFeedbackDetailCreate:()=>sa,CategoricalFeedbackDetailPublic:()=>da,CategoricalFeedbackDetailUpdate:()=>wa,ChatCompletionChoice:()=>Ct,ChatCompletionRequest:()=>Ge,ChatCompletionResponse:()=>Ut,ChunkedOutputJsonNode:()=>Ls,ChunkedOutputJsonNodePublic:()=>Qs,ChunkedOutputJsonNodePublicType:()=>ii,ChunkedOutputJsonNodeType:()=>ea,Column:()=>Zt,ColumnCompare:()=>Mt,ColumnCompareTypesItem:()=>Dt,ColumnPublic:()=>$t,ColumnPublicTypesItem:()=>Ht,ColumnTypesItem:()=>Yt,Comment:()=>j,CommentCompare:()=>Bt,CommentPublic:()=>oe,CompletionTokensDetails:()=>jt,CountValueStatPublic:()=>Za,CreatePromptVersionDetail:()=>Ae,DataPointNumberPublic:()=>Ta,Dataset:()=>Ms,DatasetIdentifier:()=>Ye,DatasetIdentifierPublic:()=>qe,DatasetItem:()=>Ft,DatasetItemBatch:()=>Bs,DatasetItemBatchWrite:()=>$e,DatasetItemCompare:()=>Kt,DatasetItemCompareSource:()=>Lt,DatasetItemPageCompare:()=>Xt,DatasetItemPagePublic:()=>Qt,DatasetItemPublic:()=>nr,DatasetItemPublicSource:()=>Gt,DatasetItemSource:()=>Nt,DatasetItemStreamRequest:()=>er,DatasetItemWrite:()=>rt,DatasetItemWriteSource:()=>et,DatasetItemsDelete:()=>Ze,DatasetPagePublic:()=>Ot,DatasetPublic:()=>de,DatasetUpdate:()=>Qe,DatasetWrite:()=>He,DeleteFeedbackScore:()=>dr,DeleteTraceThreads:()=>Je,Delta:()=>Et,DeltaRole:()=>vt,ErrorInfo:()=>G,ErrorInfoPublic:()=>ur,ErrorInfoWrite:()=>Pe,ErrorMessage:()=>$,ErrorMessageDetail:()=>Hs,ErrorMessageDetailed:()=>Os,ErrorMessagePublic:()=>Ws,Experiment:()=>Vs,ExperimentItem:()=>Ue,ExperimentItemCompare:()=>Jt,ExperimentItemPublic:()=>ir,ExperimentItemStreamRequest:()=>Be,ExperimentItemsBatch:()=>Ne,ExperimentItemsDelete:()=>Fe,ExperimentPagePublic:()=>oa,ExperimentPublic:()=>ue,ExperimentWrite:()=>Ie,ExperimentsDelete:()=>De,Feedback:()=>Js,FeedbackCreate:()=>ma,FeedbackDefinitionPagePublic:()=>fa,FeedbackObjectPublic:()=>ga,FeedbackPublic:()=>ba,FeedbackScore:()=>J,FeedbackScoreAverage:()=>re,FeedbackScoreAverageDetailed:()=>Ua,FeedbackScoreAveragePublic:()=>ra,FeedbackScoreBatch:()=>wr,FeedbackScoreBatchItem:()=>ai,FeedbackScoreBatchItemSource:()=>ti,FeedbackScoreCompare:()=>Wt,FeedbackScoreCompareSource:()=>Vt,FeedbackScoreNames:()=>_a,FeedbackScorePublic:()=>gr,FeedbackScorePublicSource:()=>Ha,FeedbackScoreSource:()=>Go,FeedbackUpdate:()=>Sa,FindFeedbackDefinitionsRequestType:()=>jr,FindFeedbackScoreNames1RequestType:()=>Wr,Function:()=>Oe,FunctionCall:()=>H,GetSpanStatsRequestType:()=>Jr,GetSpansByProjectRequestType:()=>Vr,IdentifierPublic:()=>Me,JsonNode:()=>x,JsonNodeCompare:()=>eo,JsonNodeDetail:()=>Wo,JsonNodePublic:()=>B,JsonNodeWrite:()=>M,JsonObjectSchema:()=>Xe,JsonSchema:()=>Yo,JsonSchemaElement:()=>$r,LlmAsJudgeCode:()=>or,LlmAsJudgeCodePublic:()=>xt,LlmAsJudgeCodeWrite:()=>bt,LlmAsJudgeMessage:()=>ct,LlmAsJudgeMessagePublic:()=>kt,LlmAsJudgeMessagePublicRole:()=>yt,LlmAsJudgeMessageRole:()=>st,LlmAsJudgeMessageWrite:()=>ut,LlmAsJudgeMessageWriteRole:()=>dt,LlmAsJudgeModelParameters:()=>nt,LlmAsJudgeModelParametersPublic:()=>ht,LlmAsJudgeModelParametersWrite:()=>mt,LlmAsJudgeOutputSchema:()=>lt,LlmAsJudgeOutputSchemaPublic:()=>zt,LlmAsJudgeOutputSchemaPublicType:()=>St,LlmAsJudgeOutputSchemaType:()=>pt,LlmAsJudgeOutputSchemaWrite:()=>ft,LlmAsJudgeOutputSchemaWriteType:()=>gt,LogItem:()=>_t,LogItemLevel:()=>At,LogPage:()=>qr,Message:()=>Ho,NumericalFeedbackDefinition:()=>na,NumericalFeedbackDefinitionCreate:()=>la,NumericalFeedbackDefinitionPublic:()=>cr,NumericalFeedbackDefinitionUpdate:()=>ka,NumericalFeedbackDetail:()=>ia,NumericalFeedbackDetailCreate:()=>pa,NumericalFeedbackDetailPublic:()=>ua,NumericalFeedbackDetailUpdate:()=>ya,PageColumns:()=>qt,PercentageValueStatPublic:()=>ei,PercentageValues:()=>mr,PercentageValuesDetailed:()=>Na,PercentageValuesPublic:()=>qa,Project:()=>Xs,ProjectDetailed:()=>Fa,ProjectMetricRequestPublic:()=>ze,ProjectMetricRequestPublicInterval:()=>Dr,ProjectMetricRequestPublicMetricType:()=>Fr,ProjectMetricResponsePublic:()=>Ca,ProjectMetricResponsePublicInterval:()=>va,ProjectMetricResponsePublicMetricType:()=>Pa,ProjectPagePublic:()=>lr,ProjectPublic:()=>pr,ProjectRetrieveDetailed:()=>xe,ProjectStatItemObjectPublic:()=>oi,ProjectStatsPublic:()=>br,ProjectStatsSummary:()=>Ia,ProjectStatsSummaryItem:()=>ja,ProjectUpdate:()=>Se,ProjectWrite:()=>ke,Prompt:()=>Gs,PromptDetail:()=>La,PromptPagePublic:()=>Xa,PromptPublic:()=>Ka,PromptType:()=>Da,PromptUpdatable:()=>_e,PromptVersion:()=>Ba,PromptVersionDetail:()=>O,PromptVersionDetailType:()=>Jo,PromptVersionLink:()=>ro,PromptVersionLinkPublic:()=>oo,PromptVersionLinkWrite:()=>Gr,PromptVersionPagePublic:()=>Ja,PromptVersionPublic:()=>Wa,PromptVersionPublicType:()=>Va,PromptVersionRetrieveDetail:()=>Te,PromptVersionType:()=>Ma,PromptWrite:()=>Re,PromptWriteType:()=>Br,ProviderApiKey:()=>Ks,ProviderApiKeyProvider:()=>Ra,ProviderApiKeyPublic:()=>xa,ProviderApiKeyPublicProvider:()=>za,ProviderApiKeyUpdate:()=>ye,ProviderApiKeyWrite:()=>he,ProviderApiKeyWriteProvider:()=>Ur,ResponseFormat:()=>Zo,ResponseFormatType:()=>Qo,ResultsNumberPublic:()=>Ea,ScoreName:()=>Aa,Span:()=>Ga,SpanBatch:()=>$s,SpanBatchWrite:()=>Ee,SpanFilterPublic:()=>Oo,SpanFilterPublicOperator:()=>Xo,SpanPagePublic:()=>Qa,SpanPublic:()=>fr,SpanPublicType:()=>$a,SpanSearchStreamRequestPublic:()=>je,SpanSearchStreamRequestPublicType:()=>Kr,SpanType:()=>Oa,SpanUpdate:()=>Ce,SpanWrite:()=>ve,SpanWriteType:()=>Ko,StreamOptions:()=>$o,Tool:()=>qo,ToolCall:()=>ar,Trace:()=>ni,TraceBatch:()=>Ys,TraceBatchWrite:()=>Ve,TraceCountResponse:()=>at,TracePagePublic:()=>ci,TracePublic:()=>hr,TraceThread:()=>yr,TraceThreadIdentifier:()=>Ke,TraceThreadPage:()=>si,TraceUpdate:()=>We,TraceWrite:()=>Le,Usage:()=>It,UserDefinedMetricPythonCode:()=>tr,UserDefinedMetricPythonCodePublic:()=>Rt,UserDefinedMetricPythonCodeWrite:()=>wt,WorkspaceMetadata:()=>pi,WorkspaceTraceCount:()=>tt,chatCompletions:()=>Qr,datasets:()=>Yr,experiments:()=>le,feedbackDefinitions:()=>Ir,llmProviderKey:()=>Nr,projects:()=>Mr,prompts:()=>Lr,spans:()=>pe,traces:()=>me});var Ir={};T(Ir,{FindFeedbackDefinitionsRequestType:()=>jr});var jr=e.enum_(["numerical","categorical"]);var Nr={};T(Nr,{ProviderApiKeyUpdate:()=>ye,ProviderApiKeyWrite:()=>he,ProviderApiKeyWriteProvider:()=>Ur});var Ur=e.enum_(["openai","anthropic","gemini","openrouter"]);var he=e.object({provider:Ur,apiKey:e.property("api_key",e.string()),name:e.string().optional()});var ye=e.object({apiKey:e.property("api_key",e.string()),name:e.string().optional()});var Mr={};T(Mr,{ProjectMetricRequestPublic:()=>ze,ProjectMetricRequestPublicInterval:()=>Dr,ProjectMetricRequestPublicMetricType:()=>Fr,ProjectRetrieveDetailed:()=>xe,ProjectUpdate:()=>Se,ProjectWrite:()=>ke});var Fr=e.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST"]);var Dr=e.enum_(["HOURLY","DAILY","WEEKLY"]);var ke=e.object({name:e.string(),description:e.string().optional()});var Se=e.object({name:e.string().optional(),description:e.string().optional()});var ze=e.object({metricType:e.property("metric_type",Fr.optional()),interval:Dr.optional(),intervalStart:e.property("interval_start",e.date().optional()),intervalEnd:e.property("interval_end",e.date().optional())});var xe=e.object({name:e.string()});var Lr={};T(Lr,{CreatePromptVersionDetail:()=>Ae,PromptUpdatable:()=>_e,PromptVersionRetrieveDetail:()=>Te,PromptWrite:()=>Re,PromptWriteType:()=>Br});var Br=e.enum_(["mustache","jinja2"]);var M=e.record(e.string(),e.unknown());var Re=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),template:e.string().optional(),metadata:M.optional(),changeDescription:e.property("change_description",e.string().optional()),type:Br.optional()});var Wo=e.record(e.string(),e.unknown());var Jo=e.enum_(["mustache","jinja2"]);var O=e.object({id:e.string().optional(),promptId:e.property("prompt_id",e.string().optional()),commit:e.string().optional(),template:e.string(),metadata:Wo.optional(),type:Jo.optional(),changeDescription:e.property("change_description",e.string().optional()),variables:e.list(e.string()).optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional())});var Ae=e.object({name:e.string(),version:O});var _e=e.object({name:e.string(),description:e.string().optional()});var Te=e.object({name:e.string(),commit:e.string().optional()});var pe={};T(pe,{FindFeedbackScoreNames1RequestType:()=>Wr,GetSpanStatsRequestType:()=>Jr,GetSpansByProjectRequestType:()=>Vr,SpanBatchWrite:()=>Ee,SpanSearchStreamRequestPublic:()=>je,SpanSearchStreamRequestPublicType:()=>Kr,SpanUpdate:()=>Ce,findFeedbackScoreNames1:()=>Xr});var Vr=e.enum_(["general","tool","llm"]);var Wr=e.enum_(["general","tool","llm"]);var Jr=e.enum_(["general","tool","llm"]);var Kr=e.enum_(["general","tool","llm"]);var Xr={};T(Xr,{Response:()=>Ts});var Ts=e.list(e.string());var Ko=e.enum_(["general","tool","llm"]);var Pe=e.object({exceptionType:e.property("exception_type",e.string()),message:e.string().optional(),traceback:e.string()});var ve=e.object({id:e.string().optional(),projectName:e.property("project_name",e.string().optional()),traceId:e.property("trace_id",e.string()),parentSpanId:e.property("parent_span_id",e.string().optional()),name:e.string(),type:Ko,startTime:e.property("start_time",e.date()),endTime:e.property("end_time",e.date().optional()),input:M.optional(),output:M.optional(),metadata:M.optional(),model:e.string().optional(),provider:e.string().optional(),tags:e.list(e.string()).optional(),usage:e.record(e.string(),e.number()).optional(),errorInfo:e.property("error_info",Pe.optional()),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),totalEstimatedCostVersion:e.property("total_estimated_cost_version",e.string().optional())});var Ee=e.object({spans:e.list(ve)});var x=e.record(e.string(),e.unknown());var G=e.object({exceptionType:e.property("exception_type",e.string()),message:e.string().optional(),traceback:e.string()});var Ce=e.object({projectName:e.property("project_name",e.string().optional()),projectId:e.property("project_id",e.string().optional()),traceId:e.property("trace_id",e.string()),parentSpanId:e.property("parent_span_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),input:x.optional(),output:x.optional(),metadata:x.optional(),model:e.string().optional(),provider:e.string().optional(),tags:e.list(e.string()).optional(),usage:e.record(e.string(),e.number()).optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),errorInfo:e.property("error_info",G.optional())});var Xo=e.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<="]);var Oo=e.object({field:e.string().optional(),operator:Xo.optional(),key:e.string().optional(),value:e.string().optional()});var je=e.object({traceId:e.property("trace_id",e.string().optional()),projectName:e.property("project_name",e.string().optional()),projectId:e.property("project_id",e.string().optional()),type:Kr.optional(),filters:e.list(Oo).optional(),limit:e.number().optional(),lastRetrievedId:e.property("last_retrieved_id",e.string().optional()),truncate:e.boolean().optional()});var le={};T(le,{ExperimentItemStreamRequest:()=>Be,ExperimentItemsBatch:()=>Ne,ExperimentItemsDelete:()=>Fe,ExperimentWrite:()=>Ie,ExperimentsDelete:()=>De,IdentifierPublic:()=>Me,findFeedbackScoreNames:()=>Or});var Or={};T(Or,{Response:()=>Ps});var Ps=e.list(e.string());var Gr=e.object({id:e.string()});var Ie=e.object({id:e.string().optional(),datasetName:e.property("dataset_name",e.string()),name:e.string().optional(),metadata:M.optional(),promptVersion:e.property("prompt_version",Gr.optional()),promptVersions:e.property("prompt_versions",e.list(Gr).optional())});var Go=e.enum_(["ui","sdk","online_scoring"]);var J=e.object({name:e.string(),categoryName:e.property("category_name",e.string().optional()),value:e.number(),reason:e.string().optional(),source:Go,createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var j=e.object({id:e.string().optional(),text:e.string(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Ue=e.object({id:e.string().optional(),experimentId:e.property("experiment_id",e.string()),datasetItemId:e.property("dataset_item_id",e.string()),traceId:e.property("trace_id",e.string()),input:x.optional(),output:x.optional(),feedbackScores:e.property("feedback_scores",e.list(J).optional()),comments:e.list(j).optional(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Ne=e.object({experimentItems:e.property("experiment_items",e.list(Ue))});var Fe=e.object({ids:e.list(e.string())});var De=e.object({ids:e.list(e.string())});var Me=e.object({name:e.string()});var Be=e.object({experimentName:e.property("experiment_name",e.string()),limit:e.number().optional(),lastRetrievedId:e.property("last_retrieved_id",e.string().optional()),truncate:e.boolean().optional()});var me={};T(me,{DeleteTraceThreads:()=>Je,TraceBatchWrite:()=>Ve,TraceThreadIdentifier:()=>Ke,TraceUpdate:()=>We,findFeedbackScoreNames2:()=>Hr});var Hr={};T(Hr,{Response:()=>vs});var vs=e.list(e.string());var Le=e.object({id:e.string().optional(),projectName:e.property("project_name",e.string().optional()),name:e.string(),startTime:e.property("start_time",e.date()),endTime:e.property("end_time",e.date().optional()),input:M.optional(),output:M.optional(),metadata:M.optional(),tags:e.list(e.string()).optional(),errorInfo:e.property("error_info",Pe.optional()),threadId:e.property("thread_id",e.string().optional())});var Ve=e.object({traces:e.list(Le)});var We=e.object({projectName:e.property("project_name",e.string().optional()),projectId:e.property("project_id",e.string().optional()),endTime:e.property("end_time",e.date().optional()),input:x.optional(),output:x.optional(),metadata:x.optional(),tags:e.list(e.string()).optional(),errorInfo:e.property("error_info",G.optional()),threadId:e.property("thread_id",e.string().optional())});var Je=e.object({projectName:e.property("project_name",e.string().optional()),projectId:e.property("project_id",e.string().optional()),threadIds:e.property("thread_ids",e.list(e.string()))});var Ke=e.object({projectId:e.property("project_id",e.string()),threadId:e.property("thread_id",e.string())});var Qr={};T(Qr,{ChatCompletionRequest:()=>Ge});var Ho=e.record(e.string(),e.unknown());var $o=e.object({includeUsage:e.property("include_usage",e.boolean().optional())});var Qo=e.enum_(["text","json_object","json_schema"]);var $r=e.object({type:e.string().optional()});var Xe=e.object({type:e.string().optional(),description:e.string().optional(),properties:e.record(e.string(),$r).optional(),required:e.list(e.string()).optional(),additionalProperties:e.boolean().optional(),defs:e.property("$defs",e.record(e.string(),$r).optional())});var Yo=e.object({name:e.string().optional(),strict:e.boolean().optional(),schema:Xe.optional()});var Zo=e.object({type:Qo.optional(),jsonSchema:e.property("json_schema",Yo.optional())});var Oe=e.object({name:e.string().optional(),description:e.string().optional(),strict:e.boolean().optional(),parameters:Xe.optional()});var qo=e.object({type:e.stringLiteral("function").optional(),function:Oe.optional()});var H=e.object({name:e.string().optional(),arguments:e.string().optional()});var Ge=e.object({model:e.string().optional(),messages:e.list(Ho).optional(),temperature:e.number().optional(),topP:e.property("top_p",e.number().optional()),n:e.number().optional(),stream:e.boolean().optional(),streamOptions:e.property("stream_options",$o.optional()),stop:e.list(e.string()).optional(),maxTokens:e.property("max_tokens",e.number().optional()),maxCompletionTokens:e.property("max_completion_tokens",e.number().optional()),presencePenalty:e.property("presence_penalty",e.number().optional()),frequencyPenalty:e.property("frequency_penalty",e.number().optional()),logitBias:e.property("logit_bias",e.record(e.string(),e.number()).optional()),user:e.string().optional(),responseFormat:e.property("response_format",Zo.optional()),seed:e.number().optional(),tools:e.list(qo).optional(),toolChoice:e.property("tool_choice",e.record(e.string(),e.unknown()).optional()),parallelToolCalls:e.property("parallel_tool_calls",e.boolean().optional()),functions:e.list(Oe).optional(),functionCall:e.property("function_call",H.optional())});var Yr={};T(Yr,{DatasetIdentifier:()=>Ye,DatasetIdentifierPublic:()=>qe,DatasetItemBatchWrite:()=>$e,DatasetItemStreamRequest:()=>er,DatasetItemsDelete:()=>Ze,DatasetUpdate:()=>Qe,DatasetWrite:()=>He});var He=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional()});var et=e.enum_(["manual","trace","span","sdk"]);var rt=e.object({id:e.string().optional(),traceId:e.property("trace_id",e.string().optional()),spanId:e.property("span_id",e.string().optional()),source:et,data:x});var $e=e.object({datasetName:e.property("dataset_name",e.string().optional()),datasetId:e.property("dataset_id",e.string().optional()),items:e.list(rt)});var Qe=e.object({name:e.string(),description:e.string().optional()});var Ye=e.object({datasetName:e.property("dataset_name",e.string())});var Ze=e.object({itemIds:e.property("item_ids",e.list(e.string()))});var qe=e.object({datasetName:e.property("dataset_name",e.string())});var er=e.object({datasetName:e.property("dataset_name",e.string()),lastRetrievedId:e.property("last_retrieved_id",e.string().optional()),steamLimit:e.property("steam_limit",e.number().optional())});var ot=e.object({workspaceId:e.property("workspace_id",e.string().optional()),user:e.string().optional(),count:e.number().optional()});var rr=e.object({biInformation:e.property("bi_information",e.list(ot).optional())});var tt=e.object({workspace:e.string().optional(),traceCount:e.property("trace_count",e.number().optional())});var at=e.object({workspacesTracesCount:e.property("workspaces_traces_count",e.list(tt).optional())});var $=e.object({code:e.number().optional(),message:e.string().optional(),details:e.string().optional()});var it=e.record(e.string(),e.unknown());var nt=e.object({name:e.string(),temperature:e.number()});var st=e.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT"]);var ct=e.object({role:st,content:e.string()});var pt=e.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var lt=e.object({name:e.string(),type:pt,description:e.string()});var or=e.object({model:nt,messages:e.list(ct),variables:e.record(e.string(),e.string()),schema:e.list(lt)});var Es=e.object({code:or.optional()});var tr=e.object({metric:e.string(),arguments:e.record(e.string(),e.string())});var Cs=e.object({code:tr.optional()});var mt=e.object({name:e.string(),temperature:e.number()});var dt=e.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT"]);var ut=e.object({role:dt,content:e.string()});var gt=e.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var ft=e.object({name:e.string(),type:gt,description:e.string()});var bt=e.object({model:mt,messages:e.list(ut),variables:e.record(e.string(),e.string()),schema:e.list(ft)});var js=e.object({code:bt.optional()});var wt=e.object({metric:e.string(),arguments:e.record(e.string(),e.string())});var Is=e.object({code:wt.optional()});var E=e.object({ids:e.list(e.string())});var ht=e.object({name:e.string(),temperature:e.number()});var yt=e.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT"]);var kt=e.object({role:yt,content:e.string()});var St=e.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var zt=e.object({name:e.string(),type:St,description:e.string()});var xt=e.object({model:ht,messages:e.list(kt),variables:e.record(e.string(),e.string()),schema:e.list(zt)});var Us=e.object({code:xt.optional()});var Zr=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(e.unknown()).optional()});var Rt=e.object({metric:e.string(),arguments:e.record(e.string(),e.string())});var Ns=e.object({code:Rt.optional()});var At=e.enum_(["INFO","WARN","ERROR","DEBUG","TRACE"]);var _t=e.object({timestamp:e.date().optional(),ruleId:e.property("rule_id",e.string().optional()),level:At.optional(),message:e.string().optional(),markers:e.record(e.string(),e.string()).optional()});var qr=e.object({content:e.list(_t).optional(),page:e.number().optional(),size:e.number().optional(),total:e.number().optional()});var Fs=e.object({code:or.optional()});var Ds=e.object({code:tr.optional()});var Tt=e.enum_(["system","user","assistant","tool","function"]);var ar=e.object({id:e.string().optional(),index:e.number().optional(),type:e.stringLiteral("function").optional(),function:H.optional()});var Pt=e.object({role:Tt.optional(),content:e.string().optional(),name:e.string().optional(),toolCalls:e.property("tool_calls",e.list(ar).optional()),refusal:e.boolean().optional(),functionCall:e.property("function_call",H.optional())});var vt=e.enum_(["system","user","assistant","tool","function"]);var Et=e.object({role:vt.optional(),content:e.string().optional(),toolCalls:e.property("tool_calls",e.list(ar).optional()),functionCall:e.property("function_call",H.optional())});var Ct=e.object({index:e.number().optional(),message:Pt.optional(),delta:Et.optional(),finishReason:e.property("finish_reason",e.string().optional())});var jt=e.object({reasoningTokens:e.property("reasoning_tokens",e.number().optional())});var It=e.object({totalTokens:e.property("total_tokens",e.number().optional()),promptTokens:e.property("prompt_tokens",e.number().optional()),completionTokens:e.property("completion_tokens",e.number().optional()),completionTokensDetails:e.property("completion_tokens_details",jt.optional())});var Ut=e.object({id:e.string().optional(),created:e.number().optional(),model:e.string().optional(),choices:e.list(Ct).optional(),usage:It.optional(),systemFingerprint:e.property("system_fingerprint",e.string().optional())});var Ms=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),experimentCount:e.property("experiment_count",e.number().optional()),datasetItemsCount:e.property("dataset_items_count",e.number().optional()),mostRecentExperimentAt:e.property("most_recent_experiment_at",e.date().optional()),lastCreatedExperimentAt:e.property("last_created_experiment_at",e.date().optional())});var Nt=e.enum_(["manual","trace","span","sdk"]);var Ft=e.object({id:e.string().optional(),traceId:e.property("trace_id",e.string().optional()),spanId:e.property("span_id",e.string().optional()),source:Nt,data:x,experimentItems:e.property("experiment_items",e.list(Ue).optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Bs=e.object({datasetName:e.property("dataset_name",e.string().optional()),datasetId:e.property("dataset_id",e.string().optional()),items:e.list(Ft)});var Dt=e.enum_(["string","number","object","boolean","array","null"]);var Mt=e.object({name:e.string().optional(),types:e.list(Dt).optional(),filterFieldPrefix:e.property("filter_field_prefix",e.string().optional()),filterField:e.string().optional()});var Bt=e.object({id:e.string().optional(),text:e.string(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Lt=e.enum_(["manual","trace","span","sdk"]);var eo=e.record(e.string(),e.unknown());var Vt=e.enum_(["ui","sdk","online_scoring"]);var Wt=e.object({name:e.string(),categoryName:e.property("category_name",e.string().optional()),value:e.number(),reason:e.string().optional(),source:Vt,createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Jt=e.object({id:e.string().optional(),experimentId:e.property("experiment_id",e.string()),datasetItemId:e.property("dataset_item_id",e.string()),traceId:e.property("trace_id",e.string()),input:eo.optional(),output:eo.optional(),feedbackScores:e.property("feedback_scores",e.list(Wt).optional()),comments:e.list(Bt).optional(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Kt=e.object({id:e.string().optional(),traceId:e.property("trace_id",e.string().optional()),spanId:e.property("span_id",e.string().optional()),source:Lt,data:x,experimentItems:e.property("experiment_items",e.list(Jt).optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Xt=e.object({content:e.list(Kt).optional(),page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),columns:e.list(Mt).optional()});var de=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),experimentCount:e.property("experiment_count",e.number().optional()),datasetItemsCount:e.property("dataset_items_count",e.number().optional()),mostRecentExperimentAt:e.property("most_recent_experiment_at",e.date().optional()),lastCreatedExperimentAt:e.property("last_created_experiment_at",e.date().optional())});var Ot=e.object({content:e.list(de).optional(),page:e.number().optional(),size:e.number().optional(),total:e.number().optional()});var Gt=e.enum_(["manual","trace","span","sdk"]);var ir=e.object({id:e.string().optional(),experimentId:e.property("experiment_id",e.string()),datasetItemId:e.property("dataset_item_id",e.string()),traceId:e.property("trace_id",e.string()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var nr=e.object({id:e.string().optional(),traceId:e.property("trace_id",e.string().optional()),spanId:e.property("span_id",e.string().optional()),source:Gt,data:x,experimentItems:e.property("experiment_items",e.list(ir).optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Ht=e.enum_(["string","number","object","boolean","array","null"]);var $t=e.object({name:e.string().optional(),types:e.list(Ht).optional(),filterFieldPrefix:e.property("filter_field_prefix",e.string().optional()),filterField:e.string().optional()});var Qt=e.object({content:e.list(nr).optional(),page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),columns:e.list($t).optional()});var Yt=e.enum_(["string","number","object","boolean","array","null"]);var Zt=e.object({name:e.string().optional(),types:e.list(Yt).optional(),filterFieldPrefix:e.property("filter_field_prefix",e.string().optional()),filterField:e.string().optional()});var qt=e.object({columns:e.list(Zt).optional()});var ea=e.object({typeName:e.string().optional()});var Ls=e.object({type:ea.optional(),closed:e.boolean().optional()});var re=e.object({name:e.string(),value:e.number()});var ro=e.object({id:e.string(),commit:e.string().optional(),promptId:e.property("prompt_id",e.string().optional())});var Vs=e.object({id:e.string().optional(),datasetName:e.property("dataset_name",e.string()),datasetId:e.property("dataset_id",e.string().optional()),name:e.string().optional(),metadata:x.optional(),feedbackScores:e.property("feedback_scores",e.list(re).optional()),comments:e.list(j).optional(),traceCount:e.property("trace_count",e.number().optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),promptVersion:e.property("prompt_version",ro.optional()),promptVersions:e.property("prompt_versions",e.list(ro).optional())});var oe=e.object({id:e.string().optional(),text:e.string(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var B=e.record(e.string(),e.unknown());var ra=e.object({name:e.string(),value:e.number()});var oo=e.object({id:e.string(),commit:e.string().optional(),promptId:e.property("prompt_id",e.string().optional())});var ue=e.object({id:e.string().optional(),datasetName:e.property("dataset_name",e.string()),datasetId:e.property("dataset_id",e.string().optional()),name:e.string().optional(),metadata:B.optional(),feedbackScores:e.property("feedback_scores",e.list(ra).optional()),comments:e.list(oe).optional(),traceCount:e.property("trace_count",e.number().optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),promptVersion:e.property("prompt_version",oo.optional()),promptVersions:e.property("prompt_versions",e.list(oo).optional())});var oa=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(ue).optional()});var Ws=e.object({code:e.number().optional(),message:e.string().optional(),details:e.string().optional()});var ta=e.object({categories:e.record(e.string(),e.number())});var aa=e.object({details:ta.optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var ia=e.object({max:e.number(),min:e.number()});var na=e.object({details:ia.optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var bn=e.object({id:e.string().optional(),name:e.string(),createdAt:e.date().optional(),createdBy:e.string().optional(),lastUpdatedAt:e.date().optional(),lastUpdatedBy:e.string().optional()}),Js=e.union("type",{numerical:na.extend(bn),categorical:aa.extend(bn)}).transform({transform:s=>s,untransform:s=>s});var sa=e.object({categories:e.record(e.string(),e.number())});var ca=e.object({details:sa.optional()});var pa=e.object({max:e.number(),min:e.number()});var la=e.object({details:pa.optional()});var wn=e.object({id:e.string().optional(),name:e.string()}),ma=e.union("type",{numerical:la.extend(wn),categorical:ca.extend(wn)}).transform({transform:s=>s,untransform:s=>s});var da=e.object({categories:e.record(e.string(),e.number())});var sr=e.object({details:da.optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var ua=e.object({max:e.number(),min:e.number()});var cr=e.object({details:ua.optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var hn=e.object({id:e.string().optional(),name:e.string(),createdAt:e.date().optional(),createdBy:e.string().optional(),lastUpdatedAt:e.date().optional(),lastUpdatedBy:e.string().optional()}),ga=e.union("type",{numerical:cr.extend(hn),categorical:sr.extend(hn)}).transform({transform:s=>s,untransform:s=>s});var fa=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(ga).optional()});var yn=e.object({id:e.string().optional(),name:e.string(),createdAt:e.date().optional(),createdBy:e.string().optional(),lastUpdatedAt:e.date().optional(),lastUpdatedBy:e.string().optional()}),ba=e.union("type",{numerical:cr.extend(yn),categorical:sr.extend(yn)}).transform({transform:s=>s,untransform:s=>s});var wa=e.object({categories:e.record(e.string(),e.number())});var ha=e.object({details:wa.optional()});var ya=e.object({max:e.number(),min:e.number()});var ka=e.object({details:ya.optional()});var kn=e.object({id:e.string().optional(),name:e.string()}),Sa=e.union("type",{numerical:ka.extend(kn),categorical:ha.extend(kn)}).transform({transform:s=>s,untransform:s=>s});var pr=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),lastUpdatedTraceAt:e.property("last_updated_trace_at",e.date().optional())});var lr=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(pr).optional(),sortableBy:e.list(e.string()).optional()});var za=e.enum_(["openai","anthropic","gemini","openrouter"]);var xa=e.object({id:e.string().optional(),provider:za,apiKey:e.property("api_key",e.string()),name:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var Ra=e.enum_(["openai","anthropic","gemini","openrouter"]);var Ks=e.object({id:e.string().optional(),provider:Ra,apiKey:e.property("api_key",e.string()),name:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var mr=e.object({p50:e.number().optional(),p90:e.number().optional(),p99:e.number().optional()});var Xs=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),lastUpdatedTraceAt:e.property("last_updated_trace_at",e.date().optional()),feedbackScores:e.property("feedback_scores",e.list(re).optional()),duration:mr.optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),usage:e.record(e.string(),e.number()).optional(),traceCount:e.property("trace_count",e.number().optional())});var Aa=e.object({name:e.string().optional()});var _a=e.object({scores:e.list(Aa).optional()});var Ta=e.object({time:e.date(),value:e.number().optional()});var Pa=e.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST"]);var va=e.enum_(["HOURLY","DAILY","WEEKLY"]);var Ea=e.object({name:e.string().optional(),data:e.list(Ta).optional()});var Ca=e.object({projectId:e.property("project_id",e.string().optional()),metricType:e.property("metric_type",Pa.optional()),interval:va.optional(),results:e.list(Ea).optional()});var ja=e.object({projectId:e.property("project_id",e.string().optional()),feedbackScores:e.property("feedback_scores",e.list(re).optional()),duration:mr.optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),usage:e.record(e.string(),e.number()).optional(),traceCount:e.property("trace_count",e.number().optional())});var Ia=e.object({content:e.list(ja).optional()});var Ua=e.object({name:e.string(),value:e.number()});var Na=e.object({p50:e.number().optional(),p90:e.number().optional(),p99:e.number().optional()});var Fa=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),lastUpdatedTraceAt:e.property("last_updated_trace_at",e.date().optional()),feedbackScores:e.property("feedback_scores",e.list(Ua).optional()),duration:Na.optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),usage:e.record(e.string(),e.number()).optional(),traceCount:e.property("trace_count",e.number().optional())});var Os=e.object({errors:e.list(e.string()).optional()});var Da=e.enum_(["mustache","jinja2"]);var Ma=e.enum_(["mustache","jinja2"]);var Ba=e.object({id:e.string().optional(),promptId:e.property("prompt_id",e.string().optional()),commit:e.string().optional(),template:e.string(),metadata:x.optional(),type:Ma.optional(),changeDescription:e.property("change_description",e.string().optional()),variables:e.list(e.string()).optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional())});var Gs=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),template:e.string().optional(),metadata:x.optional(),changeDescription:e.property("change_description",e.string().optional()),type:Da.optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),versionCount:e.property("version_count",e.number().optional()),latestVersion:e.property("latest_version",Ba.optional())});var Hs=e.object({code:e.number().optional(),message:e.string().optional(),details:e.string().optional()});var La=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),versionCount:e.property("version_count",e.number().optional()),latestVersion:e.property("latest_version",O.optional())});var Va=e.enum_(["mustache","jinja2"]);var Wa=e.object({id:e.string().optional(),promptId:e.property("prompt_id",e.string().optional()),commit:e.string().optional(),template:e.string(),metadata:B.optional(),type:Va.optional(),changeDescription:e.property("change_description",e.string().optional()),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional())});var Ja=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(Wa).optional()});var Ka=e.object({id:e.string().optional(),name:e.string(),description:e.string().optional(),createdAt:e.property("created_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),versionCount:e.property("version_count",e.number().optional())});var Xa=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(Ka).optional()});var Oa=e.enum_(["general","tool","llm"]);var Ga=e.object({id:e.string().optional(),projectName:e.property("project_name",e.string().optional()),projectId:e.property("project_id",e.string().optional()),traceId:e.property("trace_id",e.string()),parentSpanId:e.property("parent_span_id",e.string().optional()),name:e.string(),type:Oa,startTime:e.property("start_time",e.date()),endTime:e.property("end_time",e.date().optional()),input:x.optional(),output:x.optional(),metadata:x.optional(),model:e.string().optional(),provider:e.string().optional(),tags:e.list(e.string()).optional(),usage:e.record(e.string(),e.number()).optional(),errorInfo:e.property("error_info",G.optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),feedbackScores:e.property("feedback_scores",e.list(J).optional()),comments:e.list(j).optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),totalEstimatedCostVersion:e.property("total_estimated_cost_version",e.string().optional()),duration:e.number().optional()});var $s=e.object({spans:e.list(Ga)});var dr=e.object({name:e.string()});var ur=e.object({exceptionType:e.property("exception_type",e.string()),message:e.string().optional(),traceback:e.string()});var Ha=e.enum_(["ui","sdk","online_scoring"]);var gr=e.object({name:e.string(),categoryName:e.property("category_name",e.string().optional()),value:e.number(),reason:e.string().optional(),source:Ha,createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional())});var $a=e.enum_(["general","tool","llm"]);var fr=e.object({id:e.string().optional(),projectId:e.property("project_id",e.string().optional()),traceId:e.property("trace_id",e.string()),parentSpanId:e.property("parent_span_id",e.string().optional()),name:e.string(),type:$a,startTime:e.property("start_time",e.date()),endTime:e.property("end_time",e.date().optional()),input:B.optional(),output:B.optional(),metadata:B.optional(),model:e.string().optional(),provider:e.string().optional(),tags:e.list(e.string()).optional(),usage:e.record(e.string(),e.number()).optional(),errorInfo:e.property("error_info",ur.optional()),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),feedbackScores:e.property("feedback_scores",e.list(gr).optional()),comments:e.list(oe).optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),totalEstimatedCostVersion:e.property("total_estimated_cost_version",e.string().optional()),duration:e.number().optional()});var Qa=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(fr).optional()});var Ya=e.object({value:e.number().optional()});var Za=e.object({value:e.number().optional()});var qa=e.object({p50:e.number().optional(),p90:e.number().optional(),p99:e.number().optional()});var ei=e.object({value:qa.optional()});var ri=e.object({name:e.string().optional()}),oi=e.union("type",{PERCENTAGE:ei.extend(ri),COUNT:Za.extend(ri),AVG:Ya.extend(ri)}).transform({transform:s=>s,untransform:s=>s});var br=e.object({stats:e.list(oi).optional()});var ti=e.enum_(["ui","sdk","online_scoring"]);var ai=e.object({id:e.string(),projectName:e.property("project_name",e.string().optional()),name:e.string(),categoryName:e.property("category_name",e.string().optional()),value:e.number(),reason:e.string().optional(),source:ti});var wr=e.object({scores:e.list(ai)});var ii=e.object({typeName:e.string().optional()});var Qs=e.object({type:ii.optional(),closed:e.boolean().optional()});var ni=e.object({id:e.string().optional(),projectName:e.property("project_name",e.string().optional()),projectId:e.property("project_id",e.string().optional()),name:e.string(),startTime:e.property("start_time",e.date()),endTime:e.property("end_time",e.date().optional()),input:x.optional(),output:x.optional(),metadata:x.optional(),tags:e.list(e.string()).optional(),errorInfo:e.property("error_info",G.optional()),usage:e.record(e.string(),e.number()).optional(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),feedbackScores:e.property("feedback_scores",e.list(J).optional()),comments:e.list(j).optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),duration:e.number().optional(),threadId:e.property("thread_id",e.string().optional())});var Ys=e.object({traces:e.list(ni)});var hr=e.object({id:e.string().optional(),projectId:e.property("project_id",e.string().optional()),name:e.string(),startTime:e.property("start_time",e.date()),endTime:e.property("end_time",e.date().optional()),input:B.optional(),output:B.optional(),metadata:B.optional(),tags:e.list(e.string()).optional(),errorInfo:e.property("error_info",ur.optional()),usage:e.record(e.string(),e.number()).optional(),createdAt:e.property("created_at",e.date().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),lastUpdatedBy:e.property("last_updated_by",e.string().optional()),feedbackScores:e.property("feedback_scores",e.list(gr).optional()),comments:e.list(oe).optional(),totalEstimatedCost:e.property("total_estimated_cost",e.number().optional()),duration:e.number().optional(),threadId:e.property("thread_id",e.string().optional())});var yr=e.object({id:e.string().optional(),projectId:e.property("project_id",e.string().optional()),startTime:e.property("start_time",e.date().optional()),endTime:e.property("end_time",e.date().optional()),duration:e.number().optional(),firstMessage:e.property("first_message",x.optional()),lastMessage:e.property("last_message",x.optional()),numberOfMessages:e.property("number_of_messages",e.number().optional()),lastUpdatedAt:e.property("last_updated_at",e.date().optional()),createdBy:e.property("created_by",e.string().optional()),createdAt:e.property("created_at",e.date().optional())});var si=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(yr).optional()});var ci=e.object({page:e.number().optional(),size:e.number().optional(),total:e.number().optional(),content:e.list(hr).optional(),sortableBy:e.list(e.string()).optional()});var pi=e.object({traceDynamicSortingEnabled:e.property("trace_dynamic_sorting_enabled",e.boolean().optional())});var to=class{constructor(t={}){this._options=t;}async getDatasetBiInfo(t){var o,a;let r=await b({url:w((a=(o=await i.get(this._options.baseUrl))!=null?o:await i.get(this._options.environment))!=null?a:f.Default,"v1/internal/usage/bi-datasets"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return rr.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/internal/usage/bi-datasets.");case "unknown":throw new c({message:r.error.errorMessage})}}async getExperimentBiInfo(t){var o,a;let r=await b({url:w((a=(o=await i.get(this._options.baseUrl))!=null?o:await i.get(this._options.environment))!=null?a:f.Default,"v1/internal/usage/bi-experiments"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return rr.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/internal/usage/bi-experiments.");case "unknown":throw new c({message:r.error.errorMessage})}}async getTracesBiInfo(t){var o,a;let r=await b({url:w((a=(o=await i.get(this._options.baseUrl))!=null?o:await i.get(this._options.environment))!=null?a:f.Default,"v1/internal/usage/bi-traces"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return rr.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/internal/usage/bi-traces.");case "unknown":throw new c({message:r.error.errorMessage})}}async getTracesCountForWorkspaces(t){var o,a;let r=await b({url:w((a=(o=await i.get(this._options.baseUrl))!=null?o:await i.get(this._options.environment))!=null?a:f.Default,"v1/internal/usage/workspace-trace-counts"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return at.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/internal/usage/workspace-trace-counts.");case "unknown":throw new c({message:r.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var ao=class{constructor(t={}){this._options=t;}async access(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/auth"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:it.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Q($.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}));case 403:throw new Y($.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}));default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/auth.");case "unknown":throw new c({message:o.error.errorMessage})}}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var io=class{constructor(t={}){this._options=t;}async findEvaluators(t={},r){var h,y;let{projectId:o,name:a,page:n,size:p}=t,d={};o!=null&&(d.project_id=o),a!=null&&(d.name=a),n!=null&&(d.page=n.toString()),p!=null&&(d.size=p.toString());let u=await b({url:w((y=(h=await i.get(this._options.baseUrl))!=null?h:await i.get(this._options.environment))!=null?y:f.Default,"v1/private/automations/evaluators"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(u.ok)return Zr.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(u.error.reason==="status-code")throw new c({statusCode:u.error.statusCode,body:u.error.body});switch(u.error.reason){case "non-json":throw new c({statusCode:u.error.statusCode,body:u.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/automations/evaluators.");case "unknown":throw new c({message:u.error.errorMessage})}}async createAutomationRuleEvaluator(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/automations/evaluators"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:t,timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/automations/evaluators.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteAutomationRuleEvaluatorBatch(t,r){var d,u;let{projectId:o,body:a}=t,n={};n.project_id=o;let p=await b({url:w((u=(d=await i.get(this._options.baseUrl))!=null?d:await i.get(this._options.environment))!=null?u:f.Default,"v1/private/automations/evaluators/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:n,requestType:"json",body:E.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!p.ok){if(p.error.reason==="status-code")throw new c({statusCode:p.error.statusCode,body:p.error.body});switch(p.error.reason){case "non-json":throw new c({statusCode:p.error.statusCode,body:p.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/automations/evaluators/delete.");case "unknown":throw new c({message:p.error.errorMessage})}}}async getEvaluatorById(t,r={},o){var d,u;let{projectId:a}=r,n={};a!=null&&(n.project_id=a);let p=await b({url:w((u=(d=await i.get(this._options.baseUrl))!=null?d:await i.get(this._options.environment))!=null?u:f.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:n,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(p.ok)return p.body;if(p.error.reason==="status-code")throw new c({statusCode:p.error.statusCode,body:p.error.body});switch(p.error.reason){case "non-json":throw new c({statusCode:p.error.statusCode,body:p.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/automations/evaluators/{id}.");case "unknown":throw new c({message:p.error.errorMessage})}}async updateAutomationRuleEvaluator(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:r,timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/automations/evaluators/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async getEvaluatorLogsById(t,r={},o){var d,u;let{size:a}=r,n={};a!=null&&(n.size=a.toString());let p=await b({url:w((u=(d=await i.get(this._options.baseUrl))!=null?d:await i.get(this._options.environment))!=null?u:f.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}/logs`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:n,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(p.ok)return qr.parseOrThrow(p.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(p.error.reason==="status-code")throw new c({statusCode:p.error.statusCode,body:p.error.body});switch(p.error.reason){case "non-json":throw new c({statusCode:p.error.statusCode,body:p.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/automations/evaluators/{id}/logs.");case "unknown":throw new c({message:p.error.errorMessage})}}async findEvaluatorsDeprecated(t,r={},o){var h,y;let{name:a,page:n,size:p}=r,d={};a!=null&&(d.name=a),n!=null&&(d.page=n.toString()),p!=null&&(d.size=p.toString());let u=await b({url:w((y=(h=await i.get(this._options.baseUrl))!=null?h:await i.get(this._options.environment))!=null?y:f.Default,`v1/private/automations/projects/${encodeURIComponent(t)}/evaluators`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(u.ok)return Zr.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(u.error.reason==="status-code")throw new c({statusCode:u.error.statusCode,body:u.error.body});switch(u.error.reason){case "non-json":throw new c({statusCode:u.error.statusCode,body:u.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/automations/projects/{projectId}/evaluators.");case "unknown":throw new c({message:u.error.errorMessage})}}async createAutomationRuleEvaluatorDeprecated(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/automations/projects/${encodeURIComponent(t)}/evaluators`),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:r,timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/automations/projects/{projectId}/evaluators.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteAutomationRuleEvaluatorBatchDeprecated(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/automations/projects/${encodeURIComponent(t)}/evaluators/delete`),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/automations/projects/{projectId}/evaluators/delete.");case "unknown":throw new c({message:a.error.errorMessage})}}}async getEvaluatorByIdDeprecated(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/automations/projects/${encodeURIComponent(t)}/evaluators/${encodeURIComponent(r)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(a.ok)return a.body;if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/automations/projects/{projectId}/evaluators/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}async updateAutomationRuleEvaluatorDeprecated(t,r,o,a){var p,d;let n=await b({url:w((d=(p=await i.get(this._options.baseUrl))!=null?p:await i.get(this._options.environment))!=null?d:f.Default,`v1/private/automations/projects/${encodeURIComponent(r)}/evaluators/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...a==null?void 0:a.headers},contentType:"application/json",requestType:"json",body:o,timeoutMs:(a==null?void 0:a.timeoutInSeconds)!=null?a.timeoutInSeconds*1e3:6e4,maxRetries:a==null?void 0:a.maxRetries,withCredentials:true,abortSignal:a==null?void 0:a.abortSignal});if(!n.ok){if(n.error.reason==="status-code")throw new c({statusCode:n.error.statusCode,body:n.error.body});switch(n.error.reason){case "non-json":throw new c({statusCode:n.error.statusCode,body:n.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/automations/projects/{projectId}/evaluators/{id}.");case "unknown":throw new c({message:n.error.errorMessage})}}}async getEvaluatorLogsByIdDeprecated(t,r,o={},a){var u,h;let{size:n}=o,p={};n!=null&&(p.size=n.toString());let d=await b({url:w((h=(u=await i.get(this._options.baseUrl))!=null?u:await i.get(this._options.environment))!=null?h:f.Default,`v1/private/automations/projects/${encodeURIComponent(t)}/evaluators/${encodeURIComponent(r)}/logs`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...a==null?void 0:a.headers},contentType:"application/json",queryParameters:p,requestType:"json",timeoutMs:(a==null?void 0:a.timeoutInSeconds)!=null?a.timeoutInSeconds*1e3:6e4,maxRetries:a==null?void 0:a.maxRetries,withCredentials:true,abortSignal:a==null?void 0:a.abortSignal});if(d.ok)return qr.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(d.error.reason==="status-code")throw new c({statusCode:d.error.statusCode,body:d.error.body});switch(d.error.reason){case "non-json":throw new c({statusCode:d.error.statusCode,body:d.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/automations/projects/{projectId}/evaluators/{id}/logs.");case "unknown":throw new c({message:d.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var no=class{constructor(t={}){this._options=t;}async createChatCompletions(t={},r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/chat/completions"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ge.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return Ut.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/chat/completions.");case "unknown":throw new c({message:o.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var so=class{constructor(t={}){this._options=t;}async findDatasets(t={},r){var k,S;let{page:o,size:a,withExperimentsOnly:n,promptId:p,name:d,sorting:u}=t,h={};o!=null&&(h.page=o.toString()),a!=null&&(h.size=a.toString()),n!=null&&(h.with_experiments_only=n.toString()),p!=null&&(h.prompt_id=p),d!=null&&(h.name=d),u!=null&&(h.sorting=u);let y=await b({url:w((S=(k=await i.get(this._options.baseUrl))!=null?k:await i.get(this._options.environment))!=null?S:f.Default,"v1/private/datasets"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:h,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(y.ok)return Ot.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(y.error.reason==="status-code")throw new c({statusCode:y.error.statusCode,body:y.error.body});switch(y.error.reason){case "non-json":throw new c({statusCode:y.error.statusCode,body:y.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/datasets.");case "unknown":throw new c({message:y.error.errorMessage})}}async createDataset(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/datasets"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:He.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/datasets.");case "unknown":throw new c({message:o.error.errorMessage})}}}async createOrUpdateDatasetItems(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/datasets/items"),method:"PUT",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:$e.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/datasets/items.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getDatasetById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return de.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/datasets/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async updateDataset(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Qe.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/datasets/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteDataset(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling DELETE /v1/private/datasets/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteDatasetByName(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/datasets/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ye.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/datasets/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteDatasetItems(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/datasets/items/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ze.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/datasets/items/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteDatasetsBatch(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/datasets/delete-batch"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/datasets/delete-batch.");case "unknown":throw new c({message:o.error.errorMessage})}}}async findDatasetItemsWithExperimentItems(t,r,o){var k,S;let{page:a,size:n,experimentIds:p,filters:d,truncate:u}=r,h={};a!=null&&(h.page=a.toString()),n!=null&&(h.size=n.toString()),h.experiment_ids=p,d!=null&&(h.filters=d),u!=null&&(h.truncate=u.toString());let y=await b({url:w((S=(k=await i.get(this._options.baseUrl))!=null?k:await i.get(this._options.environment))!=null?S:f.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:h,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(y.ok)return Xt.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(y.error.reason==="status-code")throw new c({statusCode:y.error.statusCode,body:y.error.body});switch(y.error.reason){case "non-json":throw new c({statusCode:y.error.statusCode,body:y.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items.");case "unknown":throw new c({message:y.error.errorMessage})}}async getDatasetByIdentifier(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/datasets/retrieve"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:qe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return de.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/datasets/retrieve.");case "unknown":throw new c({message:o.error.errorMessage})}}async getDatasetItemById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/datasets/items/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return nr.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/datasets/items/{itemId}.");case "unknown":throw new c({message:o.error.errorMessage})}}async getDatasetItems(t,r={},o){var h,y;let{page:a,size:n,truncate:p}=r,d={};a!=null&&(d.page=a.toString()),n!=null&&(d.size=n.toString()),p!=null&&(d.truncate=p.toString());let u=await b({url:w((y=(h=await i.get(this._options.baseUrl))!=null?h:await i.get(this._options.environment))!=null?y:f.Default,`v1/private/datasets/${encodeURIComponent(t)}/items`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(u.ok)return Qt.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(u.error.reason==="status-code")throw new c({statusCode:u.error.statusCode,body:u.error.body});switch(u.error.reason){case "non-json":throw new c({statusCode:u.error.statusCode,body:u.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/datasets/{id}/items.");case "unknown":throw new c({message:u.error.errorMessage})}}async getDatasetItemsOutputColumns(t,r={},o){var d,u;let{experimentIds:a}=r,n={};a!=null&&(n.experiment_ids=a);let p=await b({url:w((u=(d=await i.get(this._options.baseUrl))!=null?d:await i.get(this._options.environment))!=null?u:f.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items/output/columns`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:n,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(p.ok)return qt.parseOrThrow(p.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(p.error.reason==="status-code")throw new c({statusCode:p.error.statusCode,body:p.error.body});switch(p.error.reason){case "non-json":throw new c({statusCode:p.error.statusCode,body:p.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items/output/columns.");case "unknown":throw new c({message:p.error.errorMessage})}}async streamDatasetItems(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/datasets/items/stream"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:er.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return o.body;if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/datasets/items/stream.");case "unknown":throw new c({message:o.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var co=class{constructor(t={}){this._options=t;}async findExperiments(t={},r){var k,S;let{page:o,size:a,datasetId:n,name:p,datasetDeleted:d,promptId:u}=t,h={};o!=null&&(h.page=o.toString()),a!=null&&(h.size=a.toString()),n!=null&&(h.datasetId=n),p!=null&&(h.name=p),d!=null&&(h.dataset_deleted=d.toString()),u!=null&&(h.prompt_id=u);let y=await b({url:w((S=(k=await i.get(this._options.baseUrl))!=null?k:await i.get(this._options.environment))!=null?S:f.Default,"v1/private/experiments"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:h,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(y.ok)return oa.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(y.error.reason==="status-code")throw new c({statusCode:y.error.statusCode,body:y.error.body});switch(y.error.reason){case "non-json":throw new c({statusCode:y.error.statusCode,body:y.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/experiments.");case "unknown":throw new c({message:y.error.errorMessage})}}async createExperiment(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/experiments"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ie.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/experiments.");case "unknown":throw new c({message:o.error.errorMessage})}}}async createExperimentItems(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/experiments/items"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ne.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/experiments/items.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteExperimentItems(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/experiments/items/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Fe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/experiments/items/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteExperimentsById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/experiments/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:De.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/experiments/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async findFeedbackScoreNames(t={},r){var p,d;let{experimentIds:o}=t,a={};o!=null&&(a.experiment_ids=o);let n=await b({url:w((d=(p=await i.get(this._options.baseUrl))!=null?p:await i.get(this._options.environment))!=null?d:f.Default,"v1/private/experiments/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(n.ok)return le.findFeedbackScoreNames.Response.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(n.error.reason==="status-code")throw new c({statusCode:n.error.statusCode,body:n.error.body});switch(n.error.reason){case "non-json":throw new c({statusCode:n.error.statusCode,body:n.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/experiments/feedback-scores/names.");case "unknown":throw new c({message:n.error.errorMessage})}}async getExperimentById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/experiments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return ue.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/experiments/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async getExperimentByName(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/experiments/retrieve"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Me.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return ue.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/experiments/retrieve.");case "unknown":throw new c({message:o.error.errorMessage})}}async getExperimentItemById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/experiments/items/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return ir.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/experiments/items/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async streamExperimentItems(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/experiments/items/stream"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Be.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return o.body;if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/experiments/items/stream.");case "unknown":throw new c({message:o.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var po=class{constructor(t={}){this._options=t;}async findFeedbackDefinitions(t={},r){var h,y;let{page:o,size:a,name:n,type:p}=t,d={};o!=null&&(d.page=o.toString()),a!=null&&(d.size=a.toString()),n!=null&&(d.name=n),p!=null&&(d.type=jr.jsonOrThrow(p,{unrecognizedObjectKeys:"strip"}));let u=await b({url:w((y=(h=await i.get(this._options.baseUrl))!=null?h:await i.get(this._options.environment))!=null?y:f.Default,"v1/private/feedback-definitions"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(u.ok)return fa.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(u.error.reason==="status-code")throw new c({statusCode:u.error.statusCode,body:u.error.body});switch(u.error.reason){case "non-json":throw new c({statusCode:u.error.statusCode,body:u.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/feedback-definitions.");case "unknown":throw new c({message:u.error.errorMessage})}}async createFeedbackDefinition(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/feedback-definitions"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:ma.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/feedback-definitions.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getFeedbackDefinitionById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return ba.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/feedback-definitions/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async updateFeedbackDefinition(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Sa.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/feedback-definitions/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteFeedbackDefinitionById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling DELETE /v1/private/feedback-definitions/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteFeedbackDefinitionsBatch(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/feedback-definitions/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/feedback-definitions/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var lo=class{constructor(t={}){this._options=t;}async deleteLlmProviderApiKeysBatch(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/llm-provider-key/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/llm-provider-key/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async findLlmProviderKeys(t){var o,a;let r=await b({url:w((a=(o=await i.get(this._options.baseUrl))!=null?o:await i.get(this._options.environment))!=null?a:f.Default,"v1/private/llm-provider-key"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return lr.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/llm-provider-key.");case "unknown":throw new c({message:r.error.errorMessage})}}async storeLlmProviderApiKey(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/llm-provider-key"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:he.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Q($.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}));case 403:throw new Y($.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}));default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/llm-provider-key.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getLlmProviderApiKeyById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/llm-provider-key/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return xa.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/llm-provider-key/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async updateLlmProviderApiKey(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/llm-provider-key/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:ye.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Q($.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}));case 403:throw new Y($.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}));case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/llm-provider-key/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var mo=class{constructor(t={}){this._options=t;}async receiveTraces(t){var o,a;let r=await b({url:w((a=(o=await i.get(this._options.baseUrl))!=null?o:await i.get(this._options.environment))!=null?a:f.Default,"v1/private/otel/v1/traces"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return r.body;if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/otel/v1/traces.");case "unknown":throw new c({message:r.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var uo=class{constructor(t={}){this._options=t;}async findProjects(t={},r){var h,y;let{page:o,size:a,name:n,sorting:p}=t,d={};o!=null&&(d.page=o.toString()),a!=null&&(d.size=a.toString()),n!=null&&(d.name=n),p!=null&&(d.sorting=p);let u=await b({url:w((y=(h=await i.get(this._options.baseUrl))!=null?h:await i.get(this._options.environment))!=null?y:f.Default,"v1/private/projects"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(u.ok)return lr.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(u.error.reason==="status-code")throw new c({statusCode:u.error.statusCode,body:u.error.body});switch(u.error.reason){case "non-json":throw new c({statusCode:u.error.statusCode,body:u.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/projects.");case "unknown":throw new c({message:u.error.errorMessage})}}async createProject(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/projects"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:ke.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new N(o.error.body);case 422:throw new L(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/projects.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getProjectById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return pr.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/projects/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async deleteProjectById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new X(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling DELETE /v1/private/projects/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}}async updateProject(t,r={},o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Se.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new N(a.error.body);case 422:throw new L(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/projects/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteProjectsBatch(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/projects/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/projects/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async findFeedbackScoreNamesByProjectIds(t={},r){var p,d;let{projectIds:o}=t,a={};o!=null&&(a.project_ids=o);let n=await b({url:w((d=(p=await i.get(this._options.baseUrl))!=null?p:await i.get(this._options.environment))!=null?d:f.Default,"v1/private/projects/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(n.ok)return _a.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(n.error.reason==="status-code")throw new c({statusCode:n.error.statusCode,body:n.error.body});switch(n.error.reason){case "non-json":throw new c({statusCode:n.error.statusCode,body:n.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/projects/feedback-scores/names.");case "unknown":throw new c({message:n.error.errorMessage})}}async getProjectMetrics(t,r={},o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/projects/${encodeURIComponent(t)}/metrics`),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:ze.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(a.ok)return Ca.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new N(a.error.body);case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/projects/{id}/metrics.");case "unknown":throw new c({message:a.error.errorMessage})}}async getProjectStats(t={},r){var h,y;let{page:o,size:a,name:n,sorting:p}=t,d={};o!=null&&(d.page=o.toString()),a!=null&&(d.size=a.toString()),n!=null&&(d.name=n),p!=null&&(d.sorting=p);let u=await b({url:w((y=(h=await i.get(this._options.baseUrl))!=null?h:await i.get(this._options.environment))!=null?y:f.Default,"v1/private/projects/stats"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(u.ok)return Ia.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(u.error.reason==="status-code")throw new c({statusCode:u.error.statusCode,body:u.error.body});switch(u.error.reason){case "non-json":throw new c({statusCode:u.error.statusCode,body:u.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/projects/stats.");case "unknown":throw new c({message:u.error.errorMessage})}}async retrieveProject(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/projects/retrieve"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:xe.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return Fa.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new N(o.error.body);case 404:throw new _(o.error.body);case 422:throw new L(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/projects/retrieve.");case "unknown":throw new c({message:o.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var go=class{constructor(t={}){this._options=t;}async getPrompts(t={},r){var u,h;let{page:o,size:a,name:n}=t,p={};o!=null&&(p.page=o.toString()),a!=null&&(p.size=a.toString()),n!=null&&(p.name=n);let d=await b({url:w((h=(u=await i.get(this._options.baseUrl))!=null?u:await i.get(this._options.environment))!=null?h:f.Default,"v1/private/prompts"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:p,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(d.ok)return Xa.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(d.error.reason==="status-code")throw new c({statusCode:d.error.statusCode,body:d.error.body});switch(d.error.reason){case "non-json":throw new c({statusCode:d.error.statusCode,body:d.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/prompts.");case "unknown":throw new c({message:d.error.errorMessage})}}async createPrompt(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/prompts"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Re.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new N(o.error.body);case 409:throw new X(o.error.body);case 422:throw new L(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/prompts.");case "unknown":throw new c({message:o.error.errorMessage})}}}async createPromptVersion(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/prompts/versions"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ae.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return O.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new N(o.error.body);case 409:throw new X(o.error.body);case 422:throw new L(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/prompts/versions.");case "unknown":throw new c({message:o.error.errorMessage})}}async getPromptById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return La.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/prompts/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async updatePrompt(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:_e.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new N(a.error.body);case 404:throw new _(a.error.body);case 409:throw new X(a.error.body);case 422:throw new L(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/prompts/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deletePrompt(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling DELETE /v1/private/prompts/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deletePromptsBatch(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/prompts/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/prompts/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getPromptVersionById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/prompts/versions/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return O.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/prompts/versions/{versionId}.");case "unknown":throw new c({message:o.error.errorMessage})}}async getPromptVersions(t,r={},o){var u,h;let{page:a,size:n}=r,p={};a!=null&&(p.page=a.toString()),n!=null&&(p.size=n.toString());let d=await b({url:w((h=(u=await i.get(this._options.baseUrl))!=null?u:await i.get(this._options.environment))!=null?h:f.Default,`v1/private/prompts/${encodeURIComponent(t)}/versions`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:p,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(d.ok)return Ja.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(d.error.reason==="status-code")throw new c({statusCode:d.error.statusCode,body:d.error.body});switch(d.error.reason){case "non-json":throw new c({statusCode:d.error.statusCode,body:d.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/prompts/{id}/versions.");case "unknown":throw new c({message:d.error.errorMessage})}}async retrievePromptVersion(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/prompts/versions/retrieve"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Te.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return O.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new N(o.error.body);case 404:throw new _(o.error.body);case 422:throw new L(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/prompts/versions/retrieve.");case "unknown":throw new c({message:o.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var fo=class{constructor(t={}){this._options=t;}async addSpanComment(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/spans/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:j.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/spans/{id}/comments.");case "unknown":throw new c({message:a.error.errorMessage})}}}async addSpanFeedbackScore(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/spans/${encodeURIComponent(t)}/feedback-scores`),method:"PUT",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:J.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/spans/{id}/feedback-scores.");case "unknown":throw new c({message:a.error.errorMessage})}}}async getSpansByProject(t={},r){var D,ae;let{page:o,size:a,projectName:n,projectId:p,traceId:d,type:u,filters:h,truncate:y}=t,k={};o!=null&&(k.page=o.toString()),a!=null&&(k.size=a.toString()),n!=null&&(k.project_name=n),p!=null&&(k.project_id=p),d!=null&&(k.trace_id=d),u!=null&&(k.type=Vr.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"})),h!=null&&(k.filters=h),y!=null&&(k.truncate=y.toString());let S=await b({url:w((ae=(D=await i.get(this._options.baseUrl))!=null?D:await i.get(this._options.environment))!=null?ae:f.Default,"v1/private/spans"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:k,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(S.ok)return Qa.parseOrThrow(S.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(S.error.reason==="status-code")throw new c({statusCode:S.error.statusCode,body:S.error.body});switch(S.error.reason){case "non-json":throw new c({statusCode:S.error.statusCode,body:S.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/spans.");case "unknown":throw new c({message:S.error.errorMessage})}}async createSpan(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/spans"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:ve.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/spans.");case "unknown":throw new c({message:o.error.errorMessage})}}}async createSpans(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/spans/batch"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ee.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/spans/batch.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getSpanById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return fr.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/spans/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async deleteSpanById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")switch(o.error.statusCode){case 501:throw new ge(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling DELETE /v1/private/spans/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}}async updateSpan(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Ce.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/spans/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteSpanComments(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/spans/comments/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/spans/comments/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteSpanFeedbackScore(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/spans/${encodeURIComponent(t)}/feedback-scores/delete`),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:dr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/spans/{id}/feedback-scores/delete.");case "unknown":throw new c({message:a.error.errorMessage})}}}async findFeedbackScoreNames1(t={},r){var d,u;let{projectId:o,type:a}=t,n={};o!=null&&(n.project_id=o),a!=null&&(n.type=Wr.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}));let p=await b({url:w((u=(d=await i.get(this._options.baseUrl))!=null?d:await i.get(this._options.environment))!=null?u:f.Default,"v1/private/spans/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:n,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(p.ok)return pe.findFeedbackScoreNames1.Response.parseOrThrow(p.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(p.error.reason==="status-code")throw new c({statusCode:p.error.statusCode,body:p.error.body});switch(p.error.reason){case "non-json":throw new c({statusCode:p.error.statusCode,body:p.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/spans/feedback-scores/names.");case "unknown":throw new c({message:p.error.errorMessage})}}async getSpanComment(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/spans/${encodeURIComponent(r)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(a.ok)return j.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/spans/{spanId}/comments/{commentId}.");case "unknown":throw new c({message:a.error.errorMessage})}}async getSpanStats(t={},r){var y,k;let{projectId:o,projectName:a,traceId:n,type:p,filters:d}=t,u={};o!=null&&(u.project_id=o),a!=null&&(u.project_name=a),n!=null&&(u.trace_id=n),p!=null&&(u.type=Jr.jsonOrThrow(p,{unrecognizedObjectKeys:"strip"})),d!=null&&(u.filters=d);let h=await b({url:w((k=(y=await i.get(this._options.baseUrl))!=null?y:await i.get(this._options.environment))!=null?k:f.Default,"v1/private/spans/stats"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(h.ok)return br.parseOrThrow(h.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(h.error.reason==="status-code")throw new c({statusCode:h.error.statusCode,body:h.error.body});switch(h.error.reason){case "non-json":throw new c({statusCode:h.error.statusCode,body:h.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/spans/stats.");case "unknown":throw new c({message:h.error.errorMessage})}}async scoreBatchOfSpans(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/spans/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:wr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/spans/feedback-scores.");case "unknown":throw new c({message:o.error.errorMessage})}}}async searchSpans(t={},r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/spans/search"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:je.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return o.body;if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new N(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/spans/search.");case "unknown":throw new c({message:o.error.errorMessage})}}async updateSpanComment(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/spans/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:j.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/spans/comments/{commentId}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var bo=class{constructor(t={}){this._options=t;}async addTraceComment(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/traces/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:j.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces/{id}/comments.");case "unknown":throw new c({message:a.error.errorMessage})}}}async addTraceFeedbackScore(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/traces/${encodeURIComponent(t)}/feedback-scores`),method:"PUT",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:J.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/traces/{id}/feedback-scores.");case "unknown":throw new c({message:a.error.errorMessage})}}}async getTracesByProject(t={},r){var S,D;let{page:o,size:a,projectName:n,projectId:p,filters:d,truncate:u,sorting:h}=t,y={};o!=null&&(y.page=o.toString()),a!=null&&(y.size=a.toString()),n!=null&&(y.project_name=n),p!=null&&(y.project_id=p),d!=null&&(y.filters=d),u!=null&&(y.truncate=u.toString()),h!=null&&(y.sorting=h);let k=await b({url:w((D=(S=await i.get(this._options.baseUrl))!=null?S:await i.get(this._options.environment))!=null?D:f.Default,"v1/private/traces"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:y,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(k.ok)return ci.parseOrThrow(k.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(k.error.reason==="status-code")throw new c({statusCode:k.error.statusCode,body:k.error.body});switch(k.error.reason){case "non-json":throw new c({statusCode:k.error.statusCode,body:k.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/traces.");case "unknown":throw new c({message:k.error.errorMessage})}}async createTrace(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/traces"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Le.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces.");case "unknown":throw new c({message:o.error.errorMessage})}}}async createTraces(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/traces/batch"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ve.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces/batch.");case "unknown":throw new c({message:o.error.errorMessage})}}}async getTraceById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return hr.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/traces/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}async deleteTraceById(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling DELETE /v1/private/traces/{id}.");case "unknown":throw new c({message:o.error.errorMessage})}}}async updateTrace(t,r={},o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:We.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/traces/{id}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteTraceComments(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/traces/comments/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces/comments/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteTraceFeedbackScore(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/traces/${encodeURIComponent(t)}/feedback-scores/delete`),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:dr.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")throw new c({statusCode:a.error.statusCode,body:a.error.body});switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces/{id}/feedback-scores/delete.");case "unknown":throw new c({message:a.error.errorMessage})}}}async deleteTraceThreads(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/traces/threads/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Je.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces/threads/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async deleteTraces(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/traces/delete"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:E.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces/delete.");case "unknown":throw new c({message:o.error.errorMessage})}}}async findFeedbackScoreNames2(t={},r){var p,d;let{projectId:o}=t,a={};o!=null&&(a.project_id=o);let n=await b({url:w((d=(p=await i.get(this._options.baseUrl))!=null?p:await i.get(this._options.environment))!=null?d:f.Default,"v1/private/traces/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(n.ok)return me.findFeedbackScoreNames2.Response.parseOrThrow(n.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(n.error.reason==="status-code")throw new c({statusCode:n.error.statusCode,body:n.error.body});switch(n.error.reason){case "non-json":throw new c({statusCode:n.error.statusCode,body:n.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/traces/feedback-scores/names.");case "unknown":throw new c({message:n.error.errorMessage})}}async getTraceStats(t={},r){var u,h;let{projectId:o,projectName:a,filters:n}=t,p={};o!=null&&(p.project_id=o),a!=null&&(p.project_name=a),n!=null&&(p.filters=n);let d=await b({url:w((h=(u=await i.get(this._options.baseUrl))!=null?u:await i.get(this._options.environment))!=null?h:f.Default,"v1/private/traces/stats"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:p,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(d.ok)return br.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(d.error.reason==="status-code")throw new c({statusCode:d.error.statusCode,body:d.error.body});switch(d.error.reason){case "non-json":throw new c({statusCode:d.error.statusCode,body:d.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/traces/stats.");case "unknown":throw new c({message:d.error.errorMessage})}}async getTraceComment(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/traces/${encodeURIComponent(r)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(a.ok)return j.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/traces/{traceId}/comments/{commentId}.");case "unknown":throw new c({message:a.error.errorMessage})}}async getTraceThread(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/traces/threads/retrieve"),method:"POST",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:Ke.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(o.ok)return yr.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _(o.error.body);default:throw new c({statusCode:o.error.statusCode,body:o.error.body})}switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling POST /v1/private/traces/threads/retrieve.");case "unknown":throw new c({message:o.error.errorMessage})}}async getTraceThreads(t={},r){var k,S;let{page:o,size:a,projectName:n,projectId:p,truncate:d,filters:u}=t,h={};o!=null&&(h.page=o.toString()),a!=null&&(h.size=a.toString()),n!=null&&(h.project_name=n),p!=null&&(h.project_id=p),d!=null&&(h.truncate=d.toString()),u!=null&&(h.filters=u);let y=await b({url:w((S=(k=await i.get(this._options.baseUrl))!=null?k:await i.get(this._options.environment))!=null?S:f.Default,"v1/private/traces/threads"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",queryParameters:h,requestType:"json",timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(y.ok)return si.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(y.error.reason==="status-code")throw new c({statusCode:y.error.statusCode,body:y.error.body});switch(y.error.reason){case "non-json":throw new c({statusCode:y.error.statusCode,body:y.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/traces/threads.");case "unknown":throw new c({message:y.error.errorMessage})}}async scoreBatchOfTraces(t,r){var a,n;let o=await b({url:w((n=(a=await i.get(this._options.baseUrl))!=null?a:await i.get(this._options.environment))!=null?n:f.Default,"v1/private/traces/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...r==null?void 0:r.headers},contentType:"application/json",requestType:"json",body:wr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(r==null?void 0:r.timeoutInSeconds)!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r==null?void 0:r.maxRetries,withCredentials:true,abortSignal:r==null?void 0:r.abortSignal});if(!o.ok){if(o.error.reason==="status-code")throw new c({statusCode:o.error.statusCode,body:o.error.body});switch(o.error.reason){case "non-json":throw new c({statusCode:o.error.statusCode,body:o.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PUT /v1/private/traces/feedback-scores.");case "unknown":throw new c({message:o.error.errorMessage})}}}async updateTraceComment(t,r,o){var n,p;let a=await b({url:w((p=(n=await i.get(this._options.baseUrl))!=null?n:await i.get(this._options.environment))!=null?p:f.Default,`v1/private/traces/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:j.jsonOrThrow(r,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(!a.ok){if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _(a.error.body);default:throw new c({statusCode:a.error.statusCode,body:a.error.body})}switch(a.error.reason){case "non-json":throw new c({statusCode:a.error.statusCode,body:a.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling PATCH /v1/private/traces/comments/{commentId}.");case "unknown":throw new c({message:a.error.errorMessage})}}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var wo=class{constructor(t={}){this._options=t;}async getWorkspaceMetadata(t){var o,a;let r=await b({url:w((a=(o=await i.get(this._options.baseUrl))!=null?o:await i.get(this._options.environment))!=null?a:f.Default,"v1/private/workspaces/metadata"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return pi.parseOrThrow(r.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]});if(r.error.reason==="status-code")switch(r.error.statusCode){case 404:throw new _(r.error.body);default:throw new c({statusCode:r.error.statusCode,body:r.error.body})}switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /v1/private/workspaces/metadata.");case "unknown":throw new c({message:r.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var kr=class{constructor(t={}){this._options=t;}get systemUsage(){var t;return (t=this._systemUsage)!=null?t:this._systemUsage=new to(this._options)}get check(){var t;return (t=this._check)!=null?t:this._check=new ao(this._options)}get automationRuleEvaluators(){var t;return (t=this._automationRuleEvaluators)!=null?t:this._automationRuleEvaluators=new io(this._options)}get chatCompletions(){var t;return (t=this._chatCompletions)!=null?t:this._chatCompletions=new no(this._options)}get datasets(){var t;return (t=this._datasets)!=null?t:this._datasets=new so(this._options)}get experiments(){var t;return (t=this._experiments)!=null?t:this._experiments=new co(this._options)}get feedbackDefinitions(){var t;return (t=this._feedbackDefinitions)!=null?t:this._feedbackDefinitions=new po(this._options)}get llmProviderKey(){var t;return (t=this._llmProviderKey)!=null?t:this._llmProviderKey=new lo(this._options)}get openTelemetryIngestion(){var t;return (t=this._openTelemetryIngestion)!=null?t:this._openTelemetryIngestion=new mo(this._options)}get projects(){var t;return (t=this._projects)!=null?t:this._projects=new uo(this._options)}get prompts(){var t;return (t=this._prompts)!=null?t:this._prompts=new go(this._options)}get spans(){var t;return (t=this._spans)!=null?t:this._spans=new fo(this._options)}get traces(){var t;return (t=this._traces)!=null?t:this._traces=new bo(this._options)}get workspaces(){var t;return (t=this._workspaces)!=null?t:this._workspaces=new wo(this._options)}async isAlive(t){var o,a;let r=await b({url:w((a=(o=await i.get(this._options.baseUrl))!=null?o:await i.get(this._options.environment))!=null?a:f.Default,"is-alive/ping"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return r.body;if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /is-alive/ping.");case "unknown":throw new c({message:r.error.errorMessage})}}async version(t){var o,a;let r=await b({url:w((a=(o=await i.get(this._options.baseUrl))!=null?o:await i.get(this._options.environment))!=null?a:f.Default,"is-alive/ver"),method:"GET",headers:{"Comet-Workspace":await i.get(this._options.workspaceName)!=null?await i.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(r.ok)return r.body;if(r.error.reason==="status-code")throw new c({statusCode:r.error.statusCode,body:r.error.body});switch(r.error.reason){case "non-json":throw new c({statusCode:r.error.statusCode,body:r.error.rawBody});case "timeout":throw new g("Timeout exceeded when calling GET /is-alive/ver.");case "unknown":throw new c({message:r.error.errorMessage})}}async _getCustomAuthorizationHeaders(){return {Authorization:await i.get(this._options.apiKey)}}};var Sr=()=>uuid.v7();var ho=class{constructor(t,r){this.data=t;this.opik=r;this.end=()=>this.update({endTime:new Date});this.score=t=>{var r;this.opik.spanFeedbackScoresBatchQueue.create({...t,projectName:(r=this.data.projectName)!=null?r:this.opik.config.projectName,id:this.data.id,source:"sdk"});};this.update=t=>{var o;let r={parentSpanId:this.data.parentSpanId,projectName:(o=this.data.projectName)!=null?o:this.opik.config.projectName,traceId:this.data.traceId,...t};return this.opik.spanBatchQueue.update(this.data.id,r),this.data={...this.data,...t},this};}};var yo=class{constructor(t,r){this.data=t;this.opik=r;this.spans=[];this.end=()=>this.update({endTime:new Date});this.score=t=>{var r;this.opik.traceFeedbackScoresBatchQueue.create({...t,projectName:(r=this.data.projectName)!=null?r:this.opik.config.projectName,id:this.data.id,source:"sdk"});};this.span=t=>{var n,p;let r=(p=(n=this.data.projectName)!=null?n:t.projectName)!=null?p:this.opik.config.projectName,o={id:Sr(),startTime:new Date,...t,projectName:r,traceId:this.data.id};this.opik.spanBatchQueue.create(o);let a=new ho(o,this.opik);return this.spans.push(a),a};this.update=t=>{var o;let r={projectName:(o=this.data.projectName)!=null?o:this.opik.config.projectName,...t};return this.opik.traceBatchQueue.update(this.data.id,r),this.data={...this.data,...r},this};}};var qs=s=>s.replace("/api",""),Sn=({apiUrl:s,projectName:t,workspaceName:r})=>{let o=encodeURIComponent(t);return `${qs(s)}/${r}/redirect/projects?name=${o}`};var ec=300,rc=100,zr=class{constructor({action:t,batchSize:r=rc,delay:o,enableBatch:a,name:n="ActionQueue"}){this.timerId=null;this.promise=Promise.resolve();this.queue=new Map;this.debounceFlush=()=>{this.timerId&&clearTimeout(this.timerId),this.timerId=setTimeout(()=>this.flush(),this.delay);};this.add=(t,r)=>{if(this.queue.set(t,r),!this.enableBatch){this.flush();return}if(this.queue.size>=this.batchSize){this.flush();return}this.debounceFlush();};this.update=(t,r)=>{let o=this.queue.get(t);o&&(this.queue.set(t,{...o,...r}),this.debounceFlush());};this.flush=async()=>{if(this.queue.size===0)return this.promise;let t=new Map(this.queue);this.queue.clear(),P.debug(`Adding ${t.size} items to ${this.name} promise:`,t),this.promise=this.promise.finally(()=>(P.debug(`Flushing ${this.name}:`,t),this.action(t))).catch(r=>{P.error(`Failed to flush ${this.name}:`,r,t);}),await this.promise;};this.action=t,this.batchSize=r,this.delay=o,this.enableBatch=a,this.name=n;}},K=class{constructor({delay:t=ec,enableCreateBatch:r=true,enableDeleteBatch:o=true,name:a="BatchQueue"}){this.create=t=>{let r=this.getId(t);this.createQueue.add(r,t);};this.get=async t=>{let r=this.createQueue.queue.get(t);return r||this.getEntity(t)};this.update=(t,r)=>{if(this.createQueue.queue.get(t)){this.createQueue.update(t,r);return}this.updateQueue.add(t,r);};this.delete=t=>{if(this.createQueue.queue.has(t)){this.createQueue.queue.delete(t);return}this.deleteQueue.add(t);};this.flush=async()=>{await this.createQueue.flush(),await this.updateQueue.flush(),await this.deleteQueue.flush();};this.name=a,this.createQueue=new zr({action:async n=>{await this.createEntities(Array.from(n.values()));},delay:t,enableBatch:r,name:`${a}:createQueue`}),this.updateQueue=new zr({action:async n=>{await this.createQueue.flush();let p=Array.from(n.entries());for(let[d,u]of p)await this.updateEntity(d,u);},delay:t,enableBatch:false,name:`${a}:updateQueue`}),this.deleteQueue=new zr({action:async n=>{await this.createQueue.flush(),await this.updateQueue.flush(),await this.deleteEntities(Array.from(n.keys()));},delay:t,enableBatch:o,name:`${a}:deleteQueue`});}};var ko=class extends K{constructor(r,o){super({delay:o,enableDeleteBatch:false,name:"SpanBatchQueue"});this.api=r;}getId(r){return r.id}async createEntities(r){await this.api.spans.createSpans({spans:r});}async getEntity(r){return await this.api.spans.getSpanById(r)}async updateEntity(r,o){await this.api.spans.updateSpan(r,o);}async deleteEntities(r){for(let o of r)await this.api.spans.deleteSpanById(o);}};var So=class extends K{constructor(r,o){super({delay:o,enableDeleteBatch:false,name:"SpanFeedbackScoresBatchQueue"});this.api=r;}getId(r){return {id:r.id,name:r.name}}async createEntities(r){await this.api.spans.scoreBatchOfSpans({scores:r});}async getEntity(){throw new Error("Not implemented")}async updateEntity(){throw new Error("Not implemented")}async deleteEntities(r){for(let o of r)await this.api.spans.deleteSpanFeedbackScore(o.id,{name:o.name});}};var zo=class extends K{constructor(r,o){super({delay:o,name:"TraceBatchQueue"});this.api=r;}getId(r){return r.id}async createEntities(r){await this.api.traces.createTraces({traces:r});}async getEntity(r){return await this.api.traces.getTraceById(r)}async updateEntity(r,o){await this.api.traces.updateTrace(r,o);}async deleteEntities(r){await this.api.traces.deleteTraces({ids:r});}};var xo=class extends K{constructor(r,o){super({delay:o,enableDeleteBatch:false,name:"TraceFeedbackScoresBatchQueue"});this.api=r;}getId(r){return {id:r.id,name:r.name}}async createEntities(r){await this.api.traces.scoreBatchOfTraces({scores:r});}async getEntity(){throw new Error("Not implemented")}async updateEntity(){throw new Error("Not implemented")}async deleteEntities(r){for(let o of r)await this.api.traces.deleteTraceFeedbackScore(o.id,{name:o.name});}};var te=class{constructor(t){this.displayTraceLog=t=>{if(t===this.lastProjectNameLogged||!this.config.apiUrl)return;let r=Sn({apiUrl:this.config.apiUrl,projectName:t,workspaceName:this.config.workspaceName});P.info(`Started logging traces to the "${t}" project at ${ui(r)}`),this.lastProjectNameLogged=t;};this.trace=t=>{var a;P.debug("Creating new trace with data:",t);let r=(a=t.projectName)!=null?a:this.config.projectName,o=new yo({id:Sr(),startTime:new Date,...t,projectName:r},this);return this.traceBatchQueue.create(o.data),P.debug("Trace added to the queue with ID:",o.data.id),this.displayTraceLog(r),o};this.flush=async()=>{P.debug("Starting flush operation");try{await this.traceBatchQueue.flush(),await this.spanBatchQueue.flush(),await this.traceFeedbackScoresBatchQueue.flush(),await this.spanFeedbackScoresBatchQueue.flush(),P.info("Successfully flushed all data to Opik");}catch(t){P.error("Error during flush operation:",{error:t instanceof Error?t.message:t});}};P.debug("Initializing OpikClient with config:",t),this.config=wi(t),this.api=new kr({apiKey:this.config.apiKey,environment:this.config.apiUrl,workspaceName:this.config.workspaceName}),this.spanBatchQueue=new ko(this.api),this.traceBatchQueue=new zo(this.api),this.spanFeedbackScoresBatchQueue=new So(this.api),this.traceFeedbackScoresBatchQueue=new xo(this.api);}};new async_hooks.AsyncLocalStorage;new te;var tc=new te,mi=class{constructor({client:t=tc}={}){this.traces=new Map;this.spans=new Map;this.getSpanInput=t=>{let r={},{attributes:o}=t;return Object.keys(o).forEach(n=>{if(n==="ai.prompt"||n==="gen_ai.request"){let p=ic(o[n]);p&&(r={...r,...p});}if(n.startsWith("ai.prompt.")){let p=n.replace("ai.prompt.","");r[p]=li(o[n]);}if(n.startsWith("gen_ai.request.")){let p=n.replace("gen_ai.request.","");r[p]=li(o[n]);}}),Object.keys(r).length>0||("ai.toolCall.name"in o&&(r.toolName=o["ai.toolCall.name"]),"ai.toolCall.args"in o&&(r.args=o["ai.toolCall.args"])),r};this.getSpanOutput=t=>{let{attributes:r}=t;return r["ai.response.text"]?{text:r["ai.response.text"]}:r["ai.toolCall.result"]?{result:r["ai.toolCall.result"]}:r["ai.response.toolCalls"]?{toolCalls:li(r["ai.response.toolCalls"])}:{}};this.getSpanMetadata=t=>{let{attributes:r}=t,o={};return r["gen_ai.response.model"]&&(o.model=r["gen_ai.response.model"]),r["gen_ai.system"]&&(o.system=r["gen_ai.system"]),o};this.getSpanUsage=t=>{let{attributes:r}=t,o={};return "ai.usage.promptTokens"in r&&(o.prompt_tokens=r["ai.usage.promptTokens"]),"gen_ai.usage.input_tokens"in r&&(o.prompt_tokens=r["gen_ai.usage.input_tokens"]),"ai.usage.completionTokens"in r&&(o.completion_tokens=r["ai.usage.completionTokens"]),"gen_ai.usage.output_tokens"in r&&(o.completion_tokens=r["gen_ai.usage.output_tokens"]),("prompt_tokens"in o||"completion_tokens"in o)&&(o.total_tokens=(o.prompt_tokens||0)+(o.completion_tokens||0)),o};this.processSpan=({otelSpan:t,parentSpan:r,trace:o})=>o.span({name:t.name,startTime:new Date(Ro(t.startTime)),endTime:new Date(Ro(t.endTime)),parentSpanId:r==null?void 0:r.data.id,input:this.getSpanInput(t),output:this.getSpanOutput(t),metadata:this.getSpanMetadata(t),usage:this.getSpanUsage(t),type:"llm"});this.shutdown=async()=>{await this.client.flush();};this.forceFlush=async()=>{await this.client.flush();};this.export=async(t,r)=>{let o=t.filter(p=>p.instrumentationLibrary.name==="ai"),a=t.length-o.length;if(a>0&&P.debug(`Ignored ${a} non-AI SDK spans`),o.length===0){P.debug("No AI SDK spans found"),r({code:0});return}let n=ac(o);P.debug("Exporting spans",o),Object.entries(n).forEach(([p,d])=>{var k,S;let[u,...h]=d,y=this.client.trace({startTime:new Date(Ro(u.startTime)),endTime:new Date(Ro(u.endTime)),name:(S=(k=u.attributes["ai.telemetry.metadata.traceName"])==null?void 0:k.toString())!=null?S:u.name,input:this.getSpanInput(u),output:this.getSpanOutput(u),metadata:this.getSpanMetadata(u),usage:this.getSpanUsage(u)});this.traces.set(p,y),h.forEach(D=>{var di;let ae=this.spans.get((di=D.parentSpanId)!=null?di:""),Rn=this.processSpan({parentSpan:ae,otelSpan:D,trace:y});this.spans.set(D.spanContext().spanId,Rn);});});try{await this.client.flush(),r({code:0});}catch(p){P.error("Error exporting spans",p),r({code:1,error:p instanceof Error?p:new Error("Unknown error")});}};this.client=t;}static getSettings(t){var o,a,n;let r={...t.metadata};return t.name&&(r.traceName=t.name),{isEnabled:(o=t.isEnabled)!=null?o:true,recordInputs:(a=t.recordInputs)!=null?a:true,recordOutputs:(n=t.recordOutputs)!=null?n:true,functionId:t.functionId,metadata:r}}};function ac(s){let t={};return s.forEach(r=>{let o=r.spanContext();t[o.traceId]||(t[o.traceId]=[]),t[o.traceId].push(r);}),Object.entries(t).forEach(([r,o])=>{t[r]=nc(o);}),t}function Ro(s){return s[0]*1e3+s[1]/1e6}function li(s){try{return JSON.parse(s)}catch{return s}}function ic(s){if(typeof s=="string")try{let t=JSON.parse(s);if(t!==null&&typeof t=="object"&&!Array.isArray(t))return t}catch{return}}function nc(s){let t=new Map,r=new Map;for(let p of s){let{spanId:d}=p.spanContext();t.set(d,p),p.parentSpanId&&(r.has(p.parentSpanId)||r.set(p.parentSpanId,[]),r.get(p.parentSpanId).push(p));}let o=s.filter(p=>!p.parentSpanId||!t.has(p.parentSpanId)),a=[],n=[...o];for(;n.length>0;){let p=n.shift();a.push(p);let d=p.spanContext().spanId,u=r.get(d)||[];n.push(...u);}return a}
4
+ exports.OpikExporter=mi;