opik 1.9.15 → 1.9.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,28 +1,28 @@
1
- 'use strict';var ansiEscapes=require('ansi-escapes'),tslog=require('tslog'),vm=require('fs'),$u=require('ini');require('dotenv/config');var Cw=require('qs'),uuid=require('uuid'),Af=require('fast-json-stable-stringify'),Tf=require('xxhash-wasm'),util=require('util'),If=require('mustache'),Nf=require('nunjucks'),dateFns=require('date-fns'),jestDiff=require('jest-diff'),Ff=require('fast-deep-equal'),async_hooks=require('async_hooks'),Pa=require('chalk'),$f=require('boxen'),Qf=require('ora'),ai$1=require('ai'),openai=require('@ai-sdk/openai'),anthropic=require('@ai-sdk/anthropic'),google=require('@ai-sdk/google'),bm=require('zod');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var vm__default=/*#__PURE__*/_interopDefault(vm);var $u__default=/*#__PURE__*/_interopDefault($u);var Cw__default=/*#__PURE__*/_interopDefault(Cw);var Af__default=/*#__PURE__*/_interopDefault(Af);var Tf__default=/*#__PURE__*/_interopDefault(Tf);var If__default=/*#__PURE__*/_interopDefault(If);var Nf__default=/*#__PURE__*/_interopDefault(Nf);var Ff__default=/*#__PURE__*/_interopDefault(Ff);var Pa__default=/*#__PURE__*/_interopDefault(Pa);var $f__default=/*#__PURE__*/_interopDefault($f);var Qf__default=/*#__PURE__*/_interopDefault(Qf);var bm__default=/*#__PURE__*/_interopDefault(bm);var Ou=Object.create;var ht=Object.defineProperty;var Wu=Object.getOwnPropertyDescriptor;var xm=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),nr=n=>{throw TypeError(n)};var Bu=(n,t,e)=>t in n?ht(n,t,{enumerable:true,configurable:true,writable:true,value:e}):n[t]=e;var Wa=(n,t)=>()=>(n&&(t=n(n=0)),t);var P=(n,t)=>{for(var e in t)ht(n,e,{get:t[e],enumerable:true});};var _m=n=>{var t;return [,,,Ou((t=void 0)!=null?t:null)]},Tm=["class","method","getter","setter","accessor","field","value","get","set"],ar=n=>n!==void 0&&typeof n!="function"?nr("Function expected"):n,Lu=(n,t,e,o,i)=>({kind:Tm[n],name:t,metadata:o,addInitializer:a=>e._?nr("Already initialized"):i.push(ar(a||null))}),Ba=(n,t)=>Bu(t,xm("metadata"),n[3]),Am=(n,t,e,o)=>{for(var i=0,a=n[t>>1],c=a&&a.length;i<c;i++)a[i].call(e);return o},Em=(n,t,e,o,i,a)=>{var d,u,g,y,k=t&7,S=false,x=false,_=2,M=Tm[k+5],J=n[_]||(n[_]=[]),q=((i=i.prototype),Wu(i,e));for(var Be=o.length-1;Be>=0;Be--)g=Lu(k,e,u={},n[3],J),(g.static=S,g.private=x,y=g.access={has:oe=>e in oe},(y.get=oe=>oe[e]),k>2),d=(0, o[Be])(q[M],g),u._=1,ar(d)&&(q[M]=d);return q&&ht(i,e,q),i};var sd={};P(sd,{Node18UniversalStreamWrapper:()=>nn});var nn,pd=Wa(()=>{nn=class n{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,e){var o;(o=this.events[t])==null||o.push(e);}off(t,e){var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(i=>i!==e);}pipe(t){return this.on("data",async e=>{if(t instanceof n)t._write(e);else if(t instanceof WritableStream){let o=t.getWriter();o.write(e).then(()=>o.releaseLock());}else t.write(e);}),this.on("end",async()=>{t instanceof n?t._end():t instanceof WritableStream?t.getWriter().close():t.end();}),this.on("error",async e=>{t instanceof n?t._error(e):t instanceof WritableStream?t.getWriter().abort(e):t.destroy(e);}),this._startReading(),t}pipeTo(t){return this.pipe(t)}unpipe(t){this.off("data",async e=>{if(t instanceof n)t._write(e);else if(t instanceof WritableStream){let o=t.getWriter();o.write(e).then(()=>o.releaseLock());}else t.write(e);}),this.off("end",async()=>{t instanceof n?t._end():t instanceof WritableStream?t.getWriter().close():t.end();}),this.off("error",async e=>{t instanceof n?t._error(e):t instanceof WritableStream?t.getWriter().abort(e):t.destroy(e);});}destroy(t){this.reader.cancel(t).then(()=>{this._emit("close");}).catch(e=>{this._emit("error",e);});}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:e}=await this.reader.read();if(!t)return e}setEncoding(t){this.encoding=t;}async text(){let t=[];for(;;){let{done:o,value:i}=await this.reader.read();if(o)break;i&&t.push(i);}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,e){if(this.events[t])for(let o of this.events[t]||[])o(e);}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();if(t){this._emit("end"),this._emit("close");break}e&&this._emit("data",e);}}catch(t){this._emit("error",t);}}[Symbol.asyncIterator](){return {next:async()=>{this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();return t?{done:true,value:void 0}:{done:false,value:e}},[Symbol.asyncIterator](){return this}}}};});var cd={};P(cd,{UndiciStreamWrapper:()=>sn});var sn,ld=Wa(()=>{sn=class n{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,e){var o;(o=this.events[t])==null||o.push(e);}off(t,e){var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(i=>i!==e);}pipe(t){return this.on("data",e=>{if(t instanceof n)t._write(e);else {let o=t.getWriter();o.write(e).then(()=>o.releaseLock());}}),this.on("end",()=>{t instanceof n?t._end():t.getWriter().close();}),this.on("error",e=>{t instanceof n?t._error(e):t.getWriter().abort(e);}),this._startReading(),t}pipeTo(t){return this.pipe(t)}unpipe(t){this.off("data",e=>{if(t instanceof n)t._write(e);else {let o=t.getWriter();o.write(e).then(()=>o.releaseLock());}}),this.off("end",()=>{t instanceof n?t._end():t.getWriter().close();}),this.off("error",e=>{t instanceof n?t._error(e):t.getWriter().abort(e);});}destroy(t){this.reader.cancel(t).then(()=>{this._emit("close");}).catch(e=>{this._emit("error",e);});}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:e}=await this.reader.read();if(!t)return e}setEncoding(t){this.encoding=t;}async text(){let t=[];for(;;){let{done:o,value:i}=await this.reader.read();if(o)break;i&&t.push(i);}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,e){if(this.events[t])for(let o of this.events[t]||[])o(e);}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();if(t){this._emit("end"),this._emit("close");break}e&&this._emit("data",e);}}catch(t){this._emit("error",t);}}[Symbol.asyncIterator](){return {next:async()=>{this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();return t?{done:true,value:void 0}:{done:false,value:e}},[Symbol.asyncIterator](){return this}}}};});var md={};P(md,{NodePre18StreamWrapper:()=>pn});var pn,dd=Wa(()=>{pn=class{constructor(t){this.readableStream=t;}on(t,e){this.readableStream.on(t,e);}off(t,e){this.readableStream.off(t,e);}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,e)=>{let o=this.readableStream.read();o?t(o):(this.readableStream.once("readable",()=>{let i=this.readableStream.read();t(i);}),this.readableStream.once("error",e));})}setEncoding(t){this.readableStream.setEncoding(t),this.encoding=t;}async text(){let t=[],e=new TextEncoder;this.readableStream.setEncoding(this.encoding||"utf-8");for await(let i of this.readableStream)t.push(e.encode(i));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 e=this.readableStream[Symbol.asyncIterator]();return {async next(){let{value:o,done:i}=await e.next();return {value:o,done:i}},[Symbol.asyncIterator](){return this}}}};});var Xu={SILLY:0,TRACE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,FATAL:6};function Rt(n,t=n){return ansiEscapes.link(t,n)}var z=new tslog.Logger({hideLogPositionForProduction:true,prettyLogTemplate:"{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}} {{logLevelName}} "}),Pm=n=>{z.settings.minLevel=Xu[n];},Gu=()=>{z.settings.minLevel=100;};Pm(process.env.OPIK_LOG_LEVEL||"INFO");var Qu="~/.opik.config",Va={apiKey:"",apiUrl:"https://www.comet.com/opik/api",projectName:"Default Project",workspaceName:"default",batchDelayMs:300,holdUntilFlush:false};function Cm(n){return Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0))}function Yu(){return Cm({apiKey:process.env.OPIK_API_KEY,apiUrl:process.env.OPIK_URL_OVERRIDE,projectName:process.env.OPIK_PROJECT_NAME,workspaceName:process.env.OPIK_WORKSPACE,batchDelayMs:process.env.OPIK_BATCH_DELAY_MS?Number(process.env.OPIK_BATCH_DELAY_MS):void 0,holdUntilFlush:process.env.OPIK_HOLD_UNTIL_FLUSH===void 0?void 0:["1","true","yes"].includes(String(process.env.OPIK_HOLD_UNTIL_FLUSH).toLowerCase())})}function Zu(){let n=process.env.OPIK_CONFIG_PATH||Qu;if(!vm__default.default.existsSync(n)){if(process.env.OPIK_CONFIG_PATH)throw new Error(`Config file not found at ${n}`);return {}}try{let t=$u__default.default.parse(vm__default.default.readFileSync(n,"utf8"));return t.opik?Cm({apiKey:t.opik.api_key,apiUrl:t.opik.url_override,projectName:t.opik.project_name,workspaceName:t.opik.workspace}):{}}catch(t){return z.error(`Error loading config file ${n}: ${t}`),{}}}function Im(n){let t=Yu(),e=Zu(),{headers:o,...i}=n||{};return qu({...Va,...e,...t,...i})}function qu(n){if(!n.apiUrl)throw new Error("OPIK_URL_OVERRIDE is not set");let t=eg(n.apiUrl);if(t&&!n.apiKey)throw new Error("OPIK_API_KEY is not set");if(t&&!n.workspaceName)throw new Error("OPIK_WORKSPACE is not set");return n}function eg(n){return new URL(n).hostname.endsWith("comet.com")}var X={};P(X,{AlertAlertType:()=>rg,AlertPublicAlertType:()=>cg,AlertTriggerConfigPublicType:()=>sg,AlertTriggerConfigType:()=>tg,AlertTriggerConfigWriteType:()=>ig,AlertTriggerEventType:()=>og,AlertTriggerPublicEventType:()=>pg,AlertTriggerWriteEventType:()=>ag,AlertWriteAlertType:()=>ng,AnnotationQueuePublicScope:()=>ug,AnnotationQueueScope:()=>mg,AnnotationQueueWriteScope:()=>dg,AssistantMessageRole:()=>Tg,AttachmentListRequestEntityType:()=>Um,BadRequestError:()=>T,CheckName:()=>Hg,CheckPublicName:()=>xw,CheckPublicResult:()=>_w,CheckResult:()=>Jg,ColumnCompareTypesItem:()=>jg,ColumnPublicTypesItem:()=>Bg,ColumnTypesItem:()=>Lg,CompleteMultipartUploadRequestEntityType:()=>gg,ConflictError:()=>L,DatasetItemCompareSource:()=>Ug,DatasetItemPublicSource:()=>Og,DatasetItemSource:()=>Pg,DatasetItemWriteSource:()=>tn,DatasetPublicVisibility:()=>Fg,DatasetUpdateVisibility:()=>Om,DatasetVisibility:()=>Eg,DatasetWriteVisibility:()=>Fm,DeleteAttachmentsRequestEntityType:()=>wg,DownloadAttachmentRequestEntityType:()=>Nm,ExperimentItemCompareTraceVisibilityMode:()=>Ng,ExperimentItemPublicTraceVisibilityMode:()=>Wg,ExperimentItemTraceVisibilityMode:()=>vg,ExperimentPublicStatus:()=>Yg,ExperimentPublicType:()=>Qg,ExperimentStatus:()=>Vg,ExperimentType:()=>an,ExperimentUpdateStatus:()=>Vm,ExperimentUpdateType:()=>Lm,ExperimentWriteStatus:()=>Bm,ExperimentWriteType:()=>Wm,FeedbackScoreBatchItemSource:()=>zw,FeedbackScoreBatchItemThreadSource:()=>Ew,FeedbackScoreCompareSource:()=>Mg,FeedbackScoreExperimentItemBulkWriteViewSource:()=>Xg,FeedbackScorePublicSource:()=>bw,FeedbackScoreSource:()=>Cg,FindFeedbackDefinitionsRequestType:()=>Hm,FindFeedbackScoreNames1RequestType:()=>ed,ForbiddenError:()=>$,GetSpanStatsRequestType:()=>rd,GetSpansByProjectRequestType:()=>Zm,GetWebhookExamplesRequestAlertType:()=>jm,GuardrailName:()=>Zg,GuardrailResult:()=>qg,GuardrailWriteName:()=>ew,GuardrailWriteResult:()=>rw,LlmAsJudgeMessagePublicRole:()=>zg,LlmAsJudgeMessageRole:()=>fg,LlmAsJudgeMessageWriteRole:()=>bg,LlmAsJudgeOutputSchemaPublicType:()=>Sg,LlmAsJudgeOutputSchemaType:()=>hg,LlmAsJudgeOutputSchemaWriteType:()=>yg,LogItemLevel:()=>_g,ManualEvaluationRequestEntityType:()=>iw,NotFoundError:()=>A,NotImplementedError:()=>sr,OptimizationPublicStatus:()=>sw,OptimizationStatus:()=>aw,OptimizationUpdateStatus:()=>Km,OptimizationWriteStatus:()=>nw,ProjectDetailedVisibility:()=>uw,ProjectMetricRequestPublicInterval:()=>Qm,ProjectMetricRequestPublicMetricType:()=>$m,ProjectMetricResponsePublicInterval:()=>mw,ProjectMetricResponsePublicMetricType:()=>lw,ProjectPublicVisibility:()=>cw,ProjectUpdateVisibility:()=>Gm,ProjectVisibility:()=>pw,ProjectWriteVisibility:()=>Xm,PromptType:()=>gw,PromptVersionDetailType:()=>fw,PromptVersionPublicType:()=>hw,PromptVersionType:()=>ww,PromptWriteType:()=>Ym,ProviderApiKeyProvider:()=>tw,ProviderApiKeyPublicProvider:()=>ow,ProviderApiKeyWriteProvider:()=>Jm,ResponseFormatType:()=>Ag,SpanExperimentItemBulkWriteViewType:()=>Gg,SpanFilterPublicOperator:()=>Sw,SpanPublicType:()=>yw,SpanSearchStreamRequestPublicType:()=>od,SpanType:()=>we,SpanUpdateType:()=>qm,SpanWriteType:()=>Rw,StartMultipartUploadRequestEntityType:()=>Mm,TraceFilterOperator:()=>Rg,TraceFilterPublicOperator:()=>xg,TraceFilterWriteOperator:()=>kg,TracePublicVisibilityMode:()=>Tw,TraceThreadFilterOperator:()=>Pw,TraceThreadFilterPublicOperator:()=>dw,TraceThreadStatus:()=>Aw,TraceVisibilityMode:()=>Kg,UnauthorizedError:()=>K,UnprocessableEntityError:()=>F,UploadAttachmentRequestEntityType:()=>Dm,ValueEntryCompareSource:()=>Dg,ValueEntryExperimentItemBulkWriteViewSource:()=>$g,ValueEntryPublicSource:()=>kw,ValueEntrySource:()=>Ig,WebhookTestResultStatus:()=>lg,alerts:()=>bt,annotationQueues:()=>Ja,attachments:()=>yt,automationRuleEvaluators:()=>Xa,chatCompletions:()=>Ga,check:()=>Ka,datasets:()=>kt,experiments:()=>zt,feedbackDefinitions:()=>St,guardrails:()=>$a,llmProviderKey:()=>xt,manualEvaluation:()=>Qa,openTelemetryIngestion:()=>Ya,optimizations:()=>_t,projects:()=>Tt,prompts:()=>At,redirect:()=>on,serviceToggles:()=>Za,spans:()=>Et,systemUsage:()=>Ha,traces:()=>qa,welcomeWizard:()=>en,workspaces:()=>rn});var bt={};P(bt,{GetWebhookExamplesRequestAlertType:()=>jm});var jm={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var yt={};P(yt,{AttachmentListRequestEntityType:()=>Um,DownloadAttachmentRequestEntityType:()=>Nm,StartMultipartUploadRequestEntityType:()=>Mm,UploadAttachmentRequestEntityType:()=>Dm});var Um={Trace:"trace",Span:"span"};var Nm={Trace:"trace",Span:"span"};var Mm={Trace:"trace",Span:"span"};var Dm={Trace:"trace",Span:"span"};var kt={};P(kt,{DatasetUpdateVisibility:()=>Om,DatasetWriteVisibility:()=>Fm});var Fm={Private:"private",Public:"public"};var Om={Private:"private",Public:"public"};var zt={};P(zt,{ExperimentUpdateStatus:()=>Vm,ExperimentUpdateType:()=>Lm,ExperimentWriteStatus:()=>Bm,ExperimentWriteType:()=>Wm});var Wm={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Bm={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Lm={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Vm={Running:"running",Completed:"completed",Cancelled:"cancelled"};var St={};P(St,{FindFeedbackDefinitionsRequestType:()=>Hm});var Hm={Numerical:"numerical",Categorical:"categorical",Boolean:"boolean"};var xt={};P(xt,{ProviderApiKeyWriteProvider:()=>Jm});var Jm={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var _t={};P(_t,{OptimizationUpdateStatus:()=>Km});var Km={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Tt={};P(Tt,{ProjectMetricRequestPublicInterval:()=>Qm,ProjectMetricRequestPublicMetricType:()=>$m,ProjectUpdateVisibility:()=>Gm,ProjectWriteVisibility:()=>Xm});var Xm={Private:"private",Public:"public"};var Gm={Private:"private",Public:"public"};var $m={FeedbackScores:"FEEDBACK_SCORES",TraceCount:"TRACE_COUNT",TokenUsage:"TOKEN_USAGE",Duration:"DURATION",Cost:"COST",GuardrailsFailedCount:"GUARDRAILS_FAILED_COUNT",ThreadCount:"THREAD_COUNT",ThreadDuration:"THREAD_DURATION",ThreadFeedbackScores:"THREAD_FEEDBACK_SCORES"};var Qm={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var At={};P(At,{PromptWriteType:()=>Ym});var Ym={Mustache:"mustache",Jinja2:"jinja2"};var Et={};P(Et,{FindFeedbackScoreNames1RequestType:()=>ed,GetSpanStatsRequestType:()=>rd,GetSpansByProjectRequestType:()=>Zm,SpanSearchStreamRequestPublicType:()=>od,SpanUpdateType:()=>qm});var Zm={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var qm={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var ed={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var rd={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var od={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Ha={};var Ja={};var Ka={};var Xa={};var Ga={};var $a={};var Qa={};var Ya={};var Za={};var qa={};var en={};var rn={};var on={};var rg={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var og={TraceErrors:"trace:errors",TraceFeedbackScore:"trace:feedback_score",TraceThreadFeedbackScore:"trace_thread:feedback_score",PromptCreated:"prompt:created",PromptCommitted:"prompt:committed",TraceGuardrailsTriggered:"trace:guardrails_triggered",PromptDeleted:"prompt:deleted",ExperimentFinished:"experiment:finished",TraceCost:"trace:cost",TraceLatency:"trace:latency"};var tg={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score",ThresholdCost:"threshold:cost",ThresholdLatency:"threshold:latency"};var ig={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score",ThresholdCost:"threshold:cost",ThresholdLatency:"threshold:latency"};var ag={TraceErrors:"trace:errors",TraceFeedbackScore:"trace:feedback_score",TraceThreadFeedbackScore:"trace_thread:feedback_score",PromptCreated:"prompt:created",PromptCommitted:"prompt:committed",TraceGuardrailsTriggered:"trace:guardrails_triggered",PromptDeleted:"prompt:deleted",ExperimentFinished:"experiment:finished",TraceCost:"trace:cost",TraceLatency:"trace:latency"};var ng={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var sg={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score",ThresholdCost:"threshold:cost",ThresholdLatency:"threshold:latency"};var pg={TraceErrors:"trace:errors",TraceFeedbackScore:"trace:feedback_score",TraceThreadFeedbackScore:"trace_thread:feedback_score",PromptCreated:"prompt:created",PromptCommitted:"prompt:committed",TraceGuardrailsTriggered:"trace:guardrails_triggered",PromptDeleted:"prompt:deleted",ExperimentFinished:"experiment:finished",TraceCost:"trace:cost",TraceLatency:"trace:latency"};var cg={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var lg={Success:"success",Failure:"failure"};var mg={Trace:"trace",Thread:"thread"};var dg={Trace:"trace",Thread:"thread"};var ug={Trace:"trace",Thread:"thread"};var gg={Trace:"trace",Span:"span"};var wg={Trace:"trace",Span:"span"};var fg={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var hg={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var Rg={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var bg={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var yg={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var kg={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var zg={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var Sg={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var xg={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var _g={Info:"INFO",Warn:"WARN",Error:"ERROR",Debug:"DEBUG",Trace:"TRACE"};var Tg={System:"system",User:"user",Assistant:"assistant",Tool:"tool",Function:"function"};var Ag={Text:"text",JsonObject:"json_object",JsonSchema:"json_schema"};var Eg={Private:"private",Public:"public"};var Pg={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var vg={Default:"default",Hidden:"hidden"};var Cg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Ig={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var tn={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var jg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var Ug={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Ng={Default:"default",Hidden:"hidden"};var Mg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Dg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Fg={Private:"private",Public:"public"};var Og={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Wg={Default:"default",Hidden:"hidden"};var Bg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var Lg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var an={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Vg={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Hg={Topic:"TOPIC",Pii:"PII"};var Jg={Passed:"passed",Failed:"failed"};var we={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Kg={Default:"default",Hidden:"hidden"};var Xg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Gg={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var $g={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Qg={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Yg={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Zg={Topic:"TOPIC",Pii:"PII"};var qg={Passed:"passed",Failed:"failed"};var ew={Topic:"TOPIC",Pii:"PII"};var rw={Passed:"passed",Failed:"failed"};var ow={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var tw={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var iw={Trace:"trace",Thread:"thread"};var aw={Running:"running",Completed:"completed",Cancelled:"cancelled"};var nw={Running:"running",Completed:"completed",Cancelled:"cancelled"};var sw={Running:"running",Completed:"completed",Cancelled:"cancelled"};var pw={Private:"private",Public:"public"};var cw={Private:"private",Public:"public"};var lw={FeedbackScores:"FEEDBACK_SCORES",TraceCount:"TRACE_COUNT",TokenUsage:"TOKEN_USAGE",Duration:"DURATION",Cost:"COST",GuardrailsFailedCount:"GUARDRAILS_FAILED_COUNT",ThreadCount:"THREAD_COUNT",ThreadDuration:"THREAD_DURATION",ThreadFeedbackScores:"THREAD_FEEDBACK_SCORES"};var mw={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var dw={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var uw={Private:"private",Public:"public"};var gw={Mustache:"mustache",Jinja2:"jinja2"};var ww={Mustache:"mustache",Jinja2:"jinja2"};var fw={Mustache:"mustache",Jinja2:"jinja2"};var hw={Mustache:"mustache",Jinja2:"jinja2"};var Rw={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var bw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var yw={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var kw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var zw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Sw={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var xw={Topic:"TOPIC",Pii:"PII"};var _w={Passed:"passed",Failed:"failed"};var Tw={Default:"default",Hidden:"hidden"};var Aw={Active:"active",Inactive:"inactive"};var Ew={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Pw={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var Le=(n,t,e)=>JSON.stringify(n,t,e);var p=class n extends Error{constructor({message:t,statusCode:e,body:o,rawResponse:i}){super(vw({message:t,statusCode:e,body:o})),Object.setPrototypeOf(this,n.prototype),this.statusCode=e,this.body=o,this.rawResponse=i;}};function vw({message:n,statusCode:t,body:e}){let o=[];return n!=null&&o.push(n),t!=null&&o.push(`Status code: ${t.toString()}`),e!=null&&o.push(`Body: ${Le(e,void 0,2)}`),o.join(`
2
- `)}var w=class n extends Error{constructor(t){super(t),Object.setPrototypeOf(this,n.prototype);}};var T=class n extends p{constructor(t,e){super({message:"BadRequestError",statusCode:400,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var L=class n extends p{constructor(t,e){super({message:"ConflictError",statusCode:409,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var F=class n extends p{constructor(t,e){super({message:"UnprocessableEntityError",statusCode:422,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var A=class n extends p{constructor(t,e){super({message:"NotFoundError",statusCode:404,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var K=class n extends p{constructor(t,e){super({message:"UnauthorizedError",statusCode:401,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var $=class n extends p{constructor(t,e){super({message:"ForbiddenError",statusCode:403,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var sr=class n extends p{constructor(t,e){super({message:"NotImplementedError",statusCode:501,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var h={Default:"http://localhost:5173/api"};var pr;typeof globalThis.Headers!="undefined"?pr=globalThis.Headers:pr=class td{constructor(t){if(this.headers=new Map,t)if(t instanceof td)t.forEach((e,o)=>this.append(o,e));else if(Array.isArray(t))for(let[e,o]of t)if(typeof e=="string"&&typeof o=="string")this.append(e,o);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[e,o]of Object.entries(t))if(typeof o=="string")this.append(e,o);else throw new TypeError("Header values must be strings")}append(t,e){let o=t.toLowerCase(),i=this.headers.get(o)||[];this.headers.set(o,[...i,e]);}delete(t){let e=t.toLowerCase();this.headers.delete(e);}get(t){let e=t.toLowerCase(),o=this.headers.get(e);return o?o.join(", "):null}has(t){let e=t.toLowerCase();return this.headers.has(e)}set(t,e){let o=t.toLowerCase();this.headers.set(o,[e]);}forEach(t,e){let o=e?t.bind(e):t;this.headers.forEach((i,a)=>o(i.join(", "),a,this));}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[t,e]of this.headers.entries())yield [t,e.join(", ")];}*keys(){yield*this.headers.keys();}*values(){for(let t of this.headers.values())yield t.join(", ");}[Symbol.iterator](){return this.entries()}};var Pt={headers:new pr,redirected:false,status:499,statusText:"Client Closed Request",type:"error",url:""},vt={headers:new pr,redirected:false,status:0,statusText:"Unknown Error",type:"error",url:""};function Ct(n){return {headers:n.headers,redirected:n.redirected,status:n.status,statusText:n.statusText,type:n.type,url:n.url}}function id(n,t){return Object.keys(t!=null?t:{}).length>0?`${n}?${Cw__default.default.stringify(t,{arrayFormat:"repeat"})}`:n}var m=Iw();function Iw(){var u,g,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"&&(((g=self.constructor)==null?void 0:g.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 ad(){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 nd({body:n,type:t}){return t.includes("json")?Le(n):n}async function ud(n){return m.type==="node"&&m.parsedVersion!=null&&m.parsedVersion>=18?new(await Promise.resolve().then(()=>(pd(),sd))).Node18UniversalStreamWrapper(n):m.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(ld(),cd))).UndiciStreamWrapper(n):new(await Promise.resolve().then(()=>(dd(),md))).NodePre18StreamWrapper(n)}async function gd(n,t){if(n.body!=null&&t==="blob")return await n.blob();if(n.body!=null&&t==="arrayBuffer")return await n.arrayBuffer();if(n.body!=null&&t==="sse")return n.body;if(n.body!=null&&t==="streaming")return ud(n.body);if(n.body!=null&&t==="text")return await n.text();{let e=await n.text();if(e.length>0)try{return JSON.parse(e)}catch{return {ok:false,error:{reason:"non-json",statusCode:n.status,rawBody:e}}}else return}}var jw="timeout";function wd(n){let t=new AbortController,e=setTimeout(()=>t.abort(jw),n);return {signal:t.signal,abortId:e}}function fd(...n){let t=n.length===1&&Array.isArray(n[0])?n[0]:n,e=new AbortController;for(let o of t){if(o.aborted){e.abort(o==null?void 0:o.reason);break}o.addEventListener("abort",()=>e.abort(o==null?void 0:o.reason),{signal:e.signal});}return e.signal}var hd=async(n,t,e,o,i,a,c,d,u)=>{let g=[],y;if(a!=null){let{signal:x,abortId:_}=wd(a);y=_,g.push(x);}c!=null&&g.push(c);let k=fd(g),S=await n(t,{method:e,headers:o,body:i,signal:k,credentials:d?"include":void 0,duplex:u});return y!=null&&clearTimeout(y),S};function Uw(n){let t=1+(Math.random()*2-1)*.2;return n*t}async function Rd(n,t=2){let e=await n();for(let o=0;o<t&&([408,429].includes(e.status)||e.status>=500);++o){let i=Math.min(1e3*Math.pow(2,o),6e4),a=Uw(i);await new Promise(c=>setTimeout(c,a)),e=await n();}return e}async function Nw(n){let t={};if(n.body!==void 0&&n.contentType!=null&&(t["Content-Type"]=n.contentType),n.headers!=null)for(let[a,c]of Object.entries(n.headers))c!=null&&(t[a]=c);let e=id(n.url,n.queryParameters),o=await nd({body:n.body,type:n.requestType==="json"?"json":"other"}),i=await ad();try{let a=await Rd(async()=>hd(i,e,n.method,t,o,n.timeoutMs,n.abortSignal,n.withCredentials,n.duplex),n.maxRetries),c=await gd(a,n.responseType);return a.status>=200&&a.status<400?{ok:!0,body:c,headers:a.headers,rawResponse:Ct(a)}:{ok:!1,error:{reason:"status-code",statusCode:a.status,body:c},rawResponse:Ct(a)}}catch(a){return n.abortSignal!=null&&n.abortSignal.aborted?{ok:false,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:Pt}:a instanceof Error&&a.name==="AbortError"?{ok:false,error:{reason:"timeout"},rawResponse:Pt}:a instanceof Error?{ok:false,error:{reason:"unknown",errorMessage:a.message},rawResponse:vt}:{ok:false,error:{reason:"unknown",errorMessage:Le(a)},rawResponse:vt}}}var R=Nw;var s={get:async n=>typeof n=="function"?n():n};var f=class n extends Promise{constructor(t){super(e=>{e(void 0);}),this.innerPromise=t;}static fromFunction(t,...e){return new n(t(...e))}static interceptFunction(t){return (...e)=>n.fromPromise(t(...e))}static fromPromise(t){return new n(t)}static fromExecutor(t){let e=new Promise(t);return new n(e)}static fromResult(t){let e=Promise.resolve(t);return new n(e)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:t})=>t)),this.unwrappedPromise}then(t,e){return this.unwrap().then(t,e)}catch(t){return this.unwrap().catch(t)}finally(t){return this.unwrap().finally(t)}async withRawResponse(){return await this.innerPromise}};var r={};P(r,{JsonError:()=>Ve,ParseError:()=>He,any:()=>jd,bigint:()=>yd,boolean:()=>Ud,booleanLiteral:()=>Id,date:()=>kd,discriminant:()=>Vd,enum_:()=>jt,getObjectLikeUtils:()=>le,getObjectUtils:()=>Ie,getSchemaUtils:()=>C,isProperty:()=>xe,lazy:()=>zd,lazyObject:()=>Pd,list:()=>Nt,number:()=>Nd,object:()=>Ut,objectWithoutOptionalProperties:()=>Ed,optional:()=>cn,property:()=>xd,record:()=>Od,set:()=>Wd,string:()=>Md,stringLiteral:()=>Cd,transform:()=>ln,undiscriminatedUnion:()=>Ld,union:()=>Jd,unknown:()=>Dd,withParsedProperties:()=>dn});var E={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 v(n,t){return `Expected ${t}. Received ${Mw(n)}.`}function Mw(n){if(Array.isArray(n))return "list";if(n===null)return "null";if(n instanceof BigInt)return "BigInt";switch(typeof n){case "string":return `"${n}"`;case "bigint":case "number":case "boolean":case "undefined":return `${n}`}return typeof n}function G(n){return {...n,json:bd(n.json),parse:bd(n.parse)}}function bd(n){return (t,e)=>{let o=n(t,e),{skipValidation:i=false}=e!=null?e:{};return !o.ok&&i?(console.warn(["Failed to validate.",...o.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
3
- `)),{ok:true,value:t}):o}}function It(n){return n.path.length===0?n.message:`${n.path.join(" -> ")}: ${n.message}`}var Ve=class n extends Error{constructor(e){super(e.map(It).join("; "));this.errors=e;Object.setPrototypeOf(this,n.prototype);}};var He=class n extends Error{constructor(e){super(e.map(It).join("; "));this.errors=e;Object.setPrototypeOf(this,n.prototype);}};function C(n){return {nullable:()=>Dw(n),optional:()=>cn(n),optionalNullable:()=>Fw(n),transform:t=>ln(n,t),parseOrThrow:(t,e)=>{let o=n.parse(t,e);if(o.ok)return o.value;throw new He(o.errors)},jsonOrThrow:(t,e)=>{let o=n.json(t,e);if(o.ok)return o.value;throw new Ve(o.errors)}}}function Dw(n){let t={parse:(e,o)=>e==null?{ok:true,value:null}:n.parse(e,o),json:(e,o)=>e==null?{ok:true,value:null}:n.json(e,o),getType:()=>E.NULLABLE};return {...t,...C(t)}}function cn(n){let t={parse:(e,o)=>e==null?{ok:true,value:void 0}:n.parse(e,o),json:(e,o)=>o!=null&&o.omitUndefined&&e===void 0?{ok:true,value:void 0}:e==null?{ok:true,value:null}:n.json(e,o),getType:()=>E.OPTIONAL};return {...t,...C(t)}}function Fw(n){let t={parse:(e,o)=>e===void 0?{ok:true,value:void 0}:e===null?{ok:true,value:null}:n.parse(e,o),json:(e,o)=>e===void 0?{ok:true,value:void 0}:e===null?{ok:true,value:null}:n.json(e,o),getType:()=>E.OPTIONAL_NULLABLE};return {...t,...C(t)}}function ln(n,t){let e={parse:(o,i)=>{let a=n.parse(o,i);return a.ok?{ok:true,value:t.transform(a.value)}:a},json:(o,i)=>{let a=t.untransform(o);return n.json(a,i)},getType:()=>n.getType()};return {...e,...C(e)}}function yd(){let n={parse:(t,{breadcrumbsPrefix:e=[]}={})=>typeof t=="bigint"?{ok:true,value:t}:typeof t=="number"?{ok:true,value:BigInt(t)}:{ok:false,errors:[{path:e,message:v(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:e=[]}={})=>typeof t!="bigint"?{ok:false,errors:[{path:e,message:v(t,"bigint")}]}:{ok:true,value:t},getType:()=>E.BIGINT};return {...G(n),...C(n)}}var Ow=/^([+-]?\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 kd(){let n={parse:(t,{breadcrumbsPrefix:e=[]}={})=>typeof t!="string"?{ok:false,errors:[{path:e,message:v(t,"string")}]}:Ow.test(t)?{ok:true,value:new Date(t)}:{ok:false,errors:[{path:e,message:v(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:e=[]}={})=>t instanceof Date?{ok:true,value:t.toISOString()}:{ok:false,errors:[{path:e,message:v(t,"Date object")}]},getType:()=>E.DATE};return {...G(n),...C(n)}}function Q(n,t){return ()=>{let e={parse:t,json:t,getType:()=>n};return {...G(e),...C(e)}}}function jt(n){let t=new Set(n);return Q(E.ENUM,(o,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof o!="string"?{ok:false,errors:[{path:a,message:v(o,"string")}]}:!t.has(o)&&!i?{ok:false,errors:[{path:a,message:v(o,"enum")}]}:{ok:true,value:o})()}function zd(n){let t=mn(n);return {...t,...C(t)}}function mn(n){return {parse:(t,e)=>Je(n).parse(t,e),json:(t,e)=>Je(n).json(t,e),getType:()=>Je(n).getType()}}function Je(n){let t=n;return t.__zurg_memoized==null&&(t.__zurg_memoized=n()),t.__zurg_memoized}function cr(n){return Object.entries(n)}function lr(n,t){let e=new Set(t);return Object.entries(n).reduce((o,[i,a])=>(e.has(i)&&(o[i]=a),o),{})}function Se(n){if(typeof n!="object"||n===null)return false;if(Object.getPrototypeOf(n)===null)return true;let t=n;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(n)===t}function mr(n){return Object.keys(n)}function Sd(n,t){let e=[],o=[];for(let i of n)t(i)?e.push(i):o.push(i);return [e,o]}function le(n){return {withParsedProperties:t=>dn(n,t)}}function dn(n,t){let e={parse:(o,i)=>{let a=n.parse(o,i);if(!a.ok)return a;let c=Object.entries(t).reduce((d,[u,g])=>({...d,[u]:typeof g=="function"?g(a.value):g}),{});return {ok:true,value:{...a.value,...c}}},json:(o,i)=>{var d;if(!Se(o))return {ok:false,errors:[{path:(d=i==null?void 0:i.breadcrumbsPrefix)!=null?d:[],message:v(o,"object")}]};let a=new Set(Object.keys(t)),c=lr(o,Object.keys(o).filter(u=>!a.has(u)));return n.json(c,i)},getType:()=>n.getType()};return {...e,...C(e),...le(e)}}function xd(n,t){return {rawKey:n,valueSchema:t,isProperty:true}}function xe(n){return n.isProperty}function Ut(n){let t={_getRawProperties:()=>Object.entries(n).map(([e,o])=>xe(o)?o.rawKey:e),_getParsedProperties:()=>mr(n),parse:(e,o)=>{let i={},a=[];for(let[c,d]of cr(n)){let u=xe(d)?d.rawKey:c,g=xe(d)?d.valueSchema:d,y={rawKey:u,parsedKey:c,valueSchema:g};i[u]=y,Ad(g)&&a.push(u);}return _d({value:e,requiredKeys:a,getProperty:c=>{let d=i[c];if(d!=null)return {transformedKey:d.parsedKey,transform:u=>{var g;return d.valueSchema.parse(u,{...o,breadcrumbsPrefix:[...(g=o==null?void 0:o.breadcrumbsPrefix)!=null?g:[],c]})}}},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:(e,o)=>{let i=[];for(let[a,c]of cr(n)){let d=xe(c)?c.valueSchema:c;Ad(d)&&i.push(a);}return _d({value:e,requiredKeys:i,getProperty:a=>{let c=n[a];if(c!=null)return xe(c)?{transformedKey:c.rawKey,transform:d=>{var u;return c.valueSchema.json(d,{...o,breadcrumbsPrefix:[...(u=o==null?void 0:o.breadcrumbsPrefix)!=null?u:[],a]})}}:{transformedKey:a,transform:d=>{var u;return c.json(d,{...o,breadcrumbsPrefix:[...(u=o==null?void 0:o.breadcrumbsPrefix)!=null?u:[],a]})}}},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:()=>E.OBJECT};return {...G(t),...C(t),...le(t),...Ie(t)}}function _d({value:n,requiredKeys:t,getProperty:e,unrecognizedObjectKeys:o="fail",skipValidation:i=false,breadcrumbsPrefix:a=[]}){if(!Se(n))return {ok:false,errors:[{path:a,message:v(n,"object")}]};let c=new Set(t),d=[],u={};for(let[g,y]of Object.entries(n)){let k=e(g);if(k!=null){c.delete(g);let S=k.transform(y);S.ok?u[k.transformedKey]=S.value:(u[g]=y,d.push(...S.errors));}else switch(o){case "fail":d.push({path:[...a,g],message:`Unexpected key "${g}"`});break;case "strip":break;case "passthrough":u[g]=y;break}}return d.push(...t.filter(g=>c.has(g)).map(g=>({path:a,message:`Missing required key "${g}"`}))),d.length===0||i?{ok:true,value:u}:{ok:false,errors:d}}function Ie(n){return {extend:t=>{let e={_getParsedProperties:()=>[...n._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...n._getRawProperties(),...t._getRawProperties()],parse:(o,i)=>Td({extensionKeys:t._getRawProperties(),value:o,transformBase:a=>n.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(o,i)=>Td({extensionKeys:t._getParsedProperties(),value:o,transformBase:a=>n.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>E.OBJECT};return {...e,...C(e),...le(e),...Ie(e)}},passthrough:()=>{let t={_getParsedProperties:()=>n._getParsedProperties(),_getRawProperties:()=>n._getRawProperties(),parse:(e,o)=>{let i=n.parse(e,{...o,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:true,value:{...e,...i.value}}:i},json:(e,o)=>{let i=n.json(e,{...o,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:true,value:{...e,...i.value}}:i},getType:()=>E.OBJECT};return {...t,...C(t),...le(t),...Ie(t)}}}}function Td({extensionKeys:n,value:t,transformBase:e,transformExtension:o}){let i=new Set(n),[a,c]=Sd(mr(t),g=>i.has(g)),d=e(lr(t,c)),u=o(lr(t,a));return d.ok&&u.ok?{ok:true,value:{...d.value,...u.value}}:{ok:false,errors:[...d.ok?[]:d.errors,...u.ok?[]:u.errors]}}function Ad(n){return !Ww(n)}function Ww(n){switch(n.getType()){case E.ANY:case E.UNKNOWN:case E.OPTIONAL:case E.OPTIONAL_NULLABLE:return true;default:return false}}function Ed(n){return Ut(n)}function Pd(n){let t={...mn(n),_getRawProperties:()=>Je(n)._getRawProperties(),_getParsedProperties:()=>Je(n)._getParsedProperties()};return {...t,...C(t),...le(t),...Ie(t)}}function Nt(n){let t={parse:(e,o)=>vd(e,(i,a)=>{var c;return n.parse(i,{...o,breadcrumbsPrefix:[...(c=o==null?void 0:o.breadcrumbsPrefix)!=null?c:[],`[${a}]`]})}),json:(e,o)=>vd(e,(i,a)=>{var c;return n.json(i,{...o,breadcrumbsPrefix:[...(c=o==null?void 0:o.breadcrumbsPrefix)!=null?c:[],`[${a}]`]})}),getType:()=>E.LIST};return {...G(t),...C(t)}}function vd(n,t){return Array.isArray(n)?n.map((o,i)=>t(o,i)).reduce((o,i)=>{if(o.ok&&i.ok)return {ok:true,value:[...o.value,i.value]};let a=[];return o.ok||a.push(...o.errors),i.ok||a.push(...i.errors),{ok:false,errors:a}},{ok:true,value:[]}):{ok:false,errors:[{message:v(n,"list"),path:[]}]}}function Cd(n){return Q(E.STRING_LITERAL,(e,{breadcrumbsPrefix:o=[]}={})=>e===n?{ok:true,value:n}:{ok:false,errors:[{path:o,message:v(e,`"${n}"`)}]})()}function Id(n){return Q(E.BOOLEAN_LITERAL,(e,{breadcrumbsPrefix:o=[]}={})=>e===n?{ok:true,value:n}:{ok:false,errors:[{path:o,message:v(e,`${n.toString()}`)}]})()}var jd=Q(E.ANY,n=>({ok:true,value:n}));var Ud=Q(E.BOOLEAN,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="boolean"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:v(n,"boolean")}]});var Nd=Q(E.NUMBER,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="number"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:v(n,"number")}]});var Md=Q(E.STRING,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="string"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:v(n,"string")}]});var Dd=Q(E.UNKNOWN,n=>({ok:true,value:n}));function Od(n,t){let e={parse:(o,i)=>Fd({value:o,isKeyNumeric:n.getType()===E.NUMBER,transformKey:a=>{var c;return n.parse(a,{...i,breadcrumbsPrefix:[...(c=i==null?void 0:i.breadcrumbsPrefix)!=null?c:[],`${a} (key)`]})},transformValue:(a,c)=>{var d;return t.parse(a,{...i,breadcrumbsPrefix:[...(d=i==null?void 0:i.breadcrumbsPrefix)!=null?d:[],`${c}`]})},breadcrumbsPrefix:i==null?void 0:i.breadcrumbsPrefix}),json:(o,i)=>Fd({value:o,isKeyNumeric:n.getType()===E.NUMBER,transformKey:a=>{var c;return n.json(a,{...i,breadcrumbsPrefix:[...(c=i==null?void 0:i.breadcrumbsPrefix)!=null?c:[],`${a} (key)`]})},transformValue:(a,c)=>{var d;return t.json(a,{...i,breadcrumbsPrefix:[...(d=i==null?void 0:i.breadcrumbsPrefix)!=null?d:[],`${c}`]})},breadcrumbsPrefix:i==null?void 0:i.breadcrumbsPrefix}),getType:()=>E.RECORD};return {...G(e),...C(e)}}function Fd({value:n,isKeyNumeric:t,transformKey:e,transformValue:o,breadcrumbsPrefix:i=[]}){return Se(n)?cr(n).reduce((a,[c,d])=>{if(d===void 0)return a;let u=a,g=c;if(t){let x=c.length>0?Number(c):NaN;isNaN(x)||(g=x);}let y=e(g),k=o(d,g);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:i,message:v(n,"object")}]}}function Wd(n){let t=Nt(n),e={parse:(o,i)=>{let a=t.parse(o,i);return a.ok?{ok:true,value:new Set(a.value)}:a},json:(o,i)=>{var c;return o instanceof Set?t.json([...o],i):{ok:false,errors:[{path:(c=i==null?void 0:i.breadcrumbsPrefix)!=null?c:[],message:v(o,"Set")}]}},getType:()=>E.SET};return {...G(e),...C(e)}}function Ld(n){let t={parse:(e,o)=>Bd((i,a)=>i.parse(e,a),n,o),json:(e,o)=>Bd((i,a)=>i.json(e,a),n,o),getType:()=>E.UNDISCRIMINATED_UNION};return {...G(t),...C(t)}}function Bd(n,t,e){let o=[];for(let[i,a]of t.entries()){let c=n(a,{...e,skipValidation:false});if(c.ok)return c;for(let d of c.errors)o.push({path:d.path,message:`[Variant ${i}] ${d.message}`});}return {ok:false,errors:o}}function Vd(n,t){return {parsedDiscriminant:n,rawDiscriminant:t}}function Jd(n,t){let e=typeof n=="string"?n:n.rawDiscriminant,o=typeof n=="string"?n:n.parsedDiscriminant,i=jt(mr(t)),a={parse:(c,d)=>Hd({value:c,discriminant:e,transformedDiscriminant:o,transformDiscriminantValue:u=>{var g;return i.parse(u,{allowUnrecognizedEnumValues:d==null?void 0:d.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(g=d==null?void 0:d.breadcrumbsPrefix)!=null?g:[],e]})},getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:d==null?void 0:d.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,g)=>g.parse(u,d),breadcrumbsPrefix:d==null?void 0:d.breadcrumbsPrefix}),json:(c,d)=>Hd({value:c,discriminant:o,transformedDiscriminant:e,transformDiscriminantValue:u=>{var g;return i.json(u,{allowUnrecognizedEnumValues:d==null?void 0:d.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(g=d==null?void 0:d.breadcrumbsPrefix)!=null?g:[],o]})},getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:d==null?void 0:d.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,g)=>g.json(u,d),breadcrumbsPrefix:d==null?void 0:d.breadcrumbsPrefix}),getType:()=>E.UNION};return {...G(a),...C(a),...le(a)}}function Hd({value:n,discriminant:t,transformedDiscriminant:e,transformDiscriminantValue:o,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=false,transformAdditionalProperties:c,breadcrumbsPrefix:d=[]}){if(!Se(n))return {ok:false,errors:[{path:d,message:v(n,"object")}]};let{[t]:u,...g}=n;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=i(y.value);if(k==null)return a?{ok:true,value:{[e]:y.value,...g}}:{ok:false,errors:[{path:[...d,t],message:"Unexpected discriminant value"}]};let S=c(g,k);return S.ok?{ok:true,value:{[e]:u,...S.value}}:S}function Bw(n){var t=[];if(n.length===0)return "";if(typeof n[0]!="string")throw new TypeError("Url must be a string. Received "+n[0]);if(n[0].match(/^[^/:]+:\/*$/)&&n.length>1){var e=n.shift();n[0]=e+n[0];}n[0].match(/^file:\/\/\//)?n[0]=n[0].replace(/^([^/:]+):\/*/,"$1:///"):n[0]=n[0].replace(/^([^/:]+):\/*/,"$1://");for(var o=0;o<n.length;o++){var i=n[o];if(typeof i!="string")throw new TypeError("Url must be a string. Received "+i);i!==""&&(o>0&&(i=i.replace(/^[\/]+/,"")),o<n.length-1?i=i.replace(/[\/]+$/,""):i=i.replace(/[\/]+$/,"/"),t.push(i));}var a=t.join("/");a=a.replace(/\/(\?|&|#[^!])/g,"$1");var c=a.split("?");return a=c.shift()+(c.length>0?"?":"")+c.join("&"),a}function b(){var n;return typeof arguments[0]=="object"?n=arguments[0]:n=[].slice.call(arguments),Bw(n)}var I={};P(I,{AggregationData:()=>Sc,Alert:()=>Xw,AlertAlertType:()=>ts,AlertPagePublic:()=>ks,AlertPublic:()=>uo,AlertPublicAlertType:()=>ws,AlertTrigger:()=>ps,AlertTriggerConfig:()=>ss,AlertTriggerConfigPublic:()=>bs,AlertTriggerConfigPublicType:()=>Rs,AlertTriggerConfigType:()=>ns,AlertTriggerConfigWrite:()=>ls,AlertTriggerConfigWriteType:()=>cs,AlertTriggerEventType:()=>as,AlertTriggerPublic:()=>ys,AlertTriggerPublicEventType:()=>hs,AlertTriggerWrite:()=>ds,AlertTriggerWriteEventType:()=>ms,AlertWrite:()=>mo,AlertWriteAlertType:()=>us,AnnotationQueue:()=>As,AnnotationQueueBatch:()=>$w,AnnotationQueueBatchWrite:()=>ao,AnnotationQueueItemIds:()=>Si,AnnotationQueuePagePublic:()=>vs,AnnotationQueuePublic:()=>go,AnnotationQueuePublicScope:()=>Es,AnnotationQueueReviewer:()=>Ts,AnnotationQueueReviewerPublic:()=>Ps,AnnotationQueueScope:()=>_s,AnnotationQueueUpdate:()=>no,AnnotationQueueWrite:()=>io,AnnotationQueueWriteScope:()=>Ln,AssistantMessage:()=>Sp,AssistantMessageRole:()=>zp,Attachment:()=>Cs,AttachmentListRequestEntityType:()=>Ft,AttachmentPage:()=>Is,AuthDetailsHolder:()=>Ds,AutomationRuleEvaluator:()=>Yw,AutomationRuleEvaluatorLlmAsJudge:()=>Ls,AutomationRuleEvaluatorLlmAsJudgePublic:()=>Po,AutomationRuleEvaluatorLlmAsJudgeWrite:()=>$s,AutomationRuleEvaluatorObjectPublic:()=>mp,AutomationRuleEvaluatorPagePublic:()=>dp,AutomationRuleEvaluatorPublic:()=>up,AutomationRuleEvaluatorTraceThreadLlmAsJudge:()=>Hs,AutomationRuleEvaluatorTraceThreadLlmAsJudgePublic:()=>Co,AutomationRuleEvaluatorTraceThreadLlmAsJudgeWrite:()=>Ys,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPython:()=>Js,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPythonPublic:()=>Io,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPythonWrite:()=>qs,AutomationRuleEvaluatorUpdate:()=>kp,AutomationRuleEvaluatorUpdateLlmAsJudge:()=>hp,AutomationRuleEvaluatorUpdateTraceThreadLlmAsJudge:()=>bp,AutomationRuleEvaluatorUpdateTraceThreadUserDefinedMetricPython:()=>yp,AutomationRuleEvaluatorUpdateUserDefinedMetricPython:()=>Rp,AutomationRuleEvaluatorUserDefinedMetricPython:()=>Vs,AutomationRuleEvaluatorUserDefinedMetricPythonPublic:()=>vo,AutomationRuleEvaluatorUserDefinedMetricPythonWrite:()=>rp,AutomationRuleEvaluatorWrite:()=>ip,AvgValueStatPublic:()=>Xp,BatchDelete:()=>W,BatchDeleteByProject:()=>Rf,BiInformation:()=>Zn,BiInformationResponse:()=>$e,BooleanFeedbackDefinition:()=>Ec,BooleanFeedbackDefinitionCreate:()=>Nc,BooleanFeedbackDefinitionPublic:()=>Bo,BooleanFeedbackDefinitionUpdate:()=>Yc,BooleanFeedbackDetail:()=>Ac,BooleanFeedbackDetailCreate:()=>Uc,BooleanFeedbackDetailPublic:()=>Lc,BooleanFeedbackDetailUpdate:()=>Qc,CategoricalFeedbackDefinition:()=>vc,CategoricalFeedbackDefinitionCreate:()=>Dc,CategoricalFeedbackDefinitionPublic:()=>Lo,CategoricalFeedbackDefinitionUpdate:()=>qc,CategoricalFeedbackDetail:()=>Pc,CategoricalFeedbackDetailCreate:()=>Mc,CategoricalFeedbackDetailPublic:()=>Vc,CategoricalFeedbackDetailUpdate:()=>Zc,ChatCompletionChoice:()=>_p,ChatCompletionRequest:()=>po,ChatCompletionResponse:()=>Pp,Check:()=>mc,CheckName:()=>cc,CheckPublic:()=>Zl,CheckPublicName:()=>Ql,CheckPublicResult:()=>Yl,CheckResult:()=>lc,ChunkedOutputJsonNode:()=>rf,ChunkedOutputJsonNodePublic:()=>nf,ChunkedOutputJsonNodePublicType:()=>Tc,ChunkedOutputJsonNodeType:()=>nc,Column:()=>ic,ColumnCompare:()=>Up,ColumnCompareTypesItem:()=>jp,ColumnPublic:()=>rc,ColumnPublicTypesItem:()=>ec,ColumnTypesItem:()=>tc,Comment:()=>B,CommentCompare:()=>Np,CommentPublic:()=>Me,CompleteMultipartUploadRequest:()=>xi,CompleteMultipartUploadRequestEntityType:()=>js,CompletionTokensDetails:()=>Ap,CountValueStatPublic:()=>Gp,CreateDatasetItemsFromSpansRequest:()=>wr,CreateDatasetItemsFromTracesRequest:()=>fr,CreatePromptVersionDetail:()=>Wr,DataPointDouble:()=>bf,DataPointNumberPublic:()=>yl,Dataset:()=>Zw,DatasetExpansion:()=>ef,DatasetExpansionResponse:()=>Ip,DatasetExpansionWrite:()=>yr,DatasetIdentifier:()=>Rr,DatasetIdentifierPublic:()=>kr,DatasetItem:()=>Uo,DatasetItemBatch:()=>qw,DatasetItemBatchWrite:()=>gr,DatasetItemCompare:()=>Vp,DatasetItemCompareSource:()=>Mp,DatasetItemPageCompare:()=>Hp,DatasetItemPagePublic:()=>oc,DatasetItemPublic:()=>Do,DatasetItemPublicSource:()=>Zp,DatasetItemSource:()=>Cp,DatasetItemStreamRequest:()=>zr,DatasetItemWrite:()=>gn,DatasetItemWriteSource:()=>un,DatasetItemsDelete:()=>br,DatasetPagePublic:()=>Kp,DatasetPublic:()=>Qe,DatasetPublicVisibility:()=>Jp,DatasetUpdate:()=>hr,DatasetUpdateVisibility:()=>Ht,DatasetVisibility:()=>vp,DatasetWrite:()=>ur,DatasetWriteVisibility:()=>Vt,DeleteAttachmentsRequest:()=>Qw,DeleteAttachmentsRequestEntityType:()=>Ns,DeleteFeedbackScore:()=>Go,DeleteIdsHolder:()=>Ye,DeleteThreadFeedbackScores:()=>Zr,DeleteTraceThreads:()=>qr,Delta:()=>xp,DownloadAttachmentRequestEntityType:()=>Ot,ErrorCountWithDeviation:()=>Ko,ErrorCountWithDeviationDetailed:()=>Al,ErrorInfo:()=>be,ErrorInfoExperimentItemBulkWriteView:()=>Ar,ErrorInfoPublic:()=>$o,ErrorInfoWrite:()=>Vr,ErrorMessage:()=>ee,ErrorMessageDetail:()=>wf,ErrorMessageDetailed:()=>uf,ErrorMessagePublic:()=>Gw,Experiment:()=>of,ExperimentGroupAggregationsResponse:()=>_c,ExperimentGroupResponse:()=>zc,ExperimentItem:()=>xr,ExperimentItemBulkRecord:()=>wc,ExperimentItemBulkRecordExperimentItemBulkWriteView:()=>En,ExperimentItemBulkUpload:()=>tf,ExperimentItemBulkUploadExperimentItemBulkWriteView:()=>Er,ExperimentItemCompare:()=>Lp,ExperimentItemCompareTraceVisibilityMode:()=>Bp,ExperimentItemPublic:()=>Mo,ExperimentItemPublicTraceVisibilityMode:()=>qp,ExperimentItemStreamRequest:()=>vr,ExperimentItemTraceVisibilityMode:()=>yn,ExperimentItemsBatch:()=>_r,ExperimentItemsDelete:()=>Tr,ExperimentPagePublic:()=>Rc,ExperimentPublic:()=>Wo,ExperimentPublicStatus:()=>hc,ExperimentPublicType:()=>fc,ExperimentStatus:()=>pc,ExperimentStreamRequestPublic:()=>Cr,ExperimentType:()=>sc,ExperimentUpdate:()=>Pr,ExperimentUpdateStatus:()=>$t,ExperimentUpdateType:()=>Gt,ExperimentWrite:()=>Sr,ExperimentWriteStatus:()=>Xt,ExperimentWriteType:()=>Kt,ExportTraceServiceRequest:()=>lf,Feedback:()=>sf,FeedbackCreate:()=>Bc,FeedbackDefinitionPagePublic:()=>Xc,FeedbackObjectPublic:()=>Kc,FeedbackPublic:()=>$c,FeedbackScore:()=>Y,FeedbackScoreAverage:()=>ie,FeedbackScoreAverageDetailed:()=>El,FeedbackScoreAveragePublic:()=>Ue,FeedbackScoreBatch:()=>Zo,FeedbackScoreBatchItem:()=>$l,FeedbackScoreBatchItemSource:()=>Gl,FeedbackScoreBatchItemThread:()=>On,FeedbackScoreBatchItemThreadSource:()=>Fn,FeedbackScoreBatchThread:()=>eo,FeedbackScoreCompare:()=>Wp,FeedbackScoreCompareSource:()=>Dp,FeedbackScoreExperimentItemBulkWriteView:()=>An,FeedbackScoreExperimentItemBulkWriteViewSource:()=>xn,FeedbackScoreNames:()=>bl,FeedbackScorePublic:()=>Qo,FeedbackScorePublicSource:()=>Vl,FeedbackScoreSource:()=>hn,FeedbackUpdate:()=>tl,FindFeedbackDefinitionsRequestType:()=>Zt,FindFeedbackScoreNames1RequestType:()=>ui,Function:()=>so,FunctionCall:()=>ye,GetSpanStatsRequestType:()=>gi,GetSpansByProjectRequestType:()=>mi,GetWebhookExamplesRequestAlertType:()=>Mt,GroupContent:()=>bc,GroupContentWithAggregations:()=>xc,GroupDetail:()=>yc,GroupDetails:()=>kc,Guardrail:()=>nl,GuardrailBatch:()=>pf,GuardrailBatchWrite:()=>co,GuardrailName:()=>il,GuardrailResult:()=>al,GuardrailWrite:()=>Yn,GuardrailWriteName:()=>$n,GuardrailWriteResult:()=>Qn,GuardrailsValidation:()=>dc,GuardrailsValidationPublic:()=>ql,IdsHolder:()=>af,JsonListString:()=>U,JsonListStringCompare:()=>vi,JsonListStringExperimentItemBulkWriteView:()=>me,JsonListStringPublic:()=>ae,JsonListStringWrite:()=>te,JsonNode:()=>O,JsonNodeDetail:()=>jn,JsonNodePublic:()=>Ml,JsonNodeWrite:()=>In,JsonSchema:()=>Kn,LlmAsJudgeCode:()=>bo,LlmAsJudgeCodePublic:()=>sp,LlmAsJudgeCodeWrite:()=>Gs,LlmAsJudgeMessage:()=>ho,LlmAsJudgeMessagePublic:()=>Ao,LlmAsJudgeMessagePublicRole:()=>ap,LlmAsJudgeMessageRole:()=>Ws,LlmAsJudgeMessageWrite:()=>xo,LlmAsJudgeMessageWriteRole:()=>Ks,LlmAsJudgeModelParameters:()=>fo,LlmAsJudgeModelParametersPublic:()=>To,LlmAsJudgeModelParametersWrite:()=>So,LlmAsJudgeOutputSchema:()=>Ro,LlmAsJudgeOutputSchemaPublic:()=>Eo,LlmAsJudgeOutputSchemaPublicType:()=>np,LlmAsJudgeOutputSchemaType:()=>Bs,LlmAsJudgeOutputSchemaWrite:()=>_o,LlmAsJudgeOutputSchemaWriteType:()=>Xs,LogItem:()=>wp,LogItemLevel:()=>gp,LogPage:()=>fp,ManualEvaluationRequest:()=>Ui,ManualEvaluationRequestEntityType:()=>ll,ManualEvaluationResponse:()=>ji,Message:()=>Vn,MultipartUploadPart:()=>Us,NumericalFeedbackDefinition:()=>Ic,NumericalFeedbackDefinitionCreate:()=>Oc,NumericalFeedbackDefinitionPublic:()=>Vo,NumericalFeedbackDefinitionUpdate:()=>rl,NumericalFeedbackDetail:()=>Cc,NumericalFeedbackDetailCreate:()=>Fc,NumericalFeedbackDetailPublic:()=>Hc,NumericalFeedbackDetailUpdate:()=>el,Optimization:()=>mf,OptimizationPagePublic:()=>gl,OptimizationPublic:()=>Jo,OptimizationPublicStatus:()=>ul,OptimizationStatus:()=>ml,OptimizationUpdate:()=>Ur,OptimizationUpdateStatus:()=>oi,OptimizationWrite:()=>Ni,OptimizationWriteStatus:()=>dl,PageColumns:()=>ac,PercentageValueStatPublic:()=>$p,PercentageValues:()=>ke,PercentageValuesDetailed:()=>Pl,PercentageValuesPublic:()=>No,Project:()=>df,ProjectDetailed:()=>Cl,ProjectDetailedVisibility:()=>vl,ProjectMetricRequestPublic:()=>Dr,ProjectMetricRequestPublicInterval:()=>si,ProjectMetricRequestPublicMetricType:()=>ni,ProjectMetricResponsePublic:()=>xl,ProjectMetricResponsePublicInterval:()=>zl,ProjectMetricResponsePublicMetricType:()=>kl,ProjectPagePublic:()=>hl,ProjectPublic:()=>Xo,ProjectPublicVisibility:()=>fl,ProjectRetrieveDetailed:()=>Fr,ProjectStatItemObjectPublic:()=>Yp,ProjectStatsPublic:()=>Ne,ProjectStatsSummary:()=>Tl,ProjectStatsSummaryItem:()=>_l,ProjectUpdate:()=>Mr,ProjectUpdateVisibility:()=>ai,ProjectVisibility:()=>wl,ProjectWrite:()=>Nr,ProjectWriteVisibility:()=>ii,Prompt:()=>gf,PromptDetail:()=>Nl,PromptPagePublic:()=>Bl,PromptPublic:()=>Wl,PromptTokensDetails:()=>Tp,PromptType:()=>Il,PromptUpdatable:()=>Br,PromptVersion:()=>Ul,PromptVersionDetail:()=>fe,PromptVersionDetailType:()=>Un,PromptVersionLink:()=>Ci,PromptVersionLinkPublic:()=>Ii,PromptVersionLinkWrite:()=>Yt,PromptVersionPagePublic:()=>Ol,PromptVersionPublic:()=>Fl,PromptVersionPublicType:()=>Dl,PromptVersionRetrieveDetail:()=>Lr,PromptVersionType:()=>jl,PromptWrite:()=>Or,PromptWriteType:()=>ci,ProviderApiKey:()=>cf,ProviderApiKeyPagePublic:()=>pl,ProviderApiKeyProvider:()=>cl,ProviderApiKeyPublic:()=>Ho,ProviderApiKeyPublicProvider:()=>sl,ProviderApiKeyUpdate:()=>jr,ProviderApiKeyWrite:()=>Ir,ProviderApiKeyWriteProvider:()=>ei,ResponseFormat:()=>Xn,ResponseFormatType:()=>Jn,Result:()=>De,ResultsNumberPublic:()=>Sl,ScoreName:()=>Rl,ServiceTogglesConfig:()=>Ll,Span:()=>Oo,SpanBatch:()=>ff,SpanBatchWrite:()=>Jr,SpanEnrichmentOptions:()=>wn,SpanExperimentItemBulkWriteView:()=>Sn,SpanExperimentItemBulkWriteViewType:()=>zn,SpanFilterPublic:()=>Dn,SpanFilterPublicOperator:()=>Mn,SpanPagePublic:()=>Xl,SpanPublic:()=>Yo,SpanPublicType:()=>Kl,SpanSearchStreamRequestPublic:()=>Xr,SpanSearchStreamRequestPublicType:()=>wi,SpanType:()=>gc,SpanUpdate:()=>Kr,SpanUpdateType:()=>di,SpanWrite:()=>Hr,SpanWriteType:()=>Nn,SpansCountResponse:()=>es,StartMultipartUploadRequest:()=>dr,StartMultipartUploadRequestEntityType:()=>Wt,StartMultipartUploadResponse:()=>Ms,StreamOptions:()=>Hn,Tool:()=>Gn,ToolCall:()=>jo,Trace:()=>Fo,TraceBatch:()=>hf,TraceBatchWrite:()=>Qr,TraceCountResponse:()=>os,TraceEnrichmentOptions:()=>fn,TraceExperimentItemBulkWriteView:()=>kn,TraceFilter:()=>wo,TraceFilterOperator:()=>Os,TraceFilterPublic:()=>Re,TraceFilterPublicOperator:()=>Pn,TraceFilterWrite:()=>tp,TraceFilterWriteOperator:()=>op,TracePagePublic:()=>tm,TracePublic:()=>qo,TracePublicVisibilityMode:()=>em,TraceSearchStreamRequestPublic:()=>oo,TraceThread:()=>et,TraceThreadBatchIdentifier:()=>Gr,TraceThreadFilter:()=>Bn,TraceThreadFilterOperator:()=>Wn,TraceThreadFilterPublic:()=>Cn,TraceThreadFilterPublicOperator:()=>vn,TraceThreadIdentifier:()=>Mi,TraceThreadLlmAsJudgeCode:()=>ko,TraceThreadLlmAsJudgeCodePublic:()=>cp,TraceThreadLlmAsJudgeCodeWrite:()=>Qs,TraceThreadPage:()=>om,TraceThreadSearchStreamRequest:()=>ro,TraceThreadStatus:()=>rm,TraceThreadUpdate:()=>to,TraceThreadUserDefinedMetricPythonCode:()=>zo,TraceThreadUserDefinedMetricPythonCodePublic:()=>lp,TraceThreadUserDefinedMetricPythonCodeWrite:()=>Zs,TraceUpdate:()=>Yr,TraceVisibilityMode:()=>uc,TraceWrite:()=>$r,UploadAttachmentRequestEntityType:()=>Bt,Usage:()=>Ep,UserDefinedMetricPythonCode:()=>yo,UserDefinedMetricPythonCodePublic:()=>pp,UserDefinedMetricPythonCodeWrite:()=>ep,ValueEntry:()=>bn,ValueEntryCompare:()=>Op,ValueEntryCompareSource:()=>Fp,ValueEntryExperimentItemBulkWriteView:()=>Tn,ValueEntryExperimentItemBulkWriteViewSource:()=>_n,ValueEntryPublic:()=>Jl,ValueEntryPublicSource:()=>Hl,ValueEntrySource:()=>Rn,Webhook:()=>is,WebhookExamples:()=>zs,WebhookPublic:()=>fs,WebhookTestResult:()=>xs,WebhookTestResultStatus:()=>Ss,WebhookWrite:()=>gs,WelcomeWizardSubmission:()=>lo,WelcomeWizardTracking:()=>im,WorkspaceConfiguration:()=>rt,WorkspaceMetricRequest:()=>yf,WorkspaceMetricResponse:()=>Di,WorkspaceMetricsSummaryRequest:()=>Ze,WorkspaceMetricsSummaryResponse:()=>am,WorkspaceNameHolder:()=>Fs,WorkspaceSpansCount:()=>qn,WorkspaceTraceCount:()=>rs,alerts:()=>Dt,annotationQueues:()=>bi,attachments:()=>Ke,chatCompletions:()=>yi,datasets:()=>Jt,experiments:()=>Xe,feedbackDefinitions:()=>qt,guardrails:()=>ki,llmProviderKey:()=>ri,optimizations:()=>ti,projects:()=>pi,prompts:()=>li,spans:()=>Ge,traces:()=>je,welcomeWizard:()=>zi});var Dt={};P(Dt,{GetWebhookExamplesRequestAlertType:()=>Mt});var Mt=r.enum_(["general","slack","pagerduty"]);var Ke={};P(Ke,{AttachmentListRequestEntityType:()=>Ft,DownloadAttachmentRequestEntityType:()=>Ot,StartMultipartUploadRequest:()=>dr,StartMultipartUploadRequestEntityType:()=>Wt,UploadAttachmentRequestEntityType:()=>Bt,uploadAttachment:()=>Lt});var Ft=r.enum_(["trace","span"]);var Ot=r.enum_(["trace","span"]);var Wt=r.enum_(["trace","span"]);var Bt=r.enum_(["trace","span"]);var Lt={};P(Lt,{Request:()=>Lw});var Lw=r.record(r.string(),r.unknown());var dr=r.object({fileName:r.property("file_name",r.string()),numOfFileParts:r.property("num_of_file_parts",r.number()),mimeType:r.property("mime_type",r.string().optional()),projectName:r.property("project_name",r.string().optional()),entityType:r.property("entity_type",Wt),entityId:r.property("entity_id",r.string()),path:r.string()});var Jt={};P(Jt,{CreateDatasetItemsFromSpansRequest:()=>wr,CreateDatasetItemsFromTracesRequest:()=>fr,DatasetExpansionWrite:()=>yr,DatasetIdentifier:()=>Rr,DatasetIdentifierPublic:()=>kr,DatasetItemBatchWrite:()=>gr,DatasetItemStreamRequest:()=>zr,DatasetItemsDelete:()=>br,DatasetUpdate:()=>hr,DatasetUpdateVisibility:()=>Ht,DatasetWrite:()=>ur,DatasetWriteVisibility:()=>Vt});var Vt=r.enum_(["private","public"]);var Ht=r.enum_(["private","public"]);var ur=r.object({id:r.string().optional(),name:r.string(),visibility:Vt.optional(),tags:r.list(r.string()).optional(),description:r.string().optional()});var un=r.enum_(["manual","trace","span","sdk"]);var O=r.record(r.string(),r.unknown());var gn=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:un,data:O});var gr=r.object({datasetName:r.property("dataset_name",r.string().optional()),datasetId:r.property("dataset_id",r.string().optional()),items:r.list(gn)});var wn=r.object({includeTags:r.boolean().optional(),includeFeedbackScores:r.boolean().optional(),includeComments:r.boolean().optional(),includeUsage:r.boolean().optional(),includeMetadata:r.boolean().optional()});var wr=r.object({spanIds:r.property("span_ids",r.list(r.string())),enrichmentOptions:r.property("enrichment_options",wn)});var fn=r.object({includeSpans:r.boolean().optional(),includeTags:r.boolean().optional(),includeFeedbackScores:r.boolean().optional(),includeComments:r.boolean().optional(),includeUsage:r.boolean().optional(),includeMetadata:r.boolean().optional()});var fr=r.object({traceIds:r.property("trace_ids",r.list(r.string())),enrichmentOptions:r.property("enrichment_options",fn)});var hr=r.object({name:r.string(),description:r.string().optional(),visibility:Ht.optional(),tags:r.list(r.string()).optional()});var Rr=r.object({datasetName:r.property("dataset_name",r.string())});var br=r.object({itemIds:r.property("item_ids",r.list(r.string()))});var yr=r.object({model:r.string(),sampleCount:r.property("sample_count",r.number().optional()),preserveFields:r.property("preserve_fields",r.list(r.string()).optional()),variationInstructions:r.property("variation_instructions",r.string().optional()),customPrompt:r.property("custom_prompt",r.string().optional())});var kr=r.object({datasetName:r.property("dataset_name",r.string())});var zr=r.object({datasetName:r.property("dataset_name",r.string()),lastRetrievedId:r.property("last_retrieved_id",r.string().optional()),steamLimit:r.property("steam_limit",r.number().optional())});var Xe={};P(Xe,{ExperimentItemBulkUploadExperimentItemBulkWriteView:()=>Er,ExperimentItemStreamRequest:()=>vr,ExperimentItemsBatch:()=>_r,ExperimentItemsDelete:()=>Tr,ExperimentStreamRequestPublic:()=>Cr,ExperimentUpdate:()=>Pr,ExperimentUpdateStatus:()=>$t,ExperimentUpdateType:()=>Gt,ExperimentWrite:()=>Sr,ExperimentWriteStatus:()=>Xt,ExperimentWriteType:()=>Kt,findFeedbackScoreNames:()=>Qt});var Kt=r.enum_(["regular","trial","mini-batch"]);var Xt=r.enum_(["running","completed","cancelled"]);var Gt=r.enum_(["regular","trial","mini-batch"]);var $t=r.enum_(["running","completed","cancelled"]);var Qt={};P(Qt,{Response:()=>Vw});var Vw=r.list(r.string());var te=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var Yt=r.object({id:r.string()});var Sr=r.object({id:r.string().optional(),datasetName:r.property("dataset_name",r.string()),name:r.string().optional(),metadata:te.optional(),type:Kt.optional(),optimizationId:r.property("optimization_id",r.string().optional()),status:Xt.optional(),promptVersion:r.property("prompt_version",Yt.optional()),promptVersions:r.property("prompt_versions",r.list(Yt).optional())});var U=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var hn=r.enum_(["ui","sdk","online_scoring"]);var Rn=r.enum_(["ui","sdk","online_scoring"]);var bn=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Rn.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Y=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:hn,createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),valueByAuthor:r.property("value_by_author",r.record(r.string(),bn).optional())});var B=r.object({id:r.string().optional(),text:r.string(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var yn=r.enum_(["default","hidden"]);var xr=r.object({id:r.string().optional(),experimentId:r.property("experiment_id",r.string()),datasetItemId:r.property("dataset_item_id",r.string()),traceId:r.property("trace_id",r.string()),input:U.optional(),output:U.optional(),feedbackScores:r.property("feedback_scores",r.list(Y).optional()),comments:r.list(B).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),duration:r.number().optional(),usage:r.record(r.string(),r.number()).optional(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),traceVisibilityMode:r.property("trace_visibility_mode",yn.optional())});var _r=r.object({experimentItems:r.property("experiment_items",r.list(xr))});var Tr=r.object({ids:r.list(r.string())});var me=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var Ar=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var kn=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),name:r.string().optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:me.optional(),output:me.optional(),metadata:me.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",Ar.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),threadId:r.property("thread_id",r.string().optional())});var zn=r.enum_(["general","tool","llm","guardrail"]);var Sn=r.object({id:r.string().optional(),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:zn.optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:me.optional(),output:me.optional(),metadata:me.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),errorInfo:r.property("error_info",Ar.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostVersion:r.property("total_estimated_cost_version",r.string().optional())});var xn=r.enum_(["ui","sdk","online_scoring"]);var _n=r.enum_(["ui","sdk","online_scoring"]);var Tn=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:_n.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var An=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:xn,createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),valueByAuthor:r.property("value_by_author",r.record(r.string(),Tn).optional())});var En=r.object({datasetItemId:r.property("dataset_item_id",r.string()),evaluateTaskResult:r.property("evaluate_task_result",me.optional()),trace:kn.optional(),spans:r.list(Sn).optional(),feedbackScores:r.property("feedback_scores",r.list(An).optional())});var Er=r.object({experimentName:r.property("experiment_name",r.string()),datasetName:r.property("dataset_name",r.string()),experimentId:r.property("experiment_id",r.string().optional()),items:r.list(En)});var Pr=r.object({name:r.string().optional(),metadata:O.optional(),type:Gt.optional(),status:$t.optional()});var vr=r.object({experimentName:r.property("experiment_name",r.string()),limit:r.number().optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional()),truncate:r.boolean().optional()});var Cr=r.object({name:r.string(),limit:r.number().optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional())});var qt={};P(qt,{FindFeedbackDefinitionsRequestType:()=>Zt});var Zt=r.enum_(["numerical","categorical","boolean"]);var ri={};P(ri,{ProviderApiKeyUpdate:()=>jr,ProviderApiKeyWrite:()=>Ir,ProviderApiKeyWriteProvider:()=>ei});var ei=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var Ir=r.object({provider:ei,apiKey:r.property("api_key",r.string().optional()),name:r.string().optional(),providerName:r.property("provider_name",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),configuration:r.record(r.string(),r.string()).optional(),baseUrl:r.property("base_url",r.string().optional())});var jr=r.object({apiKey:r.property("api_key",r.string().optional()),name:r.string().optional(),providerName:r.property("provider_name",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),configuration:r.record(r.string(),r.string()).optional(),baseUrl:r.property("base_url",r.string().optional())});var ti={};P(ti,{OptimizationUpdate:()=>Ur,OptimizationUpdateStatus:()=>oi});var oi=r.enum_(["running","completed","cancelled"]);var Ur=r.object({name:r.string().optional(),status:oi.optional()});var pi={};P(pi,{ProjectMetricRequestPublic:()=>Dr,ProjectMetricRequestPublicInterval:()=>si,ProjectMetricRequestPublicMetricType:()=>ni,ProjectRetrieveDetailed:()=>Fr,ProjectUpdate:()=>Mr,ProjectUpdateVisibility:()=>ai,ProjectWrite:()=>Nr,ProjectWriteVisibility:()=>ii});var ii=r.enum_(["private","public"]);var ai=r.enum_(["private","public"]);var ni=r.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST","GUARDRAILS_FAILED_COUNT","THREAD_COUNT","THREAD_DURATION","THREAD_FEEDBACK_SCORES"]);var si=r.enum_(["HOURLY","DAILY","WEEKLY"]);var Nr=r.object({name:r.string(),visibility:ii.optional(),description:r.string().optional()});var Mr=r.object({name:r.string().optional(),description:r.string().optional(),visibility:ai.optional()});var Pn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Re=r.object({field:r.string().optional(),operator:Pn.optional(),key:r.string().optional(),value:r.string().optional()});var vn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Cn=r.object({field:r.string().optional(),operator:vn.optional(),key:r.string().optional(),value:r.string().optional()});var Dr=r.object({metricType:r.property("metric_type",ni.optional()),interval:si.optional(),intervalStart:r.property("interval_start",r.date().optional()),intervalEnd:r.property("interval_end",r.date().optional()),traceFilters:r.property("trace_filters",r.list(Re).optional()),threadFilters:r.property("thread_filters",r.list(Cn).optional())});var Fr=r.object({name:r.string()});var li={};P(li,{CreatePromptVersionDetail:()=>Wr,PromptUpdatable:()=>Br,PromptVersionRetrieveDetail:()=>Lr,PromptWrite:()=>Or,PromptWriteType:()=>ci});var ci=r.enum_(["mustache","jinja2"]);var In=r.record(r.string(),r.unknown());var Or=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),template:r.string().optional(),metadata:In.optional(),changeDescription:r.property("change_description",r.string().optional()),type:ci.optional(),tags:r.list(r.string()).optional()});var jn=r.record(r.string(),r.unknown());var Un=r.enum_(["mustache","jinja2"]);var fe=r.object({id:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),commit:r.string().optional(),template:r.string(),metadata:jn.optional(),type:Un.optional(),changeDescription:r.property("change_description",r.string().optional()),variables:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var Wr=r.object({name:r.string(),version:fe});var Br=r.object({name:r.string(),description:r.string().optional(),tags:r.list(r.string()).optional()});var Lr=r.object({name:r.string(),commit:r.string().optional()});var Ge={};P(Ge,{FindFeedbackScoreNames1RequestType:()=>ui,GetSpanStatsRequestType:()=>gi,GetSpansByProjectRequestType:()=>mi,SpanBatchWrite:()=>Jr,SpanSearchStreamRequestPublic:()=>Xr,SpanSearchStreamRequestPublicType:()=>wi,SpanUpdate:()=>Kr,SpanUpdateType:()=>di,findFeedbackScoreNames1:()=>fi});var mi=r.enum_(["general","tool","llm","guardrail"]);var di=r.enum_(["general","tool","llm","guardrail"]);var ui=r.enum_(["general","tool","llm","guardrail"]);var gi=r.enum_(["general","tool","llm","guardrail"]);var wi=r.enum_(["general","tool","llm","guardrail"]);var fi={};P(fi,{Response:()=>Hw});var Hw=r.list(r.string());var Nn=r.enum_(["general","tool","llm","guardrail"]);var Vr=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var Hr=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),traceId:r.property("trace_id",r.string().optional()),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:Nn.optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:te.optional(),output:te.optional(),metadata:te.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),errorInfo:r.property("error_info",Vr.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostVersion:r.property("total_estimated_cost_version",r.string().optional())});var Jr=r.object({spans:r.list(Hr)});var be=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var Kr=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),traceId:r.property("trace_id",r.string()),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:di.optional(),endTime:r.property("end_time",r.date().optional()),input:U.optional(),output:U.optional(),metadata:U.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),errorInfo:r.property("error_info",be.optional())});var Mn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Dn=r.object({field:r.string().optional(),operator:Mn.optional(),key:r.string().optional(),value:r.string().optional()});var Xr=r.object({traceId:r.property("trace_id",r.string().optional()),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),type:wi.optional(),filters:r.list(Dn).optional(),limit:r.number().optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional()),truncate:r.boolean().optional(),fromTime:r.property("from_time",r.date().optional()),toTime:r.property("to_time",r.date().optional())});var je={};P(je,{DeleteThreadFeedbackScores:()=>Zr,DeleteTraceThreads:()=>qr,FeedbackScoreBatchThread:()=>eo,TraceBatchWrite:()=>Qr,TraceSearchStreamRequestPublic:()=>oo,TraceThreadBatchIdentifier:()=>Gr,TraceThreadSearchStreamRequest:()=>ro,TraceThreadUpdate:()=>to,TraceUpdate:()=>Yr,findFeedbackScoreNames2:()=>hi,findTraceThreadsFeedbackScoreNames:()=>Ri});var hi={};P(hi,{Response:()=>Jw});var Jw=r.list(r.string());var Ri={};P(Ri,{Response:()=>Kw});var Kw=r.list(r.string());var Gr=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),threadId:r.property("thread_id",r.string().optional()),threadIds:r.property("thread_ids",r.list(r.string()).optional())});var $r=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),name:r.string().optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:te.optional(),output:te.optional(),metadata:te.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",Vr.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),threadId:r.property("thread_id",r.string().optional())});var Qr=r.object({traces:r.list($r)});var Yr=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:r.string().optional(),endTime:r.property("end_time",r.date().optional()),input:U.optional(),output:U.optional(),metadata:U.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",be.optional()),threadId:r.property("thread_id",r.string().optional())});var Zr=r.object({projectName:r.property("project_name",r.string()),threadId:r.property("thread_id",r.string()),names:r.list(r.string()),author:r.string().optional()});var qr=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),threadIds:r.property("thread_ids",r.list(r.string()))});var Fn=r.enum_(["ui","sdk","online_scoring"]);var On=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Fn,author:r.string().optional(),threadId:r.property("thread_id",r.string())});var eo=r.object({scores:r.list(On)});var Wn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Bn=r.object({field:r.string().optional(),operator:Wn.optional(),key:r.string().optional(),value:r.string().optional()});var ro=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),filters:r.list(Bn).optional(),lastRetrievedThreadModelId:r.property("last_retrieved_thread_model_id",r.string().optional()),limit:r.number().optional(),truncate:r.boolean().optional(),stripAttachments:r.property("strip_attachments",r.boolean().optional()),fromTime:r.property("from_time",r.date().optional()),toTime:r.property("to_time",r.date().optional())});var oo=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),filters:r.list(Re).optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional()),limit:r.number().optional(),truncate:r.boolean().optional(),stripAttachments:r.property("strip_attachments",r.boolean().optional()),fromTime:r.property("from_time",r.date().optional()),toTime:r.property("to_time",r.date().optional())});var to=r.object({tags:r.list(r.string()).optional()});var bi={};P(bi,{AnnotationQueueBatchWrite:()=>ao,AnnotationQueueUpdate:()=>no});var Ln=r.enum_(["trace","thread"]);var io=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),name:r.string(),description:r.string().optional(),instructions:r.string().optional(),scope:Ln,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional())});var ao=r.object({annotationQueues:r.property("annotation_queues",r.list(io))});var no=r.object({name:r.string().optional(),description:r.string().optional(),instructions:r.string().optional(),commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional())});var yi={};P(yi,{ChatCompletionRequest:()=>po});var Vn=r.record(r.string(),r.unknown());var Hn=r.object({includeUsage:r.property("include_usage",r.boolean().optional())});var Jn=r.enum_(["text","json_object","json_schema"]);var Kn=r.object({name:r.string().optional(),strict:r.boolean().optional(),schema:r.record(r.string(),r.record(r.string(),r.unknown())).optional()});var Xn=r.object({type:Jn.optional(),jsonSchema:r.property("json_schema",Kn.optional())});var so=r.object({name:r.string().optional(),description:r.string().optional(),strict:r.boolean().optional(),parameters:r.record(r.string(),r.record(r.string(),r.unknown())).optional()});var Gn=r.object({type:r.stringLiteral("function").optional(),function:so.optional()});var ye=r.object({name:r.string().optional(),arguments:r.string().optional()});var po=r.object({model:r.string().optional(),messages:r.list(Vn).optional(),temperature:r.number().optional(),topP:r.property("top_p",r.number().optional()),n:r.number().optional(),stream:r.boolean().optional(),streamOptions:r.property("stream_options",Hn.optional()),stop:r.list(r.string()).optional(),maxTokens:r.property("max_tokens",r.number().optional()),maxCompletionTokens:r.property("max_completion_tokens",r.number().optional()),presencePenalty:r.property("presence_penalty",r.number().optional()),frequencyPenalty:r.property("frequency_penalty",r.number().optional()),logitBias:r.property("logit_bias",r.record(r.string(),r.number()).optional()),user:r.string().optional(),responseFormat:r.property("response_format",Xn.optional()),seed:r.number().optional(),tools:r.list(Gn).optional(),toolChoice:r.property("tool_choice",r.record(r.string(),r.unknown()).optional()),parallelToolCalls:r.property("parallel_tool_calls",r.boolean().optional()),store:r.boolean().optional(),metadata:r.record(r.string(),r.string()).optional(),reasoningEffort:r.property("reasoning_effort",r.string().optional()),serviceTier:r.property("service_tier",r.string().optional()),functions:r.list(so).optional(),functionCall:r.property("function_call",ye.optional())});var ki={};P(ki,{GuardrailBatchWrite:()=>co});var $n=r.enum_(["TOPIC","PII"]);var Qn=r.enum_(["passed","failed"]);var Yn=r.object({entityId:r.property("entity_id",r.string()),secondaryId:r.property("secondary_id",r.string()),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:$n,result:Qn,config:O,details:O});var co=r.object({guardrails:r.list(Yn)});var zi={};P(zi,{WelcomeWizardSubmission:()=>lo});var lo=r.object({role:r.string().optional(),integrations:r.list(r.string()).optional(),email:r.string().optional(),joinBetaProgram:r.property("join_beta_program",r.boolean().optional())});var Zn=r.object({workspaceId:r.property("workspace_id",r.string().optional()),user:r.string().optional(),count:r.number().optional()});var $e=r.object({biInformation:r.property("bi_information",r.list(Zn).optional())});var qn=r.object({workspace:r.string().optional(),spanCount:r.property("span_count",r.number().optional())});var es=r.object({workspacesSpansCount:r.property("workspaces_spans_count",r.list(qn).optional())});var rs=r.object({workspace:r.string().optional(),traceCount:r.property("trace_count",r.number().optional())});var os=r.object({workspacesTracesCount:r.property("workspaces_traces_count",r.list(rs).optional())});var ee=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var ts=r.enum_(["general","slack","pagerduty"]);var is=r.object({id:r.string().optional(),name:r.string().optional(),url:r.string(),secretToken:r.property("secret_token",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var as=r.enum_(["trace:errors","trace:feedback_score","trace_thread:feedback_score","prompt:created","prompt:committed","trace:guardrails_triggered","prompt:deleted","experiment:finished","trace:cost","trace:latency"]);var ns=r.enum_(["scope:project","threshold:feedback_score","threshold:cost","threshold:latency"]);var ss=r.object({id:r.string().optional(),alertTriggerId:r.property("alert_trigger_id",r.string().optional()),type:ns,configValue:r.property("config_value",r.record(r.string(),r.string()).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ps=r.object({id:r.string().optional(),alertId:r.property("alert_id",r.string().optional()),eventType:r.property("event_type",as),triggerConfigs:r.property("trigger_configs",r.list(ss).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var Xw=r.object({id:r.string().optional(),name:r.string().optional(),enabled:r.boolean().optional(),alertType:r.property("alert_type",ts.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:is,triggers:r.list(ps).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var cs=r.enum_(["scope:project","threshold:feedback_score","threshold:cost","threshold:latency"]);var ls=r.object({id:r.string().optional(),type:cs,configValue:r.property("config_value",r.record(r.string(),r.string()).optional())});var ms=r.enum_(["trace:errors","trace:feedback_score","trace_thread:feedback_score","prompt:created","prompt:committed","trace:guardrails_triggered","prompt:deleted","experiment:finished","trace:cost","trace:latency"]);var ds=r.object({id:r.string().optional(),eventType:r.property("event_type",ms),triggerConfigs:r.property("trigger_configs",r.list(ls).optional())});var us=r.enum_(["general","slack","pagerduty"]);var gs=r.object({id:r.string().optional(),name:r.string().optional(),url:r.string(),secretToken:r.property("secret_token",r.string().optional()),headers:r.record(r.string(),r.string()).optional()});var mo=r.object({id:r.string().optional(),name:r.string().optional(),enabled:r.boolean().optional(),alertType:r.property("alert_type",us.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:gs,triggers:r.list(ds).optional()});var W=r.object({ids:r.list(r.string())});var ws=r.enum_(["general","slack","pagerduty"]);var fs=r.object({id:r.string().optional(),name:r.string().optional(),url:r.string(),secretToken:r.property("secret_token",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var hs=r.enum_(["trace:errors","trace:feedback_score","trace_thread:feedback_score","prompt:created","prompt:committed","trace:guardrails_triggered","prompt:deleted","experiment:finished","trace:cost","trace:latency"]);var Rs=r.enum_(["scope:project","threshold:feedback_score","threshold:cost","threshold:latency"]);var bs=r.object({id:r.string().optional(),alertTriggerId:r.property("alert_trigger_id",r.string().optional()),type:Rs,configValue:r.property("config_value",r.record(r.string(),r.string()).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ys=r.object({id:r.string().optional(),alertId:r.property("alert_id",r.string().optional()),eventType:r.property("event_type",hs),triggerConfigs:r.property("trigger_configs",r.list(bs).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var uo=r.object({id:r.string().optional(),name:r.string().optional(),enabled:r.boolean().optional(),alertType:r.property("alert_type",ws.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:fs,triggers:r.list(ys).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ks=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(uo).optional(),sortableBy:r.property("sortable_by",r.list(r.string()).optional())});var Gw=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var zs=r.object({responseExamples:r.property("response_examples",r.record(r.string(),r.record(r.string(),r.unknown())).optional())});var Ss=r.enum_(["success","failure"]);var xs=r.object({status:Ss.optional(),statusCode:r.property("status_code",r.number().optional()),requestBody:r.property("request_body",r.string().optional()),errorMessage:r.property("error_message",r.string().optional())});var Si=r.object({ids:r.list(r.string())});var _s=r.enum_(["trace","thread"]);var Ts=r.object({username:r.string().optional(),status:r.number().optional()});var ie=r.object({name:r.string(),value:r.number()});var As=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),description:r.string().optional(),instructions:r.string().optional(),scope:_s,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional()),reviewers:r.list(Ts).optional(),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),itemsCount:r.property("items_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var $w=r.object({annotationQueues:r.property("annotation_queues",r.list(As))});var Es=r.enum_(["trace","thread"]);var Ps=r.object({username:r.string().optional(),status:r.number().optional()});var Ue=r.object({name:r.string(),value:r.number()});var go=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),description:r.string().optional(),instructions:r.string().optional(),scope:Es,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional()),reviewers:r.list(Ps).optional(),feedbackScores:r.property("feedback_scores",r.list(Ue).optional()),itemsCount:r.property("items_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var vs=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(go).optional(),sortableBy:r.list(r.string()).optional()});var Cs=r.object({link:r.string().optional(),fileName:r.property("file_name",r.string()),fileSize:r.property("file_size",r.number()),mimeType:r.property("mime_type",r.string())});var Is=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Cs).optional(),sortableBy:r.list(r.string()).optional()});var js=r.enum_(["trace","span"]);var Us=r.object({eTag:r.property("e_tag",r.string()),partNumber:r.property("part_number",r.number())});var xi=r.object({fileName:r.property("file_name",r.string()),projectName:r.property("project_name",r.string().optional()),entityType:r.property("entity_type",js),entityId:r.property("entity_id",r.string()),containerId:r.property("container_id",r.string().optional()),fileSize:r.property("file_size",r.number()),mimeType:r.property("mime_type",r.string().optional()),uploadId:r.property("upload_id",r.string()),uploadedFileParts:r.property("uploaded_file_parts",r.list(Us))});var Ns=r.enum_(["trace","span"]);var Qw=r.object({fileNames:r.property("file_names",r.list(r.string())),entityType:r.property("entity_type",Ns),entityId:r.property("entity_id",r.string()),containerId:r.property("container_id",r.string())});var Ms=r.object({uploadId:r.property("upload_id",r.string()),preSignUrls:r.property("pre_sign_urls",r.list(r.string()))});var Ds=r.record(r.string(),r.unknown());var Fs=r.object({workspaceName:r.property("workspace_name",r.string().optional())});var Os=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var wo=r.object({field:r.string().optional(),operator:Os.optional(),key:r.string().optional(),value:r.string().optional()});var fo=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional()});var Ws=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var ho=r.object({role:Ws,content:r.string()});var Bs=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var Ro=r.object({name:r.string(),type:Bs,description:r.string()});var bo=r.object({model:fo,messages:r.list(ho),variables:r.record(r.string(),r.string()),schema:r.list(Ro)});var Ls=r.object({code:bo.optional()});var yo=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var Vs=r.object({code:yo.optional()});var ko=r.object({model:fo,messages:r.list(ho),schema:r.list(Ro)});var Hs=r.object({code:ko.optional()});var zo=r.object({metric:r.string()});var Js=r.object({code:zo.optional()});var _i=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(wo).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),action:r.stringLiteral("evaluator")}),Yw=r.union("type",{llm_as_judge:Ls.extend(_i),user_defined_metric_python:Vs.extend(_i),trace_thread_llm_as_judge:Hs.extend(_i),trace_thread_user_defined_metric_python:Js.extend(_i)}).transform({transform:n=>n,untransform:n=>n});var So=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional()});var Ks=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var xo=r.object({role:Ks,content:r.string()});var Xs=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var _o=r.object({name:r.string(),type:Xs,description:r.string()});var Gs=r.object({model:So,messages:r.list(xo),variables:r.record(r.string(),r.string()),schema:r.list(_o)});var $s=r.object({code:Gs.optional()});var Qs=r.object({model:So,messages:r.list(xo),schema:r.list(_o)});var Ys=r.object({code:Qs.optional()});var Zs=r.object({metric:r.string()});var qs=r.object({code:Zs.optional()});var ep=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var rp=r.object({code:ep.optional()});var op=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var tp=r.object({field:r.string().optional(),operator:op.optional(),key:r.string().optional(),value:r.string().optional()});var Ti=r.object({projectId:r.property("project_id",r.string()),name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(tp).optional(),action:r.stringLiteral("evaluator")}),ip=r.union("type",{llm_as_judge:$s.extend(Ti),user_defined_metric_python:rp.extend(Ti),trace_thread_llm_as_judge:Ys.extend(Ti),trace_thread_user_defined_metric_python:qs.extend(Ti)}).transform({transform:n=>n,untransform:n=>n});var To=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional()});var ap=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var Ao=r.object({role:ap,content:r.string()});var np=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var Eo=r.object({name:r.string(),type:np,description:r.string()});var sp=r.object({model:To,messages:r.list(Ao),variables:r.record(r.string(),r.string()),schema:r.list(Eo)});var Po=r.object({code:sp.optional()});var pp=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var vo=r.object({code:pp.optional()});var cp=r.object({model:To,messages:r.list(Ao),schema:r.list(Eo)});var Co=r.object({code:cp.optional()});var lp=r.object({metric:r.string()});var Io=r.object({code:lp.optional()});var Ai=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(Re).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),action:r.stringLiteral("evaluator")}),mp=r.union("type",{llm_as_judge:Po.extend(Ai),user_defined_metric_python:vo.extend(Ai),trace_thread_llm_as_judge:Co.extend(Ai),trace_thread_user_defined_metric_python:Io.extend(Ai)}).transform({transform:n=>n,untransform:n=>n});var dp=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(mp).optional(),sortableBy:r.property("sortable_by",r.list(r.string()).optional())});var Ei=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(Re).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),action:r.stringLiteral("evaluator")}),up=r.union("type",{llm_as_judge:Po.extend(Ei),user_defined_metric_python:vo.extend(Ei),trace_thread_llm_as_judge:Co.extend(Ei),trace_thread_user_defined_metric_python:Io.extend(Ei)}).transform({transform:n=>n,untransform:n=>n});var gp=r.enum_(["INFO","WARN","ERROR","DEBUG","TRACE"]);var wp=r.object({timestamp:r.date().optional(),ruleId:r.property("rule_id",r.string().optional()),level:gp.optional(),message:r.string().optional(),markers:r.record(r.string(),r.string()).optional()});var fp=r.object({content:r.list(wp).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional()});var hp=r.object({code:bo.optional()});var Rp=r.object({code:yo.optional()});var bp=r.object({code:ko.optional()});var yp=r.object({code:zo.optional()});var Pi=r.object({name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(wo).optional(),projectId:r.property("project_id",r.string()),action:r.stringLiteral("evaluator")}),kp=r.union("type",{llm_as_judge:hp.extend(Pi),user_defined_metric_python:Rp.extend(Pi),trace_thread_llm_as_judge:bp.extend(Pi),trace_thread_user_defined_metric_python:yp.extend(Pi)}).transform({transform:n=>n,untransform:n=>n});var zp=r.enum_(["system","user","assistant","tool","function"]);var jo=r.object({id:r.string().optional(),index:r.number().optional(),type:r.stringLiteral("function").optional(),function:ye.optional()});var Sp=r.object({role:zp.optional(),content:r.string().optional(),reasoningContent:r.property("reasoning_content",r.string().optional()),name:r.string().optional(),toolCalls:r.property("tool_calls",r.list(jo).optional()),refusal:r.string().optional(),functionCall:r.property("function_call",ye.optional())});var xp=r.object({role:r.string().optional(),content:r.string().optional(),reasoningContent:r.property("reasoning_content",r.string().optional()),toolCalls:r.property("tool_calls",r.list(jo).optional()),functionCall:r.property("function_call",ye.optional())});var _p=r.object({index:r.number().optional(),message:Sp.optional(),delta:xp.optional(),finishReason:r.property("finish_reason",r.string().optional())});var Tp=r.object({cachedTokens:r.property("cached_tokens",r.number().optional())});var Ap=r.object({reasoningTokens:r.property("reasoning_tokens",r.number().optional())});var Ep=r.object({totalTokens:r.property("total_tokens",r.number().optional()),promptTokens:r.property("prompt_tokens",r.number().optional()),promptTokensDetails:r.property("prompt_tokens_details",Tp.optional()),completionTokens:r.property("completion_tokens",r.number().optional()),completionTokensDetails:r.property("completion_tokens_details",Ap.optional())});var Pp=r.object({id:r.string().optional(),created:r.number().optional(),model:r.string().optional(),choices:r.list(_p).optional(),usage:Ep.optional(),systemFingerprint:r.property("system_fingerprint",r.string().optional()),serviceTier:r.property("service_tier",r.string().optional())});var vp=r.enum_(["private","public"]);var Zw=r.object({id:r.string().optional(),name:r.string(),visibility:vp.optional(),tags:r.list(r.string()).optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),experimentCount:r.property("experiment_count",r.number().optional()),datasetItemsCount:r.property("dataset_items_count",r.number().optional()),optimizationCount:r.property("optimization_count",r.number().optional()),mostRecentExperimentAt:r.property("most_recent_experiment_at",r.date().optional()),lastCreatedExperimentAt:r.property("last_created_experiment_at",r.date().optional()),mostRecentOptimizationAt:r.property("most_recent_optimization_at",r.date().optional()),lastCreatedOptimizationAt:r.property("last_created_optimization_at",r.date().optional())});var Cp=r.enum_(["manual","trace","span","sdk"]);var Uo=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:Cp,data:O,experimentItems:r.property("experiment_items",r.list(xr).optional()),datasetId:r.property("dataset_id",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var qw=r.object({datasetName:r.property("dataset_name",r.string().optional()),datasetId:r.property("dataset_id",r.string().optional()),items:r.list(Uo)});var Ip=r.object({generatedSamples:r.property("generated_samples",r.list(Uo).optional()),model:r.string().optional(),totalGenerated:r.property("total_generated",r.number().optional()),generationTime:r.property("generation_time",r.date().optional())});var ef=r.object({model:r.string(),sampleCount:r.property("sample_count",r.number().optional()),preserveFields:r.property("preserve_fields",r.list(r.string()).optional()),variationInstructions:r.property("variation_instructions",r.string().optional()),customPrompt:r.property("custom_prompt",r.string().optional())});var jp=r.enum_(["string","number","object","boolean","array","null"]);var Up=r.object({name:r.string().optional(),types:r.list(jp).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var Np=r.object({id:r.string().optional(),text:r.string(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Mp=r.enum_(["manual","trace","span","sdk"]);var vi=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var Dp=r.enum_(["ui","sdk","online_scoring"]);var Fp=r.enum_(["ui","sdk","online_scoring"]);var Op=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Fp.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Wp=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Dp,createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),valueByAuthor:r.property("value_by_author",r.record(r.string(),Op).optional())});var Bp=r.enum_(["default","hidden"]);var Lp=r.object({id:r.string().optional(),experimentId:r.property("experiment_id",r.string()),datasetItemId:r.property("dataset_item_id",r.string()),traceId:r.property("trace_id",r.string()),input:vi.optional(),output:vi.optional(),feedbackScores:r.property("feedback_scores",r.list(Wp).optional()),comments:r.list(Np).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),duration:r.number().optional(),usage:r.record(r.string(),r.number()).optional(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),traceVisibilityMode:r.property("trace_visibility_mode",Bp.optional())});var Vp=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:Mp,data:O,experimentItems:r.property("experiment_items",r.list(Lp).optional()),datasetId:r.property("dataset_id",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Hp=r.object({content:r.list(Vp).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),columns:r.list(Up).optional(),sortableBy:r.list(r.string()).optional()});var Jp=r.enum_(["private","public"]);var Qe=r.object({id:r.string().optional(),name:r.string(),visibility:Jp.optional(),tags:r.list(r.string()).optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),experimentCount:r.property("experiment_count",r.number().optional()),datasetItemsCount:r.property("dataset_items_count",r.number().optional()),optimizationCount:r.property("optimization_count",r.number().optional()),mostRecentExperimentAt:r.property("most_recent_experiment_at",r.date().optional()),lastCreatedExperimentAt:r.property("last_created_experiment_at",r.date().optional()),mostRecentOptimizationAt:r.property("most_recent_optimization_at",r.date().optional()),lastCreatedOptimizationAt:r.property("last_created_optimization_at",r.date().optional())});var Kp=r.object({content:r.list(Qe).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),sortableBy:r.list(r.string()).optional()});var Xp=r.object({value:r.number().optional()});var Gp=r.object({value:r.number().optional()});var No=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var $p=r.object({value:No.optional()});var Qp=r.object({name:r.string().optional()}),Yp=r.union("type",{PERCENTAGE:$p.extend(Qp),COUNT:Gp.extend(Qp),AVG:Xp.extend(Qp)}).transform({transform:n=>n,untransform:n=>n});var Ne=r.object({stats:r.list(Yp).optional()});var Zp=r.enum_(["manual","trace","span","sdk"]);var qp=r.enum_(["default","hidden"]);var Mo=r.object({id:r.string().optional(),experimentId:r.property("experiment_id",r.string()),datasetItemId:r.property("dataset_item_id",r.string()),traceId:r.property("trace_id",r.string()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),traceVisibilityMode:r.property("trace_visibility_mode",qp.optional())});var Do=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:Zp,data:O,experimentItems:r.property("experiment_items",r.list(Mo).optional()),datasetId:r.property("dataset_id",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ec=r.enum_(["string","number","object","boolean","array","null"]);var rc=r.object({name:r.string().optional(),types:r.list(ec).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var oc=r.object({content:r.list(Do).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),columns:r.list(rc).optional(),sortableBy:r.list(r.string()).optional()});var tc=r.enum_(["string","number","object","boolean","array","null"]);var ic=r.object({name:r.string().optional(),types:r.list(tc).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var ac=r.object({columns:r.list(ic).optional()});var nc=r.object({typeName:r.string().optional()});var rf=r.object({type:nc.optional(),closed:r.boolean().optional()});var sc=r.enum_(["regular","trial","mini-batch"]);var pc=r.enum_(["running","completed","cancelled"]);var ke=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var Ci=r.object({id:r.string(),commit:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),promptName:r.property("prompt_name",r.string().optional())});var of=r.object({id:r.string().optional(),datasetName:r.property("dataset_name",r.string()),datasetId:r.property("dataset_id",r.string().optional()),name:r.string().optional(),metadata:U.optional(),type:sc.optional(),optimizationId:r.property("optimization_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),comments:r.list(B).optional(),traceCount:r.property("trace_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),duration:ke.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostAvg:r.property("total_estimated_cost_avg",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),status:pc.optional(),promptVersion:r.property("prompt_version",Ci.optional()),promptVersions:r.property("prompt_versions",r.list(Ci).optional())});var Ye=r.object({ids:r.list(r.string())});var cc=r.enum_(["TOPIC","PII"]);var lc=r.enum_(["passed","failed"]);var mc=r.object({name:cc.optional(),result:lc.optional()});var dc=r.object({spanId:r.property("span_id",r.string().optional()),checks:r.list(mc).optional()});var uc=r.enum_(["default","hidden"]);var Fo=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:r.string().optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:U.optional(),output:U.optional(),metadata:U.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",be.optional()),usage:r.record(r.string(),r.number()).optional(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Y).optional()),comments:r.list(B).optional(),guardrailsValidations:r.property("guardrails_validations",r.list(dc).optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),spanCount:r.property("span_count",r.number().optional()),duration:r.number().optional(),threadId:r.property("thread_id",r.string().optional()),visibilityMode:r.property("visibility_mode",uc.optional()),llmSpanCount:r.property("llm_span_count",r.number().optional()),providers:r.list(r.string()).optional()});var gc=r.enum_(["general","tool","llm","guardrail"]);var Oo=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),traceId:r.property("trace_id",r.string().optional()),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:gc.optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:U.optional(),output:U.optional(),metadata:U.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),errorInfo:r.property("error_info",be.optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Y).optional()),comments:r.list(B).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostVersion:r.property("total_estimated_cost_version",r.string().optional()),duration:r.number().optional()});var wc=r.object({datasetItemId:r.property("dataset_item_id",r.string()),evaluateTaskResult:r.property("evaluate_task_result",U.optional()),trace:Fo.optional(),spans:r.list(Oo).optional(),feedbackScores:r.property("feedback_scores",r.list(Y).optional())});var tf=r.object({experimentName:r.property("experiment_name",r.string()),datasetName:r.property("dataset_name",r.string()),experimentId:r.property("experiment_id",r.string().optional()),items:r.list(wc)});var Me=r.object({id:r.string().optional(),text:r.string(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ae=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var fc=r.enum_(["regular","trial","mini-batch"]);var hc=r.enum_(["running","completed","cancelled"]);var Ii=r.object({id:r.string(),commit:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),promptName:r.property("prompt_name",r.string().optional())});var Wo=r.object({id:r.string().optional(),datasetName:r.property("dataset_name",r.string()),datasetId:r.property("dataset_id",r.string().optional()),name:r.string().optional(),metadata:ae.optional(),type:fc.optional(),optimizationId:r.property("optimization_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Ue).optional()),comments:r.list(Me).optional(),traceCount:r.property("trace_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),duration:No.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostAvg:r.property("total_estimated_cost_avg",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),status:hc.optional(),promptVersion:r.property("prompt_version",Ii.optional()),promptVersions:r.property("prompt_versions",r.list(Ii).optional())});var Rc=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Wo).optional(),sortableBy:r.list(r.string()).optional()});var bc=r.object({label:r.string().optional()});var yc=r.object({groupSorting:r.property("group_sorting",r.list(r.string()).optional())});var kc=r.object({groupsDetails:r.property("groups_details",r.list(yc).optional())});var zc=r.object({content:r.record(r.string(),bc).optional(),details:kc.optional()});var Sc=r.object({experimentCount:r.property("experiment_count",r.number().optional()),traceCount:r.property("trace_count",r.number().optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostAvg:r.property("total_estimated_cost_avg",r.number().optional()),duration:ke.optional(),feedbackScores:r.property("feedback_scores",r.list(ie).optional())});var xc=r.object({aggregations:Sc.optional()});var _c=r.object({content:r.record(r.string(),xc).optional()});var af=r.object({ids:r.list(r.string())});var Tc=r.object({typeName:r.string().optional()});var nf=r.object({type:Tc.optional(),closed:r.boolean().optional()});var Ac=r.object({trueLabel:r.string(),falseLabel:r.string()});var Ec=r.object({details:Ac.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Pc=r.object({categories:r.record(r.string(),r.number())});var vc=r.object({details:Pc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Cc=r.object({max:r.number(),min:r.number()});var Ic=r.object({details:Cc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var jc=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),createdAt:r.date().optional(),createdBy:r.string().optional(),lastUpdatedAt:r.date().optional(),lastUpdatedBy:r.string().optional()}),sf=r.union("type",{numerical:Ic.extend(jc),categorical:vc.extend(jc),boolean:Ec.extend(jc)}).transform({transform:n=>n,untransform:n=>n});var Uc=r.object({trueLabel:r.string(),falseLabel:r.string()});var Nc=r.object({details:Uc.optional()});var Mc=r.object({categories:r.record(r.string(),r.number())});var Dc=r.object({details:Mc.optional()});var Fc=r.object({max:r.number(),min:r.number()});var Oc=r.object({details:Fc.optional()});var Wc=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional()}),Bc=r.union("type",{numerical:Oc.extend(Wc),categorical:Dc.extend(Wc),boolean:Nc.extend(Wc)}).transform({transform:n=>n,untransform:n=>n});var Lc=r.object({trueLabel:r.string(),falseLabel:r.string()});var Bo=r.object({details:Lc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Vc=r.object({categories:r.record(r.string(),r.number())});var Lo=r.object({details:Vc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Hc=r.object({max:r.number(),min:r.number()});var Vo=r.object({details:Hc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Jc=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),createdAt:r.date().optional(),createdBy:r.string().optional(),lastUpdatedAt:r.date().optional(),lastUpdatedBy:r.string().optional()}),Kc=r.union("type",{numerical:Vo.extend(Jc),categorical:Lo.extend(Jc),boolean:Bo.extend(Jc)}).transform({transform:n=>n,untransform:n=>n});var Xc=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Kc).optional()});var Gc=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),createdAt:r.date().optional(),createdBy:r.string().optional(),lastUpdatedAt:r.date().optional(),lastUpdatedBy:r.string().optional()}),$c=r.union("type",{numerical:Vo.extend(Gc),categorical:Lo.extend(Gc),boolean:Bo.extend(Gc)}).transform({transform:n=>n,untransform:n=>n});var Qc=r.object({trueLabel:r.string(),falseLabel:r.string()});var Yc=r.object({details:Qc.optional()});var Zc=r.object({categories:r.record(r.string(),r.number())});var qc=r.object({details:Zc.optional()});var el=r.object({max:r.number(),min:r.number()});var rl=r.object({details:el.optional()});var ol=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional()}),tl=r.union("type",{numerical:rl.extend(ol),categorical:qc.extend(ol),boolean:Yc.extend(ol)}).transform({transform:n=>n,untransform:n=>n});var il=r.enum_(["TOPIC","PII"]);var al=r.enum_(["passed","failed"]);var nl=r.object({id:r.string().optional(),entityId:r.property("entity_id",r.string()),secondaryId:r.property("secondary_id",r.string()),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:il,result:al,config:O,details:O});var pf=r.object({guardrails:r.list(nl)});var sl=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var Ho=r.object({id:r.string().optional(),provider:sl,apiKey:r.property("api_key",r.string().optional()),name:r.string().optional(),providerName:r.property("provider_name",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),configuration:r.record(r.string(),r.string()).optional(),baseUrl:r.property("base_url",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var pl=r.object({size:r.number().optional(),total:r.number().optional(),content:r.list(Ho).optional(),sortableBy:r.list(r.string()).optional()});var cl=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var cf=r.object({id:r.string().optional(),provider:cl,apiKey:r.property("api_key",r.string().optional()),name:r.string().optional(),providerName:r.property("provider_name",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),configuration:r.record(r.string(),r.string()).optional(),baseUrl:r.property("base_url",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ji=r.object({entitiesQueued:r.property("entities_queued",r.number().optional()),rulesApplied:r.property("rules_applied",r.number().optional())});var ll=r.enum_(["trace","thread"]);var Ui=r.object({projectId:r.property("project_id",r.string()),entityIds:r.property("entity_ids",r.list(r.string())),ruleIds:r.property("rule_ids",r.list(r.string())),entityType:r.property("entity_type",ll)});var lf=O;var ml=r.enum_(["running","completed","cancelled"]);var mf=r.object({id:r.string().optional(),name:r.string().optional(),datasetName:r.property("dataset_name",r.string()),objectiveName:r.property("objective_name",r.string()),status:ml,metadata:U.optional(),datasetId:r.property("dataset_id",r.string().optional()),numTrials:r.property("num_trials",r.number().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var dl=r.enum_(["running","completed","cancelled"]);var Ni=r.object({id:r.string().optional(),name:r.string().optional(),datasetName:r.property("dataset_name",r.string()),objectiveName:r.property("objective_name",r.string()),status:dl,metadata:te.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var ul=r.enum_(["running","completed","cancelled"]);var Jo=r.object({id:r.string().optional(),name:r.string().optional(),datasetName:r.property("dataset_name",r.string()),objectiveName:r.property("objective_name",r.string()),status:ul,metadata:ae.optional(),datasetId:r.property("dataset_id",r.string().optional()),numTrials:r.property("num_trials",r.number().optional()),feedbackScores:r.property("feedback_scores",r.list(Ue).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var gl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Jo).optional(),sortableBy:r.list(r.string()).optional()});var Ko=r.object({count:r.number().optional(),deviation:r.number().optional(),deviationPercentage:r.property("deviation_percentage",r.number().optional())});var wl=r.enum_(["private","public"]);var df=r.object({id:r.string().optional(),name:r.string(),visibility:wl.optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),lastUpdatedTraceAt:r.property("last_updated_trace_at",r.date().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),duration:ke.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostSum:r.property("total_estimated_cost_sum",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),traceCount:r.property("trace_count",r.number().optional()),guardrailsFailedCount:r.property("guardrails_failed_count",r.number().optional()),errorCount:r.property("error_count",Ko.optional())});var fl=r.enum_(["private","public"]);var Xo=r.object({id:r.string().optional(),name:r.string(),visibility:fl.optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),lastUpdatedTraceAt:r.property("last_updated_trace_at",r.date().optional())});var hl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Xo).optional(),sortableBy:r.list(r.string()).optional()});var Rl=r.object({name:r.string().optional()});var bl=r.object({scores:r.list(Rl).optional()});var yl=r.object({time:r.date(),value:r.number().optional()});var kl=r.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST","GUARDRAILS_FAILED_COUNT","THREAD_COUNT","THREAD_DURATION","THREAD_FEEDBACK_SCORES"]);var zl=r.enum_(["HOURLY","DAILY","WEEKLY"]);var Sl=r.object({name:r.string().optional(),data:r.list(yl).optional()});var xl=r.object({projectId:r.property("project_id",r.string().optional()),metricType:r.property("metric_type",kl.optional()),interval:zl.optional(),results:r.list(Sl).optional()});var _l=r.object({projectId:r.property("project_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),duration:ke.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostSum:r.property("total_estimated_cost_sum",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),traceCount:r.property("trace_count",r.number().optional()),guardrailsFailedCount:r.property("guardrails_failed_count",r.number().optional()),errorCount:r.property("error_count",Ko.optional())});var Tl=r.object({content:r.list(_l).optional()});var Al=r.object({count:r.number().optional(),deviation:r.number().optional(),deviationPercentage:r.property("deviation_percentage",r.number().optional())});var El=r.object({name:r.string(),value:r.number()});var Pl=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var vl=r.enum_(["private","public"]);var Cl=r.object({id:r.string().optional(),name:r.string(),visibility:vl.optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),lastUpdatedTraceAt:r.property("last_updated_trace_at",r.date().optional()),feedbackScores:r.property("feedback_scores",r.list(El).optional()),duration:Pl.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostSum:r.property("total_estimated_cost_sum",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),traceCount:r.property("trace_count",r.number().optional()),guardrailsFailedCount:r.property("guardrails_failed_count",r.number().optional()),errorCount:r.property("error_count",Al.optional())});var uf=r.object({errors:r.list(r.string()).optional()});var Il=r.enum_(["mustache","jinja2"]);var jl=r.enum_(["mustache","jinja2"]);var Ul=r.object({id:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),commit:r.string().optional(),template:r.string(),metadata:O.optional(),type:jl.optional(),changeDescription:r.property("change_description",r.string().optional()),variables:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var gf=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),template:r.string().optional(),metadata:O.optional(),changeDescription:r.property("change_description",r.string().optional()),type:Il.optional(),tags:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),versionCount:r.property("version_count",r.number().optional()),latestVersion:r.property("latest_version",Ul.optional())});var wf=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var Nl=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),tags:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),versionCount:r.property("version_count",r.number().optional()),latestVersion:r.property("latest_version",fe.optional())});var Ml=r.record(r.string(),r.unknown());var Dl=r.enum_(["mustache","jinja2"]);var Fl=r.object({id:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),commit:r.string().optional(),template:r.string(),metadata:Ml.optional(),type:Dl.optional(),changeDescription:r.property("change_description",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var Ol=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Fl).optional()});var Wl=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),tags:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),versionCount:r.property("version_count",r.number().optional())});var Bl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Wl).optional(),sortableBy:r.list(r.string()).optional()});var Ll=r.object({pythonEvaluatorEnabled:r.boolean(),traceThreadPythonEvaluatorEnabled:r.boolean(),guardrailsEnabled:r.boolean(),opikAiEnabled:r.property("opikAIEnabled",r.boolean()),alertsEnabled:r.boolean(),welcomeWizardEnabled:r.boolean()});var ff=r.object({spans:r.list(Oo)});var Go=r.object({name:r.string(),author:r.string().optional()});var $o=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var Vl=r.enum_(["ui","sdk","online_scoring"]);var Hl=r.enum_(["ui","sdk","online_scoring"]);var Jl=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Hl.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Qo=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Vl,createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),valueByAuthor:r.property("value_by_author",r.record(r.string(),Jl).optional())});var Kl=r.enum_(["general","tool","llm","guardrail"]);var Yo=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),traceId:r.property("trace_id",r.string().optional()),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:Kl.optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:ae.optional(),output:ae.optional(),metadata:ae.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),errorInfo:r.property("error_info",$o.optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Qo).optional()),comments:r.list(Me).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostVersion:r.property("total_estimated_cost_version",r.string().optional()),duration:r.number().optional()});var Xl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Yo).optional(),sortableBy:r.list(r.string()).optional()});var Gl=r.enum_(["ui","sdk","online_scoring"]);var $l=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Gl,author:r.string().optional(),id:r.string()});var Zo=r.object({scores:r.list($l)});var hf=r.object({traces:r.list(Fo)});var Rf=r.object({ids:r.list(r.string()),projectId:r.property("project_id",r.string().optional())});var Ql=r.enum_(["TOPIC","PII"]);var Yl=r.enum_(["passed","failed"]);var Zl=r.object({name:Ql.optional(),result:Yl.optional()});var ql=r.object({spanId:r.property("span_id",r.string().optional()),checks:r.list(Zl).optional()});var em=r.enum_(["default","hidden"]);var qo=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string().optional()),name:r.string().optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:ae.optional(),output:ae.optional(),metadata:ae.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",$o.optional()),usage:r.record(r.string(),r.number()).optional(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Qo).optional()),comments:r.list(Me).optional(),guardrailsValidations:r.property("guardrails_validations",r.list(ql).optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),spanCount:r.property("span_count",r.number().optional()),duration:r.number().optional(),threadId:r.property("thread_id",r.string().optional()),visibilityMode:r.property("visibility_mode",em.optional()),llmSpanCount:r.property("llm_span_count",r.number().optional()),providers:r.list(r.string()).optional()});var rm=r.enum_(["active","inactive"]);var et=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string().optional()),threadModelId:r.property("thread_model_id",r.string().optional()),startTime:r.property("start_time",r.date().optional()),endTime:r.property("end_time",r.date().optional()),duration:r.number().optional(),firstMessage:r.property("first_message",U.optional()),lastMessage:r.property("last_message",U.optional()),feedbackScores:r.property("feedback_scores",r.list(Y).optional()),status:rm.optional(),numberOfMessages:r.property("number_of_messages",r.number().optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),comments:r.list(B).optional(),tags:r.list(r.string()).optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),createdBy:r.property("created_by",r.string().optional()),createdAt:r.property("created_at",r.date().optional())});var Mi=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),threadId:r.property("thread_id",r.string()),truncate:r.boolean().optional()});var om=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(et).optional(),sortableBy:r.list(r.string()).optional()});var tm=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(qo).optional(),sortableBy:r.list(r.string()).optional()});var im=r.object({completed:r.boolean().optional()});var De=r.object({name:r.string().optional(),current:r.number().optional(),previous:r.number().optional()});var Ze=r.object({projectIds:r.property("project_ids",r.list(r.string()).optional()),intervalStart:r.property("interval_start",r.date()),intervalEnd:r.property("interval_end",r.date()),startBeforeEnd:r.property("start_before_end",r.boolean().optional())});var bf=r.object({time:r.date(),value:r.number().optional()});var Di=r.object({results:r.list(De).optional()});var yf=r.object({projectIds:r.property("project_ids",r.list(r.string()).optional()),name:r.string().optional(),intervalStart:r.property("interval_start",r.date()),intervalEnd:r.property("interval_end",r.date()),startBeforeEnd:r.property("start_before_end",r.boolean().optional())});var rt=r.object({timeoutToMarkThreadAsInactive:r.property("timeout_to_mark_thread_as_inactive",r.string().optional()),truncationOnTables:r.property("truncation_on_tables",r.boolean().optional())});var am=r.object({results:r.list(De).optional()});var Fi=class{constructor(t={}){this._options=t;}getDatasetBiInfo(t){return f.fromPromise(this.__getDatasetBiInfo(t))}async __getDatasetBiInfo(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/internal/usage/bi-datasets"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:$e.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/bi-datasets.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getExperimentBiInfo(t){return f.fromPromise(this.__getExperimentBiInfo(t))}async __getExperimentBiInfo(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/internal/usage/bi-experiments"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:$e.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/bi-experiments.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getSpansBiInfo(t){return f.fromPromise(this.__getSpansBiInfo(t))}async __getSpansBiInfo(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/internal/usage/bi-spans"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:$e.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/bi-spans.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getSpansCountForWorkspaces(t){return f.fromPromise(this.__getSpansCountForWorkspaces(t))}async __getSpansCountForWorkspaces(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/internal/usage/workspace-span-counts"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:es.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/workspace-span-counts.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getTracesBiInfo(t){return f.fromPromise(this.__getTracesBiInfo(t))}async __getTracesBiInfo(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/internal/usage/bi-traces"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:$e.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/bi-traces.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getTracesCountForWorkspaces(t){return f.fromPromise(this.__getTracesCountForWorkspaces(t))}async __getTracesCountForWorkspaces(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/internal/usage/workspace-trace-counts"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:os.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/workspace-trace-counts.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Oi=class{constructor(t={}){this._options=t;}findAlerts(t={},e){return f.fromPromise(this.__findAlerts(t,e))}async __findAlerts(t={},e){var g,y;let{page:o,size:i,sorting:a,filters:c}=t,d={};o!=null&&(d.page=o.toString()),i!=null&&(d.size=i.toString()),a!=null&&(d.sorting=a),c!=null&&(d.filters=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/private/alerts"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:ks.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse});switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/alerts.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}createAlert(t,e){return f.fromPromise(this.__createAlert(t,e))}async __createAlert(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/alerts"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:mo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 409:throw new L(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/alerts.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteAlertBatch(t,e){return f.fromPromise(this.__deleteAlertBatch(t,e))}async __deleteAlertBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/alerts/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/alerts/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getAlertById(t,e){return f.fromPromise(this.__getAlertById(t,e))}async __getAlertById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/alerts/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:uo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/alerts/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateAlert(t,e,o){return f.fromPromise(this.__updateAlert(t,e,o))}async __updateAlert(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/alerts/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:mo.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);case 409:throw new L(i.error.body,i.rawResponse);case 422:throw new F(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/alerts/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getWebhookExamples(t={},e){return f.fromPromise(this.__getWebhookExamples(t,e))}async __getWebhookExamples(t={},e){var c,d;let{alertType:o}=t,i={};o!=null&&(i.alert_type=Mt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}));let a=await R({url:b((d=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?d:h.Default,"v1/private/alerts/webhooks/examples"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:zs.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/alerts/webhooks/examples.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}testWebhook(t,e){return f.fromPromise(this.__testWebhook(t,e))}async __testWebhook(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/alerts/webhooks/tests"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:mo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:xs.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/alerts/webhooks/tests.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Wi=class{constructor(t={}){this._options=t;}addItemsToAnnotationQueue(t,e,o){return f.fromPromise(this.__addItemsToAnnotationQueue(t,e,o))}async __addItemsToAnnotationQueue(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/annotation-queues/${encodeURIComponent(t)}/items/add`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:Si.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues/{id}/items/add.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}findAnnotationQueues(t={},e){return f.fromPromise(this.__findAnnotationQueues(t,e))}async __findAnnotationQueues(t={},e){var y,k;let{page:o,size:i,name:a,filters:c,sorting:d}=t,u={};o!=null&&(u.page=o.toString()),i!=null&&(u.size=i.toString()),a!=null&&(u.name=a),c!=null&&(u.filters=c),d!=null&&(u.sorting=d);let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:h.Default,"v1/private/annotation-queues"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(g.ok)return {data:vs.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse});switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/annotation-queues.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}createAnnotationQueue(t,e){return f.fromPromise(this.__createAnnotationQueue(t,e))}async __createAnnotationQueue(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/annotation-queues"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:io.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createAnnotationQueueBatch(t,e){return f.fromPromise(this.__createAnnotationQueueBatch(t,e))}async __createAnnotationQueueBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/annotation-queues/batch"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ao.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 409:throw new L(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues/batch.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteAnnotationQueueBatch(t,e){return f.fromPromise(this.__deleteAnnotationQueueBatch(t,e))}async __deleteAnnotationQueueBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/annotation-queues/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getAnnotationQueueById(t,e){return f.fromPromise(this.__getAnnotationQueueById(t,e))}async __getAnnotationQueueById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/annotation-queues/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:go.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/annotation-queues/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateAnnotationQueue(t,e={},o){return f.fromPromise(this.__updateAnnotationQueue(t,e,o))}async __updateAnnotationQueue(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/annotation-queues/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:no.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/annotation-queues/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}removeItemsFromAnnotationQueue(t,e,o){return f.fromPromise(this.__removeItemsFromAnnotationQueue(t,e,o))}async __removeItemsFromAnnotationQueue(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/annotation-queues/${encodeURIComponent(t)}/items/delete`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:Si.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues/{id}/items/delete.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Bi=class{constructor(t={}){this._options=t;}attachmentList(t,e){return f.fromPromise(this.__attachmentList(t,e))}async __attachmentList(t,e){var k,S;let{page:o,size:i,projectId:a,entityType:c,entityId:d,path:u}=t,g={};o!=null&&(g.page=o.toString()),i!=null&&(g.size=i.toString()),g.project_id=a,g.entity_type=Ft.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"}),g.entity_id=d,g.path=u;let y=await R({url:b((S=(k=await s.get(this._options.baseUrl))!=null?k:await s.get(this._options.environment))!=null?S:h.Default,"v1/private/attachment/list"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:g,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(y.ok)return {data:Is.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new K(y.error.body,y.rawResponse);case 403:throw new $(ee.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new p({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}switch(y.error.reason){case "non-json":throw new p({statusCode:y.error.statusCode,body:y.error.rawBody,rawResponse:y.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/attachment/list.");case "unknown":throw new p({message:y.error.errorMessage,rawResponse:y.rawResponse})}}completeMultiPartUpload(t,e){return f.fromPromise(this.__completeMultiPartUpload(t,e))}async __completeMultiPartUpload(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/attachment/upload-complete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:xi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new K(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/attachment/upload-complete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteAttachments(t,e){return f.fromPromise(this.__deleteAttachments(t,e))}async __deleteAttachments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/attachment/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:xi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new K(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/attachment/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}downloadAttachment(t,e){return f.fromPromise(this.__downloadAttachment(t,e))}async __downloadAttachment(t,e){var k,S;let{workspaceName:o,containerId:i,entityType:a,entityId:c,fileName:d,mimeType:u}=t,g={};o!=null&&(g.workspace_name=o),g.container_id=i,g.entity_type=Ot.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}),g.entity_id=c,g.file_name=d,g.mime_type=u;let y=await R({url:b((S=(k=await s.get(this._options.baseUrl))!=null?k:await s.get(this._options.environment))!=null?S:h.Default,"v1/private/attachment/download"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:g,requestType:"json",responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(y.ok)return {data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new K(y.error.body,y.rawResponse);case 403:throw new $(ee.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new p({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}switch(y.error.reason){case "non-json":throw new p({statusCode:y.error.statusCode,body:y.error.rawBody,rawResponse:y.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/attachment/download.");case "unknown":throw new p({message:y.error.errorMessage,rawResponse:y.rawResponse})}}startMultiPartUpload(t,e){return f.fromPromise(this.__startMultiPartUpload(t,e))}async __startMultiPartUpload(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/attachment/upload-start"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:dr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Ms.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new K(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/attachment/upload-start.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}uploadAttachment(t,e){return f.fromPromise(this.__uploadAttachment(t,e))}async __uploadAttachment(t,e){var k,S;let{fileName:o,projectName:i,mimeType:a,entityType:c,entityId:d,body:u}=t,g={};g.file_name=o,i!=null&&(g.project_name=i),a!=null&&(g.mime_type=a),g.entity_type=Bt.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"}),g.entity_id=d;let y=await R({url:b((S=(k=await s.get(this._options.baseUrl))!=null?k:await s.get(this._options.environment))!=null?S:h.Default,"v1/private/attachment/upload"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:g,requestType:"json",body:Ke.uploadAttachment.Request.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(y.ok)return {data:void 0,rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new K(y.error.body,y.rawResponse);case 403:throw new $(ee.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new p({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}switch(y.error.reason){case "non-json":throw new p({statusCode:y.error.statusCode,body:y.error.rawBody,rawResponse:y.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/attachment/upload.");case "unknown":throw new p({message:y.error.errorMessage,rawResponse:y.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Li=class{constructor(t={}){this._options=t;}access(t,e){return f.fromPromise(this.__access(t,e))}async __access(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/auth"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ds.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new K(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/auth.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getWorkspaceName(t){return f.fromPromise(this.__getWorkspaceName(t))}async __getWorkspaceName(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/auth/workspace"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:Fs.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")switch(e.error.statusCode){case 401:throw new K(e.error.body,e.rawResponse);case 403:throw new $(ee.parseOrThrow(e.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),e.rawResponse);default:throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse})}switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/auth/workspace.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Vi=class{constructor(t={}){this._options=t;}findEvaluators(t={},e){return f.fromPromise(this.__findEvaluators(t,e))}async __findEvaluators(t={},e){var S,x;let{projectId:o,id:i,name:a,filters:c,sorting:d,page:u,size:g}=t,y={};o!=null&&(y.project_id=o),i!=null&&(y.id=i),a!=null&&(y.name=a),c!=null&&(y.filters=c),d!=null&&(y.sorting=d),u!=null&&(y.page=u.toString()),g!=null&&(y.size=g.toString());let k=await R({url:b((x=(S=await s.get(this._options.baseUrl))!=null?S:await s.get(this._options.environment))!=null?x:h.Default,"v1/private/automations/evaluators"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:y,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(k.ok)return {data:dp.parseOrThrow(k.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:k.rawResponse};if(k.error.reason==="status-code")throw new p({statusCode:k.error.statusCode,body:k.error.body,rawResponse:k.rawResponse});switch(k.error.reason){case "non-json":throw new p({statusCode:k.error.statusCode,body:k.error.rawBody,rawResponse:k.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/automations/evaluators.");case "unknown":throw new p({message:k.error.errorMessage,rawResponse:k.rawResponse})}}createAutomationRuleEvaluator(t,e){return f.fromPromise(this.__createAutomationRuleEvaluator(t,e))}async __createAutomationRuleEvaluator(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/automations/evaluators"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ip.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/automations/evaluators.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteAutomationRuleEvaluatorBatch(t,e){return f.fromPromise(this.__deleteAutomationRuleEvaluatorBatch(t,e))}async __deleteAutomationRuleEvaluatorBatch(t,e){var d,u;let{projectId:o,body:i}=t,a={};o!=null&&(a.project_id=o);let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,"v1/private/automations/evaluators/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:a,requestType:"json",body:W.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(c.ok)return {data:void 0,rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/automations/evaluators/delete.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}getEvaluatorById(t,e={},o){return f.fromPromise(this.__getEvaluatorById(t,e,o))}async __getEvaluatorById(t,e={},o){var d,u;let{projectId:i}=e,a={};i!=null&&(a.project_id=i);let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:a,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(c.ok)return {data:up.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/automations/evaluators/{id}.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}updateAutomationRuleEvaluator(t,e,o){return f.fromPromise(this.__updateAutomationRuleEvaluator(t,e,o))}async __updateAutomationRuleEvaluator(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:kp.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/automations/evaluators/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getEvaluatorLogsById(t,e={},o){return f.fromPromise(this.__getEvaluatorLogsById(t,e,o))}async __getEvaluatorLogsById(t,e={},o){var d,u;let{size:i}=e,a={};i!=null&&(a.size=i.toString());let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}/logs`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:a,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(c.ok)return {data:fp.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/automations/evaluators/{id}/logs.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Hi=class{constructor(t={}){this._options=t;}createChatCompletions(t={},e){return f.fromPromise(this.__createChatCompletions(t,e))}async __createChatCompletions(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/chat/completions"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:po.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Pp.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/chat/completions.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Ji=class{constructor(t={}){this._options=t;}findDatasets(t={},e){return f.fromPromise(this.__findDatasets(t,e))}async __findDatasets(t={},e){var x,_;let{page:o,size:i,withExperimentsOnly:a,withOptimizationsOnly:c,promptId:d,name:u,sorting:g,filters:y}=t,k={};o!=null&&(k.page=o.toString()),i!=null&&(k.size=i.toString()),a!=null&&(k.with_experiments_only=a.toString()),c!=null&&(k.with_optimizations_only=c.toString()),d!=null&&(k.prompt_id=d),u!=null&&(k.name=u),g!=null&&(k.sorting=g),y!=null&&(k.filters=y);let S=await R({url:b((_=(x=await s.get(this._options.baseUrl))!=null?x:await s.get(this._options.environment))!=null?_:h.Default,"v1/private/datasets"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:k,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(S.ok)return {data:Kp.parseOrThrow(S.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:S.rawResponse};if(S.error.reason==="status-code")throw new p({statusCode:S.error.statusCode,body:S.error.body,rawResponse:S.rawResponse});switch(S.error.reason){case "non-json":throw new p({statusCode:S.error.statusCode,body:S.error.rawBody,rawResponse:S.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets.");case "unknown":throw new p({message:S.error.errorMessage,rawResponse:S.rawResponse})}}createDataset(t,e){return f.fromPromise(this.__createDataset(t,e))}async __createDataset(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ur.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createOrUpdateDatasetItems(t,e){return f.fromPromise(this.__createOrUpdateDatasetItems(t,e))}async __createOrUpdateDatasetItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets/items"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:gr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/datasets/items.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createDatasetItemsFromSpans(t,e,o){return f.fromPromise(this.__createDatasetItemsFromSpans(t,e,o))}async __createDatasetItemsFromSpans(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/from-spans`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:wr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/{dataset_id}/items/from-spans.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}createDatasetItemsFromTraces(t,e,o){return f.fromPromise(this.__createDatasetItemsFromTraces(t,e,o))}async __createDatasetItemsFromTraces(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/from-traces`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:fr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/{dataset_id}/items/from-traces.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getDatasetById(t,e){return f.fromPromise(this.__getDatasetById(t,e))}async __getDatasetById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Qe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateDataset(t,e,o){return f.fromPromise(this.__updateDataset(t,e,o))}async __updateDataset(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:hr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/datasets/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteDataset(t,e){return f.fromPromise(this.__deleteDataset(t,e))}async __deleteDataset(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/datasets/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteDatasetByName(t,e){return f.fromPromise(this.__deleteDatasetByName(t,e))}async __deleteDatasetByName(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Rr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteDatasetItems(t,e){return f.fromPromise(this.__deleteDatasetItems(t,e))}async __deleteDatasetItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets/items/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:br.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/items/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteDatasetsBatch(t,e){return f.fromPromise(this.__deleteDatasetsBatch(t,e))}async __deleteDatasetsBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets/delete-batch"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/delete-batch.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}expandDataset(t,e,o){return f.fromPromise(this.__expandDataset(t,e,o))}async __expandDataset(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/expansions`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:yr.jsonOrThrow(e,{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(i.ok)return {data:Ip.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/{id}/expansions.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}findDatasetItemsWithExperimentItems(t,e,o){return f.fromPromise(this.__findDatasetItemsWithExperimentItems(t,e,o))}async __findDatasetItemsWithExperimentItems(t,e,o){var x,_;let{page:i,size:a,experimentIds:c,filters:d,sorting:u,search:g,truncate:y}=e,k={};i!=null&&(k.page=i.toString()),a!=null&&(k.size=a.toString()),k.experiment_ids=c,d!=null&&(k.filters=d),u!=null&&(k.sorting=u),g!=null&&(k.search=g),y!=null&&(k.truncate=y.toString());let S=await R({url:b((_=(x=await s.get(this._options.baseUrl))!=null?x:await s.get(this._options.environment))!=null?_:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:k,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(S.ok)return {data:Hp.parseOrThrow(S.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:S.rawResponse};if(S.error.reason==="status-code")throw new p({statusCode:S.error.statusCode,body:S.error.body,rawResponse:S.rawResponse});switch(S.error.reason){case "non-json":throw new p({statusCode:S.error.statusCode,body:S.error.rawBody,rawResponse:S.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items.");case "unknown":throw new p({message:S.error.errorMessage,rawResponse:S.rawResponse})}}getDatasetByIdentifier(t,e){return f.fromPromise(this.__getDatasetByIdentifier(t,e))}async __getDatasetByIdentifier(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets/retrieve"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:kr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Qe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/retrieve.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getDatasetExperimentItemsStats(t,e,o){return f.fromPromise(this.__getDatasetExperimentItemsStats(t,e,o))}async __getDatasetExperimentItemsStats(t,e,o){var u,g;let{experimentIds:i,filters:a}=e,c={};c.experiment_ids=i,a!=null&&(c.filters=a);let d=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items/stats`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:c,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 {data:Ne.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")throw new p({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse});switch(d.error.reason){case "non-json":throw new p({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items/stats.");case "unknown":throw new p({message:d.error.errorMessage,rawResponse:d.rawResponse})}}getDatasetItemById(t,e){return f.fromPromise(this.__getDatasetItemById(t,e))}async __getDatasetItemById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/datasets/items/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Do.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/items/{itemId}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getDatasetItems(t,e={},o){return f.fromPromise(this.__getDatasetItems(t,e,o))}async __getDatasetItems(t,e={},o){var y,k;let{page:i,size:a,filters:c,truncate:d}=e,u={};i!=null&&(u.page=i.toString()),a!=null&&(u.size=a.toString()),c!=null&&(u.filters=c),d!=null&&(u.truncate=d.toString());let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/items`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:u,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(g.ok)return {data:oc.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse});switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}getDatasetItemsOutputColumns(t,e={},o){return f.fromPromise(this.__getDatasetItemsOutputColumns(t,e,o))}async __getDatasetItemsOutputColumns(t,e={},o){var d,u;let{experimentIds:i}=e,a={};i!=null&&(a.experiment_ids=i);let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items/output/columns`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:a,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(c.ok)return {data:ac.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items/output/columns.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}streamDatasetItems(t,e){return f.fromPromise(this.__streamDatasetItems(t,e))}async __streamDatasetItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets/items/stream"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:zr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/items/stream.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Ki=class{constructor(t={}){this._options=t;}findExperiments(t={},e){return f.fromPromise(this.__findExperiments(t,e))}async __findExperiments(t={},e){var M,N;let{page:o,size:i,datasetId:a,optimizationId:c,types:d,name:u,datasetDeleted:g,promptId:y,sorting:k,filters:S}=t,x={};o!=null&&(x.page=o.toString()),i!=null&&(x.size=i.toString()),a!=null&&(x.datasetId=a),c!=null&&(x.optimization_id=c),d!=null&&(x.types=d),u!=null&&(x.name=u),g!=null&&(x.dataset_deleted=g.toString()),y!=null&&(x.prompt_id=y),k!=null&&(x.sorting=k),S!=null&&(x.filters=S);let _=await R({url:b((N=(M=await s.get(this._options.baseUrl))!=null?M:await s.get(this._options.environment))!=null?N:h.Default,"v1/private/experiments"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:x,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(_.ok)return {data:Rc.parseOrThrow(_.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:_.rawResponse};if(_.error.reason==="status-code")switch(_.error.statusCode){case 400:throw new T(_.error.body,_.rawResponse);default:throw new p({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse})}switch(_.error.reason){case "non-json":throw new p({statusCode:_.error.statusCode,body:_.error.rawBody,rawResponse:_.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments.");case "unknown":throw new p({message:_.error.errorMessage,rawResponse:_.rawResponse})}}createExperiment(t,e){return f.fromPromise(this.__createExperiment(t,e))}async __createExperiment(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Sr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createExperimentItems(t,e){return f.fromPromise(this.__createExperimentItems(t,e))}async __createExperimentItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/items"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:_r.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/items.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteExperimentItems(t,e){return f.fromPromise(this.__deleteExperimentItems(t,e))}async __deleteExperimentItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/items/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Tr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/items/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteExperimentsById(t,e){return f.fromPromise(this.__deleteExperimentsById(t,e))}async __deleteExperimentsById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ye.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}experimentItemsBulk(t,e){return f.fromPromise(this.__experimentItemsBulk(t,e))}async __experimentItemsBulk(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/items/bulk"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Er.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 409:throw new L(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/experiments/items/bulk.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}findFeedbackScoreNames(t={},e){return f.fromPromise(this.__findFeedbackScoreNames(t,e))}async __findFeedbackScoreNames(t={},e){var c,d;let{experimentIds:o}=t,i={};o!=null&&(i.experiment_ids=o);let a=await R({url:b((d=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?d:h.Default,"v1/private/experiments/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:Xe.findFeedbackScoreNames.Response.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/feedback-scores/names.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}findExperimentGroups(t={},e){return f.fromPromise(this.__findExperimentGroups(t,e))}async __findExperimentGroups(t={},e){var g,y;let{groups:o,types:i,name:a,filters:c}=t,d={};o!=null&&(d.groups=o),i!=null&&(d.types=i),a!=null&&(d.name=a),c!=null&&(d.filters=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/private/experiments/groups"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:zc.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new T(u.error.body,u.rawResponse);default:throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/groups.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}findExperimentGroupsAggregations(t={},e){return f.fromPromise(this.__findExperimentGroupsAggregations(t,e))}async __findExperimentGroupsAggregations(t={},e){var g,y;let{groups:o,types:i,name:a,filters:c}=t,d={};o!=null&&(d.groups=o),i!=null&&(d.types=i),a!=null&&(d.name=a),c!=null&&(d.filters=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/private/experiments/groups/aggregations"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:_c.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new T(u.error.body,u.rawResponse);default:throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/groups/aggregations.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}finishExperiments(t,e){return f.fromPromise(this.__finishExperiments(t,e))}async __finishExperiments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/finish"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ye.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/finish.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getExperimentById(t,e){return f.fromPromise(this.__getExperimentById(t,e))}async __getExperimentById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/experiments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Wo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateExperiment(t,e={},o){return f.fromPromise(this.__updateExperiment(t,e,o))}async __updateExperiment(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/experiments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:Pr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/experiments/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getExperimentItemById(t,e){return f.fromPromise(this.__getExperimentItemById(t,e))}async __getExperimentItemById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/experiments/items/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Mo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/items/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}streamExperimentItems(t,e){return f.fromPromise(this.__streamExperimentItems(t,e))}async __streamExperimentItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/items/stream"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:vr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/items/stream.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}streamExperiments(t,e){return f.fromPromise(this.__streamExperiments(t,e))}async __streamExperiments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/stream"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Cr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/stream.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Xi=class{constructor(t={}){this._options=t;}findFeedbackDefinitions(t={},e){return f.fromPromise(this.__findFeedbackDefinitions(t,e))}async __findFeedbackDefinitions(t={},e){var g,y;let{page:o,size:i,name:a,type:c}=t,d={};o!=null&&(d.page=o.toString()),i!=null&&(d.size=i.toString()),a!=null&&(d.name=a),c!=null&&(d.type=Zt.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"}));let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/private/feedback-definitions"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:Xc.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse});switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/feedback-definitions.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}createFeedbackDefinition(t,e){return f.fromPromise(this.__createFeedbackDefinition(t,e))}async __createFeedbackDefinition(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/feedback-definitions"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Bc.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/feedback-definitions.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getFeedbackDefinitionById(t,e){return f.fromPromise(this.__getFeedbackDefinitionById(t,e))}async __getFeedbackDefinitionById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:$c.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/feedback-definitions/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateFeedbackDefinition(t,e,o){return f.fromPromise(this.__updateFeedbackDefinition(t,e,o))}async __updateFeedbackDefinition(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:tl.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/feedback-definitions/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteFeedbackDefinitionById(t,e){return f.fromPromise(this.__deleteFeedbackDefinitionById(t,e))}async __deleteFeedbackDefinitionById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new L(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/feedback-definitions/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteFeedbackDefinitionsBatch(t,e){return f.fromPromise(this.__deleteFeedbackDefinitionsBatch(t,e))}async __deleteFeedbackDefinitionsBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/feedback-definitions/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new L(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/feedback-definitions/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Gi=class{constructor(t={}){this._options=t;}createGuardrails(t,e){return f.fromPromise(this.__createGuardrails(t,e))}async __createGuardrails(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/guardrails"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:co.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/guardrails.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var $i=class{constructor(t={}){this._options=t;}deleteLlmProviderApiKeysBatch(t,e){return f.fromPromise(this.__deleteLlmProviderApiKeysBatch(t,e))}async __deleteLlmProviderApiKeysBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/llm-provider-key/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/llm-provider-key/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}findLlmProviderKeys(t){return f.fromPromise(this.__findLlmProviderKeys(t))}async __findLlmProviderKeys(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/llm-provider-key"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:pl.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/llm-provider-key.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}storeLlmProviderApiKey(t,e){return f.fromPromise(this.__storeLlmProviderApiKey(t,e))}async __storeLlmProviderApiKey(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/llm-provider-key"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ir.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new K(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/llm-provider-key.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getLlmProviderApiKeyById(t,e){return f.fromPromise(this.__getLlmProviderApiKeyById(t,e))}async __getLlmProviderApiKeyById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/llm-provider-key/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Ho.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/llm-provider-key/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateLlmProviderApiKey(t,e={},o){return f.fromPromise(this.__updateLlmProviderApiKey(t,e,o))}async __updateLlmProviderApiKey(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/llm-provider-key/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:jr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 401:throw new K(i.error.body,i.rawResponse);case 403:throw new $(ee.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/llm-provider-key/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Qi=class{constructor(t={}){this._options=t;}evaluateThreads(t,e){return f.fromPromise(this.__evaluateThreads(t,e))}async __evaluateThreads(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/manual-evaluation/threads"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ui.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:ji.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/manual-evaluation/threads.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}evaluateTraces(t,e){return f.fromPromise(this.__evaluateTraces(t,e))}async __evaluateTraces(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/manual-evaluation/traces"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ui.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:ji.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/manual-evaluation/traces.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Yi=class{constructor(t={}){this._options=t;}receiveProtobufTraces(t){return f.fromPromise(this.__receiveProtobufTraces(t))}async __receiveProtobufTraces(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/otel/v1/traces"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:e.body,rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/otel/v1/traces.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Zi=class{constructor(t={}){this._options=t;}findOptimizations(t={},e){return f.fromPromise(this.__findOptimizations(t,e))}async __findOptimizations(t={},e){var y,k;let{page:o,size:i,datasetId:a,name:c,datasetDeleted:d}=t,u={};o!=null&&(u.page=o.toString()),i!=null&&(u.size=i.toString()),a!=null&&(u.dataset_id=a),c!=null&&(u.name=c),d!=null&&(u.dataset_deleted=d.toString());let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:h.Default,"v1/private/optimizations"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(g.ok)return {data:gl.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new T(g.error.body,g.rawResponse);default:throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/optimizations.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}createOptimization(t,e){return f.fromPromise(this.__createOptimization(t,e))}async __createOptimization(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/optimizations"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ni.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/optimizations.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}upsertOptimization(t,e){return f.fromPromise(this.__upsertOptimization(t,e))}async __upsertOptimization(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/optimizations"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ni.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/optimizations.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteOptimizationsById(t,e){return f.fromPromise(this.__deleteOptimizationsById(t,e))}async __deleteOptimizationsById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/optimizations/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ye.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/optimizations/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getOptimizationById(t,e){return f.fromPromise(this.__getOptimizationById(t,e))}async __getOptimizationById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/optimizations/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Jo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/optimizations/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateOptimizationsById(t,e={},o){return f.fromPromise(this.__updateOptimizationsById(t,e,o))}async __updateOptimizationsById(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/optimizations/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:Ur.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/optimizations/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var qi=class{constructor(t={}){this._options=t;}findProjects(t={},e){return f.fromPromise(this.__findProjects(t,e))}async __findProjects(t={},e){var g,y;let{page:o,size:i,name:a,sorting:c}=t,d={};o!=null&&(d.page=o.toString()),i!=null&&(d.size=i.toString()),a!=null&&(d.name=a),c!=null&&(d.sorting=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/private/projects"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:hl.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse});switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/projects.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}createProject(t,e){return f.fromPromise(this.__createProject(t,e))}async __createProject(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/projects"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Nr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/projects.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getProjectById(t,e){return f.fromPromise(this.__getProjectById(t,e))}async __getProjectById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Xo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/projects/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteProjectById(t,e){return f.fromPromise(this.__deleteProjectById(t,e))}async __deleteProjectById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new L(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/projects/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateProject(t,e={},o){return f.fromPromise(this.__updateProject(t,e,o))}async __updateProject(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:Mr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);case 422:throw new F(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/projects/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteProjectsBatch(t,e){return f.fromPromise(this.__deleteProjectsBatch(t,e))}async __deleteProjectsBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/projects/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/projects/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}findFeedbackScoreNamesByProjectIds(t={},e){return f.fromPromise(this.__findFeedbackScoreNamesByProjectIds(t,e))}async __findFeedbackScoreNamesByProjectIds(t={},e){var c,d;let{projectIds:o}=t,i={};o!=null&&(i.project_ids=o);let a=await R({url:b((d=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?d:h.Default,"v1/private/projects/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:bl.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/projects/feedback-scores/names.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}getProjectMetrics(t,e={},o){return f.fromPromise(this.__getProjectMetrics(t,e,o))}async __getProjectMetrics(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/projects/${encodeURIComponent(t)}/metrics`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e,{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(i.ok)return {data:xl.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/projects/{id}/metrics.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getProjectStats(t={},e){return f.fromPromise(this.__getProjectStats(t,e))}async __getProjectStats(t={},e){var g,y;let{page:o,size:i,name:a,sorting:c}=t,d={};o!=null&&(d.page=o.toString()),i!=null&&(d.size=i.toString()),a!=null&&(d.name=a),c!=null&&(d.sorting=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/private/projects/stats"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:Tl.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse});switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/projects/stats.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}retrieveProject(t,e){return f.fromPromise(this.__retrieveProject(t,e))}async __retrieveProject(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/projects/retrieve"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Fr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Cl.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 404:throw new A(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/projects/retrieve.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ea=class{constructor(t={}){this._options=t;}getPrompts(t={},e){return f.fromPromise(this.__getPrompts(t,e))}async __getPrompts(t={},e){var y,k;let{page:o,size:i,name:a,sorting:c,filters:d}=t,u={};o!=null&&(u.page=o.toString()),i!=null&&(u.size=i.toString()),a!=null&&(u.name=a),c!=null&&(u.sorting=c),d!=null&&(u.filters=d);let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:h.Default,"v1/private/prompts"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(g.ok)return {data:Bl.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse});switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/prompts.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}createPrompt(t,e){return f.fromPromise(this.__createPrompt(t,e))}async __createPrompt(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/prompts"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Or.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 409:throw new L(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createPromptVersion(t,e){return f.fromPromise(this.__createPromptVersion(t,e))}async __createPromptVersion(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/prompts/versions"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Wr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:fe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 409:throw new L(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts/versions.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getPromptById(t,e){return f.fromPromise(this.__getPromptById(t,e))}async __getPromptById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Nl.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/prompts/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updatePrompt(t,e,o){return f.fromPromise(this.__updatePrompt(t,e,o))}async __updatePrompt(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:Br.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);case 404:throw new A(i.error.body,i.rawResponse);case 409:throw new L(i.error.body,i.rawResponse);case 422:throw new F(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/prompts/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deletePrompt(t,e){return f.fromPromise(this.__deletePrompt(t,e))}async __deletePrompt(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/prompts/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deletePromptsBatch(t,e){return f.fromPromise(this.__deletePromptsBatch(t,e))}async __deletePromptsBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/prompts/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getPromptVersionById(t,e){return f.fromPromise(this.__getPromptVersionById(t,e))}async __getPromptVersionById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/prompts/versions/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:fe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/prompts/versions/{versionId}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getPromptVersions(t,e={},o){return f.fromPromise(this.__getPromptVersions(t,e,o))}async __getPromptVersions(t,e={},o){var u,g;let{page:i,size:a}=e,c={};i!=null&&(c.page=i.toString()),a!=null&&(c.size=a.toString());let d=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:h.Default,`v1/private/prompts/${encodeURIComponent(t)}/versions`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:c,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 {data:Ol.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")throw new p({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse});switch(d.error.reason){case "non-json":throw new p({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/prompts/{id}/versions.");case "unknown":throw new p({message:d.error.errorMessage,rawResponse:d.rawResponse})}}restorePromptVersion(t,e,o){return f.fromPromise(this.__restorePromptVersion(t,e,o))}async __restorePromptVersion(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/prompts/${encodeURIComponent(t)}/versions/${encodeURIComponent(e)}/restore`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(i.ok)return {data:fe.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts/{promptId}/versions/{versionId}/restore.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}retrievePromptVersion(t,e){return f.fromPromise(this.__retrievePromptVersion(t,e))}async __retrievePromptVersion(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/prompts/versions/retrieve"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Lr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:fe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 404:throw new A(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts/versions/retrieve.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ra=class{constructor(t={}){this._options=t;}getServiceToggles(t){return f.fromPromise(this.__getServiceToggles(t))}async __getServiceToggles(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/toggles"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:Ll.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/toggles.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var oa=class{constructor(t={}){this._options=t;}addSpanComment(t,e,o){return f.fromPromise(this.__addSpanComment(t,e,o))}async __addSpanComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/spans/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:B.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/{id}/comments.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}addSpanFeedbackScore(t,e,o){return f.fromPromise(this.__addSpanFeedbackScore(t,e,o))}async __addSpanFeedbackScore(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/spans/${encodeURIComponent(t)}/feedback-scores`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:Y.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/spans/{id}/feedback-scores.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getSpansByProject(t={},e){return f.fromPromise(this.__getSpansByProject(t,e))}async __getSpansByProject(t={},e){var q,Be;let{page:o,size:i,projectName:a,projectId:c,traceId:d,type:u,filters:g,truncate:y,stripAttachments:k,sorting:S,exclude:x,fromTime:_,toTime:M}=t,N={};o!=null&&(N.page=o.toString()),i!=null&&(N.size=i.toString()),a!=null&&(N.project_name=a),c!=null&&(N.project_id=c),d!=null&&(N.trace_id=d),u!=null&&(N.type=mi.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"})),g!=null&&(N.filters=g),y!=null&&(N.truncate=y.toString()),k!=null&&(N.strip_attachments=k.toString()),S!=null&&(N.sorting=S),x!=null&&(N.exclude=x),_!=null&&(N.from_time=_.toISOString()),M!=null&&(N.to_time=M.toISOString());let J=await R({url:b((Be=(q=await s.get(this._options.baseUrl))!=null?q:await s.get(this._options.environment))!=null?Be:h.Default,"v1/private/spans"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:N,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(J.ok)return {data:Xl.parseOrThrow(J.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:J.rawResponse};if(J.error.reason==="status-code")throw new p({statusCode:J.error.statusCode,body:J.error.body,rawResponse:J.rawResponse});switch(J.error.reason){case "non-json":throw new p({statusCode:J.error.statusCode,body:J.error.rawBody,rawResponse:J.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans.");case "unknown":throw new p({message:J.error.errorMessage,rawResponse:J.rawResponse})}}createSpan(t,e){return f.fromPromise(this.__createSpan(t,e))}async __createSpan(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/spans"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Hr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new L(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createSpans(t,e){return f.fromPromise(this.__createSpans(t,e))}async __createSpans(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/spans/batch"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Jr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/batch.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getSpanById(t,e={},o){return f.fromPromise(this.__getSpanById(t,e,o))}async __getSpanById(t,e={},o){var d,u;let{stripAttachments:i}=e,a={};i!=null&&(a.strip_attachments=i.toString());let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:a,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(c.ok)return {data:Yo.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 404:throw new A(c.error.body,c.rawResponse);default:throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans/{id}.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}deleteSpanById(t,e){return f.fromPromise(this.__deleteSpanById(t,e))}async __deleteSpanById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 501:throw new sr(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/spans/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateSpan(t,e,o){return f.fromPromise(this.__updateSpan(t,e,o))}async __updateSpan(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:Kr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/spans/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteSpanComments(t,e){return f.fromPromise(this.__deleteSpanComments(t,e))}async __deleteSpanComments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/spans/comments/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/comments/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteSpanFeedbackScore(t,e,o){return f.fromPromise(this.__deleteSpanFeedbackScore(t,e,o))}async __deleteSpanFeedbackScore(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/spans/${encodeURIComponent(t)}/feedback-scores/delete`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:Go.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/{id}/feedback-scores/delete.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}findFeedbackScoreNames1(t={},e){return f.fromPromise(this.__findFeedbackScoreNames1(t,e))}async __findFeedbackScoreNames1(t={},e){var d,u;let{projectId:o,type:i}=t,a={};o!=null&&(a.project_id=o),i!=null&&(a.type=ui.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}));let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,"v1/private/spans/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(c.ok)return {data:Ge.findFeedbackScoreNames1.Response.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans/feedback-scores/names.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}getSpanComment(t,e,o){return f.fromPromise(this.__getSpanComment(t,e,o))}async __getSpanComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/spans/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(i.ok)return {data:B.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans/{spanId}/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getSpanStats(t={},e){return f.fromPromise(this.__getSpanStats(t,e))}async __getSpanStats(t={},e){var S,x;let{projectId:o,projectName:i,traceId:a,type:c,filters:d,fromTime:u,toTime:g}=t,y={};o!=null&&(y.project_id=o),i!=null&&(y.project_name=i),a!=null&&(y.trace_id=a),c!=null&&(y.type=gi.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"})),d!=null&&(y.filters=d),u!=null&&(y.from_time=u.toISOString()),g!=null&&(y.to_time=g.toISOString());let k=await R({url:b((x=(S=await s.get(this._options.baseUrl))!=null?S:await s.get(this._options.environment))!=null?x:h.Default,"v1/private/spans/stats"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:y,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(k.ok)return {data:Ne.parseOrThrow(k.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:k.rawResponse};if(k.error.reason==="status-code")throw new p({statusCode:k.error.statusCode,body:k.error.body,rawResponse:k.rawResponse});switch(k.error.reason){case "non-json":throw new p({statusCode:k.error.statusCode,body:k.error.rawBody,rawResponse:k.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans/stats.");case "unknown":throw new p({message:k.error.errorMessage,rawResponse:k.rawResponse})}}scoreBatchOfSpans(t,e){return f.fromPromise(this.__scoreBatchOfSpans(t,e))}async __scoreBatchOfSpans(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/spans/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Zo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/spans/feedback-scores.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}searchSpans(t={},e){return f.fromPromise(this.__searchSpans(t,e))}async __searchSpans(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/spans/search"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Xr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/search.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateSpanComment(t,e,o){return f.fromPromise(this.__updateSpanComment(t,e,o))}async __updateSpanComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/spans/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:B.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/spans/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ta=class{constructor(t={}){this._options=t;}addThreadComment(t,e,o){return f.fromPromise(this.__addThreadComment(t,e,o))}async __addThreadComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/threads/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:B.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/{id}/comments.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}addTraceComment(t,e,o){return f.fromPromise(this.__addTraceComment(t,e,o))}async __addTraceComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:B.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/{id}/comments.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}addTraceFeedbackScore(t,e,o){return f.fromPromise(this.__addTraceFeedbackScore(t,e,o))}async __addTraceFeedbackScore(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/${encodeURIComponent(t)}/feedback-scores`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:Y.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/{id}/feedback-scores.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}closeTraceThread(t={},e){return f.fromPromise(this.__closeTraceThread(t,e))}async __closeTraceThread(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/close"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Gr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/threads/close.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getTracesByProject(t={},e){return f.fromPromise(this.__getTracesByProject(t,e))}async __getTracesByProject(t={},e){var N,J;let{page:o,size:i,projectName:a,projectId:c,filters:d,truncate:u,stripAttachments:g,sorting:y,exclude:k,fromTime:S,toTime:x}=t,_={};o!=null&&(_.page=o.toString()),i!=null&&(_.size=i.toString()),a!=null&&(_.project_name=a),c!=null&&(_.project_id=c),d!=null&&(_.filters=d),u!=null&&(_.truncate=u.toString()),g!=null&&(_.strip_attachments=g.toString()),y!=null&&(_.sorting=y),k!=null&&(_.exclude=k),S!=null&&(_.from_time=S.toISOString()),x!=null&&(_.to_time=x.toISOString());let M=await R({url:b((J=(N=await s.get(this._options.baseUrl))!=null?N:await s.get(this._options.environment))!=null?J:h.Default,"v1/private/traces"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:_,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(M.ok)return {data:tm.parseOrThrow(M.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:M.rawResponse};if(M.error.reason==="status-code")throw new p({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse});switch(M.error.reason){case "non-json":throw new p({statusCode:M.error.statusCode,body:M.error.rawBody,rawResponse:M.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces.");case "unknown":throw new p({message:M.error.errorMessage,rawResponse:M.rawResponse})}}createTrace(t,e){return f.fromPromise(this.__createTrace(t,e))}async __createTrace(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:$r.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createTraces(t,e){return f.fromPromise(this.__createTraces(t,e))}async __createTraces(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/batch"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Qr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/batch.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getTraceById(t,e={},o){return f.fromPromise(this.__getTraceById(t,e,o))}async __getTraceById(t,e={},o){var d,u;let{stripAttachments:i}=e,a={};i!=null&&(a.strip_attachments=i.toString());let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:a,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(c.ok)return {data:qo.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/{id}.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}deleteTraceById(t,e){return f.fromPromise(this.__deleteTraceById(t,e))}async __deleteTraceById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/traces/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateTrace(t,e={},o){return f.fromPromise(this.__updateTrace(t,e,o))}async __updateTrace(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:Yr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/traces/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteThreadComments(t,e){return f.fromPromise(this.__deleteThreadComments(t,e))}async __deleteThreadComments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/comments/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/comments/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteThreadFeedbackScores(t,e){return f.fromPromise(this.__deleteThreadFeedbackScores(t,e))}async __deleteThreadFeedbackScores(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/feedback-scores/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Zr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/feedback-scores/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteTraceComments(t,e){return f.fromPromise(this.__deleteTraceComments(t,e))}async __deleteTraceComments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/comments/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/comments/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteTraceFeedbackScore(t,e,o){return f.fromPromise(this.__deleteTraceFeedbackScore(t,e,o))}async __deleteTraceFeedbackScore(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/${encodeURIComponent(t)}/feedback-scores/delete`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:Go.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/{id}/feedback-scores/delete.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteTraceThreads(t,e){return f.fromPromise(this.__deleteTraceThreads(t,e))}async __deleteTraceThreads(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:qr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteTraces(t,e){return f.fromPromise(this.__deleteTraces(t,e))}async __deleteTraces(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}findFeedbackScoreNames2(t={},e){return f.fromPromise(this.__findFeedbackScoreNames2(t,e))}async __findFeedbackScoreNames2(t={},e){var c,d;let{projectId:o}=t,i={};o!=null&&(i.project_id=o);let a=await R({url:b((d=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?d:h.Default,"v1/private/traces/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:je.findFeedbackScoreNames2.Response.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/feedback-scores/names.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}findTraceThreadsFeedbackScoreNames(t,e){return f.fromPromise(this.__findTraceThreadsFeedbackScoreNames(t,e))}async __findTraceThreadsFeedbackScoreNames(t,e){var c,d;let{projectId:o}=t,i={};i.project_id=o;let a=await R({url:b((d=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?d:h.Default,"v1/private/traces/threads/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:je.findTraceThreadsFeedbackScoreNames.Response.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/threads/feedback-scores/names.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}getTraceStats(t={},e){return f.fromPromise(this.__getTraceStats(t,e))}async __getTraceStats(t={},e){var y,k;let{projectId:o,projectName:i,filters:a,fromTime:c,toTime:d}=t,u={};o!=null&&(u.project_id=o),i!=null&&(u.project_name=i),a!=null&&(u.filters=a),c!=null&&(u.from_time=c.toISOString()),d!=null&&(u.to_time=d.toISOString());let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:h.Default,"v1/private/traces/stats"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(g.ok)return {data:Ne.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse});switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/stats.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}getThreadComment(t,e,o){return f.fromPromise(this.__getThreadComment(t,e,o))}async __getThreadComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/threads/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(i.ok)return {data:B.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/threads/{threadId}/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getTraceComment(t,e,o){return f.fromPromise(this.__getTraceComment(t,e,o))}async __getTraceComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(i.ok)return {data:B.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/{traceId}/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getTraceThread(t,e){return f.fromPromise(this.__getTraceThread(t,e))}async __getTraceThread(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/retrieve"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Mi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:et.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/retrieve.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getTraceThreads(t={},e){return f.fromPromise(this.__getTraceThreads(t,e))}async __getTraceThreads(t={},e){var M,N;let{page:o,size:i,projectName:a,projectId:c,truncate:d,stripAttachments:u,filters:g,sorting:y,fromTime:k,toTime:S}=t,x={};o!=null&&(x.page=o.toString()),i!=null&&(x.size=i.toString()),a!=null&&(x.project_name=a),c!=null&&(x.project_id=c),d!=null&&(x.truncate=d.toString()),u!=null&&(x.strip_attachments=u.toString()),g!=null&&(x.filters=g),y!=null&&(x.sorting=y),k!=null&&(x.from_time=k.toISOString()),S!=null&&(x.to_time=S.toISOString());let _=await R({url:b((N=(M=await s.get(this._options.baseUrl))!=null?M:await s.get(this._options.environment))!=null?N:h.Default,"v1/private/traces/threads"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:x,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(_.ok)return {data:om.parseOrThrow(_.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:_.rawResponse};if(_.error.reason==="status-code")throw new p({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse});switch(_.error.reason){case "non-json":throw new p({statusCode:_.error.statusCode,body:_.error.rawBody,rawResponse:_.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/threads.");case "unknown":throw new p({message:_.error.errorMessage,rawResponse:_.rawResponse})}}openTraceThread(t,e){return f.fromPromise(this.__openTraceThread(t,e))}async __openTraceThread(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/open"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Mi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/threads/open.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}scoreBatchOfThreads(t,e){return f.fromPromise(this.__scoreBatchOfThreads(t,e))}async __scoreBatchOfThreads(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:eo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/threads/feedback-scores.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}scoreBatchOfTraces(t,e){return f.fromPromise(this.__scoreBatchOfTraces(t,e))}async __scoreBatchOfTraces(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Zo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/feedback-scores.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}searchTraceThreads(t={},e){return f.fromPromise(this.__searchTraceThreads(t,e))}async __searchTraceThreads(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/search"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ro.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/search.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}searchTraces(t={},e){return f.fromPromise(this.__searchTraces(t,e))}async __searchTraces(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/search"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:oo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 401:throw new K(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/search.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateThread(t,e={},o){return f.fromPromise(this.__updateThread(t,e,o))}async __updateThread(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/threads/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:to.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/traces/threads/{threadModelId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}updateThreadComment(t,e,o){return f.fromPromise(this.__updateThreadComment(t,e,o))}async __updateThreadComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/threads/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:B.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/traces/threads/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}updateTraceComment(t,e,o){return f.fromPromise(this.__updateTraceComment(t,e,o))}async __updateTraceComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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:B.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/traces/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ia=class{constructor(t={}){this._options=t;}getWelcomeWizardStatus(t){return f.fromPromise(this.__getWelcomeWizardStatus(t))}async __getWelcomeWizardStatus(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/welcome-wizard"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:im.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/welcome-wizard.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}submitWelcomeWizard(t={},e){return f.fromPromise(this.__submitWelcomeWizard(t,e))}async __submitWelcomeWizard(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/welcome-wizard"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:lo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/welcome-wizard.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var aa=class{constructor(t={}){this._options=t;}costsSummary(t,e){return f.fromPromise(this.__costsSummary(t,e))}async __costsSummary(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/workspaces/costs/summaries"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ze.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:De.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/workspaces/costs/summaries.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getWorkspaceConfiguration(t){return f.fromPromise(this.__getWorkspaceConfiguration(t))}async __getWorkspaceConfiguration(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/workspaces/configurations"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:rt.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")switch(e.error.statusCode){case 404:throw new A(e.error.body,e.rawResponse);default:throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse})}switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/workspaces/configurations.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}upsertWorkspaceConfiguration(t,e){return f.fromPromise(this.__upsertWorkspaceConfiguration(t,e))}async __upsertWorkspaceConfiguration(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/workspaces/configurations"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:rt.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:rt.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/workspaces/configurations.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteWorkspaceConfiguration(t){return f.fromPromise(this.__deleteWorkspaceConfiguration(t))}async __deleteWorkspaceConfiguration(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/workspaces/configurations"),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:void 0,rawResponse:e.rawResponse};if(e.error.reason==="status-code")switch(e.error.statusCode){case 404:throw new A(e.error.body,e.rawResponse);default:throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse})}switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/workspaces/configurations.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getCost(t,e){return f.fromPromise(this.__getCost(t,e))}async __getCost(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/workspaces/costs"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ze.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Di.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/workspaces/costs.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getMetric(t,e){return f.fromPromise(this.__getMetric(t,e))}async __getMetric(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/workspaces/metrics"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ze.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Di.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/workspaces/metrics.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}metricsSummary(t,e){return f.fromPromise(this.__metricsSummary(t,e))}async __metricsSummary(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/workspaces/metrics/summaries"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ze.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:am.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/workspaces/metrics/summaries.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var na=class{constructor(t={}){this._options=t;}datasetsRedirect(t,e){return f.fromPromise(this.__datasetsRedirect(t,e))}async __datasetsRedirect(t,e){var u,g;let{datasetId:o,workspaceName:i,path:a}=t,c={};c.dataset_id=o,i!=null&&(c.workspace_name=i),c.path=a;let d=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:h.Default,"v1/session/redirect/datasets"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:c,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(d.ok)return {data:void 0,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new T(d.error.body,d.rawResponse);case 404:throw new A(d.error.body,d.rawResponse);default:throw new p({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case "non-json":throw new p({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/session/redirect/datasets.");case "unknown":throw new p({message:d.error.errorMessage,rawResponse:d.rawResponse})}}experimentsRedirect(t,e){return f.fromPromise(this.__experimentsRedirect(t,e))}async __experimentsRedirect(t,e){var g,y;let{datasetId:o,experimentId:i,workspaceName:a,path:c}=t,d={};d.dataset_id=o,d.experiment_id=i,a!=null&&(d.workspace_name=a),d.path=c;let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/session/redirect/experiments"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:void 0,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new T(u.error.body,u.rawResponse);case 404:throw new A(u.error.body,u.rawResponse);default:throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/session/redirect/experiments.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}optimizationsRedirect(t,e){return f.fromPromise(this.__optimizationsRedirect(t,e))}async __optimizationsRedirect(t,e){var g,y;let{datasetId:o,optimizationId:i,workspaceName:a,path:c}=t,d={};d.dataset_id=o,d.optimization_id=i,a!=null&&(d.workspace_name=a),d.path=c;let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/session/redirect/optimizations"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:void 0,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new T(u.error.body,u.rawResponse);case 404:throw new A(u.error.body,u.rawResponse);default:throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/session/redirect/optimizations.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}projectsRedirect(t,e){return f.fromPromise(this.__projectsRedirect(t,e))}async __projectsRedirect(t,e){var u,g;let{traceId:o,workspaceName:i,path:a}=t,c={};c.trace_id=o,i!=null&&(c.workspace_name=i),c.path=a;let d=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:h.Default,"v1/session/redirect/projects"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:c,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(d.ok)return {data:void 0,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new T(d.error.body,d.rawResponse);case 404:throw new A(d.error.body,d.rawResponse);default:throw new p({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case "non-json":throw new p({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/session/redirect/projects.");case "unknown":throw new p({message:d.error.errorMessage,rawResponse:d.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ot=class{constructor(t={}){this._options=t;}get systemUsage(){var t;return (t=this._systemUsage)!=null?t:this._systemUsage=new Fi(this._options)}get alerts(){var t;return (t=this._alerts)!=null?t:this._alerts=new Oi(this._options)}get annotationQueues(){var t;return (t=this._annotationQueues)!=null?t:this._annotationQueues=new Wi(this._options)}get attachments(){var t;return (t=this._attachments)!=null?t:this._attachments=new Bi(this._options)}get check(){var t;return (t=this._check)!=null?t:this._check=new Li(this._options)}get automationRuleEvaluators(){var t;return (t=this._automationRuleEvaluators)!=null?t:this._automationRuleEvaluators=new Vi(this._options)}get chatCompletions(){var t;return (t=this._chatCompletions)!=null?t:this._chatCompletions=new Hi(this._options)}get datasets(){var t;return (t=this._datasets)!=null?t:this._datasets=new Ji(this._options)}get experiments(){var t;return (t=this._experiments)!=null?t:this._experiments=new Ki(this._options)}get feedbackDefinitions(){var t;return (t=this._feedbackDefinitions)!=null?t:this._feedbackDefinitions=new Xi(this._options)}get guardrails(){var t;return (t=this._guardrails)!=null?t:this._guardrails=new Gi(this._options)}get llmProviderKey(){var t;return (t=this._llmProviderKey)!=null?t:this._llmProviderKey=new $i(this._options)}get manualEvaluation(){var t;return (t=this._manualEvaluation)!=null?t:this._manualEvaluation=new Qi(this._options)}get openTelemetryIngestion(){var t;return (t=this._openTelemetryIngestion)!=null?t:this._openTelemetryIngestion=new Yi(this._options)}get optimizations(){var t;return (t=this._optimizations)!=null?t:this._optimizations=new Zi(this._options)}get projects(){var t;return (t=this._projects)!=null?t:this._projects=new qi(this._options)}get prompts(){var t;return (t=this._prompts)!=null?t:this._prompts=new ea(this._options)}get serviceToggles(){var t;return (t=this._serviceToggles)!=null?t:this._serviceToggles=new ra(this._options)}get spans(){var t;return (t=this._spans)!=null?t:this._spans=new oa(this._options)}get traces(){var t;return (t=this._traces)!=null?t:this._traces=new ta(this._options)}get welcomeWizard(){var t;return (t=this._welcomeWizard)!=null?t:this._welcomeWizard=new ia(this._options)}get workspaces(){var t;return (t=this._workspaces)!=null?t:this._workspaces=new aa(this._options)}get redirect(){var t;return (t=this._redirect)!=null?t:this._redirect=new na(this._options)}isAlive(t){return f.fromPromise(this.__isAlive(t))}async __isAlive(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"is-alive/ping"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:e.body,rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /is-alive/ping.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}version(t){return f.fromPromise(this.__version(t))}async __version(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"is-alive/ver"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.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(e.ok)return {data:e.body,rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /is-alive/ver.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Z=()=>uuid.v7();var sa=class n{constructor(t,e){this.data=t;this.opik=e;this.childSpans=[];this.end=()=>this.update({endTime:new Date});this.score=t=>{var e;this.opik.spanFeedbackScoresBatchQueue.create({...t,projectName:(e=this.data.projectName)!=null?e:this.opik.config.projectName,id:this.data.id,source:"sdk"});};this.update=t=>{var o;let e={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,e),this.data={...this.data,...t},this};this.span=t=>{var a;let e=(a=this.data.projectName)!=null?a:this.opik.config.projectName,o={id:Z(),startTime:new Date,...t,projectName:e,traceId:this.data.traceId,parentSpanId:this.data.id};this.opik.spanBatchQueue.create(o);let i=new n(o,this.opik);return this.childSpans.push(i),i};}};var pa=class{constructor(t,e){this.data=t;this.opik=e;this.spans=[];this.end=()=>this.update({endTime:new Date});this.score=t=>{var e;this.opik.traceFeedbackScoresBatchQueue.create({...t,projectName:(e=this.data.projectName)!=null?e:this.opik.config.projectName,id:this.data.id,source:"sdk"});};this.span=t=>{var a,c;let e=(c=(a=this.data.projectName)!=null?a:t.projectName)!=null?c:this.opik.config.projectName,o={id:Z(),startTime:new Date,...t,projectName:e,traceId:this.data.id};this.opik.spanBatchQueue.create(o);let i=new sa(o,this.opik);return this.spans.push(i),i};this.update=t=>{var o;let e={projectName:(o=this.data.projectName)!=null?o:this.opik.config.projectName,...t};return this.opik.traceBatchQueue.update(this.data.id,e),this.data={...this.data,...e},this};}};var Kd={EXPERIMENTS:"api/v1/session/redirect/experiments/",PROJECT_BY_NAME:"redirect/projects"},ca={EXPERIMENT_ID:"experiment_id",DATASET_ID:"dataset_id",PROJECT_NAME:"name",PATH:"path"},zf=n=>Object.entries(n).map(([t,e])=>`${t}=${encodeURIComponent(e)}`).join("&").replace(/%3A/g,":").replace(/%2F/g,"/").replace(/%26/g,"&").replace(/%3F/g,"?").replace(/%3D/g,"="),Sf=n=>n.replace(/\/api$/,""),xf=n=>Buffer.from(n).toString("base64"),Xd=(n,t,e)=>{let o=zf(e),i=`${t}?${o}`;return new URL(i,n).toString()},Gd=({datasetId:n,experimentId:t,baseUrl:e})=>Xd(e,Kd.EXPERIMENTS,{[ca.EXPERIMENT_ID]:t,[ca.DATASET_ID]:n,[ca.PATH]:xf(e)});var $d=({projectName:n,workspaceName:t,apiUrl:e})=>{let o=Sf(e),i=`${t}/${Kd.PROJECT_BY_NAME}`;return Xd(o,i,{[ca.PROJECT_NAME]:n})};var _f=300,la=100,tt=class{constructor({action:t,batchSize:e=la,delay:o,enableBatch:i,name:a="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,e)=>{if(this.queue.set(t,e),!this.enableBatch){this.flush();return}if(this.queue.size>=this.batchSize){this.flush();return}this.debounceFlush();};this.update=(t,e)=>{let o=this.queue.get(t);o&&(this.queue.set(t,{...o,...e}),this.debounceFlush());};this.flush=async()=>{if(this.queue.size===0)return this.promise;let t=new Map(this.queue);this.queue.clear(),z.debug(`Adding ${t.size} items to ${this.name} promise:`,t),this.promise=this.promise.finally(()=>(z.debug(`Flushing ${this.name}:`,t),this.action(t))).catch(e=>{z.error(`Failed to flush ${this.name}:`,e,t);}),await this.promise;};this.action=t,this.batchSize=e,this.delay=o,this.enableBatch=i,this.name=a;}},se=class{constructor({delay:t=_f,enableCreateBatch:e=true,enableUpdateBatch:o=false,enableDeleteBatch:i=true,createBatchSize:a=la,updateBatchSize:c=la,deleteBatchSize:d=la,name:u="BatchQueue"}={}){this.create=t=>{let e=this.getId(t);this.createQueue.add(e,t);};this.get=async t=>{let e=this.createQueue.queue.get(t);return e||this.getEntity(t)};this.update=(t,e)=>{if(this.createQueue.queue.get(t)){this.createQueue.update(t,e);return}this.updateQueue.add(t,e);};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=u,this.createQueue=new tt({action:async g=>{await this.createEntities(Array.from(g.values()));},delay:t,enableBatch:e,batchSize:a,name:`${u}:createQueue`}),this.updateQueue=new tt({action:async g=>{await this.createQueue.flush();let y=Array.from(g.entries());for(let[k,S]of y)await this.updateEntity(k,S);},delay:t,enableBatch:o,batchSize:c,name:`${u}:updateQueue`}),this.deleteQueue=new tt({action:async g=>{await this.createQueue.flush(),await this.updateQueue.flush(),await this.deleteEntities(Array.from(g.keys()));},delay:t,enableBatch:i,batchSize:d,name:`${u}:deleteQueue`});}};var ma=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"SpanBatchQueue"});this.api=e;}getId(e){return e.id}async createEntities(e){await this.api.spans.createSpans({spans:e},this.api.requestOptions);}async getEntity(e){return await this.api.spans.getSpanById(e,{},this.api.requestOptions)}async updateEntity(e,o){await this.api.spans.updateSpan(e,o,this.api.requestOptions);}async deleteEntities(e){for(let o of e)await this.api.spans.deleteSpanById(o,this.api.requestOptions);}};var da=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"SpanFeedbackScoresBatchQueue"});this.api=e;}getId(e){return {id:e.id,name:e.name}}async createEntities(e){await this.api.spans.scoreBatchOfSpans({scores:e},this.api.requestOptions);}async getEntity(){throw new Error("Not implemented")}async updateEntity(){throw new Error("Not implemented")}async deleteEntities(e){for(let o of e)await this.api.spans.deleteSpanFeedbackScore(o.id,{name:o.name},this.api.requestOptions);}};var ua=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"TraceBatchQueue"});this.api=e;}getId(e){return e.id}async createEntities(e){await this.api.traces.createTraces({traces:e},this.api.requestOptions);}async getEntity(e){return await this.api.traces.getTraceById(e,{},this.api.requestOptions)}async updateEntity(e,o){await this.api.traces.updateTrace(e,o,this.api.requestOptions);}async deleteEntities(e){await this.api.traces.deleteTraces({ids:e},this.api.requestOptions);}};var ga=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"TraceFeedbackScoresBatchQueue"});this.api=e;}getId(e){return {id:e.id,name:e.name}}async createEntities(e){await this.api.traces.scoreBatchOfTraces({scores:e},this.api.requestOptions);}async getEntity(){throw new Error("Not implemented")}async updateEntity(){throw new Error("Not implemented")}async deleteEntities(e){for(let o of e)await this.api.traces.deleteTraceFeedbackScore(o.id,{name:o.name},this.api.requestOptions);}};var wa=class extends ot{constructor(e){super(e);this.setHeaders=e=>{this.requestOptions.headers=e;};this.requestOptions=(e==null?void 0:e.requestOptions)||{};}};var fa=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"DatasetBatchQueue"});this.api=e;}getId(e){return e.id||""}async createEntities(e){for(let o of e)await this.api.datasets.createDataset(o,this.api.requestOptions);}async getEntity(e){try{return await this.api.datasets.getDatasetById(e,this.api.requestOptions)}catch{return}}async updateEntity(e,o){await this.api.datasets.updateDataset(e,{name:o.name||"",visibility:o.visibility,description:o.description},this.api.requestOptions);}async deleteEntities(e){await this.api.datasets.deleteDatasetsBatch({ids:e},this.api.requestOptions);}};var nm=null;async function Qd(){return nm||(nm=await Tf__default.default()),nm}var it=class n{constructor(t){let{id:e,traceId:o,spanId:i,source:a,...c}=t;this.id=e||Z(),this.traceId=o,this.spanId=i,this.source=a||tn.Sdk,this.data={...c};}getContent(t=false){return t?{...this.data,id:this.id}:{...this.data}}async contentHash(){let t=this.getContent(),e=Af__default.default(t);return (await Qd()).h32(e,43981).toString(16)}toApiModel(){return {id:this.id,traceId:this.traceId,spanId:this.spanId,source:this.source,data:this.getContent()}}static fromApiModel(t){return new n({id:t.id,traceId:t.traceId,spanId:t.spanId,source:t.source,...t.data})}};async function _e(n,t,e){var c;if(e===0)return [];let o=new util.TextDecoder("utf-8"),i=[],a="";try{for await(let d of n){a+=o.decode(d,{stream:!0});let u=a.split(`
4
- `);a=(c=u.pop())!=null?c:"";for(let g of u)if(!(!g.trim()||g==="{}"||g==="[]"||g==="null"))try{let y=JSON.parse(g),k=t.parse(y);if(k.ok){if(i.push(k.value),e!==void 0&&i.length>=e)return i}else z.error("Error parsing experiment item:",k.errors);}catch(y){z.error("Error parsing JSON line:",y instanceof Error?y.message:String(y));}}if(a.trim()&&a!=="{}"&&a!=="[]"&&a!=="null")try{let d=JSON.parse(a),u=t.parse(d);u.ok?i.push(u.value):z.error("Error parsing experiment item:",u.errors);}catch(d){z.error("Error parsing remaining buffer:",d instanceof Error?d.message:String(d));}}catch(d){z.error("Error processing stream:",d instanceof Error?d.message:String(d));}return i}function at(n,t){let e=[];for(let o=0;o<n.length;o+=t.maxBatchSize)e.push(n.slice(o,o+t.maxBatchSize));return e}var ne=class extends Error{constructor(t){var e;super(t.message),this.name=this.constructor.name,this.code=t.code,this.statusCode=t.statusCode,this.details=t.details,this.originalError=t.originalError,z.error(this.message),(e=Error.captureStackTrace)==null||e.call(Error,this,this.constructor);}toJSON(){return {name:this.name,message:this.message,code:this.code,statusCode:this.statusCode,details:this.details,originalError:this.originalError,stack:this.stack}}};var Yd={DATASET_NOT_FOUND:n=>`Dataset with name '${n}' not found`,DATASET_ITEM_NOT_FOUND:n=>`Dataset item with id '${n}' not found`,DATASET_ITEM_MISSING_ID:n=>`Item at index ${n} is missing an ID required for update`,INVALID_JSON_FORMAT:n=>`Invalid JSON format${n?": "+n:""}`,JSON_NOT_ARRAY:"JSON input must be an array of objects",ITEM_NOT_OBJECT:(n,t)=>`Item at position ${n} is not an object (${t})`,INSERTION_FAILED:n=>`Failed to insert items from JSON: ${n}`,DATASET_JSON_PARSE_ERROR:n=>`Failed to parse JSON input: ${n}`};var Pf={DATASET_ITEM_MISSING_ID:"DATASET_ITEM_MISSING_ID"},ha=class extends ne{constructor(t){super({message:Yd.DATASET_ITEM_MISSING_ID(t),code:Pf.DATASET_ITEM_MISSING_ID});}};var vf={SEARCH_TIMEOUT:"SEARCH_TIMEOUT"},Ra=class extends ne{constructor(t){super({message:t,code:vf.SEARCH_TIMEOUT});}};var ba={JSON_NOT_ARRAY:n=>`JSON input must be an array of objects${n?` (${n})`:""}`,JSON_PARSE_ERROR:"Failed to parse JSON input",JSON_ITEM_NOT_OBJECT:(n,t)=>`Item at position ${n} is not an object (${t})`};var sm={JSON_PARSE_ERROR:"JSON_PARSE_ERROR",JSON_NOT_ARRAY:"JSON_NOT_ARRAY",JSON_ITEM_NOT_OBJECT:"JSON_ITEM_NOT_OBJECT"},ya=class extends ne{constructor(t){let e=t instanceof Error?t:new Error(String(t));super({message:ba.JSON_PARSE_ERROR,code:sm.JSON_PARSE_ERROR,originalError:e});}},ka=class extends ne{constructor(t){super({message:ba.JSON_NOT_ARRAY(t),code:sm.JSON_NOT_ARRAY});}},za=class extends ne{constructor(t,e){super({message:ba.JSON_ITEM_NOT_OBJECT(t,e),code:sm.JSON_ITEM_NOT_OBJECT});}};var qe=class{constructor({name:t,description:e,id:o},i){this.opik=i;this.idToHash=new Map;this.hashes=new Set;this.id=o||Z(),this.name=t,this.description=e;}async insert(t){if(!t||t.length===0)return;await this.opik.datasetBatchQueue.flush(),await this.syncHashes();let e=await this.getDeduplicatedItems(t),o=at(e,{maxBatchSize:1e3});try{let i=0;for(let a of o)await this.opik.api.datasets.createOrUpdateDatasetItems({datasetId:this.id,items:a}),i+=a.length,z.info(`Inserted ${Math.min(i,e.length)} of ${e.length} items into dataset ${this.id}`);}catch(i){throw z.error(`Error inserting items into dataset: ${i instanceof Error?i.message:String(i)}`),i}}async update(t){if(!(!t||t.length===0)){for(let e=0;e<t.length;e++)if(!t[e].id)throw new ha(e);await this.insert(t);}}async delete(t){if(!t||t.length===0){z.info("No item IDs provided for deletion");return}let e=at(t,{maxBatchSize:100});for await(let o of e){z.debug("Deleting dataset items batch",{batchSize:o.length,datasetId:this.id}),await this.opik.api.datasets.deleteDatasetItems({itemIds:o});for(let i of o)if(this.idToHash.has(i)){let a=this.idToHash.get(i);this.hashes.delete(a),this.idToHash.delete(i);}}}async clear(){let e=(await this.getItems()).map(o=>o.id).filter(Boolean);e.length!==0&&await this.delete(e);}async getItems(t,e){return (await this.getItemsAsDataclasses(t,e)).map(i=>i.getContent(true))}async getItemsAsDataclasses(t,e){let o=t?Math.min(t,2e3):2e3,i=await this.opik.api.datasets.streamDatasetItems({datasetName:this.name,lastRetrievedId:e,steamLimit:o});return (await _e(i,I.DatasetItemPublic,t)).map(c=>it.fromApiModel(c))}async insertFromJson(t,e={},o=[]){let i;try{i=JSON.parse(t);}catch(c){throw new ya(c)}if(!Array.isArray(i))throw new ka(typeof i);if(i.length===0)return;for(let c=0;c<i.length;c++){let d=i[c];if(typeof d!="object"||d===null)throw new za(c,typeof d)}let a=i.map(c=>{let d=c,u={};for(let[g,y]of Object.entries(d)){if(o.includes(g))continue;let k=e[g]||g;u[k]=y;}return u});await this.insert(a);}async toJson(t={}){let o=(await this.getItems()).map(i=>{let a={...i};if(Object.keys(t).length>0){for(let[c,d]of Object.entries(t))if(c in a){let u=a[c];delete a[c],a[d]=u;}}return a});return Af__default.default(o)}async getDeduplicatedItems(t){let e=[];for(let o of t){let i=new it(o),a=await i.contentHash();if(this.hashes.has(a)){z.debug("Duplicate item found - skipping",{contentHash:a,datasetId:this.id});continue}e.push(i.toApiModel()),this.hashes.add(a),this.idToHash.set(i.id,a);}return e}clearHashState(){this.idToHash.clear(),this.hashes.clear();}async syncHashes(){z.debug("Syncing dataset hashes with backend",{datasetId:this.id});try{let t=await this.getItemsAsDataclasses();this.clearHashState();for(let e of t){let o=await e.contentHash();this.idToHash.set(e.id,o),this.hashes.add(o);}z.debug("Dataset hash sync completed",{datasetId:this.id,itemCount:t.length});}catch(t){if(t instanceof p&&t.statusCode===404){z.debug("Dataset not found - starting with empty hash state",{datasetId:this.id}),this.clearHashState();return}throw t}}};var pm=class extends Error{constructor(t){super(t),this.name="DatasetError";}},nt=class extends pm{constructor(t){super(`Dataset with name '${t}' not found`),this.name="DatasetNotFoundError";}};var Sa=class{constructor(t){if(!t.datasetItemId)throw new Error("datasetItemId is required");if(!t.traceId)throw new Error("traceId is required");this.datasetItemId=t.datasetItemId,this.traceId=t.traceId;}},xa=class n{constructor(t){this.id=t.id,this.datasetItemId=t.datasetItemId,this.traceId=t.traceId,this.datasetItemData=t.datasetItemData,this.evaluationTaskOutput=t.evaluationTaskOutput,this.feedbackScores=[...t.feedbackScores];}static fromRestExperimentItemCompare(t){var o,i;let e=(i=(o=t.feedbackScores)==null?void 0:o.map(a=>({categoryName:a.categoryName,name:a.name,reason:a.reason,value:a.value,source:a.source})))!=null?i:[];return new n({id:t.id,traceId:t.traceId,datasetItemId:t.datasetItemId,datasetItemData:t.input,evaluationTaskOutput:t.output,feedbackScores:e})}};var Fe=class{constructor({id:t,name:e,datasetName:o,prompts:i},a){this.opik=a;this.id=t||Z(),this._name=e,this.datasetName=o,this.prompts=i;}get name(){return this._name}async ensureNameLoaded(){if(this._name!==void 0)return this._name;let t=await this.opik.api.experiments.getExperimentById(this.id);if(this._name=t.name,!this._name)throw new Error("Experiment name is not loaded");return this._name}async insert(t){if(t.length===0)return;let e=t.map(i=>({id:Z(),experimentId:this.id,datasetItemId:i.datasetItemId,traceId:i.traceId})),o=at(e,{maxBatchSize:50});try{for(let i of o)await this.opik.api.experiments.createExperimentItems({experimentItems:i});z.debug(`Inserted ${t.length} items into experiment ${this.id}`);}catch(i){throw z.error(`Error inserting items into experiment: ${i instanceof Error?i.message:String(i)}`),i}}async getItems(t){let e=[],{maxResults:i,truncate:a=false}=t||{},c,d=true;try{for(;d&&!(i!==void 0&&e.length>=i);){let u=i?Math.min(i-e.length,2e3):2e3,g=await this.opik.api.experiments.streamExperimentItems({experimentName:this.name,limit:u,lastRetrievedId:c,truncate:a});try{let y=await _e(g,I.ExperimentItemCompare,u);if(y.length===0){d=!1;break}for(let k of y){let S=xa.fromRestExperimentItemCompare(k);if(e.push(S),i!==void 0&&e.length>=i){d=!1;break}}c=y[y.length-1].id;}catch(y){z.error("Error parsing experiment item: "+(y instanceof Error?y.message:String(y))),d=!1;break}}}catch(u){throw z.error("Error retrieving experiment items: "+(u instanceof Error?u.message:String(u))),u}return z.info(`Retrieved ${e.length} items${i?` (limited by maxResults=${i})`:""}`),e}async getUrl(){let t=await this.opik.getDataset(this.datasetName),e=this.opik.config.apiUrl||Va.apiUrl;return Gd({datasetId:t.id,experimentId:this.id,baseUrl:e})}};var _a={EXPERIMENT_NOT_FOUND:n=>`Experiment with name '${n}' not found`,INVALID_CONFIG_TYPE:n=>`experimentConfig must be a plain object, but ${n} was provided. Please provide a valid configuration object like { model: 'gpt-4', temperature: 0.7 }`,CONFIG_PROMPTS_CONFLICT:()=>`Cannot specify both 'prompts' parameter and 'experimentConfig.prompts'. Choose one approach:
1
+ 'use strict';var ansiEscapes=require('ansi-escapes'),tslog=require('tslog'),Dm=require('fs'),og=require('ini');require('dotenv/config');var Fw=require('qs'),uuid=require('uuid'),jh=require('fast-json-stable-stringify'),Ih=require('xxhash-wasm'),util=require('util'),Fh=require('mustache'),Bh=require('nunjucks'),dateFns=require('date-fns'),jestDiff=require('jest-diff'),Hh=require('fast-deep-equal'),async_hooks=require('async_hooks'),Ma=require('chalk'),rf=require('boxen'),of=require('ora'),ai$1=require('ai'),openai=require('@ai-sdk/openai'),anthropic=require('@ai-sdk/anthropic'),google=require('@ai-sdk/google'),Tm=require('zod');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Dm__default=/*#__PURE__*/_interopDefault(Dm);var og__default=/*#__PURE__*/_interopDefault(og);var Fw__default=/*#__PURE__*/_interopDefault(Fw);var jh__default=/*#__PURE__*/_interopDefault(jh);var Ih__default=/*#__PURE__*/_interopDefault(Ih);var Fh__default=/*#__PURE__*/_interopDefault(Fh);var Bh__default=/*#__PURE__*/_interopDefault(Bh);var Hh__default=/*#__PURE__*/_interopDefault(Hh);var Ma__default=/*#__PURE__*/_interopDefault(Ma);var rf__default=/*#__PURE__*/_interopDefault(rf);var of__default=/*#__PURE__*/_interopDefault(of);var Tm__default=/*#__PURE__*/_interopDefault(Tm);var Ku=Object.create;var zt=Object.defineProperty;var Xu=Object.getOwnPropertyDescriptor;var Cm=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),cr=n=>{throw TypeError(n)};var Gu=(n,t,e)=>t in n?zt(n,t,{enumerable:true,configurable:true,writable:true,value:e}):n[t]=e;var Xa=(n,t)=>()=>(n&&(t=n(n=0)),t);var P=(n,t)=>{for(var e in t)zt(n,e,{get:t[e],enumerable:true});};var Im=n=>{var t;return [,,,Ku((t=void 0)!=null?t:null)]},jm=["class","method","getter","setter","accessor","field","value","get","set"],pr=n=>n!==void 0&&typeof n!="function"?cr("Function expected"):n,$u=(n,t,e,o,i)=>({kind:jm[n],name:t,metadata:o,addInitializer:a=>e._?cr("Already initialized"):i.push(pr(a||null))}),Ga=(n,t)=>Gu(t,Cm("metadata"),n[3]),Um=(n,t,e,o)=>{for(var i=0,a=n[t>>1],c=a&&a.length;i<c;i++)a[i].call(e);return o},Nm=(n,t,e,o,i,a)=>{var m,u,g,y,k=t&7,S=false,x=false,_=2,M=jm[k+5],K=n[_]||(n[_]=[]),q=((i=i.prototype),Xu(i,e));for(var He=o.length-1;He>=0;He--)g=$u(k,e,u={},n[3],K),(g.static=S,g.private=x,y=g.access={has:oe=>e in oe},(y.get=oe=>oe[e]),k>2),m=(0, o[He])(q[M],g),u._=1,pr(m)&&(q[M]=m);return q&&zt(i,e,q),i};var gd={};P(gd,{Node18UniversalStreamWrapper:()=>gn});var gn,wd=Xa(()=>{gn=class n{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,e){var o;(o=this.events[t])==null||o.push(e);}off(t,e){var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(i=>i!==e);}pipe(t){return this.on("data",async e=>{if(t instanceof n)t._write(e);else if(t instanceof WritableStream){let o=t.getWriter();o.write(e).then(()=>o.releaseLock());}else t.write(e);}),this.on("end",async()=>{t instanceof n?t._end():t instanceof WritableStream?t.getWriter().close():t.end();}),this.on("error",async e=>{t instanceof n?t._error(e):t instanceof WritableStream?t.getWriter().abort(e):t.destroy(e);}),this._startReading(),t}pipeTo(t){return this.pipe(t)}unpipe(t){this.off("data",async e=>{if(t instanceof n)t._write(e);else if(t instanceof WritableStream){let o=t.getWriter();o.write(e).then(()=>o.releaseLock());}else t.write(e);}),this.off("end",async()=>{t instanceof n?t._end():t instanceof WritableStream?t.getWriter().close():t.end();}),this.off("error",async e=>{t instanceof n?t._error(e):t instanceof WritableStream?t.getWriter().abort(e):t.destroy(e);});}destroy(t){this.reader.cancel(t).then(()=>{this._emit("close");}).catch(e=>{this._emit("error",e);});}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:e}=await this.reader.read();if(!t)return e}setEncoding(t){this.encoding=t;}async text(){let t=[];for(;;){let{done:o,value:i}=await this.reader.read();if(o)break;i&&t.push(i);}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,e){if(this.events[t])for(let o of this.events[t]||[])o(e);}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();if(t){this._emit("end"),this._emit("close");break}e&&this._emit("data",e);}}catch(t){this._emit("error",t);}}[Symbol.asyncIterator](){return {next:async()=>{this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();return t?{done:true,value:void 0}:{done:false,value:e}},[Symbol.asyncIterator](){return this}}}};});var hd={};P(hd,{UndiciStreamWrapper:()=>wn});var wn,fd=Xa(()=>{wn=class n{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,e){var o;(o=this.events[t])==null||o.push(e);}off(t,e){var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(i=>i!==e);}pipe(t){return this.on("data",e=>{if(t instanceof n)t._write(e);else {let o=t.getWriter();o.write(e).then(()=>o.releaseLock());}}),this.on("end",()=>{t instanceof n?t._end():t.getWriter().close();}),this.on("error",e=>{t instanceof n?t._error(e):t.getWriter().abort(e);}),this._startReading(),t}pipeTo(t){return this.pipe(t)}unpipe(t){this.off("data",e=>{if(t instanceof n)t._write(e);else {let o=t.getWriter();o.write(e).then(()=>o.releaseLock());}}),this.off("end",()=>{t instanceof n?t._end():t.getWriter().close();}),this.off("error",e=>{t instanceof n?t._error(e):t.getWriter().abort(e);});}destroy(t){this.reader.cancel(t).then(()=>{this._emit("close");}).catch(e=>{this._emit("error",e);});}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:e}=await this.reader.read();if(!t)return e}setEncoding(t){this.encoding=t;}async text(){let t=[];for(;;){let{done:o,value:i}=await this.reader.read();if(o)break;i&&t.push(i);}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,e){if(this.events[t])for(let o of this.events[t]||[])o(e);}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();if(t){this._emit("end"),this._emit("close");break}e&&this._emit("data",e);}}catch(t){this._emit("error",t);}}[Symbol.asyncIterator](){return {next:async()=>{this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();return t?{done:true,value:void 0}:{done:false,value:e}},[Symbol.asyncIterator](){return this}}}};});var Rd={};P(Rd,{NodePre18StreamWrapper:()=>hn});var hn,bd=Xa(()=>{hn=class{constructor(t){this.readableStream=t;}on(t,e){this.readableStream.on(t,e);}off(t,e){this.readableStream.off(t,e);}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,e)=>{let o=this.readableStream.read();o?t(o):(this.readableStream.once("readable",()=>{let i=this.readableStream.read();t(i);}),this.readableStream.once("error",e));})}setEncoding(t){this.readableStream.setEncoding(t),this.encoding=t;}async text(){let t=[],e=new TextEncoder;this.readableStream.setEncoding(this.encoding||"utf-8");for await(let i of this.readableStream)t.push(e.encode(i));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 e=this.readableStream[Symbol.asyncIterator]();return {async next(){let{value:o,done:i}=await e.next();return {value:o,done:i}},[Symbol.asyncIterator](){return this}}}};});var eg={SILLY:0,TRACE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,FATAL:6};function St(n,t=n){return ansiEscapes.link(t,n)}var z=new tslog.Logger({hideLogPositionForProduction:true,prettyLogTemplate:"{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}} {{logLevelName}} "}),Mm=n=>{z.settings.minLevel=eg[n];},rg=()=>{z.settings.minLevel=100;};Mm(process.env.OPIK_LOG_LEVEL||"INFO");var tg="~/.opik.config",Qa={apiKey:"",apiUrl:"https://www.comet.com/opik/api",projectName:"Default Project",workspaceName:"default",batchDelayMs:300,holdUntilFlush:false};function Fm(n){return Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0))}function ig(){return Fm({apiKey:process.env.OPIK_API_KEY,apiUrl:process.env.OPIK_URL_OVERRIDE,projectName:process.env.OPIK_PROJECT_NAME,workspaceName:process.env.OPIK_WORKSPACE,batchDelayMs:process.env.OPIK_BATCH_DELAY_MS?Number(process.env.OPIK_BATCH_DELAY_MS):void 0,holdUntilFlush:process.env.OPIK_HOLD_UNTIL_FLUSH===void 0?void 0:["1","true","yes"].includes(String(process.env.OPIK_HOLD_UNTIL_FLUSH).toLowerCase())})}function ag(){let n=process.env.OPIK_CONFIG_PATH||tg;if(!Dm__default.default.existsSync(n)){if(process.env.OPIK_CONFIG_PATH)throw new Error(`Config file not found at ${n}`);return {}}try{let t=og__default.default.parse(Dm__default.default.readFileSync(n,"utf8"));return t.opik?Fm({apiKey:t.opik.api_key,apiUrl:t.opik.url_override,projectName:t.opik.project_name,workspaceName:t.opik.workspace}):{}}catch(t){return z.error(`Error loading config file ${n}: ${t}`),{}}}function Om(n){let t=ig(),e=ag(),{headers:o,...i}=n||{};return ng({...Qa,...e,...t,...i})}function ng(n){if(!n.apiUrl)throw new Error("OPIK_URL_OVERRIDE is not set");let t=sg(n.apiUrl);if(t&&!n.apiKey)throw new Error("OPIK_API_KEY is not set");if(t&&!n.workspaceName)throw new Error("OPIK_WORKSPACE is not set");return n}function sg(n){return new URL(n).hostname.endsWith("comet.com")}var J={};P(J,{AlertAlertType:()=>pg,AlertPublicAlertType:()=>hg,AlertTriggerConfigPublicType:()=>gg,AlertTriggerConfigType:()=>lg,AlertTriggerConfigWriteType:()=>mg,AlertTriggerEventType:()=>cg,AlertTriggerPublicEventType:()=>wg,AlertTriggerWriteEventType:()=>dg,AlertWriteAlertType:()=>ug,AnnotationQueuePublicScope:()=>yg,AnnotationQueueScope:()=>Rg,AnnotationQueueWriteScope:()=>bg,AssistantMessageRole:()=>jg,AttachmentListRequestEntityType:()=>Bm,BadRequestError:()=>A,CheckName:()=>Yg,CheckPublicName:()=>Cw,CheckPublicResult:()=>Iw,CheckResult:()=>Zg,ColumnCompareTypesItem:()=>Wg,ColumnPublicTypesItem:()=>Gg,ColumnTypesItem:()=>$g,CompleteMultipartUploadRequestEntityType:()=>kg,ConflictError:()=>O,DatasetItemCompareSource:()=>Bg,DatasetItemPublicSource:()=>Kg,DatasetItemSource:()=>Mg,DatasetItemWriteSource:()=>dn,DatasetPublicVisibility:()=>Jg,DatasetUpdateVisibility:()=>Km,DatasetVisibility:()=>Ng,DatasetWriteVisibility:()=>Jm,DeleteAttachmentsRequestEntityType:()=>zg,DownloadAttachmentRequestEntityType:()=>Lm,ExperimentItemCompareTraceVisibilityMode:()=>Lg,ExperimentItemPublicTraceVisibilityMode:()=>Xg,ExperimentItemTraceVisibilityMode:()=>Dg,ExperimentPublicStatus:()=>iw,ExperimentPublicType:()=>tw,ExperimentStatus:()=>Qg,ExperimentType:()=>un,ExperimentUpdateStatus:()=>Qm,ExperimentUpdateType:()=>$m,ExperimentWriteStatus:()=>Gm,ExperimentWriteType:()=>Xm,FeedbackScoreBatchItemSource:()=>Pw,FeedbackScoreBatchItemThreadSource:()=>Nw,FeedbackScoreCompareSource:()=>Vg,FeedbackScoreExperimentItemBulkWriteViewSource:()=>ew,FeedbackScorePublicSource:()=>Tw,FeedbackScoreSource:()=>Fg,FindFeedbackDefinitionsRequestType:()=>Ym,FindFeedbackScoreNames1RequestType:()=>sd,ForbiddenError:()=>$,GetSpanStatsRequestType:()=>pd,GetSpansByProjectRequestType:()=>ad,GetWebhookExamplesRequestAlertType:()=>Wm,GuardrailName:()=>aw,GuardrailResult:()=>nw,GuardrailWriteName:()=>sw,GuardrailWriteResult:()=>pw,LlmAsJudgeMessagePublicRole:()=>Pg,LlmAsJudgeMessageRole:()=>Sg,LlmAsJudgeMessageWriteRole:()=>Tg,LlmAsJudgeOutputSchemaPublicType:()=>vg,LlmAsJudgeOutputSchemaType:()=>xg,LlmAsJudgeOutputSchemaWriteType:()=>Ag,LogItemLevel:()=>Ig,ManualEvaluationRequestEntityType:()=>mw,NotFoundError:()=>T,NotImplementedError:()=>lr,OptimizationPublicStatus:()=>gw,OptimizationStatus:()=>dw,OptimizationUpdateStatus:()=>qm,OptimizationWriteStatus:()=>uw,ProjectDetailedVisibility:()=>yw,ProjectMetricRequestPublicInterval:()=>td,ProjectMetricRequestPublicMetricType:()=>od,ProjectMetricResponsePublicInterval:()=>Rw,ProjectMetricResponsePublicMetricType:()=>fw,ProjectPublicVisibility:()=>hw,ProjectUpdateVisibility:()=>rd,ProjectVisibility:()=>ww,ProjectWriteVisibility:()=>ed,PromptType:()=>kw,PromptVersionDetailType:()=>Sw,PromptVersionPublicType:()=>xw,PromptVersionType:()=>zw,PromptWriteType:()=>id,ProviderApiKeyProvider:()=>lw,ProviderApiKeyPublicProvider:()=>cw,ProviderApiKeyWriteProvider:()=>Zm,ResponseFormatType:()=>Ug,SpanExperimentItemBulkWriteViewType:()=>rw,SpanFilterPublicOperator:()=>vw,SpanPublicType:()=>Aw,SpanSearchStreamRequestPublicType:()=>cd,SpanType:()=>we,SpanUpdateType:()=>nd,SpanWriteType:()=>_w,StartMultipartUploadRequestEntityType:()=>Vm,TraceFilterOperator:()=>_g,TraceFilterPublicOperator:()=>Cg,TraceFilterWriteOperator:()=>Eg,TracePublicVisibilityMode:()=>jw,TraceThreadFilterOperator:()=>Mw,TraceThreadFilterPublicOperator:()=>bw,TraceThreadStatus:()=>Uw,TraceVisibilityMode:()=>qg,UnauthorizedError:()=>X,UnprocessableEntityError:()=>W,UploadAttachmentRequestEntityType:()=>Hm,ValueEntryCompareSource:()=>Hg,ValueEntryExperimentItemBulkWriteViewSource:()=>ow,ValueEntryPublicSource:()=>Ew,ValueEntrySource:()=>Og,WebhookTestResultStatus:()=>fg,alerts:()=>xt,annotationQueues:()=>Za,attachments:()=>_t,automationRuleEvaluators:()=>en,chatCompletions:()=>rn,check:()=>qa,dashboards:()=>on,datasets:()=>Tt,experiments:()=>At,feedbackDefinitions:()=>Et,guardrails:()=>tn,llmProviderKey:()=>Pt,manualEvaluation:()=>an,openTelemetryIngestion:()=>nn,optimizations:()=>vt,projects:()=>Ct,prompts:()=>It,redirect:()=>mn,serviceToggles:()=>sn,spans:()=>jt,systemUsage:()=>Ya,traces:()=>pn,welcomeWizard:()=>cn,workspaces:()=>ln});var xt={};P(xt,{GetWebhookExamplesRequestAlertType:()=>Wm});var Wm={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var _t={};P(_t,{AttachmentListRequestEntityType:()=>Bm,DownloadAttachmentRequestEntityType:()=>Lm,StartMultipartUploadRequestEntityType:()=>Vm,UploadAttachmentRequestEntityType:()=>Hm});var Bm={Trace:"trace",Span:"span"};var Lm={Trace:"trace",Span:"span"};var Vm={Trace:"trace",Span:"span"};var Hm={Trace:"trace",Span:"span"};var Tt={};P(Tt,{DatasetUpdateVisibility:()=>Km,DatasetWriteVisibility:()=>Jm});var Jm={Private:"private",Public:"public"};var Km={Private:"private",Public:"public"};var At={};P(At,{ExperimentUpdateStatus:()=>Qm,ExperimentUpdateType:()=>$m,ExperimentWriteStatus:()=>Gm,ExperimentWriteType:()=>Xm});var Xm={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Gm={Running:"running",Completed:"completed",Cancelled:"cancelled"};var $m={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Qm={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Et={};P(Et,{FindFeedbackDefinitionsRequestType:()=>Ym});var Ym={Numerical:"numerical",Categorical:"categorical",Boolean:"boolean"};var Pt={};P(Pt,{ProviderApiKeyWriteProvider:()=>Zm});var Zm={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var vt={};P(vt,{OptimizationUpdateStatus:()=>qm});var qm={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Ct={};P(Ct,{ProjectMetricRequestPublicInterval:()=>td,ProjectMetricRequestPublicMetricType:()=>od,ProjectUpdateVisibility:()=>rd,ProjectWriteVisibility:()=>ed});var ed={Private:"private",Public:"public"};var rd={Private:"private",Public:"public"};var od={FeedbackScores:"FEEDBACK_SCORES",TraceCount:"TRACE_COUNT",TokenUsage:"TOKEN_USAGE",Duration:"DURATION",Cost:"COST",GuardrailsFailedCount:"GUARDRAILS_FAILED_COUNT",ThreadCount:"THREAD_COUNT",ThreadDuration:"THREAD_DURATION",ThreadFeedbackScores:"THREAD_FEEDBACK_SCORES"};var td={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var It={};P(It,{PromptWriteType:()=>id});var id={Mustache:"mustache",Jinja2:"jinja2"};var jt={};P(jt,{FindFeedbackScoreNames1RequestType:()=>sd,GetSpanStatsRequestType:()=>pd,GetSpansByProjectRequestType:()=>ad,SpanSearchStreamRequestPublicType:()=>cd,SpanUpdateType:()=>nd});var ad={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var nd={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var sd={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var pd={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var cd={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Ya={};var Za={};var qa={};var en={};var rn={};var on={};var tn={};var an={};var nn={};var sn={};var pn={};var cn={};var ln={};var mn={};var pg={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var cg={TraceErrors:"trace:errors",TraceFeedbackScore:"trace:feedback_score",TraceThreadFeedbackScore:"trace_thread:feedback_score",PromptCreated:"prompt:created",PromptCommitted:"prompt:committed",TraceGuardrailsTriggered:"trace:guardrails_triggered",PromptDeleted:"prompt:deleted",ExperimentFinished:"experiment:finished",TraceCost:"trace:cost",TraceLatency:"trace:latency"};var lg={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score",ThresholdCost:"threshold:cost",ThresholdLatency:"threshold:latency"};var mg={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score",ThresholdCost:"threshold:cost",ThresholdLatency:"threshold:latency"};var dg={TraceErrors:"trace:errors",TraceFeedbackScore:"trace:feedback_score",TraceThreadFeedbackScore:"trace_thread:feedback_score",PromptCreated:"prompt:created",PromptCommitted:"prompt:committed",TraceGuardrailsTriggered:"trace:guardrails_triggered",PromptDeleted:"prompt:deleted",ExperimentFinished:"experiment:finished",TraceCost:"trace:cost",TraceLatency:"trace:latency"};var ug={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var gg={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score",ThresholdCost:"threshold:cost",ThresholdLatency:"threshold:latency"};var wg={TraceErrors:"trace:errors",TraceFeedbackScore:"trace:feedback_score",TraceThreadFeedbackScore:"trace_thread:feedback_score",PromptCreated:"prompt:created",PromptCommitted:"prompt:committed",TraceGuardrailsTriggered:"trace:guardrails_triggered",PromptDeleted:"prompt:deleted",ExperimentFinished:"experiment:finished",TraceCost:"trace:cost",TraceLatency:"trace:latency"};var hg={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var fg={Success:"success",Failure:"failure"};var Rg={Trace:"trace",Thread:"thread"};var bg={Trace:"trace",Thread:"thread"};var yg={Trace:"trace",Thread:"thread"};var kg={Trace:"trace",Span:"span"};var zg={Trace:"trace",Span:"span"};var Sg={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var xg={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var _g={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var Tg={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var Ag={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var Eg={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var Pg={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var vg={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var Cg={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var Ig={Info:"INFO",Warn:"WARN",Error:"ERROR",Debug:"DEBUG",Trace:"TRACE"};var jg={System:"system",User:"user",Assistant:"assistant",Tool:"tool",Function:"function"};var Ug={Text:"text",JsonObject:"json_object",JsonSchema:"json_schema"};var Ng={Private:"private",Public:"public"};var Mg={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Dg={Default:"default",Hidden:"hidden"};var Fg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Og={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var dn={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Wg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var Bg={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Lg={Default:"default",Hidden:"hidden"};var Vg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Hg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Jg={Private:"private",Public:"public"};var Kg={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Xg={Default:"default",Hidden:"hidden"};var Gg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var $g={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var un={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Qg={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Yg={Topic:"TOPIC",Pii:"PII"};var Zg={Passed:"passed",Failed:"failed"};var we={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var qg={Default:"default",Hidden:"hidden"};var ew={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var rw={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var ow={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var tw={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var iw={Running:"running",Completed:"completed",Cancelled:"cancelled"};var aw={Topic:"TOPIC",Pii:"PII"};var nw={Passed:"passed",Failed:"failed"};var sw={Topic:"TOPIC",Pii:"PII"};var pw={Passed:"passed",Failed:"failed"};var cw={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var lw={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var mw={Trace:"trace",Thread:"thread"};var dw={Running:"running",Completed:"completed",Cancelled:"cancelled"};var uw={Running:"running",Completed:"completed",Cancelled:"cancelled"};var gw={Running:"running",Completed:"completed",Cancelled:"cancelled"};var ww={Private:"private",Public:"public"};var hw={Private:"private",Public:"public"};var fw={FeedbackScores:"FEEDBACK_SCORES",TraceCount:"TRACE_COUNT",TokenUsage:"TOKEN_USAGE",Duration:"DURATION",Cost:"COST",GuardrailsFailedCount:"GUARDRAILS_FAILED_COUNT",ThreadCount:"THREAD_COUNT",ThreadDuration:"THREAD_DURATION",ThreadFeedbackScores:"THREAD_FEEDBACK_SCORES"};var Rw={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var bw={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var yw={Private:"private",Public:"public"};var kw={Mustache:"mustache",Jinja2:"jinja2"};var zw={Mustache:"mustache",Jinja2:"jinja2"};var Sw={Mustache:"mustache",Jinja2:"jinja2"};var xw={Mustache:"mustache",Jinja2:"jinja2"};var _w={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Tw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Aw={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Ew={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Pw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var vw={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var Cw={Topic:"TOPIC",Pii:"PII"};var Iw={Passed:"passed",Failed:"failed"};var jw={Default:"default",Hidden:"hidden"};var Uw={Active:"active",Inactive:"inactive"};var Nw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Mw={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var Je=(n,t,e)=>JSON.stringify(n,t,e);var p=class n extends Error{constructor({message:t,statusCode:e,body:o,rawResponse:i}){super(Dw({message:t,statusCode:e,body:o})),Object.setPrototypeOf(this,n.prototype),this.statusCode=e,this.body=o,this.rawResponse=i;}};function Dw({message:n,statusCode:t,body:e}){let o=[];return n!=null&&o.push(n),t!=null&&o.push(`Status code: ${t.toString()}`),e!=null&&o.push(`Body: ${Je(e,void 0,2)}`),o.join(`
2
+ `)}var w=class n extends Error{constructor(t){super(t),Object.setPrototypeOf(this,n.prototype);}};var A=class n extends p{constructor(t,e){super({message:"BadRequestError",statusCode:400,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var O=class n extends p{constructor(t,e){super({message:"ConflictError",statusCode:409,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var W=class n extends p{constructor(t,e){super({message:"UnprocessableEntityError",statusCode:422,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var T=class n extends p{constructor(t,e){super({message:"NotFoundError",statusCode:404,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var X=class n extends p{constructor(t,e){super({message:"UnauthorizedError",statusCode:401,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var $=class n extends p{constructor(t,e){super({message:"ForbiddenError",statusCode:403,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var lr=class n extends p{constructor(t,e){super({message:"NotImplementedError",statusCode:501,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var f={Default:"http://localhost:5173/api"};var mr;typeof globalThis.Headers!="undefined"?mr=globalThis.Headers:mr=class ld{constructor(t){if(this.headers=new Map,t)if(t instanceof ld)t.forEach((e,o)=>this.append(o,e));else if(Array.isArray(t))for(let[e,o]of t)if(typeof e=="string"&&typeof o=="string")this.append(e,o);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[e,o]of Object.entries(t))if(typeof o=="string")this.append(e,o);else throw new TypeError("Header values must be strings")}append(t,e){let o=t.toLowerCase(),i=this.headers.get(o)||[];this.headers.set(o,[...i,e]);}delete(t){let e=t.toLowerCase();this.headers.delete(e);}get(t){let e=t.toLowerCase(),o=this.headers.get(e);return o?o.join(", "):null}has(t){let e=t.toLowerCase();return this.headers.has(e)}set(t,e){let o=t.toLowerCase();this.headers.set(o,[e]);}forEach(t,e){let o=e?t.bind(e):t;this.headers.forEach((i,a)=>o(i.join(", "),a,this));}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[t,e]of this.headers.entries())yield [t,e.join(", ")];}*keys(){yield*this.headers.keys();}*values(){for(let t of this.headers.values())yield t.join(", ");}[Symbol.iterator](){return this.entries()}};var Ut={headers:new mr,redirected:false,status:499,statusText:"Client Closed Request",type:"error",url:""},Nt={headers:new mr,redirected:false,status:0,statusText:"Unknown Error",type:"error",url:""};function Mt(n){return {headers:n.headers,redirected:n.redirected,status:n.status,statusText:n.statusText,type:n.type,url:n.url}}function md(n,t){return Object.keys(t!=null?t:{}).length>0?`${n}?${Fw__default.default.stringify(t,{arrayFormat:"repeat"})}`:n}var d=Ow();function Ow(){var u,g,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"&&(((g=self.constructor)==null?void 0:g.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 dd(){return d.type==="node"&&d.parsedVersion!=null&&d.parsedVersion>=18?fetch:d.type==="node"?(await import('node-fetch')).default:typeof fetch=="function"?fetch:(await import('node-fetch')).default}async function ud({body:n,type:t}){return t.includes("json")?Je(n):n}async function yd(n){return d.type==="node"&&d.parsedVersion!=null&&d.parsedVersion>=18?new(await Promise.resolve().then(()=>(wd(),gd))).Node18UniversalStreamWrapper(n):d.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(fd(),hd))).UndiciStreamWrapper(n):new(await Promise.resolve().then(()=>(bd(),Rd))).NodePre18StreamWrapper(n)}async function kd(n,t){if(n.body!=null&&t==="blob")return await n.blob();if(n.body!=null&&t==="arrayBuffer")return await n.arrayBuffer();if(n.body!=null&&t==="sse")return n.body;if(n.body!=null&&t==="streaming")return yd(n.body);if(n.body!=null&&t==="text")return await n.text();{let e=await n.text();if(e.length>0)try{return JSON.parse(e)}catch{return {ok:false,error:{reason:"non-json",statusCode:n.status,rawBody:e}}}else return}}var Ww="timeout";function zd(n){let t=new AbortController,e=setTimeout(()=>t.abort(Ww),n);return {signal:t.signal,abortId:e}}function Sd(...n){let t=n.length===1&&Array.isArray(n[0])?n[0]:n,e=new AbortController;for(let o of t){if(o.aborted){e.abort(o==null?void 0:o.reason);break}o.addEventListener("abort",()=>e.abort(o==null?void 0:o.reason),{signal:e.signal});}return e.signal}var xd=async(n,t,e,o,i,a,c,m,u)=>{let g=[],y;if(a!=null){let{signal:x,abortId:_}=zd(a);y=_,g.push(x);}c!=null&&g.push(c);let k=Sd(g),S=await n(t,{method:e,headers:o,body:i,signal:k,credentials:m?"include":void 0,duplex:u});return y!=null&&clearTimeout(y),S};function Bw(n){let t=1+(Math.random()*2-1)*.2;return n*t}async function _d(n,t=2){let e=await n();for(let o=0;o<t&&([408,429].includes(e.status)||e.status>=500);++o){let i=Math.min(1e3*Math.pow(2,o),6e4),a=Bw(i);await new Promise(c=>setTimeout(c,a)),e=await n();}return e}async function Lw(n){let t={};if(n.body!==void 0&&n.contentType!=null&&(t["Content-Type"]=n.contentType),n.headers!=null)for(let[a,c]of Object.entries(n.headers))c!=null&&(t[a]=c);let e=md(n.url,n.queryParameters),o=await ud({body:n.body,type:n.requestType==="json"?"json":"other"}),i=await dd();try{let a=await _d(async()=>xd(i,e,n.method,t,o,n.timeoutMs,n.abortSignal,n.withCredentials,n.duplex),n.maxRetries),c=await kd(a,n.responseType);return a.status>=200&&a.status<400?{ok:!0,body:c,headers:a.headers,rawResponse:Mt(a)}:{ok:!1,error:{reason:"status-code",statusCode:a.status,body:c},rawResponse:Mt(a)}}catch(a){return n.abortSignal!=null&&n.abortSignal.aborted?{ok:false,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:Ut}:a instanceof Error&&a.name==="AbortError"?{ok:false,error:{reason:"timeout"},rawResponse:Ut}:a instanceof Error?{ok:false,error:{reason:"unknown",errorMessage:a.message},rawResponse:Nt}:{ok:false,error:{reason:"unknown",errorMessage:Je(a)},rawResponse:Nt}}}var R=Lw;var s={get:async n=>typeof n=="function"?n():n};var h=class n extends Promise{constructor(t){super(e=>{e(void 0);}),this.innerPromise=t;}static fromFunction(t,...e){return new n(t(...e))}static interceptFunction(t){return (...e)=>n.fromPromise(t(...e))}static fromPromise(t){return new n(t)}static fromExecutor(t){let e=new Promise(t);return new n(e)}static fromResult(t){let e=Promise.resolve(t);return new n(e)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:t})=>t)),this.unwrappedPromise}then(t,e){return this.unwrap().then(t,e)}catch(t){return this.unwrap().catch(t)}finally(t){return this.unwrap().finally(t)}async withRawResponse(){return await this.innerPromise}};var r={};P(r,{JsonError:()=>Ke,ParseError:()=>Xe,any:()=>Wd,bigint:()=>Ad,boolean:()=>Bd,booleanLiteral:()=>Od,date:()=>Ed,discriminant:()=>Qd,enum_:()=>Ft,getObjectLikeUtils:()=>le,getObjectUtils:()=>je,getSchemaUtils:()=>j,isProperty:()=>_e,lazy:()=>Pd,lazyObject:()=>Md,list:()=>Wt,number:()=>Ld,object:()=>Ot,objectWithoutOptionalProperties:()=>Nd,optional:()=>fn,property:()=>Cd,record:()=>Kd,set:()=>Xd,string:()=>Vd,stringLiteral:()=>Fd,transform:()=>Rn,undiscriminatedUnion:()=>$d,union:()=>Zd,unknown:()=>Hd,withParsedProperties:()=>yn});var E={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 I(n,t){return `Expected ${t}. Received ${Vw(n)}.`}function Vw(n){if(Array.isArray(n))return "list";if(n===null)return "null";if(n instanceof BigInt)return "BigInt";switch(typeof n){case "string":return `"${n}"`;case "bigint":case "number":case "boolean":case "undefined":return `${n}`}return typeof n}function G(n){return {...n,json:Td(n.json),parse:Td(n.parse)}}function Td(n){return (t,e)=>{let o=n(t,e),{skipValidation:i=false}=e!=null?e:{};return !o.ok&&i?(console.warn(["Failed to validate.",...o.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
3
+ `)),{ok:true,value:t}):o}}function Dt(n){return n.path.length===0?n.message:`${n.path.join(" -> ")}: ${n.message}`}var Ke=class n extends Error{constructor(e){super(e.map(Dt).join("; "));this.errors=e;Object.setPrototypeOf(this,n.prototype);}};var Xe=class n extends Error{constructor(e){super(e.map(Dt).join("; "));this.errors=e;Object.setPrototypeOf(this,n.prototype);}};function j(n){return {nullable:()=>Hw(n),optional:()=>fn(n),optionalNullable:()=>Jw(n),transform:t=>Rn(n,t),parseOrThrow:(t,e)=>{let o=n.parse(t,e);if(o.ok)return o.value;throw new Xe(o.errors)},jsonOrThrow:(t,e)=>{let o=n.json(t,e);if(o.ok)return o.value;throw new Ke(o.errors)}}}function Hw(n){let t={parse:(e,o)=>e==null?{ok:true,value:null}:n.parse(e,o),json:(e,o)=>e==null?{ok:true,value:null}:n.json(e,o),getType:()=>E.NULLABLE};return {...t,...j(t)}}function fn(n){let t={parse:(e,o)=>e==null?{ok:true,value:void 0}:n.parse(e,o),json:(e,o)=>o!=null&&o.omitUndefined&&e===void 0?{ok:true,value:void 0}:e==null?{ok:true,value:null}:n.json(e,o),getType:()=>E.OPTIONAL};return {...t,...j(t)}}function Jw(n){let t={parse:(e,o)=>e===void 0?{ok:true,value:void 0}:e===null?{ok:true,value:null}:n.parse(e,o),json:(e,o)=>e===void 0?{ok:true,value:void 0}:e===null?{ok:true,value:null}:n.json(e,o),getType:()=>E.OPTIONAL_NULLABLE};return {...t,...j(t)}}function Rn(n,t){let e={parse:(o,i)=>{let a=n.parse(o,i);return a.ok?{ok:true,value:t.transform(a.value)}:a},json:(o,i)=>{let a=t.untransform(o);return n.json(a,i)},getType:()=>n.getType()};return {...e,...j(e)}}function Ad(){let n={parse:(t,{breadcrumbsPrefix:e=[]}={})=>typeof t=="bigint"?{ok:true,value:t}:typeof t=="number"?{ok:true,value:BigInt(t)}:{ok:false,errors:[{path:e,message:I(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:e=[]}={})=>typeof t!="bigint"?{ok:false,errors:[{path:e,message:I(t,"bigint")}]}:{ok:true,value:t},getType:()=>E.BIGINT};return {...G(n),...j(n)}}var Kw=/^([+-]?\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 Ed(){let n={parse:(t,{breadcrumbsPrefix:e=[]}={})=>typeof t!="string"?{ok:false,errors:[{path:e,message:I(t,"string")}]}:Kw.test(t)?{ok:true,value:new Date(t)}:{ok:false,errors:[{path:e,message:I(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:e=[]}={})=>t instanceof Date?{ok:true,value:t.toISOString()}:{ok:false,errors:[{path:e,message:I(t,"Date object")}]},getType:()=>E.DATE};return {...G(n),...j(n)}}function Q(n,t){return ()=>{let e={parse:t,json:t,getType:()=>n};return {...G(e),...j(e)}}}function Ft(n){let t=new Set(n);return Q(E.ENUM,(o,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof o!="string"?{ok:false,errors:[{path:a,message:I(o,"string")}]}:!t.has(o)&&!i?{ok:false,errors:[{path:a,message:I(o,"enum")}]}:{ok:true,value:o})()}function Pd(n){let t=bn(n);return {...t,...j(t)}}function bn(n){return {parse:(t,e)=>Ge(n).parse(t,e),json:(t,e)=>Ge(n).json(t,e),getType:()=>Ge(n).getType()}}function Ge(n){let t=n;return t.__zurg_memoized==null&&(t.__zurg_memoized=n()),t.__zurg_memoized}function dr(n){return Object.entries(n)}function ur(n,t){let e=new Set(t);return Object.entries(n).reduce((o,[i,a])=>(e.has(i)&&(o[i]=a),o),{})}function xe(n){if(typeof n!="object"||n===null)return false;if(Object.getPrototypeOf(n)===null)return true;let t=n;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(n)===t}function gr(n){return Object.keys(n)}function vd(n,t){let e=[],o=[];for(let i of n)t(i)?e.push(i):o.push(i);return [e,o]}function le(n){return {withParsedProperties:t=>yn(n,t)}}function yn(n,t){let e={parse:(o,i)=>{let a=n.parse(o,i);if(!a.ok)return a;let c=Object.entries(t).reduce((m,[u,g])=>({...m,[u]:typeof g=="function"?g(a.value):g}),{});return {ok:true,value:{...a.value,...c}}},json:(o,i)=>{var m;if(!xe(o))return {ok:false,errors:[{path:(m=i==null?void 0:i.breadcrumbsPrefix)!=null?m:[],message:I(o,"object")}]};let a=new Set(Object.keys(t)),c=ur(o,Object.keys(o).filter(u=>!a.has(u)));return n.json(c,i)},getType:()=>n.getType()};return {...e,...j(e),...le(e)}}function Cd(n,t){return {rawKey:n,valueSchema:t,isProperty:true}}function _e(n){return n.isProperty}function Ot(n){let t={_getRawProperties:()=>Object.entries(n).map(([e,o])=>_e(o)?o.rawKey:e),_getParsedProperties:()=>gr(n),parse:(e,o)=>{let i={},a=[];for(let[c,m]of dr(n)){let u=_e(m)?m.rawKey:c,g=_e(m)?m.valueSchema:m,y={rawKey:u,parsedKey:c,valueSchema:g};i[u]=y,Ud(g)&&a.push(u);}return Id({value:e,requiredKeys:a,getProperty:c=>{let m=i[c];if(m!=null)return {transformedKey:m.parsedKey,transform:u=>{var g;return m.valueSchema.parse(u,{...o,breadcrumbsPrefix:[...(g=o==null?void 0:o.breadcrumbsPrefix)!=null?g:[],c]})}}},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:(e,o)=>{let i=[];for(let[a,c]of dr(n)){let m=_e(c)?c.valueSchema:c;Ud(m)&&i.push(a);}return Id({value:e,requiredKeys:i,getProperty:a=>{let c=n[a];if(c!=null)return _e(c)?{transformedKey:c.rawKey,transform:m=>{var u;return c.valueSchema.json(m,{...o,breadcrumbsPrefix:[...(u=o==null?void 0:o.breadcrumbsPrefix)!=null?u:[],a]})}}:{transformedKey:a,transform:m=>{var u;return c.json(m,{...o,breadcrumbsPrefix:[...(u=o==null?void 0:o.breadcrumbsPrefix)!=null?u:[],a]})}}},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:()=>E.OBJECT};return {...G(t),...j(t),...le(t),...je(t)}}function Id({value:n,requiredKeys:t,getProperty:e,unrecognizedObjectKeys:o="fail",skipValidation:i=false,breadcrumbsPrefix:a=[]}){if(!xe(n))return {ok:false,errors:[{path:a,message:I(n,"object")}]};let c=new Set(t),m=[],u={};for(let[g,y]of Object.entries(n)){let k=e(g);if(k!=null){c.delete(g);let S=k.transform(y);S.ok?u[k.transformedKey]=S.value:(u[g]=y,m.push(...S.errors));}else switch(o){case "fail":m.push({path:[...a,g],message:`Unexpected key "${g}"`});break;case "strip":break;case "passthrough":u[g]=y;break}}return m.push(...t.filter(g=>c.has(g)).map(g=>({path:a,message:`Missing required key "${g}"`}))),m.length===0||i?{ok:true,value:u}:{ok:false,errors:m}}function je(n){return {extend:t=>{let e={_getParsedProperties:()=>[...n._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...n._getRawProperties(),...t._getRawProperties()],parse:(o,i)=>jd({extensionKeys:t._getRawProperties(),value:o,transformBase:a=>n.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(o,i)=>jd({extensionKeys:t._getParsedProperties(),value:o,transformBase:a=>n.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>E.OBJECT};return {...e,...j(e),...le(e),...je(e)}},passthrough:()=>{let t={_getParsedProperties:()=>n._getParsedProperties(),_getRawProperties:()=>n._getRawProperties(),parse:(e,o)=>{let i=n.parse(e,{...o,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:true,value:{...e,...i.value}}:i},json:(e,o)=>{let i=n.json(e,{...o,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:true,value:{...e,...i.value}}:i},getType:()=>E.OBJECT};return {...t,...j(t),...le(t),...je(t)}}}}function jd({extensionKeys:n,value:t,transformBase:e,transformExtension:o}){let i=new Set(n),[a,c]=vd(gr(t),g=>i.has(g)),m=e(ur(t,c)),u=o(ur(t,a));return m.ok&&u.ok?{ok:true,value:{...m.value,...u.value}}:{ok:false,errors:[...m.ok?[]:m.errors,...u.ok?[]:u.errors]}}function Ud(n){return !Xw(n)}function Xw(n){switch(n.getType()){case E.ANY:case E.UNKNOWN:case E.OPTIONAL:case E.OPTIONAL_NULLABLE:return true;default:return false}}function Nd(n){return Ot(n)}function Md(n){let t={...bn(n),_getRawProperties:()=>Ge(n)._getRawProperties(),_getParsedProperties:()=>Ge(n)._getParsedProperties()};return {...t,...j(t),...le(t),...je(t)}}function Wt(n){let t={parse:(e,o)=>Dd(e,(i,a)=>{var c;return n.parse(i,{...o,breadcrumbsPrefix:[...(c=o==null?void 0:o.breadcrumbsPrefix)!=null?c:[],`[${a}]`]})}),json:(e,o)=>Dd(e,(i,a)=>{var c;return n.json(i,{...o,breadcrumbsPrefix:[...(c=o==null?void 0:o.breadcrumbsPrefix)!=null?c:[],`[${a}]`]})}),getType:()=>E.LIST};return {...G(t),...j(t)}}function Dd(n,t){return Array.isArray(n)?n.map((o,i)=>t(o,i)).reduce((o,i)=>{if(o.ok&&i.ok)return {ok:true,value:[...o.value,i.value]};let a=[];return o.ok||a.push(...o.errors),i.ok||a.push(...i.errors),{ok:false,errors:a}},{ok:true,value:[]}):{ok:false,errors:[{message:I(n,"list"),path:[]}]}}function Fd(n){return Q(E.STRING_LITERAL,(e,{breadcrumbsPrefix:o=[]}={})=>e===n?{ok:true,value:n}:{ok:false,errors:[{path:o,message:I(e,`"${n}"`)}]})()}function Od(n){return Q(E.BOOLEAN_LITERAL,(e,{breadcrumbsPrefix:o=[]}={})=>e===n?{ok:true,value:n}:{ok:false,errors:[{path:o,message:I(e,`${n.toString()}`)}]})()}var Wd=Q(E.ANY,n=>({ok:true,value:n}));var Bd=Q(E.BOOLEAN,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="boolean"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:I(n,"boolean")}]});var Ld=Q(E.NUMBER,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="number"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:I(n,"number")}]});var Vd=Q(E.STRING,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="string"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:I(n,"string")}]});var Hd=Q(E.UNKNOWN,n=>({ok:true,value:n}));function Kd(n,t){let e={parse:(o,i)=>Jd({value:o,isKeyNumeric:n.getType()===E.NUMBER,transformKey:a=>{var c;return n.parse(a,{...i,breadcrumbsPrefix:[...(c=i==null?void 0:i.breadcrumbsPrefix)!=null?c:[],`${a} (key)`]})},transformValue:(a,c)=>{var m;return t.parse(a,{...i,breadcrumbsPrefix:[...(m=i==null?void 0:i.breadcrumbsPrefix)!=null?m:[],`${c}`]})},breadcrumbsPrefix:i==null?void 0:i.breadcrumbsPrefix}),json:(o,i)=>Jd({value:o,isKeyNumeric:n.getType()===E.NUMBER,transformKey:a=>{var c;return n.json(a,{...i,breadcrumbsPrefix:[...(c=i==null?void 0:i.breadcrumbsPrefix)!=null?c:[],`${a} (key)`]})},transformValue:(a,c)=>{var m;return t.json(a,{...i,breadcrumbsPrefix:[...(m=i==null?void 0:i.breadcrumbsPrefix)!=null?m:[],`${c}`]})},breadcrumbsPrefix:i==null?void 0:i.breadcrumbsPrefix}),getType:()=>E.RECORD};return {...G(e),...j(e)}}function Jd({value:n,isKeyNumeric:t,transformKey:e,transformValue:o,breadcrumbsPrefix:i=[]}){return xe(n)?dr(n).reduce((a,[c,m])=>{if(m===void 0)return a;let u=a,g=c;if(t){let x=c.length>0?Number(c):NaN;isNaN(x)||(g=x);}let y=e(g),k=o(m,g);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:i,message:I(n,"object")}]}}function Xd(n){let t=Wt(n),e={parse:(o,i)=>{let a=t.parse(o,i);return a.ok?{ok:true,value:new Set(a.value)}:a},json:(o,i)=>{var c;return o instanceof Set?t.json([...o],i):{ok:false,errors:[{path:(c=i==null?void 0:i.breadcrumbsPrefix)!=null?c:[],message:I(o,"Set")}]}},getType:()=>E.SET};return {...G(e),...j(e)}}function $d(n){let t={parse:(e,o)=>Gd((i,a)=>i.parse(e,a),n,o),json:(e,o)=>Gd((i,a)=>i.json(e,a),n,o),getType:()=>E.UNDISCRIMINATED_UNION};return {...G(t),...j(t)}}function Gd(n,t,e){let o=[];for(let[i,a]of t.entries()){let c=n(a,{...e,skipValidation:false});if(c.ok)return c;for(let m of c.errors)o.push({path:m.path,message:`[Variant ${i}] ${m.message}`});}return {ok:false,errors:o}}function Qd(n,t){return {parsedDiscriminant:n,rawDiscriminant:t}}function Zd(n,t){let e=typeof n=="string"?n:n.rawDiscriminant,o=typeof n=="string"?n:n.parsedDiscriminant,i=Ft(gr(t)),a={parse:(c,m)=>Yd({value:c,discriminant:e,transformedDiscriminant:o,transformDiscriminantValue:u=>{var g;return i.parse(u,{allowUnrecognizedEnumValues:m==null?void 0:m.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(g=m==null?void 0:m.breadcrumbsPrefix)!=null?g:[],e]})},getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:m==null?void 0:m.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,g)=>g.parse(u,m),breadcrumbsPrefix:m==null?void 0:m.breadcrumbsPrefix}),json:(c,m)=>Yd({value:c,discriminant:o,transformedDiscriminant:e,transformDiscriminantValue:u=>{var g;return i.json(u,{allowUnrecognizedEnumValues:m==null?void 0:m.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(g=m==null?void 0:m.breadcrumbsPrefix)!=null?g:[],o]})},getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:m==null?void 0:m.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,g)=>g.json(u,m),breadcrumbsPrefix:m==null?void 0:m.breadcrumbsPrefix}),getType:()=>E.UNION};return {...G(a),...j(a),...le(a)}}function Yd({value:n,discriminant:t,transformedDiscriminant:e,transformDiscriminantValue:o,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=false,transformAdditionalProperties:c,breadcrumbsPrefix:m=[]}){if(!xe(n))return {ok:false,errors:[{path:m,message:I(n,"object")}]};let{[t]:u,...g}=n;if(u==null)return {ok:false,errors:[{path:m,message:`Missing discriminant ("${t}")`}]};let y=o(u);if(!y.ok)return {ok:false,errors:y.errors};let k=i(y.value);if(k==null)return a?{ok:true,value:{[e]:y.value,...g}}:{ok:false,errors:[{path:[...m,t],message:"Unexpected discriminant value"}]};let S=c(g,k);return S.ok?{ok:true,value:{[e]:u,...S.value}}:S}function Gw(n){var t=[];if(n.length===0)return "";if(typeof n[0]!="string")throw new TypeError("Url must be a string. Received "+n[0]);if(n[0].match(/^[^/:]+:\/*$/)&&n.length>1){var e=n.shift();n[0]=e+n[0];}n[0].match(/^file:\/\/\//)?n[0]=n[0].replace(/^([^/:]+):\/*/,"$1:///"):n[0]=n[0].replace(/^([^/:]+):\/*/,"$1://");for(var o=0;o<n.length;o++){var i=n[o];if(typeof i!="string")throw new TypeError("Url must be a string. Received "+i);i!==""&&(o>0&&(i=i.replace(/^[\/]+/,"")),o<n.length-1?i=i.replace(/[\/]+$/,""):i=i.replace(/[\/]+$/,"/"),t.push(i));}var a=t.join("/");a=a.replace(/\/(\?|&|#[^!])/g,"$1");var c=a.split("?");return a=c.shift()+(c.length>0?"?":"")+c.join("&"),a}function b(){var n;return typeof arguments[0]=="object"?n=arguments[0]:n=[].slice.call(arguments),Gw(n)}var v={};P(v,{AggregationData:()=>Cc,Alert:()=>eh,AlertAlertType:()=>ls,AlertPagePublic:()=>Es,AlertPublic:()=>Ro,AlertPublicAlertType:()=>zs,AlertTrigger:()=>ws,AlertTriggerConfig:()=>gs,AlertTriggerConfigPublic:()=>Ts,AlertTriggerConfigPublicType:()=>_s,AlertTriggerConfigType:()=>us,AlertTriggerConfigWrite:()=>fs,AlertTriggerConfigWriteType:()=>hs,AlertTriggerEventType:()=>ds,AlertTriggerPublic:()=>As,AlertTriggerPublicEventType:()=>xs,AlertTriggerWrite:()=>bs,AlertTriggerWriteEventType:()=>Rs,AlertWrite:()=>fo,AlertWriteAlertType:()=>ys,AnnotationQueue:()=>Us,AnnotationQueueBatch:()=>oh,AnnotationQueueBatchWrite:()=>po,AnnotationQueueItemIds:()=>Pi,AnnotationQueuePagePublic:()=>Ds,AnnotationQueuePublic:()=>bo,AnnotationQueuePublicScope:()=>Ns,AnnotationQueueReviewer:()=>js,AnnotationQueueReviewerPublic:()=>Ms,AnnotationQueueScope:()=>Is,AnnotationQueueUpdate:()=>co,AnnotationQueueWrite:()=>so,AnnotationQueueWriteScope:()=>$n,AssistantMessage:()=>vp,AssistantMessageRole:()=>Pp,Attachment:()=>Fs,AttachmentListRequestEntityType:()=>Vt,AttachmentPage:()=>Os,AuthDetailsHolder:()=>Hs,AutomationRuleEvaluator:()=>ih,AutomationRuleEvaluatorLlmAsJudge:()=>$s,AutomationRuleEvaluatorLlmAsJudgePublic:()=>Uo,AutomationRuleEvaluatorLlmAsJudgeWrite:()=>op,AutomationRuleEvaluatorObjectPublic:()=>Rp,AutomationRuleEvaluatorPagePublic:()=>bp,AutomationRuleEvaluatorPublic:()=>yp,AutomationRuleEvaluatorTraceThreadLlmAsJudge:()=>Ys,AutomationRuleEvaluatorTraceThreadLlmAsJudgePublic:()=>Mo,AutomationRuleEvaluatorTraceThreadLlmAsJudgeWrite:()=>ip,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPython:()=>Zs,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPythonPublic:()=>Do,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPythonWrite:()=>np,AutomationRuleEvaluatorUpdate:()=>Ep,AutomationRuleEvaluatorUpdateLlmAsJudge:()=>xp,AutomationRuleEvaluatorUpdateTraceThreadLlmAsJudge:()=>Tp,AutomationRuleEvaluatorUpdateTraceThreadUserDefinedMetricPython:()=>Ap,AutomationRuleEvaluatorUpdateUserDefinedMetricPython:()=>_p,AutomationRuleEvaluatorUserDefinedMetricPython:()=>Qs,AutomationRuleEvaluatorUserDefinedMetricPythonPublic:()=>No,AutomationRuleEvaluatorUserDefinedMetricPythonWrite:()=>pp,AutomationRuleEvaluatorWrite:()=>mp,AvgValueStatPublic:()=>rc,BatchDelete:()=>B,BatchDeleteByProject:()=>xh,BiInformation:()=>as,BiInformationResponse:()=>Ze,BooleanFeedbackDefinition:()=>Mc,BooleanFeedbackDefinitionCreate:()=>Vc,BooleanFeedbackDefinitionPublic:()=>Ko,BooleanFeedbackDefinitionUpdate:()=>al,BooleanFeedbackDetail:()=>Nc,BooleanFeedbackDetailCreate:()=>Lc,BooleanFeedbackDetailPublic:()=>Qc,BooleanFeedbackDetailUpdate:()=>il,CategoricalFeedbackDefinition:()=>Fc,CategoricalFeedbackDefinitionCreate:()=>Jc,CategoricalFeedbackDefinitionPublic:()=>Xo,CategoricalFeedbackDefinitionUpdate:()=>sl,CategoricalFeedbackDetail:()=>Dc,CategoricalFeedbackDetailCreate:()=>Hc,CategoricalFeedbackDetailPublic:()=>Yc,CategoricalFeedbackDetailUpdate:()=>nl,ChatCompletionChoice:()=>Ip,ChatCompletionRequest:()=>mo,ChatCompletionResponse:()=>Mp,Check:()=>bc,CheckName:()=>fc,CheckPublic:()=>am,CheckPublicName:()=>tm,CheckPublicResult:()=>im,CheckResult:()=>Rc,ChunkedOutputJsonNode:()=>ph,ChunkedOutputJsonNodePublic:()=>dh,ChunkedOutputJsonNodePublicType:()=>Uc,ChunkedOutputJsonNodeType:()=>gc,Column:()=>dc,ColumnCompare:()=>Lp,ColumnCompareTypesItem:()=>Bp,ColumnPublic:()=>cc,ColumnPublicTypesItem:()=>pc,ColumnTypesItem:()=>mc,Comment:()=>L,CommentCompare:()=>Vp,CommentPublic:()=>Oe,CompleteMultipartUploadRequest:()=>vi,CompleteMultipartUploadRequestEntityType:()=>Ws,CompletionTokensDetails:()=>Up,CountValueStatPublic:()=>oc,CreateDatasetItemsFromSpansRequest:()=>Rr,CreateDatasetItemsFromTracesRequest:()=>br,CreatePromptVersionDetail:()=>Vr,DashboardPagePublic:()=>Dp,DashboardPublic:()=>De,DashboardUpdatePublic:()=>go,DashboardWrite:()=>uo,DataPointDouble:()=>_h,DataPointNumberPublic:()=>El,Dataset:()=>ah,DatasetExpansion:()=>sh,DatasetExpansionResponse:()=>Wp,DatasetExpansionWrite:()=>Sr,DatasetIdentifier:()=>kr,DatasetIdentifierPublic:()=>xr,DatasetItem:()=>Oo,DatasetItemBatch:()=>nh,DatasetItemBatchWrite:()=>fr,DatasetItemCompare:()=>Yp,DatasetItemCompareSource:()=>Hp,DatasetItemPageCompare:()=>Zp,DatasetItemPagePublic:()=>lc,DatasetItemPublic:()=>Lo,DatasetItemPublicSource:()=>nc,DatasetItemSource:()=>Op,DatasetItemStreamRequest:()=>_r,DatasetItemWrite:()=>zn,DatasetItemWriteSource:()=>kn,DatasetItemsDelete:()=>zr,DatasetPagePublic:()=>ec,DatasetPublic:()=>qe,DatasetPublicVisibility:()=>qp,DatasetUpdate:()=>yr,DatasetUpdateVisibility:()=>$t,DatasetVisibility:()=>Fp,DatasetWrite:()=>hr,DatasetWriteVisibility:()=>Gt,DeleteAttachmentsRequest:()=>th,DeleteAttachmentsRequestEntityType:()=>Ls,DeleteFeedbackScore:()=>qo,DeleteIdsHolder:()=>er,DeleteThreadFeedbackScores:()=>ro,DeleteTraceThreads:()=>oo,Delta:()=>Cp,DownloadAttachmentRequestEntityType:()=>Ht,ErrorCountWithDeviation:()=>Yo,ErrorCountWithDeviationDetailed:()=>Nl,ErrorInfo:()=>be,ErrorInfoExperimentItemBulkWriteView:()=>vr,ErrorInfoPublic:()=>et,ErrorInfoWrite:()=>Kr,ErrorMessage:()=>ee,ErrorMessageDetail:()=>kh,ErrorMessageDetailed:()=>bh,ErrorMessagePublic:()=>rh,Experiment:()=>ch,ExperimentGroupAggregationsResponse:()=>jc,ExperimentGroupResponse:()=>vc,ExperimentItem:()=>Ar,ExperimentItemBulkRecord:()=>Sc,ExperimentItemBulkRecordExperimentItemBulkWriteView:()=>Mn,ExperimentItemBulkUpload:()=>lh,ExperimentItemBulkUploadExperimentItemBulkWriteView:()=>Cr,ExperimentItemCompare:()=>Qp,ExperimentItemCompareTraceVisibilityMode:()=>$p,ExperimentItemPublic:()=>Bo,ExperimentItemPublicTraceVisibilityMode:()=>sc,ExperimentItemStreamRequest:()=>jr,ExperimentItemTraceVisibilityMode:()=>En,ExperimentItemsBatch:()=>Er,ExperimentItemsDelete:()=>Pr,ExperimentPagePublic:()=>Tc,ExperimentPublic:()=>Jo,ExperimentPublicStatus:()=>_c,ExperimentPublicType:()=>xc,ExperimentStatus:()=>hc,ExperimentStreamRequestPublic:()=>Ur,ExperimentType:()=>wc,ExperimentUpdate:()=>Ir,ExperimentUpdateStatus:()=>ei,ExperimentUpdateType:()=>qt,ExperimentWrite:()=>Tr,ExperimentWriteStatus:()=>Zt,ExperimentWriteType:()=>Yt,ExportTraceServiceRequest:()=>hh,Feedback:()=>uh,FeedbackCreate:()=>$c,FeedbackDefinitionPagePublic:()=>rl,FeedbackObjectPublic:()=>el,FeedbackPublic:()=>tl,FeedbackScore:()=>Y,FeedbackScoreAverage:()=>ie,FeedbackScoreAverageDetailed:()=>Ml,FeedbackScoreAveragePublic:()=>Me,FeedbackScoreBatch:()=>tt,FeedbackScoreBatchItem:()=>om,FeedbackScoreBatchItemSource:()=>rm,FeedbackScoreBatchItemThread:()=>Kn,FeedbackScoreBatchItemThreadSource:()=>Jn,FeedbackScoreBatchThread:()=>to,FeedbackScoreCompare:()=>Gp,FeedbackScoreCompareSource:()=>Jp,FeedbackScoreExperimentItemBulkWriteView:()=>Nn,FeedbackScoreExperimentItemBulkWriteViewSource:()=>In,FeedbackScoreNames:()=>Al,FeedbackScorePublic:()=>rt,FeedbackScorePublicSource:()=>Ql,FeedbackScoreSource:()=>_n,FeedbackUpdate:()=>ml,FindFeedbackDefinitionsRequestType:()=>ti,FindFeedbackScoreNames1RequestType:()=>Ri,Function:()=>lo,FunctionCall:()=>ye,GetSpanStatsRequestType:()=>bi,GetSpansByProjectRequestType:()=>hi,GetWebhookExamplesRequestAlertType:()=>Bt,GroupContent:()=>Ac,GroupContentWithAggregations:()=>Ic,GroupDetail:()=>Ec,GroupDetails:()=>Pc,Guardrail:()=>gl,GuardrailBatch:()=>gh,GuardrailBatchWrite:()=>wo,GuardrailName:()=>dl,GuardrailResult:()=>ul,GuardrailWrite:()=>is,GuardrailWriteName:()=>os,GuardrailWriteResult:()=>ts,GuardrailsValidation:()=>yc,GuardrailsValidationPublic:()=>nm,IdsHolder:()=>mh,JsonListString:()=>U,JsonListStringCompare:()=>Mi,JsonListStringExperimentItemBulkWriteView:()=>me,JsonListStringPublic:()=>ae,JsonListStringWrite:()=>te,JsonNode:()=>F,JsonNodeDetail:()=>Wn,JsonNodePublic:()=>ke,JsonNodeWrite:()=>Ue,JsonSchema:()=>qn,LlmAsJudgeCode:()=>xo,LlmAsJudgeCodePublic:()=>gp,LlmAsJudgeCodeWrite:()=>rp,LlmAsJudgeMessage:()=>zo,LlmAsJudgeMessagePublic:()=>Io,LlmAsJudgeMessagePublicRole:()=>dp,LlmAsJudgeMessageRole:()=>Xs,LlmAsJudgeMessageWrite:()=>Po,LlmAsJudgeMessageWriteRole:()=>qs,LlmAsJudgeModelParameters:()=>ko,LlmAsJudgeModelParametersPublic:()=>Co,LlmAsJudgeModelParametersWrite:()=>Eo,LlmAsJudgeOutputSchema:()=>So,LlmAsJudgeOutputSchemaPublic:()=>jo,LlmAsJudgeOutputSchemaPublicType:()=>up,LlmAsJudgeOutputSchemaType:()=>Gs,LlmAsJudgeOutputSchemaWrite:()=>vo,LlmAsJudgeOutputSchemaWriteType:()=>ep,LogItem:()=>zp,LogItemLevel:()=>kp,LogPage:()=>Sp,ManualEvaluationRequest:()=>Wi,ManualEvaluationRequestEntityType:()=>Rl,ManualEvaluationResponse:()=>Oi,Message:()=>Qn,MultipartUploadPart:()=>Bs,NumericalFeedbackDefinition:()=>Wc,NumericalFeedbackDefinitionCreate:()=>Xc,NumericalFeedbackDefinitionPublic:()=>Go,NumericalFeedbackDefinitionUpdate:()=>cl,NumericalFeedbackDetail:()=>Oc,NumericalFeedbackDetailCreate:()=>Kc,NumericalFeedbackDetailPublic:()=>Zc,NumericalFeedbackDetailUpdate:()=>pl,Optimization:()=>fh,OptimizationPagePublic:()=>zl,OptimizationPublic:()=>Qo,OptimizationPublicStatus:()=>kl,OptimizationStatus:()=>bl,OptimizationUpdate:()=>Dr,OptimizationUpdateStatus:()=>si,OptimizationWrite:()=>Bi,OptimizationWriteStatus:()=>yl,PageColumns:()=>uc,PercentageValueStatPublic:()=>tc,PercentageValues:()=>ze,PercentageValuesDetailed:()=>Dl,PercentageValuesPublic:()=>Wo,Project:()=>Rh,ProjectDetailed:()=>Ol,ProjectDetailedVisibility:()=>Fl,ProjectMetricRequestPublic:()=>Wr,ProjectMetricRequestPublicInterval:()=>di,ProjectMetricRequestPublicMetricType:()=>mi,ProjectMetricResponsePublic:()=>Il,ProjectMetricResponsePublicInterval:()=>vl,ProjectMetricResponsePublicMetricType:()=>Pl,ProjectPagePublic:()=>_l,ProjectPublic:()=>Zo,ProjectPublicVisibility:()=>xl,ProjectRetrieveDetailed:()=>Br,ProjectStatItemObjectPublic:()=>ac,ProjectStatsPublic:()=>Fe,ProjectStatsSummary:()=>Ul,ProjectStatsSummaryItem:()=>jl,ProjectUpdate:()=>Or,ProjectUpdateVisibility:()=>li,ProjectVisibility:()=>Sl,ProjectWrite:()=>Fr,ProjectWriteVisibility:()=>ci,Prompt:()=>yh,PromptDetail:()=>Vl,PromptPagePublic:()=>Gl,PromptPublic:()=>Xl,PromptTokensDetails:()=>jp,PromptType:()=>Wl,PromptUpdatable:()=>Hr,PromptVersion:()=>Ll,PromptVersionDetail:()=>he,PromptVersionDetailType:()=>Bn,PromptVersionLink:()=>Di,PromptVersionLinkPublic:()=>Fi,PromptVersionLinkWrite:()=>oi,PromptVersionPagePublic:()=>Kl,PromptVersionPublic:()=>Jl,PromptVersionPublicType:()=>Hl,PromptVersionRetrieveDetail:()=>Jr,PromptVersionType:()=>Bl,PromptWrite:()=>Lr,PromptWriteType:()=>gi,ProviderApiKey:()=>wh,ProviderApiKeyPagePublic:()=>hl,ProviderApiKeyProvider:()=>fl,ProviderApiKeyPublic:()=>$o,ProviderApiKeyPublicProvider:()=>wl,ProviderApiKeyUpdate:()=>Mr,ProviderApiKeyWrite:()=>Nr,ProviderApiKeyWriteProvider:()=>ai,ResponseFormat:()=>es,ResponseFormatType:()=>Zn,Result:()=>We,ResultsNumberPublic:()=>Cl,ScoreName:()=>Tl,ServiceTogglesConfig:()=>$l,Span:()=>Ho,SpanBatch:()=>zh,SpanBatchWrite:()=>Gr,SpanEnrichmentOptions:()=>Sn,SpanExperimentItemBulkWriteView:()=>Cn,SpanExperimentItemBulkWriteViewType:()=>vn,SpanFilterPublic:()=>Hn,SpanFilterPublicOperator:()=>Vn,SpanPagePublic:()=>em,SpanPublic:()=>ot,SpanPublicType:()=>ql,SpanSearchStreamRequestPublic:()=>Qr,SpanSearchStreamRequestPublicType:()=>yi,SpanType:()=>zc,SpanUpdate:()=>$r,SpanUpdateType:()=>fi,SpanWrite:()=>Xr,SpanWriteType:()=>Ln,SpansCountResponse:()=>ss,StartMultipartUploadRequest:()=>wr,StartMultipartUploadRequestEntityType:()=>Jt,StartMultipartUploadResponse:()=>Vs,StreamOptions:()=>Yn,Tool:()=>rs,ToolCall:()=>Fo,Trace:()=>Vo,TraceBatch:()=>Sh,TraceBatchWrite:()=>qr,TraceCountResponse:()=>cs,TraceEnrichmentOptions:()=>xn,TraceExperimentItemBulkWriteView:()=>Pn,TraceFilter:()=>yo,TraceFilterOperator:()=>Ks,TraceFilterPublic:()=>Re,TraceFilterPublicOperator:()=>Dn,TraceFilterWrite:()=>lp,TraceFilterWriteOperator:()=>cp,TracePagePublic:()=>lm,TracePublic:()=>it,TracePublicVisibilityMode:()=>sm,TraceSearchStreamRequestPublic:()=>ao,TraceThread:()=>at,TraceThreadBatchIdentifier:()=>Yr,TraceThreadFilter:()=>Gn,TraceThreadFilterOperator:()=>Xn,TraceThreadFilterPublic:()=>On,TraceThreadFilterPublicOperator:()=>Fn,TraceThreadIdentifier:()=>Li,TraceThreadLlmAsJudgeCode:()=>To,TraceThreadLlmAsJudgeCodePublic:()=>hp,TraceThreadLlmAsJudgeCodeWrite:()=>tp,TraceThreadPage:()=>cm,TraceThreadSearchStreamRequest:()=>io,TraceThreadStatus:()=>pm,TraceThreadUpdate:()=>no,TraceThreadUserDefinedMetricPythonCode:()=>Ao,TraceThreadUserDefinedMetricPythonCodePublic:()=>fp,TraceThreadUserDefinedMetricPythonCodeWrite:()=>ap,TraceUpdate:()=>eo,TraceVisibilityMode:()=>kc,TraceWrite:()=>Zr,UploadAttachmentRequestEntityType:()=>Kt,Usage:()=>Np,UserDefinedMetricPythonCode:()=>_o,UserDefinedMetricPythonCodePublic:()=>wp,UserDefinedMetricPythonCodeWrite:()=>sp,ValueEntry:()=>An,ValueEntryCompare:()=>Xp,ValueEntryCompareSource:()=>Kp,ValueEntryExperimentItemBulkWriteView:()=>Un,ValueEntryExperimentItemBulkWriteViewSource:()=>jn,ValueEntryPublic:()=>Zl,ValueEntryPublicSource:()=>Yl,ValueEntrySource:()=>Tn,Webhook:()=>ms,WebhookExamples:()=>Ps,WebhookPublic:()=>Ss,WebhookTestResult:()=>Cs,WebhookTestResultStatus:()=>vs,WebhookWrite:()=>ks,WelcomeWizardSubmission:()=>ho,WelcomeWizardTracking:()=>mm,WorkspaceConfiguration:()=>nt,WorkspaceMetricRequest:()=>Th,WorkspaceMetricResponse:()=>Vi,WorkspaceMetricsSummaryRequest:()=>rr,WorkspaceMetricsSummaryResponse:()=>dm,WorkspaceNameHolder:()=>Js,WorkspaceSpansCount:()=>ns,WorkspaceTraceCount:()=>ps,alerts:()=>Lt,annotationQueues:()=>xi,attachments:()=>$e,chatCompletions:()=>_i,dashboards:()=>Ti,datasets:()=>Qt,experiments:()=>Qe,feedbackDefinitions:()=>ii,guardrails:()=>Ai,llmProviderKey:()=>ni,optimizations:()=>pi,projects:()=>ui,prompts:()=>wi,spans:()=>Ye,traces:()=>Ne,welcomeWizard:()=>Ei});var Lt={};P(Lt,{GetWebhookExamplesRequestAlertType:()=>Bt});var Bt=r.enum_(["general","slack","pagerduty"]);var $e={};P($e,{AttachmentListRequestEntityType:()=>Vt,DownloadAttachmentRequestEntityType:()=>Ht,StartMultipartUploadRequest:()=>wr,StartMultipartUploadRequestEntityType:()=>Jt,UploadAttachmentRequestEntityType:()=>Kt,uploadAttachment:()=>Xt});var Vt=r.enum_(["trace","span"]);var Ht=r.enum_(["trace","span"]);var Jt=r.enum_(["trace","span"]);var Kt=r.enum_(["trace","span"]);var Xt={};P(Xt,{Request:()=>$w});var $w=r.record(r.string(),r.unknown());var wr=r.object({fileName:r.property("file_name",r.string()),numOfFileParts:r.property("num_of_file_parts",r.number()),mimeType:r.property("mime_type",r.string().optional()),projectName:r.property("project_name",r.string().optional()),entityType:r.property("entity_type",Jt),entityId:r.property("entity_id",r.string()),path:r.string()});var Qt={};P(Qt,{CreateDatasetItemsFromSpansRequest:()=>Rr,CreateDatasetItemsFromTracesRequest:()=>br,DatasetExpansionWrite:()=>Sr,DatasetIdentifier:()=>kr,DatasetIdentifierPublic:()=>xr,DatasetItemBatchWrite:()=>fr,DatasetItemStreamRequest:()=>_r,DatasetItemsDelete:()=>zr,DatasetUpdate:()=>yr,DatasetUpdateVisibility:()=>$t,DatasetWrite:()=>hr,DatasetWriteVisibility:()=>Gt});var Gt=r.enum_(["private","public"]);var $t=r.enum_(["private","public"]);var hr=r.object({id:r.string().optional(),name:r.string(),visibility:Gt.optional(),tags:r.list(r.string()).optional(),description:r.string().optional()});var kn=r.enum_(["manual","trace","span","sdk"]);var F=r.record(r.string(),r.unknown());var zn=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:kn,data:F});var fr=r.object({datasetName:r.property("dataset_name",r.string().optional()),datasetId:r.property("dataset_id",r.string().optional()),items:r.list(zn)});var Sn=r.object({includeTags:r.boolean().optional(),includeFeedbackScores:r.boolean().optional(),includeComments:r.boolean().optional(),includeUsage:r.boolean().optional(),includeMetadata:r.boolean().optional()});var Rr=r.object({spanIds:r.property("span_ids",r.list(r.string())),enrichmentOptions:r.property("enrichment_options",Sn)});var xn=r.object({includeSpans:r.boolean().optional(),includeTags:r.boolean().optional(),includeFeedbackScores:r.boolean().optional(),includeComments:r.boolean().optional(),includeUsage:r.boolean().optional(),includeMetadata:r.boolean().optional()});var br=r.object({traceIds:r.property("trace_ids",r.list(r.string())),enrichmentOptions:r.property("enrichment_options",xn)});var yr=r.object({name:r.string(),description:r.string().optional(),visibility:$t.optional(),tags:r.list(r.string()).optional()});var kr=r.object({datasetName:r.property("dataset_name",r.string())});var zr=r.object({itemIds:r.property("item_ids",r.list(r.string()))});var Sr=r.object({model:r.string(),sampleCount:r.property("sample_count",r.number().optional()),preserveFields:r.property("preserve_fields",r.list(r.string()).optional()),variationInstructions:r.property("variation_instructions",r.string().optional()),customPrompt:r.property("custom_prompt",r.string().optional())});var xr=r.object({datasetName:r.property("dataset_name",r.string())});var _r=r.object({datasetName:r.property("dataset_name",r.string()),lastRetrievedId:r.property("last_retrieved_id",r.string().optional()),steamLimit:r.property("steam_limit",r.number().optional())});var Qe={};P(Qe,{ExperimentItemBulkUploadExperimentItemBulkWriteView:()=>Cr,ExperimentItemStreamRequest:()=>jr,ExperimentItemsBatch:()=>Er,ExperimentItemsDelete:()=>Pr,ExperimentStreamRequestPublic:()=>Ur,ExperimentUpdate:()=>Ir,ExperimentUpdateStatus:()=>ei,ExperimentUpdateType:()=>qt,ExperimentWrite:()=>Tr,ExperimentWriteStatus:()=>Zt,ExperimentWriteType:()=>Yt,findFeedbackScoreNames:()=>ri});var Yt=r.enum_(["regular","trial","mini-batch"]);var Zt=r.enum_(["running","completed","cancelled"]);var qt=r.enum_(["regular","trial","mini-batch"]);var ei=r.enum_(["running","completed","cancelled"]);var ri={};P(ri,{Response:()=>Qw});var Qw=r.list(r.string());var te=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var oi=r.object({id:r.string()});var Tr=r.object({id:r.string().optional(),datasetName:r.property("dataset_name",r.string()),name:r.string().optional(),metadata:te.optional(),type:Yt.optional(),optimizationId:r.property("optimization_id",r.string().optional()),status:Zt.optional(),promptVersion:r.property("prompt_version",oi.optional()),promptVersions:r.property("prompt_versions",r.list(oi).optional())});var U=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var _n=r.enum_(["ui","sdk","online_scoring"]);var Tn=r.enum_(["ui","sdk","online_scoring"]);var An=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Tn.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Y=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:_n,createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),valueByAuthor:r.property("value_by_author",r.record(r.string(),An).optional())});var L=r.object({id:r.string().optional(),text:r.string(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var En=r.enum_(["default","hidden"]);var Ar=r.object({id:r.string().optional(),experimentId:r.property("experiment_id",r.string()),datasetItemId:r.property("dataset_item_id",r.string()),traceId:r.property("trace_id",r.string()),input:U.optional(),output:U.optional(),feedbackScores:r.property("feedback_scores",r.list(Y).optional()),comments:r.list(L).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),duration:r.number().optional(),usage:r.record(r.string(),r.number()).optional(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),traceVisibilityMode:r.property("trace_visibility_mode",En.optional())});var Er=r.object({experimentItems:r.property("experiment_items",r.list(Ar))});var Pr=r.object({ids:r.list(r.string())});var me=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var vr=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var Pn=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),name:r.string().optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:me.optional(),output:me.optional(),metadata:me.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",vr.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),threadId:r.property("thread_id",r.string().optional())});var vn=r.enum_(["general","tool","llm","guardrail"]);var Cn=r.object({id:r.string().optional(),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:vn.optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:me.optional(),output:me.optional(),metadata:me.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),errorInfo:r.property("error_info",vr.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostVersion:r.property("total_estimated_cost_version",r.string().optional())});var In=r.enum_(["ui","sdk","online_scoring"]);var jn=r.enum_(["ui","sdk","online_scoring"]);var Un=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:jn.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Nn=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:In,createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),valueByAuthor:r.property("value_by_author",r.record(r.string(),Un).optional())});var Mn=r.object({datasetItemId:r.property("dataset_item_id",r.string()),evaluateTaskResult:r.property("evaluate_task_result",me.optional()),trace:Pn.optional(),spans:r.list(Cn).optional(),feedbackScores:r.property("feedback_scores",r.list(Nn).optional())});var Cr=r.object({experimentName:r.property("experiment_name",r.string()),datasetName:r.property("dataset_name",r.string()),experimentId:r.property("experiment_id",r.string().optional()),items:r.list(Mn)});var Ir=r.object({name:r.string().optional(),metadata:F.optional(),type:qt.optional(),status:ei.optional()});var jr=r.object({experimentName:r.property("experiment_name",r.string()),limit:r.number().optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional()),truncate:r.boolean().optional()});var Ur=r.object({name:r.string(),limit:r.number().optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional())});var ii={};P(ii,{FindFeedbackDefinitionsRequestType:()=>ti});var ti=r.enum_(["numerical","categorical","boolean"]);var ni={};P(ni,{ProviderApiKeyUpdate:()=>Mr,ProviderApiKeyWrite:()=>Nr,ProviderApiKeyWriteProvider:()=>ai});var ai=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var Nr=r.object({provider:ai,apiKey:r.property("api_key",r.string().optional()),name:r.string().optional(),providerName:r.property("provider_name",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),configuration:r.record(r.string(),r.string()).optional(),baseUrl:r.property("base_url",r.string().optional())});var Mr=r.object({apiKey:r.property("api_key",r.string().optional()),name:r.string().optional(),providerName:r.property("provider_name",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),configuration:r.record(r.string(),r.string()).optional(),baseUrl:r.property("base_url",r.string().optional())});var pi={};P(pi,{OptimizationUpdate:()=>Dr,OptimizationUpdateStatus:()=>si});var si=r.enum_(["running","completed","cancelled"]);var Dr=r.object({name:r.string().optional(),status:si.optional()});var ui={};P(ui,{ProjectMetricRequestPublic:()=>Wr,ProjectMetricRequestPublicInterval:()=>di,ProjectMetricRequestPublicMetricType:()=>mi,ProjectRetrieveDetailed:()=>Br,ProjectUpdate:()=>Or,ProjectUpdateVisibility:()=>li,ProjectWrite:()=>Fr,ProjectWriteVisibility:()=>ci});var ci=r.enum_(["private","public"]);var li=r.enum_(["private","public"]);var mi=r.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST","GUARDRAILS_FAILED_COUNT","THREAD_COUNT","THREAD_DURATION","THREAD_FEEDBACK_SCORES"]);var di=r.enum_(["HOURLY","DAILY","WEEKLY"]);var Fr=r.object({name:r.string(),visibility:ci.optional(),description:r.string().optional()});var Or=r.object({name:r.string().optional(),description:r.string().optional(),visibility:li.optional()});var Dn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Re=r.object({field:r.string().optional(),operator:Dn.optional(),key:r.string().optional(),value:r.string().optional()});var Fn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var On=r.object({field:r.string().optional(),operator:Fn.optional(),key:r.string().optional(),value:r.string().optional()});var Wr=r.object({metricType:r.property("metric_type",mi.optional()),interval:di.optional(),intervalStart:r.property("interval_start",r.date().optional()),intervalEnd:r.property("interval_end",r.date().optional()),traceFilters:r.property("trace_filters",r.list(Re).optional()),threadFilters:r.property("thread_filters",r.list(On).optional())});var Br=r.object({name:r.string()});var wi={};P(wi,{CreatePromptVersionDetail:()=>Vr,PromptUpdatable:()=>Hr,PromptVersionRetrieveDetail:()=>Jr,PromptWrite:()=>Lr,PromptWriteType:()=>gi});var gi=r.enum_(["mustache","jinja2"]);var Ue=r.record(r.string(),r.unknown());var Lr=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),template:r.string().optional(),metadata:Ue.optional(),changeDescription:r.property("change_description",r.string().optional()),type:gi.optional(),tags:r.list(r.string()).optional()});var Wn=r.record(r.string(),r.unknown());var Bn=r.enum_(["mustache","jinja2"]);var he=r.object({id:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),commit:r.string().optional(),template:r.string(),metadata:Wn.optional(),type:Bn.optional(),changeDescription:r.property("change_description",r.string().optional()),variables:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var Vr=r.object({name:r.string(),version:he});var Hr=r.object({name:r.string(),description:r.string().optional(),tags:r.list(r.string()).optional()});var Jr=r.object({name:r.string(),commit:r.string().optional()});var Ye={};P(Ye,{FindFeedbackScoreNames1RequestType:()=>Ri,GetSpanStatsRequestType:()=>bi,GetSpansByProjectRequestType:()=>hi,SpanBatchWrite:()=>Gr,SpanSearchStreamRequestPublic:()=>Qr,SpanSearchStreamRequestPublicType:()=>yi,SpanUpdate:()=>$r,SpanUpdateType:()=>fi,findFeedbackScoreNames1:()=>ki});var hi=r.enum_(["general","tool","llm","guardrail"]);var fi=r.enum_(["general","tool","llm","guardrail"]);var Ri=r.enum_(["general","tool","llm","guardrail"]);var bi=r.enum_(["general","tool","llm","guardrail"]);var yi=r.enum_(["general","tool","llm","guardrail"]);var ki={};P(ki,{Response:()=>Yw});var Yw=r.list(r.string());var Ln=r.enum_(["general","tool","llm","guardrail"]);var Kr=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var Xr=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),traceId:r.property("trace_id",r.string().optional()),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:Ln.optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:te.optional(),output:te.optional(),metadata:te.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),errorInfo:r.property("error_info",Kr.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostVersion:r.property("total_estimated_cost_version",r.string().optional())});var Gr=r.object({spans:r.list(Xr)});var be=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var $r=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),traceId:r.property("trace_id",r.string()),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:fi.optional(),endTime:r.property("end_time",r.date().optional()),input:U.optional(),output:U.optional(),metadata:U.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),errorInfo:r.property("error_info",be.optional())});var Vn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Hn=r.object({field:r.string().optional(),operator:Vn.optional(),key:r.string().optional(),value:r.string().optional()});var Qr=r.object({traceId:r.property("trace_id",r.string().optional()),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),type:yi.optional(),filters:r.list(Hn).optional(),limit:r.number().optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional()),truncate:r.boolean().optional(),fromTime:r.property("from_time",r.date().optional()),toTime:r.property("to_time",r.date().optional())});var Ne={};P(Ne,{DeleteThreadFeedbackScores:()=>ro,DeleteTraceThreads:()=>oo,FeedbackScoreBatchThread:()=>to,TraceBatchWrite:()=>qr,TraceSearchStreamRequestPublic:()=>ao,TraceThreadBatchIdentifier:()=>Yr,TraceThreadSearchStreamRequest:()=>io,TraceThreadUpdate:()=>no,TraceUpdate:()=>eo,findFeedbackScoreNames2:()=>zi,findTraceThreadsFeedbackScoreNames:()=>Si});var zi={};P(zi,{Response:()=>Zw});var Zw=r.list(r.string());var Si={};P(Si,{Response:()=>qw});var qw=r.list(r.string());var Yr=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),threadId:r.property("thread_id",r.string().optional()),threadIds:r.property("thread_ids",r.list(r.string()).optional())});var Zr=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),name:r.string().optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:te.optional(),output:te.optional(),metadata:te.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",Kr.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),threadId:r.property("thread_id",r.string().optional())});var qr=r.object({traces:r.list(Zr)});var eo=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:r.string().optional(),endTime:r.property("end_time",r.date().optional()),input:U.optional(),output:U.optional(),metadata:U.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",be.optional()),threadId:r.property("thread_id",r.string().optional())});var ro=r.object({projectName:r.property("project_name",r.string()),threadId:r.property("thread_id",r.string()),names:r.list(r.string()),author:r.string().optional()});var oo=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),threadIds:r.property("thread_ids",r.list(r.string()))});var Jn=r.enum_(["ui","sdk","online_scoring"]);var Kn=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Jn,author:r.string().optional(),threadId:r.property("thread_id",r.string())});var to=r.object({scores:r.list(Kn)});var Xn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Gn=r.object({field:r.string().optional(),operator:Xn.optional(),key:r.string().optional(),value:r.string().optional()});var io=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),filters:r.list(Gn).optional(),lastRetrievedThreadModelId:r.property("last_retrieved_thread_model_id",r.string().optional()),limit:r.number().optional(),truncate:r.boolean().optional(),stripAttachments:r.property("strip_attachments",r.boolean().optional()),fromTime:r.property("from_time",r.date().optional()),toTime:r.property("to_time",r.date().optional())});var ao=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),filters:r.list(Re).optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional()),limit:r.number().optional(),truncate:r.boolean().optional(),stripAttachments:r.property("strip_attachments",r.boolean().optional()),fromTime:r.property("from_time",r.date().optional()),toTime:r.property("to_time",r.date().optional())});var no=r.object({tags:r.list(r.string()).optional()});var xi={};P(xi,{AnnotationQueueBatchWrite:()=>po,AnnotationQueueUpdate:()=>co});var $n=r.enum_(["trace","thread"]);var so=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),name:r.string(),description:r.string().optional(),instructions:r.string().optional(),scope:$n,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional())});var po=r.object({annotationQueues:r.property("annotation_queues",r.list(so))});var co=r.object({name:r.string().optional(),description:r.string().optional(),instructions:r.string().optional(),commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional())});var _i={};P(_i,{ChatCompletionRequest:()=>mo});var Qn=r.record(r.string(),r.unknown());var Yn=r.object({includeUsage:r.property("include_usage",r.boolean().optional())});var Zn=r.enum_(["text","json_object","json_schema"]);var qn=r.object({name:r.string().optional(),strict:r.boolean().optional(),schema:r.record(r.string(),r.record(r.string(),r.unknown())).optional()});var es=r.object({type:Zn.optional(),jsonSchema:r.property("json_schema",qn.optional())});var lo=r.object({name:r.string().optional(),description:r.string().optional(),strict:r.boolean().optional(),parameters:r.record(r.string(),r.record(r.string(),r.unknown())).optional()});var rs=r.object({type:r.stringLiteral("function").optional(),function:lo.optional()});var ye=r.object({name:r.string().optional(),arguments:r.string().optional()});var mo=r.object({model:r.string().optional(),messages:r.list(Qn).optional(),temperature:r.number().optional(),topP:r.property("top_p",r.number().optional()),n:r.number().optional(),stream:r.boolean().optional(),streamOptions:r.property("stream_options",Yn.optional()),stop:r.list(r.string()).optional(),maxTokens:r.property("max_tokens",r.number().optional()),maxCompletionTokens:r.property("max_completion_tokens",r.number().optional()),presencePenalty:r.property("presence_penalty",r.number().optional()),frequencyPenalty:r.property("frequency_penalty",r.number().optional()),logitBias:r.property("logit_bias",r.record(r.string(),r.number()).optional()),user:r.string().optional(),responseFormat:r.property("response_format",es.optional()),seed:r.number().optional(),tools:r.list(rs).optional(),toolChoice:r.property("tool_choice",r.record(r.string(),r.unknown()).optional()),parallelToolCalls:r.property("parallel_tool_calls",r.boolean().optional()),store:r.boolean().optional(),metadata:r.record(r.string(),r.string()).optional(),reasoningEffort:r.property("reasoning_effort",r.string().optional()),serviceTier:r.property("service_tier",r.string().optional()),functions:r.list(lo).optional(),functionCall:r.property("function_call",ye.optional())});var Ti={};P(Ti,{DashboardUpdatePublic:()=>go,DashboardWrite:()=>uo});var uo=r.object({name:r.string(),description:r.string().optional(),config:Ue});var ke=r.record(r.string(),r.unknown());var go=r.object({name:r.string().optional(),description:r.string().optional(),config:ke.optional()});var Ai={};P(Ai,{GuardrailBatchWrite:()=>wo});var os=r.enum_(["TOPIC","PII"]);var ts=r.enum_(["passed","failed"]);var is=r.object({entityId:r.property("entity_id",r.string()),secondaryId:r.property("secondary_id",r.string()),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:os,result:ts,config:F,details:F});var wo=r.object({guardrails:r.list(is)});var Ei={};P(Ei,{WelcomeWizardSubmission:()=>ho});var ho=r.object({role:r.string().optional(),integrations:r.list(r.string()).optional(),email:r.string().optional(),joinBetaProgram:r.property("join_beta_program",r.boolean().optional())});var as=r.object({workspaceId:r.property("workspace_id",r.string().optional()),user:r.string().optional(),count:r.number().optional()});var Ze=r.object({biInformation:r.property("bi_information",r.list(as).optional())});var ns=r.object({workspace:r.string().optional(),spanCount:r.property("span_count",r.number().optional())});var ss=r.object({workspacesSpansCount:r.property("workspaces_spans_count",r.list(ns).optional())});var ps=r.object({workspace:r.string().optional(),traceCount:r.property("trace_count",r.number().optional())});var cs=r.object({workspacesTracesCount:r.property("workspaces_traces_count",r.list(ps).optional())});var ee=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var ls=r.enum_(["general","slack","pagerduty"]);var ms=r.object({id:r.string().optional(),name:r.string().optional(),url:r.string(),secretToken:r.property("secret_token",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ds=r.enum_(["trace:errors","trace:feedback_score","trace_thread:feedback_score","prompt:created","prompt:committed","trace:guardrails_triggered","prompt:deleted","experiment:finished","trace:cost","trace:latency"]);var us=r.enum_(["scope:project","threshold:feedback_score","threshold:cost","threshold:latency"]);var gs=r.object({id:r.string().optional(),alertTriggerId:r.property("alert_trigger_id",r.string().optional()),type:us,configValue:r.property("config_value",r.record(r.string(),r.string()).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ws=r.object({id:r.string().optional(),alertId:r.property("alert_id",r.string().optional()),eventType:r.property("event_type",ds),triggerConfigs:r.property("trigger_configs",r.list(gs).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var eh=r.object({id:r.string().optional(),name:r.string().optional(),enabled:r.boolean().optional(),alertType:r.property("alert_type",ls.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:ms,triggers:r.list(ws).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var hs=r.enum_(["scope:project","threshold:feedback_score","threshold:cost","threshold:latency"]);var fs=r.object({id:r.string().optional(),type:hs,configValue:r.property("config_value",r.record(r.string(),r.string()).optional())});var Rs=r.enum_(["trace:errors","trace:feedback_score","trace_thread:feedback_score","prompt:created","prompt:committed","trace:guardrails_triggered","prompt:deleted","experiment:finished","trace:cost","trace:latency"]);var bs=r.object({id:r.string().optional(),eventType:r.property("event_type",Rs),triggerConfigs:r.property("trigger_configs",r.list(fs).optional())});var ys=r.enum_(["general","slack","pagerduty"]);var ks=r.object({id:r.string().optional(),name:r.string().optional(),url:r.string(),secretToken:r.property("secret_token",r.string().optional()),headers:r.record(r.string(),r.string()).optional()});var fo=r.object({id:r.string().optional(),name:r.string().optional(),enabled:r.boolean().optional(),alertType:r.property("alert_type",ys.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:ks,triggers:r.list(bs).optional()});var B=r.object({ids:r.list(r.string())});var zs=r.enum_(["general","slack","pagerduty"]);var Ss=r.object({id:r.string().optional(),name:r.string().optional(),url:r.string(),secretToken:r.property("secret_token",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var xs=r.enum_(["trace:errors","trace:feedback_score","trace_thread:feedback_score","prompt:created","prompt:committed","trace:guardrails_triggered","prompt:deleted","experiment:finished","trace:cost","trace:latency"]);var _s=r.enum_(["scope:project","threshold:feedback_score","threshold:cost","threshold:latency"]);var Ts=r.object({id:r.string().optional(),alertTriggerId:r.property("alert_trigger_id",r.string().optional()),type:_s,configValue:r.property("config_value",r.record(r.string(),r.string()).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var As=r.object({id:r.string().optional(),alertId:r.property("alert_id",r.string().optional()),eventType:r.property("event_type",xs),triggerConfigs:r.property("trigger_configs",r.list(Ts).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var Ro=r.object({id:r.string().optional(),name:r.string().optional(),enabled:r.boolean().optional(),alertType:r.property("alert_type",zs.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:Ss,triggers:r.list(As).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Es=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Ro).optional(),sortableBy:r.property("sortable_by",r.list(r.string()).optional())});var rh=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var Ps=r.object({responseExamples:r.property("response_examples",r.record(r.string(),r.record(r.string(),r.unknown())).optional())});var vs=r.enum_(["success","failure"]);var Cs=r.object({status:vs.optional(),statusCode:r.property("status_code",r.number().optional()),requestBody:r.property("request_body",r.string().optional()),errorMessage:r.property("error_message",r.string().optional())});var Pi=r.object({ids:r.list(r.string())});var Is=r.enum_(["trace","thread"]);var js=r.object({username:r.string().optional(),status:r.number().optional()});var ie=r.object({name:r.string(),value:r.number()});var Us=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),description:r.string().optional(),instructions:r.string().optional(),scope:Is,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional()),reviewers:r.list(js).optional(),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),itemsCount:r.property("items_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var oh=r.object({annotationQueues:r.property("annotation_queues",r.list(Us))});var Ns=r.enum_(["trace","thread"]);var Ms=r.object({username:r.string().optional(),status:r.number().optional()});var Me=r.object({name:r.string(),value:r.number()});var bo=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),description:r.string().optional(),instructions:r.string().optional(),scope:Ns,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional()),reviewers:r.list(Ms).optional(),feedbackScores:r.property("feedback_scores",r.list(Me).optional()),itemsCount:r.property("items_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Ds=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(bo).optional(),sortableBy:r.list(r.string()).optional()});var Fs=r.object({link:r.string().optional(),fileName:r.property("file_name",r.string()),fileSize:r.property("file_size",r.number()),mimeType:r.property("mime_type",r.string())});var Os=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Fs).optional(),sortableBy:r.list(r.string()).optional()});var Ws=r.enum_(["trace","span"]);var Bs=r.object({eTag:r.property("e_tag",r.string()),partNumber:r.property("part_number",r.number())});var vi=r.object({fileName:r.property("file_name",r.string()),projectName:r.property("project_name",r.string().optional()),entityType:r.property("entity_type",Ws),entityId:r.property("entity_id",r.string()),containerId:r.property("container_id",r.string().optional()),fileSize:r.property("file_size",r.number()),mimeType:r.property("mime_type",r.string().optional()),uploadId:r.property("upload_id",r.string()),uploadedFileParts:r.property("uploaded_file_parts",r.list(Bs))});var Ls=r.enum_(["trace","span"]);var th=r.object({fileNames:r.property("file_names",r.list(r.string())),entityType:r.property("entity_type",Ls),entityId:r.property("entity_id",r.string()),containerId:r.property("container_id",r.string())});var Vs=r.object({uploadId:r.property("upload_id",r.string()),preSignUrls:r.property("pre_sign_urls",r.list(r.string()))});var Hs=r.record(r.string(),r.unknown());var Js=r.object({workspaceName:r.property("workspace_name",r.string().optional())});var Ks=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var yo=r.object({field:r.string().optional(),operator:Ks.optional(),key:r.string().optional(),value:r.string().optional()});var ko=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional(),customParameters:r.property("custom_parameters",F.optional())});var Xs=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var zo=r.object({role:Xs,content:r.record(r.string(),r.unknown()),structuredContent:r.property("structured_content",r.boolean().optional()),stringContent:r.property("string_content",r.boolean().optional())});var Gs=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var So=r.object({name:r.string(),type:Gs,description:r.string()});var xo=r.object({model:ko,messages:r.list(zo),variables:r.record(r.string(),r.string()),schema:r.list(So)});var $s=r.object({code:xo.optional()});var _o=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var Qs=r.object({code:_o.optional()});var To=r.object({model:ko,messages:r.list(zo),schema:r.list(So)});var Ys=r.object({code:To.optional()});var Ao=r.object({metric:r.string()});var Zs=r.object({code:Ao.optional()});var Ci=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(yo).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),action:r.stringLiteral("evaluator")}),ih=r.union("type",{llm_as_judge:$s.extend(Ci),user_defined_metric_python:Qs.extend(Ci),trace_thread_llm_as_judge:Ys.extend(Ci),trace_thread_user_defined_metric_python:Zs.extend(Ci)}).transform({transform:n=>n,untransform:n=>n});var Eo=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional(),customParameters:r.property("custom_parameters",Ue.optional())});var qs=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var Po=r.object({role:qs,content:r.record(r.string(),r.unknown()),structuredContent:r.property("structured_content",r.boolean().optional()),stringContent:r.property("string_content",r.boolean().optional())});var ep=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var vo=r.object({name:r.string(),type:ep,description:r.string()});var rp=r.object({model:Eo,messages:r.list(Po),variables:r.record(r.string(),r.string()),schema:r.list(vo)});var op=r.object({code:rp.optional()});var tp=r.object({model:Eo,messages:r.list(Po),schema:r.list(vo)});var ip=r.object({code:tp.optional()});var ap=r.object({metric:r.string()});var np=r.object({code:ap.optional()});var sp=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var pp=r.object({code:sp.optional()});var cp=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var lp=r.object({field:r.string().optional(),operator:cp.optional(),key:r.string().optional(),value:r.string().optional()});var Ii=r.object({projectId:r.property("project_id",r.string()),name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(lp).optional(),action:r.stringLiteral("evaluator")}),mp=r.union("type",{llm_as_judge:op.extend(Ii),user_defined_metric_python:pp.extend(Ii),trace_thread_llm_as_judge:ip.extend(Ii),trace_thread_user_defined_metric_python:np.extend(Ii)}).transform({transform:n=>n,untransform:n=>n});var Co=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional(),customParameters:r.property("custom_parameters",ke.optional())});var dp=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var Io=r.object({role:dp,content:r.record(r.string(),r.unknown()),structuredContent:r.property("structured_content",r.boolean().optional()),stringContent:r.property("string_content",r.boolean().optional())});var up=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var jo=r.object({name:r.string(),type:up,description:r.string()});var gp=r.object({model:Co,messages:r.list(Io),variables:r.record(r.string(),r.string()),schema:r.list(jo)});var Uo=r.object({code:gp.optional()});var wp=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var No=r.object({code:wp.optional()});var hp=r.object({model:Co,messages:r.list(Io),schema:r.list(jo)});var Mo=r.object({code:hp.optional()});var fp=r.object({metric:r.string()});var Do=r.object({code:fp.optional()});var ji=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(Re).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),action:r.stringLiteral("evaluator")}),Rp=r.union("type",{llm_as_judge:Uo.extend(ji),user_defined_metric_python:No.extend(ji),trace_thread_llm_as_judge:Mo.extend(ji),trace_thread_user_defined_metric_python:Do.extend(ji)}).transform({transform:n=>n,untransform:n=>n});var bp=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Rp).optional(),sortableBy:r.property("sortable_by",r.list(r.string()).optional())});var Ui=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(Re).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),action:r.stringLiteral("evaluator")}),yp=r.union("type",{llm_as_judge:Uo.extend(Ui),user_defined_metric_python:No.extend(Ui),trace_thread_llm_as_judge:Mo.extend(Ui),trace_thread_user_defined_metric_python:Do.extend(Ui)}).transform({transform:n=>n,untransform:n=>n});var kp=r.enum_(["INFO","WARN","ERROR","DEBUG","TRACE"]);var zp=r.object({timestamp:r.date().optional(),ruleId:r.property("rule_id",r.string().optional()),level:kp.optional(),message:r.string().optional(),markers:r.record(r.string(),r.string()).optional()});var Sp=r.object({content:r.list(zp).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional()});var xp=r.object({code:xo.optional()});var _p=r.object({code:_o.optional()});var Tp=r.object({code:To.optional()});var Ap=r.object({code:Ao.optional()});var Ni=r.object({name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(yo).optional(),projectId:r.property("project_id",r.string()),action:r.stringLiteral("evaluator")}),Ep=r.union("type",{llm_as_judge:xp.extend(Ni),user_defined_metric_python:_p.extend(Ni),trace_thread_llm_as_judge:Tp.extend(Ni),trace_thread_user_defined_metric_python:Ap.extend(Ni)}).transform({transform:n=>n,untransform:n=>n});var Pp=r.enum_(["system","user","assistant","tool","function"]);var Fo=r.object({id:r.string().optional(),index:r.number().optional(),type:r.stringLiteral("function").optional(),function:ye.optional()});var vp=r.object({role:Pp.optional(),content:r.string().optional(),reasoningContent:r.property("reasoning_content",r.string().optional()),name:r.string().optional(),toolCalls:r.property("tool_calls",r.list(Fo).optional()),refusal:r.string().optional(),functionCall:r.property("function_call",ye.optional())});var Cp=r.object({role:r.string().optional(),content:r.string().optional(),reasoningContent:r.property("reasoning_content",r.string().optional()),toolCalls:r.property("tool_calls",r.list(Fo).optional()),functionCall:r.property("function_call",ye.optional())});var Ip=r.object({index:r.number().optional(),message:vp.optional(),delta:Cp.optional(),finishReason:r.property("finish_reason",r.string().optional())});var jp=r.object({cachedTokens:r.property("cached_tokens",r.number().optional())});var Up=r.object({reasoningTokens:r.property("reasoning_tokens",r.number().optional())});var Np=r.object({totalTokens:r.property("total_tokens",r.number().optional()),promptTokens:r.property("prompt_tokens",r.number().optional()),promptTokensDetails:r.property("prompt_tokens_details",jp.optional()),completionTokens:r.property("completion_tokens",r.number().optional()),completionTokensDetails:r.property("completion_tokens_details",Up.optional())});var Mp=r.object({id:r.string().optional(),created:r.number().optional(),model:r.string().optional(),choices:r.list(Ip).optional(),usage:Np.optional(),systemFingerprint:r.property("system_fingerprint",r.string().optional()),serviceTier:r.property("service_tier",r.string().optional())});var De=r.object({id:r.string().optional(),workspaceId:r.property("workspace_id",r.string().optional()),name:r.string(),slug:r.string().optional(),description:r.string().optional(),config:ke,createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Dp=r.object({content:r.list(De).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional()});var Fp=r.enum_(["private","public"]);var ah=r.object({id:r.string().optional(),name:r.string(),visibility:Fp.optional(),tags:r.list(r.string()).optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),experimentCount:r.property("experiment_count",r.number().optional()),datasetItemsCount:r.property("dataset_items_count",r.number().optional()),optimizationCount:r.property("optimization_count",r.number().optional()),mostRecentExperimentAt:r.property("most_recent_experiment_at",r.date().optional()),lastCreatedExperimentAt:r.property("last_created_experiment_at",r.date().optional()),mostRecentOptimizationAt:r.property("most_recent_optimization_at",r.date().optional()),lastCreatedOptimizationAt:r.property("last_created_optimization_at",r.date().optional())});var Op=r.enum_(["manual","trace","span","sdk"]);var Oo=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:Op,data:F,experimentItems:r.property("experiment_items",r.list(Ar).optional()),datasetId:r.property("dataset_id",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var nh=r.object({datasetName:r.property("dataset_name",r.string().optional()),datasetId:r.property("dataset_id",r.string().optional()),items:r.list(Oo)});var Wp=r.object({generatedSamples:r.property("generated_samples",r.list(Oo).optional()),model:r.string().optional(),totalGenerated:r.property("total_generated",r.number().optional()),generationTime:r.property("generation_time",r.date().optional())});var sh=r.object({model:r.string(),sampleCount:r.property("sample_count",r.number().optional()),preserveFields:r.property("preserve_fields",r.list(r.string()).optional()),variationInstructions:r.property("variation_instructions",r.string().optional()),customPrompt:r.property("custom_prompt",r.string().optional())});var Bp=r.enum_(["string","number","object","boolean","array","null"]);var Lp=r.object({name:r.string().optional(),types:r.list(Bp).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var Vp=r.object({id:r.string().optional(),text:r.string(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Hp=r.enum_(["manual","trace","span","sdk"]);var Mi=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var Jp=r.enum_(["ui","sdk","online_scoring"]);var Kp=r.enum_(["ui","sdk","online_scoring"]);var Xp=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Kp.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Gp=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Jp,createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),valueByAuthor:r.property("value_by_author",r.record(r.string(),Xp).optional())});var $p=r.enum_(["default","hidden"]);var Qp=r.object({id:r.string().optional(),experimentId:r.property("experiment_id",r.string()),datasetItemId:r.property("dataset_item_id",r.string()),traceId:r.property("trace_id",r.string()),input:Mi.optional(),output:Mi.optional(),feedbackScores:r.property("feedback_scores",r.list(Gp).optional()),comments:r.list(Vp).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),duration:r.number().optional(),usage:r.record(r.string(),r.number()).optional(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),traceVisibilityMode:r.property("trace_visibility_mode",$p.optional())});var Yp=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:Hp,data:F,experimentItems:r.property("experiment_items",r.list(Qp).optional()),datasetId:r.property("dataset_id",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Zp=r.object({content:r.list(Yp).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),columns:r.list(Lp).optional(),sortableBy:r.list(r.string()).optional()});var qp=r.enum_(["private","public"]);var qe=r.object({id:r.string().optional(),name:r.string(),visibility:qp.optional(),tags:r.list(r.string()).optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),experimentCount:r.property("experiment_count",r.number().optional()),datasetItemsCount:r.property("dataset_items_count",r.number().optional()),optimizationCount:r.property("optimization_count",r.number().optional()),mostRecentExperimentAt:r.property("most_recent_experiment_at",r.date().optional()),lastCreatedExperimentAt:r.property("last_created_experiment_at",r.date().optional()),mostRecentOptimizationAt:r.property("most_recent_optimization_at",r.date().optional()),lastCreatedOptimizationAt:r.property("last_created_optimization_at",r.date().optional())});var ec=r.object({content:r.list(qe).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),sortableBy:r.list(r.string()).optional()});var rc=r.object({value:r.number().optional()});var oc=r.object({value:r.number().optional()});var Wo=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var tc=r.object({value:Wo.optional()});var ic=r.object({name:r.string().optional()}),ac=r.union("type",{PERCENTAGE:tc.extend(ic),COUNT:oc.extend(ic),AVG:rc.extend(ic)}).transform({transform:n=>n,untransform:n=>n});var Fe=r.object({stats:r.list(ac).optional()});var nc=r.enum_(["manual","trace","span","sdk"]);var sc=r.enum_(["default","hidden"]);var Bo=r.object({id:r.string().optional(),experimentId:r.property("experiment_id",r.string()),datasetItemId:r.property("dataset_item_id",r.string()),traceId:r.property("trace_id",r.string()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),traceVisibilityMode:r.property("trace_visibility_mode",sc.optional())});var Lo=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:nc,data:F,experimentItems:r.property("experiment_items",r.list(Bo).optional()),datasetId:r.property("dataset_id",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var pc=r.enum_(["string","number","object","boolean","array","null"]);var cc=r.object({name:r.string().optional(),types:r.list(pc).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var lc=r.object({content:r.list(Lo).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),columns:r.list(cc).optional(),sortableBy:r.list(r.string()).optional()});var mc=r.enum_(["string","number","object","boolean","array","null"]);var dc=r.object({name:r.string().optional(),types:r.list(mc).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var uc=r.object({columns:r.list(dc).optional()});var gc=r.object({typeName:r.string().optional()});var ph=r.object({type:gc.optional(),closed:r.boolean().optional()});var wc=r.enum_(["regular","trial","mini-batch"]);var hc=r.enum_(["running","completed","cancelled"]);var ze=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var Di=r.object({id:r.string(),commit:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),promptName:r.property("prompt_name",r.string().optional())});var ch=r.object({id:r.string().optional(),datasetName:r.property("dataset_name",r.string()),datasetId:r.property("dataset_id",r.string().optional()),name:r.string().optional(),metadata:U.optional(),type:wc.optional(),optimizationId:r.property("optimization_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),comments:r.list(L).optional(),traceCount:r.property("trace_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),duration:ze.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostAvg:r.property("total_estimated_cost_avg",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),status:hc.optional(),promptVersion:r.property("prompt_version",Di.optional()),promptVersions:r.property("prompt_versions",r.list(Di).optional())});var er=r.object({ids:r.list(r.string())});var fc=r.enum_(["TOPIC","PII"]);var Rc=r.enum_(["passed","failed"]);var bc=r.object({name:fc.optional(),result:Rc.optional()});var yc=r.object({spanId:r.property("span_id",r.string().optional()),checks:r.list(bc).optional()});var kc=r.enum_(["default","hidden"]);var Vo=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:r.string().optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:U.optional(),output:U.optional(),metadata:U.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",be.optional()),usage:r.record(r.string(),r.number()).optional(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Y).optional()),comments:r.list(L).optional(),guardrailsValidations:r.property("guardrails_validations",r.list(yc).optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),spanCount:r.property("span_count",r.number().optional()),duration:r.number().optional(),threadId:r.property("thread_id",r.string().optional()),visibilityMode:r.property("visibility_mode",kc.optional()),llmSpanCount:r.property("llm_span_count",r.number().optional()),providers:r.list(r.string()).optional()});var zc=r.enum_(["general","tool","llm","guardrail"]);var Ho=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),traceId:r.property("trace_id",r.string().optional()),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:zc.optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:U.optional(),output:U.optional(),metadata:U.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),errorInfo:r.property("error_info",be.optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Y).optional()),comments:r.list(L).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostVersion:r.property("total_estimated_cost_version",r.string().optional()),duration:r.number().optional()});var Sc=r.object({datasetItemId:r.property("dataset_item_id",r.string()),evaluateTaskResult:r.property("evaluate_task_result",U.optional()),trace:Vo.optional(),spans:r.list(Ho).optional(),feedbackScores:r.property("feedback_scores",r.list(Y).optional())});var lh=r.object({experimentName:r.property("experiment_name",r.string()),datasetName:r.property("dataset_name",r.string()),experimentId:r.property("experiment_id",r.string().optional()),items:r.list(Sc)});var Oe=r.object({id:r.string().optional(),text:r.string(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ae=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var xc=r.enum_(["regular","trial","mini-batch"]);var _c=r.enum_(["running","completed","cancelled"]);var Fi=r.object({id:r.string(),commit:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),promptName:r.property("prompt_name",r.string().optional())});var Jo=r.object({id:r.string().optional(),datasetName:r.property("dataset_name",r.string()),datasetId:r.property("dataset_id",r.string().optional()),name:r.string().optional(),metadata:ae.optional(),type:xc.optional(),optimizationId:r.property("optimization_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Me).optional()),comments:r.list(Oe).optional(),traceCount:r.property("trace_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),duration:Wo.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostAvg:r.property("total_estimated_cost_avg",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),status:_c.optional(),promptVersion:r.property("prompt_version",Fi.optional()),promptVersions:r.property("prompt_versions",r.list(Fi).optional())});var Tc=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Jo).optional(),sortableBy:r.list(r.string()).optional()});var Ac=r.object({label:r.string().optional()});var Ec=r.object({groupSorting:r.property("group_sorting",r.list(r.string()).optional())});var Pc=r.object({groupsDetails:r.property("groups_details",r.list(Ec).optional())});var vc=r.object({content:r.record(r.string(),Ac).optional(),details:Pc.optional()});var Cc=r.object({experimentCount:r.property("experiment_count",r.number().optional()),traceCount:r.property("trace_count",r.number().optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostAvg:r.property("total_estimated_cost_avg",r.number().optional()),duration:ze.optional(),feedbackScores:r.property("feedback_scores",r.list(ie).optional())});var Ic=r.object({aggregations:Cc.optional()});var jc=r.object({content:r.record(r.string(),Ic).optional()});var mh=r.object({ids:r.list(r.string())});var Uc=r.object({typeName:r.string().optional()});var dh=r.object({type:Uc.optional(),closed:r.boolean().optional()});var Nc=r.object({trueLabel:r.string(),falseLabel:r.string()});var Mc=r.object({details:Nc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Dc=r.object({categories:r.record(r.string(),r.number())});var Fc=r.object({details:Dc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Oc=r.object({max:r.number(),min:r.number()});var Wc=r.object({details:Oc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Bc=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),createdAt:r.date().optional(),createdBy:r.string().optional(),lastUpdatedAt:r.date().optional(),lastUpdatedBy:r.string().optional()}),uh=r.union("type",{numerical:Wc.extend(Bc),categorical:Fc.extend(Bc),boolean:Mc.extend(Bc)}).transform({transform:n=>n,untransform:n=>n});var Lc=r.object({trueLabel:r.string(),falseLabel:r.string()});var Vc=r.object({details:Lc.optional()});var Hc=r.object({categories:r.record(r.string(),r.number())});var Jc=r.object({details:Hc.optional()});var Kc=r.object({max:r.number(),min:r.number()});var Xc=r.object({details:Kc.optional()});var Gc=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional()}),$c=r.union("type",{numerical:Xc.extend(Gc),categorical:Jc.extend(Gc),boolean:Vc.extend(Gc)}).transform({transform:n=>n,untransform:n=>n});var Qc=r.object({trueLabel:r.string(),falseLabel:r.string()});var Ko=r.object({details:Qc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Yc=r.object({categories:r.record(r.string(),r.number())});var Xo=r.object({details:Yc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Zc=r.object({max:r.number(),min:r.number()});var Go=r.object({details:Zc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var qc=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),createdAt:r.date().optional(),createdBy:r.string().optional(),lastUpdatedAt:r.date().optional(),lastUpdatedBy:r.string().optional()}),el=r.union("type",{numerical:Go.extend(qc),categorical:Xo.extend(qc),boolean:Ko.extend(qc)}).transform({transform:n=>n,untransform:n=>n});var rl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(el).optional()});var ol=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),createdAt:r.date().optional(),createdBy:r.string().optional(),lastUpdatedAt:r.date().optional(),lastUpdatedBy:r.string().optional()}),tl=r.union("type",{numerical:Go.extend(ol),categorical:Xo.extend(ol),boolean:Ko.extend(ol)}).transform({transform:n=>n,untransform:n=>n});var il=r.object({trueLabel:r.string(),falseLabel:r.string()});var al=r.object({details:il.optional()});var nl=r.object({categories:r.record(r.string(),r.number())});var sl=r.object({details:nl.optional()});var pl=r.object({max:r.number(),min:r.number()});var cl=r.object({details:pl.optional()});var ll=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional()}),ml=r.union("type",{numerical:cl.extend(ll),categorical:sl.extend(ll),boolean:al.extend(ll)}).transform({transform:n=>n,untransform:n=>n});var dl=r.enum_(["TOPIC","PII"]);var ul=r.enum_(["passed","failed"]);var gl=r.object({id:r.string().optional(),entityId:r.property("entity_id",r.string()),secondaryId:r.property("secondary_id",r.string()),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:dl,result:ul,config:F,details:F});var gh=r.object({guardrails:r.list(gl)});var wl=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var $o=r.object({id:r.string().optional(),provider:wl,apiKey:r.property("api_key",r.string().optional()),name:r.string().optional(),providerName:r.property("provider_name",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),configuration:r.record(r.string(),r.string()).optional(),baseUrl:r.property("base_url",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var hl=r.object({size:r.number().optional(),total:r.number().optional(),content:r.list($o).optional(),sortableBy:r.list(r.string()).optional()});var fl=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var wh=r.object({id:r.string().optional(),provider:fl,apiKey:r.property("api_key",r.string().optional()),name:r.string().optional(),providerName:r.property("provider_name",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),configuration:r.record(r.string(),r.string()).optional(),baseUrl:r.property("base_url",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Oi=r.object({entitiesQueued:r.property("entities_queued",r.number().optional()),rulesApplied:r.property("rules_applied",r.number().optional())});var Rl=r.enum_(["trace","thread"]);var Wi=r.object({projectId:r.property("project_id",r.string()),entityIds:r.property("entity_ids",r.list(r.string())),ruleIds:r.property("rule_ids",r.list(r.string())),entityType:r.property("entity_type",Rl)});var hh=F;var bl=r.enum_(["running","completed","cancelled"]);var fh=r.object({id:r.string().optional(),name:r.string().optional(),datasetName:r.property("dataset_name",r.string()),objectiveName:r.property("objective_name",r.string()),status:bl,metadata:U.optional(),datasetId:r.property("dataset_id",r.string().optional()),numTrials:r.property("num_trials",r.number().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var yl=r.enum_(["running","completed","cancelled"]);var Bi=r.object({id:r.string().optional(),name:r.string().optional(),datasetName:r.property("dataset_name",r.string()),objectiveName:r.property("objective_name",r.string()),status:yl,metadata:te.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var kl=r.enum_(["running","completed","cancelled"]);var Qo=r.object({id:r.string().optional(),name:r.string().optional(),datasetName:r.property("dataset_name",r.string()),objectiveName:r.property("objective_name",r.string()),status:kl,metadata:ae.optional(),datasetId:r.property("dataset_id",r.string().optional()),numTrials:r.property("num_trials",r.number().optional()),feedbackScores:r.property("feedback_scores",r.list(Me).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var zl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Qo).optional(),sortableBy:r.list(r.string()).optional()});var Yo=r.object({count:r.number().optional(),deviation:r.number().optional(),deviationPercentage:r.property("deviation_percentage",r.number().optional())});var Sl=r.enum_(["private","public"]);var Rh=r.object({id:r.string().optional(),name:r.string(),visibility:Sl.optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),lastUpdatedTraceAt:r.property("last_updated_trace_at",r.date().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),duration:ze.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostSum:r.property("total_estimated_cost_sum",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),traceCount:r.property("trace_count",r.number().optional()),guardrailsFailedCount:r.property("guardrails_failed_count",r.number().optional()),errorCount:r.property("error_count",Yo.optional())});var xl=r.enum_(["private","public"]);var Zo=r.object({id:r.string().optional(),name:r.string(),visibility:xl.optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),lastUpdatedTraceAt:r.property("last_updated_trace_at",r.date().optional())});var _l=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Zo).optional(),sortableBy:r.list(r.string()).optional()});var Tl=r.object({name:r.string().optional()});var Al=r.object({scores:r.list(Tl).optional()});var El=r.object({time:r.date(),value:r.number().optional()});var Pl=r.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST","GUARDRAILS_FAILED_COUNT","THREAD_COUNT","THREAD_DURATION","THREAD_FEEDBACK_SCORES"]);var vl=r.enum_(["HOURLY","DAILY","WEEKLY"]);var Cl=r.object({name:r.string().optional(),data:r.list(El).optional()});var Il=r.object({projectId:r.property("project_id",r.string().optional()),metricType:r.property("metric_type",Pl.optional()),interval:vl.optional(),results:r.list(Cl).optional()});var jl=r.object({projectId:r.property("project_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),duration:ze.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostSum:r.property("total_estimated_cost_sum",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),traceCount:r.property("trace_count",r.number().optional()),guardrailsFailedCount:r.property("guardrails_failed_count",r.number().optional()),errorCount:r.property("error_count",Yo.optional())});var Ul=r.object({content:r.list(jl).optional()});var Nl=r.object({count:r.number().optional(),deviation:r.number().optional(),deviationPercentage:r.property("deviation_percentage",r.number().optional())});var Ml=r.object({name:r.string(),value:r.number()});var Dl=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var Fl=r.enum_(["private","public"]);var Ol=r.object({id:r.string().optional(),name:r.string(),visibility:Fl.optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),lastUpdatedTraceAt:r.property("last_updated_trace_at",r.date().optional()),feedbackScores:r.property("feedback_scores",r.list(Ml).optional()),duration:Dl.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostSum:r.property("total_estimated_cost_sum",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),traceCount:r.property("trace_count",r.number().optional()),guardrailsFailedCount:r.property("guardrails_failed_count",r.number().optional()),errorCount:r.property("error_count",Nl.optional())});var bh=r.object({errors:r.list(r.string()).optional()});var Wl=r.enum_(["mustache","jinja2"]);var Bl=r.enum_(["mustache","jinja2"]);var Ll=r.object({id:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),commit:r.string().optional(),template:r.string(),metadata:F.optional(),type:Bl.optional(),changeDescription:r.property("change_description",r.string().optional()),variables:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var yh=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),template:r.string().optional(),metadata:F.optional(),changeDescription:r.property("change_description",r.string().optional()),type:Wl.optional(),tags:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),versionCount:r.property("version_count",r.number().optional()),latestVersion:r.property("latest_version",Ll.optional())});var kh=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var Vl=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),tags:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),versionCount:r.property("version_count",r.number().optional()),latestVersion:r.property("latest_version",he.optional())});var Hl=r.enum_(["mustache","jinja2"]);var Jl=r.object({id:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),commit:r.string().optional(),template:r.string(),metadata:ke.optional(),type:Hl.optional(),changeDescription:r.property("change_description",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var Kl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Jl).optional()});var Xl=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),tags:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),versionCount:r.property("version_count",r.number().optional())});var Gl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Xl).optional(),sortableBy:r.list(r.string()).optional()});var $l=r.object({pythonEvaluatorEnabled:r.boolean(),traceThreadPythonEvaluatorEnabled:r.boolean(),guardrailsEnabled:r.boolean(),opikAiEnabled:r.property("opikAIEnabled",r.boolean()),alertsEnabled:r.boolean(),welcomeWizardEnabled:r.boolean()});var zh=r.object({spans:r.list(Ho)});var qo=r.object({name:r.string(),author:r.string().optional()});var et=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var Ql=r.enum_(["ui","sdk","online_scoring"]);var Yl=r.enum_(["ui","sdk","online_scoring"]);var Zl=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Yl.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var rt=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Ql,createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),valueByAuthor:r.property("value_by_author",r.record(r.string(),Zl).optional())});var ql=r.enum_(["general","tool","llm","guardrail"]);var ot=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),traceId:r.property("trace_id",r.string().optional()),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:ql.optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:ae.optional(),output:ae.optional(),metadata:ae.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),errorInfo:r.property("error_info",et.optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(rt).optional()),comments:r.list(Oe).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostVersion:r.property("total_estimated_cost_version",r.string().optional()),duration:r.number().optional()});var em=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(ot).optional(),sortableBy:r.list(r.string()).optional()});var rm=r.enum_(["ui","sdk","online_scoring"]);var om=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:rm,author:r.string().optional(),id:r.string()});var tt=r.object({scores:r.list(om)});var Sh=r.object({traces:r.list(Vo)});var xh=r.object({ids:r.list(r.string()),projectId:r.property("project_id",r.string().optional())});var tm=r.enum_(["TOPIC","PII"]);var im=r.enum_(["passed","failed"]);var am=r.object({name:tm.optional(),result:im.optional()});var nm=r.object({spanId:r.property("span_id",r.string().optional()),checks:r.list(am).optional()});var sm=r.enum_(["default","hidden"]);var it=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string().optional()),name:r.string().optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:ae.optional(),output:ae.optional(),metadata:ae.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",et.optional()),usage:r.record(r.string(),r.number()).optional(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(rt).optional()),comments:r.list(Oe).optional(),guardrailsValidations:r.property("guardrails_validations",r.list(nm).optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),spanCount:r.property("span_count",r.number().optional()),duration:r.number().optional(),threadId:r.property("thread_id",r.string().optional()),visibilityMode:r.property("visibility_mode",sm.optional()),llmSpanCount:r.property("llm_span_count",r.number().optional()),providers:r.list(r.string()).optional()});var pm=r.enum_(["active","inactive"]);var at=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string().optional()),threadModelId:r.property("thread_model_id",r.string().optional()),startTime:r.property("start_time",r.date().optional()),endTime:r.property("end_time",r.date().optional()),duration:r.number().optional(),firstMessage:r.property("first_message",U.optional()),lastMessage:r.property("last_message",U.optional()),feedbackScores:r.property("feedback_scores",r.list(Y).optional()),status:pm.optional(),numberOfMessages:r.property("number_of_messages",r.number().optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),comments:r.list(L).optional(),tags:r.list(r.string()).optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),createdBy:r.property("created_by",r.string().optional()),createdAt:r.property("created_at",r.date().optional())});var Li=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),threadId:r.property("thread_id",r.string()),truncate:r.boolean().optional()});var cm=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(at).optional(),sortableBy:r.list(r.string()).optional()});var lm=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(it).optional(),sortableBy:r.list(r.string()).optional()});var mm=r.object({completed:r.boolean().optional()});var We=r.object({name:r.string().optional(),current:r.number().optional(),previous:r.number().optional()});var rr=r.object({projectIds:r.property("project_ids",r.list(r.string()).optional()),intervalStart:r.property("interval_start",r.date()),intervalEnd:r.property("interval_end",r.date()),startBeforeEnd:r.property("start_before_end",r.boolean().optional())});var _h=r.object({time:r.date(),value:r.number().optional()});var Vi=r.object({results:r.list(We).optional()});var Th=r.object({projectIds:r.property("project_ids",r.list(r.string()).optional()),name:r.string().optional(),intervalStart:r.property("interval_start",r.date()),intervalEnd:r.property("interval_end",r.date()),startBeforeEnd:r.property("start_before_end",r.boolean().optional())});var nt=r.object({timeoutToMarkThreadAsInactive:r.property("timeout_to_mark_thread_as_inactive",r.string().optional()),truncationOnTables:r.property("truncation_on_tables",r.boolean().optional())});var dm=r.object({results:r.list(We).optional()});var Hi=class{constructor(t={}){this._options=t;}getDatasetBiInfo(t){return h.fromPromise(this.__getDatasetBiInfo(t))}async __getDatasetBiInfo(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/internal/usage/bi-datasets"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:Ze.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/bi-datasets.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getExperimentBiInfo(t){return h.fromPromise(this.__getExperimentBiInfo(t))}async __getExperimentBiInfo(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/internal/usage/bi-experiments"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:Ze.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/bi-experiments.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getSpansBiInfo(t){return h.fromPromise(this.__getSpansBiInfo(t))}async __getSpansBiInfo(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/internal/usage/bi-spans"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:Ze.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/bi-spans.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getSpansCountForWorkspaces(t){return h.fromPromise(this.__getSpansCountForWorkspaces(t))}async __getSpansCountForWorkspaces(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/internal/usage/workspace-span-counts"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:ss.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/workspace-span-counts.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getTracesBiInfo(t){return h.fromPromise(this.__getTracesBiInfo(t))}async __getTracesBiInfo(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/internal/usage/bi-traces"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:Ze.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/bi-traces.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getTracesCountForWorkspaces(t){return h.fromPromise(this.__getTracesCountForWorkspaces(t))}async __getTracesCountForWorkspaces(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/internal/usage/workspace-trace-counts"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:cs.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/workspace-trace-counts.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Ji=class{constructor(t={}){this._options=t;}findAlerts(t={},e){return h.fromPromise(this.__findAlerts(t,e))}async __findAlerts(t={},e){var g,y;let{page:o,size:i,sorting:a,filters:c}=t,m={};o!=null&&(m.page=o.toString()),i!=null&&(m.size=i.toString()),a!=null&&(m.sorting=a),c!=null&&(m.filters=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:f.Default,"v1/private/alerts"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:m,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:Es.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse});switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/alerts.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}createAlert(t,e){return h.fromPromise(this.__createAlert(t,e))}async __createAlert(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/alerts"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:fo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 409:throw new O(o.error.body,o.rawResponse);case 422:throw new W(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/alerts.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteAlertBatch(t,e){return h.fromPromise(this.__deleteAlertBatch(t,e))}async __deleteAlertBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/alerts/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/alerts/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getAlertById(t,e){return h.fromPromise(this.__getAlertById(t,e))}async __getAlertById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/alerts/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Ro.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/alerts/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateAlert(t,e,o){return h.fromPromise(this.__updateAlert(t,e,o))}async __updateAlert(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/alerts/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:fo.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new A(i.error.body,i.rawResponse);case 409:throw new O(i.error.body,i.rawResponse);case 422:throw new W(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/alerts/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getWebhookExamples(t={},e){return h.fromPromise(this.__getWebhookExamples(t,e))}async __getWebhookExamples(t={},e){var c,m;let{alertType:o}=t,i={};o!=null&&(i.alert_type=Bt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}));let a=await R({url:b((m=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?m:f.Default,"v1/private/alerts/webhooks/examples"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:Ps.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/alerts/webhooks/examples.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}testWebhook(t,e){return h.fromPromise(this.__testWebhook(t,e))}async __testWebhook(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/alerts/webhooks/tests"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:fo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Cs.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 422:throw new W(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/alerts/webhooks/tests.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Ki=class{constructor(t={}){this._options=t;}addItemsToAnnotationQueue(t,e,o){return h.fromPromise(this.__addItemsToAnnotationQueue(t,e,o))}async __addItemsToAnnotationQueue(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/annotation-queues/${encodeURIComponent(t)}/items/add`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Pi.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues/{id}/items/add.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}findAnnotationQueues(t={},e){return h.fromPromise(this.__findAnnotationQueues(t,e))}async __findAnnotationQueues(t={},e){var y,k;let{page:o,size:i,name:a,filters:c,sorting:m}=t,u={};o!=null&&(u.page=o.toString()),i!=null&&(u.size=i.toString()),a!=null&&(u.name=a),c!=null&&(u.filters=c),m!=null&&(u.sorting=m);let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:f.Default,"v1/private/annotation-queues"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(g.ok)return {data:Ds.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse});switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/annotation-queues.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}createAnnotationQueue(t,e){return h.fromPromise(this.__createAnnotationQueue(t,e))}async __createAnnotationQueue(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/annotation-queues"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:so.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 422:throw new W(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createAnnotationQueueBatch(t,e){return h.fromPromise(this.__createAnnotationQueueBatch(t,e))}async __createAnnotationQueueBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/annotation-queues/batch"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:po.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 409:throw new O(o.error.body,o.rawResponse);case 422:throw new W(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues/batch.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteAnnotationQueueBatch(t,e){return h.fromPromise(this.__deleteAnnotationQueueBatch(t,e))}async __deleteAnnotationQueueBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/annotation-queues/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getAnnotationQueueById(t,e){return h.fromPromise(this.__getAnnotationQueueById(t,e))}async __getAnnotationQueueById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/annotation-queues/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:bo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/annotation-queues/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateAnnotationQueue(t,e={},o){return h.fromPromise(this.__updateAnnotationQueue(t,e,o))}async __updateAnnotationQueue(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/annotation-queues/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:co.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/annotation-queues/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}removeItemsFromAnnotationQueue(t,e,o){return h.fromPromise(this.__removeItemsFromAnnotationQueue(t,e,o))}async __removeItemsFromAnnotationQueue(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/annotation-queues/${encodeURIComponent(t)}/items/delete`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Pi.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues/{id}/items/delete.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Xi=class{constructor(t={}){this._options=t;}attachmentList(t,e){return h.fromPromise(this.__attachmentList(t,e))}async __attachmentList(t,e){var k,S;let{page:o,size:i,projectId:a,entityType:c,entityId:m,path:u}=t,g={};o!=null&&(g.page=o.toString()),i!=null&&(g.size=i.toString()),g.project_id=a,g.entity_type=Vt.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"}),g.entity_id=m,g.path=u;let y=await R({url:b((S=(k=await s.get(this._options.baseUrl))!=null?k:await s.get(this._options.environment))!=null?S:f.Default,"v1/private/attachment/list"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:g,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(y.ok)return {data:Os.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new X(y.error.body,y.rawResponse);case 403:throw new $(ee.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new p({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}switch(y.error.reason){case "non-json":throw new p({statusCode:y.error.statusCode,body:y.error.rawBody,rawResponse:y.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/attachment/list.");case "unknown":throw new p({message:y.error.errorMessage,rawResponse:y.rawResponse})}}completeMultiPartUpload(t,e){return h.fromPromise(this.__completeMultiPartUpload(t,e))}async __completeMultiPartUpload(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/attachment/upload-complete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:vi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new X(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/attachment/upload-complete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteAttachments(t,e){return h.fromPromise(this.__deleteAttachments(t,e))}async __deleteAttachments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/attachment/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:vi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new X(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/attachment/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}downloadAttachment(t,e){return h.fromPromise(this.__downloadAttachment(t,e))}async __downloadAttachment(t,e){var k,S;let{workspaceName:o,containerId:i,entityType:a,entityId:c,fileName:m,mimeType:u}=t,g={};o!=null&&(g.workspace_name=o),g.container_id=i,g.entity_type=Ht.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}),g.entity_id=c,g.file_name=m,g.mime_type=u;let y=await R({url:b((S=(k=await s.get(this._options.baseUrl))!=null?k:await s.get(this._options.environment))!=null?S:f.Default,"v1/private/attachment/download"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:g,requestType:"json",responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(y.ok)return {data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new X(y.error.body,y.rawResponse);case 403:throw new $(ee.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new p({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}switch(y.error.reason){case "non-json":throw new p({statusCode:y.error.statusCode,body:y.error.rawBody,rawResponse:y.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/attachment/download.");case "unknown":throw new p({message:y.error.errorMessage,rawResponse:y.rawResponse})}}startMultiPartUpload(t,e){return h.fromPromise(this.__startMultiPartUpload(t,e))}async __startMultiPartUpload(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/attachment/upload-start"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:wr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Vs.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new X(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/attachment/upload-start.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}uploadAttachment(t,e){return h.fromPromise(this.__uploadAttachment(t,e))}async __uploadAttachment(t,e){var k,S;let{fileName:o,projectName:i,mimeType:a,entityType:c,entityId:m,body:u}=t,g={};g.file_name=o,i!=null&&(g.project_name=i),a!=null&&(g.mime_type=a),g.entity_type=Kt.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"}),g.entity_id=m;let y=await R({url:b((S=(k=await s.get(this._options.baseUrl))!=null?k:await s.get(this._options.environment))!=null?S:f.Default,"v1/private/attachment/upload"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:g,requestType:"json",body:$e.uploadAttachment.Request.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(y.ok)return {data:void 0,rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new X(y.error.body,y.rawResponse);case 403:throw new $(ee.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new p({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}switch(y.error.reason){case "non-json":throw new p({statusCode:y.error.statusCode,body:y.error.rawBody,rawResponse:y.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/attachment/upload.");case "unknown":throw new p({message:y.error.errorMessage,rawResponse:y.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Gi=class{constructor(t={}){this._options=t;}access(t,e){return h.fromPromise(this.__access(t,e))}async __access(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/auth"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Hs.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new X(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/auth.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getWorkspaceName(t){return h.fromPromise(this.__getWorkspaceName(t))}async __getWorkspaceName(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/private/auth/workspace"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:Js.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")switch(e.error.statusCode){case 401:throw new X(e.error.body,e.rawResponse);case 403:throw new $(ee.parseOrThrow(e.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),e.rawResponse);default:throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse})}switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/auth/workspace.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var $i=class{constructor(t={}){this._options=t;}findEvaluators(t={},e){return h.fromPromise(this.__findEvaluators(t,e))}async __findEvaluators(t={},e){var S,x;let{projectId:o,id:i,name:a,filters:c,sorting:m,page:u,size:g}=t,y={};o!=null&&(y.project_id=o),i!=null&&(y.id=i),a!=null&&(y.name=a),c!=null&&(y.filters=c),m!=null&&(y.sorting=m),u!=null&&(y.page=u.toString()),g!=null&&(y.size=g.toString());let k=await R({url:b((x=(S=await s.get(this._options.baseUrl))!=null?S:await s.get(this._options.environment))!=null?x:f.Default,"v1/private/automations/evaluators"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:y,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(k.ok)return {data:bp.parseOrThrow(k.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:k.rawResponse};if(k.error.reason==="status-code")throw new p({statusCode:k.error.statusCode,body:k.error.body,rawResponse:k.rawResponse});switch(k.error.reason){case "non-json":throw new p({statusCode:k.error.statusCode,body:k.error.rawBody,rawResponse:k.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/automations/evaluators.");case "unknown":throw new p({message:k.error.errorMessage,rawResponse:k.rawResponse})}}createAutomationRuleEvaluator(t,e){return h.fromPromise(this.__createAutomationRuleEvaluator(t,e))}async __createAutomationRuleEvaluator(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/automations/evaluators"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:mp.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/automations/evaluators.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteAutomationRuleEvaluatorBatch(t,e){return h.fromPromise(this.__deleteAutomationRuleEvaluatorBatch(t,e))}async __deleteAutomationRuleEvaluatorBatch(t,e){var m,u;let{projectId:o,body:i}=t,a={};o!=null&&(a.project_id=o);let c=await R({url:b((u=(m=await s.get(this._options.baseUrl))!=null?m:await s.get(this._options.environment))!=null?u:f.Default,"v1/private/automations/evaluators/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:a,requestType:"json",body:B.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(c.ok)return {data:void 0,rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/automations/evaluators/delete.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}getEvaluatorById(t,e={},o){return h.fromPromise(this.__getEvaluatorById(t,e,o))}async __getEvaluatorById(t,e={},o){var m,u;let{projectId:i}=e,a={};i!=null&&(a.project_id=i);let c=await R({url:b((u=(m=await s.get(this._options.baseUrl))!=null?m:await s.get(this._options.environment))!=null?u:f.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:a,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(c.ok)return {data:yp.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/automations/evaluators/{id}.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}updateAutomationRuleEvaluator(t,e,o){return h.fromPromise(this.__updateAutomationRuleEvaluator(t,e,o))}async __updateAutomationRuleEvaluator(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Ep.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/automations/evaluators/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getEvaluatorLogsById(t,e={},o){return h.fromPromise(this.__getEvaluatorLogsById(t,e,o))}async __getEvaluatorLogsById(t,e={},o){var m,u;let{size:i}=e,a={};i!=null&&(a.size=i.toString());let c=await R({url:b((u=(m=await s.get(this._options.baseUrl))!=null?m:await s.get(this._options.environment))!=null?u:f.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}/logs`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:a,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(c.ok)return {data:Sp.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/automations/evaluators/{id}/logs.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Qi=class{constructor(t={}){this._options=t;}createChatCompletions(t={},e){return h.fromPromise(this.__createChatCompletions(t,e))}async __createChatCompletions(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/chat/completions"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:mo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Mp.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/chat/completions.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Yi=class{constructor(t={}){this._options=t;}findDashboards(t={},e){return h.fromPromise(this.__findDashboards(t,e))}async __findDashboards(t={},e){var u,g;let{page:o,size:i,name:a}=t,c={};o!=null&&(c.page=o.toString()),i!=null&&(c.size=i.toString()),a!=null&&(c.name=a);let m=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:f.Default,"v1/private/dashboards"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:c,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(m.ok)return {data:Dp.parseOrThrow(m.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw new p({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});switch(m.error.reason){case "non-json":throw new p({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/dashboards.");case "unknown":throw new p({message:m.error.errorMessage,rawResponse:m.rawResponse})}}createDashboard(t,e){return h.fromPromise(this.__createDashboard(t,e))}async __createDashboard(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/dashboards"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:uo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:De.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/dashboards.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getDashboardById(t,e){return h.fromPromise(this.__getDashboardById(t,e))}async __getDashboardById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/dashboards/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:De.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/dashboards/{dashboardId}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteDashboard(t,e){return h.fromPromise(this.__deleteDashboard(t,e))}async __deleteDashboard(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/dashboards/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/dashboards/{dashboardId}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateDashboard(t,e={},o){return h.fromPromise(this.__updateDashboard(t,e,o))}async __updateDashboard(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/dashboards/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:go.jsonOrThrow(e,{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(i.ok)return {data:De.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new T(i.error.body,i.rawResponse);case 409:throw new O(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/dashboards/{dashboardId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Zi=class{constructor(t={}){this._options=t;}findDatasets(t={},e){return h.fromPromise(this.__findDatasets(t,e))}async __findDatasets(t={},e){var x,_;let{page:o,size:i,withExperimentsOnly:a,withOptimizationsOnly:c,promptId:m,name:u,sorting:g,filters:y}=t,k={};o!=null&&(k.page=o.toString()),i!=null&&(k.size=i.toString()),a!=null&&(k.with_experiments_only=a.toString()),c!=null&&(k.with_optimizations_only=c.toString()),m!=null&&(k.prompt_id=m),u!=null&&(k.name=u),g!=null&&(k.sorting=g),y!=null&&(k.filters=y);let S=await R({url:b((_=(x=await s.get(this._options.baseUrl))!=null?x:await s.get(this._options.environment))!=null?_:f.Default,"v1/private/datasets"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:k,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(S.ok)return {data:ec.parseOrThrow(S.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:S.rawResponse};if(S.error.reason==="status-code")throw new p({statusCode:S.error.statusCode,body:S.error.body,rawResponse:S.rawResponse});switch(S.error.reason){case "non-json":throw new p({statusCode:S.error.statusCode,body:S.error.rawBody,rawResponse:S.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets.");case "unknown":throw new p({message:S.error.errorMessage,rawResponse:S.rawResponse})}}createDataset(t,e){return h.fromPromise(this.__createDataset(t,e))}async __createDataset(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/datasets"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:hr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createOrUpdateDatasetItems(t,e){return h.fromPromise(this.__createOrUpdateDatasetItems(t,e))}async __createOrUpdateDatasetItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/datasets/items"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:fr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/datasets/items.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createDatasetItemsFromSpans(t,e,o){return h.fromPromise(this.__createDatasetItemsFromSpans(t,e,o))}async __createDatasetItemsFromSpans(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/from-spans`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Rr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/{dataset_id}/items/from-spans.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}createDatasetItemsFromTraces(t,e,o){return h.fromPromise(this.__createDatasetItemsFromTraces(t,e,o))}async __createDatasetItemsFromTraces(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/from-traces`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:br.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/{dataset_id}/items/from-traces.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getDatasetById(t,e){return h.fromPromise(this.__getDatasetById(t,e))}async __getDatasetById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:qe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateDataset(t,e,o){return h.fromPromise(this.__updateDataset(t,e,o))}async __updateDataset(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:yr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/datasets/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteDataset(t,e){return h.fromPromise(this.__deleteDataset(t,e))}async __deleteDataset(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/datasets/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteDatasetByName(t,e){return h.fromPromise(this.__deleteDatasetByName(t,e))}async __deleteDatasetByName(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/datasets/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:kr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteDatasetItems(t,e){return h.fromPromise(this.__deleteDatasetItems(t,e))}async __deleteDatasetItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/datasets/items/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:zr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/items/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteDatasetsBatch(t,e){return h.fromPromise(this.__deleteDatasetsBatch(t,e))}async __deleteDatasetsBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/datasets/delete-batch"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/delete-batch.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}expandDataset(t,e,o){return h.fromPromise(this.__expandDataset(t,e,o))}async __expandDataset(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/datasets/${encodeURIComponent(t)}/expansions`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Sr.jsonOrThrow(e,{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(i.ok)return {data:Wp.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/{id}/expansions.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}findDatasetItemsWithExperimentItems(t,e,o){return h.fromPromise(this.__findDatasetItemsWithExperimentItems(t,e,o))}async __findDatasetItemsWithExperimentItems(t,e,o){var x,_;let{page:i,size:a,experimentIds:c,filters:m,sorting:u,search:g,truncate:y}=e,k={};i!=null&&(k.page=i.toString()),a!=null&&(k.size=a.toString()),k.experiment_ids=c,m!=null&&(k.filters=m),u!=null&&(k.sorting=u),g!=null&&(k.search=g),y!=null&&(k.truncate=y.toString());let S=await R({url:b((_=(x=await s.get(this._options.baseUrl))!=null?x:await s.get(this._options.environment))!=null?_:f.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:k,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(S.ok)return {data:Zp.parseOrThrow(S.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:S.rawResponse};if(S.error.reason==="status-code")throw new p({statusCode:S.error.statusCode,body:S.error.body,rawResponse:S.rawResponse});switch(S.error.reason){case "non-json":throw new p({statusCode:S.error.statusCode,body:S.error.rawBody,rawResponse:S.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items.");case "unknown":throw new p({message:S.error.errorMessage,rawResponse:S.rawResponse})}}getDatasetByIdentifier(t,e){return h.fromPromise(this.__getDatasetByIdentifier(t,e))}async __getDatasetByIdentifier(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/datasets/retrieve"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:xr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:qe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/retrieve.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getDatasetExperimentItemsStats(t,e,o){return h.fromPromise(this.__getDatasetExperimentItemsStats(t,e,o))}async __getDatasetExperimentItemsStats(t,e,o){var u,g;let{experimentIds:i,filters:a}=e,c={};c.experiment_ids=i,a!=null&&(c.filters=a);let m=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:f.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items/stats`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:c,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(m.ok)return {data:Fe.parseOrThrow(m.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw new p({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});switch(m.error.reason){case "non-json":throw new p({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items/stats.");case "unknown":throw new p({message:m.error.errorMessage,rawResponse:m.rawResponse})}}getDatasetItemById(t,e){return h.fromPromise(this.__getDatasetItemById(t,e))}async __getDatasetItemById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/datasets/items/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Lo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/items/{itemId}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getDatasetItems(t,e={},o){return h.fromPromise(this.__getDatasetItems(t,e,o))}async __getDatasetItems(t,e={},o){var y,k;let{page:i,size:a,filters:c,truncate:m}=e,u={};i!=null&&(u.page=i.toString()),a!=null&&(u.size=a.toString()),c!=null&&(u.filters=c),m!=null&&(u.truncate=m.toString());let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:f.Default,`v1/private/datasets/${encodeURIComponent(t)}/items`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:u,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(g.ok)return {data:lc.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse});switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}getDatasetItemsOutputColumns(t,e={},o){return h.fromPromise(this.__getDatasetItemsOutputColumns(t,e,o))}async __getDatasetItemsOutputColumns(t,e={},o){var m,u;let{experimentIds:i}=e,a={};i!=null&&(a.experiment_ids=i);let c=await R({url:b((u=(m=await s.get(this._options.baseUrl))!=null?m:await s.get(this._options.environment))!=null?u:f.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items/output/columns`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:a,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(c.ok)return {data:uc.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items/output/columns.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}streamDatasetItems(t,e){return h.fromPromise(this.__streamDatasetItems(t,e))}async __streamDatasetItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/datasets/items/stream"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:_r.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/items/stream.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var qi=class{constructor(t={}){this._options=t;}findExperiments(t={},e){return h.fromPromise(this.__findExperiments(t,e))}async __findExperiments(t={},e){var M,N;let{page:o,size:i,datasetId:a,optimizationId:c,types:m,name:u,datasetDeleted:g,promptId:y,sorting:k,filters:S}=t,x={};o!=null&&(x.page=o.toString()),i!=null&&(x.size=i.toString()),a!=null&&(x.datasetId=a),c!=null&&(x.optimization_id=c),m!=null&&(x.types=m),u!=null&&(x.name=u),g!=null&&(x.dataset_deleted=g.toString()),y!=null&&(x.prompt_id=y),k!=null&&(x.sorting=k),S!=null&&(x.filters=S);let _=await R({url:b((N=(M=await s.get(this._options.baseUrl))!=null?M:await s.get(this._options.environment))!=null?N:f.Default,"v1/private/experiments"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:x,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(_.ok)return {data:Tc.parseOrThrow(_.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:_.rawResponse};if(_.error.reason==="status-code")switch(_.error.statusCode){case 400:throw new A(_.error.body,_.rawResponse);default:throw new p({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse})}switch(_.error.reason){case "non-json":throw new p({statusCode:_.error.statusCode,body:_.error.rawBody,rawResponse:_.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments.");case "unknown":throw new p({message:_.error.errorMessage,rawResponse:_.rawResponse})}}createExperiment(t,e){return h.fromPromise(this.__createExperiment(t,e))}async __createExperiment(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/experiments"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Tr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createExperimentItems(t,e){return h.fromPromise(this.__createExperimentItems(t,e))}async __createExperimentItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/experiments/items"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Er.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/items.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteExperimentItems(t,e){return h.fromPromise(this.__deleteExperimentItems(t,e))}async __deleteExperimentItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/experiments/items/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Pr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/items/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteExperimentsById(t,e){return h.fromPromise(this.__deleteExperimentsById(t,e))}async __deleteExperimentsById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/experiments/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:er.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}experimentItemsBulk(t,e){return h.fromPromise(this.__experimentItemsBulk(t,e))}async __experimentItemsBulk(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/experiments/items/bulk"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Cr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 409:throw new O(o.error.body,o.rawResponse);case 422:throw new W(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/experiments/items/bulk.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}findFeedbackScoreNames(t={},e){return h.fromPromise(this.__findFeedbackScoreNames(t,e))}async __findFeedbackScoreNames(t={},e){var c,m;let{experimentIds:o}=t,i={};o!=null&&(i.experiment_ids=o);let a=await R({url:b((m=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?m:f.Default,"v1/private/experiments/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:Qe.findFeedbackScoreNames.Response.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/feedback-scores/names.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}findExperimentGroups(t={},e){return h.fromPromise(this.__findExperimentGroups(t,e))}async __findExperimentGroups(t={},e){var g,y;let{groups:o,types:i,name:a,filters:c}=t,m={};o!=null&&(m.groups=o),i!=null&&(m.types=i),a!=null&&(m.name=a),c!=null&&(m.filters=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:f.Default,"v1/private/experiments/groups"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:m,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:vc.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new A(u.error.body,u.rawResponse);default:throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/groups.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}findExperimentGroupsAggregations(t={},e){return h.fromPromise(this.__findExperimentGroupsAggregations(t,e))}async __findExperimentGroupsAggregations(t={},e){var g,y;let{groups:o,types:i,name:a,filters:c}=t,m={};o!=null&&(m.groups=o),i!=null&&(m.types=i),a!=null&&(m.name=a),c!=null&&(m.filters=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:f.Default,"v1/private/experiments/groups/aggregations"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:m,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:jc.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new A(u.error.body,u.rawResponse);default:throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/groups/aggregations.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}finishExperiments(t,e){return h.fromPromise(this.__finishExperiments(t,e))}async __finishExperiments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/experiments/finish"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:er.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/finish.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getExperimentById(t,e){return h.fromPromise(this.__getExperimentById(t,e))}async __getExperimentById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/experiments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Jo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateExperiment(t,e={},o){return h.fromPromise(this.__updateExperiment(t,e,o))}async __updateExperiment(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/experiments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Ir.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new A(i.error.body,i.rawResponse);case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/experiments/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getExperimentItemById(t,e){return h.fromPromise(this.__getExperimentItemById(t,e))}async __getExperimentItemById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/experiments/items/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Bo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/items/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}streamExperimentItems(t,e){return h.fromPromise(this.__streamExperimentItems(t,e))}async __streamExperimentItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/experiments/items/stream"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:jr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/items/stream.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}streamExperiments(t,e){return h.fromPromise(this.__streamExperiments(t,e))}async __streamExperiments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/experiments/stream"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ur.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/stream.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ea=class{constructor(t={}){this._options=t;}findFeedbackDefinitions(t={},e){return h.fromPromise(this.__findFeedbackDefinitions(t,e))}async __findFeedbackDefinitions(t={},e){var g,y;let{page:o,size:i,name:a,type:c}=t,m={};o!=null&&(m.page=o.toString()),i!=null&&(m.size=i.toString()),a!=null&&(m.name=a),c!=null&&(m.type=ti.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"}));let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:f.Default,"v1/private/feedback-definitions"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:m,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:rl.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse});switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/feedback-definitions.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}createFeedbackDefinition(t,e){return h.fromPromise(this.__createFeedbackDefinition(t,e))}async __createFeedbackDefinition(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/feedback-definitions"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:$c.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/feedback-definitions.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getFeedbackDefinitionById(t,e){return h.fromPromise(this.__getFeedbackDefinitionById(t,e))}async __getFeedbackDefinitionById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:tl.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/feedback-definitions/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateFeedbackDefinition(t,e,o){return h.fromPromise(this.__updateFeedbackDefinition(t,e,o))}async __updateFeedbackDefinition(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:ml.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/feedback-definitions/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteFeedbackDefinitionById(t,e){return h.fromPromise(this.__deleteFeedbackDefinitionById(t,e))}async __deleteFeedbackDefinitionById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new O(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/feedback-definitions/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteFeedbackDefinitionsBatch(t,e){return h.fromPromise(this.__deleteFeedbackDefinitionsBatch(t,e))}async __deleteFeedbackDefinitionsBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/feedback-definitions/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new O(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/feedback-definitions/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ra=class{constructor(t={}){this._options=t;}createGuardrails(t,e){return h.fromPromise(this.__createGuardrails(t,e))}async __createGuardrails(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/guardrails"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:wo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/guardrails.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var oa=class{constructor(t={}){this._options=t;}deleteLlmProviderApiKeysBatch(t,e){return h.fromPromise(this.__deleteLlmProviderApiKeysBatch(t,e))}async __deleteLlmProviderApiKeysBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/llm-provider-key/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/llm-provider-key/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}findLlmProviderKeys(t){return h.fromPromise(this.__findLlmProviderKeys(t))}async __findLlmProviderKeys(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/private/llm-provider-key"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:hl.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/llm-provider-key.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}storeLlmProviderApiKey(t,e){return h.fromPromise(this.__storeLlmProviderApiKey(t,e))}async __storeLlmProviderApiKey(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/llm-provider-key"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Nr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new X(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/llm-provider-key.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getLlmProviderApiKeyById(t,e){return h.fromPromise(this.__getLlmProviderApiKeyById(t,e))}async __getLlmProviderApiKeyById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/llm-provider-key/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:$o.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/llm-provider-key/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateLlmProviderApiKey(t,e={},o){return h.fromPromise(this.__updateLlmProviderApiKey(t,e,o))}async __updateLlmProviderApiKey(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/llm-provider-key/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Mr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 401:throw new X(i.error.body,i.rawResponse);case 403:throw new $(ee.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/llm-provider-key/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ta=class{constructor(t={}){this._options=t;}evaluateThreads(t,e){return h.fromPromise(this.__evaluateThreads(t,e))}async __evaluateThreads(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/manual-evaluation/threads"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Wi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Oi.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/manual-evaluation/threads.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}evaluateTraces(t,e){return h.fromPromise(this.__evaluateTraces(t,e))}async __evaluateTraces(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/manual-evaluation/traces"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Wi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Oi.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/manual-evaluation/traces.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ia=class{constructor(t={}){this._options=t;}receiveProtobufTraces(t){return h.fromPromise(this.__receiveProtobufTraces(t))}async __receiveProtobufTraces(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/private/otel/v1/traces"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:e.body,rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/otel/v1/traces.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var aa=class{constructor(t={}){this._options=t;}findOptimizations(t={},e){return h.fromPromise(this.__findOptimizations(t,e))}async __findOptimizations(t={},e){var y,k;let{page:o,size:i,datasetId:a,name:c,datasetDeleted:m}=t,u={};o!=null&&(u.page=o.toString()),i!=null&&(u.size=i.toString()),a!=null&&(u.dataset_id=a),c!=null&&(u.name=c),m!=null&&(u.dataset_deleted=m.toString());let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:f.Default,"v1/private/optimizations"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(g.ok)return {data:zl.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new A(g.error.body,g.rawResponse);default:throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/optimizations.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}createOptimization(t,e){return h.fromPromise(this.__createOptimization(t,e))}async __createOptimization(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/optimizations"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Bi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/optimizations.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}upsertOptimization(t,e){return h.fromPromise(this.__upsertOptimization(t,e))}async __upsertOptimization(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/optimizations"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Bi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/optimizations.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteOptimizationsById(t,e){return h.fromPromise(this.__deleteOptimizationsById(t,e))}async __deleteOptimizationsById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/optimizations/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:er.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/optimizations/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getOptimizationById(t,e){return h.fromPromise(this.__getOptimizationById(t,e))}async __getOptimizationById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/optimizations/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Qo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/optimizations/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateOptimizationsById(t,e={},o){return h.fromPromise(this.__updateOptimizationsById(t,e,o))}async __updateOptimizationsById(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/optimizations/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Dr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/optimizations/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var na=class{constructor(t={}){this._options=t;}findProjects(t={},e){return h.fromPromise(this.__findProjects(t,e))}async __findProjects(t={},e){var g,y;let{page:o,size:i,name:a,sorting:c}=t,m={};o!=null&&(m.page=o.toString()),i!=null&&(m.size=i.toString()),a!=null&&(m.name=a),c!=null&&(m.sorting=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:f.Default,"v1/private/projects"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:m,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:_l.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse});switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/projects.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}createProject(t,e){return h.fromPromise(this.__createProject(t,e))}async __createProject(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/projects"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Fr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 422:throw new W(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/projects.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getProjectById(t,e){return h.fromPromise(this.__getProjectById(t,e))}async __getProjectById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Zo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/projects/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteProjectById(t,e){return h.fromPromise(this.__deleteProjectById(t,e))}async __deleteProjectById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new O(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/projects/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateProject(t,e={},o){return h.fromPromise(this.__updateProject(t,e,o))}async __updateProject(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Or.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new A(i.error.body,i.rawResponse);case 422:throw new W(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/projects/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteProjectsBatch(t,e){return h.fromPromise(this.__deleteProjectsBatch(t,e))}async __deleteProjectsBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/projects/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/projects/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}findFeedbackScoreNamesByProjectIds(t={},e){return h.fromPromise(this.__findFeedbackScoreNamesByProjectIds(t,e))}async __findFeedbackScoreNamesByProjectIds(t={},e){var c,m;let{projectIds:o}=t,i={};o!=null&&(i.project_ids=o);let a=await R({url:b((m=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?m:f.Default,"v1/private/projects/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:Al.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/projects/feedback-scores/names.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}getProjectMetrics(t,e={},o){return h.fromPromise(this.__getProjectMetrics(t,e,o))}async __getProjectMetrics(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/projects/${encodeURIComponent(t)}/metrics`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Wr.jsonOrThrow(e,{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(i.ok)return {data:Il.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new A(i.error.body,i.rawResponse);case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/projects/{id}/metrics.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getProjectStats(t={},e){return h.fromPromise(this.__getProjectStats(t,e))}async __getProjectStats(t={},e){var g,y;let{page:o,size:i,name:a,sorting:c}=t,m={};o!=null&&(m.page=o.toString()),i!=null&&(m.size=i.toString()),a!=null&&(m.name=a),c!=null&&(m.sorting=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:f.Default,"v1/private/projects/stats"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:m,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:Ul.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse});switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/projects/stats.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}retrieveProject(t,e){return h.fromPromise(this.__retrieveProject(t,e))}async __retrieveProject(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/projects/retrieve"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Br.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Ol.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 404:throw new T(o.error.body,o.rawResponse);case 422:throw new W(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/projects/retrieve.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var sa=class{constructor(t={}){this._options=t;}getPrompts(t={},e){return h.fromPromise(this.__getPrompts(t,e))}async __getPrompts(t={},e){var y,k;let{page:o,size:i,name:a,sorting:c,filters:m}=t,u={};o!=null&&(u.page=o.toString()),i!=null&&(u.size=i.toString()),a!=null&&(u.name=a),c!=null&&(u.sorting=c),m!=null&&(u.filters=m);let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:f.Default,"v1/private/prompts"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(g.ok)return {data:Gl.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse});switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/prompts.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}createPrompt(t,e){return h.fromPromise(this.__createPrompt(t,e))}async __createPrompt(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/prompts"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Lr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 409:throw new O(o.error.body,o.rawResponse);case 422:throw new W(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createPromptVersion(t,e){return h.fromPromise(this.__createPromptVersion(t,e))}async __createPromptVersion(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/prompts/versions"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Vr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:he.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 409:throw new O(o.error.body,o.rawResponse);case 422:throw new W(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts/versions.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getPromptById(t,e){return h.fromPromise(this.__getPromptById(t,e))}async __getPromptById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Vl.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/prompts/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updatePrompt(t,e,o){return h.fromPromise(this.__updatePrompt(t,e,o))}async __updatePrompt(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Hr.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new A(i.error.body,i.rawResponse);case 404:throw new T(i.error.body,i.rawResponse);case 409:throw new O(i.error.body,i.rawResponse);case 422:throw new W(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/prompts/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deletePrompt(t,e){return h.fromPromise(this.__deletePrompt(t,e))}async __deletePrompt(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/prompts/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deletePromptsBatch(t,e){return h.fromPromise(this.__deletePromptsBatch(t,e))}async __deletePromptsBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/prompts/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getPromptVersionById(t,e){return h.fromPromise(this.__getPromptVersionById(t,e))}async __getPromptVersionById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/prompts/versions/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:he.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/prompts/versions/{versionId}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getPromptVersions(t,e={},o){return h.fromPromise(this.__getPromptVersions(t,e,o))}async __getPromptVersions(t,e={},o){var u,g;let{page:i,size:a}=e,c={};i!=null&&(c.page=i.toString()),a!=null&&(c.size=a.toString());let m=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:f.Default,`v1/private/prompts/${encodeURIComponent(t)}/versions`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:c,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(m.ok)return {data:Kl.parseOrThrow(m.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw new p({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});switch(m.error.reason){case "non-json":throw new p({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/prompts/{id}/versions.");case "unknown":throw new p({message:m.error.errorMessage,rawResponse:m.rawResponse})}}restorePromptVersion(t,e,o){return h.fromPromise(this.__restorePromptVersion(t,e,o))}async __restorePromptVersion(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/prompts/${encodeURIComponent(t)}/versions/${encodeURIComponent(e)}/restore`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(i.ok)return {data:he.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new A(i.error.body,i.rawResponse);case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts/{promptId}/versions/{versionId}/restore.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}retrievePromptVersion(t,e){return h.fromPromise(this.__retrievePromptVersion(t,e))}async __retrievePromptVersion(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/prompts/versions/retrieve"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Jr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:he.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 404:throw new T(o.error.body,o.rawResponse);case 422:throw new W(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts/versions/retrieve.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var pa=class{constructor(t={}){this._options=t;}getServiceToggles(t){return h.fromPromise(this.__getServiceToggles(t))}async __getServiceToggles(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/private/toggles"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:$l.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/toggles.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ca=class{constructor(t={}){this._options=t;}addSpanComment(t,e,o){return h.fromPromise(this.__addSpanComment(t,e,o))}async __addSpanComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/spans/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:L.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/{id}/comments.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}addSpanFeedbackScore(t,e,o){return h.fromPromise(this.__addSpanFeedbackScore(t,e,o))}async __addSpanFeedbackScore(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/spans/${encodeURIComponent(t)}/feedback-scores`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Y.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/spans/{id}/feedback-scores.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getSpansByProject(t={},e){return h.fromPromise(this.__getSpansByProject(t,e))}async __getSpansByProject(t={},e){var q,He;let{page:o,size:i,projectName:a,projectId:c,traceId:m,type:u,filters:g,truncate:y,stripAttachments:k,sorting:S,exclude:x,fromTime:_,toTime:M}=t,N={};o!=null&&(N.page=o.toString()),i!=null&&(N.size=i.toString()),a!=null&&(N.project_name=a),c!=null&&(N.project_id=c),m!=null&&(N.trace_id=m),u!=null&&(N.type=hi.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"})),g!=null&&(N.filters=g),y!=null&&(N.truncate=y.toString()),k!=null&&(N.strip_attachments=k.toString()),S!=null&&(N.sorting=S),x!=null&&(N.exclude=x),_!=null&&(N.from_time=_.toISOString()),M!=null&&(N.to_time=M.toISOString());let K=await R({url:b((He=(q=await s.get(this._options.baseUrl))!=null?q:await s.get(this._options.environment))!=null?He:f.Default,"v1/private/spans"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:N,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(K.ok)return {data:em.parseOrThrow(K.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:K.rawResponse};if(K.error.reason==="status-code")throw new p({statusCode:K.error.statusCode,body:K.error.body,rawResponse:K.rawResponse});switch(K.error.reason){case "non-json":throw new p({statusCode:K.error.statusCode,body:K.error.rawBody,rawResponse:K.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans.");case "unknown":throw new p({message:K.error.errorMessage,rawResponse:K.rawResponse})}}createSpan(t,e){return h.fromPromise(this.__createSpan(t,e))}async __createSpan(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/spans"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Xr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new O(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createSpans(t,e){return h.fromPromise(this.__createSpans(t,e))}async __createSpans(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/spans/batch"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Gr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/batch.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getSpanById(t,e={},o){return h.fromPromise(this.__getSpanById(t,e,o))}async __getSpanById(t,e={},o){var m,u;let{stripAttachments:i}=e,a={};i!=null&&(a.strip_attachments=i.toString());let c=await R({url:b((u=(m=await s.get(this._options.baseUrl))!=null?m:await s.get(this._options.environment))!=null?u:f.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:a,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(c.ok)return {data:ot.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 404:throw new T(c.error.body,c.rawResponse);default:throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans/{id}.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}deleteSpanById(t,e){return h.fromPromise(this.__deleteSpanById(t,e))}async __deleteSpanById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 501:throw new lr(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/spans/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateSpan(t,e,o){return h.fromPromise(this.__updateSpan(t,e,o))}async __updateSpan(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:$r.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/spans/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteSpanComments(t,e){return h.fromPromise(this.__deleteSpanComments(t,e))}async __deleteSpanComments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/spans/comments/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/comments/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteSpanFeedbackScore(t,e,o){return h.fromPromise(this.__deleteSpanFeedbackScore(t,e,o))}async __deleteSpanFeedbackScore(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/spans/${encodeURIComponent(t)}/feedback-scores/delete`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:qo.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/{id}/feedback-scores/delete.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}findFeedbackScoreNames1(t={},e){return h.fromPromise(this.__findFeedbackScoreNames1(t,e))}async __findFeedbackScoreNames1(t={},e){var m,u;let{projectId:o,type:i}=t,a={};o!=null&&(a.project_id=o),i!=null&&(a.type=Ri.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}));let c=await R({url:b((u=(m=await s.get(this._options.baseUrl))!=null?m:await s.get(this._options.environment))!=null?u:f.Default,"v1/private/spans/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(c.ok)return {data:Ye.findFeedbackScoreNames1.Response.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans/feedback-scores/names.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}getSpanComment(t,e,o){return h.fromPromise(this.__getSpanComment(t,e,o))}async __getSpanComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/spans/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(i.ok)return {data:L.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans/{spanId}/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getSpanStats(t={},e){return h.fromPromise(this.__getSpanStats(t,e))}async __getSpanStats(t={},e){var S,x;let{projectId:o,projectName:i,traceId:a,type:c,filters:m,fromTime:u,toTime:g}=t,y={};o!=null&&(y.project_id=o),i!=null&&(y.project_name=i),a!=null&&(y.trace_id=a),c!=null&&(y.type=bi.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"})),m!=null&&(y.filters=m),u!=null&&(y.from_time=u.toISOString()),g!=null&&(y.to_time=g.toISOString());let k=await R({url:b((x=(S=await s.get(this._options.baseUrl))!=null?S:await s.get(this._options.environment))!=null?x:f.Default,"v1/private/spans/stats"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:y,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(k.ok)return {data:Fe.parseOrThrow(k.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:k.rawResponse};if(k.error.reason==="status-code")throw new p({statusCode:k.error.statusCode,body:k.error.body,rawResponse:k.rawResponse});switch(k.error.reason){case "non-json":throw new p({statusCode:k.error.statusCode,body:k.error.rawBody,rawResponse:k.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans/stats.");case "unknown":throw new p({message:k.error.errorMessage,rawResponse:k.rawResponse})}}scoreBatchOfSpans(t,e){return h.fromPromise(this.__scoreBatchOfSpans(t,e))}async __scoreBatchOfSpans(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/spans/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:tt.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/spans/feedback-scores.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}searchSpans(t={},e){return h.fromPromise(this.__searchSpans(t,e))}async __searchSpans(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/spans/search"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Qr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/search.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateSpanComment(t,e,o){return h.fromPromise(this.__updateSpanComment(t,e,o))}async __updateSpanComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/spans/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:L.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/spans/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var la=class{constructor(t={}){this._options=t;}addThreadComment(t,e,o){return h.fromPromise(this.__addThreadComment(t,e,o))}async __addThreadComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/traces/threads/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:L.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/{id}/comments.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}addTraceComment(t,e,o){return h.fromPromise(this.__addTraceComment(t,e,o))}async __addTraceComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/traces/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:L.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/{id}/comments.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}addTraceFeedbackScore(t,e,o){return h.fromPromise(this.__addTraceFeedbackScore(t,e,o))}async __addTraceFeedbackScore(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/traces/${encodeURIComponent(t)}/feedback-scores`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Y.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/{id}/feedback-scores.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}closeTraceThread(t={},e){return h.fromPromise(this.__closeTraceThread(t,e))}async __closeTraceThread(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/threads/close"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Yr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/threads/close.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getTracesByProject(t={},e){return h.fromPromise(this.__getTracesByProject(t,e))}async __getTracesByProject(t={},e){var N,K;let{page:o,size:i,projectName:a,projectId:c,filters:m,truncate:u,stripAttachments:g,sorting:y,exclude:k,fromTime:S,toTime:x}=t,_={};o!=null&&(_.page=o.toString()),i!=null&&(_.size=i.toString()),a!=null&&(_.project_name=a),c!=null&&(_.project_id=c),m!=null&&(_.filters=m),u!=null&&(_.truncate=u.toString()),g!=null&&(_.strip_attachments=g.toString()),y!=null&&(_.sorting=y),k!=null&&(_.exclude=k),S!=null&&(_.from_time=S.toISOString()),x!=null&&(_.to_time=x.toISOString());let M=await R({url:b((K=(N=await s.get(this._options.baseUrl))!=null?N:await s.get(this._options.environment))!=null?K:f.Default,"v1/private/traces"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:_,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(M.ok)return {data:lm.parseOrThrow(M.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:M.rawResponse};if(M.error.reason==="status-code")throw new p({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse});switch(M.error.reason){case "non-json":throw new p({statusCode:M.error.statusCode,body:M.error.rawBody,rawResponse:M.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces.");case "unknown":throw new p({message:M.error.errorMessage,rawResponse:M.rawResponse})}}createTrace(t,e){return h.fromPromise(this.__createTrace(t,e))}async __createTrace(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Zr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createTraces(t,e){return h.fromPromise(this.__createTraces(t,e))}async __createTraces(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/batch"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:qr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/batch.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getTraceById(t,e={},o){return h.fromPromise(this.__getTraceById(t,e,o))}async __getTraceById(t,e={},o){var m,u;let{stripAttachments:i}=e,a={};i!=null&&(a.strip_attachments=i.toString());let c=await R({url:b((u=(m=await s.get(this._options.baseUrl))!=null?m:await s.get(this._options.environment))!=null?u:f.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:a,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(c.ok)return {data:it.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/{id}.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}deleteTraceById(t,e){return h.fromPromise(this.__deleteTraceById(t,e))}async __deleteTraceById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/traces/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateTrace(t,e={},o){return h.fromPromise(this.__updateTrace(t,e,o))}async __updateTrace(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:eo.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/traces/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteThreadComments(t,e){return h.fromPromise(this.__deleteThreadComments(t,e))}async __deleteThreadComments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/threads/comments/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/comments/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteThreadFeedbackScores(t,e){return h.fromPromise(this.__deleteThreadFeedbackScores(t,e))}async __deleteThreadFeedbackScores(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/threads/feedback-scores/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ro.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/feedback-scores/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteTraceComments(t,e){return h.fromPromise(this.__deleteTraceComments(t,e))}async __deleteTraceComments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/comments/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/comments/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteTraceFeedbackScore(t,e,o){return h.fromPromise(this.__deleteTraceFeedbackScore(t,e,o))}async __deleteTraceFeedbackScore(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/traces/${encodeURIComponent(t)}/feedback-scores/delete`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:qo.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/{id}/feedback-scores/delete.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteTraceThreads(t,e){return h.fromPromise(this.__deleteTraceThreads(t,e))}async __deleteTraceThreads(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/threads/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:oo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteTraces(t,e){return h.fromPromise(this.__deleteTraces(t,e))}async __deleteTraces(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}findFeedbackScoreNames2(t={},e){return h.fromPromise(this.__findFeedbackScoreNames2(t,e))}async __findFeedbackScoreNames2(t={},e){var c,m;let{projectId:o}=t,i={};o!=null&&(i.project_id=o);let a=await R({url:b((m=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?m:f.Default,"v1/private/traces/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:Ne.findFeedbackScoreNames2.Response.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/feedback-scores/names.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}findTraceThreadsFeedbackScoreNames(t,e){return h.fromPromise(this.__findTraceThreadsFeedbackScoreNames(t,e))}async __findTraceThreadsFeedbackScoreNames(t,e){var c,m;let{projectId:o}=t,i={};i.project_id=o;let a=await R({url:b((m=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?m:f.Default,"v1/private/traces/threads/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:Ne.findTraceThreadsFeedbackScoreNames.Response.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/threads/feedback-scores/names.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}getTraceStats(t={},e){return h.fromPromise(this.__getTraceStats(t,e))}async __getTraceStats(t={},e){var y,k;let{projectId:o,projectName:i,filters:a,fromTime:c,toTime:m}=t,u={};o!=null&&(u.project_id=o),i!=null&&(u.project_name=i),a!=null&&(u.filters=a),c!=null&&(u.from_time=c.toISOString()),m!=null&&(u.to_time=m.toISOString());let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:f.Default,"v1/private/traces/stats"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(g.ok)return {data:Fe.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse});switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/stats.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}getThreadComment(t,e,o){return h.fromPromise(this.__getThreadComment(t,e,o))}async __getThreadComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/traces/threads/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(i.ok)return {data:L.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/threads/{threadId}/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getTraceComment(t,e,o){return h.fromPromise(this.__getTraceComment(t,e,o))}async __getTraceComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/traces/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(i.ok)return {data:L.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/{traceId}/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getTraceThread(t,e){return h.fromPromise(this.__getTraceThread(t,e))}async __getTraceThread(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/threads/retrieve"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Li.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:at.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/retrieve.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getTraceThreads(t={},e){return h.fromPromise(this.__getTraceThreads(t,e))}async __getTraceThreads(t={},e){var M,N;let{page:o,size:i,projectName:a,projectId:c,truncate:m,stripAttachments:u,filters:g,sorting:y,fromTime:k,toTime:S}=t,x={};o!=null&&(x.page=o.toString()),i!=null&&(x.size=i.toString()),a!=null&&(x.project_name=a),c!=null&&(x.project_id=c),m!=null&&(x.truncate=m.toString()),u!=null&&(x.strip_attachments=u.toString()),g!=null&&(x.filters=g),y!=null&&(x.sorting=y),k!=null&&(x.from_time=k.toISOString()),S!=null&&(x.to_time=S.toISOString());let _=await R({url:b((N=(M=await s.get(this._options.baseUrl))!=null?M:await s.get(this._options.environment))!=null?N:f.Default,"v1/private/traces/threads"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:x,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(_.ok)return {data:cm.parseOrThrow(_.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:_.rawResponse};if(_.error.reason==="status-code")throw new p({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse});switch(_.error.reason){case "non-json":throw new p({statusCode:_.error.statusCode,body:_.error.rawBody,rawResponse:_.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/threads.");case "unknown":throw new p({message:_.error.errorMessage,rawResponse:_.rawResponse})}}openTraceThread(t,e){return h.fromPromise(this.__openTraceThread(t,e))}async __openTraceThread(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/threads/open"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Li.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/threads/open.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}scoreBatchOfThreads(t,e){return h.fromPromise(this.__scoreBatchOfThreads(t,e))}async __scoreBatchOfThreads(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/threads/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:to.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/threads/feedback-scores.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}scoreBatchOfTraces(t,e){return h.fromPromise(this.__scoreBatchOfTraces(t,e))}async __scoreBatchOfTraces(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:tt.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/feedback-scores.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}searchTraceThreads(t={},e){return h.fromPromise(this.__searchTraceThreads(t,e))}async __searchTraceThreads(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/threads/search"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:io.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/search.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}searchTraces(t={},e){return h.fromPromise(this.__searchTraces(t,e))}async __searchTraces(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/traces/search"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ao.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 401:throw new X(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/search.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateThread(t,e={},o){return h.fromPromise(this.__updateThread(t,e,o))}async __updateThread(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/traces/threads/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:no.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/traces/threads/{threadModelId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}updateThreadComment(t,e,o){return h.fromPromise(this.__updateThreadComment(t,e,o))}async __updateThreadComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/traces/threads/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:L.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/traces/threads/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}updateTraceComment(t,e,o){return h.fromPromise(this.__updateTraceComment(t,e,o))}async __updateTraceComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:f.Default,`v1/private/traces/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:L.jsonOrThrow(e,{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(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/traces/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ma=class{constructor(t={}){this._options=t;}getWelcomeWizardStatus(t){return h.fromPromise(this.__getWelcomeWizardStatus(t))}async __getWelcomeWizardStatus(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/private/welcome-wizard"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:mm.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/welcome-wizard.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}submitWelcomeWizard(t={},e){return h.fromPromise(this.__submitWelcomeWizard(t,e))}async __submitWelcomeWizard(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/welcome-wizard"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ho.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/welcome-wizard.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var da=class{constructor(t={}){this._options=t;}costsSummary(t,e){return h.fromPromise(this.__costsSummary(t,e))}async __costsSummary(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/workspaces/costs/summaries"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:rr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:We.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/workspaces/costs/summaries.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getWorkspaceConfiguration(t){return h.fromPromise(this.__getWorkspaceConfiguration(t))}async __getWorkspaceConfiguration(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/private/workspaces/configurations"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:nt.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")switch(e.error.statusCode){case 404:throw new T(e.error.body,e.rawResponse);default:throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse})}switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/workspaces/configurations.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}upsertWorkspaceConfiguration(t,e){return h.fromPromise(this.__upsertWorkspaceConfiguration(t,e))}async __upsertWorkspaceConfiguration(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/workspaces/configurations"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:nt.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:nt.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);case 422:throw new W(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/workspaces/configurations.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteWorkspaceConfiguration(t){return h.fromPromise(this.__deleteWorkspaceConfiguration(t))}async __deleteWorkspaceConfiguration(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"v1/private/workspaces/configurations"),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:void 0,rawResponse:e.rawResponse};if(e.error.reason==="status-code")switch(e.error.statusCode){case 404:throw new T(e.error.body,e.rawResponse);default:throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse})}switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/workspaces/configurations.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getCost(t,e){return h.fromPromise(this.__getCost(t,e))}async __getCost(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/workspaces/costs"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:rr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Vi.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/workspaces/costs.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getMetric(t,e){return h.fromPromise(this.__getMetric(t,e))}async __getMetric(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/workspaces/metrics"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:rr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Vi.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/workspaces/metrics.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}metricsSummary(t,e){return h.fromPromise(this.__metricsSummary(t,e))}async __metricsSummary(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:f.Default,"v1/private/workspaces/metrics/summaries"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:rr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:dm.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/workspaces/metrics/summaries.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ua=class{constructor(t={}){this._options=t;}datasetsRedirect(t,e){return h.fromPromise(this.__datasetsRedirect(t,e))}async __datasetsRedirect(t,e){var u,g;let{datasetId:o,workspaceName:i,path:a}=t,c={};c.dataset_id=o,i!=null&&(c.workspace_name=i),c.path=a;let m=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:f.Default,"v1/session/redirect/datasets"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:c,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(m.ok)return {data:void 0,rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 400:throw new A(m.error.body,m.rawResponse);case 404:throw new T(m.error.body,m.rawResponse);default:throw new p({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}switch(m.error.reason){case "non-json":throw new p({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/session/redirect/datasets.");case "unknown":throw new p({message:m.error.errorMessage,rawResponse:m.rawResponse})}}experimentsRedirect(t,e){return h.fromPromise(this.__experimentsRedirect(t,e))}async __experimentsRedirect(t,e){var g,y;let{datasetId:o,experimentId:i,workspaceName:a,path:c}=t,m={};m.dataset_id=o,m.experiment_id=i,a!=null&&(m.workspace_name=a),m.path=c;let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:f.Default,"v1/session/redirect/experiments"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:m,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:void 0,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new A(u.error.body,u.rawResponse);case 404:throw new T(u.error.body,u.rawResponse);default:throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/session/redirect/experiments.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}optimizationsRedirect(t,e){return h.fromPromise(this.__optimizationsRedirect(t,e))}async __optimizationsRedirect(t,e){var g,y;let{datasetId:o,optimizationId:i,workspaceName:a,path:c}=t,m={};m.dataset_id=o,m.optimization_id=i,a!=null&&(m.workspace_name=a),m.path=c;let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:f.Default,"v1/session/redirect/optimizations"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:m,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:void 0,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new A(u.error.body,u.rawResponse);case 404:throw new T(u.error.body,u.rawResponse);default:throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/session/redirect/optimizations.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}projectsRedirect(t,e){return h.fromPromise(this.__projectsRedirect(t,e))}async __projectsRedirect(t,e){var u,g;let{traceId:o,workspaceName:i,path:a}=t,c={};c.trace_id=o,i!=null&&(c.workspace_name=i),c.path=a;let m=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:f.Default,"v1/session/redirect/projects"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:c,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(m.ok)return {data:void 0,rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 400:throw new A(m.error.body,m.rawResponse);case 404:throw new T(m.error.body,m.rawResponse);default:throw new p({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}switch(m.error.reason){case "non-json":throw new p({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/session/redirect/projects.");case "unknown":throw new p({message:m.error.errorMessage,rawResponse:m.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var st=class{constructor(t={}){this._options=t;}get systemUsage(){var t;return (t=this._systemUsage)!=null?t:this._systemUsage=new Hi(this._options)}get alerts(){var t;return (t=this._alerts)!=null?t:this._alerts=new Ji(this._options)}get annotationQueues(){var t;return (t=this._annotationQueues)!=null?t:this._annotationQueues=new Ki(this._options)}get attachments(){var t;return (t=this._attachments)!=null?t:this._attachments=new Xi(this._options)}get check(){var t;return (t=this._check)!=null?t:this._check=new Gi(this._options)}get automationRuleEvaluators(){var t;return (t=this._automationRuleEvaluators)!=null?t:this._automationRuleEvaluators=new $i(this._options)}get chatCompletions(){var t;return (t=this._chatCompletions)!=null?t:this._chatCompletions=new Qi(this._options)}get dashboards(){var t;return (t=this._dashboards)!=null?t:this._dashboards=new Yi(this._options)}get datasets(){var t;return (t=this._datasets)!=null?t:this._datasets=new Zi(this._options)}get experiments(){var t;return (t=this._experiments)!=null?t:this._experiments=new qi(this._options)}get feedbackDefinitions(){var t;return (t=this._feedbackDefinitions)!=null?t:this._feedbackDefinitions=new ea(this._options)}get guardrails(){var t;return (t=this._guardrails)!=null?t:this._guardrails=new ra(this._options)}get llmProviderKey(){var t;return (t=this._llmProviderKey)!=null?t:this._llmProviderKey=new oa(this._options)}get manualEvaluation(){var t;return (t=this._manualEvaluation)!=null?t:this._manualEvaluation=new ta(this._options)}get openTelemetryIngestion(){var t;return (t=this._openTelemetryIngestion)!=null?t:this._openTelemetryIngestion=new ia(this._options)}get optimizations(){var t;return (t=this._optimizations)!=null?t:this._optimizations=new aa(this._options)}get projects(){var t;return (t=this._projects)!=null?t:this._projects=new na(this._options)}get prompts(){var t;return (t=this._prompts)!=null?t:this._prompts=new sa(this._options)}get serviceToggles(){var t;return (t=this._serviceToggles)!=null?t:this._serviceToggles=new pa(this._options)}get spans(){var t;return (t=this._spans)!=null?t:this._spans=new ca(this._options)}get traces(){var t;return (t=this._traces)!=null?t:this._traces=new la(this._options)}get welcomeWizard(){var t;return (t=this._welcomeWizard)!=null?t:this._welcomeWizard=new ma(this._options)}get workspaces(){var t;return (t=this._workspaces)!=null?t:this._workspaces=new da(this._options)}get redirect(){var t;return (t=this._redirect)!=null?t:this._redirect=new ua(this._options)}isAlive(t){return h.fromPromise(this.__isAlive(t))}async __isAlive(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"is-alive/ping"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:e.body,rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /is-alive/ping.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}version(t){return h.fromPromise(this.__version(t))}async __version(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:f.Default,"is-alive/ver"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":d.type,"X-Fern-Runtime-Version":d.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(e.ok)return {data:e.body,rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /is-alive/ver.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Z=()=>uuid.v7();var ga=class n{constructor(t,e){this.data=t;this.opik=e;this.childSpans=[];this.end=()=>this.update({endTime:new Date});this.score=t=>{var e;this.opik.spanFeedbackScoresBatchQueue.create({...t,projectName:(e=this.data.projectName)!=null?e:this.opik.config.projectName,id:this.data.id,source:"sdk"});};this.update=t=>{var o;let e={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,e),this.data={...this.data,...t},this};this.span=t=>{var a;let e=(a=this.data.projectName)!=null?a:this.opik.config.projectName,o={id:Z(),startTime:new Date,...t,projectName:e,traceId:this.data.traceId,parentSpanId:this.data.id};this.opik.spanBatchQueue.create(o);let i=new n(o,this.opik);return this.childSpans.push(i),i};}};var wa=class{constructor(t,e){this.data=t;this.opik=e;this.spans=[];this.end=()=>this.update({endTime:new Date});this.score=t=>{var e;this.opik.traceFeedbackScoresBatchQueue.create({...t,projectName:(e=this.data.projectName)!=null?e:this.opik.config.projectName,id:this.data.id,source:"sdk"});};this.span=t=>{var a,c;let e=(c=(a=this.data.projectName)!=null?a:t.projectName)!=null?c:this.opik.config.projectName,o={id:Z(),startTime:new Date,...t,projectName:e,traceId:this.data.id};this.opik.spanBatchQueue.create(o);let i=new ga(o,this.opik);return this.spans.push(i),i};this.update=t=>{var o;let e={projectName:(o=this.data.projectName)!=null?o:this.opik.config.projectName,...t};return this.opik.traceBatchQueue.update(this.data.id,e),this.data={...this.data,...e},this};}};var qd={EXPERIMENTS:"api/v1/session/redirect/experiments/",PROJECT_BY_NAME:"redirect/projects"},ha={EXPERIMENT_ID:"experiment_id",DATASET_ID:"dataset_id",PROJECT_NAME:"name",PATH:"path"},Eh=n=>Object.entries(n).map(([t,e])=>`${t}=${encodeURIComponent(e)}`).join("&").replace(/%3A/g,":").replace(/%2F/g,"/").replace(/%26/g,"&").replace(/%3F/g,"?").replace(/%3D/g,"="),Ph=n=>n.replace(/\/api$/,""),vh=n=>Buffer.from(n).toString("base64"),eu=(n,t,e)=>{let o=Eh(e),i=`${t}?${o}`;return new URL(i,n).toString()},ru=({datasetId:n,experimentId:t,baseUrl:e})=>eu(e,qd.EXPERIMENTS,{[ha.EXPERIMENT_ID]:t,[ha.DATASET_ID]:n,[ha.PATH]:vh(e)});var ou=({projectName:n,workspaceName:t,apiUrl:e})=>{let o=Ph(e),i=`${t}/${qd.PROJECT_BY_NAME}`;return eu(o,i,{[ha.PROJECT_NAME]:n})};var Ch=300,fa=100,pt=class{constructor({action:t,batchSize:e=fa,delay:o,enableBatch:i,name:a="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,e)=>{if(this.queue.set(t,e),!this.enableBatch){this.flush();return}if(this.queue.size>=this.batchSize){this.flush();return}this.debounceFlush();};this.update=(t,e)=>{let o=this.queue.get(t);o&&(this.queue.set(t,{...o,...e}),this.debounceFlush());};this.flush=async()=>{if(this.queue.size===0)return this.promise;let t=new Map(this.queue);this.queue.clear(),z.debug(`Adding ${t.size} items to ${this.name} promise:`,t),this.promise=this.promise.finally(()=>(z.debug(`Flushing ${this.name}:`,t),this.action(t))).catch(e=>{z.error(`Failed to flush ${this.name}:`,e,t);}),await this.promise;};this.action=t,this.batchSize=e,this.delay=o,this.enableBatch=i,this.name=a;}},se=class{constructor({delay:t=Ch,enableCreateBatch:e=true,enableUpdateBatch:o=false,enableDeleteBatch:i=true,createBatchSize:a=fa,updateBatchSize:c=fa,deleteBatchSize:m=fa,name:u="BatchQueue"}={}){this.create=t=>{let e=this.getId(t);this.createQueue.add(e,t);};this.get=async t=>{let e=this.createQueue.queue.get(t);return e||this.getEntity(t)};this.update=(t,e)=>{if(this.createQueue.queue.get(t)){this.createQueue.update(t,e);return}this.updateQueue.add(t,e);};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=u,this.createQueue=new pt({action:async g=>{await this.createEntities(Array.from(g.values()));},delay:t,enableBatch:e,batchSize:a,name:`${u}:createQueue`}),this.updateQueue=new pt({action:async g=>{await this.createQueue.flush();let y=Array.from(g.entries());for(let[k,S]of y)await this.updateEntity(k,S);},delay:t,enableBatch:o,batchSize:c,name:`${u}:updateQueue`}),this.deleteQueue=new pt({action:async g=>{await this.createQueue.flush(),await this.updateQueue.flush(),await this.deleteEntities(Array.from(g.keys()));},delay:t,enableBatch:i,batchSize:m,name:`${u}:deleteQueue`});}};var Ra=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"SpanBatchQueue"});this.api=e;}getId(e){return e.id}async createEntities(e){await this.api.spans.createSpans({spans:e},this.api.requestOptions);}async getEntity(e){return await this.api.spans.getSpanById(e,{},this.api.requestOptions)}async updateEntity(e,o){await this.api.spans.updateSpan(e,o,this.api.requestOptions);}async deleteEntities(e){for(let o of e)await this.api.spans.deleteSpanById(o,this.api.requestOptions);}};var ba=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"SpanFeedbackScoresBatchQueue"});this.api=e;}getId(e){return {id:e.id,name:e.name}}async createEntities(e){await this.api.spans.scoreBatchOfSpans({scores:e},this.api.requestOptions);}async getEntity(){throw new Error("Not implemented")}async updateEntity(){throw new Error("Not implemented")}async deleteEntities(e){for(let o of e)await this.api.spans.deleteSpanFeedbackScore(o.id,{name:o.name},this.api.requestOptions);}};var ya=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"TraceBatchQueue"});this.api=e;}getId(e){return e.id}async createEntities(e){await this.api.traces.createTraces({traces:e},this.api.requestOptions);}async getEntity(e){return await this.api.traces.getTraceById(e,{},this.api.requestOptions)}async updateEntity(e,o){await this.api.traces.updateTrace(e,o,this.api.requestOptions);}async deleteEntities(e){await this.api.traces.deleteTraces({ids:e},this.api.requestOptions);}};var ka=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"TraceFeedbackScoresBatchQueue"});this.api=e;}getId(e){return {id:e.id,name:e.name}}async createEntities(e){await this.api.traces.scoreBatchOfTraces({scores:e},this.api.requestOptions);}async getEntity(){throw new Error("Not implemented")}async updateEntity(){throw new Error("Not implemented")}async deleteEntities(e){for(let o of e)await this.api.traces.deleteTraceFeedbackScore(o.id,{name:o.name},this.api.requestOptions);}};var za=class extends st{constructor(e){super(e);this.setHeaders=e=>{this.requestOptions.headers=e;};this.requestOptions=(e==null?void 0:e.requestOptions)||{};}};var Sa=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"DatasetBatchQueue"});this.api=e;}getId(e){return e.id||""}async createEntities(e){for(let o of e)await this.api.datasets.createDataset(o,this.api.requestOptions);}async getEntity(e){try{return await this.api.datasets.getDatasetById(e,this.api.requestOptions)}catch{return}}async updateEntity(e,o){await this.api.datasets.updateDataset(e,{name:o.name||"",visibility:o.visibility,description:o.description},this.api.requestOptions);}async deleteEntities(e){await this.api.datasets.deleteDatasetsBatch({ids:e},this.api.requestOptions);}};var um=null;async function tu(){return um||(um=await Ih__default.default()),um}var ct=class n{constructor(t){let{id:e,traceId:o,spanId:i,source:a,...c}=t;this.id=e||Z(),this.traceId=o,this.spanId=i,this.source=a||dn.Sdk,this.data={...c};}getContent(t=false){return t?{...this.data,id:this.id}:{...this.data}}async contentHash(){let t=this.getContent(),e=jh__default.default(t);return (await tu()).h32(e,43981).toString(16)}toApiModel(){return {id:this.id,traceId:this.traceId,spanId:this.spanId,source:this.source,data:this.getContent()}}static fromApiModel(t){return new n({id:t.id,traceId:t.traceId,spanId:t.spanId,source:t.source,...t.data})}};async function Te(n,t,e){var c;if(e===0)return [];let o=new util.TextDecoder("utf-8"),i=[],a="";try{for await(let m of n){a+=o.decode(m,{stream:!0});let u=a.split(`
4
+ `);a=(c=u.pop())!=null?c:"";for(let g of u)if(!(!g.trim()||g==="{}"||g==="[]"||g==="null"))try{let y=JSON.parse(g),k=t.parse(y);if(k.ok){if(i.push(k.value),e!==void 0&&i.length>=e)return i}else z.error("Error parsing experiment item:",k.errors);}catch(y){z.error("Error parsing JSON line:",y instanceof Error?y.message:String(y));}}if(a.trim()&&a!=="{}"&&a!=="[]"&&a!=="null")try{let m=JSON.parse(a),u=t.parse(m);u.ok?i.push(u.value):z.error("Error parsing experiment item:",u.errors);}catch(m){z.error("Error parsing remaining buffer:",m instanceof Error?m.message:String(m));}}catch(m){z.error("Error processing stream:",m instanceof Error?m.message:String(m));}return i}function lt(n,t){let e=[];for(let o=0;o<n.length;o+=t.maxBatchSize)e.push(n.slice(o,o+t.maxBatchSize));return e}var ne=class extends Error{constructor(t){var e;super(t.message),this.name=this.constructor.name,this.code=t.code,this.statusCode=t.statusCode,this.details=t.details,this.originalError=t.originalError,z.error(this.message),(e=Error.captureStackTrace)==null||e.call(Error,this,this.constructor);}toJSON(){return {name:this.name,message:this.message,code:this.code,statusCode:this.statusCode,details:this.details,originalError:this.originalError,stack:this.stack}}};var iu={DATASET_NOT_FOUND:n=>`Dataset with name '${n}' not found`,DATASET_ITEM_NOT_FOUND:n=>`Dataset item with id '${n}' not found`,DATASET_ITEM_MISSING_ID:n=>`Item at index ${n} is missing an ID required for update`,INVALID_JSON_FORMAT:n=>`Invalid JSON format${n?": "+n:""}`,JSON_NOT_ARRAY:"JSON input must be an array of objects",ITEM_NOT_OBJECT:(n,t)=>`Item at position ${n} is not an object (${t})`,INSERTION_FAILED:n=>`Failed to insert items from JSON: ${n}`,DATASET_JSON_PARSE_ERROR:n=>`Failed to parse JSON input: ${n}`};var Nh={DATASET_ITEM_MISSING_ID:"DATASET_ITEM_MISSING_ID"},xa=class extends ne{constructor(t){super({message:iu.DATASET_ITEM_MISSING_ID(t),code:Nh.DATASET_ITEM_MISSING_ID});}};var Mh={SEARCH_TIMEOUT:"SEARCH_TIMEOUT"},_a=class extends ne{constructor(t){super({message:t,code:Mh.SEARCH_TIMEOUT});}};var Ta={JSON_NOT_ARRAY:n=>`JSON input must be an array of objects${n?` (${n})`:""}`,JSON_PARSE_ERROR:"Failed to parse JSON input",JSON_ITEM_NOT_OBJECT:(n,t)=>`Item at position ${n} is not an object (${t})`};var gm={JSON_PARSE_ERROR:"JSON_PARSE_ERROR",JSON_NOT_ARRAY:"JSON_NOT_ARRAY",JSON_ITEM_NOT_OBJECT:"JSON_ITEM_NOT_OBJECT"},Aa=class extends ne{constructor(t){let e=t instanceof Error?t:new Error(String(t));super({message:Ta.JSON_PARSE_ERROR,code:gm.JSON_PARSE_ERROR,originalError:e});}},Ea=class extends ne{constructor(t){super({message:Ta.JSON_NOT_ARRAY(t),code:gm.JSON_NOT_ARRAY});}},Pa=class extends ne{constructor(t,e){super({message:Ta.JSON_ITEM_NOT_OBJECT(t,e),code:gm.JSON_ITEM_NOT_OBJECT});}};var or=class{constructor({name:t,description:e,id:o},i){this.opik=i;this.idToHash=new Map;this.hashes=new Set;this.id=o||Z(),this.name=t,this.description=e;}async insert(t){if(!t||t.length===0)return;await this.opik.datasetBatchQueue.flush(),await this.syncHashes();let e=await this.getDeduplicatedItems(t),o=lt(e,{maxBatchSize:1e3});try{let i=0;for(let a of o)await this.opik.api.datasets.createOrUpdateDatasetItems({datasetId:this.id,items:a}),i+=a.length,z.info(`Inserted ${Math.min(i,e.length)} of ${e.length} items into dataset ${this.id}`);}catch(i){throw z.error(`Error inserting items into dataset: ${i instanceof Error?i.message:String(i)}`),i}}async update(t){if(!(!t||t.length===0)){for(let e=0;e<t.length;e++)if(!t[e].id)throw new xa(e);await this.insert(t);}}async delete(t){if(!t||t.length===0){z.info("No item IDs provided for deletion");return}let e=lt(t,{maxBatchSize:100});for await(let o of e){z.debug("Deleting dataset items batch",{batchSize:o.length,datasetId:this.id}),await this.opik.api.datasets.deleteDatasetItems({itemIds:o});for(let i of o)if(this.idToHash.has(i)){let a=this.idToHash.get(i);this.hashes.delete(a),this.idToHash.delete(i);}}}async clear(){let e=(await this.getItems()).map(o=>o.id).filter(Boolean);e.length!==0&&await this.delete(e);}async getItems(t,e){return (await this.getItemsAsDataclasses(t,e)).map(i=>i.getContent(true))}async getItemsAsDataclasses(t,e){let o=t?Math.min(t,2e3):2e3,i=await this.opik.api.datasets.streamDatasetItems({datasetName:this.name,lastRetrievedId:e,steamLimit:o});return (await Te(i,v.DatasetItemPublic,t)).map(c=>ct.fromApiModel(c))}async insertFromJson(t,e={},o=[]){let i;try{i=JSON.parse(t);}catch(c){throw new Aa(c)}if(!Array.isArray(i))throw new Ea(typeof i);if(i.length===0)return;for(let c=0;c<i.length;c++){let m=i[c];if(typeof m!="object"||m===null)throw new Pa(c,typeof m)}let a=i.map(c=>{let m=c,u={};for(let[g,y]of Object.entries(m)){if(o.includes(g))continue;let k=e[g]||g;u[k]=y;}return u});await this.insert(a);}async toJson(t={}){let o=(await this.getItems()).map(i=>{let a={...i};if(Object.keys(t).length>0){for(let[c,m]of Object.entries(t))if(c in a){let u=a[c];delete a[c],a[m]=u;}}return a});return jh__default.default(o)}async getDeduplicatedItems(t){let e=[];for(let o of t){let i=new ct(o),a=await i.contentHash();if(this.hashes.has(a)){z.debug("Duplicate item found - skipping",{contentHash:a,datasetId:this.id});continue}e.push(i.toApiModel()),this.hashes.add(a),this.idToHash.set(i.id,a);}return e}clearHashState(){this.idToHash.clear(),this.hashes.clear();}async syncHashes(){z.debug("Syncing dataset hashes with backend",{datasetId:this.id});try{let t=await this.getItemsAsDataclasses();this.clearHashState();for(let e of t){let o=await e.contentHash();this.idToHash.set(e.id,o),this.hashes.add(o);}z.debug("Dataset hash sync completed",{datasetId:this.id,itemCount:t.length});}catch(t){if(t instanceof p&&t.statusCode===404){z.debug("Dataset not found - starting with empty hash state",{datasetId:this.id}),this.clearHashState();return}throw t}}};var wm=class extends Error{constructor(t){super(t),this.name="DatasetError";}},mt=class extends wm{constructor(t){super(`Dataset with name '${t}' not found`),this.name="DatasetNotFoundError";}};var va=class{constructor(t){if(!t.datasetItemId)throw new Error("datasetItemId is required");if(!t.traceId)throw new Error("traceId is required");this.datasetItemId=t.datasetItemId,this.traceId=t.traceId;}},Ca=class n{constructor(t){this.id=t.id,this.datasetItemId=t.datasetItemId,this.traceId=t.traceId,this.datasetItemData=t.datasetItemData,this.evaluationTaskOutput=t.evaluationTaskOutput,this.feedbackScores=[...t.feedbackScores];}static fromRestExperimentItemCompare(t){var o,i;let e=(i=(o=t.feedbackScores)==null?void 0:o.map(a=>({categoryName:a.categoryName,name:a.name,reason:a.reason,value:a.value,source:a.source})))!=null?i:[];return new n({id:t.id,traceId:t.traceId,datasetItemId:t.datasetItemId,datasetItemData:t.input,evaluationTaskOutput:t.output,feedbackScores:e})}};var Be=class{constructor({id:t,name:e,datasetName:o,prompts:i},a){this.opik=a;this.id=t||Z(),this._name=e,this.datasetName=o,this.prompts=i;}get name(){return this._name}async ensureNameLoaded(){if(this._name!==void 0)return this._name;let t=await this.opik.api.experiments.getExperimentById(this.id);if(this._name=t.name,!this._name)throw new Error("Experiment name is not loaded");return this._name}async insert(t){if(t.length===0)return;let e=t.map(i=>({id:Z(),experimentId:this.id,datasetItemId:i.datasetItemId,traceId:i.traceId})),o=lt(e,{maxBatchSize:50});try{for(let i of o)await this.opik.api.experiments.createExperimentItems({experimentItems:i});z.debug(`Inserted ${t.length} items into experiment ${this.id}`);}catch(i){throw z.error(`Error inserting items into experiment: ${i instanceof Error?i.message:String(i)}`),i}}async getItems(t){let e=[],{maxResults:i,truncate:a=false}=t||{},c,m=true;try{for(;m&&!(i!==void 0&&e.length>=i);){let u=i?Math.min(i-e.length,2e3):2e3,g=await this.opik.api.experiments.streamExperimentItems({experimentName:this.name,limit:u,lastRetrievedId:c,truncate:a});try{let y=await Te(g,v.ExperimentItemCompare,u);if(y.length===0){m=!1;break}for(let k of y){let S=Ca.fromRestExperimentItemCompare(k);if(e.push(S),i!==void 0&&e.length>=i){m=!1;break}}c=y[y.length-1].id;}catch(y){z.error("Error parsing experiment item: "+(y instanceof Error?y.message:String(y))),m=!1;break}}}catch(u){throw z.error("Error retrieving experiment items: "+(u instanceof Error?u.message:String(u))),u}return z.info(`Retrieved ${e.length} items${i?` (limited by maxResults=${i})`:""}`),e}async getUrl(){let t=await this.opik.getDataset(this.datasetName),e=this.opik.config.apiUrl||Qa.apiUrl;return ru({datasetId:t.id,experimentId:this.id,baseUrl:e})}};var Ia={EXPERIMENT_NOT_FOUND:n=>`Experiment with name '${n}' not found`,INVALID_CONFIG_TYPE:n=>`experimentConfig must be a plain object, but ${n} was provided. Please provide a valid configuration object like { model: 'gpt-4', temperature: 0.7 }`,CONFIG_PROMPTS_CONFLICT:()=>`Cannot specify both 'prompts' parameter and 'experimentConfig.prompts'. Choose one approach:
5
5
  1. Use prompts parameter: buildMetadataAndPromptVersions(config, [prompt1, prompt2])
6
6
  2. Use config only: buildMetadataAndPromptVersions({ ...config, prompts: {...} })
7
7
 
8
- The prompts parameter is recommended for prompt version tracking.`};var cm={EXPERIMENT_NOT_FOUND:"EXPERIMENT_NOT_FOUND",INVALID_CONFIG_TYPE:"INVALID_CONFIG_TYPE",CONFIG_PROMPTS_CONFLICT:"CONFIG_PROMPTS_CONFLICT"},st=class extends ne{constructor(t){super({message:_a.EXPERIMENT_NOT_FOUND(t),code:cm.EXPERIMENT_NOT_FOUND});}},pt=class n extends ne{constructor(t,e){super({message:t,code:e});}static invalidConfigType(t){return new n(_a.INVALID_CONFIG_TYPE(t),cm.INVALID_CONFIG_TYPE)}static promptsConflict(){return new n(_a.CONFIG_PROMPTS_CONFLICT(),cm.CONFIG_PROMPTS_CONFLICT)}};function Zd(n,t){if(n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)))throw pt.invalidConfigType(typeof n);if(t&&t.length>0&&(n!=null&&n.prompts))throw pt.promptsConflict();if(!n&&(!t||t.length===0))return [void 0,void 0];let e=n?structuredClone(n):{},o;if(t&&t.length>0){o=[];let i={};for(let a of t)o.push({id:a.versionId}),i[a.name]=a.prompt;e.prompts=i;}return Object.keys(e).length===0?[void 0,void 0]:[e,o]}var de={MUSTACHE:"mustache",JINJA2:"jinja2"};var H=class n extends Error{constructor(t){super(t),this.name="PromptValidationError",Object.setPrototypeOf(this,n.prototype);}};function jf(n){try{let e=If__default.default.parse(n).filter(o=>{let i=o[0];return i==="name"||i==="#"||i==="&"||i==="^"}).map(o=>o[1].split(".")[0]);return new Set(e)}catch(t){throw new H(`Invalid Mustache template syntax: ${t instanceof Error?t.message:String(t)}`)}}function qd(n,t,e){if(e!=="mustache")return;let o=jf(n),i=new Set(Object.keys(t)),a=new Set([...o].filter(c=>!i.has(c)));if(a.size>0){let c=[];throw c.push(`Missing required variables: ${[...a].join(", ")}`),c.push(`Template placeholders: {${[...o].join(", ")}}`),c.push(`Provided variables: {${[...i].join(", ")}}`),new H(`Template variables validation failed:
8
+ The prompts parameter is recommended for prompt version tracking.`};var hm={EXPERIMENT_NOT_FOUND:"EXPERIMENT_NOT_FOUND",INVALID_CONFIG_TYPE:"INVALID_CONFIG_TYPE",CONFIG_PROMPTS_CONFLICT:"CONFIG_PROMPTS_CONFLICT"},dt=class extends ne{constructor(t){super({message:Ia.EXPERIMENT_NOT_FOUND(t),code:hm.EXPERIMENT_NOT_FOUND});}},ut=class n extends ne{constructor(t,e){super({message:t,code:e});}static invalidConfigType(t){return new n(Ia.INVALID_CONFIG_TYPE(t),hm.INVALID_CONFIG_TYPE)}static promptsConflict(){return new n(Ia.CONFIG_PROMPTS_CONFLICT(),hm.CONFIG_PROMPTS_CONFLICT)}};function au(n,t){if(n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)))throw ut.invalidConfigType(typeof n);if(t&&t.length>0&&(n!=null&&n.prompts))throw ut.promptsConflict();if(!n&&(!t||t.length===0))return [void 0,void 0];let e=n?structuredClone(n):{},o;if(t&&t.length>0){o=[];let i={};for(let a of t)o.push({id:a.versionId}),i[a.name]=a.prompt;e.prompts=i;}return Object.keys(e).length===0?[void 0,void 0]:[e,o]}var de={MUSTACHE:"mustache",JINJA2:"jinja2"};var H=class n extends Error{constructor(t){super(t),this.name="PromptValidationError",Object.setPrototypeOf(this,n.prototype);}};function Oh(n){try{let e=Fh__default.default.parse(n).filter(o=>{let i=o[0];return i==="name"||i==="#"||i==="&"||i==="^"}).map(o=>o[1].split(".")[0]);return new Set(e)}catch(t){throw new H(`Invalid Mustache template syntax: ${t instanceof Error?t.message:String(t)}`)}}function nu(n,t,e){if(e!=="mustache")return;let o=Oh(n),i=new Set(Object.keys(t)),a=new Set([...o].filter(c=>!i.has(c)));if(a.size>0){let c=[];throw c.push(`Missing required variables: ${[...a].join(", ")}`),c.push(`Template placeholders: {${[...o].join(", ")}}`),c.push(`Provided variables: {${[...i].join(", ")}}`),new H(`Template variables validation failed:
9
9
  ${c.join(`
10
- `)}`)}}function he(n,t,e){try{switch(qd(n,t,e),e){case "mustache":return If__default.default.render(n,t,{},{escape:o=>o});case "jinja2":return Nf__default.default.renderString(n,t);default:return n}}catch(o){if(o instanceof H)throw o;let i=o instanceof Error?o.message:String(o);throw new H(`Failed to format prompt template: ${i}`)}}var ct=class n{constructor(t){this.id=t.versionId,this.name=t.name,this.prompt=t.prompt,this.commit=t.commit,this.type=t.type,this.metadata=t.metadata,this.changeDescription=t.changeDescription,this.createdAt=t.createdAt,this.createdBy=t.createdBy;}format(t){return he(this.prompt,t,this.type)}getVersionAge(){return this.createdAt?dateFns.formatDistanceToNow(new Date(this.createdAt),{addSuffix:true}):"Unknown"}getVersionInfo(){let t=[`[${this.commit}]`];if(this.createdAt){let e=new Date(this.createdAt);t.push(e.toISOString().split("T")[0]);}return this.createdBy&&t.push(`by ${this.createdBy}`),this.changeDescription&&t.push(`- ${this.changeDescription}`),t.join(" ")}compareTo(t){let e=`Current version [${this.commit}]`,o=`Other version [${t.commit}]`,i=jestDiff.diffStringsUnified(t.prompt,this.prompt,{aAnnotation:o,bAnnotation:e,includeChangeCounts:true,contextLines:3,expand:false});return z.info(`
10
+ `)}`)}}function fe(n,t,e){try{switch(nu(n,t,e),e){case "mustache":return Fh__default.default.render(n,t,{},{escape:o=>o});case "jinja2":return Bh__default.default.renderString(n,t);default:return n}}catch(o){if(o instanceof H)throw o;let i=o instanceof Error?o.message:String(o);throw new H(`Failed to format prompt template: ${i}`)}}var gt=class n{constructor(t){this.id=t.versionId,this.name=t.name,this.prompt=t.prompt,this.commit=t.commit,this.type=t.type,this.metadata=t.metadata,this.changeDescription=t.changeDescription,this.createdAt=t.createdAt,this.createdBy=t.createdBy;}format(t){return fe(this.prompt,t,this.type)}getVersionAge(){return this.createdAt?dateFns.formatDistanceToNow(new Date(this.createdAt),{addSuffix:true}):"Unknown"}getVersionInfo(){let t=[`[${this.commit}]`];if(this.createdAt){let e=new Date(this.createdAt);t.push(e.toISOString().split("T")[0]);}return this.createdBy&&t.push(`by ${this.createdBy}`),this.changeDescription&&t.push(`- ${this.changeDescription}`),t.join(" ")}compareTo(t){let e=`Current version [${this.commit}]`,o=`Other version [${t.commit}]`,i=jestDiff.diffStringsUnified(t.prompt,this.prompt,{aAnnotation:o,bAnnotation:e,includeChangeCounts:true,contextLines:3,expand:false});return z.info(`
11
11
  Prompt version comparison:
12
- ${i}`),i}static fromApiResponse(t,e){var o;if(!e.template)throw new H("Invalid API response: missing required field 'template'");if(!e.commit)throw new H("Invalid API response: missing required field 'commit'");if(!e.promptId)throw new H("Invalid API response: missing required field 'promptId'");if(!e.id)throw new H("Invalid API response: missing required field 'id'");return new n({name:t,prompt:e.template,commit:e.commit,promptId:e.promptId,versionId:e.id,type:(o=e.type)!=null?o:de.MUSTACHE,metadata:e.metadata,changeDescription:e.changeDescription,createdAt:e.createdAt?new Date(e.createdAt):void 0,createdBy:e.createdBy})}};var Te=class n{constructor({promptId:t,versionId:e,name:o,prompt:i,commit:a,metadata:c,type:d,changeDescription:u,description:g,tags:y=[]},k){this.opik=k;this.id=t,this.versionId=e,this.prompt=i,this.commit=a,this.type=d!=null?d:de.MUSTACHE,this.changeDescription=u,this._name=o,this._description=g,this._tags=[...y],this._metadata=c;}get name(){return this._name}get description(){return this._description}get tags(){return Object.freeze([...this._tags])}get metadata(){if(this._metadata)return structuredClone(this._metadata)}format(t){return he(this.prompt,t,this.type)}static fromApiResponse(t,e,o){var a;if(!e.template)throw new H("Invalid API response: missing required field 'template'");if(!e.commit)throw new H("Invalid API response: missing required field 'commit'");if(!e.promptId)throw new H("Invalid API response: missing required field 'promptId'");if(!e.id)throw new H("Invalid API response: missing required field 'id' (version ID)");let i=(a=e.type)!=null?a:de.MUSTACHE;if(i!=="mustache"&&i!=="jinja2")throw new H(`Invalid API response: unknown prompt type '${i}'`);return new n({promptId:e.promptId,versionId:e.id,name:t.name,prompt:e.template,commit:e.commit,metadata:e.metadata,type:i,changeDescription:e.changeDescription,description:t.description,tags:t.tags},o)}async updateProperties(t){var e,o,i,a;return await this.opik.api.prompts.updatePrompt(this.id,{name:(e=t.name)!=null?e:this._name,description:t.description,tags:t.tags},this.opik.api.requestOptions),this._name=(o=t.name)!=null?o:this._name,this._description=(i=t.description)!=null?i:this._description,this._tags=(a=t.tags)!=null?a:this._tags,this}async delete(){await this.opik.deletePrompts([this.id]);}async getVersions(){var t;z.debug("Getting versions for prompt",{promptId:this.id,name:this.name});try{let e=[],o=1,i=100;for(;;){let c=(t=(await this.opik.api.prompts.getPromptVersions(this.id,{page:o,size:i},this.opik.api.requestOptions)).content)!=null?t:[];if(e.push(...c),c.length<i)break;o++;}return z.debug("Successfully retrieved prompt versions",{promptId:this.id,name:this.name,totalVersions:e.length}),e.map(a=>ct.fromApiResponse(this.name,a))}catch(e){throw z.error("Failed to get prompt versions",{promptId:this.id,name:this.name,error:e}),e}}async useVersion(t){z.debug("Restoring prompt version",{promptId:this.id,name:this.name,versionId:t.id,versionCommit:t.commit});try{let e=await this.opik.api.prompts.restorePromptVersion(this.id,t.id,this.opik.api.requestOptions);return z.debug("Successfully restored prompt version",{promptId:this.id,name:this.name,restoredVersionId:e.id,restoredCommit:e.commit}),n.fromApiResponse({name:this.name,description:this.description,tags:this._tags},e,this.opik)}catch(e){throw z.error("Failed to restore prompt version",{promptId:this.id,name:this.name,versionId:t.id,versionCommit:t.commit,error:e}),e}}async getVersion(t){try{let e=await this.opik.api.prompts.retrievePromptVersion({name:this.name,commit:t},this.opik.api.requestOptions);return n.fromApiResponse({name:this.name,description:this.description,tags:this._tags},e,this.opik)}catch(e){if(e&&typeof e=="object"&&"statusCode"in e&&e.statusCode===404)return null;throw z.error("Failed to retrieve prompt version",{promptName:this.name,commit:t,error:e}),e}}};async function eu(n,t,e){try{return await n.retrievePromptVersion({name:t},e)}catch(o){if(Wf(o))return null;throw o}}function ru(n,t,e){return t?t.template!==n.prompt||!Of(t.metadata,n.metadata)||t.type!==e:true}function Of(n,t){let e=n!=null?n:{},o=t!=null?t:{};return Ff__default.default(e,o)}function Wf(n){return typeof n=="object"&&n!==null&&"statusCode"in n&&n.statusCode===404}var re=class{constructor(t){this.input=t;this.cursor=0;}getPosition(){return this.cursor}getRemainingInput(){return this.input.slice(this.cursor)}getFullInput(){return this.input}isAtEnd(){return this.cursor>=this.input.length}peekChar(){return this.input[this.cursor]}peekCharAt(t){return this.input[this.cursor+t]}consumeChar(){return this.input[this.cursor++]}advance(t=1){this.cursor+=t;}skipWhitespace(){for(;this.cursor<this.input.length&&/\s/.test(this.input[this.cursor]);)this.cursor++;}consumeWhile(t){let e=this.cursor;for(;this.cursor<this.input.length&&t(this.input[this.cursor]);)this.cursor++;return this.input.slice(e,this.cursor)}sliceFrom(t){return this.input.slice(t,this.cursor)}static isFieldChar(t){return /[a-zA-Z0-9_]/.test(t)}static isLetterChar(t){return /[a-zA-Z]/.test(t)}static isDigitChar(t){return /\d/.test(t)}static isWhitespaceChar(t){return /\s/.test(t)}static isQuoteChar(t){return t==='"'||t==="'"}};var V={STRING_OPS:["=","contains","not_contains","starts_with","ends_with","!=",">","<"],NUMERIC_OPS:["=","!=",">","<",">=","<="],DATETIME_OPS:["=",">","<",">=","<="],LIST_OPS:["contains"],DICT_OPS:["=","contains",">","<"],LIMITED_STRING_OPS:["=","contains","not_contains"]},Ae={id:"string",name:"string",status:"string",start_time:"date_time",end_time:"date_time",input:"string",output:"string",metadata:"dictionary",feedback_scores:"feedback_scores_number",tags:"list","usage.total_tokens":"number","usage.prompt_tokens":"number","usage.completion_tokens":"number",duration:"number",number_of_messages:"number",created_by:"string",thread_id:"string",total_estimated_cost:"number",type:"string",model:"string",provider:"string"},ou={id:V.STRING_OPS,name:V.STRING_OPS,status:V.LIMITED_STRING_OPS,start_time:V.DATETIME_OPS,end_time:V.DATETIME_OPS,input:V.LIMITED_STRING_OPS,output:V.LIMITED_STRING_OPS,metadata:V.DICT_OPS,feedback_scores:V.NUMERIC_OPS,tags:V.LIST_OPS,"usage.total_tokens":V.NUMERIC_OPS,"usage.prompt_tokens":V.NUMERIC_OPS,"usage.completion_tokens":V.NUMERIC_OPS,duration:V.NUMERIC_OPS,number_of_messages:V.NUMERIC_OPS,created_by:V.STRING_OPS,thread_id:V.STRING_OPS,total_estimated_cost:V.NUMERIC_OPS,type:V.STRING_OPS,model:V.STRING_OPS,provider:V.STRING_OPS},Ta={SPECIAL_FIELDS:["usage","metadata","feedback_scores"],USAGE_KEYS:["total_tokens","prompt_tokens","completion_tokens"]};function tu(n){let t=Ta.SPECIAL_FIELDS.includes(n),e=Object.keys(Ae).includes(n);if(!t&&!e){let o=Object.keys(Ae).join(", ");throw new Error(`Field ${n} is not supported, only the fields ${o} are supported.`)}}function iu(n,t){if(!Ta.SPECIAL_FIELDS.includes(n)){let e=Object.keys(Ae).join(", ");throw new Error(`Field ${n}.${t} is not supported, only the fields ${e} are supported.`)}if(n==="usage"&&!Ta.USAGE_KEYS.includes(t))throw new Error(`When querying usage, ${t} is not supported, only usage.total_tokens, usage.prompt_tokens and usage.completion_tokens are supported.`)}function lm(n,t){let e=ou[n];if(!(e!=null&&e.includes(t))){let o=(e==null?void 0:e.join(", "))||"none";throw new Error(`Operator ${t} is not supported for field ${n}, only the operators ${o} are supported.`)}}function au(n){let t=n.toLowerCase();if(t==="and")return true;throw t==="or"?new Error("Invalid filter string, OR is not currently supported"):new Error(`Invalid filter string, trailing characters ${n}`)}function Aa(n,t,e){if(!n)throw new Error(`Missing closing quote for: ${e}`)}var lt=class{static parse(t){t.skipWhitespace();let e=this.parseFieldName(t);return tu(e),t.peekChar()==="."?this.parseFieldWithKey(t,e):{type:"simple",field:e,columnType:Ae[e]}}static parseFieldName(t){return t.consumeWhile(e=>re.isFieldChar(e))}static parseFieldWithKey(t,e){t.advance();let o=this.parseKey(t);if(iu(e,o),e==="usage"){let i=`usage.${o}`;return {type:"simple",field:i,columnType:Ae[i]}}return {type:"nested",field:e,key:o,columnType:Ae[e]}}static parseKey(t){let e=t.peekChar();return re.isQuoteChar(e)?this.parseQuotedKey(t,e):this.parseUnquotedKey(t)}static parseUnquotedKey(t){return t.consumeWhile(e=>re.isFieldChar(e))}static parseQuotedKey(t,e){let o=t.getPosition();t.advance();let i="",a=false;for(;!t.isAtEnd();){let d=t.peekChar();if(d===e){if(t.peekCharAt(1)===e){i+=e,t.advance(2);continue}a=true,t.advance();break}i+=d,t.advance();}let c=t.getFullInput().slice(o);return Aa(a,o,c),i}};var mt=class{static parse(t,e){t.skipWhitespace();let o=t.peekChar(),i=this.tryParseSymbolicOperator(t,o);if(i)return lm(e,i),{operator:i};let a=this.parseWordOperator(t);return lm(e,a),{operator:a}}static tryParseSymbolicOperator(t,e){if(e==="=")return t.advance(),"=";if(e==="<"||e===">"){let o=e;return t.advance(),t.peekChar()==="="?(t.advance(),o+"="):o}return e==="!"&&t.peekCharAt(1)==="="?(t.advance(2),"!="):null}static parseWordOperator(t){return t.consumeWhile(e=>!re.isWhitespaceChar(e))}};var dt=class{static parse(t){t.skipWhitespace();let e=t.getPosition(),o=t.peekChar();if(o==='"')return this.parseQuotedString(t,e);if(re.isDigitChar(o)||o==="-")return this.parseNumber(t);let i=t.getRemainingInput();throw new Error(`Invalid value ${i.slice(0,20)}, expected a string in double quotes("value") or a number`)}static parseQuotedString(t,e){t.advance();let o=t.getPosition(),i=false;for(;!t.isAtEnd();){if(t.peekChar()==='"'){i=true;break}t.advance();}Aa(i,e,`value starting at position ${e}`);let a=t.sliceFrom(o);return t.advance(),{value:a}}static parseNumber(t){let e="";return t.peekChar()==="-"&&(e+=t.consumeChar()),e+=this.parseDigits(t),t.peekChar()==="."&&(e+=t.consumeChar(),e+=this.parseDigits(t)),{value:e}}static parseDigits(t){return t.consumeWhile(e=>re.isDigitChar(e))}};var Ee=class{constructor(t){let e=t||"";this.filterExpressions=e?this.parse(e):null,this.parsedFilters=this.filterExpressions?JSON.stringify(this.filterExpressions):null;}getFilterExpressions(){return this.filterExpressions}parse(t){let e=new re(t),o=[];for(;!e.isAtEnd();){let i=this.parseExpression(e);if(o.push(i),e.skipWhitespace(),!e.isAtEnd()&&!this.parseConnector(e))break}return o}parseExpression(t){let e=lt.parse(t),o=mt.parse(t,this.getFieldName(e)),i=dt.parse(t);return this.buildExpression(e,o,i)}getFieldName(t){return t.field}buildExpression(t,e,o){let i={field:t.field,operator:e.operator,value:o.value,type:t.columnType};return t.type==="nested"&&(i.key=t.key),i}parseConnector(t){let e=t.getPosition(),o=t.consumeWhile(i=>re.isLetterChar(i));try{return au(o)}catch(i){if(i instanceof Error&&i.message.includes("trailing characters")){let a=t.getFullInput().slice(e);throw new Error(`Invalid filter string, trailing characters ${a}`)}throw i}}};async function nu(n,t,e,o,i){let a=await n.traces.searchTraces({projectName:t,filters:e!=null?e:void 0,limit:o,truncate:i});return await _e(a,I.TracePublic,o)}async function su(n,t,e,o){let i=Date.now(),a=[];for(;;){if(a=await n(),a.length>=t||Date.now()-i>=e)return a;await new Promise(d=>setTimeout(d,o));}}function pu(n){if(!n)return null;let e=new Ee(n).getFilterExpressions();return e?e.map(o=>{let i={field:o.field,operator:o.operator,value:o.value};return o.key&&(i.key=o.key),i}):null}var mm=[],Oe=class{constructor(t){this.displayTraceLog=t=>{if(t===this.lastProjectNameLogged||!this.config.apiUrl)return;let e=$d({apiUrl:this.config.apiUrl,projectName:t,workspaceName:this.config.workspaceName});z.info(`Started logging traces to the "${t}" project at ${Rt(e)}`),this.lastProjectNameLogged=t;};this.trace=t=>{var i;z.debug("Creating new trace with data:",t);let e=(i=t.projectName)!=null?i:this.config.projectName,o=new pa({id:Z(),startTime:new Date,...t,projectName:e},this);return this.traceBatchQueue.create(o.data),z.debug("Trace added to the queue with ID:",o.data.id),this.displayTraceLog(e),o};this.getDataset=async t=>{z.debug(`Getting dataset with name "${t}"`);try{await this.datasetBatchQueue.flush();let e=await this.api.datasets.getDatasetByIdentifier({datasetName:t});return new qe(e,this)}catch(e){throw e instanceof p&&e.statusCode===404?new nt(t):e}};this.createDataset=async(t,e)=>{z.debug(`Creating dataset with name "${t}"`);let o=new qe({name:t,description:e},this);try{return this.datasetBatchQueue.create({name:o.name,description:o.description,id:o.id}),z.debug("Dataset added to the queue with name:",o.name),o}catch(i){throw z.error(`Failed to create dataset "${t}"`,{error:i}),new Error(`Error creating dataset "${t}": ${i}`)}};this.getOrCreateDataset=async(t,e)=>{z.debug(`Attempting to retrieve or create dataset with name: "${t}"`);try{return await this.getDataset(t)}catch(o){if(o instanceof nt)return z.info(`Dataset "${t}" not found. Proceeding to create a new one.`),this.createDataset(t,e);throw z.error(`Error retrieving dataset "${t}":`,o),o}};this.getDatasets=async(t=100)=>{z.debug(`Getting all datasets (limit: ${t})`);try{await this.datasetBatchQueue.flush();let e=await this.api.datasets.findDatasets({size:t}),o=[];for(let i of e.content||[])o.push(new qe(i,this));return z.info(`Retrieved ${o.length} datasets`),o}catch(e){throw z.error("Failed to retrieve datasets",{error:e}),new Error("Failed to retrieve datasets")}};this.deleteDataset=async t=>{z.debug(`Deleting dataset with name "${t}"`);try{let e=await this.getDataset(t);if(!e.id)throw new Error(`Cannot delete dataset "${t}": ID not available`);this.datasetBatchQueue.delete(e.id);}catch(e){throw z.error(`Failed to delete dataset "${t}"`,{error:e}),new Error(`Failed to delete dataset "${t}": ${e}`)}};this.createExperiment=async({datasetName:t,name:e,experimentConfig:o,prompts:i,type:a=an.Regular,optimizationId:c})=>{if(z.debug(`Creating experiment for dataset "${t}"`),!t)throw new Error("Dataset name is required to create an experiment");let[d,u]=Zd(o,i),g=Z(),y=new Fe({id:g,name:e,datasetName:t,prompts:i},this);try{return this.api.experiments.createExperiment({id:g,datasetName:t,name:e,metadata:d,promptVersions:u,type:a,optimizationId:c}),z.debug("Experiment added to the queue with id:",g),y}catch(k){throw z.error(`Failed to create experiment for dataset "${t}"`,{error:k}),new Error(`Error creating experiment: ${k}`)}};this.getExperimentById=async t=>{z.debug(`Getting experiment with ID "${t}"`);try{let e=await this.api.experiments.getExperimentById(t);return new Fe({id:e.id,name:e.name,datasetName:e.datasetName},this)}catch(e){throw e instanceof p&&e.statusCode===404?new st(`No experiment found with ID '${t}'`):(z.error(`Failed to get experiment with ID "${t}"`,{error:e}),e)}};this.getExperimentsByName=async t=>{z.debug(`Getting experiments with name "${t}"`);try{let e=await this.api.experiments.streamExperiments({name:t});return (await _e(e,I.ExperimentPublic)).map(i=>new Fe({id:i.id,name:i.name,datasetName:i.datasetName},this))}catch(e){throw z.error(`Failed to get experiments with name "${t}"`,{error:e}),e}};this.getExperiment=async t=>{z.debug(`Getting experiment with name "${t}"`);let e=await this.getExperimentsByName(t);if(e.length===0)throw new st(t);return e[0]};this.getDatasetExperiments=async(t,e=100)=>{var c;z.debug(`Getting experiments for dataset "${t}"`);let o=await this.getDataset(t),i=Math.min(100,e),a=[];try{let d=1;for(;a.length<e;){let u=await this.api.experiments.findExperiments({page:d,size:i,datasetId:o.id}),g=(c=u==null?void 0:u.content)!=null?c:[];if(g.length===0)break;let y=e-a.length,k=Math.min(g.length,y);for(let S=0;S<k;S++){let x=g[S];a.push(new Fe({id:x.id,name:x.name,datasetName:x.datasetName},this));}if(k<g.length)break;d+=1;}return a}catch(d){throw z.error(`Failed to get experiments for dataset "${t}"`,{error:d}),d}};this.deleteExperiment=async t=>{z.debug(`Deleting experiment with ID "${t}"`);try{await this.api.experiments.deleteExperimentsById({ids:[t]});}catch(e){throw z.error(`Failed to delete experiment with ID "${t}"`,{error:e}),e}};this.createPrompt=async t=>{var e;z.debug("Creating prompt",{name:t.name});try{let o=await eu(this.api.prompts,t.name,this.api.requestOptions),i=(e=t.type)!=null?e:de.MUSTACHE,a=ru(t,o,i),c;if(a?(z.debug("Creating new prompt version",{name:t.name}),c=await this.api.prompts.createPromptVersion({name:t.name,version:{template:t.prompt,metadata:t.metadata,type:i}},this.api.requestOptions)):(z.debug("Returning existing prompt version",{name:t.name}),c=o),!c.promptId)throw new Error("Invalid API response: missing promptId");let d=await this.api.prompts.getPromptById(c.promptId,this.api.requestOptions),u=Te.fromApiResponse(d,c,this);return z.debug("Prompt created",{name:t.name}),t.description||t.tags?await u.updateProperties({description:t.description,tags:t.tags}):u}catch(o){throw z.error("Failed to create prompt",{name:t.name,error:o}),o}};this.getPrompt=async t=>{var e;z.debug("Getting prompt",t);try{let i=(e=(await this.api.prompts.getPrompts({filters:JSON.stringify([{field:"name",operator:"=",value:t.name}]),size:1},this.api.requestOptions)).content)==null?void 0:e[0];if(!i)return z.debug("Prompt not found",{name:t.name}),null;let a=await this.api.prompts.retrievePromptVersion(t,this.api.requestOptions);return Te.fromApiResponse(i,a,this)}catch(o){if(o instanceof p&&o.statusCode===404)return null;throw z.error("Failed to get prompt",{name:t.name,error:o}),o}};this.searchPrompts=async t=>{var e;z.debug("Searching prompts",{filterString:t});try{let o;if(t){let u=new Ee(t).getFilterExpressions();o=u?JSON.stringify(u):void 0;}let a=(e=(await this.api.prompts.getPrompts({filters:o,size:1e3},this.api.requestOptions)).content)!=null?e:[];return (await Promise.all(a.map(async d=>{if(!d.name)return null;try{let u=await this.api.prompts.retrievePromptVersion({name:d.name},this.api.requestOptions);return Te.fromApiResponse(d,u,this)}catch(u){return z.debug("Failed to get version for prompt",{name:d.name,error:u}),null}}))).filter(d=>d!==null)}catch(o){throw z.error("Failed to search prompts",{error:o}),o}};this.deletePrompts=async t=>{z.debug("Deleting prompts in batch",{count:t.length});try{await this.api.prompts.deletePromptsBatch({ids:t},this.api.requestOptions),z.info("Successfully deleted prompts",{count:t.length});}catch(e){throw z.error("Failed to delete prompts",{count:t.length,error:e}),e}};this.searchTraces=async t=>{let{projectName:e,filterString:o,maxResults:i=1e3,truncate:a=true,waitForAtLeast:c,waitForTimeout:d=60}=t!=null?t:{};z.debug("Searching traces",{projectName:e,filterString:o,maxResults:i,truncate:a,waitForAtLeast:c,waitForTimeout:d});let u=pu(o),g=e!=null?e:this.config.projectName,y=()=>nu(this.api,g,u,i,a);if(c===void 0)return await y();let k=await su(y,c,d*1e3,5e3);if(k.length<c)throw new Ra(`Timeout after ${d} seconds: expected ${c} traces, but only ${k.length} were found.`);return k};this.flush=async()=>{z.debug("Starting flush operation");try{await this.traceBatchQueue.flush(),await this.spanBatchQueue.flush(),await this.traceFeedbackScoresBatchQueue.flush(),await this.spanFeedbackScoresBatchQueue.flush(),await this.datasetBatchQueue.flush(),z.info("Successfully flushed all data to Opik");}catch(t){z.error("Error during flush operation:",{error:t instanceof Error?t.message:t});}};z.debug("Initializing OpikClient with config:",t),this.config=Im(t);let e={apiKey:this.config.apiKey,environment:this.config.apiUrl,workspaceName:this.config.workspaceName};t!=null&&t.headers&&(z.debug("Initializing OpikClient with additional headers:",t==null?void 0:t.headers),e.requestOptions={headers:t==null?void 0:t.headers}),this.api=new wa(e);let o=this.config.holdUntilFlush?24*60*60*1e3:this.config.batchDelayMs;this.spanBatchQueue=new ma(this.api,o),this.traceBatchQueue=new ua(this.api,o),this.spanFeedbackScoresBatchQueue=new da(this.api,o),this.traceFeedbackScoresBatchQueue=new ga(this.api,o),this.datasetBatchQueue=new fa(this.api,o),mm.push(this);}};var Lf="track.decorator",ut=new async_hooks.AsyncLocalStorage,Vf=()=>{let{span:n,trace:t}=ut.getStore()||{};if(!(!n||!t))return {span:n,trace:t}};function Hf(n){return !!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}function Jf({name:n,parentSpan:t,projectName:e,trace:o,type:i="llm"}){z.debug("Creating new span:",{name:n,parentSpan:t==null?void 0:t.data.id,projectName:e,type:i});let a=o;a||(a=um().trace({name:n,projectName:e}));let c=a.span({name:n,parentSpanId:t==null?void 0:t.data.id,projectName:e,type:i});return z.debug("Span created with ID:",c.data.id),{span:c,trace:a}}function Kf({args:n,span:t,trace:e}){if(z.debug("Starting span execution:",{spanId:t.data.id,traceId:e==null?void 0:e.data.id}),n.length===0)return;let o={arguments:n};z.debug("Recording span input"),t.update({input:o}),e&&(z.debug("Recording trace input"),e.update({input:o}));}function cu({result:n,span:t,trace:e,enrichSpan:o}){z.debug("Recording successful execution:",{spanId:t.data.id,traceId:e==null?void 0:e.data.id});let i=typeof n=="object"?n:{result:n},a=new Date,c={endTime:a,output:i};if(o){let d=o(n);Object.assign(c,d);}t.update(c),e&&e.update({endTime:a,output:i});}function lu({span:n,error:t,trace:e}){var o,i;z.error("Recording execution error:",{spanId:n.data.id,traceId:e==null?void 0:e.data.id,error:t instanceof Error?{name:t.name,message:t.message,stack:t.stack}:t}),t instanceof Error&&n.update({errorInfo:{message:t.message,exceptionType:t.name,traceback:(o=t.stack)!=null?o:""}}),n.end(),e&&(e.update({errorInfo:{message:t.message,exceptionType:t.name,traceback:(i=t.stack)!=null?i:""}}),e.end());}function Ea({name:n,projectName:t,type:e,enrichSpan:o}={},i){return function(...c){let d=ut.getStore(),{span:u,trace:g}=Jf({name:n!=null?n:i.name||Lf,parentSpan:d==null?void 0:d.span,projectName:t,trace:d==null?void 0:d.trace,type:e}),y=!d,k=this;return ut.run({span:u,trace:g},()=>{let S=y?g:void 0;try{Kf({args:c,span:u,trace:S});let x=i.apply(k,c);return Hf(x)?x.then(_=>(cu({span:u,result:_,trace:S,enrichSpan:o}),_),_=>{throw lu({span:u,error:_,trace:S}),_}):(cu({span:u,result:x,trace:S,enrichSpan:o}),x)}catch(x){throw lu({span:u,error:x,trace:S}),x}})}}function ze(n,t){if(typeof n=="function")return Ea({},n);let e=n;return t?Ea(e,t):function(...o){if(o.length===2&&typeof o[1]=="object"&&o[1]!==null&&"kind"in o[1]){let[c,d]=o;if(d.kind!=="method")throw new Error("track decorator is only applicable to methods");return Ea(e,c)}let[,,i]=o;if(!i||typeof i.value!="function")throw new Error("track decorator can only be applied to methods");let a=i.value;return i.value=Ea(e,a),i}}var dm=null;function um(){return dm===null&&(dm=new Oe),dm}var Xf=async()=>{z.debug("Starting flushAll operation");try{await Promise.all([um().flush(),...mm.map(n=>n.flush())]),z.debug("flushAll operation completed successfully");}catch(n){throw z.error("Error during flushAll operation:",{error:n instanceof Error?n.message:n,stack:n instanceof Error?n.stack:void 0}),n}};function mu(n,t){if(!t||typeof t!="object")throw new Error("Arguments must be an object");let e=n.validationSchema,i=e.extend(Object.fromEntries(Object.entries(e.shape).map(([a,c])=>[a,c.refine(d=>d!==void 0,{message:`${a} cannot be undefined`,path:[a]})]))).safeParse(t);if(!i.success){let a=i.error.issues.map(d=>d.path[0]).filter(Boolean),c=[...new Set(a)];throw new Error(Gf(n,t,c))}}function Gf(n,t,e){let o=Object.keys(t),i=e.filter(a=>!(a in t));return `Metric '${n.name}' is skipped, missing required arguments: ${i.join(", ")}. Available arguments: ${o.join(", ")}.`}var va=class{static calculateAverageScores(t){if(!t||t.length===0)return new Map;let e=new Map;for(let i of t)if(!(!i||!i.scoreResults||i.scoreResults.length===0))for(let a of i.scoreResults){if(!a||a.scoringFailed||typeof a.value!="number")continue;let c=e.get(a.name)||{sum:0,count:0};c.sum+=a.value,c.count+=1,e.set(a.name,c);}let o=new Map;return e.forEach((i,a)=>{o.set(a,i.count>0?i.sum/i.count:0);}),o}static formatScore(t){return t.toFixed(4)}static formatTime(t){let e=Math.floor(t/3600),o=Math.floor(t%3600/60),i=Math.floor(t%60);return `${e.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}static async generateResultTable(t,e,o,i){if(t.length===0){z.info(`
12
+ ${i}`),i}static fromApiResponse(t,e){var o;if(!e.template)throw new H("Invalid API response: missing required field 'template'");if(!e.commit)throw new H("Invalid API response: missing required field 'commit'");if(!e.promptId)throw new H("Invalid API response: missing required field 'promptId'");if(!e.id)throw new H("Invalid API response: missing required field 'id'");return new n({name:t,prompt:e.template,commit:e.commit,promptId:e.promptId,versionId:e.id,type:(o=e.type)!=null?o:de.MUSTACHE,metadata:e.metadata,changeDescription:e.changeDescription,createdAt:e.createdAt?new Date(e.createdAt):void 0,createdBy:e.createdBy})}};var Ae=class n{constructor({promptId:t,versionId:e,name:o,prompt:i,commit:a,metadata:c,type:m,changeDescription:u,description:g,tags:y=[]},k){this.opik=k;this.id=t,this.versionId=e,this.prompt=i,this.commit=a,this.type=m!=null?m:de.MUSTACHE,this.changeDescription=u,this._name=o,this._description=g,this._tags=[...y],this._metadata=c;}get name(){return this._name}get description(){return this._description}get tags(){return Object.freeze([...this._tags])}get metadata(){if(this._metadata)return structuredClone(this._metadata)}format(t){return fe(this.prompt,t,this.type)}static fromApiResponse(t,e,o){var a;if(!e.template)throw new H("Invalid API response: missing required field 'template'");if(!e.commit)throw new H("Invalid API response: missing required field 'commit'");if(!e.promptId)throw new H("Invalid API response: missing required field 'promptId'");if(!e.id)throw new H("Invalid API response: missing required field 'id' (version ID)");let i=(a=e.type)!=null?a:de.MUSTACHE;if(i!=="mustache"&&i!=="jinja2")throw new H(`Invalid API response: unknown prompt type '${i}'`);return new n({promptId:e.promptId,versionId:e.id,name:t.name,prompt:e.template,commit:e.commit,metadata:e.metadata,type:i,changeDescription:e.changeDescription,description:t.description,tags:t.tags},o)}async updateProperties(t){var e,o,i,a;return await this.opik.api.prompts.updatePrompt(this.id,{name:(e=t.name)!=null?e:this._name,description:t.description,tags:t.tags},this.opik.api.requestOptions),this._name=(o=t.name)!=null?o:this._name,this._description=(i=t.description)!=null?i:this._description,this._tags=(a=t.tags)!=null?a:this._tags,this}async delete(){await this.opik.deletePrompts([this.id]);}async getVersions(){var t;z.debug("Getting versions for prompt",{promptId:this.id,name:this.name});try{let e=[],o=1,i=100;for(;;){let c=(t=(await this.opik.api.prompts.getPromptVersions(this.id,{page:o,size:i},this.opik.api.requestOptions)).content)!=null?t:[];if(e.push(...c),c.length<i)break;o++;}return z.debug("Successfully retrieved prompt versions",{promptId:this.id,name:this.name,totalVersions:e.length}),e.map(a=>gt.fromApiResponse(this.name,a))}catch(e){throw z.error("Failed to get prompt versions",{promptId:this.id,name:this.name,error:e}),e}}async useVersion(t){z.debug("Restoring prompt version",{promptId:this.id,name:this.name,versionId:t.id,versionCommit:t.commit});try{let e=await this.opik.api.prompts.restorePromptVersion(this.id,t.id,this.opik.api.requestOptions);return z.debug("Successfully restored prompt version",{promptId:this.id,name:this.name,restoredVersionId:e.id,restoredCommit:e.commit}),n.fromApiResponse({name:this.name,description:this.description,tags:this._tags},e,this.opik)}catch(e){throw z.error("Failed to restore prompt version",{promptId:this.id,name:this.name,versionId:t.id,versionCommit:t.commit,error:e}),e}}async getVersion(t){try{let e=await this.opik.api.prompts.retrievePromptVersion({name:this.name,commit:t},this.opik.api.requestOptions);return n.fromApiResponse({name:this.name,description:this.description,tags:this._tags},e,this.opik)}catch(e){if(e&&typeof e=="object"&&"statusCode"in e&&e.statusCode===404)return null;throw z.error("Failed to retrieve prompt version",{promptName:this.name,commit:t,error:e}),e}}};async function su(n,t,e){try{return await n.retrievePromptVersion({name:t},e)}catch(o){if(Kh(o))return null;throw o}}function pu(n,t,e){return t?t.template!==n.prompt||!Jh(t.metadata,n.metadata)||t.type!==e:true}function Jh(n,t){let e=n!=null?n:{},o=t!=null?t:{};return Hh__default.default(e,o)}function Kh(n){return typeof n=="object"&&n!==null&&"statusCode"in n&&n.statusCode===404}var re=class{constructor(t){this.input=t;this.cursor=0;}getPosition(){return this.cursor}getRemainingInput(){return this.input.slice(this.cursor)}getFullInput(){return this.input}isAtEnd(){return this.cursor>=this.input.length}peekChar(){return this.input[this.cursor]}peekCharAt(t){return this.input[this.cursor+t]}consumeChar(){return this.input[this.cursor++]}advance(t=1){this.cursor+=t;}skipWhitespace(){for(;this.cursor<this.input.length&&/\s/.test(this.input[this.cursor]);)this.cursor++;}consumeWhile(t){let e=this.cursor;for(;this.cursor<this.input.length&&t(this.input[this.cursor]);)this.cursor++;return this.input.slice(e,this.cursor)}sliceFrom(t){return this.input.slice(t,this.cursor)}static isFieldChar(t){return /[a-zA-Z0-9_]/.test(t)}static isLetterChar(t){return /[a-zA-Z]/.test(t)}static isDigitChar(t){return /\d/.test(t)}static isWhitespaceChar(t){return /\s/.test(t)}static isQuoteChar(t){return t==='"'||t==="'"}};var V={STRING_OPS:["=","contains","not_contains","starts_with","ends_with","!=",">","<"],NUMERIC_OPS:["=","!=",">","<",">=","<="],DATETIME_OPS:["=",">","<",">=","<="],LIST_OPS:["contains"],DICT_OPS:["=","contains",">","<"],LIMITED_STRING_OPS:["=","contains","not_contains"]},Ee={id:"string",name:"string",status:"string",start_time:"date_time",end_time:"date_time",input:"string",output:"string",metadata:"dictionary",feedback_scores:"feedback_scores_number",tags:"list","usage.total_tokens":"number","usage.prompt_tokens":"number","usage.completion_tokens":"number",duration:"number",number_of_messages:"number",created_by:"string",thread_id:"string",total_estimated_cost:"number",type:"string",model:"string",provider:"string"},cu={id:V.STRING_OPS,name:V.STRING_OPS,status:V.LIMITED_STRING_OPS,start_time:V.DATETIME_OPS,end_time:V.DATETIME_OPS,input:V.LIMITED_STRING_OPS,output:V.LIMITED_STRING_OPS,metadata:V.DICT_OPS,feedback_scores:V.NUMERIC_OPS,tags:V.LIST_OPS,"usage.total_tokens":V.NUMERIC_OPS,"usage.prompt_tokens":V.NUMERIC_OPS,"usage.completion_tokens":V.NUMERIC_OPS,duration:V.NUMERIC_OPS,number_of_messages:V.NUMERIC_OPS,created_by:V.STRING_OPS,thread_id:V.STRING_OPS,total_estimated_cost:V.NUMERIC_OPS,type:V.STRING_OPS,model:V.STRING_OPS,provider:V.STRING_OPS},ja={SPECIAL_FIELDS:["usage","metadata","feedback_scores"],USAGE_KEYS:["total_tokens","prompt_tokens","completion_tokens"]};function lu(n){let t=ja.SPECIAL_FIELDS.includes(n),e=Object.keys(Ee).includes(n);if(!t&&!e){let o=Object.keys(Ee).join(", ");throw new Error(`Field ${n} is not supported, only the fields ${o} are supported.`)}}function mu(n,t){if(!ja.SPECIAL_FIELDS.includes(n)){let e=Object.keys(Ee).join(", ");throw new Error(`Field ${n}.${t} is not supported, only the fields ${e} are supported.`)}if(n==="usage"&&!ja.USAGE_KEYS.includes(t))throw new Error(`When querying usage, ${t} is not supported, only usage.total_tokens, usage.prompt_tokens and usage.completion_tokens are supported.`)}function fm(n,t){let e=cu[n];if(!(e!=null&&e.includes(t))){let o=(e==null?void 0:e.join(", "))||"none";throw new Error(`Operator ${t} is not supported for field ${n}, only the operators ${o} are supported.`)}}function du(n){let t=n.toLowerCase();if(t==="and")return true;throw t==="or"?new Error("Invalid filter string, OR is not currently supported"):new Error(`Invalid filter string, trailing characters ${n}`)}function Ua(n,t,e){if(!n)throw new Error(`Missing closing quote for: ${e}`)}var wt=class{static parse(t){t.skipWhitespace();let e=this.parseFieldName(t);return lu(e),t.peekChar()==="."?this.parseFieldWithKey(t,e):{type:"simple",field:e,columnType:Ee[e]}}static parseFieldName(t){return t.consumeWhile(e=>re.isFieldChar(e))}static parseFieldWithKey(t,e){t.advance();let o=this.parseKey(t);if(mu(e,o),e==="usage"){let i=`usage.${o}`;return {type:"simple",field:i,columnType:Ee[i]}}return {type:"nested",field:e,key:o,columnType:Ee[e]}}static parseKey(t){let e=t.peekChar();return re.isQuoteChar(e)?this.parseQuotedKey(t,e):this.parseUnquotedKey(t)}static parseUnquotedKey(t){return t.consumeWhile(e=>re.isFieldChar(e))}static parseQuotedKey(t,e){let o=t.getPosition();t.advance();let i="",a=false;for(;!t.isAtEnd();){let m=t.peekChar();if(m===e){if(t.peekCharAt(1)===e){i+=e,t.advance(2);continue}a=true,t.advance();break}i+=m,t.advance();}let c=t.getFullInput().slice(o);return Ua(a,o,c),i}};var ht=class{static parse(t,e){t.skipWhitespace();let o=t.peekChar(),i=this.tryParseSymbolicOperator(t,o);if(i)return fm(e,i),{operator:i};let a=this.parseWordOperator(t);return fm(e,a),{operator:a}}static tryParseSymbolicOperator(t,e){if(e==="=")return t.advance(),"=";if(e==="<"||e===">"){let o=e;return t.advance(),t.peekChar()==="="?(t.advance(),o+"="):o}return e==="!"&&t.peekCharAt(1)==="="?(t.advance(2),"!="):null}static parseWordOperator(t){return t.consumeWhile(e=>!re.isWhitespaceChar(e))}};var ft=class{static parse(t){t.skipWhitespace();let e=t.getPosition(),o=t.peekChar();if(o==='"')return this.parseQuotedString(t,e);if(re.isDigitChar(o)||o==="-")return this.parseNumber(t);let i=t.getRemainingInput();throw new Error(`Invalid value ${i.slice(0,20)}, expected a string in double quotes("value") or a number`)}static parseQuotedString(t,e){t.advance();let o=t.getPosition(),i=false;for(;!t.isAtEnd();){if(t.peekChar()==='"'){i=true;break}t.advance();}Ua(i,e,`value starting at position ${e}`);let a=t.sliceFrom(o);return t.advance(),{value:a}}static parseNumber(t){let e="";return t.peekChar()==="-"&&(e+=t.consumeChar()),e+=this.parseDigits(t),t.peekChar()==="."&&(e+=t.consumeChar(),e+=this.parseDigits(t)),{value:e}}static parseDigits(t){return t.consumeWhile(e=>re.isDigitChar(e))}};var Pe=class{constructor(t){let e=t||"";this.filterExpressions=e?this.parse(e):null,this.parsedFilters=this.filterExpressions?JSON.stringify(this.filterExpressions):null;}getFilterExpressions(){return this.filterExpressions}parse(t){let e=new re(t),o=[];for(;!e.isAtEnd();){let i=this.parseExpression(e);if(o.push(i),e.skipWhitespace(),!e.isAtEnd()&&!this.parseConnector(e))break}return o}parseExpression(t){let e=wt.parse(t),o=ht.parse(t,this.getFieldName(e)),i=ft.parse(t);return this.buildExpression(e,o,i)}getFieldName(t){return t.field}buildExpression(t,e,o){let i={field:t.field,operator:e.operator,value:o.value,type:t.columnType};return t.type==="nested"&&(i.key=t.key),i}parseConnector(t){let e=t.getPosition(),o=t.consumeWhile(i=>re.isLetterChar(i));try{return du(o)}catch(i){if(i instanceof Error&&i.message.includes("trailing characters")){let a=t.getFullInput().slice(e);throw new Error(`Invalid filter string, trailing characters ${a}`)}throw i}}};async function uu(n,t,e,o,i){let a=await n.traces.searchTraces({projectName:t,filters:e!=null?e:void 0,limit:o,truncate:i});return await Te(a,v.TracePublic,o)}async function gu(n,t,e,o){let i=Date.now(),a=[];for(;;){if(a=await n(),a.length>=t||Date.now()-i>=e)return a;await new Promise(m=>setTimeout(m,o));}}function wu(n){if(!n)return null;let e=new Pe(n).getFilterExpressions();return e?e.map(o=>{let i={field:o.field,operator:o.operator,value:o.value};return o.key&&(i.key=o.key),i}):null}var Rm=[],Le=class{constructor(t){this.displayTraceLog=t=>{if(t===this.lastProjectNameLogged||!this.config.apiUrl)return;let e=ou({apiUrl:this.config.apiUrl,projectName:t,workspaceName:this.config.workspaceName});z.info(`Started logging traces to the "${t}" project at ${St(e)}`),this.lastProjectNameLogged=t;};this.trace=t=>{var i;z.debug("Creating new trace with data:",t);let e=(i=t.projectName)!=null?i:this.config.projectName,o=new wa({id:Z(),startTime:new Date,...t,projectName:e},this);return this.traceBatchQueue.create(o.data),z.debug("Trace added to the queue with ID:",o.data.id),this.displayTraceLog(e),o};this.getDataset=async t=>{z.debug(`Getting dataset with name "${t}"`);try{await this.datasetBatchQueue.flush();let e=await this.api.datasets.getDatasetByIdentifier({datasetName:t});return new or(e,this)}catch(e){throw e instanceof p&&e.statusCode===404?new mt(t):e}};this.createDataset=async(t,e)=>{z.debug(`Creating dataset with name "${t}"`);let o=new or({name:t,description:e},this);try{return this.datasetBatchQueue.create({name:o.name,description:o.description,id:o.id}),z.debug("Dataset added to the queue with name:",o.name),o}catch(i){throw z.error(`Failed to create dataset "${t}"`,{error:i}),new Error(`Error creating dataset "${t}": ${i}`)}};this.getOrCreateDataset=async(t,e)=>{z.debug(`Attempting to retrieve or create dataset with name: "${t}"`);try{return await this.getDataset(t)}catch(o){if(o instanceof mt)return z.info(`Dataset "${t}" not found. Proceeding to create a new one.`),this.createDataset(t,e);throw z.error(`Error retrieving dataset "${t}":`,o),o}};this.getDatasets=async(t=100)=>{z.debug(`Getting all datasets (limit: ${t})`);try{await this.datasetBatchQueue.flush();let e=await this.api.datasets.findDatasets({size:t}),o=[];for(let i of e.content||[])o.push(new or(i,this));return z.info(`Retrieved ${o.length} datasets`),o}catch(e){throw z.error("Failed to retrieve datasets",{error:e}),new Error("Failed to retrieve datasets")}};this.deleteDataset=async t=>{z.debug(`Deleting dataset with name "${t}"`);try{let e=await this.getDataset(t);if(!e.id)throw new Error(`Cannot delete dataset "${t}": ID not available`);this.datasetBatchQueue.delete(e.id);}catch(e){throw z.error(`Failed to delete dataset "${t}"`,{error:e}),new Error(`Failed to delete dataset "${t}": ${e}`)}};this.createExperiment=async({datasetName:t,name:e,experimentConfig:o,prompts:i,type:a=un.Regular,optimizationId:c})=>{if(z.debug(`Creating experiment for dataset "${t}"`),!t)throw new Error("Dataset name is required to create an experiment");let[m,u]=au(o,i),g=Z(),y=new Be({id:g,name:e,datasetName:t,prompts:i},this);try{return this.api.experiments.createExperiment({id:g,datasetName:t,name:e,metadata:m,promptVersions:u,type:a,optimizationId:c}),z.debug("Experiment added to the queue with id:",g),y}catch(k){throw z.error(`Failed to create experiment for dataset "${t}"`,{error:k}),new Error(`Error creating experiment: ${k}`)}};this.getExperimentById=async t=>{z.debug(`Getting experiment with ID "${t}"`);try{let e=await this.api.experiments.getExperimentById(t);return new Be({id:e.id,name:e.name,datasetName:e.datasetName},this)}catch(e){throw e instanceof p&&e.statusCode===404?new dt(`No experiment found with ID '${t}'`):(z.error(`Failed to get experiment with ID "${t}"`,{error:e}),e)}};this.getExperimentsByName=async t=>{z.debug(`Getting experiments with name "${t}"`);try{let e=await this.api.experiments.streamExperiments({name:t});return (await Te(e,v.ExperimentPublic)).map(i=>new Be({id:i.id,name:i.name,datasetName:i.datasetName},this))}catch(e){throw z.error(`Failed to get experiments with name "${t}"`,{error:e}),e}};this.getExperiment=async t=>{z.debug(`Getting experiment with name "${t}"`);let e=await this.getExperimentsByName(t);if(e.length===0)throw new dt(t);return e[0]};this.getDatasetExperiments=async(t,e=100)=>{var c;z.debug(`Getting experiments for dataset "${t}"`);let o=await this.getDataset(t),i=Math.min(100,e),a=[];try{let m=1;for(;a.length<e;){let u=await this.api.experiments.findExperiments({page:m,size:i,datasetId:o.id}),g=(c=u==null?void 0:u.content)!=null?c:[];if(g.length===0)break;let y=e-a.length,k=Math.min(g.length,y);for(let S=0;S<k;S++){let x=g[S];a.push(new Be({id:x.id,name:x.name,datasetName:x.datasetName},this));}if(k<g.length)break;m+=1;}return a}catch(m){throw z.error(`Failed to get experiments for dataset "${t}"`,{error:m}),m}};this.deleteExperiment=async t=>{z.debug(`Deleting experiment with ID "${t}"`);try{await this.api.experiments.deleteExperimentsById({ids:[t]});}catch(e){throw z.error(`Failed to delete experiment with ID "${t}"`,{error:e}),e}};this.createPrompt=async t=>{var e;z.debug("Creating prompt",{name:t.name});try{let o=await su(this.api.prompts,t.name,this.api.requestOptions),i=(e=t.type)!=null?e:de.MUSTACHE,a=pu(t,o,i),c;if(a?(z.debug("Creating new prompt version",{name:t.name}),c=await this.api.prompts.createPromptVersion({name:t.name,version:{template:t.prompt,metadata:t.metadata,type:i}},this.api.requestOptions)):(z.debug("Returning existing prompt version",{name:t.name}),c=o),!c.promptId)throw new Error("Invalid API response: missing promptId");let m=await this.api.prompts.getPromptById(c.promptId,this.api.requestOptions),u=Ae.fromApiResponse(m,c,this);return z.debug("Prompt created",{name:t.name}),t.description||t.tags?await u.updateProperties({description:t.description,tags:t.tags}):u}catch(o){throw z.error("Failed to create prompt",{name:t.name,error:o}),o}};this.getPrompt=async t=>{var e;z.debug("Getting prompt",t);try{let i=(e=(await this.api.prompts.getPrompts({filters:JSON.stringify([{field:"name",operator:"=",value:t.name}]),size:1},this.api.requestOptions)).content)==null?void 0:e[0];if(!i)return z.debug("Prompt not found",{name:t.name}),null;let a=await this.api.prompts.retrievePromptVersion(t,this.api.requestOptions);return Ae.fromApiResponse(i,a,this)}catch(o){if(o instanceof p&&o.statusCode===404)return null;throw z.error("Failed to get prompt",{name:t.name,error:o}),o}};this.searchPrompts=async t=>{var e;z.debug("Searching prompts",{filterString:t});try{let o;if(t){let u=new Pe(t).getFilterExpressions();o=u?JSON.stringify(u):void 0;}let a=(e=(await this.api.prompts.getPrompts({filters:o,size:1e3},this.api.requestOptions)).content)!=null?e:[];return (await Promise.all(a.map(async m=>{if(!m.name)return null;try{let u=await this.api.prompts.retrievePromptVersion({name:m.name},this.api.requestOptions);return Ae.fromApiResponse(m,u,this)}catch(u){return z.debug("Failed to get version for prompt",{name:m.name,error:u}),null}}))).filter(m=>m!==null)}catch(o){throw z.error("Failed to search prompts",{error:o}),o}};this.deletePrompts=async t=>{z.debug("Deleting prompts in batch",{count:t.length});try{await this.api.prompts.deletePromptsBatch({ids:t},this.api.requestOptions),z.info("Successfully deleted prompts",{count:t.length});}catch(e){throw z.error("Failed to delete prompts",{count:t.length,error:e}),e}};this.searchTraces=async t=>{let{projectName:e,filterString:o,maxResults:i=1e3,truncate:a=true,waitForAtLeast:c,waitForTimeout:m=60}=t!=null?t:{};z.debug("Searching traces",{projectName:e,filterString:o,maxResults:i,truncate:a,waitForAtLeast:c,waitForTimeout:m});let u=wu(o),g=e!=null?e:this.config.projectName,y=()=>uu(this.api,g,u,i,a);if(c===void 0)return await y();let k=await gu(y,c,m*1e3,5e3);if(k.length<c)throw new _a(`Timeout after ${m} seconds: expected ${c} traces, but only ${k.length} were found.`);return k};this.flush=async()=>{z.debug("Starting flush operation");try{await this.traceBatchQueue.flush(),await this.spanBatchQueue.flush(),await this.traceFeedbackScoresBatchQueue.flush(),await this.spanFeedbackScoresBatchQueue.flush(),await this.datasetBatchQueue.flush(),z.info("Successfully flushed all data to Opik");}catch(t){z.error("Error during flush operation:",{error:t instanceof Error?t.message:t});}};z.debug("Initializing OpikClient with config:",t),this.config=Om(t);let e={apiKey:this.config.apiKey,environment:this.config.apiUrl,workspaceName:this.config.workspaceName};t!=null&&t.headers&&(z.debug("Initializing OpikClient with additional headers:",t==null?void 0:t.headers),e.requestOptions={headers:t==null?void 0:t.headers}),this.api=new za(e);let o=this.config.holdUntilFlush?24*60*60*1e3:this.config.batchDelayMs;this.spanBatchQueue=new Ra(this.api,o),this.traceBatchQueue=new ya(this.api,o),this.spanFeedbackScoresBatchQueue=new ba(this.api,o),this.traceFeedbackScoresBatchQueue=new ka(this.api,o),this.datasetBatchQueue=new Sa(this.api,o),Rm.push(this);}};var Gh="track.decorator",Rt=new async_hooks.AsyncLocalStorage,$h=()=>{let{span:n,trace:t}=Rt.getStore()||{};if(!(!n||!t))return {span:n,trace:t}};function Qh(n){return !!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}function Yh({name:n,parentSpan:t,projectName:e,trace:o,type:i="llm"}){z.debug("Creating new span:",{name:n,parentSpan:t==null?void 0:t.data.id,projectName:e,type:i});let a=o;a||(a=ym().trace({name:n,projectName:e}));let c=a.span({name:n,parentSpanId:t==null?void 0:t.data.id,projectName:e,type:i});return z.debug("Span created with ID:",c.data.id),{span:c,trace:a}}function Zh({args:n,span:t,trace:e}){if(z.debug("Starting span execution:",{spanId:t.data.id,traceId:e==null?void 0:e.data.id}),n.length===0)return;let o={arguments:n};z.debug("Recording span input"),t.update({input:o}),e&&(z.debug("Recording trace input"),e.update({input:o}));}function hu({result:n,span:t,trace:e,enrichSpan:o}){z.debug("Recording successful execution:",{spanId:t.data.id,traceId:e==null?void 0:e.data.id});let i=typeof n=="object"?n:{result:n},a=new Date,c={endTime:a,output:i};if(o){let m=o(n);Object.assign(c,m);}t.update(c),e&&e.update({endTime:a,output:i});}function fu({span:n,error:t,trace:e}){var o,i;z.error("Recording execution error:",{spanId:n.data.id,traceId:e==null?void 0:e.data.id,error:t instanceof Error?{name:t.name,message:t.message,stack:t.stack}:t}),t instanceof Error&&n.update({errorInfo:{message:t.message,exceptionType:t.name,traceback:(o=t.stack)!=null?o:""}}),n.end(),e&&(e.update({errorInfo:{message:t.message,exceptionType:t.name,traceback:(i=t.stack)!=null?i:""}}),e.end());}function Na({name:n,projectName:t,type:e,enrichSpan:o}={},i){return function(...c){let m=Rt.getStore(),{span:u,trace:g}=Yh({name:n!=null?n:i.name||Gh,parentSpan:m==null?void 0:m.span,projectName:t,trace:m==null?void 0:m.trace,type:e}),y=!m,k=this;return Rt.run({span:u,trace:g},()=>{let S=y?g:void 0;try{Zh({args:c,span:u,trace:S});let x=i.apply(k,c);return Qh(x)?x.then(_=>(hu({span:u,result:_,trace:S,enrichSpan:o}),_),_=>{throw fu({span:u,error:_,trace:S}),_}):(hu({span:u,result:x,trace:S,enrichSpan:o}),x)}catch(x){throw fu({span:u,error:x,trace:S}),x}})}}function Se(n,t){if(typeof n=="function")return Na({},n);let e=n;return t?Na(e,t):function(...o){if(o.length===2&&typeof o[1]=="object"&&o[1]!==null&&"kind"in o[1]){let[c,m]=o;if(m.kind!=="method")throw new Error("track decorator is only applicable to methods");return Na(e,c)}let[,,i]=o;if(!i||typeof i.value!="function")throw new Error("track decorator can only be applied to methods");let a=i.value;return i.value=Na(e,a),i}}var bm=null;function ym(){return bm===null&&(bm=new Le),bm}var qh=async()=>{z.debug("Starting flushAll operation");try{await Promise.all([ym().flush(),...Rm.map(n=>n.flush())]),z.debug("flushAll operation completed successfully");}catch(n){throw z.error("Error during flushAll operation:",{error:n instanceof Error?n.message:n,stack:n instanceof Error?n.stack:void 0}),n}};function Ru(n,t){if(!t||typeof t!="object")throw new Error("Arguments must be an object");let e=n.validationSchema,i=e.extend(Object.fromEntries(Object.entries(e.shape).map(([a,c])=>[a,c.refine(m=>m!==void 0,{message:`${a} cannot be undefined`,path:[a]})]))).safeParse(t);if(!i.success){let a=i.error.issues.map(m=>m.path[0]).filter(Boolean),c=[...new Set(a)];throw new Error(ef(n,t,c))}}function ef(n,t,e){let o=Object.keys(t),i=e.filter(a=>!(a in t));return `Metric '${n.name}' is skipped, missing required arguments: ${i.join(", ")}. Available arguments: ${o.join(", ")}.`}var Da=class{static calculateAverageScores(t){if(!t||t.length===0)return new Map;let e=new Map;for(let i of t)if(!(!i||!i.scoreResults||i.scoreResults.length===0))for(let a of i.scoreResults){if(!a||a.scoringFailed||typeof a.value!="number")continue;let c=e.get(a.name)||{sum:0,count:0};c.sum+=a.value,c.count+=1,e.set(a.name,c);}let o=new Map;return e.forEach((i,a)=>{o.set(a,i.count>0?i.sum/i.count:0);}),o}static formatScore(t){return t.toFixed(4)}static formatTime(t){let e=Math.floor(t/3600),o=Math.floor(t%3600/60),i=Math.floor(t%60);return `${e.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}static async generateResultTable(t,e,o,i){if(t.length===0){z.info(`
13
13
  No test results available to display.`);return}if(o.size===0){z.info(`
14
- No metrics available to display.`);return}let a=[...o.keys()].sort(),c=this.formatTime(i),d=[Pa__default.default.bold(`Total time: ${c}`),Pa__default.default.bold(`Number of samples: ${t.length}`),"",...a.map(y=>{let k=this.formatScore(o.get(y)||0);return Pa__default.default.green(`${y}: ${k} (avg)`)})].join(`
15
- `),u=await e.ensureNameLoaded(),g=$f__default.default(d,{title:`${u} (${t.length} samples)`,titleAlignment:"left",padding:1,margin:0,borderColor:"cyan",borderStyle:"round"});z.info(`
14
+ No metrics available to display.`);return}let a=[...o.keys()].sort(),c=this.formatTime(i),m=[Ma__default.default.bold(`Total time: ${c}`),Ma__default.default.bold(`Number of samples: ${t.length}`),"",...a.map(y=>{let k=this.formatScore(o.get(y)||0);return Ma__default.default.green(`${y}: ${k} (avg)`)})].join(`
15
+ `),u=await e.ensureNameLoaded(),g=rf__default.default(m,{title:`${u} (${t.length} samples)`,titleAlignment:"left",padding:1,margin:0,borderColor:"cyan",borderStyle:"round"});z.info(`
16
16
  `+g+`
17
- `),z.info(Pa__default.default.blue("Uploading results to Opik ... "));}static async displayExperimentLink(t){let e=await t.getUrl();z.info(`View the results ${Rt(e,"in your Opik dashboard")}`);}static async processResults(t,e,o=0){let i=this.calculateAverageScores(t);await this.generateResultTable(t,e,i,o),await this.displayExperimentLink(e);let a=await e.ensureNameLoaded();return {experimentId:e.id,experimentName:a,testResults:t}}};function du(n,t,e){if(!n||typeof t!="string"||t.trim()==="")return e;let o=t.replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split("."),i=n;for(let a of o)if(typeof i=="object"&&i!==null&&a in i)i=i[a];else return e;return i===void 0?e:i}var uu,gm;uu=[ze({name:"metrics_calculation",type:we.General})];var er=class{constructor(t,e,o){Am(gm,5,this);this.client=void 0;this.dataset=void 0;this.task=void 0;this.scoringMetrics=void 0;this.projectName=void 0;this.nbSamples=void 0;this.scoringKeyMapping=void 0;this.experiment=void 0;this.rootTrace=void 0;this.client=e,this.dataset=t.dataset,this.experiment=o,this.task=t.task,this.scoringMetrics=t.scoringMetrics||[],this.projectName=t.projectName,this.nbSamples=t.nbSamples,this.scoringKeyMapping=t.scoringKeyMapping;}async execute(){var y;let t=performance.now(),e=[],o=await this.dataset.getItems(this.nbSamples),i=o.length,a=z.settings.minLevel;z.settings.minLevel=6;let c=Qf__default.default({text:`Evaluating dataset (0/${i} items)`}).start(),d=[];for(let k=0;k<o.length;k++){let S=o[k];try{this.rootTrace=this.client.trace({projectName:this.projectName,name:"evaluation_task",createdBy:"evaluation",input:S}),ut.enterWith({trace:this.rootTrace});let x=await this.executeTask(S);d.push(x),this.rootTrace.update({output:x.testCase.taskOutput,endTime:new Date});}catch(x){let _=x instanceof Error?x.message:String(x);z.error(`Error processing dataset item: ${S.id} - ${_}`),x instanceof Error&&this.rootTrace.update({errorInfo:{message:x.message,exceptionType:x.name,traceback:(y=x.stack)!=null?y:""},endTime:new Date});}e.push(new Sa({datasetItemId:S.id,traceId:this.rootTrace.data.id})),c.text=`Evaluating dataset (${k+1}/${i} items, ${Math.round((k+1)/i*100)}%)`;}let g=(performance.now()-t)/1e3;return c.succeed(`Evaluation complete: ${i} items processed in ${g.toFixed(2)}s`),z.settings.minLevel=a,this.experiment.insert(e),await this.client.flush(),va.processResults(d,this.experiment,g)}async executeTask(t){let e={},o=[];z.debug(`Starting evaluation task on dataset item ${t.id}`),e=await ze({name:"llm_task",type:we.General},this.task)(t),z.debug(`Finished evaluation task on dataset item ${t.id}`);let i=this.prepareScoringInputs(t,e),a={traceId:this.rootTrace.data.id,datasetItemId:t.id,scoringInputs:i,taskOutput:e};return this.scoringMetrics.length>0?this.calculateScores(a):{testCase:a,scoreResults:o}}async calculateScores(t){let e=[],{scoringInputs:o}=t;for(let i of this.scoringMetrics){z.debug(`Calculating score for metric ${i.name}`);try{mu(i,o);let a=await i.score(o),c=Array.isArray(a)?a:[a];e.push(...c);}catch(a){let c=a instanceof Error?a.message:String(a);z.error(`Metric ${i.name} failed: ${c}`);}z.debug(`Finished calculating score for metric ${i.name}`);}return e.forEach(i=>{var a;return (a=this.rootTrace)==null?void 0:a.score({name:i.name,value:i.value,reason:i.reason})}),{testCase:t,scoreResults:e}}prepareScoringInputs(t,e){let o={...t,...e};if(!this.scoringKeyMapping)return o;let i={...o};for(let[a,c]of Object.entries(this.scoringKeyMapping)){let d=du(o,c);d!==void 0&&(i[a]=d);}return i}};gm=_m(),Em(gm,1,"calculateScores",uu,er),Ba(gm,er);var rr=class rr{static getInstance(t){return rr.instance||(rr.instance=new Oe(t)),rr.instance}};rr.instance=null;var Ca=rr;async function gu(n){var o;if(!n.dataset)throw new Error("Dataset is required for evaluation");if(!n.task)throw new Error("Task function is required for evaluation");let t=(o=n.client)!=null?o:Ca.getInstance(),e=await t.createExperiment({name:n.experimentName,datasetName:n.dataset.name,experimentConfig:n.experimentConfig,prompts:n.prompts});try{let i=new er(n,t,e);return z.info("Starting evaluation"),i.execute()}catch(i){throw z.error(`Error during evaluation: ${i}`),i}}var We=class{constructor(t){this.modelName=t;}};var gt=class n extends Error{constructor(t){super(t),this.name="ModelError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},or=class n extends gt{constructor(e,o){super(e);this.cause=o;this.name="ModelGenerationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},Pe=class n extends gt{constructor(t){super(t),this.name="ModelConfigurationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}};function eh(n,t){return n.startsWith("gpt-")||n.startsWith("o1")||n.startsWith("o3")||n.startsWith("chatgpt-")}function rh(n,t){return n.startsWith("claude-")}function oh(n,t){return n.startsWith("gemini-")||n.startsWith("gemma-")}function wm(n,t,e){if(!t)throw new Pe(`API key for ${n} is not configured. Please provide it via the 'apiKey' option or set the ${e} environment variable.`)}function fm(n,t){if(eh(n)){let e=(t==null?void 0:t.apiKey)||process.env.OPENAI_API_KEY;return wm("OpenAI",e,"OPENAI_API_KEY"),openai.createOpenAI({apiKey:e,...t})(n)}if(rh(n)){let e=(t==null?void 0:t.apiKey)||process.env.ANTHROPIC_API_KEY;return wm("Anthropic",e,"ANTHROPIC_API_KEY"),anthropic.createAnthropic({apiKey:e,...t})(n)}if(oh(n)){let e=(t==null?void 0:t.apiKey)||process.env.GOOGLE_API_KEY;return wm("Google Gemini",e,"GOOGLE_API_KEY"),google.createGoogleGenerativeAI({apiKey:e,...t})(n)}throw new Pe(`Unable to detect provider for model ID: ${n}. Supported providers are OpenAI (gpt-*, o1*, o3*, chatgpt-*), Anthropic (claude-*), and Google Gemini (gemini-*, gemma-*).`)}var th={inputTokens:"prompt_tokens",outputTokens:"completion_tokens",totalTokens:"total_tokens",reasoningTokens:"reasoning_tokens",cachedInputTokens:"cached_input_tokens"};function ih(n){if(!n||typeof n!="object")return false;let t=n,e="usage"in t,o="response"in t,i="text"in t,a="object"in t;return e||o||i||a}function hm(n,t){if(!ih(n))return {model:t};let e={model:ah(n,t)},o=nh(n.usage);o&&(e.usage=o);let i=sh(n);i&&(e.provider=i);let a=ch(n);a&&(e.metadata=a);let c=lh(n);return c&&(e.output=c),e}function ah(n,t){var e,o;return (o=(e=n.response)==null?void 0:e.modelId)!=null?o:t}function nh(n){if(!n)return;let t={};for(let[e,o]of Object.entries(th)){let i=n[e];i!==void 0&&(t[o]=i);}return Object.keys(t).length>0?t:void 0}function sh(n){if(!n.providerMetadata)return;let t=Object.keys(n.providerMetadata);return t.length>0?t[0]:void 0}function ph(n){if(!n)return;let t={};return n.id&&(t.id=n.id),n.timestamp&&(t.timestamp=n.timestamp.toISOString()),Object.keys(t).length>0?t:void 0}function ch(n){let t={};n.usage&&(t.usage=n.usage),n.warnings&&n.warnings.length>0&&(t.warnings=n.warnings);let e=ph(n.response);return e&&(t.response=e),n.providerMetadata&&(t.providerMetadata=n.providerMetadata),n.finishReason&&(t.finishReason=n.finishReason),Object.keys(t).length>0?t:void 0}function lh(n){let t={};return "text"in n&&n.text&&(t.text=n.text),"object"in n&&n.object!==void 0&&(t.object=n.object),"toolCalls"in n&&Array.isArray(n.toolCalls)&&(t.toolCalls=n.toolCalls),"toolResults"in n&&Array.isArray(n.toolResults)&&(t.toolResults=n.toolResults),"sources"in n&&Array.isArray(n.sources)&&(t.sources=n.sources),Object.keys(t).length>0?t:void 0}var tr=class extends We{constructor(t,e={trackGenerations:true}){let o=typeof t=="string"?t:t.modelId;super(o);let{trackGenerations:i,...a}=e;try{typeof t!="string"?(this.model=t,z.debug("Initialized VercelAIChatModel with custom LanguageModel")):(this.model=fm(t,a),z.debug(`Initialized VercelAIChatModel with model ID: ${t}`)),i?(this._generateText=ze({name:"model.generateText",type:we.Llm,enrichSpan:c=>hm(c,this.modelName)},ai$1.generateText),this._generateObject=ze({name:"model.generateObject",type:we.Llm,enrichSpan:c=>hm(c,this.modelName)},ai$1.generateObject)):(this._generateText=ai$1.generateText,this._generateObject=ai$1.generateObject);}catch(c){throw new Pe(`Failed to initialize model ${o}: ${c instanceof Error?c.message:String(c)}`)}}async generateString(t,e,o){try{let i;if(e){z.debug(`Generating structured output with model ${this.modelName}, input length: ${t.length}`);let a=await this._generateObject({model:this.model,prompt:t,schema:e,...o});z.debug(`Generated structured output with model ${this.modelName}`),i=JSON.stringify(a.object);}else {z.debug(`Generating text with model ${this.modelName}, input length: ${t.length}`);let a=await this._generateText({model:this.model,prompt:t,...o});z.debug(`Generated text with model ${this.modelName}, output length: ${a.text.length}`),i=a.text;}return i}catch(i){let a=e?`Failed to generate structured output with model ${this.modelName}`:`Failed to generate text with model ${this.modelName}`;throw z.error(a,{error:i}),new or(a,i instanceof Error?i:new Error(String(i)))}}async generateProviderResponse(t,e){try{z.debug(`Generating provider response with model ${this.modelName}, messages count: ${t.length}`);let o=await this._generateText({model:this.model,messages:t,...e});return z.debug(`Generated provider response with model ${this.modelName}`),o}catch(o){let i=`Failed to generate provider response with model ${this.modelName}`;throw z.error(i,{error:o}),new or(i,o instanceof Error?o:new Error(String(o)))}}};var hu="gpt-4o";function Rm(n,t){return new tr(n,t)}function Ru(n,t){return new tr(n,t)}function mh(n){return n instanceof We}function dh(n){return typeof n=="object"&&n!==null&&"modelId"in n&&typeof n.modelId=="string"}function uh(n){return typeof n=="string"&&n.length>0}function gh(n){let t=typeof n,e=t==="object"?JSON.stringify(n):String(n);return new Error(`Invalid model type. Expected one of:
17
+ `),z.info(Ma__default.default.blue("Uploading results to Opik ... "));}static async displayExperimentLink(t){let e=await t.getUrl();z.info(`View the results ${St(e,"in your Opik dashboard")}`);}static async processResults(t,e,o=0){let i=this.calculateAverageScores(t);await this.generateResultTable(t,e,i,o),await this.displayExperimentLink(e);let a=await e.ensureNameLoaded();return {experimentId:e.id,experimentName:a,testResults:t}}};function bu(n,t,e){if(!n||typeof t!="string"||t.trim()==="")return e;let o=t.replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split("."),i=n;for(let a of o)if(typeof i=="object"&&i!==null&&a in i)i=i[a];else return e;return i===void 0?e:i}var yu,km;yu=[Se({name:"metrics_calculation",type:we.General})];var tr=class{constructor(t,e,o){Um(km,5,this);this.client=void 0;this.dataset=void 0;this.task=void 0;this.scoringMetrics=void 0;this.projectName=void 0;this.nbSamples=void 0;this.scoringKeyMapping=void 0;this.experiment=void 0;this.rootTrace=void 0;this.client=e,this.dataset=t.dataset,this.experiment=o,this.task=t.task,this.scoringMetrics=t.scoringMetrics||[],this.projectName=t.projectName,this.nbSamples=t.nbSamples,this.scoringKeyMapping=t.scoringKeyMapping;}async execute(){var y;let t=performance.now(),e=[],o=await this.dataset.getItems(this.nbSamples),i=o.length,a=z.settings.minLevel;z.settings.minLevel=6;let c=of__default.default({text:`Evaluating dataset (0/${i} items)`}).start(),m=[];for(let k=0;k<o.length;k++){let S=o[k];try{this.rootTrace=this.client.trace({projectName:this.projectName,name:"evaluation_task",createdBy:"evaluation",input:S}),Rt.enterWith({trace:this.rootTrace});let x=await this.executeTask(S);m.push(x),this.rootTrace.update({output:x.testCase.taskOutput,endTime:new Date});}catch(x){let _=x instanceof Error?x.message:String(x);z.error(`Error processing dataset item: ${S.id} - ${_}`),x instanceof Error&&this.rootTrace.update({errorInfo:{message:x.message,exceptionType:x.name,traceback:(y=x.stack)!=null?y:""},endTime:new Date});}e.push(new va({datasetItemId:S.id,traceId:this.rootTrace.data.id})),c.text=`Evaluating dataset (${k+1}/${i} items, ${Math.round((k+1)/i*100)}%)`;}let g=(performance.now()-t)/1e3;return c.succeed(`Evaluation complete: ${i} items processed in ${g.toFixed(2)}s`),z.settings.minLevel=a,this.experiment.insert(e),await this.client.flush(),Da.processResults(m,this.experiment,g)}async executeTask(t){let e={},o=[];z.debug(`Starting evaluation task on dataset item ${t.id}`),e=await Se({name:"llm_task",type:we.General},this.task)(t),z.debug(`Finished evaluation task on dataset item ${t.id}`);let i=this.prepareScoringInputs(t,e),a={traceId:this.rootTrace.data.id,datasetItemId:t.id,scoringInputs:i,taskOutput:e};return this.scoringMetrics.length>0?this.calculateScores(a):{testCase:a,scoreResults:o}}async calculateScores(t){let e=[],{scoringInputs:o}=t;for(let i of this.scoringMetrics){z.debug(`Calculating score for metric ${i.name}`);try{Ru(i,o);let a=await i.score(o),c=Array.isArray(a)?a:[a];e.push(...c);}catch(a){let c=a instanceof Error?a.message:String(a);z.error(`Metric ${i.name} failed: ${c}`);}z.debug(`Finished calculating score for metric ${i.name}`);}return e.forEach(i=>{var a;return (a=this.rootTrace)==null?void 0:a.score({name:i.name,value:i.value,reason:i.reason})}),{testCase:t,scoreResults:e}}prepareScoringInputs(t,e){let o={...t,...e};if(!this.scoringKeyMapping)return o;let i={...o};for(let[a,c]of Object.entries(this.scoringKeyMapping)){let m=bu(o,c);m!==void 0&&(i[a]=m);}return i}};km=Im(),Nm(km,1,"calculateScores",yu,tr),Ga(km,tr);var ir=class ir{static getInstance(t){return ir.instance||(ir.instance=new Le(t)),ir.instance}};ir.instance=null;var Fa=ir;async function ku(n){var o;if(!n.dataset)throw new Error("Dataset is required for evaluation");if(!n.task)throw new Error("Task function is required for evaluation");let t=(o=n.client)!=null?o:Fa.getInstance(),e=await t.createExperiment({name:n.experimentName,datasetName:n.dataset.name,experimentConfig:n.experimentConfig,prompts:n.prompts});try{let i=new tr(n,t,e);return z.info("Starting evaluation"),i.execute()}catch(i){throw z.error(`Error during evaluation: ${i}`),i}}var Ve=class{constructor(t){this.modelName=t;}};var bt=class n extends Error{constructor(t){super(t),this.name="ModelError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},ar=class n extends bt{constructor(e,o){super(e);this.cause=o;this.name="ModelGenerationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},ve=class n extends bt{constructor(t){super(t),this.name="ModelConfigurationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}};function sf(n,t){return n.startsWith("gpt-")||n.startsWith("o1")||n.startsWith("o3")||n.startsWith("chatgpt-")}function pf(n,t){return n.startsWith("claude-")}function cf(n,t){return n.startsWith("gemini-")||n.startsWith("gemma-")}function zm(n,t,e){if(!t)throw new ve(`API key for ${n} is not configured. Please provide it via the 'apiKey' option or set the ${e} environment variable.`)}function Sm(n,t){if(sf(n)){let e=(t==null?void 0:t.apiKey)||process.env.OPENAI_API_KEY;return zm("OpenAI",e,"OPENAI_API_KEY"),openai.createOpenAI({apiKey:e,...t})(n)}if(pf(n)){let e=(t==null?void 0:t.apiKey)||process.env.ANTHROPIC_API_KEY;return zm("Anthropic",e,"ANTHROPIC_API_KEY"),anthropic.createAnthropic({apiKey:e,...t})(n)}if(cf(n)){let e=(t==null?void 0:t.apiKey)||process.env.GOOGLE_API_KEY;return zm("Google Gemini",e,"GOOGLE_API_KEY"),google.createGoogleGenerativeAI({apiKey:e,...t})(n)}throw new ve(`Unable to detect provider for model ID: ${n}. Supported providers are OpenAI (gpt-*, o1*, o3*, chatgpt-*), Anthropic (claude-*), and Google Gemini (gemini-*, gemma-*).`)}var lf={inputTokens:"prompt_tokens",outputTokens:"completion_tokens",totalTokens:"total_tokens",reasoningTokens:"reasoning_tokens",cachedInputTokens:"cached_input_tokens"};function mf(n){if(!n||typeof n!="object")return false;let t=n,e="usage"in t,o="response"in t,i="text"in t,a="object"in t;return e||o||i||a}function xm(n,t){if(!mf(n))return {model:t};let e={model:df(n,t)},o=uf(n.usage);o&&(e.usage=o);let i=gf(n);i&&(e.provider=i);let a=hf(n);a&&(e.metadata=a);let c=ff(n);return c&&(e.output=c),e}function df(n,t){var e,o;return (o=(e=n.response)==null?void 0:e.modelId)!=null?o:t}function uf(n){if(!n)return;let t={};for(let[e,o]of Object.entries(lf)){let i=n[e];i!==void 0&&(t[o]=i);}return Object.keys(t).length>0?t:void 0}function gf(n){if(!n.providerMetadata)return;let t=Object.keys(n.providerMetadata);return t.length>0?t[0]:void 0}function wf(n){if(!n)return;let t={};return n.id&&(t.id=n.id),n.timestamp&&(t.timestamp=n.timestamp.toISOString()),Object.keys(t).length>0?t:void 0}function hf(n){let t={};n.usage&&(t.usage=n.usage),n.warnings&&n.warnings.length>0&&(t.warnings=n.warnings);let e=wf(n.response);return e&&(t.response=e),n.providerMetadata&&(t.providerMetadata=n.providerMetadata),n.finishReason&&(t.finishReason=n.finishReason),Object.keys(t).length>0?t:void 0}function ff(n){let t={};return "text"in n&&n.text&&(t.text=n.text),"object"in n&&n.object!==void 0&&(t.object=n.object),"toolCalls"in n&&Array.isArray(n.toolCalls)&&(t.toolCalls=n.toolCalls),"toolResults"in n&&Array.isArray(n.toolResults)&&(t.toolResults=n.toolResults),"sources"in n&&Array.isArray(n.sources)&&(t.sources=n.sources),Object.keys(t).length>0?t:void 0}var nr=class extends Ve{constructor(t,e={trackGenerations:true}){let o=typeof t=="string"?t:t.modelId;super(o);let{trackGenerations:i,...a}=e;try{typeof t!="string"?(this.model=t,z.debug("Initialized VercelAIChatModel with custom LanguageModel")):(this.model=Sm(t,a),z.debug(`Initialized VercelAIChatModel with model ID: ${t}`)),i?(this._generateText=Se({name:"model.generateText",type:we.Llm,enrichSpan:c=>xm(c,this.modelName)},ai$1.generateText),this._generateObject=Se({name:"model.generateObject",type:we.Llm,enrichSpan:c=>xm(c,this.modelName)},ai$1.generateObject)):(this._generateText=ai$1.generateText,this._generateObject=ai$1.generateObject);}catch(c){throw new ve(`Failed to initialize model ${o}: ${c instanceof Error?c.message:String(c)}`)}}async generateString(t,e,o){try{let i;if(e){z.debug(`Generating structured output with model ${this.modelName}, input length: ${t.length}`);let a=await this._generateObject({model:this.model,prompt:t,schema:e,...o});z.debug(`Generated structured output with model ${this.modelName}`),i=JSON.stringify(a.object);}else {z.debug(`Generating text with model ${this.modelName}, input length: ${t.length}`);let a=await this._generateText({model:this.model,prompt:t,...o});z.debug(`Generated text with model ${this.modelName}, output length: ${a.text.length}`),i=a.text;}return i}catch(i){let a=e?`Failed to generate structured output with model ${this.modelName}`:`Failed to generate text with model ${this.modelName}`;throw z.error(a,{error:i}),new ar(a,i instanceof Error?i:new Error(String(i)))}}async generateProviderResponse(t,e){try{z.debug(`Generating provider response with model ${this.modelName}, messages count: ${t.length}`);let o=await this._generateText({model:this.model,messages:t,...e});return z.debug(`Generated provider response with model ${this.modelName}`),o}catch(o){let i=`Failed to generate provider response with model ${this.modelName}`;throw z.error(i,{error:o}),new ar(i,o instanceof Error?o:new Error(String(o)))}}};var xu="gpt-4o";function _m(n,t){return new nr(n,t)}function _u(n,t){return new nr(n,t)}function Rf(n){return n instanceof Ve}function bf(n){return typeof n=="object"&&n!==null&&"modelId"in n&&typeof n.modelId=="string"}function yf(n){return typeof n=="string"&&n.length>0}function kf(n){let t=typeof n,e=t==="object"?JSON.stringify(n):String(n);return new Error(`Invalid model type. Expected one of:
18
18
  - string (model ID like 'gpt-4o', 'claude-3-5-sonnet-latest')
19
19
  - LanguageModel instance from Vercel AI SDK
20
20
  - OpikBaseModel instance
21
- - undefined (uses default model: ${hu})
21
+ - undefined (uses default model: ${xu})
22
22
 
23
- Received: ${t} ${e}`)}function wt(n,t){if(n==null)return Rm(hu,t);if(uh(n))return Rm(n,t);if(mh(n))return n;if(dh(n))return Ru(n,t);throw gh(n)}function bu(n){return n.map(t=>{let e=Array.isArray(t.content)?wh(t.content):t.content;return `${t.role}: ${e}`}).join(`
24
- `)}function wh(n){return n.map(t=>t.type==="text"?t.text:t.type==="file"?`[file: ${t.filename||"unknown"}]`:t.type==="tool-call"?`[tool-call: ${t.toolName}]`:t.type==="tool-result"?`[tool-result: ${t.toolName}]`:t.type==="reasoning"?`[reasoning: ${t.text}]`:"").filter(t=>t.length>0).join(`
25
- `)}function fh(n,t,e){return typeof n=="string"?he(n,t,e):Array.isArray(n)?n.map(i=>i.type==="text"&&typeof i.text=="string"?{...i,text:he(i.text,t,e)}:i.type==="image"&&typeof i.image=="string"?{...i,image:he(i.image,t,e)}:i.type==="file"&&typeof i.data=="string"?{...i,data:he(i.data,t,e)}:i.type==="reasoning"&&typeof i.text=="string"?{...i,text:he(i.text,t,e)}:i):n}function yu(n,t,e){let o=fh(n.content,t,e);return {...n,content:o}}async function mre(n){var i;if(!n.dataset)throw new Error("Dataset is required for prompt evaluation");if(!n.messages||n.messages.length===0)throw new Error("Messages array is required and cannot be empty");if(n.experimentConfig!==void 0&&(typeof n.experimentConfig!="object"||n.experimentConfig===null||Array.isArray(n.experimentConfig)))throw new Error("experimentConfig must be a plain object, not an array or primitive value");let t=wt(n.model),e={...n.experimentConfig,prompt_template:n.messages,model:t.modelName,...n.temperature!==void 0&&{temperature:n.temperature},...n.seed!==void 0&&{seed:n.seed}},o=hh(t,n.messages,(i=n.templateType)!=null?i:de.MUSTACHE,{temperature:n.temperature,seed:n.seed});return gu({dataset:n.dataset,task:o,scoringMetrics:n.scoringMetrics,experimentName:n.experimentName,projectName:n.projectName,experimentConfig:e,prompts:n.prompts,client:n.client,nbSamples:n.nbSamples,scoringKeyMapping:n.scoringKeyMapping})}function hh(n,t,e,o){return async i=>{let a=t.map(g=>yu(g,i,e)),c=await n.generateProviderResponse(a,o),d=Rh(c);return {input:bu(a),output:d}}}function Rh(n){return n&&typeof n=="object"?"text"in n&&typeof n.text=="string"?n.text:"content"in n&&typeof n.content=="string"?n.content:JSON.stringify(n):String(n)}var pe=class{constructor(t,e=true){if(this.name=t,this.trackMetric=e,e){let o=this.score.bind(this);this.score=ze({name:this.name,type:we.General},o);}}};var bh=bm__default.default.object({output:bm__default.default.unknown(),expected:bm__default.default.unknown()}),ku=class extends pe{constructor(e="exact_match",o=true){super(e,o);this.validationSchema=bh;}async score(e){let{output:o,expected:i}=e,a=o===i?1:0;return {name:this.name,value:a,reason:`Exact match: ${a===1?"Match":"No match"}`}}};var yh=bm__default.default.object({output:bm__default.default.string(),substring:bm__default.default.string()}),zu=class extends pe{constructor(e="contains",o=true,i=false){super(e,o);this.validationSchema=yh;this.caseSensitive=i;}async score(e){let{output:o,substring:i}=e,a=this.caseSensitive?o:o.toLowerCase(),c=this.caseSensitive?i:i.toLowerCase();return a.includes(c)?{name:this.name,value:1,reason:`Contains: "${i}" found in output.`}:{name:this.name,value:0,reason:`Contains: "${i}" not found in output.`}}};var kh=bm.z.object({output:bm.z.string(),pattern:bm.z.string(),flags:bm.z.string().optional()}),Su=class extends pe{constructor(e="regex_match",o=true){super(e,o);this.validationSchema=kh;}async score(e){let{output:o,pattern:i,flags:a}=e,c;typeof i=="string"&&a?c=new RegExp(i,a):c=new RegExp(i);let d=c.test(o);return {name:this.name,value:d?1:0,reason:d?`Regex: Output matches the regex pattern: ${i}`:`Regex: Output does not match the regex pattern: ${i}`}}};var zh=bm__default.default.object({output:bm__default.default.unknown()}),_u=class extends pe{constructor(e="is_json_metric",o=true){super(e,o);this.validationSchema=zh;}async score(e){let{output:o}=e;try{return JSON.parse(o),{name:this.name,value:1,reason:"IsJson: Output is valid JSON."}}catch{return {name:this.name,value:0,reason:"IsJson: Output is not valid JSON"}}}};var ue=class extends pe{constructor(t,e){var i;let o=(i=e==null?void 0:e.trackMetric)!=null?i:true;super(t,o),this.temperature=e==null?void 0:e.temperature,this.seed=e==null?void 0:e.seed,this.maxTokens=e==null?void 0:e.maxTokens,this.modelSettings=e==null?void 0:e.modelSettings,this.model=this.initModel(e==null?void 0:e.model,{trackGenerations:o});}initModel(t,e){return wt(t,e)}buildModelOptions(){return {...this.modelSettings,...this.temperature!==void 0&&{temperature:this.temperature},...this.seed!==void 0&&{seed:this.seed},...this.maxTokens!==void 0&&{maxTokens:this.maxTokens}}}};function Tu(n,t=[]){let e="";return t.length>0&&(e=`
23
+ Received: ${t} ${e}`)}function yt(n,t){if(n==null)return _m(xu,t);if(yf(n))return _m(n,t);if(Rf(n))return n;if(bf(n))return _u(n,t);throw kf(n)}function Tu(n){return n.map(t=>{let e=Array.isArray(t.content)?zf(t.content):t.content;return `${t.role}: ${e}`}).join(`
24
+ `)}function zf(n){return n.map(t=>t.type==="text"?t.text:t.type==="file"?`[file: ${t.filename||"unknown"}]`:t.type==="tool-call"?`[tool-call: ${t.toolName}]`:t.type==="tool-result"?`[tool-result: ${t.toolName}]`:t.type==="reasoning"?`[reasoning: ${t.text}]`:"").filter(t=>t.length>0).join(`
25
+ `)}function Sf(n,t,e){return typeof n=="string"?fe(n,t,e):Array.isArray(n)?n.map(i=>i.type==="text"&&typeof i.text=="string"?{...i,text:fe(i.text,t,e)}:i.type==="image"&&typeof i.image=="string"?{...i,image:fe(i.image,t,e)}:i.type==="file"&&typeof i.data=="string"?{...i,data:fe(i.data,t,e)}:i.type==="reasoning"&&typeof i.text=="string"?{...i,text:fe(i.text,t,e)}:i):n}function Au(n,t,e){let o=Sf(n.content,t,e);return {...n,content:o}}async function Kre(n){var i;if(!n.dataset)throw new Error("Dataset is required for prompt evaluation");if(!n.messages||n.messages.length===0)throw new Error("Messages array is required and cannot be empty");if(n.experimentConfig!==void 0&&(typeof n.experimentConfig!="object"||n.experimentConfig===null||Array.isArray(n.experimentConfig)))throw new Error("experimentConfig must be a plain object, not an array or primitive value");let t=yt(n.model),e={...n.experimentConfig,prompt_template:n.messages,model:t.modelName,...n.temperature!==void 0&&{temperature:n.temperature},...n.seed!==void 0&&{seed:n.seed}},o=xf(t,n.messages,(i=n.templateType)!=null?i:de.MUSTACHE,{temperature:n.temperature,seed:n.seed});return ku({dataset:n.dataset,task:o,scoringMetrics:n.scoringMetrics,experimentName:n.experimentName,projectName:n.projectName,experimentConfig:e,prompts:n.prompts,client:n.client,nbSamples:n.nbSamples,scoringKeyMapping:n.scoringKeyMapping})}function xf(n,t,e,o){return async i=>{let a=t.map(g=>Au(g,i,e)),c=await n.generateProviderResponse(a,o),m=_f(c);return {input:Tu(a),output:m}}}function _f(n){return n&&typeof n=="object"?"text"in n&&typeof n.text=="string"?n.text:"content"in n&&typeof n.content=="string"?n.content:JSON.stringify(n):String(n)}var pe=class{constructor(t,e=true){if(this.name=t,this.trackMetric=e,e){let o=this.score.bind(this);this.score=Se({name:this.name,type:we.General},o);}}};var Tf=Tm__default.default.object({output:Tm__default.default.unknown(),expected:Tm__default.default.unknown()}),Eu=class extends pe{constructor(e="exact_match",o=true){super(e,o);this.validationSchema=Tf;}async score(e){let{output:o,expected:i}=e,a=o===i?1:0;return {name:this.name,value:a,reason:`Exact match: ${a===1?"Match":"No match"}`}}};var Af=Tm__default.default.object({output:Tm__default.default.string(),substring:Tm__default.default.string()}),Pu=class extends pe{constructor(e="contains",o=true,i=false){super(e,o);this.validationSchema=Af;this.caseSensitive=i;}async score(e){let{output:o,substring:i}=e,a=this.caseSensitive?o:o.toLowerCase(),c=this.caseSensitive?i:i.toLowerCase();return a.includes(c)?{name:this.name,value:1,reason:`Contains: "${i}" found in output.`}:{name:this.name,value:0,reason:`Contains: "${i}" not found in output.`}}};var Ef=Tm.z.object({output:Tm.z.string(),pattern:Tm.z.string(),flags:Tm.z.string().optional()}),vu=class extends pe{constructor(e="regex_match",o=true){super(e,o);this.validationSchema=Ef;}async score(e){let{output:o,pattern:i,flags:a}=e,c;typeof i=="string"&&a?c=new RegExp(i,a):c=new RegExp(i);let m=c.test(o);return {name:this.name,value:m?1:0,reason:m?`Regex: Output matches the regex pattern: ${i}`:`Regex: Output does not match the regex pattern: ${i}`}}};var Pf=Tm__default.default.object({output:Tm__default.default.unknown()}),Iu=class extends pe{constructor(e="is_json_metric",o=true){super(e,o);this.validationSchema=Pf;}async score(e){let{output:o}=e;try{return JSON.parse(o),{name:this.name,value:1,reason:"IsJson: Output is valid JSON."}}catch{return {name:this.name,value:0,reason:"IsJson: Output is not valid JSON"}}}};var ue=class extends pe{constructor(t,e){var i;let o=(i=e==null?void 0:e.trackMetric)!=null?i:true;super(t,o),this.temperature=e==null?void 0:e.temperature,this.seed=e==null?void 0:e.seed,this.maxTokens=e==null?void 0:e.maxTokens,this.modelSettings=e==null?void 0:e.modelSettings,this.model=this.initModel(e==null?void 0:e.model,{trackGenerations:o});}initModel(t,e){return yt(t,e)}buildModelOptions(){return {...this.modelSettings,...this.temperature!==void 0&&{temperature:this.temperature},...this.seed!==void 0&&{seed:this.seed},...this.maxTokens!==void 0&&{maxTokens:this.maxTokens}}}};function ju(n,t=[]){let e="";return t.length>0&&(e=`
26
26
 
27
27
  ###EXAMPLES###
28
28
 
@@ -84,7 +84,7 @@ ${e}
84
84
  Analyze the following text and provide your verdict score, and reason in the specified JSON format:
85
85
 
86
86
  ${n}
87
- `}var ja=class n extends Error{constructor(t){super(t),this.name="MetricError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},ce=class n extends ja{constructor(e,o){super(e);this.cause=o;this.name="MetricComputationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},Ua=class n extends ja{constructor(e,o){super(e);this.cause=o;this.name="JSONParsingError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}};function ve(n){try{return JSON.parse(n)}catch{return Sh(n)}}function Sh(n){try{let t=n.indexOf("{"),e=n.lastIndexOf("}");if(t===-1||e===-1||t>=e)throw new Error("No valid JSON object found in content");let o=n.substring(t,e+1);return JSON.parse(o)}catch(t){let e=t instanceof Error?t.message:String(t);throw new Ua(`Failed to extract JSON from content: ${e}`,t instanceof Error?t:void 0)}}function Au(n,t){try{let e=ve(n),o=Number(e.score);if(isNaN(o)||o<0||o>1)throw new Error(`Moderation score must be between 0.0 and 1.0, got ${o}`);return {name:t,value:o,reason:String(e.reason||"")}}catch(e){let o=e instanceof Error?e.message:String(e);throw z.error(`Failed to parse model output: ${o}`),new ce("Failed to calculate moderation score. The model output could not be parsed.",e instanceof Error?e:void 0)}}var xh=bm.z.object({output:bm.z.string()}),_h=bm.z.object({score:bm.z.number(),reason:bm.z.string()}),Na=class extends ue{constructor(e){var i,a;let o=(i=e==null?void 0:e.name)!=null?i:"moderation_metric";super(o,{model:e==null?void 0:e.model,trackMetric:e==null?void 0:e.trackMetric,temperature:e==null?void 0:e.temperature,seed:e==null?void 0:e.seed,maxTokens:e==null?void 0:e.maxTokens,modelSettings:e==null?void 0:e.modelSettings});this.validationSchema=xh;this.fewShotExamples=(a=e==null?void 0:e.fewShotExamples)!=null?a:[];}async score(e){let{output:o}=e,i=Tu(o,this.fewShotExamples),a=this.buildModelOptions(),c=await this.model.generateString(i,_h,a);return Au(c,this.name)}};function Eu(n,t){return `
87
+ `}var Wa=class n extends Error{constructor(t){super(t),this.name="MetricError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},ce=class n extends Wa{constructor(e,o){super(e);this.cause=o;this.name="MetricComputationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},Ba=class n extends Wa{constructor(e,o){super(e);this.cause=o;this.name="JSONParsingError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}};function Ce(n){try{return JSON.parse(n)}catch{return vf(n)}}function vf(n){try{let t=n.indexOf("{"),e=n.lastIndexOf("}");if(t===-1||e===-1||t>=e)throw new Error("No valid JSON object found in content");let o=n.substring(t,e+1);return JSON.parse(o)}catch(t){let e=t instanceof Error?t.message:String(t);throw new Ba(`Failed to extract JSON from content: ${e}`,t instanceof Error?t:void 0)}}function Uu(n,t){try{let e=Ce(n),o=Number(e.score);if(isNaN(o)||o<0||o>1)throw new Error(`Moderation score must be between 0.0 and 1.0, got ${o}`);return {name:t,value:o,reason:String(e.reason||"")}}catch(e){let o=e instanceof Error?e.message:String(e);throw z.error(`Failed to parse model output: ${o}`),new ce("Failed to calculate moderation score. The model output could not be parsed.",e instanceof Error?e:void 0)}}var Cf=Tm.z.object({output:Tm.z.string()}),If=Tm.z.object({score:Tm.z.number(),reason:Tm.z.string()}),La=class extends ue{constructor(e){var i,a;let o=(i=e==null?void 0:e.name)!=null?i:"moderation_metric";super(o,{model:e==null?void 0:e.model,trackMetric:e==null?void 0:e.trackMetric,temperature:e==null?void 0:e.temperature,seed:e==null?void 0:e.seed,maxTokens:e==null?void 0:e.maxTokens,modelSettings:e==null?void 0:e.modelSettings});this.validationSchema=Cf;this.fewShotExamples=(a=e==null?void 0:e.fewShotExamples)!=null?a:[];}async score(e){let{output:o}=e,i=ju(o,this.fewShotExamples),a=this.buildModelOptions(),c=await this.model.generateString(i,If,a);return Uu(c,this.name)}};function Nu(n,t){return `
88
88
  You are an impartial judge tasked with evaluating the quality and usefulness of AI-generated responses.
89
89
  Your evaluation should consider the following key factors:
90
90
  - Helpfulness: How well does it solve the user's problem?
@@ -120,7 +120,7 @@ ${n}
120
120
  AI Response: ${t}
121
121
 
122
122
  Provide your evaluation in the specified JSON format.
123
- `}function Pu(n,t){try{let e=ve(n),o=Number(e.score);if(isNaN(o)||o<0||o>1)throw new Error(`Usefulness score must be between 0.0 and 1.0, got ${o}`);return {name:t,value:o,reason:String(e.reason||"")}}catch(e){let o=e instanceof Error?e.message:String(e);throw z.error(`Failed to parse model output: ${o}`),new ce("Failed to calculate usefulness score. The model output could not be parsed.",e instanceof Error?e:void 0)}}var Th=bm.z.object({input:bm.z.string(),output:bm.z.string()}),Ah=bm.z.object({score:bm.z.number(),reason:bm.z.string()}),Ma=class extends ue{constructor(e){var i;let o=(i=e==null?void 0:e.name)!=null?i:"usefulness_metric";super(o,{model:e==null?void 0:e.model,trackMetric:e==null?void 0:e.trackMetric,temperature:e==null?void 0:e.temperature,seed:e==null?void 0:e.seed,maxTokens:e==null?void 0:e.maxTokens,modelSettings:e==null?void 0:e.modelSettings});this.validationSchema=Th;}async score(e){let{input:o,output:i}=e,a=Eu(o,i),c=this.buildModelOptions(),d=await this.model.generateString(a,Ah,c);return Pu(d,this.name)}};var Eh=`You are an expert judge tasked with evaluating the faithfulness of an AI-generated answer to the given context. Analyze the provided INPUT, CONTEXT, and OUTPUT to determine if the OUTPUT contains any hallucinations or unfaithful information.
123
+ `}function Mu(n,t){try{let e=Ce(n),o=Number(e.score);if(isNaN(o)||o<0||o>1)throw new Error(`Usefulness score must be between 0.0 and 1.0, got ${o}`);return {name:t,value:o,reason:String(e.reason||"")}}catch(e){let o=e instanceof Error?e.message:String(e);throw z.error(`Failed to parse model output: ${o}`),new ce("Failed to calculate usefulness score. The model output could not be parsed.",e instanceof Error?e:void 0)}}var jf=Tm.z.object({input:Tm.z.string(),output:Tm.z.string()}),Uf=Tm.z.object({score:Tm.z.number(),reason:Tm.z.string()}),Va=class extends ue{constructor(e){var i;let o=(i=e==null?void 0:e.name)!=null?i:"usefulness_metric";super(o,{model:e==null?void 0:e.model,trackMetric:e==null?void 0:e.trackMetric,temperature:e==null?void 0:e.temperature,seed:e==null?void 0:e.seed,maxTokens:e==null?void 0:e.maxTokens,modelSettings:e==null?void 0:e.modelSettings});this.validationSchema=jf;}async score(e){let{input:o,output:i}=e,a=Nu(o,i),c=this.buildModelOptions(),m=await this.model.generateString(a,Uf,c);return Mu(m,this.name)}};var Nf=`You are an expert judge tasked with evaluating the faithfulness of an AI-generated answer to the given context. Analyze the provided INPUT, CONTEXT, and OUTPUT to determine if the OUTPUT contains any hallucinations or unfaithful information.
124
124
 
125
125
  Guidelines:
126
126
  1. The OUTPUT must not introduce new information beyond what's provided in the CONTEXT.
@@ -155,7 +155,7 @@ It is crucial that you provide your answer in the following JSON format:
155
155
  "reason": ["reason 1", "reason 2"]
156
156
  }}
157
157
  Reasons amount is not restricted. Output must be JSON format only.
158
- `,Ph=`You are an expert judge tasked with evaluating the factual accuracy and reliability of an AI-generated answer. Analyze the provided INPUT, and OUTPUT to determine if the OUTPUT contains any hallucinations or unfaithful information.
158
+ `,Mf=`You are an expert judge tasked with evaluating the factual accuracy and reliability of an AI-generated answer. Analyze the provided INPUT, and OUTPUT to determine if the OUTPUT contains any hallucinations or unfaithful information.
159
159
 
160
160
  Guidelines:
161
161
  1. Evaluate the OUTPUT based on generally accepted facts and reliable information.
@@ -186,7 +186,7 @@ It is crucial that you provide your answer in the following JSON format:
186
186
  "reason": ["some reason 1", "some reason 2"]
187
187
  }}
188
188
  Reasons amount is not restricted. Output must be JSON format only.
189
- `;function vu(n,t){return n.length===0?"":`
189
+ `;function Du(n,t){return n.length===0?"":`
190
190
 
191
191
  EXAMPLES:
192
192
 
@@ -198,7 +198,7 @@ ${i}Output: ${o.output}
198
198
  {"score": "${o.score}", "reason": "${o.reason}"}
199
199
  </example>`}).join(`
200
200
 
201
- `)}`}function Cu(n,t,e,o=[]){let i=vu(o,true);return Eh.replace("{examples_str}",i).replace("{input}",n).replace("{context}",JSON.stringify(e)).replace("{output}",t)}function Iu(n,t,e=[]){let o=vu(e,false);return Ph.replace("{examples_str}",o).replace("{input}",n).replace("{output}",t)}function ju(n,t){try{let e=ve(n),o=e.score;if(o==null)throw new Error(`Hallucination score is required but got ${o}`);let i=Number(o);if(isNaN(i)||i<0||i>1)throw new Error(`Hallucination score must be between 0.0 and 1.0, got ${i}`);let a="",c=e.reason;return Array.isArray(c)?a=c.map(d=>String(d)).join(" "):c&&(a=String(c)),{name:t,value:i,reason:a}}catch(e){let o=e instanceof Error?e.message:String(e);throw z.error(`Failed to parse model output: ${o}`),new ce("Failed to calculate hallucination score. The model output could not be parsed.",e instanceof Error?e:void 0)}}var vh=bm.z.object({input:bm.z.string(),output:bm.z.string(),context:bm.z.array(bm.z.string()).optional()}),Ch=bm.z.object({score:bm.z.number(),reason:bm.z.union([bm.z.string(),bm.z.array(bm.z.string())])}),Da=class extends ue{constructor(e){var i,a;let o=(i=e==null?void 0:e.name)!=null?i:"hallucination_metric";super(o,{model:e==null?void 0:e.model,trackMetric:e==null?void 0:e.trackMetric,temperature:e==null?void 0:e.temperature,seed:e==null?void 0:e.seed,maxTokens:e==null?void 0:e.maxTokens,modelSettings:e==null?void 0:e.modelSettings});this.validationSchema=vh;this.fewShotExamples=(a=e==null?void 0:e.fewShotExamples)!=null?a:[];}async score(e){let{input:o,output:i,context:a}=e,c=a?Cu(o,i,a,this.fewShotExamples):Iu(o,i,this.fewShotExamples),d=this.buildModelOptions(),u=await this.model.generateString(c,Ch,d);return ju(u,this.name)}};var Uu=[{title:"Low Relevance Score",input:"What's the capital of France?",output:"The Eiffel Tower is a famous landmark.",context:["France is a country in Europe.","Paris is known for its iconic Eiffel Tower."],answer_relevance_score:.2,reason:"The answer provides information about the Eiffel Tower, which is related to France, but fails to address the specific question about the capital city. It doesn't directly answer the user's query, resulting in low relevance."},{title:"Medium Relevance Score",input:"What's the capital of France?",output:"France has many beautiful cities, including Paris.",context:["France is a country in Europe.","Paris is the capital and largest city of France."],answer_relevance_score:.6,reason:"The answer mentions Paris, which is the correct capital, but it's presented as just one of many cities rather than explicitly stating it's the capital. The response is partially relevant but lacks directness in addressing the specific question."},{title:"High Relevance Score",input:"What's the capital of France?",output:"The capital of France is Paris, a city known for its iconic Eiffel Tower.",context:["France is a country in Europe.","Paris is the capital and largest city of France."],answer_relevance_score:.9,reason:"The answer directly and correctly identifies Paris as the capital of France, which is highly relevant to the user's question. It also provides additional context about the Eiffel Tower, which aligns with the provided context. The response is comprehensive and relevant, though slightly more detailed than necessary, preventing a perfect score."}],Nu=[{title:"Low Relevance Score",input:"What's the capital of France?",output:"The Eiffel Tower is a famous landmark.",answer_relevance_score:.2,reason:"The answer provides information about the Eiffel Tower, which is related to France, but fails to address the specific question about the capital city. It doesn't directly answer the user's query, resulting in low relevance."},{title:"Medium Relevance Score",input:"What's the capital of France?",output:"France has many beautiful cities, including Paris.",answer_relevance_score:.6,reason:"The answer mentions Paris, which is the correct capital, but it's presented as just one of many cities rather than explicitly stating it's the capital. The response is partially relevant but lacks directness in addressing the specific question."},{title:"High Relevance Score",input:"What's the capital of France?",output:"The capital of France is Paris, a city known for its iconic Eiffel Tower.",answer_relevance_score:.9,reason:"The answer directly and correctly identifies Paris as the capital of France, which is highly relevant to the user's question. It also provides additional context about the Eiffel Tower, which aligns with the provided context. The response is comprehensive and relevant, though slightly more detailed than necessary, preventing a perfect score."}];function Ih(n){return n.map((t,e)=>`#### Example ${e+1}: ${t.title}
201
+ `)}`}function Fu(n,t,e,o=[]){let i=Du(o,true);return Nf.replace("{examples_str}",i).replace("{input}",n).replace("{context}",JSON.stringify(e)).replace("{output}",t)}function Ou(n,t,e=[]){let o=Du(e,false);return Mf.replace("{examples_str}",o).replace("{input}",n).replace("{output}",t)}function Wu(n,t){try{let e=Ce(n),o=e.score;if(o==null)throw new Error(`Hallucination score is required but got ${o}`);let i=Number(o);if(isNaN(i)||i<0||i>1)throw new Error(`Hallucination score must be between 0.0 and 1.0, got ${i}`);let a="",c=e.reason;return Array.isArray(c)?a=c.map(m=>String(m)).join(" "):c&&(a=String(c)),{name:t,value:i,reason:a}}catch(e){let o=e instanceof Error?e.message:String(e);throw z.error(`Failed to parse model output: ${o}`),new ce("Failed to calculate hallucination score. The model output could not be parsed.",e instanceof Error?e:void 0)}}var Df=Tm.z.object({input:Tm.z.string(),output:Tm.z.string(),context:Tm.z.array(Tm.z.string()).optional()}),Ff=Tm.z.object({score:Tm.z.number(),reason:Tm.z.union([Tm.z.string(),Tm.z.array(Tm.z.string())])}),Ha=class extends ue{constructor(e){var i,a;let o=(i=e==null?void 0:e.name)!=null?i:"hallucination_metric";super(o,{model:e==null?void 0:e.model,trackMetric:e==null?void 0:e.trackMetric,temperature:e==null?void 0:e.temperature,seed:e==null?void 0:e.seed,maxTokens:e==null?void 0:e.maxTokens,modelSettings:e==null?void 0:e.modelSettings});this.validationSchema=Df;this.fewShotExamples=(a=e==null?void 0:e.fewShotExamples)!=null?a:[];}async score(e){let{input:o,output:i,context:a}=e,c=a?Fu(o,i,a,this.fewShotExamples):Ou(o,i,this.fewShotExamples),m=this.buildModelOptions(),u=await this.model.generateString(c,Ff,m);return Wu(u,this.name)}};var Bu=[{title:"Low Relevance Score",input:"What's the capital of France?",output:"The Eiffel Tower is a famous landmark.",context:["France is a country in Europe.","Paris is known for its iconic Eiffel Tower."],answer_relevance_score:.2,reason:"The answer provides information about the Eiffel Tower, which is related to France, but fails to address the specific question about the capital city. It doesn't directly answer the user's query, resulting in low relevance."},{title:"Medium Relevance Score",input:"What's the capital of France?",output:"France has many beautiful cities, including Paris.",context:["France is a country in Europe.","Paris is the capital and largest city of France."],answer_relevance_score:.6,reason:"The answer mentions Paris, which is the correct capital, but it's presented as just one of many cities rather than explicitly stating it's the capital. The response is partially relevant but lacks directness in addressing the specific question."},{title:"High Relevance Score",input:"What's the capital of France?",output:"The capital of France is Paris, a city known for its iconic Eiffel Tower.",context:["France is a country in Europe.","Paris is the capital and largest city of France."],answer_relevance_score:.9,reason:"The answer directly and correctly identifies Paris as the capital of France, which is highly relevant to the user's question. It also provides additional context about the Eiffel Tower, which aligns with the provided context. The response is comprehensive and relevant, though slightly more detailed than necessary, preventing a perfect score."}],Lu=[{title:"Low Relevance Score",input:"What's the capital of France?",output:"The Eiffel Tower is a famous landmark.",answer_relevance_score:.2,reason:"The answer provides information about the Eiffel Tower, which is related to France, but fails to address the specific question about the capital city. It doesn't directly answer the user's query, resulting in low relevance."},{title:"Medium Relevance Score",input:"What's the capital of France?",output:"France has many beautiful cities, including Paris.",answer_relevance_score:.6,reason:"The answer mentions Paris, which is the correct capital, but it's presented as just one of many cities rather than explicitly stating it's the capital. The response is partially relevant but lacks directness in addressing the specific question."},{title:"High Relevance Score",input:"What's the capital of France?",output:"The capital of France is Paris, a city known for its iconic Eiffel Tower.",answer_relevance_score:.9,reason:"The answer directly and correctly identifies Paris as the capital of France, which is highly relevant to the user's question. It also provides additional context about the Eiffel Tower, which aligns with the provided context. The response is comprehensive and relevant, though slightly more detailed than necessary, preventing a perfect score."}];function Of(n){return n.map((t,e)=>`#### Example ${e+1}: ${t.title}
202
202
 
203
203
  - **Input:** "${t.input}"
204
204
  - **Output:** "${t.output}"
@@ -211,7 +211,7 @@ ${i}Output: ${o.output}
211
211
  }
212
212
  \`\`\``).join(`
213
213
 
214
- `)}function jh(n){return n.map((t,e)=>`#### Example ${e+1}: ${t.title}
214
+ `)}function Wf(n){return n.map((t,e)=>`#### Example ${e+1}: ${t.title}
215
215
 
216
216
  - **Input:** "${t.input}"
217
217
  - **Output:** "${t.output}"
@@ -223,7 +223,7 @@ ${i}Output: ${o.output}
223
223
  }
224
224
  \`\`\``).join(`
225
225
 
226
- `)}function Mu(n,t,e,o){return `
226
+ `)}function Vu(n,t,e,o){return `
227
227
  YOU ARE AN EXPERT IN NLP EVALUATION METRICS, SPECIALLY TRAINED TO ASSESS ANSWER RELEVANCE IN RESPONSES
228
228
  PROVIDED BY LANGUAGE MODELS. YOUR TASK IS TO EVALUATE THE RELEVANCE OF A GIVEN ANSWER FROM
229
229
  ANOTHER LLM BASED ON THE USER'S INPUT AND CONTEXT PROVIDED.
@@ -269,7 +269,7 @@ ${i}Output: ${o.output}
269
269
 
270
270
  ###FEW-SHOT EXAMPLES###
271
271
 
272
- ${Ih(o)}
272
+ ${Of(o)}
273
273
 
274
274
  ###INPUTS:###
275
275
  ***
@@ -282,7 +282,7 @@ ${i}Output: ${o.output}
282
282
  Context:
283
283
  ${JSON.stringify(e)}
284
284
  ***
285
- `}function Du(n,t,e){return `
285
+ `}function Hu(n,t,e){return `
286
286
  YOU ARE AN EXPERT IN NLP EVALUATION METRICS, SPECIALLY TRAINED TO ASSESS ANSWER RELEVANCE IN RESPONSES
287
287
  PROVIDED BY LANGUAGE MODELS. YOUR TASK IS TO EVALUATE THE RELEVANCE OF A GIVEN ANSWER FROM
288
288
  ANOTHER LLM BASED ON THE USER'S INPUT.
@@ -327,7 +327,7 @@ ${i}Output: ${o.output}
327
327
 
328
328
  ###FEW-SHOT EXAMPLES###
329
329
 
330
- ${jh(e)}
330
+ ${Wf(e)}
331
331
 
332
332
  ###INPUTS:###
333
333
  ***
@@ -337,4 +337,4 @@ ${i}Output: ${o.output}
337
337
  Output:
338
338
  ${t}
339
339
  ***
340
- `}function Fu(n,t){try{let e=ve(n),o=e.answer_relevance_score;if(o==null)throw new Error(`Answer relevance score is required but got ${o}`);let i=Number(o);if(isNaN(i)||i<0||i>1)throw new Error(`Answer relevance score must be between 0.0 and 1.0, got ${i}`);return {name:t,value:i,reason:String(e.reason||"")}}catch(e){let o=e instanceof Error?e.message:String(e);throw z.error(`Failed to parse model output: ${o}`),new ce("Failed to calculate answer relevance score. The model output could not be parsed.",e instanceof Error?e:void 0)}}var Uh=bm.z.object({input:bm.z.string(),output:bm.z.string(),context:bm.z.array(bm.z.string()).optional()}),Nh=bm.z.object({answer_relevance_score:bm.z.number(),reason:bm.z.string()}),Fa=class extends ue{constructor(e){var i,a,c,d;let o=(i=e==null?void 0:e.name)!=null?i:"answer_relevance_metric";super(o,{model:e==null?void 0:e.model,trackMetric:e==null?void 0:e.trackMetric,temperature:e==null?void 0:e.temperature,seed:e==null?void 0:e.seed,maxTokens:e==null?void 0:e.maxTokens,modelSettings:e==null?void 0:e.modelSettings});this.validationSchema=Uh;this.fewShotExamplesWithContext=(a=e==null?void 0:e.fewShotExamples)!=null?a:Uu,this.fewShotExamplesNoContext=(c=e==null?void 0:e.fewShotExamplesNoContext)!=null?c:Nu,this.requireContext=(d=e==null?void 0:e.requireContext)!=null?d:true;}async score(e){let{input:o,output:i,context:a}=e;if(!a&&this.requireContext)throw new ce(`${this.name} requires context by default. If you want to allow execution in no-context mode, enable it via 'new AnswerRelevance({ requireContext: false })'`);let c=a?Mu(o,i,a,this.fewShotExamplesWithContext):Du(o,i,this.fewShotExamplesNoContext),d=this.buildModelOptions(),u=await this.model.generateString(c,Nh,d);return Fu(u,this.name)}};exports.AnswerRelevance=Fa;exports.BaseLLMJudgeMetric=ue;exports.BaseMetric=pe;exports.Contains=zu;exports.ExactMatch=ku;exports.Hallucination=Da;exports.IsJson=_u;exports.ModelConfigurationError=Pe;exports.ModelError=gt;exports.ModelGenerationError=or;exports.Moderation=Na;exports.Opik=Oe;exports.OpikBaseModel=We;exports.OpikQueryLanguage=Ee;exports.OpikSpanType=we;exports.Prompt=Te;exports.PromptType=de;exports.RegexMatch=Su;exports.Usefulness=Ma;exports.VercelAIChatModel=tr;exports.createModel=Rm;exports.createModelFromInstance=Ru;exports.detectProvider=fm;exports.disableLogger=Gu;exports.evaluate=gu;exports.evaluatePrompt=mre;exports.flushAll=Xf;exports.generateId=Z;exports.getTrackContext=Vf;exports.logger=z;exports.resolveModel=wt;exports.setLoggerLevel=Pm;exports.track=ze;
340
+ `}function Ju(n,t){try{let e=Ce(n),o=e.answer_relevance_score;if(o==null)throw new Error(`Answer relevance score is required but got ${o}`);let i=Number(o);if(isNaN(i)||i<0||i>1)throw new Error(`Answer relevance score must be between 0.0 and 1.0, got ${i}`);return {name:t,value:i,reason:String(e.reason||"")}}catch(e){let o=e instanceof Error?e.message:String(e);throw z.error(`Failed to parse model output: ${o}`),new ce("Failed to calculate answer relevance score. The model output could not be parsed.",e instanceof Error?e:void 0)}}var Bf=Tm.z.object({input:Tm.z.string(),output:Tm.z.string(),context:Tm.z.array(Tm.z.string()).optional()}),Lf=Tm.z.object({answer_relevance_score:Tm.z.number(),reason:Tm.z.string()}),Ja=class extends ue{constructor(e){var i,a,c,m;let o=(i=e==null?void 0:e.name)!=null?i:"answer_relevance_metric";super(o,{model:e==null?void 0:e.model,trackMetric:e==null?void 0:e.trackMetric,temperature:e==null?void 0:e.temperature,seed:e==null?void 0:e.seed,maxTokens:e==null?void 0:e.maxTokens,modelSettings:e==null?void 0:e.modelSettings});this.validationSchema=Bf;this.fewShotExamplesWithContext=(a=e==null?void 0:e.fewShotExamples)!=null?a:Bu,this.fewShotExamplesNoContext=(c=e==null?void 0:e.fewShotExamplesNoContext)!=null?c:Lu,this.requireContext=(m=e==null?void 0:e.requireContext)!=null?m:true;}async score(e){let{input:o,output:i,context:a}=e;if(!a&&this.requireContext)throw new ce(`${this.name} requires context by default. If you want to allow execution in no-context mode, enable it via 'new AnswerRelevance({ requireContext: false })'`);let c=a?Vu(o,i,a,this.fewShotExamplesWithContext):Hu(o,i,this.fewShotExamplesNoContext),m=this.buildModelOptions(),u=await this.model.generateString(c,Lf,m);return Ju(u,this.name)}};exports.AnswerRelevance=Ja;exports.BaseLLMJudgeMetric=ue;exports.BaseMetric=pe;exports.Contains=Pu;exports.ExactMatch=Eu;exports.Hallucination=Ha;exports.IsJson=Iu;exports.ModelConfigurationError=ve;exports.ModelError=bt;exports.ModelGenerationError=ar;exports.Moderation=La;exports.Opik=Le;exports.OpikBaseModel=Ve;exports.OpikQueryLanguage=Pe;exports.OpikSpanType=we;exports.Prompt=Ae;exports.PromptType=de;exports.RegexMatch=vu;exports.Usefulness=Va;exports.VercelAIChatModel=nr;exports.createModel=_m;exports.createModelFromInstance=_u;exports.detectProvider=Sm;exports.disableLogger=rg;exports.evaluate=ku;exports.evaluatePrompt=Kre;exports.flushAll=qh;exports.generateId=Z;exports.getTrackContext=$h;exports.logger=z;exports.resolveModel=yt;exports.setLoggerLevel=Mm;exports.track=Se;