opik 1.9.6 → 1.9.8

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,27 +1,27 @@
1
- 'use strict';var ansiEscapes=require('ansi-escapes'),tslog=require('tslog'),wm=require('fs'),Fu=require('ini');require('dotenv/config');var yw=require('qs'),uuid=require('uuid'),wh=require('fast-json-stable-stringify'),gh=require('xxhash-wasm'),util=require('util'),yh=require('mustache'),Sh=require('nunjucks'),dateFns=require('date-fns'),jestDiff=require('jest-diff'),Th=require('fast-deep-equal'),async_hooks=require('async_hooks'),Aa=require('chalk'),Dh=require('boxen'),Fh=require('ora'),ai$1=require('ai'),openai=require('@ai-sdk/openai'),anthropic=require('@ai-sdk/anthropic'),google=require('@ai-sdk/google'),im=require('zod');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var wm__default=/*#__PURE__*/_interopDefault(wm);var Fu__default=/*#__PURE__*/_interopDefault(Fu);var yw__default=/*#__PURE__*/_interopDefault(yw);var wh__default=/*#__PURE__*/_interopDefault(wh);var gh__default=/*#__PURE__*/_interopDefault(gh);var yh__default=/*#__PURE__*/_interopDefault(yh);var Sh__default=/*#__PURE__*/_interopDefault(Sh);var Th__default=/*#__PURE__*/_interopDefault(Th);var Aa__default=/*#__PURE__*/_interopDefault(Aa);var Dh__default=/*#__PURE__*/_interopDefault(Dh);var Fh__default=/*#__PURE__*/_interopDefault(Fh);var im__default=/*#__PURE__*/_interopDefault(im);var Eu=Object.create;var wt=Object.defineProperty;var Pu=Object.getOwnPropertyDescriptor;var cm=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),nr=n=>{throw TypeError(n)};var vu=(n,t,e)=>t in n?wt(n,t,{enumerable:true,configurable:true,writable:true,value:e}):n[t]=e;var Fa=(n,t)=>()=>(n&&(t=n(n=0)),t);var P=(n,t)=>{for(var e in t)wt(n,e,{get:t[e],enumerable:true});};var lm=n=>{var t;return [,,,Eu((t=void 0)!=null?t:null)]},mm=["class","method","getter","setter","accessor","field","value","get","set"],ar=n=>n!==void 0&&typeof n!="function"?nr("Function expected"):n,Cu=(n,t,e,o,i)=>({kind:mm[n],name:t,metadata:o,addInitializer:a=>e._?nr("Already initialized"):i.push(ar(a||null))}),Oa=(n,t)=>vu(t,cm("metadata"),n[3]),dm=(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},um=(n,t,e,o,i,a)=>{var m,u,g,y,k=t&7,S=false,x=false,_=2,M=mm[k+5],J=n[_]||(n[_]=[]),q=((i=i.prototype),Pu(i,e));for(var We=o.length-1;We>=0;We--)g=Cu(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),m=(0, o[We])(q[M],g),u._=1,ar(m)&&(q[M]=m);return q&&wt(i,e,q),i};var Km={};P(Km,{Node18UniversalStreamWrapper:()=>tn});var tn,Xm=Fa(()=>{tn=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 Gm={};P(Gm,{UndiciStreamWrapper:()=>an});var an,$m=Fa(()=>{an=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 Qm={};P(Qm,{NodePre18StreamWrapper:()=>nn});var nn,Ym=Fa(()=>{nn=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 Mu={SILLY:0,TRACE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,FATAL:6};function ht(n,t=n){return ansiEscapes.link(t,n)}var z=new tslog.Logger({hideLogPositionForProduction:true,prettyLogTemplate:"{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}} {{logLevelName}} "}),gm=n=>{z.settings.minLevel=Mu[n];},Du=()=>{z.settings.minLevel=100;};gm(process.env.OPIK_LOG_LEVEL||"INFO");var Ou="~/.opik.config",Ba={apiKey:"",apiUrl:"https://www.comet.com/opik/api",projectName:"Default Project",workspaceName:"default",batchDelayMs:300,holdUntilFlush:false};function hm(n){return Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0))}function Wu(){return hm({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 Bu(){let n=process.env.OPIK_CONFIG_PATH||Ou;if(!wm__default.default.existsSync(n)){if(process.env.OPIK_CONFIG_PATH)throw new Error(`Config file not found at ${n}`);return {}}try{let t=Fu__default.default.parse(wm__default.default.readFileSync(n,"utf8"));return t.opik?hm({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 fm(n){let t=Wu(),e=Bu(),{headers:o,...i}=n||{};return Lu({...Ba,...e,...t,...i})}function Lu(n){if(!n.apiUrl)throw new Error("OPIK_URL_OVERRIDE is not set");let t=Vu(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 Vu(n){return new URL(n).hostname.endsWith("comet.com")}var X={};P(X,{AlertAlertType:()=>Hu,AlertPublicAlertType:()=>Zu,AlertTriggerConfigPublicType:()=>Qu,AlertTriggerConfigType:()=>Ku,AlertTriggerConfigWriteType:()=>Xu,AlertTriggerEventType:()=>Ju,AlertTriggerPublicEventType:()=>Yu,AlertTriggerWriteEventType:()=>Gu,AlertWriteAlertType:()=>$u,AnnotationQueuePublicScope:()=>og,AnnotationQueueScope:()=>eg,AnnotationQueueWriteScope:()=>rg,AssistantMessageRole:()=>wg,AttachmentListRequestEntityType:()=>bm,BadRequestError:()=>T,CheckName:()=>jg,CheckPublicName:()=>uw,CheckPublicResult:()=>gw,CheckResult:()=>Ug,ColumnCompareTypesItem:()=>zg,ColumnPublicTypesItem:()=>vg,ColumnTypesItem:()=>Cg,CompleteMultipartUploadRequestEntityType:()=>tg,ConflictError:()=>L,DatasetItemCompareSource:()=>Sg,DatasetItemPublicSource:()=>Eg,DatasetItemSource:()=>Rg,DatasetItemWriteSource:()=>rn,DatasetPublicVisibility:()=>Ag,DatasetUpdateVisibility:()=>xm,DatasetVisibility:()=>fg,DatasetWriteVisibility:()=>Sm,DeleteAttachmentsRequestEntityType:()=>ig,DownloadAttachmentRequestEntityType:()=>ym,ExperimentItemCompareTraceVisibilityMode:()=>xg,ExperimentItemPublicTraceVisibilityMode:()=>Pg,ExperimentItemTraceVisibilityMode:()=>bg,ExperimentPublicStatus:()=>Wg,ExperimentPublicType:()=>Og,ExperimentStatus:()=>Ig,ExperimentType:()=>on,ExperimentUpdateStatus:()=>Em,ExperimentUpdateType:()=>Am,ExperimentWriteStatus:()=>Tm,ExperimentWriteType:()=>_m,FeedbackScoreBatchItemSource:()=>mw,FeedbackScoreBatchItemThreadSource:()=>fw,FeedbackScoreCompareSource:()=>_g,FeedbackScoreExperimentItemBulkWriteViewSource:()=>Mg,FeedbackScorePublicSource:()=>pw,FeedbackScoreSource:()=>yg,FindFeedbackDefinitionsRequestType:()=>Pm,FindFeedbackScoreNames1RequestType:()=>Om,ForbiddenError:()=>$,GetSpanStatsRequestType:()=>Wm,GetSpansByProjectRequestType:()=>Dm,GetWebhookExamplesRequestAlertType:()=>Rm,GuardrailName:()=>Bg,GuardrailResult:()=>Lg,GuardrailWriteName:()=>Vg,GuardrailWriteResult:()=>Hg,LlmAsJudgeMessagePublicRole:()=>mg,LlmAsJudgeMessageRole:()=>ag,LlmAsJudgeMessageWriteRole:()=>pg,LlmAsJudgeOutputSchemaPublicType:()=>dg,LlmAsJudgeOutputSchemaType:()=>ng,LlmAsJudgeOutputSchemaWriteType:()=>cg,LogItemLevel:()=>gg,ManualEvaluationRequestEntityType:()=>Xg,NotFoundError:()=>A,NotImplementedError:()=>sr,OptimizationPublicStatus:()=>Qg,OptimizationStatus:()=>Gg,OptimizationUpdateStatus:()=>Cm,OptimizationWriteStatus:()=>$g,ProjectDetailedVisibility:()=>ow,ProjectMetricRequestPublicInterval:()=>Nm,ProjectMetricRequestPublicMetricType:()=>Um,ProjectMetricResponsePublicInterval:()=>ew,ProjectMetricResponsePublicMetricType:()=>qg,ProjectPublicVisibility:()=>Zg,ProjectUpdateVisibility:()=>jm,ProjectVisibility:()=>Yg,ProjectWriteVisibility:()=>Im,PromptType:()=>tw,PromptVersionDetailType:()=>aw,PromptVersionPublicType:()=>nw,PromptVersionType:()=>iw,PromptWriteType:()=>Mm,ProviderApiKeyProvider:()=>Kg,ProviderApiKeyPublicProvider:()=>Jg,ProviderApiKeyWriteProvider:()=>vm,ResponseFormatType:()=>hg,SpanExperimentItemBulkWriteViewType:()=>Dg,SpanFilterPublicOperator:()=>dw,SpanPublicType:()=>cw,SpanSearchStreamRequestPublicType:()=>Bm,SpanType:()=>we,SpanUpdateType:()=>Fm,SpanWriteType:()=>sw,StartMultipartUploadRequestEntityType:()=>km,TraceFilterOperator:()=>sg,TraceFilterPublicOperator:()=>ug,TraceFilterWriteOperator:()=>lg,TracePublicVisibilityMode:()=>ww,TraceThreadFilterOperator:()=>Rw,TraceThreadFilterPublicOperator:()=>rw,TraceThreadStatus:()=>hw,TraceVisibilityMode:()=>Ng,UnauthorizedError:()=>K,UnprocessableEntityError:()=>F,UploadAttachmentRequestEntityType:()=>zm,ValueEntryCompareSource:()=>Tg,ValueEntryExperimentItemBulkWriteViewSource:()=>Fg,ValueEntryPublicSource:()=>lw,ValueEntrySource:()=>kg,WebhookTestResultStatus:()=>qu,alerts:()=>ft,annotationQueues:()=>Va,attachments:()=>Rt,automationRuleEvaluators:()=>Ja,chatCompletions:()=>Ka,check:()=>Ha,datasets:()=>bt,experiments:()=>yt,feedbackDefinitions:()=>kt,guardrails:()=>Xa,llmProviderKey:()=>zt,manualEvaluation:()=>Ga,openTelemetryIngestion:()=>$a,optimizations:()=>St,projects:()=>xt,prompts:()=>_t,redirect:()=>en,serviceToggles:()=>Qa,spans:()=>Tt,systemUsage:()=>La,traces:()=>Ya,welcomeWizard:()=>Za,workspaces:()=>qa});var ft={};P(ft,{GetWebhookExamplesRequestAlertType:()=>Rm});var Rm={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var Rt={};P(Rt,{AttachmentListRequestEntityType:()=>bm,DownloadAttachmentRequestEntityType:()=>ym,StartMultipartUploadRequestEntityType:()=>km,UploadAttachmentRequestEntityType:()=>zm});var bm={Trace:"trace",Span:"span"};var ym={Trace:"trace",Span:"span"};var km={Trace:"trace",Span:"span"};var zm={Trace:"trace",Span:"span"};var bt={};P(bt,{DatasetUpdateVisibility:()=>xm,DatasetWriteVisibility:()=>Sm});var Sm={Private:"private",Public:"public"};var xm={Private:"private",Public:"public"};var yt={};P(yt,{ExperimentUpdateStatus:()=>Em,ExperimentUpdateType:()=>Am,ExperimentWriteStatus:()=>Tm,ExperimentWriteType:()=>_m});var _m={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Tm={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Am={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Em={Running:"running",Completed:"completed",Cancelled:"cancelled"};var kt={};P(kt,{FindFeedbackDefinitionsRequestType:()=>Pm});var Pm={Numerical:"numerical",Categorical:"categorical"};var zt={};P(zt,{ProviderApiKeyWriteProvider:()=>vm});var vm={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var St={};P(St,{OptimizationUpdateStatus:()=>Cm});var Cm={Running:"running",Completed:"completed",Cancelled:"cancelled"};var xt={};P(xt,{ProjectMetricRequestPublicInterval:()=>Nm,ProjectMetricRequestPublicMetricType:()=>Um,ProjectUpdateVisibility:()=>jm,ProjectWriteVisibility:()=>Im});var Im={Private:"private",Public:"public"};var jm={Private:"private",Public:"public"};var Um={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 Nm={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var _t={};P(_t,{PromptWriteType:()=>Mm});var Mm={Mustache:"mustache",Jinja2:"jinja2"};var Tt={};P(Tt,{FindFeedbackScoreNames1RequestType:()=>Om,GetSpanStatsRequestType:()=>Wm,GetSpansByProjectRequestType:()=>Dm,SpanSearchStreamRequestPublicType:()=>Bm,SpanUpdateType:()=>Fm});var Dm={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Fm={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Om={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Wm={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Bm={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var La={};var Va={};var Ha={};var Ja={};var Ka={};var Xa={};var Ga={};var $a={};var Qa={};var Ya={};var Za={};var qa={};var en={};var Hu={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var Ju={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 Ku={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score"};var Xu={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score"};var Gu={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 $u={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var Qu={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score"};var Yu={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 Zu={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var qu={Success:"success",Failure:"failure"};var eg={Trace:"trace",Thread:"thread"};var rg={Trace:"trace",Thread:"thread"};var og={Trace:"trace",Thread:"thread"};var tg={Trace:"trace",Span:"span"};var ig={Trace:"trace",Span:"span"};var ag={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var ng={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var sg={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 cg={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var lg={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 mg={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var dg={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var ug={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 gg={Info:"INFO",Warn:"WARN",Error:"ERROR",Debug:"DEBUG",Trace:"TRACE"};var wg={System:"system",User:"user",Assistant:"assistant",Tool:"tool",Function:"function"};var hg={Text:"text",JsonObject:"json_object",JsonSchema:"json_schema"};var fg={Private:"private",Public:"public"};var Rg={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var bg={Default:"default",Hidden:"hidden"};var yg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var kg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var rn={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var zg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var Sg={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var xg={Default:"default",Hidden:"hidden"};var _g={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Tg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Ag={Private:"private",Public:"public"};var Eg={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Pg={Default:"default",Hidden:"hidden"};var vg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var Cg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var on={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Ig={Running:"running",Completed:"completed",Cancelled:"cancelled"};var jg={Topic:"TOPIC",Pii:"PII"};var Ug={Passed:"passed",Failed:"failed"};var we={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Ng={Default:"default",Hidden:"hidden"};var Mg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Dg={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Fg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Og={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Wg={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Bg={Topic:"TOPIC",Pii:"PII"};var Lg={Passed:"passed",Failed:"failed"};var Vg={Topic:"TOPIC",Pii:"PII"};var Hg={Passed:"passed",Failed:"failed"};var Jg={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var Kg={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var Xg={Trace:"trace",Thread:"thread"};var Gg={Running:"running",Completed:"completed",Cancelled:"cancelled"};var $g={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Qg={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Yg={Private:"private",Public:"public"};var Zg={Private:"private",Public:"public"};var qg={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 ew={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var rw={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 ow={Private:"private",Public:"public"};var tw={Mustache:"mustache",Jinja2:"jinja2"};var iw={Mustache:"mustache",Jinja2:"jinja2"};var aw={Mustache:"mustache",Jinja2:"jinja2"};var nw={Mustache:"mustache",Jinja2:"jinja2"};var sw={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var pw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var cw={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var lw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var mw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};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={Topic:"TOPIC",Pii:"PII"};var gw={Passed:"passed",Failed:"failed"};var ww={Default:"default",Hidden:"hidden"};var hw={Active:"active",Inactive:"inactive"};var fw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Rw={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 Be=(n,t,e)=>JSON.stringify(n,t,e);var p=class n extends Error{constructor({message:t,statusCode:e,body:o,rawResponse:i}){super(bw({message:t,statusCode:e,body:o})),Object.setPrototypeOf(this,n.prototype),this.statusCode=e,this.body=o,this.rawResponse=i;}};function bw({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: ${Be(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 f={Default:"http://localhost:5173/api"};var pr;typeof globalThis.Headers!="undefined"?pr=globalThis.Headers:pr=class Lm{constructor(t){if(this.headers=new Map,t)if(t instanceof Lm)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 At={headers:new pr,redirected:false,status:499,statusText:"Client Closed Request",type:"error",url:""},Et={headers:new pr,redirected:false,status:0,statusText:"Unknown Error",type:"error",url:""};function Pt(n){return {headers:n.headers,redirected:n.redirected,status:n.status,statusText:n.statusText,type:n.type,url:n.url}}function Vm(n,t){return Object.keys(t!=null?t:{}).length>0?`${n}?${yw__default.default.stringify(t,{arrayFormat:"repeat"})}`:n}var d=kw();function kw(){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 Hm(){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 Jm({body:n,type:t}){return t.includes("json")?Be(n):n}async function Zm(n){return d.type==="node"&&d.parsedVersion!=null&&d.parsedVersion>=18?new(await Promise.resolve().then(()=>(Xm(),Km))).Node18UniversalStreamWrapper(n):d.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>($m(),Gm))).UndiciStreamWrapper(n):new(await Promise.resolve().then(()=>(Ym(),Qm))).NodePre18StreamWrapper(n)}async function qm(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 Zm(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 zw="timeout";function ed(n){let t=new AbortController,e=setTimeout(()=>t.abort(zw),n);return {signal:t.signal,abortId:e}}function rd(...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 od=async(n,t,e,o,i,a,c,m,u)=>{let g=[],y;if(a!=null){let{signal:x,abortId:_}=ed(a);y=_,g.push(x);}c!=null&&g.push(c);let k=rd(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 Sw(n){let t=1+(Math.random()*2-1)*.2;return n*t}async function td(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=Sw(i);await new Promise(c=>setTimeout(c,a)),e=await n();}return e}async function xw(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=Vm(n.url,n.queryParameters),o=await Jm({body:n.body,type:n.requestType==="json"?"json":"other"}),i=await Hm();try{let a=await td(async()=>od(i,e,n.method,t,o,n.timeoutMs,n.abortSignal,n.withCredentials,n.duplex),n.maxRetries),c=await qm(a,n.responseType);return a.status>=200&&a.status<400?{ok:!0,body:c,headers:a.headers,rawResponse:Pt(a)}:{ok:!1,error:{reason:"status-code",statusCode:a.status,body:c},rawResponse:Pt(a)}}catch(a){return n.abortSignal!=null&&n.abortSignal.aborted?{ok:false,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:At}:a instanceof Error&&a.name==="AbortError"?{ok:false,error:{reason:"timeout"},rawResponse:At}:a instanceof Error?{ok:false,error:{reason:"unknown",errorMessage:a.message},rawResponse:Et}:{ok:false,error:{reason:"unknown",errorMessage:Be(a)},rawResponse:Et}}}var R=xw;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:()=>Le,ParseError:()=>Ve,any:()=>Rd,bigint:()=>ad,boolean:()=>bd,booleanLiteral:()=>fd,date:()=>nd,discriminant:()=>Ed,enum_:()=>Ct,getObjectLikeUtils:()=>le,getObjectUtils:()=>Ce,getSchemaUtils:()=>C,isProperty:()=>Se,lazy:()=>sd,lazyObject:()=>gd,list:()=>jt,number:()=>yd,object:()=>It,objectWithoutOptionalProperties:()=>ud,optional:()=>sn,property:()=>cd,record:()=>xd,set:()=>_d,string:()=>kd,stringLiteral:()=>hd,transform:()=>pn,undiscriminatedUnion:()=>Ad,union:()=>vd,unknown:()=>zd,withParsedProperties:()=>ln});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 ${_w(n)}.`}function _w(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:id(n.json),parse:id(n.parse)}}function id(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 vt(n){return n.path.length===0?n.message:`${n.path.join(" -> ")}: ${n.message}`}var Le=class n extends Error{constructor(e){super(e.map(vt).join("; "));this.errors=e;Object.setPrototypeOf(this,n.prototype);}};var Ve=class n extends Error{constructor(e){super(e.map(vt).join("; "));this.errors=e;Object.setPrototypeOf(this,n.prototype);}};function C(n){return {nullable:()=>Tw(n),optional:()=>sn(n),optionalNullable:()=>Aw(n),transform:t=>pn(n,t),parseOrThrow:(t,e)=>{let o=n.parse(t,e);if(o.ok)return o.value;throw new Ve(o.errors)},jsonOrThrow:(t,e)=>{let o=n.json(t,e);if(o.ok)return o.value;throw new Le(o.errors)}}}function Tw(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 sn(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 Aw(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 pn(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 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: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 Ew=/^([+-]?\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 nd(){let n={parse:(t,{breadcrumbsPrefix:e=[]}={})=>typeof t!="string"?{ok:false,errors:[{path:e,message:v(t,"string")}]}:Ew.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 Ct(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 sd(n){let t=cn(n);return {...t,...C(t)}}function cn(n){return {parse:(t,e)=>He(n).parse(t,e),json:(t,e)=>He(n).json(t,e),getType:()=>He(n).getType()}}function He(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 ze(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 pd(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=>ln(n,t)}}function ln(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(!ze(o))return {ok:false,errors:[{path:(m=i==null?void 0:i.breadcrumbsPrefix)!=null?m:[],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 cd(n,t){return {rawKey:n,valueSchema:t,isProperty:true}}function Se(n){return n.isProperty}function It(n){let t={_getRawProperties:()=>Object.entries(n).map(([e,o])=>Se(o)?o.rawKey:e),_getParsedProperties:()=>mr(n),parse:(e,o)=>{let i={},a=[];for(let[c,m]of cr(n)){let u=Se(m)?m.rawKey:c,g=Se(m)?m.valueSchema:m,y={rawKey:u,parsedKey:c,valueSchema:g};i[u]=y,dd(g)&&a.push(u);}return ld({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 cr(n)){let m=Se(c)?c.valueSchema:c;dd(m)&&i.push(a);}return ld({value:e,requiredKeys:i,getProperty:a=>{let c=n[a];if(c!=null)return Se(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),...C(t),...le(t),...Ce(t)}}function ld({value:n,requiredKeys:t,getProperty:e,unrecognizedObjectKeys:o="fail",skipValidation:i=false,breadcrumbsPrefix:a=[]}){if(!ze(n))return {ok:false,errors:[{path:a,message:v(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 Ce(n){return {extend:t=>{let e={_getParsedProperties:()=>[...n._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...n._getRawProperties(),...t._getRawProperties()],parse:(o,i)=>md({extensionKeys:t._getRawProperties(),value:o,transformBase:a=>n.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(o,i)=>md({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),...Ce(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),...Ce(t)}}}}function md({extensionKeys:n,value:t,transformBase:e,transformExtension:o}){let i=new Set(n),[a,c]=pd(mr(t),g=>i.has(g)),m=e(lr(t,c)),u=o(lr(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 dd(n){return !Pw(n)}function Pw(n){switch(n.getType()){case E.ANY:case E.UNKNOWN:case E.OPTIONAL:case E.OPTIONAL_NULLABLE:return true;default:return false}}function ud(n){return It(n)}function gd(n){let t={...cn(n),_getRawProperties:()=>He(n)._getRawProperties(),_getParsedProperties:()=>He(n)._getParsedProperties()};return {...t,...C(t),...le(t),...Ce(t)}}function jt(n){let t={parse:(e,o)=>wd(e,(i,a)=>{var c;return n.parse(i,{...o,breadcrumbsPrefix:[...(c=o==null?void 0:o.breadcrumbsPrefix)!=null?c:[],`[${a}]`]})}),json:(e,o)=>wd(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 wd(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 hd(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 fd(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 Rd=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:v(n,"boolean")}]});var yd=Q(E.NUMBER,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="number"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:v(n,"number")}]});var kd=Q(E.STRING,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="string"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:v(n,"string")}]});var zd=Q(E.UNKNOWN,n=>({ok:true,value:n}));function xd(n,t){let e={parse:(o,i)=>Sd({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)=>Sd({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),...C(e)}}function Sd({value:n,isKeyNumeric:t,transformKey:e,transformValue:o,breadcrumbsPrefix:i=[]}){return ze(n)?cr(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:v(n,"object")}]}}function _d(n){let t=jt(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 Ad(n){let t={parse:(e,o)=>Td((i,a)=>i.parse(e,a),n,o),json:(e,o)=>Td((i,a)=>i.json(e,a),n,o),getType:()=>E.UNDISCRIMINATED_UNION};return {...G(t),...C(t)}}function Td(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 Ed(n,t){return {parsedDiscriminant:n,rawDiscriminant:t}}function vd(n,t){let e=typeof n=="string"?n:n.rawDiscriminant,o=typeof n=="string"?n:n.parsedDiscriminant,i=Ct(mr(t)),a={parse:(c,m)=>Pd({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)=>Pd({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),...C(a),...le(a)}}function Pd({value:n,discriminant:t,transformedDiscriminant:e,transformDiscriminantValue:o,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=false,transformAdditionalProperties:c,breadcrumbsPrefix:m=[]}){if(!ze(n))return {ok:false,errors:[{path:m,message:v(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 vw(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),vw(n)}var I={};P(I,{AggregationData:()=>yc,Alert:()=>Mw,AlertAlertType:()=>es,AlertPagePublic:()=>Rs,AlertPublic:()=>mo,AlertPublicAlertType:()=>ds,AlertTrigger:()=>as,AlertTriggerConfig:()=>is,AlertTriggerConfigPublic:()=>hs,AlertTriggerConfigPublicType:()=>ws,AlertTriggerConfigType:()=>ts,AlertTriggerConfigWrite:()=>ss,AlertTriggerConfigWriteType:()=>ns,AlertTriggerEventType:()=>os,AlertTriggerPublic:()=>fs,AlertTriggerPublicEventType:()=>gs,AlertTriggerWrite:()=>cs,AlertTriggerWriteEventType:()=>ps,AlertWrite:()=>lo,AlertWriteAlertType:()=>ls,AnnotationQueue:()=>xs,AnnotationQueueBatch:()=>Fw,AnnotationQueueBatchWrite:()=>io,AnnotationQueueItemIds:()=>ki,AnnotationQueuePagePublic:()=>As,AnnotationQueuePublic:()=>uo,AnnotationQueuePublicScope:()=>_s,AnnotationQueueReviewer:()=>Ss,AnnotationQueueReviewerPublic:()=>Ts,AnnotationQueueScope:()=>zs,AnnotationQueueUpdate:()=>ao,AnnotationQueueWrite:()=>to,AnnotationQueueWriteScope:()=>On,AssistantMessage:()=>yp,AssistantMessageRole:()=>bp,Attachment:()=>Es,AttachmentListRequestEntityType:()=>Mt,AttachmentPage:()=>Ps,AuthDetailsHolder:()=>Us,AutomationRuleEvaluator:()=>Ww,AutomationRuleEvaluatorLlmAsJudge:()=>Os,AutomationRuleEvaluatorLlmAsJudgePublic:()=>Eo,AutomationRuleEvaluatorLlmAsJudgeWrite:()=>Ks,AutomationRuleEvaluatorObjectPublic:()=>pp,AutomationRuleEvaluatorPagePublic:()=>cp,AutomationRuleEvaluatorPublic:()=>lp,AutomationRuleEvaluatorTraceThreadLlmAsJudge:()=>Bs,AutomationRuleEvaluatorTraceThreadLlmAsJudgePublic:()=>vo,AutomationRuleEvaluatorTraceThreadLlmAsJudgeWrite:()=>Gs,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPython:()=>Ls,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPythonPublic:()=>Co,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPythonWrite:()=>Qs,AutomationRuleEvaluatorUpdate:()=>Rp,AutomationRuleEvaluatorUpdateLlmAsJudge:()=>gp,AutomationRuleEvaluatorUpdateTraceThreadLlmAsJudge:()=>hp,AutomationRuleEvaluatorUpdateTraceThreadUserDefinedMetricPython:()=>fp,AutomationRuleEvaluatorUpdateUserDefinedMetricPython:()=>wp,AutomationRuleEvaluatorUserDefinedMetricPython:()=>Ws,AutomationRuleEvaluatorUserDefinedMetricPythonPublic:()=>Po,AutomationRuleEvaluatorUserDefinedMetricPythonWrite:()=>Zs,AutomationRuleEvaluatorWrite:()=>rp,AvgValueStatPublic:()=>Hp,BatchDelete:()=>W,BatchDeleteByProject:()=>nh,BiInformation:()=>$n,BiInformationResponse:()=>Ge,CategoricalFeedbackDefinition:()=>_c,CategoricalFeedbackDefinitionCreate:()=>Pc,CategoricalFeedbackDefinitionPublic:()=>Wo,CategoricalFeedbackDefinitionUpdate:()=>Oc,CategoricalFeedbackDetail:()=>xc,CategoricalFeedbackDetailCreate:()=>Ec,CategoricalFeedbackDetailPublic:()=>jc,CategoricalFeedbackDetailUpdate:()=>Fc,ChatCompletionChoice:()=>zp,ChatCompletionRequest:()=>so,ChatCompletionResponse:()=>Tp,Check:()=>pc,CheckName:()=>nc,CheckPublic:()=>Dl,CheckPublicName:()=>Nl,CheckPublicResult:()=>Ml,CheckResult:()=>sc,ChunkedOutputJsonNode:()=>Hw,ChunkedOutputJsonNodePublic:()=>Gw,ChunkedOutputJsonNodePublicType:()=>Sc,ChunkedOutputJsonNodeType:()=>tc,Column:()=>rc,ColumnCompare:()=>Cp,ColumnCompareTypesItem:()=>vp,ColumnPublic:()=>Zp,ColumnPublicTypesItem:()=>Yp,ColumnTypesItem:()=>ec,Comment:()=>B,CommentCompare:()=>Ip,CommentPublic:()=>Ne,CompleteMultipartUploadRequest:()=>zi,CompleteMultipartUploadRequestEntityType:()=>vs,CompletionTokensDetails:()=>xp,CountValueStatPublic:()=>Jp,CreateDatasetItemsFromTracesRequest:()=>wr,CreatePromptVersionDetail:()=>Or,DataPointDouble:()=>sh,DataPointNumberPublic:()=>al,Dataset:()=>Bw,DatasetExpansion:()=>Vw,DatasetExpansionResponse:()=>Pp,DatasetExpansionWrite:()=>br,DatasetIdentifier:()=>fr,DatasetIdentifierPublic:()=>yr,DatasetItem:()=>jo,DatasetItemBatch:()=>Lw,DatasetItemBatchWrite:()=>gr,DatasetItemCompare:()=>Wp,DatasetItemCompareSource:()=>jp,DatasetItemPageCompare:()=>Bp,DatasetItemPagePublic:()=>qp,DatasetItemPublic:()=>Mo,DatasetItemPublicSource:()=>$p,DatasetItemSource:()=>Ep,DatasetItemStreamRequest:()=>kr,DatasetItemWrite:()=>dn,DatasetItemWriteSource:()=>mn,DatasetItemsDelete:()=>Rr,DatasetPagePublic:()=>Vp,DatasetPublic:()=>$e,DatasetPublicVisibility:()=>Lp,DatasetUpdate:()=>hr,DatasetUpdateVisibility:()=>Lt,DatasetVisibility:()=>Ap,DatasetWrite:()=>ur,DatasetWriteVisibility:()=>Bt,DeleteAttachmentsRequest:()=>Ow,DeleteAttachmentsRequestEntityType:()=>Is,DeleteFeedbackScore:()=>Ko,DeleteIdsHolder:()=>Qe,DeleteThreadFeedbackScores:()=>Yr,DeleteTraceThreads:()=>Zr,Delta:()=>kp,DownloadAttachmentRequestEntityType:()=>Dt,ErrorCountWithDeviation:()=>Ho,ErrorCountWithDeviationDetailed:()=>dl,ErrorInfo:()=>Re,ErrorInfoExperimentItemBulkWriteView:()=>Tr,ErrorInfoPublic:()=>Xo,ErrorInfoWrite:()=>Lr,ErrorMessage:()=>ee,ErrorMessageDetail:()=>th,ErrorMessageDetailed:()=>rh,ErrorMessagePublic:()=>Dw,Experiment:()=>Jw,ExperimentGroupAggregationsResponse:()=>zc,ExperimentGroupResponse:()=>bc,ExperimentItem:()=>Sr,ExperimentItemBulkRecord:()=>dc,ExperimentItemBulkRecordExperimentItemBulkWriteView:()=>_n,ExperimentItemBulkUpload:()=>Kw,ExperimentItemBulkUploadExperimentItemBulkWriteView:()=>Ar,ExperimentItemCompare:()=>Op,ExperimentItemCompareTraceVisibilityMode:()=>Fp,ExperimentItemPublic:()=>No,ExperimentItemPublicTraceVisibilityMode:()=>Qp,ExperimentItemStreamRequest:()=>Pr,ExperimentItemTraceVisibilityMode:()=>fn,ExperimentItemsBatch:()=>xr,ExperimentItemsDelete:()=>_r,ExperimentPagePublic:()=>wc,ExperimentPublic:()=>Oo,ExperimentPublicStatus:()=>gc,ExperimentPublicType:()=>uc,ExperimentStatus:()=>ac,ExperimentStreamRequestPublic:()=>vr,ExperimentType:()=>ic,ExperimentUpdate:()=>Er,ExperimentUpdateStatus:()=>Xt,ExperimentUpdateType:()=>Kt,ExperimentWrite:()=>zr,ExperimentWriteStatus:()=>Jt,ExperimentWriteType:()=>Ht,ExportTraceServiceRequest:()=>Zw,Feedback:()=>$w,FeedbackCreate:()=>Ic,FeedbackDefinitionPagePublic:()=>Mc,FeedbackObjectPublic:()=>Nc,FeedbackPublic:()=>Dc,FeedbackScore:()=>Y,FeedbackScoreAverage:()=>ie,FeedbackScoreAverageDetailed:()=>ul,FeedbackScoreAveragePublic:()=>je,FeedbackScoreBatch:()=>Qo,FeedbackScoreBatchItem:()=>Ul,FeedbackScoreBatchItemSource:()=>jl,FeedbackScoreBatchItemThread:()=>Mn,FeedbackScoreBatchItemThreadSource:()=>Nn,FeedbackScoreBatchThread:()=>qr,FeedbackScoreCompare:()=>Dp,FeedbackScoreCompareSource:()=>Up,FeedbackScoreExperimentItemBulkWriteView:()=>xn,FeedbackScoreExperimentItemBulkWriteViewSource:()=>kn,FeedbackScoreNames:()=>il,FeedbackScorePublic:()=>Go,FeedbackScorePublicSource:()=>El,FeedbackScoreSource:()=>gn,FeedbackUpdate:()=>Lc,FindFeedbackDefinitionsRequestType:()=>Qt,FindFeedbackScoreNames1RequestType:()=>mi,Function:()=>no,FunctionCall:()=>be,GetSpanStatsRequestType:()=>di,GetSpansByProjectRequestType:()=>ci,GetWebhookExamplesRequestAlertType:()=>Ut,GroupContent:()=>hc,GroupContentWithAggregations:()=>kc,GroupDetail:()=>fc,GroupDetails:()=>Rc,Guardrail:()=>Jc,GuardrailBatch:()=>Qw,GuardrailBatchWrite:()=>po,GuardrailName:()=>Vc,GuardrailResult:()=>Hc,GuardrailWrite:()=>Gn,GuardrailWriteName:()=>Kn,GuardrailWriteResult:()=>Xn,GuardrailsValidation:()=>cc,GuardrailsValidationPublic:()=>Fl,IdsHolder:()=>Xw,JsonListString:()=>U,JsonListStringCompare:()=>Ei,JsonListStringExperimentItemBulkWriteView:()=>me,JsonListStringPublic:()=>ae,JsonListStringWrite:()=>te,JsonNode:()=>O,JsonNodeDetail:()=>vn,JsonNodePublic:()=>kl,JsonNodeWrite:()=>Pn,JsonSchema:()=>Vn,LlmAsJudgeCode:()=>Ro,LlmAsJudgeCodePublic:()=>ip,LlmAsJudgeCodeWrite:()=>Js,LlmAsJudgeMessage:()=>ho,LlmAsJudgeMessagePublic:()=>To,LlmAsJudgeMessagePublicRole:()=>op,LlmAsJudgeMessageRole:()=>Ds,LlmAsJudgeMessageWrite:()=>So,LlmAsJudgeMessageWriteRole:()=>Vs,LlmAsJudgeModelParameters:()=>wo,LlmAsJudgeModelParametersPublic:()=>_o,LlmAsJudgeModelParametersWrite:()=>zo,LlmAsJudgeOutputSchema:()=>fo,LlmAsJudgeOutputSchemaPublic:()=>Ao,LlmAsJudgeOutputSchemaPublicType:()=>tp,LlmAsJudgeOutputSchemaType:()=>Fs,LlmAsJudgeOutputSchemaWrite:()=>xo,LlmAsJudgeOutputSchemaWriteType:()=>Hs,LogItem:()=>dp,LogItemLevel:()=>mp,LogPage:()=>up,ManualEvaluationRequest:()=>Ii,ManualEvaluationRequestEntityType:()=>$c,ManualEvaluationResponse:()=>Ci,Message:()=>Wn,MultipartUploadPart:()=>Cs,NumericalFeedbackDefinition:()=>Ac,NumericalFeedbackDefinitionCreate:()=>Cc,NumericalFeedbackDefinitionPublic:()=>Bo,NumericalFeedbackDefinitionUpdate:()=>Bc,NumericalFeedbackDetail:()=>Tc,NumericalFeedbackDetailCreate:()=>vc,NumericalFeedbackDetailPublic:()=>Uc,NumericalFeedbackDetailUpdate:()=>Wc,Optimization:()=>qw,OptimizationPagePublic:()=>qc,OptimizationPublic:()=>Vo,OptimizationPublicStatus:()=>Zc,OptimizationStatus:()=>Qc,OptimizationUpdate:()=>jr,OptimizationUpdateStatus:()=>ei,OptimizationWrite:()=>ji,OptimizationWriteStatus:()=>Yc,PageColumns:()=>oc,PercentageValueStatPublic:()=>Kp,PercentageValues:()=>ye,PercentageValuesDetailed:()=>gl,PercentageValuesPublic:()=>Uo,Project:()=>eh,ProjectDetailed:()=>hl,ProjectDetailedVisibility:()=>wl,ProjectMetricRequestPublic:()=>Mr,ProjectMetricRequestPublicInterval:()=>ai,ProjectMetricRequestPublicMetricType:()=>ii,ProjectMetricResponsePublic:()=>cl,ProjectMetricResponsePublicInterval:()=>sl,ProjectMetricResponsePublicMetricType:()=>nl,ProjectPagePublic:()=>ol,ProjectPublic:()=>Jo,ProjectPublicVisibility:()=>rl,ProjectRetrieveDetailed:()=>Dr,ProjectStatItemObjectPublic:()=>Gp,ProjectStatsPublic:()=>Ue,ProjectStatsSummary:()=>ml,ProjectStatsSummaryItem:()=>ll,ProjectUpdate:()=>Nr,ProjectUpdateVisibility:()=>ti,ProjectVisibility:()=>el,ProjectWrite:()=>Ur,ProjectWriteVisibility:()=>oi,Prompt:()=>oh,PromptDetail:()=>yl,PromptPagePublic:()=>Tl,PromptPublic:()=>_l,PromptTokensDetails:()=>Sp,PromptType:()=>fl,PromptUpdatable:()=>Wr,PromptVersion:()=>bl,PromptVersionDetail:()=>he,PromptVersionDetailType:()=>Cn,PromptVersionLink:()=>Pi,PromptVersionLinkPublic:()=>vi,PromptVersionLinkWrite:()=>$t,PromptVersionPagePublic:()=>xl,PromptVersionPublic:()=>Sl,PromptVersionPublicType:()=>zl,PromptVersionRetrieveDetail:()=>Br,PromptVersionType:()=>Rl,PromptWrite:()=>Fr,PromptWriteType:()=>si,ProviderApiKey:()=>Yw,ProviderApiKeyPagePublic:()=>Xc,ProviderApiKeyProvider:()=>Gc,ProviderApiKeyPublic:()=>Lo,ProviderApiKeyPublicProvider:()=>Kc,ProviderApiKeyUpdate:()=>Ir,ProviderApiKeyWrite:()=>Cr,ProviderApiKeyWriteProvider:()=>Zt,ResponseFormat:()=>Hn,ResponseFormatType:()=>Ln,Result:()=>Me,ResultsNumberPublic:()=>pl,ScoreName:()=>tl,ServiceTogglesConfig:()=>Al,Span:()=>Fo,SpanBatch:()=>ih,SpanBatchWrite:()=>Hr,SpanExperimentItemBulkWriteView:()=>yn,SpanExperimentItemBulkWriteViewType:()=>bn,SpanFilterPublic:()=>Un,SpanFilterPublicOperator:()=>jn,SpanPagePublic:()=>Il,SpanPublic:()=>$o,SpanPublicType:()=>Cl,SpanSearchStreamRequestPublic:()=>Kr,SpanSearchStreamRequestPublicType:()=>ui,SpanType:()=>mc,SpanUpdate:()=>Jr,SpanUpdateType:()=>li,SpanWrite:()=>Vr,SpanWriteType:()=>In,SpansCountResponse:()=>Yn,StartMultipartUploadRequest:()=>dr,StartMultipartUploadRequestEntityType:()=>Ft,StartMultipartUploadResponse:()=>js,StreamOptions:()=>Bn,Tool:()=>Jn,ToolCall:()=>Io,Trace:()=>Do,TraceBatch:()=>ah,TraceBatchWrite:()=>$r,TraceCountResponse:()=>qn,TraceEnrichmentOptions:()=>un,TraceExperimentItemBulkWriteView:()=>Rn,TraceFilter:()=>go,TraceFilterOperator:()=>Ms,TraceFilterPublic:()=>fe,TraceFilterPublicOperator:()=>Tn,TraceFilterWrite:()=>ep,TraceFilterWriteOperator:()=>qs,TracePagePublic:()=>Ll,TracePublic:()=>Yo,TracePublicVisibilityMode:()=>Ol,TraceSearchStreamRequestPublic:()=>ro,TraceThread:()=>Zo,TraceThreadBatchIdentifier:()=>Xr,TraceThreadFilter:()=>Fn,TraceThreadFilterOperator:()=>Dn,TraceThreadFilterPublic:()=>En,TraceThreadFilterPublicOperator:()=>An,TraceThreadIdentifier:()=>Ui,TraceThreadLlmAsJudgeCode:()=>yo,TraceThreadLlmAsJudgeCodePublic:()=>np,TraceThreadLlmAsJudgeCodeWrite:()=>Xs,TraceThreadPage:()=>Bl,TraceThreadSearchStreamRequest:()=>eo,TraceThreadStatus:()=>Wl,TraceThreadUpdate:()=>oo,TraceThreadUserDefinedMetricPythonCode:()=>ko,TraceThreadUserDefinedMetricPythonCodePublic:()=>sp,TraceThreadUserDefinedMetricPythonCodeWrite:()=>$s,TraceUpdate:()=>Qr,TraceVisibilityMode:()=>lc,TraceWrite:()=>Gr,UploadAttachmentRequestEntityType:()=>Ot,Usage:()=>_p,UserDefinedMetricPythonCode:()=>bo,UserDefinedMetricPythonCodePublic:()=>ap,UserDefinedMetricPythonCodeWrite:()=>Ys,ValueEntry:()=>hn,ValueEntryCompare:()=>Mp,ValueEntryCompareSource:()=>Np,ValueEntryExperimentItemBulkWriteView:()=>Sn,ValueEntryExperimentItemBulkWriteViewSource:()=>zn,ValueEntryPublic:()=>vl,ValueEntryPublicSource:()=>Pl,ValueEntrySource:()=>wn,Webhook:()=>rs,WebhookExamples:()=>bs,WebhookPublic:()=>us,WebhookTestResult:()=>ks,WebhookTestResultStatus:()=>ys,WebhookWrite:()=>ms,WelcomeWizardSubmission:()=>co,WelcomeWizardTracking:()=>Vl,WorkspaceConfiguration:()=>qo,WorkspaceMetricRequest:()=>ph,WorkspaceMetricResponse:()=>Ni,WorkspaceMetricsSummaryRequest:()=>Ye,WorkspaceMetricsSummaryResponse:()=>Hl,WorkspaceNameHolder:()=>Ns,WorkspaceSpansCount:()=>Qn,WorkspaceTraceCount:()=>Zn,alerts:()=>Nt,annotationQueues:()=>fi,attachments:()=>Je,chatCompletions:()=>Ri,datasets:()=>Vt,experiments:()=>Ke,feedbackDefinitions:()=>Yt,guardrails:()=>bi,llmProviderKey:()=>qt,optimizations:()=>ri,projects:()=>ni,prompts:()=>pi,spans:()=>Xe,traces:()=>Ie,welcomeWizard:()=>yi});var Nt={};P(Nt,{GetWebhookExamplesRequestAlertType:()=>Ut});var Ut=r.enum_(["general","slack","pagerduty"]);var Je={};P(Je,{AttachmentListRequestEntityType:()=>Mt,DownloadAttachmentRequestEntityType:()=>Dt,StartMultipartUploadRequest:()=>dr,StartMultipartUploadRequestEntityType:()=>Ft,UploadAttachmentRequestEntityType:()=>Ot,uploadAttachment:()=>Wt});var Mt=r.enum_(["trace","span"]);var Dt=r.enum_(["trace","span"]);var Ft=r.enum_(["trace","span"]);var Ot=r.enum_(["trace","span"]);var Wt={};P(Wt,{Request:()=>Cw});var Cw=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",Ft),entityId:r.property("entity_id",r.string()),path:r.string()});var Vt={};P(Vt,{CreateDatasetItemsFromTracesRequest:()=>wr,DatasetExpansionWrite:()=>br,DatasetIdentifier:()=>fr,DatasetIdentifierPublic:()=>yr,DatasetItemBatchWrite:()=>gr,DatasetItemStreamRequest:()=>kr,DatasetItemsDelete:()=>Rr,DatasetUpdate:()=>hr,DatasetUpdateVisibility:()=>Lt,DatasetWrite:()=>ur,DatasetWriteVisibility:()=>Bt});var Bt=r.enum_(["private","public"]);var Lt=r.enum_(["private","public"]);var ur=r.object({id:r.string().optional(),name:r.string(),visibility:Bt.optional(),tags:r.list(r.string()).optional(),description:r.string().optional()});var mn=r.enum_(["manual","trace","span","sdk"]);var O=r.record(r.string(),r.unknown());var dn=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:mn,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(dn)});var un=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 wr=r.object({traceIds:r.property("trace_ids",r.list(r.string())),enrichmentOptions:r.property("enrichment_options",un)});var hr=r.object({name:r.string(),description:r.string().optional(),visibility:Lt.optional(),tags:r.list(r.string()).optional()});var fr=r.object({datasetName:r.property("dataset_name",r.string())});var Rr=r.object({itemIds:r.property("item_ids",r.list(r.string()))});var br=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 yr=r.object({datasetName:r.property("dataset_name",r.string())});var kr=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 Ke={};P(Ke,{ExperimentItemBulkUploadExperimentItemBulkWriteView:()=>Ar,ExperimentItemStreamRequest:()=>Pr,ExperimentItemsBatch:()=>xr,ExperimentItemsDelete:()=>_r,ExperimentStreamRequestPublic:()=>vr,ExperimentUpdate:()=>Er,ExperimentUpdateStatus:()=>Xt,ExperimentUpdateType:()=>Kt,ExperimentWrite:()=>zr,ExperimentWriteStatus:()=>Jt,ExperimentWriteType:()=>Ht,findFeedbackScoreNames:()=>Gt});var Ht=r.enum_(["regular","trial","mini-batch"]);var Jt=r.enum_(["running","completed","cancelled"]);var Kt=r.enum_(["regular","trial","mini-batch"]);var Xt=r.enum_(["running","completed","cancelled"]);var Gt={};P(Gt,{Response:()=>Iw});var Iw=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 $t=r.object({id:r.string()});var zr=r.object({id:r.string().optional(),datasetName:r.property("dataset_name",r.string()),name:r.string().optional(),metadata:te.optional(),type:Ht.optional(),optimizationId:r.property("optimization_id",r.string().optional()),status:Jt.optional(),promptVersion:r.property("prompt_version",$t.optional()),promptVersions:r.property("prompt_versions",r.list($t).optional())});var U=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var gn=r.enum_(["ui","sdk","online_scoring"]);var wn=r.enum_(["ui","sdk","online_scoring"]);var hn=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:wn.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:gn,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(),hn).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 fn=r.enum_(["default","hidden"]);var Sr=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",fn.optional())});var xr=r.object({experimentItems:r.property("experiment_items",r.list(Sr))});var _r=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 Tr=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var Rn=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",Tr.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),threadId:r.property("thread_id",r.string().optional())});var bn=r.enum_(["general","tool","llm","guardrail"]);var yn=r.object({id:r.string().optional(),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:bn.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",Tr.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 kn=r.enum_(["ui","sdk","online_scoring"]);var zn=r.enum_(["ui","sdk","online_scoring"]);var Sn=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:zn.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var xn=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:kn,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(),Sn).optional())});var _n=r.object({datasetItemId:r.property("dataset_item_id",r.string()),evaluateTaskResult:r.property("evaluate_task_result",me.optional()),trace:Rn.optional(),spans:r.list(yn).optional(),feedbackScores:r.property("feedback_scores",r.list(xn).optional())});var Ar=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(_n)});var Er=r.object({name:r.string().optional(),metadata:O.optional(),type:Kt.optional(),status:Xt.optional()});var Pr=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 vr=r.object({name:r.string(),limit:r.number().optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional())});var Yt={};P(Yt,{FindFeedbackDefinitionsRequestType:()=>Qt});var Qt=r.enum_(["numerical","categorical"]);var qt={};P(qt,{ProviderApiKeyUpdate:()=>Ir,ProviderApiKeyWrite:()=>Cr,ProviderApiKeyWriteProvider:()=>Zt});var Zt=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var Cr=r.object({provider:Zt,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 Ir=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 ri={};P(ri,{OptimizationUpdate:()=>jr,OptimizationUpdateStatus:()=>ei});var ei=r.enum_(["running","completed","cancelled"]);var jr=r.object({name:r.string().optional(),status:ei.optional()});var ni={};P(ni,{ProjectMetricRequestPublic:()=>Mr,ProjectMetricRequestPublicInterval:()=>ai,ProjectMetricRequestPublicMetricType:()=>ii,ProjectRetrieveDetailed:()=>Dr,ProjectUpdate:()=>Nr,ProjectUpdateVisibility:()=>ti,ProjectWrite:()=>Ur,ProjectWriteVisibility:()=>oi});var oi=r.enum_(["private","public"]);var ti=r.enum_(["private","public"]);var ii=r.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST","GUARDRAILS_FAILED_COUNT","THREAD_COUNT","THREAD_DURATION","THREAD_FEEDBACK_SCORES"]);var ai=r.enum_(["HOURLY","DAILY","WEEKLY"]);var Ur=r.object({name:r.string(),visibility:oi.optional(),description:r.string().optional()});var Nr=r.object({name:r.string().optional(),description:r.string().optional(),visibility:ti.optional()});var Tn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var fe=r.object({field:r.string().optional(),operator:Tn.optional(),key:r.string().optional(),value:r.string().optional()});var An=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var En=r.object({field:r.string().optional(),operator:An.optional(),key:r.string().optional(),value:r.string().optional()});var Mr=r.object({metricType:r.property("metric_type",ii.optional()),interval:ai.optional(),intervalStart:r.property("interval_start",r.date().optional()),intervalEnd:r.property("interval_end",r.date().optional()),traceFilters:r.property("trace_filters",r.list(fe).optional()),threadFilters:r.property("thread_filters",r.list(En).optional())});var Dr=r.object({name:r.string()});var pi={};P(pi,{CreatePromptVersionDetail:()=>Or,PromptUpdatable:()=>Wr,PromptVersionRetrieveDetail:()=>Br,PromptWrite:()=>Fr,PromptWriteType:()=>si});var si=r.enum_(["mustache","jinja2"]);var Pn=r.record(r.string(),r.unknown());var Fr=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),template:r.string().optional(),metadata:Pn.optional(),changeDescription:r.property("change_description",r.string().optional()),type:si.optional(),tags:r.list(r.string()).optional()});var vn=r.record(r.string(),r.unknown());var Cn=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:vn.optional(),type:Cn.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 Or=r.object({name:r.string(),version:he});var Wr=r.object({name:r.string(),description:r.string().optional(),tags:r.list(r.string()).optional()});var Br=r.object({name:r.string(),commit:r.string().optional()});var Xe={};P(Xe,{FindFeedbackScoreNames1RequestType:()=>mi,GetSpanStatsRequestType:()=>di,GetSpansByProjectRequestType:()=>ci,SpanBatchWrite:()=>Hr,SpanSearchStreamRequestPublic:()=>Kr,SpanSearchStreamRequestPublicType:()=>ui,SpanUpdate:()=>Jr,SpanUpdateType:()=>li,findFeedbackScoreNames1:()=>gi});var ci=r.enum_(["general","tool","llm","guardrail"]);var li=r.enum_(["general","tool","llm","guardrail"]);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={};P(gi,{Response:()=>jw});var jw=r.list(r.string());var In=r.enum_(["general","tool","llm","guardrail"]);var Lr=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var Vr=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:In.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",Lr.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 Hr=r.object({spans:r.list(Vr)});var Re=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var Jr=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:li.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",Re.optional())});var jn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Un=r.object({field:r.string().optional(),operator:jn.optional(),key:r.string().optional(),value:r.string().optional()});var Kr=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:ui.optional(),filters:r.list(Un).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 Ie={};P(Ie,{DeleteThreadFeedbackScores:()=>Yr,DeleteTraceThreads:()=>Zr,FeedbackScoreBatchThread:()=>qr,TraceBatchWrite:()=>$r,TraceSearchStreamRequestPublic:()=>ro,TraceThreadBatchIdentifier:()=>Xr,TraceThreadSearchStreamRequest:()=>eo,TraceThreadUpdate:()=>oo,TraceUpdate:()=>Qr,findFeedbackScoreNames2:()=>wi,findTraceThreadsFeedbackScoreNames:()=>hi});var wi={};P(wi,{Response:()=>Uw});var Uw=r.list(r.string());var hi={};P(hi,{Response:()=>Nw});var Nw=r.list(r.string());var Xr=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 Gr=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",Lr.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),threadId:r.property("thread_id",r.string().optional())});var $r=r.object({traces:r.list(Gr)});var Qr=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",Re.optional()),threadId:r.property("thread_id",r.string().optional())});var Yr=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 Zr=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 Nn=r.enum_(["ui","sdk","online_scoring"]);var Mn=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:Nn,author:r.string().optional(),threadId:r.property("thread_id",r.string())});var qr=r.object({scores:r.list(Mn)});var Dn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Fn=r.object({field:r.string().optional(),operator:Dn.optional(),key:r.string().optional(),value:r.string().optional()});var eo=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),filters:r.list(Fn).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 ro=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),filters:r.list(fe).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 oo=r.object({tags:r.list(r.string()).optional()});var fi={};P(fi,{AnnotationQueueBatchWrite:()=>io,AnnotationQueueUpdate:()=>ao});var On=r.enum_(["trace","thread"]);var to=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:On,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional())});var io=r.object({annotationQueues:r.property("annotation_queues",r.list(to))});var ao=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 Ri={};P(Ri,{ChatCompletionRequest:()=>so});var Wn=r.record(r.string(),r.unknown());var Bn=r.object({includeUsage:r.property("include_usage",r.boolean().optional())});var Ln=r.enum_(["text","json_object","json_schema"]);var Vn=r.object({name:r.string().optional(),strict:r.boolean().optional(),schema:r.record(r.string(),r.record(r.string(),r.unknown())).optional()});var Hn=r.object({type:Ln.optional(),jsonSchema:r.property("json_schema",Vn.optional())});var no=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 Jn=r.object({type:r.stringLiteral("function").optional(),function:no.optional()});var be=r.object({name:r.string().optional(),arguments:r.string().optional()});var so=r.object({model:r.string().optional(),messages:r.list(Wn).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",Bn.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",Hn.optional()),seed:r.number().optional(),tools:r.list(Jn).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(no).optional(),functionCall:r.property("function_call",be.optional())});var bi={};P(bi,{GuardrailBatchWrite:()=>po});var Kn=r.enum_(["TOPIC","PII"]);var Xn=r.enum_(["passed","failed"]);var Gn=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:Kn,result:Xn,config:O,details:O});var po=r.object({guardrails:r.list(Gn)});var yi={};P(yi,{WelcomeWizardSubmission:()=>co});var co=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 $n=r.object({workspaceId:r.property("workspace_id",r.string().optional()),user:r.string().optional(),count:r.number().optional()});var Ge=r.object({biInformation:r.property("bi_information",r.list($n).optional())});var Qn=r.object({workspace:r.string().optional(),spanCount:r.property("span_count",r.number().optional())});var Yn=r.object({workspacesSpansCount:r.property("workspaces_spans_count",r.list(Qn).optional())});var Zn=r.object({workspace:r.string().optional(),traceCount:r.property("trace_count",r.number().optional())});var qn=r.object({workspacesTracesCount:r.property("workspaces_traces_count",r.list(Zn).optional())});var ee=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var es=r.enum_(["general","slack","pagerduty"]);var rs=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 os=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 ts=r.enum_(["scope:project","threshold:feedback_score"]);var is=r.object({id:r.string().optional(),alertTriggerId:r.property("alert_trigger_id",r.string().optional()),type:ts,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",os),triggerConfigs:r.property("trigger_configs",r.list(is).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var Mw=r.object({id:r.string().optional(),name:r.string().optional(),enabled:r.boolean().optional(),alertType:r.property("alert_type",es.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:rs,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 ns=r.enum_(["scope:project","threshold:feedback_score"]);var ss=r.object({id:r.string().optional(),type:ns,configValue:r.property("config_value",r.record(r.string(),r.string()).optional())});var ps=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 cs=r.object({id:r.string().optional(),eventType:r.property("event_type",ps),triggerConfigs:r.property("trigger_configs",r.list(ss).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()});var lo=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(cs).optional()});var W=r.object({ids:r.list(r.string())});var ds=r.enum_(["general","slack","pagerduty"]);var us=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 gs=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 ws=r.enum_(["scope:project","threshold:feedback_score"]);var hs=r.object({id:r.string().optional(),alertTriggerId:r.property("alert_trigger_id",r.string().optional()),type:ws,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 fs=r.object({id:r.string().optional(),alertId:r.property("alert_id",r.string().optional()),eventType:r.property("event_type",gs),triggerConfigs:r.property("trigger_configs",r.list(hs).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var mo=r.object({id:r.string().optional(),name:r.string().optional(),enabled:r.boolean().optional(),alertType:r.property("alert_type",ds.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:us,triggers:r.list(fs).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 Rs=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(mo).optional(),sortableBy:r.property("sortable_by",r.list(r.string()).optional())});var Dw=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var bs=r.object({responseExamples:r.property("response_examples",r.record(r.string(),r.record(r.string(),r.unknown())).optional())});var ys=r.enum_(["success","failure"]);var ks=r.object({status:ys.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 ki=r.object({ids:r.list(r.string())});var zs=r.enum_(["trace","thread"]);var Ss=r.object({username:r.string().optional(),status:r.number().optional()});var ie=r.object({name:r.string(),value:r.number()});var xs=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:zs,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional()),reviewers:r.list(Ss).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 Fw=r.object({annotationQueues:r.property("annotation_queues",r.list(xs))});var _s=r.enum_(["trace","thread"]);var Ts=r.object({username:r.string().optional(),status:r.number().optional()});var je=r.object({name:r.string(),value:r.number()});var uo=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(je).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 As=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(uo).optional(),sortableBy:r.list(r.string()).optional()});var Es=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 Ps=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Es).optional(),sortableBy:r.list(r.string()).optional()});var vs=r.enum_(["trace","span"]);var Cs=r.object({eTag:r.property("e_tag",r.string()),partNumber:r.property("part_number",r.number())});var zi=r.object({fileName:r.property("file_name",r.string()),projectName:r.property("project_name",r.string().optional()),entityType:r.property("entity_type",vs),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(Cs))});var Is=r.enum_(["trace","span"]);var Ow=r.object({fileNames:r.property("file_names",r.list(r.string())),entityType:r.property("entity_type",Is),entityId:r.property("entity_id",r.string()),containerId:r.property("container_id",r.string())});var js=r.object({uploadId:r.property("upload_id",r.string()),preSignUrls:r.property("pre_sign_urls",r.list(r.string()))});var Us=r.record(r.string(),r.unknown());var Ns=r.object({workspaceName:r.property("workspace_name",r.string().optional())});var Ms=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var go=r.object({field:r.string().optional(),operator:Ms.optional(),key:r.string().optional(),value:r.string().optional()});var wo=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional()});var Ds=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var ho=r.object({role:Ds,content:r.string()});var Fs=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var fo=r.object({name:r.string(),type:Fs,description:r.string()});var Ro=r.object({model:wo,messages:r.list(ho),variables:r.record(r.string(),r.string()),schema:r.list(fo)});var Os=r.object({code:Ro.optional()});var bo=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var Ws=r.object({code:bo.optional()});var yo=r.object({model:wo,messages:r.list(ho),schema:r.list(fo)});var Bs=r.object({code:yo.optional()});var ko=r.object({metric:r.string()});var Ls=r.object({code:ko.optional()});var Si=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(go).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")}),Ww=r.union("type",{llm_as_judge:Os.extend(Si),user_defined_metric_python:Ws.extend(Si),trace_thread_llm_as_judge:Bs.extend(Si),trace_thread_user_defined_metric_python:Ls.extend(Si)}).transform({transform:n=>n,untransform:n=>n});var zo=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional()});var Vs=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var So=r.object({role:Vs,content:r.string()});var Hs=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var xo=r.object({name:r.string(),type:Hs,description:r.string()});var Js=r.object({model:zo,messages:r.list(So),variables:r.record(r.string(),r.string()),schema:r.list(xo)});var Ks=r.object({code:Js.optional()});var Xs=r.object({model:zo,messages:r.list(So),schema:r.list(xo)});var Gs=r.object({code:Xs.optional()});var $s=r.object({metric:r.string()});var Qs=r.object({code:$s.optional()});var Ys=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var Zs=r.object({code:Ys.optional()});var qs=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var ep=r.object({field:r.string().optional(),operator:qs.optional(),key:r.string().optional(),value:r.string().optional()});var xi=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(ep).optional(),action:r.stringLiteral("evaluator")}),rp=r.union("type",{llm_as_judge:Ks.extend(xi),user_defined_metric_python:Zs.extend(xi),trace_thread_llm_as_judge:Gs.extend(xi),trace_thread_user_defined_metric_python:Qs.extend(xi)}).transform({transform:n=>n,untransform:n=>n});var _o=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional()});var op=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var To=r.object({role:op,content:r.string()});var tp=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var Ao=r.object({name:r.string(),type:tp,description:r.string()});var ip=r.object({model:_o,messages:r.list(To),variables:r.record(r.string(),r.string()),schema:r.list(Ao)});var Eo=r.object({code:ip.optional()});var ap=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var Po=r.object({code:ap.optional()});var np=r.object({model:_o,messages:r.list(To),schema:r.list(Ao)});var vo=r.object({code:np.optional()});var sp=r.object({metric:r.string()});var Co=r.object({code:sp.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(fe).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")}),pp=r.union("type",{llm_as_judge:Eo.extend(_i),user_defined_metric_python:Po.extend(_i),trace_thread_llm_as_judge:vo.extend(_i),trace_thread_user_defined_metric_python:Co.extend(_i)}).transform({transform:n=>n,untransform:n=>n});var cp=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(pp).optional(),sortableBy:r.property("sortable_by",r.list(r.string()).optional())});var Ti=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(fe).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")}),lp=r.union("type",{llm_as_judge:Eo.extend(Ti),user_defined_metric_python:Po.extend(Ti),trace_thread_llm_as_judge:vo.extend(Ti),trace_thread_user_defined_metric_python:Co.extend(Ti)}).transform({transform:n=>n,untransform:n=>n});var mp=r.enum_(["INFO","WARN","ERROR","DEBUG","TRACE"]);var dp=r.object({timestamp:r.date().optional(),ruleId:r.property("rule_id",r.string().optional()),level:mp.optional(),message:r.string().optional(),markers:r.record(r.string(),r.string()).optional()});var up=r.object({content:r.list(dp).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional()});var gp=r.object({code:Ro.optional()});var wp=r.object({code:bo.optional()});var hp=r.object({code:yo.optional()});var fp=r.object({code:ko.optional()});var Ai=r.object({name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(go).optional(),projectId:r.property("project_id",r.string()),action:r.stringLiteral("evaluator")}),Rp=r.union("type",{llm_as_judge:gp.extend(Ai),user_defined_metric_python:wp.extend(Ai),trace_thread_llm_as_judge:hp.extend(Ai),trace_thread_user_defined_metric_python:fp.extend(Ai)}).transform({transform:n=>n,untransform:n=>n});var bp=r.enum_(["system","user","assistant","tool","function"]);var Io=r.object({id:r.string().optional(),index:r.number().optional(),type:r.stringLiteral("function").optional(),function:be.optional()});var yp=r.object({role:bp.optional(),content:r.string().optional(),reasoningContent:r.property("reasoning_content",r.string().optional()),name:r.string().optional(),toolCalls:r.property("tool_calls",r.list(Io).optional()),refusal:r.string().optional(),functionCall:r.property("function_call",be.optional())});var kp=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(Io).optional()),functionCall:r.property("function_call",be.optional())});var zp=r.object({index:r.number().optional(),message:yp.optional(),delta:kp.optional(),finishReason:r.property("finish_reason",r.string().optional())});var Sp=r.object({cachedTokens:r.property("cached_tokens",r.number().optional())});var xp=r.object({reasoningTokens:r.property("reasoning_tokens",r.number().optional())});var _p=r.object({totalTokens:r.property("total_tokens",r.number().optional()),promptTokens:r.property("prompt_tokens",r.number().optional()),promptTokensDetails:r.property("prompt_tokens_details",Sp.optional()),completionTokens:r.property("completion_tokens",r.number().optional()),completionTokensDetails:r.property("completion_tokens_details",xp.optional())});var Tp=r.object({id:r.string().optional(),created:r.number().optional(),model:r.string().optional(),choices:r.list(zp).optional(),usage:_p.optional(),systemFingerprint:r.property("system_fingerprint",r.string().optional()),serviceTier:r.property("service_tier",r.string().optional())});var Ap=r.enum_(["private","public"]);var Bw=r.object({id:r.string().optional(),name:r.string(),visibility:Ap.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 Ep=r.enum_(["manual","trace","span","sdk"]);var jo=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:Ep,data:O,experimentItems:r.property("experiment_items",r.list(Sr).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 Lw=r.object({datasetName:r.property("dataset_name",r.string().optional()),datasetId:r.property("dataset_id",r.string().optional()),items:r.list(jo)});var Pp=r.object({generatedSamples:r.property("generated_samples",r.list(jo).optional()),model:r.string().optional(),totalGenerated:r.property("total_generated",r.number().optional()),generationTime:r.property("generation_time",r.date().optional())});var Vw=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 vp=r.enum_(["string","number","object","boolean","array","null"]);var Cp=r.object({name:r.string().optional(),types:r.list(vp).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var Ip=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 jp=r.enum_(["manual","trace","span","sdk"]);var Ei=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var Up=r.enum_(["ui","sdk","online_scoring"]);var Np=r.enum_(["ui","sdk","online_scoring"]);var Mp=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Np.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Dp=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Up,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(),Mp).optional())});var Fp=r.enum_(["default","hidden"]);var Op=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:Ei.optional(),output:Ei.optional(),feedbackScores:r.property("feedback_scores",r.list(Dp).optional()),comments:r.list(Ip).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",Fp.optional())});var Wp=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:jp,data:O,experimentItems:r.property("experiment_items",r.list(Op).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 Bp=r.object({content:r.list(Wp).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),columns:r.list(Cp).optional(),sortableBy:r.list(r.string()).optional()});var Lp=r.enum_(["private","public"]);var $e=r.object({id:r.string().optional(),name:r.string(),visibility:Lp.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 Vp=r.object({content:r.list($e).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),sortableBy:r.list(r.string()).optional()});var Hp=r.object({value:r.number().optional()});var Jp=r.object({value:r.number().optional()});var Uo=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var Kp=r.object({value:Uo.optional()});var Xp=r.object({name:r.string().optional()}),Gp=r.union("type",{PERCENTAGE:Kp.extend(Xp),COUNT:Jp.extend(Xp),AVG:Hp.extend(Xp)}).transform({transform:n=>n,untransform:n=>n});var Ue=r.object({stats:r.list(Gp).optional()});var $p=r.enum_(["manual","trace","span","sdk"]);var Qp=r.enum_(["default","hidden"]);var No=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 Mo=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:$p,data:O,experimentItems:r.property("experiment_items",r.list(No).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 Yp=r.enum_(["string","number","object","boolean","array","null"]);var Zp=r.object({name:r.string().optional(),types:r.list(Yp).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var qp=r.object({content:r.list(Mo).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),columns:r.list(Zp).optional(),sortableBy:r.list(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({columns:r.list(rc).optional()});var tc=r.object({typeName:r.string().optional()});var Hw=r.object({type:tc.optional(),closed:r.boolean().optional()});var ic=r.enum_(["regular","trial","mini-batch"]);var ac=r.enum_(["running","completed","cancelled"]);var ye=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var Pi=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 Jw=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:ic.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:ye.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:ac.optional(),promptVersion:r.property("prompt_version",Pi.optional()),promptVersions:r.property("prompt_versions",r.list(Pi).optional())});var Qe=r.object({ids:r.list(r.string())});var nc=r.enum_(["TOPIC","PII"]);var sc=r.enum_(["passed","failed"]);var pc=r.object({name:nc.optional(),result:sc.optional()});var cc=r.object({spanId:r.property("span_id",r.string().optional()),checks:r.list(pc).optional()});var lc=r.enum_(["default","hidden"]);var Do=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",Re.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(cc).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",lc.optional()),llmSpanCount:r.property("llm_span_count",r.number().optional()),providers:r.list(r.string()).optional()});var mc=r.enum_(["general","tool","llm","guardrail"]);var Fo=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:mc.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",Re.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 dc=r.object({datasetItemId:r.property("dataset_item_id",r.string()),evaluateTaskResult:r.property("evaluate_task_result",U.optional()),trace:Do.optional(),spans:r.list(Fo).optional(),feedbackScores:r.property("feedback_scores",r.list(Y).optional())});var Kw=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(dc)});var Ne=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 uc=r.enum_(["regular","trial","mini-batch"]);var gc=r.enum_(["running","completed","cancelled"]);var vi=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 Oo=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:uc.optional(),optimizationId:r.property("optimization_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(je).optional()),comments:r.list(Ne).optional(),traceCount:r.property("trace_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),duration:Uo.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:gc.optional(),promptVersion:r.property("prompt_version",vi.optional()),promptVersions:r.property("prompt_versions",r.list(vi).optional())});var wc=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Oo).optional(),sortableBy:r.list(r.string()).optional()});var hc=r.object({label:r.string().optional()});var fc=r.object({groupSorting:r.property("group_sorting",r.list(r.string()).optional())});var Rc=r.object({groupsDetails:r.property("groups_details",r.list(fc).optional())});var bc=r.object({content:r.record(r.string(),hc).optional(),details:Rc.optional()});var yc=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:ye.optional(),feedbackScores:r.property("feedback_scores",r.list(ie).optional())});var kc=r.object({aggregations:yc.optional()});var zc=r.object({content:r.record(r.string(),kc).optional()});var Xw=r.object({ids:r.list(r.string())});var Sc=r.object({typeName:r.string().optional()});var Gw=r.object({type:Sc.optional(),closed:r.boolean().optional()});var xc=r.object({categories:r.record(r.string(),r.number())});var _c=r.object({details:xc.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 Tc=r.object({max:r.number(),min:r.number()});var Ac=r.object({details:Tc.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 Cd=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()}),$w=r.union("type",{numerical:Ac.extend(Cd),categorical:_c.extend(Cd)}).transform({transform:n=>n,untransform:n=>n});var Ec=r.object({categories:r.record(r.string(),r.number())});var Pc=r.object({details:Ec.optional()});var vc=r.object({max:r.number(),min:r.number()});var Cc=r.object({details:vc.optional()});var Id=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional()}),Ic=r.union("type",{numerical:Cc.extend(Id),categorical:Pc.extend(Id)}).transform({transform:n=>n,untransform:n=>n});var jc=r.object({categories:r.record(r.string(),r.number())});var Wo=r.object({details:jc.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 Uc=r.object({max:r.number(),min:r.number()});var Bo=r.object({details:Uc.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 jd=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()}),Nc=r.union("type",{numerical:Bo.extend(jd),categorical:Wo.extend(jd)}).transform({transform:n=>n,untransform:n=>n});var Mc=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Nc).optional()});var Ud=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()}),Dc=r.union("type",{numerical:Bo.extend(Ud),categorical:Wo.extend(Ud)}).transform({transform:n=>n,untransform:n=>n});var Fc=r.object({categories:r.record(r.string(),r.number())});var Oc=r.object({details:Fc.optional()});var Wc=r.object({max:r.number(),min:r.number()});var Bc=r.object({details:Wc.optional()});var Nd=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional()}),Lc=r.union("type",{numerical:Bc.extend(Nd),categorical:Oc.extend(Nd)}).transform({transform:n=>n,untransform:n=>n});var Vc=r.enum_(["TOPIC","PII"]);var Hc=r.enum_(["passed","failed"]);var Jc=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:Vc,result:Hc,config:O,details:O});var Qw=r.object({guardrails:r.list(Jc)});var Kc=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var Lo=r.object({id:r.string().optional(),provider:Kc,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 Xc=r.object({size:r.number().optional(),total:r.number().optional(),content:r.list(Lo).optional(),sortableBy:r.list(r.string()).optional()});var Gc=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var Yw=r.object({id:r.string().optional(),provider:Gc,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 Ci=r.object({entitiesQueued:r.property("entities_queued",r.number().optional()),rulesApplied:r.property("rules_applied",r.number().optional())});var $c=r.enum_(["trace","thread"]);var Ii=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",$c)});var Zw=O;var Qc=r.enum_(["running","completed","cancelled"]);var qw=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:Qc,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 Yc=r.enum_(["running","completed","cancelled"]);var ji=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:Yc,metadata:te.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Zc=r.enum_(["running","completed","cancelled"]);var Vo=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:Zc,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(je).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({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Vo).optional(),sortableBy:r.list(r.string()).optional()});var Ho=r.object({count:r.number().optional(),deviation:r.number().optional(),deviationPercentage:r.property("deviation_percentage",r.number().optional())});var el=r.enum_(["private","public"]);var eh=r.object({id:r.string().optional(),name:r.string(),visibility:el.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:ye.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",Ho.optional())});var rl=r.enum_(["private","public"]);var Jo=r.object({id:r.string().optional(),name:r.string(),visibility:rl.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 ol=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 tl=r.object({name:r.string().optional()});var il=r.object({scores:r.list(tl).optional()});var al=r.object({time:r.date(),value:r.number().optional()});var nl=r.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST","GUARDRAILS_FAILED_COUNT","THREAD_COUNT","THREAD_DURATION","THREAD_FEEDBACK_SCORES"]);var sl=r.enum_(["HOURLY","DAILY","WEEKLY"]);var pl=r.object({name:r.string().optional(),data:r.list(al).optional()});var cl=r.object({projectId:r.property("project_id",r.string().optional()),metricType:r.property("metric_type",nl.optional()),interval:sl.optional(),results:r.list(pl).optional()});var ll=r.object({projectId:r.property("project_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),duration:ye.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",Ho.optional())});var ml=r.object({content:r.list(ll).optional()});var dl=r.object({count:r.number().optional(),deviation:r.number().optional(),deviationPercentage:r.property("deviation_percentage",r.number().optional())});var ul=r.object({name:r.string(),value:r.number()});var gl=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var wl=r.enum_(["private","public"]);var hl=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(ul).optional()),duration:gl.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",dl.optional())});var rh=r.object({errors:r.list(r.string()).optional()});var fl=r.enum_(["mustache","jinja2"]);var Rl=r.enum_(["mustache","jinja2"]);var bl=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:Rl.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 oh=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:fl.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",bl.optional())});var th=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var yl=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 kl=r.record(r.string(),r.unknown());var zl=r.enum_(["mustache","jinja2"]);var Sl=r.object({id:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),commit:r.string().optional(),template:r.string(),metadata:kl.optional(),type:zl.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 xl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Sl).optional()});var _l=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 Tl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(_l).optional(),sortableBy:r.list(r.string()).optional()});var Al=r.object({pythonEvaluatorEnabled:r.boolean(),traceThreadPythonEvaluatorEnabled:r.boolean(),guardrailsEnabled:r.boolean(),opikAiEnabled:r.property("opikAIEnabled",r.boolean()),alertsEnabled:r.boolean(),welcomeWizardEnabled:r.boolean()});var ih=r.object({spans:r.list(Fo)});var Ko=r.object({name:r.string(),author:r.string().optional()});var Xo=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var El=r.enum_(["ui","sdk","online_scoring"]);var Pl=r.enum_(["ui","sdk","online_scoring"]);var vl=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Pl.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Go=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:El,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(),vl).optional())});var Cl=r.enum_(["general","tool","llm","guardrail"]);var $o=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:Cl.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",Xo.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(Go).optional()),comments:r.list(Ne).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 Il=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list($o).optional(),sortableBy:r.list(r.string()).optional()});var jl=r.enum_(["ui","sdk","online_scoring"]);var Ul=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:jl,author:r.string().optional(),id:r.string()});var Qo=r.object({scores:r.list(Ul)});var ah=r.object({traces:r.list(Do)});var nh=r.object({ids:r.list(r.string()),projectId:r.property("project_id",r.string().optional())});var Nl=r.enum_(["TOPIC","PII"]);var Ml=r.enum_(["passed","failed"]);var Dl=r.object({name:Nl.optional(),result:Ml.optional()});var Fl=r.object({spanId:r.property("span_id",r.string().optional()),checks:r.list(Dl).optional()});var Ol=r.enum_(["default","hidden"]);var Yo=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",Xo.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(Go).optional()),comments:r.list(Ne).optional(),guardrailsValidations:r.property("guardrails_validations",r.list(Fl).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",Ol.optional()),llmSpanCount:r.property("llm_span_count",r.number().optional()),providers:r.list(r.string()).optional()});var Wl=r.enum_(["active","inactive"]);var Zo=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:Wl.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 Ui=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 Bl=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 Ll=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 Vl=r.object({completed:r.boolean().optional()});var Me=r.object({name:r.string().optional(),current:r.number().optional(),previous:r.number().optional()});var Ye=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 sh=r.object({time:r.date(),value:r.number().optional()});var Ni=r.object({results:r.list(Me).optional()});var ph=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 qo=r.object({timeoutToMarkThreadAsInactive:r.property("timeout_to_mark_thread_as_inactive",r.string().optional()),truncationOnTables:r.property("truncation_on_tables",r.boolean().optional())});var Hl=r.object({results:r.list(Me).optional()});var Mi=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:Ge.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:Ge.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:Ge.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:Yn.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:Ge.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:qn.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 Di=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:Rs.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: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")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 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: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 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: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/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:lo.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 h.fromPromise(this.__getWebhookExamples(t,e))}async __getWebhookExamples(t={},e){var c,m;let{alertType:o}=t,i={};o!=null&&(i.alert_type=Ut.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:bs.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: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:ks.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 Fi=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:ki.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 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:As.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: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")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 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: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 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 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: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 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: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/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:ao.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 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:ki.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 Oi=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=Mt.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:Ps.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 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:zi.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 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:zi.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 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=Dt.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 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 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: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:js.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 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=Ot.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:Je.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 Wi=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:Us.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 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:Ns.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 Bi=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:cp.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:rp.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: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 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:lp.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:Rp.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: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}/logs.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Li=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: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:Tp.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 Vi=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:Vp.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: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 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: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})}}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: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-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:$e.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: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 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: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 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: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/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: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 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: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:Pp.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:Bp.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: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:$e.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:Ue.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:Mo.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:qp.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:oc.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:kr.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 Hi=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:wc.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 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: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/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: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")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:_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/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:Qe.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:Ar.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 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:Ke.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:bc.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 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: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/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:Qe.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 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:Oo.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 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:Er.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 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:No.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 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:Pr.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: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/stream.");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;}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=Qt.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:Mc.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:Ic.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:Dc.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:Lc.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 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 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: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 Ki=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: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")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 Xi=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: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 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:Xc.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: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 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 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:Lo.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 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: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 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 Gi=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:Ii.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:Ci.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 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:Ii.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:Ci.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 $i=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 Qi=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:qc.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 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:ji.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:ji.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:Qe.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:Vo.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 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: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")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 Yi=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:ol.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: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")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 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:Jo.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 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 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:Nr.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 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: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 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:il.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: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:cl.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 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:ml.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: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:hl.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 Zi=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:Tl.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: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 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 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: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: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 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 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:yl.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 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: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")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 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: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 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 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 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:xl.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 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 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: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: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 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 qi=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:Al.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 ea=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: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 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,We;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=ci.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((We=(q=await s.get(this._options.baseUrl))!=null?q:await s.get(this._options.environment))!=null?We: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(J.ok)return {data:Il.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 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: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: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 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: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/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:$o.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 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 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 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: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 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 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: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 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:Ko.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=mi.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:Xe.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: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 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=di.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:Ue.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:Qo.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:Kr.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 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: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 ra=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: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 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: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 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: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 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 h.fromPromise(this.__getTracesByProject(t,e))}async __getTracesByProject(t={},e){var N,J;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((J=(N=await s.get(this._options.baseUrl))!=null?N:await s.get(this._options.environment))!=null?J: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:Ll.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: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/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:$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/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:Yo.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:Qr.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: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 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: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")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: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 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:Ko.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: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/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: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 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:Ie.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:Ie.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:Ue.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: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 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: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 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: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:Zo.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 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:Bl.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: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: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: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 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:Qo.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:eo.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 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: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);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 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:oo.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 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: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 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: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 oa=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:Vl.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: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/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 ta=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: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:Me.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 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:qo.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 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:qo.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: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 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 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 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 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: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:Ni.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 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: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:Ni.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 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: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:Hl.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 ia=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 T(m.error.body,m.rawResponse);case 404:throw new A(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 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 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 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 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 T(m.error.body,m.rawResponse);case 404:throw new A(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 et=class{constructor(t={}){this._options=t;}get systemUsage(){var t;return (t=this._systemUsage)!=null?t:this._systemUsage=new Mi(this._options)}get alerts(){var t;return (t=this._alerts)!=null?t:this._alerts=new Di(this._options)}get annotationQueues(){var t;return (t=this._annotationQueues)!=null?t:this._annotationQueues=new Fi(this._options)}get attachments(){var t;return (t=this._attachments)!=null?t:this._attachments=new Oi(this._options)}get check(){var t;return (t=this._check)!=null?t:this._check=new Wi(this._options)}get automationRuleEvaluators(){var t;return (t=this._automationRuleEvaluators)!=null?t:this._automationRuleEvaluators=new Bi(this._options)}get chatCompletions(){var t;return (t=this._chatCompletions)!=null?t:this._chatCompletions=new Li(this._options)}get datasets(){var t;return (t=this._datasets)!=null?t:this._datasets=new Vi(this._options)}get experiments(){var t;return (t=this._experiments)!=null?t:this._experiments=new Hi(this._options)}get feedbackDefinitions(){var t;return (t=this._feedbackDefinitions)!=null?t:this._feedbackDefinitions=new Ji(this._options)}get guardrails(){var t;return (t=this._guardrails)!=null?t:this._guardrails=new Ki(this._options)}get llmProviderKey(){var t;return (t=this._llmProviderKey)!=null?t:this._llmProviderKey=new Xi(this._options)}get manualEvaluation(){var t;return (t=this._manualEvaluation)!=null?t:this._manualEvaluation=new Gi(this._options)}get openTelemetryIngestion(){var t;return (t=this._openTelemetryIngestion)!=null?t:this._openTelemetryIngestion=new $i(this._options)}get optimizations(){var t;return (t=this._optimizations)!=null?t:this._optimizations=new Qi(this._options)}get projects(){var t;return (t=this._projects)!=null?t:this._projects=new Yi(this._options)}get prompts(){var t;return (t=this._prompts)!=null?t:this._prompts=new Zi(this._options)}get serviceToggles(){var t;return (t=this._serviceToggles)!=null?t:this._serviceToggles=new qi(this._options)}get spans(){var t;return (t=this._spans)!=null?t:this._spans=new ea(this._options)}get traces(){var t;return (t=this._traces)!=null?t:this._traces=new ra(this._options)}get welcomeWizard(){var t;return (t=this._welcomeWizard)!=null?t:this._welcomeWizard=new oa(this._options)}get workspaces(){var t;return (t=this._workspaces)!=null?t:this._workspaces=new ta(this._options)}get redirect(){var t;return (t=this._redirect)!=null?t:this._redirect=new ia(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 aa=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 na=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 aa(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 Md={EXPERIMENTS:"api/v1/session/redirect/experiments/",PROJECT_BY_NAME:"redirect/projects"},sa={EXPERIMENT_ID:"experiment_id",DATASET_ID:"dataset_id",PROJECT_NAME:"name",PATH:"path"},lh=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,"="),mh=n=>n.replace(/\/api$/,""),dh=n=>Buffer.from(n).toString("base64"),Dd=(n,t,e)=>{let o=lh(e),i=`${t}?${o}`;return new URL(i,n).toString()},Fd=({datasetId:n,experimentId:t,baseUrl:e})=>Dd(e,Md.EXPERIMENTS,{[sa.EXPERIMENT_ID]:t,[sa.DATASET_ID]:n,[sa.PATH]:dh(e)});var Od=({projectName:n,workspaceName:t,apiUrl:e})=>{let o=mh(e),i=`${t}/${Md.PROJECT_BY_NAME}`;return Dd(o,i,{[sa.PROJECT_NAME]:n})};var uh=300,pa=100,rt=class{constructor({action:t,batchSize:e=pa,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=uh,enableCreateBatch:e=true,enableUpdateBatch:o=false,enableDeleteBatch:i=true,createBatchSize:a=pa,updateBatchSize:c=pa,deleteBatchSize:m=pa,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 rt({action:async g=>{await this.createEntities(Array.from(g.values()));},delay:t,enableBatch:e,batchSize:a,name:`${u}:createQueue`}),this.updateQueue=new rt({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 rt({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 ca=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 la=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 ma=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 da=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 ua=class extends et{constructor(e){super(e);this.setHeaders=e=>{this.requestOptions.headers=e;};this.requestOptions=(e==null?void 0:e.requestOptions)||{};}};var ga=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 Jl=null;async function Wd(){return Jl||(Jl=await gh__default.default()),Jl}var ot=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||rn.Sdk,this.data={...c};}getContent(t=false){return t?{...this.data,id:this.id}:{...this.data}}async contentHash(){let t=this.getContent(),e=wh__default.default(t);return (await Wd()).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 xe(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 tt(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 Bd={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 fh={DATASET_ITEM_MISSING_ID:"DATASET_ITEM_MISSING_ID"},wa=class extends ne{constructor(t){super({message:Bd.DATASET_ITEM_MISSING_ID(t),code:fh.DATASET_ITEM_MISSING_ID});}};var Rh={SEARCH_TIMEOUT:"SEARCH_TIMEOUT"},ha=class extends ne{constructor(t){super({message:t,code:Rh.SEARCH_TIMEOUT});}};var fa={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 Kl={JSON_PARSE_ERROR:"JSON_PARSE_ERROR",JSON_NOT_ARRAY:"JSON_NOT_ARRAY",JSON_ITEM_NOT_OBJECT:"JSON_ITEM_NOT_OBJECT"},Ra=class extends ne{constructor(t){let e=t instanceof Error?t:new Error(String(t));super({message:fa.JSON_PARSE_ERROR,code:Kl.JSON_PARSE_ERROR,originalError:e});}},ba=class extends ne{constructor(t){super({message:fa.JSON_NOT_ARRAY(t),code:Kl.JSON_NOT_ARRAY});}},ya=class extends ne{constructor(t,e){super({message:fa.JSON_ITEM_NOT_OBJECT(t,e),code:Kl.JSON_ITEM_NOT_OBJECT});}};var Ze=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=tt(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 wa(e);await this.insert(t);}}async delete(t){if(!t||t.length===0){z.info("No item IDs provided for deletion");return}let e=tt(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 xe(i,I.DatasetItemPublic,t)).map(c=>ot.fromApiModel(c))}async insertFromJson(t,e={},o=[]){let i;try{i=JSON.parse(t);}catch(c){throw new Ra(c)}if(!Array.isArray(i))throw new ba(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 ya(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 wh__default.default(o)}async getDeduplicatedItems(t){let e=[];for(let o of t){let i=new ot(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 Xl=class extends Error{constructor(t){super(t),this.name="DatasetError";}},it=class extends Xl{constructor(t){super(`Dataset with name '${t}' not found`),this.name="DatasetNotFoundError";}};var ka=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;}},za=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 De=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=tt(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 xe(g,I.ExperimentItemCompare,u);if(y.length===0){m=!1;break}for(let k of y){let S=za.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||Ba.apiUrl;return Fd({datasetId:t.id,experimentId:this.id,baseUrl:e})}};var Sa={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'),fm=require('fs'),Wu=require('ini');require('dotenv/config');var Sw=require('qs'),uuid=require('uuid'),fh=require('fast-json-stable-stringify'),hh=require('xxhash-wasm'),util=require('util'),Sh=require('mustache'),_h=require('nunjucks'),dateFns=require('date-fns'),jestDiff=require('jest-diff'),Eh=require('fast-deep-equal'),async_hooks=require('async_hooks'),Ea=require('chalk'),Oh=require('boxen'),Wh=require('ora'),ai$1=require('ai'),openai=require('@ai-sdk/openai'),anthropic=require('@ai-sdk/anthropic'),google=require('@ai-sdk/google'),nm=require('zod');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var fm__default=/*#__PURE__*/_interopDefault(fm);var Wu__default=/*#__PURE__*/_interopDefault(Wu);var Sw__default=/*#__PURE__*/_interopDefault(Sw);var fh__default=/*#__PURE__*/_interopDefault(fh);var hh__default=/*#__PURE__*/_interopDefault(hh);var Sh__default=/*#__PURE__*/_interopDefault(Sh);var _h__default=/*#__PURE__*/_interopDefault(_h);var Eh__default=/*#__PURE__*/_interopDefault(Eh);var Ea__default=/*#__PURE__*/_interopDefault(Ea);var Oh__default=/*#__PURE__*/_interopDefault(Oh);var Wh__default=/*#__PURE__*/_interopDefault(Wh);var nm__default=/*#__PURE__*/_interopDefault(nm);var vu=Object.create;var ht=Object.defineProperty;var Cu=Object.getOwnPropertyDescriptor;var mm=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),nr=n=>{throw TypeError(n)};var Iu=(n,t,e)=>t in n?ht(n,t,{enumerable:true,configurable:true,writable:true,value:e}):n[t]=e;var Oa=(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 dm=n=>{var t;return [,,,vu((t=void 0)!=null?t:null)]},um=["class","method","getter","setter","accessor","field","value","get","set"],ar=n=>n!==void 0&&typeof n!="function"?nr("Function expected"):n,ju=(n,t,e,o,i)=>({kind:um[n],name:t,metadata:o,addInitializer:a=>e._?nr("Already initialized"):i.push(ar(a||null))}),Wa=(n,t)=>Iu(t,mm("metadata"),n[3]),gm=(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},wm=(n,t,e,o,i,a)=>{var d,u,g,y,k=t&7,z=false,x=false,_=2,M=um[k+5],J=n[_]||(n[_]=[]),q=((i=i.prototype),Cu(i,e));for(var We=o.length-1;We>=0;We--)g=ju(k,e,u={},n[3],J),(g.static=z,g.private=x,y=g.access={has:oe=>e in oe},(y.get=oe=>oe[e]),k>2),d=(0, o[We])(q[M],g),u._=1,ar(d)&&(q[M]=d);return q&&ht(i,e,q),i};var Gm={};P(Gm,{Node18UniversalStreamWrapper:()=>an});var an,$m=Oa(()=>{an=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 Qm={};P(Qm,{UndiciStreamWrapper:()=>nn});var nn,Ym=Oa(()=>{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",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 Zm={};P(Zm,{NodePre18StreamWrapper:()=>sn});var sn,qm=Oa(()=>{sn=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 Fu={SILLY:0,TRACE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,FATAL:6};function ft(n,t=n){return ansiEscapes.link(t,n)}var S=new tslog.Logger({hideLogPositionForProduction:true,prettyLogTemplate:"{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}} {{logLevelName}} "}),hm=n=>{S.settings.minLevel=Fu[n];},Ou=()=>{S.settings.minLevel=100;};hm(process.env.OPIK_LOG_LEVEL||"INFO");var Bu="~/.opik.config",La={apiKey:"",apiUrl:"https://www.comet.com/opik/api",projectName:"Default Project",workspaceName:"default",batchDelayMs:300,holdUntilFlush:false};function Rm(n){return Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0))}function Lu(){return Rm({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 Vu(){let n=process.env.OPIK_CONFIG_PATH||Bu;if(!fm__default.default.existsSync(n)){if(process.env.OPIK_CONFIG_PATH)throw new Error(`Config file not found at ${n}`);return {}}try{let t=Wu__default.default.parse(fm__default.default.readFileSync(n,"utf8"));return t.opik?Rm({apiKey:t.opik.api_key,apiUrl:t.opik.url_override,projectName:t.opik.project_name,workspaceName:t.opik.workspace}):{}}catch(t){return S.error(`Error loading config file ${n}: ${t}`),{}}}function bm(n){let t=Lu(),e=Vu(),{headers:o,...i}=n||{};return Hu({...La,...e,...t,...i})}function Hu(n){if(!n.apiUrl)throw new Error("OPIK_URL_OVERRIDE is not set");let t=Ju(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 Ju(n){return new URL(n).hostname.endsWith("comet.com")}var X={};P(X,{AlertAlertType:()=>Ku,AlertPublicAlertType:()=>eg,AlertTriggerConfigPublicType:()=>Zu,AlertTriggerConfigType:()=>Gu,AlertTriggerConfigWriteType:()=>$u,AlertTriggerEventType:()=>Xu,AlertTriggerPublicEventType:()=>qu,AlertTriggerWriteEventType:()=>Qu,AlertWriteAlertType:()=>Yu,AnnotationQueuePublicScope:()=>ig,AnnotationQueueScope:()=>og,AnnotationQueueWriteScope:()=>tg,AssistantMessageRole:()=>fg,AttachmentListRequestEntityType:()=>km,BadRequestError:()=>T,CheckName:()=>Ng,CheckPublicName:()=>ww,CheckPublicResult:()=>hw,CheckResult:()=>Mg,ColumnCompareTypesItem:()=>xg,ColumnPublicTypesItem:()=>Ig,ColumnTypesItem:()=>jg,CompleteMultipartUploadRequestEntityType:()=>ag,ConflictError:()=>L,DatasetItemCompareSource:()=>_g,DatasetItemPublicSource:()=>vg,DatasetItemSource:()=>yg,DatasetItemWriteSource:()=>on,DatasetPublicVisibility:()=>Pg,DatasetUpdateVisibility:()=>Tm,DatasetVisibility:()=>bg,DatasetWriteVisibility:()=>_m,DeleteAttachmentsRequestEntityType:()=>ng,DownloadAttachmentRequestEntityType:()=>Sm,ExperimentItemCompareTraceVisibilityMode:()=>Tg,ExperimentItemPublicTraceVisibilityMode:()=>Cg,ExperimentItemTraceVisibilityMode:()=>kg,ExperimentPublicStatus:()=>Lg,ExperimentPublicType:()=>Bg,ExperimentStatus:()=>Ug,ExperimentType:()=>tn,ExperimentUpdateStatus:()=>vm,ExperimentUpdateType:()=>Pm,ExperimentWriteStatus:()=>Em,ExperimentWriteType:()=>Am,FeedbackScoreBatchItemSource:()=>uw,FeedbackScoreBatchItemThreadSource:()=>bw,FeedbackScoreCompareSource:()=>Ag,FeedbackScoreExperimentItemBulkWriteViewSource:()=>Fg,FeedbackScorePublicSource:()=>lw,FeedbackScoreSource:()=>Sg,FindFeedbackDefinitionsRequestType:()=>Cm,FindFeedbackScoreNames1RequestType:()=>Bm,ForbiddenError:()=>$,GetSpanStatsRequestType:()=>Lm,GetSpansByProjectRequestType:()=>Om,GetWebhookExamplesRequestAlertType:()=>ym,GuardrailName:()=>Vg,GuardrailResult:()=>Hg,GuardrailWriteName:()=>Jg,GuardrailWriteResult:()=>Kg,LlmAsJudgeMessagePublicRole:()=>ug,LlmAsJudgeMessageRole:()=>sg,LlmAsJudgeMessageWriteRole:()=>lg,LlmAsJudgeOutputSchemaPublicType:()=>gg,LlmAsJudgeOutputSchemaType:()=>pg,LlmAsJudgeOutputSchemaWriteType:()=>mg,LogItemLevel:()=>hg,ManualEvaluationRequestEntityType:()=>$g,NotFoundError:()=>A,NotImplementedError:()=>sr,OptimizationPublicStatus:()=>Zg,OptimizationStatus:()=>Qg,OptimizationUpdateStatus:()=>jm,OptimizationWriteStatus:()=>Yg,ProjectDetailedVisibility:()=>iw,ProjectMetricRequestPublicInterval:()=>Dm,ProjectMetricRequestPublicMetricType:()=>Mm,ProjectMetricResponsePublicInterval:()=>ow,ProjectMetricResponsePublicMetricType:()=>rw,ProjectPublicVisibility:()=>ew,ProjectUpdateVisibility:()=>Nm,ProjectVisibility:()=>qg,ProjectWriteVisibility:()=>Um,PromptType:()=>aw,PromptVersionDetailType:()=>sw,PromptVersionPublicType:()=>pw,PromptVersionType:()=>nw,PromptWriteType:()=>Fm,ProviderApiKeyProvider:()=>Gg,ProviderApiKeyPublicProvider:()=>Xg,ProviderApiKeyWriteProvider:()=>Im,ResponseFormatType:()=>Rg,SpanExperimentItemBulkWriteViewType:()=>Og,SpanFilterPublicOperator:()=>gw,SpanPublicType:()=>mw,SpanSearchStreamRequestPublicType:()=>Vm,SpanType:()=>we,SpanUpdateType:()=>Wm,SpanWriteType:()=>cw,StartMultipartUploadRequestEntityType:()=>zm,TraceFilterOperator:()=>cg,TraceFilterPublicOperator:()=>wg,TraceFilterWriteOperator:()=>dg,TracePublicVisibilityMode:()=>fw,TraceThreadFilterOperator:()=>yw,TraceThreadFilterPublicOperator:()=>tw,TraceThreadStatus:()=>Rw,TraceVisibilityMode:()=>Dg,UnauthorizedError:()=>K,UnprocessableEntityError:()=>F,UploadAttachmentRequestEntityType:()=>xm,ValueEntryCompareSource:()=>Eg,ValueEntryExperimentItemBulkWriteViewSource:()=>Wg,ValueEntryPublicSource:()=>dw,ValueEntrySource:()=>zg,WebhookTestResultStatus:()=>rg,alerts:()=>Rt,annotationQueues:()=>Ha,attachments:()=>bt,automationRuleEvaluators:()=>Ka,chatCompletions:()=>Xa,check:()=>Ja,datasets:()=>yt,experiments:()=>kt,feedbackDefinitions:()=>St,guardrails:()=>Ga,llmProviderKey:()=>zt,manualEvaluation:()=>$a,openTelemetryIngestion:()=>Qa,optimizations:()=>xt,projects:()=>_t,prompts:()=>Tt,redirect:()=>rn,serviceToggles:()=>Ya,spans:()=>At,systemUsage:()=>Va,traces:()=>Za,welcomeWizard:()=>qa,workspaces:()=>en});var Rt={};P(Rt,{GetWebhookExamplesRequestAlertType:()=>ym});var ym={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var bt={};P(bt,{AttachmentListRequestEntityType:()=>km,DownloadAttachmentRequestEntityType:()=>Sm,StartMultipartUploadRequestEntityType:()=>zm,UploadAttachmentRequestEntityType:()=>xm});var km={Trace:"trace",Span:"span"};var Sm={Trace:"trace",Span:"span"};var zm={Trace:"trace",Span:"span"};var xm={Trace:"trace",Span:"span"};var yt={};P(yt,{DatasetUpdateVisibility:()=>Tm,DatasetWriteVisibility:()=>_m});var _m={Private:"private",Public:"public"};var Tm={Private:"private",Public:"public"};var kt={};P(kt,{ExperimentUpdateStatus:()=>vm,ExperimentUpdateType:()=>Pm,ExperimentWriteStatus:()=>Em,ExperimentWriteType:()=>Am});var Am={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Em={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Pm={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var vm={Running:"running",Completed:"completed",Cancelled:"cancelled"};var St={};P(St,{FindFeedbackDefinitionsRequestType:()=>Cm});var Cm={Numerical:"numerical",Categorical:"categorical"};var zt={};P(zt,{ProviderApiKeyWriteProvider:()=>Im});var Im={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var xt={};P(xt,{OptimizationUpdateStatus:()=>jm});var jm={Running:"running",Completed:"completed",Cancelled:"cancelled"};var _t={};P(_t,{ProjectMetricRequestPublicInterval:()=>Dm,ProjectMetricRequestPublicMetricType:()=>Mm,ProjectUpdateVisibility:()=>Nm,ProjectWriteVisibility:()=>Um});var Um={Private:"private",Public:"public"};var Nm={Private:"private",Public:"public"};var Mm={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 Dm={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var Tt={};P(Tt,{PromptWriteType:()=>Fm});var Fm={Mustache:"mustache",Jinja2:"jinja2"};var At={};P(At,{FindFeedbackScoreNames1RequestType:()=>Bm,GetSpanStatsRequestType:()=>Lm,GetSpansByProjectRequestType:()=>Om,SpanSearchStreamRequestPublicType:()=>Vm,SpanUpdateType:()=>Wm});var Om={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Wm={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Bm={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Lm={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Vm={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Va={};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 Ku={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var Xu={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 Gu={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score"};var $u={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score"};var Qu={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 Yu={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var Zu={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score"};var qu={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 eg={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var rg={Success:"success",Failure:"failure"};var og={Trace:"trace",Thread:"thread"};var tg={Trace:"trace",Thread:"thread"};var ig={Trace:"trace",Thread:"thread"};var ag={Trace:"trace",Span:"span"};var ng={Trace:"trace",Span:"span"};var sg={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var pg={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 lg={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var mg={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var dg={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 ug={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var gg={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var wg={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 hg={Info:"INFO",Warn:"WARN",Error:"ERROR",Debug:"DEBUG",Trace:"TRACE"};var fg={System:"system",User:"user",Assistant:"assistant",Tool:"tool",Function:"function"};var Rg={Text:"text",JsonObject:"json_object",JsonSchema:"json_schema"};var bg={Private:"private",Public:"public"};var yg={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var kg={Default:"default",Hidden:"hidden"};var Sg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var zg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var on={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var xg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var _g={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Tg={Default:"default",Hidden:"hidden"};var Ag={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Eg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Pg={Private:"private",Public:"public"};var vg={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Cg={Default:"default",Hidden:"hidden"};var Ig={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var jg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var tn={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Ug={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Ng={Topic:"TOPIC",Pii:"PII"};var Mg={Passed:"passed",Failed:"failed"};var we={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Dg={Default:"default",Hidden:"hidden"};var Fg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Og={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Wg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Bg={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Lg={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Vg={Topic:"TOPIC",Pii:"PII"};var Hg={Passed:"passed",Failed:"failed"};var Jg={Topic:"TOPIC",Pii:"PII"};var Kg={Passed:"passed",Failed:"failed"};var Xg={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var Gg={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var $g={Trace:"trace",Thread:"thread"};var Qg={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Yg={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Zg={Running:"running",Completed:"completed",Cancelled:"cancelled"};var qg={Private:"private",Public:"public"};var ew={Private:"private",Public:"public"};var rw={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 ow={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var tw={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 iw={Private:"private",Public:"public"};var aw={Mustache:"mustache",Jinja2:"jinja2"};var nw={Mustache:"mustache",Jinja2:"jinja2"};var sw={Mustache:"mustache",Jinja2:"jinja2"};var pw={Mustache:"mustache",Jinja2:"jinja2"};var cw={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var lw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var mw={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var dw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var uw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var gw={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 ww={Topic:"TOPIC",Pii:"PII"};var hw={Passed:"passed",Failed:"failed"};var fw={Default:"default",Hidden:"hidden"};var Rw={Active:"active",Inactive:"inactive"};var bw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var yw={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 Be=(n,t,e)=>JSON.stringify(n,t,e);var p=class n extends Error{constructor({message:t,statusCode:e,body:o,rawResponse:i}){super(kw({message:t,statusCode:e,body:o})),Object.setPrototypeOf(this,n.prototype),this.statusCode=e,this.body=o,this.rawResponse=i;}};function kw({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: ${Be(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 f={Default:"http://localhost:5173/api"};var pr;typeof globalThis.Headers!="undefined"?pr=globalThis.Headers:pr=class Hm{constructor(t){if(this.headers=new Map,t)if(t instanceof Hm)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 Et={headers:new pr,redirected:false,status:499,statusText:"Client Closed Request",type:"error",url:""},Pt={headers:new pr,redirected:false,status:0,statusText:"Unknown Error",type:"error",url:""};function vt(n){return {headers:n.headers,redirected:n.redirected,status:n.status,statusText:n.statusText,type:n.type,url:n.url}}function Jm(n,t){return Object.keys(t!=null?t:{}).length>0?`${n}?${Sw__default.default.stringify(t,{arrayFormat:"repeat"})}`:n}var m=zw();function zw(){var u,g,y,k,z;return typeof window!="undefined"&&typeof window.document!="undefined"?{type:"browser",version:window.navigator.userAgent}:typeof globalThis!="undefined"&&((u=globalThis==null?void 0:globalThis.navigator)==null?void 0:u.userAgent)==="Cloudflare-Workers"?{type:"workerd"}:typeof EdgeRuntime=="string"?{type:"edge-runtime"}:typeof self=="object"&&typeof(self==null?void 0:self.importScripts)=="function"&&(((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&&!!((z=process.versions)!=null&&z.node)?{type:"node",version:process.versions.node,parsedVersion:Number(process.versions.node.split(".")[0])}:typeof navigator!="undefined"&&(navigator==null?void 0:navigator.product)==="ReactNative"?{type:"react-native"}:{type:"unknown"}}async function Km(){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 Xm({body:n,type:t}){return t.includes("json")?Be(n):n}async function ed(n){return m.type==="node"&&m.parsedVersion!=null&&m.parsedVersion>=18?new(await Promise.resolve().then(()=>($m(),Gm))).Node18UniversalStreamWrapper(n):m.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(Ym(),Qm))).UndiciStreamWrapper(n):new(await Promise.resolve().then(()=>(qm(),Zm))).NodePre18StreamWrapper(n)}async function rd(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 ed(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 xw="timeout";function od(n){let t=new AbortController,e=setTimeout(()=>t.abort(xw),n);return {signal:t.signal,abortId:e}}function td(...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 id=async(n,t,e,o,i,a,c,d,u)=>{let g=[],y;if(a!=null){let{signal:x,abortId:_}=od(a);y=_,g.push(x);}c!=null&&g.push(c);let k=td(g),z=await n(t,{method:e,headers:o,body:i,signal:k,credentials:d?"include":void 0,duplex:u});return y!=null&&clearTimeout(y),z};function _w(n){let t=1+(Math.random()*2-1)*.2;return n*t}async function ad(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=_w(i);await new Promise(c=>setTimeout(c,a)),e=await n();}return e}async function Tw(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=Jm(n.url,n.queryParameters),o=await Xm({body:n.body,type:n.requestType==="json"?"json":"other"}),i=await Km();try{let a=await ad(async()=>id(i,e,n.method,t,o,n.timeoutMs,n.abortSignal,n.withCredentials,n.duplex),n.maxRetries),c=await rd(a,n.responseType);return a.status>=200&&a.status<400?{ok:!0,body:c,headers:a.headers,rawResponse:vt(a)}:{ok:!1,error:{reason:"status-code",statusCode:a.status,body:c},rawResponse:vt(a)}}catch(a){return n.abortSignal!=null&&n.abortSignal.aborted?{ok:false,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:Et}:a instanceof Error&&a.name==="AbortError"?{ok:false,error:{reason:"timeout"},rawResponse:Et}:a instanceof Error?{ok:false,error:{reason:"unknown",errorMessage:a.message},rawResponse:Pt}:{ok:false,error:{reason:"unknown",errorMessage:Be(a)},rawResponse:Pt}}}var R=Tw;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:()=>Le,ParseError:()=>Ve,any:()=>yd,bigint:()=>sd,boolean:()=>kd,booleanLiteral:()=>bd,date:()=>pd,discriminant:()=>vd,enum_:()=>It,getObjectLikeUtils:()=>le,getObjectUtils:()=>Ce,getSchemaUtils:()=>C,isProperty:()=>ze,lazy:()=>cd,lazyObject:()=>hd,list:()=>Ut,number:()=>Sd,object:()=>jt,objectWithoutOptionalProperties:()=>wd,optional:()=>pn,property:()=>md,record:()=>Td,set:()=>Ad,string:()=>zd,stringLiteral:()=>Rd,transform:()=>cn,undiscriminatedUnion:()=>Pd,union:()=>Id,unknown:()=>xd,withParsedProperties:()=>mn});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 ${Aw(n)}.`}function Aw(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:nd(n.json),parse:nd(n.parse)}}function nd(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 Ct(n){return n.path.length===0?n.message:`${n.path.join(" -> ")}: ${n.message}`}var Le=class n extends Error{constructor(e){super(e.map(Ct).join("; "));this.errors=e;Object.setPrototypeOf(this,n.prototype);}};var Ve=class n extends Error{constructor(e){super(e.map(Ct).join("; "));this.errors=e;Object.setPrototypeOf(this,n.prototype);}};function C(n){return {nullable:()=>Ew(n),optional:()=>pn(n),optionalNullable:()=>Pw(n),transform:t=>cn(n,t),parseOrThrow:(t,e)=>{let o=n.parse(t,e);if(o.ok)return o.value;throw new Ve(o.errors)},jsonOrThrow:(t,e)=>{let o=n.json(t,e);if(o.ok)return o.value;throw new Le(o.errors)}}}function Ew(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 pn(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 Pw(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 cn(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 sd(){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 vw=/^([+-]?\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 pd(){let n={parse:(t,{breadcrumbsPrefix:e=[]}={})=>typeof t!="string"?{ok:false,errors:[{path:e,message:v(t,"string")}]}:vw.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 It(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 cd(n){let t=ln(n);return {...t,...C(t)}}function ln(n){return {parse:(t,e)=>He(n).parse(t,e),json:(t,e)=>He(n).json(t,e),getType:()=>He(n).getType()}}function He(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 ld(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=>mn(n,t)}}function mn(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 md(n,t){return {rawKey:n,valueSchema:t,isProperty:true}}function ze(n){return n.isProperty}function jt(n){let t={_getRawProperties:()=>Object.entries(n).map(([e,o])=>ze(o)?o.rawKey:e),_getParsedProperties:()=>mr(n),parse:(e,o)=>{let i={},a=[];for(let[c,d]of cr(n)){let u=ze(d)?d.rawKey:c,g=ze(d)?d.valueSchema:d,y={rawKey:u,parsedKey:c,valueSchema:g};i[u]=y,gd(g)&&a.push(u);}return dd({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=ze(c)?c.valueSchema:c;gd(d)&&i.push(a);}return dd({value:e,requiredKeys:i,getProperty:a=>{let c=n[a];if(c!=null)return ze(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),...Ce(t)}}function dd({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 z=k.transform(y);z.ok?u[k.transformedKey]=z.value:(u[g]=y,d.push(...z.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 Ce(n){return {extend:t=>{let e={_getParsedProperties:()=>[...n._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...n._getRawProperties(),...t._getRawProperties()],parse:(o,i)=>ud({extensionKeys:t._getRawProperties(),value:o,transformBase:a=>n.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(o,i)=>ud({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),...Ce(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),...Ce(t)}}}}function ud({extensionKeys:n,value:t,transformBase:e,transformExtension:o}){let i=new Set(n),[a,c]=ld(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 gd(n){return !Cw(n)}function Cw(n){switch(n.getType()){case E.ANY:case E.UNKNOWN:case E.OPTIONAL:case E.OPTIONAL_NULLABLE:return true;default:return false}}function wd(n){return jt(n)}function hd(n){let t={...ln(n),_getRawProperties:()=>He(n)._getRawProperties(),_getParsedProperties:()=>He(n)._getParsedProperties()};return {...t,...C(t),...le(t),...Ce(t)}}function Ut(n){let t={parse:(e,o)=>fd(e,(i,a)=>{var c;return n.parse(i,{...o,breadcrumbsPrefix:[...(c=o==null?void 0:o.breadcrumbsPrefix)!=null?c:[],`[${a}]`]})}),json:(e,o)=>fd(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 fd(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 Rd(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 bd(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 yd=Q(E.ANY,n=>({ok:true,value:n}));var kd=Q(E.BOOLEAN,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="boolean"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:v(n,"boolean")}]});var Sd=Q(E.NUMBER,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="number"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:v(n,"number")}]});var zd=Q(E.STRING,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="string"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:v(n,"string")}]});var xd=Q(E.UNKNOWN,n=>({ok:true,value:n}));function Td(n,t){let e={parse:(o,i)=>_d({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)=>_d({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 _d({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 z=[];return u.ok||z.push(...u.errors),y.ok||z.push(...y.errors),k.ok||z.push(...k.errors),{ok:false,errors:z}},{ok:true,value:{}}):{ok:false,errors:[{path:i,message:v(n,"object")}]}}function Ad(n){let t=Ut(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 Pd(n){let t={parse:(e,o)=>Ed((i,a)=>i.parse(e,a),n,o),json:(e,o)=>Ed((i,a)=>i.json(e,a),n,o),getType:()=>E.UNDISCRIMINATED_UNION};return {...G(t),...C(t)}}function Ed(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 Id(n,t){let e=typeof n=="string"?n:n.rawDiscriminant,o=typeof n=="string"?n:n.parsedDiscriminant,i=It(mr(t)),a={parse:(c,d)=>Cd({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)=>Cd({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 Cd({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 z=c(g,k);return z.ok?{ok:true,value:{[e]:u,...z.value}}:z}function Iw(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),Iw(n)}var I={};P(I,{AggregationData:()=>Sc,Alert:()=>Fw,AlertAlertType:()=>os,AlertPagePublic:()=>ys,AlertPublic:()=>uo,AlertPublicAlertType:()=>gs,AlertTrigger:()=>ss,AlertTriggerConfig:()=>ns,AlertTriggerConfigPublic:()=>Rs,AlertTriggerConfigPublicType:()=>fs,AlertTriggerConfigType:()=>as,AlertTriggerConfigWrite:()=>cs,AlertTriggerConfigWriteType:()=>ps,AlertTriggerEventType:()=>is,AlertTriggerPublic:()=>bs,AlertTriggerPublicEventType:()=>hs,AlertTriggerWrite:()=>ms,AlertTriggerWriteEventType:()=>ls,AlertWrite:()=>mo,AlertWriteAlertType:()=>ds,AnnotationQueue:()=>Ts,AnnotationQueueBatch:()=>Ww,AnnotationQueueBatchWrite:()=>ao,AnnotationQueueItemIds:()=>Si,AnnotationQueuePagePublic:()=>Ps,AnnotationQueuePublic:()=>go,AnnotationQueuePublicScope:()=>As,AnnotationQueueReviewer:()=>_s,AnnotationQueueReviewerPublic:()=>Es,AnnotationQueueScope:()=>xs,AnnotationQueueUpdate:()=>no,AnnotationQueueWrite:()=>io,AnnotationQueueWriteScope:()=>Bn,AssistantMessage:()=>Sp,AssistantMessageRole:()=>kp,Attachment:()=>vs,AttachmentListRequestEntityType:()=>Dt,AttachmentPage:()=>Cs,AuthDetailsHolder:()=>Ms,AutomationRuleEvaluator:()=>Lw,AutomationRuleEvaluatorLlmAsJudge:()=>Bs,AutomationRuleEvaluatorLlmAsJudgePublic:()=>Po,AutomationRuleEvaluatorLlmAsJudgeWrite:()=>Gs,AutomationRuleEvaluatorObjectPublic:()=>lp,AutomationRuleEvaluatorPagePublic:()=>mp,AutomationRuleEvaluatorPublic:()=>dp,AutomationRuleEvaluatorTraceThreadLlmAsJudge:()=>Vs,AutomationRuleEvaluatorTraceThreadLlmAsJudgePublic:()=>Co,AutomationRuleEvaluatorTraceThreadLlmAsJudgeWrite:()=>Qs,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPython:()=>Hs,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPythonPublic:()=>Io,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPythonWrite:()=>Zs,AutomationRuleEvaluatorUpdate:()=>yp,AutomationRuleEvaluatorUpdateLlmAsJudge:()=>hp,AutomationRuleEvaluatorUpdateTraceThreadLlmAsJudge:()=>Rp,AutomationRuleEvaluatorUpdateTraceThreadUserDefinedMetricPython:()=>bp,AutomationRuleEvaluatorUpdateUserDefinedMetricPython:()=>fp,AutomationRuleEvaluatorUserDefinedMetricPython:()=>Ls,AutomationRuleEvaluatorUserDefinedMetricPythonPublic:()=>vo,AutomationRuleEvaluatorUserDefinedMetricPythonWrite:()=>ep,AutomationRuleEvaluatorWrite:()=>tp,AvgValueStatPublic:()=>Kp,BatchDelete:()=>W,BatchDeleteByProject:()=>ph,BiInformation:()=>Yn,BiInformationResponse:()=>Ge,CategoricalFeedbackDefinition:()=>Ac,CategoricalFeedbackDefinitionCreate:()=>Cc,CategoricalFeedbackDefinitionPublic:()=>Bo,CategoricalFeedbackDefinitionUpdate:()=>Bc,CategoricalFeedbackDetail:()=>Tc,CategoricalFeedbackDetailCreate:()=>vc,CategoricalFeedbackDetailPublic:()=>Nc,CategoricalFeedbackDetailUpdate:()=>Wc,ChatCompletionChoice:()=>xp,ChatCompletionRequest:()=>po,ChatCompletionResponse:()=>Ep,Check:()=>lc,CheckName:()=>pc,CheckPublic:()=>Ol,CheckPublicName:()=>Dl,CheckPublicResult:()=>Fl,CheckResult:()=>cc,ChunkedOutputJsonNode:()=>Kw,ChunkedOutputJsonNodePublic:()=>Qw,ChunkedOutputJsonNodePublicType:()=>_c,ChunkedOutputJsonNodeType:()=>ac,Column:()=>tc,ColumnCompare:()=>jp,ColumnCompareTypesItem:()=>Ip,ColumnPublic:()=>ec,ColumnPublicTypesItem:()=>qp,ColumnTypesItem:()=>oc,Comment:()=>B,CommentCompare:()=>Up,CommentPublic:()=>Ne,CompleteMultipartUploadRequest:()=>zi,CompleteMultipartUploadRequestEntityType:()=>Is,CompletionTokensDetails:()=>Tp,CountValueStatPublic:()=>Xp,CreateDatasetItemsFromSpansRequest:()=>wr,CreateDatasetItemsFromTracesRequest:()=>hr,CreatePromptVersionDetail:()=>Wr,DataPointDouble:()=>ch,DataPointNumberPublic:()=>sl,Dataset:()=>Vw,DatasetExpansion:()=>Jw,DatasetExpansionResponse:()=>Cp,DatasetExpansionWrite:()=>yr,DatasetIdentifier:()=>Rr,DatasetIdentifierPublic:()=>kr,DatasetItem:()=>Uo,DatasetItemBatch:()=>Hw,DatasetItemBatchWrite:()=>gr,DatasetItemCompare:()=>Lp,DatasetItemCompareSource:()=>Np,DatasetItemPageCompare:()=>Vp,DatasetItemPagePublic:()=>rc,DatasetItemPublic:()=>Do,DatasetItemPublicSource:()=>Yp,DatasetItemSource:()=>vp,DatasetItemStreamRequest:()=>Sr,DatasetItemWrite:()=>un,DatasetItemWriteSource:()=>dn,DatasetItemsDelete:()=>br,DatasetPagePublic:()=>Jp,DatasetPublic:()=>$e,DatasetPublicVisibility:()=>Hp,DatasetUpdate:()=>fr,DatasetUpdateVisibility:()=>Vt,DatasetVisibility:()=>Pp,DatasetWrite:()=>ur,DatasetWriteVisibility:()=>Lt,DeleteAttachmentsRequest:()=>Bw,DeleteAttachmentsRequestEntityType:()=>Us,DeleteFeedbackScore:()=>Xo,DeleteIdsHolder:()=>Qe,DeleteThreadFeedbackScores:()=>Zr,DeleteTraceThreads:()=>qr,Delta:()=>zp,DownloadAttachmentRequestEntityType:()=>Ft,ErrorCountWithDeviation:()=>Jo,ErrorCountWithDeviationDetailed:()=>gl,ErrorInfo:()=>Re,ErrorInfoExperimentItemBulkWriteView:()=>Ar,ErrorInfoPublic:()=>Go,ErrorInfoWrite:()=>Vr,ErrorMessage:()=>ee,ErrorMessageDetail:()=>ah,ErrorMessageDetailed:()=>th,ErrorMessagePublic:()=>Ow,Experiment:()=>Xw,ExperimentGroupAggregationsResponse:()=>xc,ExperimentGroupResponse:()=>kc,ExperimentItem:()=>xr,ExperimentItemBulkRecord:()=>gc,ExperimentItemBulkRecordExperimentItemBulkWriteView:()=>An,ExperimentItemBulkUpload:()=>Gw,ExperimentItemBulkUploadExperimentItemBulkWriteView:()=>Er,ExperimentItemCompare:()=>Bp,ExperimentItemCompareTraceVisibilityMode:()=>Wp,ExperimentItemPublic:()=>Mo,ExperimentItemPublicTraceVisibilityMode:()=>Zp,ExperimentItemStreamRequest:()=>vr,ExperimentItemTraceVisibilityMode:()=>bn,ExperimentItemsBatch:()=>_r,ExperimentItemsDelete:()=>Tr,ExperimentPagePublic:()=>fc,ExperimentPublic:()=>Wo,ExperimentPublicStatus:()=>hc,ExperimentPublicType:()=>wc,ExperimentStatus:()=>sc,ExperimentStreamRequestPublic:()=>Cr,ExperimentType:()=>nc,ExperimentUpdate:()=>Pr,ExperimentUpdateStatus:()=>Gt,ExperimentUpdateType:()=>Xt,ExperimentWrite:()=>zr,ExperimentWriteStatus:()=>Kt,ExperimentWriteType:()=>Jt,ExportTraceServiceRequest:()=>eh,Feedback:()=>Yw,FeedbackCreate:()=>Uc,FeedbackDefinitionPagePublic:()=>Fc,FeedbackObjectPublic:()=>Dc,FeedbackPublic:()=>Oc,FeedbackScore:()=>Y,FeedbackScoreAverage:()=>ie,FeedbackScoreAverageDetailed:()=>wl,FeedbackScoreAveragePublic:()=>je,FeedbackScoreBatch:()=>Yo,FeedbackScoreBatchItem:()=>Ml,FeedbackScoreBatchItemSource:()=>Nl,FeedbackScoreBatchItemThread:()=>Fn,FeedbackScoreBatchItemThreadSource:()=>Dn,FeedbackScoreBatchThread:()=>eo,FeedbackScoreCompare:()=>Op,FeedbackScoreCompareSource:()=>Mp,FeedbackScoreExperimentItemBulkWriteView:()=>Tn,FeedbackScoreExperimentItemBulkWriteViewSource:()=>zn,FeedbackScoreNames:()=>nl,FeedbackScorePublic:()=>$o,FeedbackScorePublicSource:()=>vl,FeedbackScoreSource:()=>hn,FeedbackUpdate:()=>Hc,FindFeedbackDefinitionsRequestType:()=>Yt,FindFeedbackScoreNames1RequestType:()=>di,Function:()=>so,FunctionCall:()=>be,GetSpanStatsRequestType:()=>ui,GetSpansByProjectRequestType:()=>li,GetWebhookExamplesRequestAlertType:()=>Nt,GroupContent:()=>Rc,GroupContentWithAggregations:()=>zc,GroupDetail:()=>bc,GroupDetails:()=>yc,Guardrail:()=>Xc,GuardrailBatch:()=>Zw,GuardrailBatchWrite:()=>co,GuardrailName:()=>Jc,GuardrailResult:()=>Kc,GuardrailWrite:()=>Qn,GuardrailWriteName:()=>Gn,GuardrailWriteResult:()=>$n,GuardrailsValidation:()=>mc,GuardrailsValidationPublic:()=>Wl,IdsHolder:()=>$w,JsonListString:()=>U,JsonListStringCompare:()=>Pi,JsonListStringExperimentItemBulkWriteView:()=>me,JsonListStringPublic:()=>ae,JsonListStringWrite:()=>te,JsonNode:()=>O,JsonNodeDetail:()=>In,JsonNodePublic:()=>zl,JsonNodeWrite:()=>Cn,JsonSchema:()=>Jn,LlmAsJudgeCode:()=>bo,LlmAsJudgeCodePublic:()=>np,LlmAsJudgeCodeWrite:()=>Xs,LlmAsJudgeMessage:()=>fo,LlmAsJudgeMessagePublic:()=>Ao,LlmAsJudgeMessagePublicRole:()=>ip,LlmAsJudgeMessageRole:()=>Os,LlmAsJudgeMessageWrite:()=>xo,LlmAsJudgeMessageWriteRole:()=>Js,LlmAsJudgeModelParameters:()=>ho,LlmAsJudgeModelParametersPublic:()=>To,LlmAsJudgeModelParametersWrite:()=>zo,LlmAsJudgeOutputSchema:()=>Ro,LlmAsJudgeOutputSchemaPublic:()=>Eo,LlmAsJudgeOutputSchemaPublicType:()=>ap,LlmAsJudgeOutputSchemaType:()=>Ws,LlmAsJudgeOutputSchemaWrite:()=>_o,LlmAsJudgeOutputSchemaWriteType:()=>Ks,LogItem:()=>gp,LogItemLevel:()=>up,LogPage:()=>wp,ManualEvaluationRequest:()=>ji,ManualEvaluationRequestEntityType:()=>Yc,ManualEvaluationResponse:()=>Ii,Message:()=>Ln,MultipartUploadPart:()=>js,NumericalFeedbackDefinition:()=>Pc,NumericalFeedbackDefinitionCreate:()=>jc,NumericalFeedbackDefinitionPublic:()=>Lo,NumericalFeedbackDefinitionUpdate:()=>Vc,NumericalFeedbackDetail:()=>Ec,NumericalFeedbackDetailCreate:()=>Ic,NumericalFeedbackDetailPublic:()=>Mc,NumericalFeedbackDetailUpdate:()=>Lc,Optimization:()=>rh,OptimizationPagePublic:()=>rl,OptimizationPublic:()=>Ho,OptimizationPublicStatus:()=>el,OptimizationStatus:()=>Zc,OptimizationUpdate:()=>Ur,OptimizationUpdateStatus:()=>ri,OptimizationWrite:()=>Ui,OptimizationWriteStatus:()=>qc,PageColumns:()=>ic,PercentageValueStatPublic:()=>Gp,PercentageValues:()=>ye,PercentageValuesDetailed:()=>hl,PercentageValuesPublic:()=>No,Project:()=>oh,ProjectDetailed:()=>Rl,ProjectDetailedVisibility:()=>fl,ProjectMetricRequestPublic:()=>Dr,ProjectMetricRequestPublicInterval:()=>ni,ProjectMetricRequestPublicMetricType:()=>ai,ProjectMetricResponsePublic:()=>ml,ProjectMetricResponsePublicInterval:()=>cl,ProjectMetricResponsePublicMetricType:()=>pl,ProjectPagePublic:()=>il,ProjectPublic:()=>Ko,ProjectPublicVisibility:()=>tl,ProjectRetrieveDetailed:()=>Fr,ProjectStatItemObjectPublic:()=>Qp,ProjectStatsPublic:()=>Ue,ProjectStatsSummary:()=>ul,ProjectStatsSummaryItem:()=>dl,ProjectUpdate:()=>Mr,ProjectUpdateVisibility:()=>ii,ProjectVisibility:()=>ol,ProjectWrite:()=>Nr,ProjectWriteVisibility:()=>ti,Prompt:()=>ih,PromptDetail:()=>Sl,PromptPagePublic:()=>El,PromptPublic:()=>Al,PromptTokensDetails:()=>_p,PromptType:()=>bl,PromptUpdatable:()=>Br,PromptVersion:()=>kl,PromptVersionDetail:()=>he,PromptVersionDetailType:()=>jn,PromptVersionLink:()=>vi,PromptVersionLinkPublic:()=>Ci,PromptVersionLinkWrite:()=>Qt,PromptVersionPagePublic:()=>Tl,PromptVersionPublic:()=>_l,PromptVersionPublicType:()=>xl,PromptVersionRetrieveDetail:()=>Lr,PromptVersionType:()=>yl,PromptWrite:()=>Or,PromptWriteType:()=>pi,ProviderApiKey:()=>qw,ProviderApiKeyPagePublic:()=>$c,ProviderApiKeyProvider:()=>Qc,ProviderApiKeyPublic:()=>Vo,ProviderApiKeyPublicProvider:()=>Gc,ProviderApiKeyUpdate:()=>jr,ProviderApiKeyWrite:()=>Ir,ProviderApiKeyWriteProvider:()=>qt,ResponseFormat:()=>Kn,ResponseFormatType:()=>Hn,Result:()=>Me,ResultsNumberPublic:()=>ll,ScoreName:()=>al,ServiceTogglesConfig:()=>Pl,Span:()=>Oo,SpanBatch:()=>nh,SpanBatchWrite:()=>Jr,SpanEnrichmentOptions:()=>gn,SpanExperimentItemBulkWriteView:()=>Sn,SpanExperimentItemBulkWriteViewType:()=>kn,SpanFilterPublic:()=>Mn,SpanFilterPublicOperator:()=>Nn,SpanPagePublic:()=>Ul,SpanPublic:()=>Qo,SpanPublicType:()=>jl,SpanSearchStreamRequestPublic:()=>Xr,SpanSearchStreamRequestPublicType:()=>gi,SpanType:()=>uc,SpanUpdate:()=>Kr,SpanUpdateType:()=>mi,SpanWrite:()=>Hr,SpanWriteType:()=>Un,SpansCountResponse:()=>qn,StartMultipartUploadRequest:()=>dr,StartMultipartUploadRequestEntityType:()=>Ot,StartMultipartUploadResponse:()=>Ns,StreamOptions:()=>Vn,Tool:()=>Xn,ToolCall:()=>jo,Trace:()=>Fo,TraceBatch:()=>sh,TraceBatchWrite:()=>Qr,TraceCountResponse:()=>rs,TraceEnrichmentOptions:()=>wn,TraceExperimentItemBulkWriteView:()=>yn,TraceFilter:()=>wo,TraceFilterOperator:()=>Fs,TraceFilterPublic:()=>fe,TraceFilterPublicOperator:()=>En,TraceFilterWrite:()=>op,TraceFilterWriteOperator:()=>rp,TracePagePublic:()=>Hl,TracePublic:()=>Zo,TracePublicVisibilityMode:()=>Bl,TraceSearchStreamRequestPublic:()=>oo,TraceThread:()=>qo,TraceThreadBatchIdentifier:()=>Gr,TraceThreadFilter:()=>Wn,TraceThreadFilterOperator:()=>On,TraceThreadFilterPublic:()=>vn,TraceThreadFilterPublicOperator:()=>Pn,TraceThreadIdentifier:()=>Ni,TraceThreadLlmAsJudgeCode:()=>ko,TraceThreadLlmAsJudgeCodePublic:()=>pp,TraceThreadLlmAsJudgeCodeWrite:()=>$s,TraceThreadPage:()=>Vl,TraceThreadSearchStreamRequest:()=>ro,TraceThreadStatus:()=>Ll,TraceThreadUpdate:()=>to,TraceThreadUserDefinedMetricPythonCode:()=>So,TraceThreadUserDefinedMetricPythonCodePublic:()=>cp,TraceThreadUserDefinedMetricPythonCodeWrite:()=>Ys,TraceUpdate:()=>Yr,TraceVisibilityMode:()=>dc,TraceWrite:()=>$r,UploadAttachmentRequestEntityType:()=>Wt,Usage:()=>Ap,UserDefinedMetricPythonCode:()=>yo,UserDefinedMetricPythonCodePublic:()=>sp,UserDefinedMetricPythonCodeWrite:()=>qs,ValueEntry:()=>Rn,ValueEntryCompare:()=>Fp,ValueEntryCompareSource:()=>Dp,ValueEntryExperimentItemBulkWriteView:()=>_n,ValueEntryExperimentItemBulkWriteViewSource:()=>xn,ValueEntryPublic:()=>Il,ValueEntryPublicSource:()=>Cl,ValueEntrySource:()=>fn,Webhook:()=>ts,WebhookExamples:()=>ks,WebhookPublic:()=>ws,WebhookTestResult:()=>zs,WebhookTestResultStatus:()=>Ss,WebhookWrite:()=>us,WelcomeWizardSubmission:()=>lo,WelcomeWizardTracking:()=>Jl,WorkspaceConfiguration:()=>et,WorkspaceMetricRequest:()=>lh,WorkspaceMetricResponse:()=>Mi,WorkspaceMetricsSummaryRequest:()=>Ye,WorkspaceMetricsSummaryResponse:()=>Kl,WorkspaceNameHolder:()=>Ds,WorkspaceSpansCount:()=>Zn,WorkspaceTraceCount:()=>es,alerts:()=>Mt,annotationQueues:()=>Ri,attachments:()=>Je,chatCompletions:()=>bi,datasets:()=>Ht,experiments:()=>Ke,feedbackDefinitions:()=>Zt,guardrails:()=>yi,llmProviderKey:()=>ei,optimizations:()=>oi,projects:()=>si,prompts:()=>ci,spans:()=>Xe,traces:()=>Ie,welcomeWizard:()=>ki});var Mt={};P(Mt,{GetWebhookExamplesRequestAlertType:()=>Nt});var Nt=r.enum_(["general","slack","pagerduty"]);var Je={};P(Je,{AttachmentListRequestEntityType:()=>Dt,DownloadAttachmentRequestEntityType:()=>Ft,StartMultipartUploadRequest:()=>dr,StartMultipartUploadRequestEntityType:()=>Ot,UploadAttachmentRequestEntityType:()=>Wt,uploadAttachment:()=>Bt});var Dt=r.enum_(["trace","span"]);var Ft=r.enum_(["trace","span"]);var Ot=r.enum_(["trace","span"]);var Wt=r.enum_(["trace","span"]);var Bt={};P(Bt,{Request:()=>jw});var jw=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",Ot),entityId:r.property("entity_id",r.string()),path:r.string()});var Ht={};P(Ht,{CreateDatasetItemsFromSpansRequest:()=>wr,CreateDatasetItemsFromTracesRequest:()=>hr,DatasetExpansionWrite:()=>yr,DatasetIdentifier:()=>Rr,DatasetIdentifierPublic:()=>kr,DatasetItemBatchWrite:()=>gr,DatasetItemStreamRequest:()=>Sr,DatasetItemsDelete:()=>br,DatasetUpdate:()=>fr,DatasetUpdateVisibility:()=>Vt,DatasetWrite:()=>ur,DatasetWriteVisibility:()=>Lt});var Lt=r.enum_(["private","public"]);var Vt=r.enum_(["private","public"]);var ur=r.object({id:r.string().optional(),name:r.string(),visibility:Lt.optional(),tags:r.list(r.string()).optional(),description:r.string().optional()});var dn=r.enum_(["manual","trace","span","sdk"]);var O=r.record(r.string(),r.unknown());var un=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:dn,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(un)});var gn=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",gn)});var wn=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 hr=r.object({traceIds:r.property("trace_ids",r.list(r.string())),enrichmentOptions:r.property("enrichment_options",wn)});var fr=r.object({name:r.string(),description:r.string().optional(),visibility:Vt.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 Sr=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 Ke={};P(Ke,{ExperimentItemBulkUploadExperimentItemBulkWriteView:()=>Er,ExperimentItemStreamRequest:()=>vr,ExperimentItemsBatch:()=>_r,ExperimentItemsDelete:()=>Tr,ExperimentStreamRequestPublic:()=>Cr,ExperimentUpdate:()=>Pr,ExperimentUpdateStatus:()=>Gt,ExperimentUpdateType:()=>Xt,ExperimentWrite:()=>zr,ExperimentWriteStatus:()=>Kt,ExperimentWriteType:()=>Jt,findFeedbackScoreNames:()=>$t});var Jt=r.enum_(["regular","trial","mini-batch"]);var Kt=r.enum_(["running","completed","cancelled"]);var Xt=r.enum_(["regular","trial","mini-batch"]);var Gt=r.enum_(["running","completed","cancelled"]);var $t={};P($t,{Response:()=>Uw});var Uw=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 Qt=r.object({id:r.string()});var zr=r.object({id:r.string().optional(),datasetName:r.property("dataset_name",r.string()),name:r.string().optional(),metadata:te.optional(),type:Jt.optional(),optimizationId:r.property("optimization_id",r.string().optional()),status:Kt.optional(),promptVersion:r.property("prompt_version",Qt.optional()),promptVersions:r.property("prompt_versions",r.list(Qt).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 fn=r.enum_(["ui","sdk","online_scoring"]);var Rn=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:fn.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(),Rn).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 bn=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",bn.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 yn=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 kn=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:kn.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 zn=r.enum_(["ui","sdk","online_scoring"]);var xn=r.enum_(["ui","sdk","online_scoring"]);var _n=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:xn.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Tn=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:zn,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(),_n).optional())});var An=r.object({datasetItemId:r.property("dataset_item_id",r.string()),evaluateTaskResult:r.property("evaluate_task_result",me.optional()),trace:yn.optional(),spans:r.list(Sn).optional(),feedbackScores:r.property("feedback_scores",r.list(Tn).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(An)});var Pr=r.object({name:r.string().optional(),metadata:O.optional(),type:Xt.optional(),status:Gt.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 Zt={};P(Zt,{FindFeedbackDefinitionsRequestType:()=>Yt});var Yt=r.enum_(["numerical","categorical"]);var ei={};P(ei,{ProviderApiKeyUpdate:()=>jr,ProviderApiKeyWrite:()=>Ir,ProviderApiKeyWriteProvider:()=>qt});var qt=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var Ir=r.object({provider:qt,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 oi={};P(oi,{OptimizationUpdate:()=>Ur,OptimizationUpdateStatus:()=>ri});var ri=r.enum_(["running","completed","cancelled"]);var Ur=r.object({name:r.string().optional(),status:ri.optional()});var si={};P(si,{ProjectMetricRequestPublic:()=>Dr,ProjectMetricRequestPublicInterval:()=>ni,ProjectMetricRequestPublicMetricType:()=>ai,ProjectRetrieveDetailed:()=>Fr,ProjectUpdate:()=>Mr,ProjectUpdateVisibility:()=>ii,ProjectWrite:()=>Nr,ProjectWriteVisibility:()=>ti});var ti=r.enum_(["private","public"]);var ii=r.enum_(["private","public"]);var ai=r.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST","GUARDRAILS_FAILED_COUNT","THREAD_COUNT","THREAD_DURATION","THREAD_FEEDBACK_SCORES"]);var ni=r.enum_(["HOURLY","DAILY","WEEKLY"]);var Nr=r.object({name:r.string(),visibility:ti.optional(),description:r.string().optional()});var Mr=r.object({name:r.string().optional(),description:r.string().optional(),visibility:ii.optional()});var En=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var fe=r.object({field:r.string().optional(),operator:En.optional(),key:r.string().optional(),value:r.string().optional()});var Pn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var vn=r.object({field:r.string().optional(),operator:Pn.optional(),key:r.string().optional(),value:r.string().optional()});var Dr=r.object({metricType:r.property("metric_type",ai.optional()),interval:ni.optional(),intervalStart:r.property("interval_start",r.date().optional()),intervalEnd:r.property("interval_end",r.date().optional()),traceFilters:r.property("trace_filters",r.list(fe).optional()),threadFilters:r.property("thread_filters",r.list(vn).optional())});var Fr=r.object({name:r.string()});var ci={};P(ci,{CreatePromptVersionDetail:()=>Wr,PromptUpdatable:()=>Br,PromptVersionRetrieveDetail:()=>Lr,PromptWrite:()=>Or,PromptWriteType:()=>pi});var pi=r.enum_(["mustache","jinja2"]);var Cn=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:Cn.optional(),changeDescription:r.property("change_description",r.string().optional()),type:pi.optional(),tags:r.list(r.string()).optional()});var In=r.record(r.string(),r.unknown());var jn=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:In.optional(),type:jn.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:he});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 Xe={};P(Xe,{FindFeedbackScoreNames1RequestType:()=>di,GetSpanStatsRequestType:()=>ui,GetSpansByProjectRequestType:()=>li,SpanBatchWrite:()=>Jr,SpanSearchStreamRequestPublic:()=>Xr,SpanSearchStreamRequestPublicType:()=>gi,SpanUpdate:()=>Kr,SpanUpdateType:()=>mi,findFeedbackScoreNames1:()=>wi});var li=r.enum_(["general","tool","llm","guardrail"]);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={};P(wi,{Response:()=>Nw});var Nw=r.list(r.string());var Un=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:Un.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 Re=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:mi.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",Re.optional())});var Nn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Mn=r.object({field:r.string().optional(),operator:Nn.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:gi.optional(),filters:r.list(Mn).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 Ie={};P(Ie,{DeleteThreadFeedbackScores:()=>Zr,DeleteTraceThreads:()=>qr,FeedbackScoreBatchThread:()=>eo,TraceBatchWrite:()=>Qr,TraceSearchStreamRequestPublic:()=>oo,TraceThreadBatchIdentifier:()=>Gr,TraceThreadSearchStreamRequest:()=>ro,TraceThreadUpdate:()=>to,TraceUpdate:()=>Yr,findFeedbackScoreNames2:()=>hi,findTraceThreadsFeedbackScoreNames:()=>fi});var hi={};P(hi,{Response:()=>Mw});var Mw=r.list(r.string());var fi={};P(fi,{Response:()=>Dw});var Dw=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",Re.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 Dn=r.enum_(["ui","sdk","online_scoring"]);var Fn=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:Dn,author:r.string().optional(),threadId:r.property("thread_id",r.string())});var eo=r.object({scores:r.list(Fn)});var On=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Wn=r.object({field:r.string().optional(),operator:On.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(Wn).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(fe).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 Ri={};P(Ri,{AnnotationQueueBatchWrite:()=>ao,AnnotationQueueUpdate:()=>no});var Bn=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:Bn,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 bi={};P(bi,{ChatCompletionRequest:()=>po});var Ln=r.record(r.string(),r.unknown());var Vn=r.object({includeUsage:r.property("include_usage",r.boolean().optional())});var Hn=r.enum_(["text","json_object","json_schema"]);var Jn=r.object({name:r.string().optional(),strict:r.boolean().optional(),schema:r.record(r.string(),r.record(r.string(),r.unknown())).optional()});var Kn=r.object({type:Hn.optional(),jsonSchema:r.property("json_schema",Jn.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 Xn=r.object({type:r.stringLiteral("function").optional(),function:so.optional()});var be=r.object({name:r.string().optional(),arguments:r.string().optional()});var po=r.object({model:r.string().optional(),messages:r.list(Ln).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",Vn.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",Kn.optional()),seed:r.number().optional(),tools:r.list(Xn).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",be.optional())});var yi={};P(yi,{GuardrailBatchWrite:()=>co});var Gn=r.enum_(["TOPIC","PII"]);var $n=r.enum_(["passed","failed"]);var Qn=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:Gn,result:$n,config:O,details:O});var co=r.object({guardrails:r.list(Qn)});var ki={};P(ki,{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 Yn=r.object({workspaceId:r.property("workspace_id",r.string().optional()),user:r.string().optional(),count:r.number().optional()});var Ge=r.object({biInformation:r.property("bi_information",r.list(Yn).optional())});var Zn=r.object({workspace:r.string().optional(),spanCount:r.property("span_count",r.number().optional())});var qn=r.object({workspacesSpansCount:r.property("workspaces_spans_count",r.list(Zn).optional())});var es=r.object({workspace:r.string().optional(),traceCount:r.property("trace_count",r.number().optional())});var rs=r.object({workspacesTracesCount:r.property("workspaces_traces_count",r.list(es).optional())});var ee=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var os=r.enum_(["general","slack","pagerduty"]);var ts=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 is=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 as=r.enum_(["scope:project","threshold:feedback_score"]);var ns=r.object({id:r.string().optional(),alertTriggerId:r.property("alert_trigger_id",r.string().optional()),type:as,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 ss=r.object({id:r.string().optional(),alertId:r.property("alert_id",r.string().optional()),eventType:r.property("event_type",is),triggerConfigs:r.property("trigger_configs",r.list(ns).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var Fw=r.object({id:r.string().optional(),name:r.string().optional(),enabled:r.boolean().optional(),alertType:r.property("alert_type",os.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:ts,triggers:r.list(ss).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.enum_(["scope:project","threshold:feedback_score"]);var cs=r.object({id:r.string().optional(),type:ps,configValue:r.property("config_value",r.record(r.string(),r.string()).optional())});var ls=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 ms=r.object({id:r.string().optional(),eventType:r.property("event_type",ls),triggerConfigs:r.property("trigger_configs",r.list(cs).optional())});var ds=r.enum_(["general","slack","pagerduty"]);var us=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",ds.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:us,triggers:r.list(ms).optional()});var W=r.object({ids:r.list(r.string())});var gs=r.enum_(["general","slack","pagerduty"]);var ws=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 fs=r.enum_(["scope:project","threshold:feedback_score"]);var Rs=r.object({id:r.string().optional(),alertTriggerId:r.property("alert_trigger_id",r.string().optional()),type:fs,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 bs=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(Rs).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",gs.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:ws,triggers:r.list(bs).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({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 Ow=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var ks=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 zs=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 xs=r.enum_(["trace","thread"]);var _s=r.object({username:r.string().optional(),status:r.number().optional()});var ie=r.object({name:r.string(),value:r.number()});var Ts=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:xs,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional()),reviewers:r.list(_s).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 Ww=r.object({annotationQueues:r.property("annotation_queues",r.list(Ts))});var As=r.enum_(["trace","thread"]);var Es=r.object({username:r.string().optional(),status:r.number().optional()});var je=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:As,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional()),reviewers:r.list(Es).optional(),feedbackScores:r.property("feedback_scores",r.list(je).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 Ps=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 vs=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 Cs=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(vs).optional(),sortableBy:r.list(r.string()).optional()});var Is=r.enum_(["trace","span"]);var js=r.object({eTag:r.property("e_tag",r.string()),partNumber:r.property("part_number",r.number())});var zi=r.object({fileName:r.property("file_name",r.string()),projectName:r.property("project_name",r.string().optional()),entityType:r.property("entity_type",Is),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(js))});var Us=r.enum_(["trace","span"]);var Bw=r.object({fileNames:r.property("file_names",r.list(r.string())),entityType:r.property("entity_type",Us),entityId:r.property("entity_id",r.string()),containerId:r.property("container_id",r.string())});var Ns=r.object({uploadId:r.property("upload_id",r.string()),preSignUrls:r.property("pre_sign_urls",r.list(r.string()))});var Ms=r.record(r.string(),r.unknown());var Ds=r.object({workspaceName:r.property("workspace_name",r.string().optional())});var Fs=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var wo=r.object({field:r.string().optional(),operator:Fs.optional(),key:r.string().optional(),value:r.string().optional()});var ho=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional()});var Os=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var fo=r.object({role:Os,content:r.string()});var Ws=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var Ro=r.object({name:r.string(),type:Ws,description:r.string()});var bo=r.object({model:ho,messages:r.list(fo),variables:r.record(r.string(),r.string()),schema:r.list(Ro)});var Bs=r.object({code:bo.optional()});var yo=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var Ls=r.object({code:yo.optional()});var ko=r.object({model:ho,messages:r.list(fo),schema:r.list(Ro)});var Vs=r.object({code:ko.optional()});var So=r.object({metric:r.string()});var Hs=r.object({code:So.optional()});var xi=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")}),Lw=r.union("type",{llm_as_judge:Bs.extend(xi),user_defined_metric_python:Ls.extend(xi),trace_thread_llm_as_judge:Vs.extend(xi),trace_thread_user_defined_metric_python:Hs.extend(xi)}).transform({transform:n=>n,untransform:n=>n});var zo=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional()});var Js=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var xo=r.object({role:Js,content:r.string()});var Ks=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var _o=r.object({name:r.string(),type:Ks,description:r.string()});var Xs=r.object({model:zo,messages:r.list(xo),variables:r.record(r.string(),r.string()),schema:r.list(_o)});var Gs=r.object({code:Xs.optional()});var $s=r.object({model:zo,messages:r.list(xo),schema:r.list(_o)});var Qs=r.object({code:$s.optional()});var Ys=r.object({metric:r.string()});var Zs=r.object({code:Ys.optional()});var qs=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var ep=r.object({code:qs.optional()});var rp=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var op=r.object({field:r.string().optional(),operator:rp.optional(),key:r.string().optional(),value:r.string().optional()});var _i=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(op).optional(),action:r.stringLiteral("evaluator")}),tp=r.union("type",{llm_as_judge:Gs.extend(_i),user_defined_metric_python:ep.extend(_i),trace_thread_llm_as_judge:Qs.extend(_i),trace_thread_user_defined_metric_python:Zs.extend(_i)}).transform({transform:n=>n,untransform:n=>n});var To=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional()});var ip=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var Ao=r.object({role:ip,content:r.string()});var ap=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var Eo=r.object({name:r.string(),type:ap,description:r.string()});var np=r.object({model:To,messages:r.list(Ao),variables:r.record(r.string(),r.string()),schema:r.list(Eo)});var Po=r.object({code:np.optional()});var sp=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var vo=r.object({code:sp.optional()});var pp=r.object({model:To,messages:r.list(Ao),schema:r.list(Eo)});var Co=r.object({code:pp.optional()});var cp=r.object({metric:r.string()});var Io=r.object({code:cp.optional()});var Ti=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(fe).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")}),lp=r.union("type",{llm_as_judge:Po.extend(Ti),user_defined_metric_python:vo.extend(Ti),trace_thread_llm_as_judge:Co.extend(Ti),trace_thread_user_defined_metric_python:Io.extend(Ti)}).transform({transform:n=>n,untransform:n=>n});var mp=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(lp).optional(),sortableBy:r.property("sortable_by",r.list(r.string()).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(fe).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")}),dp=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 up=r.enum_(["INFO","WARN","ERROR","DEBUG","TRACE"]);var gp=r.object({timestamp:r.date().optional(),ruleId:r.property("rule_id",r.string().optional()),level:up.optional(),message:r.string().optional(),markers:r.record(r.string(),r.string()).optional()});var wp=r.object({content:r.list(gp).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional()});var hp=r.object({code:bo.optional()});var fp=r.object({code:yo.optional()});var Rp=r.object({code:ko.optional()});var bp=r.object({code:So.optional()});var Ei=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")}),yp=r.union("type",{llm_as_judge:hp.extend(Ei),user_defined_metric_python:fp.extend(Ei),trace_thread_llm_as_judge:Rp.extend(Ei),trace_thread_user_defined_metric_python:bp.extend(Ei)}).transform({transform:n=>n,untransform:n=>n});var kp=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:be.optional()});var Sp=r.object({role:kp.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",be.optional())});var zp=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",be.optional())});var xp=r.object({index:r.number().optional(),message:Sp.optional(),delta:zp.optional(),finishReason:r.property("finish_reason",r.string().optional())});var _p=r.object({cachedTokens:r.property("cached_tokens",r.number().optional())});var Tp=r.object({reasoningTokens:r.property("reasoning_tokens",r.number().optional())});var Ap=r.object({totalTokens:r.property("total_tokens",r.number().optional()),promptTokens:r.property("prompt_tokens",r.number().optional()),promptTokensDetails:r.property("prompt_tokens_details",_p.optional()),completionTokens:r.property("completion_tokens",r.number().optional()),completionTokensDetails:r.property("completion_tokens_details",Tp.optional())});var Ep=r.object({id:r.string().optional(),created:r.number().optional(),model:r.string().optional(),choices:r.list(xp).optional(),usage:Ap.optional(),systemFingerprint:r.property("system_fingerprint",r.string().optional()),serviceTier:r.property("service_tier",r.string().optional())});var Pp=r.enum_(["private","public"]);var Vw=r.object({id:r.string().optional(),name:r.string(),visibility:Pp.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 vp=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:vp,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 Hw=r.object({datasetName:r.property("dataset_name",r.string().optional()),datasetId:r.property("dataset_id",r.string().optional()),items:r.list(Uo)});var Cp=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 Jw=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 Ip=r.enum_(["string","number","object","boolean","array","null"]);var jp=r.object({name:r.string().optional(),types:r.list(Ip).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var Up=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 Np=r.enum_(["manual","trace","span","sdk"]);var Pi=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var Mp=r.enum_(["ui","sdk","online_scoring"]);var Dp=r.enum_(["ui","sdk","online_scoring"]);var Fp=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Dp.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Op=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Mp,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(),Fp).optional())});var Wp=r.enum_(["default","hidden"]);var Bp=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:Pi.optional(),output:Pi.optional(),feedbackScores:r.property("feedback_scores",r.list(Op).optional()),comments:r.list(Up).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",Wp.optional())});var Lp=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:Np,data:O,experimentItems:r.property("experiment_items",r.list(Bp).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 Vp=r.object({content:r.list(Lp).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),columns:r.list(jp).optional(),sortableBy:r.list(r.string()).optional()});var Hp=r.enum_(["private","public"]);var $e=r.object({id:r.string().optional(),name:r.string(),visibility:Hp.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 Jp=r.object({content:r.list($e).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),sortableBy:r.list(r.string()).optional()});var Kp=r.object({value:r.number().optional()});var Xp=r.object({value:r.number().optional()});var No=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var Gp=r.object({value:No.optional()});var $p=r.object({name:r.string().optional()}),Qp=r.union("type",{PERCENTAGE:Gp.extend($p),COUNT:Xp.extend($p),AVG:Kp.extend($p)}).transform({transform:n=>n,untransform:n=>n});var Ue=r.object({stats:r.list(Qp).optional()});var Yp=r.enum_(["manual","trace","span","sdk"]);var Zp=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",Zp.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:Yp,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 qp=r.enum_(["string","number","object","boolean","array","null"]);var ec=r.object({name:r.string().optional(),types:r.list(qp).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var rc=r.object({content:r.list(Do).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),columns:r.list(ec).optional(),sortableBy:r.list(r.string()).optional()});var oc=r.enum_(["string","number","object","boolean","array","null"]);var tc=r.object({name:r.string().optional(),types:r.list(oc).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var ic=r.object({columns:r.list(tc).optional()});var ac=r.object({typeName:r.string().optional()});var Kw=r.object({type:ac.optional(),closed:r.boolean().optional()});var nc=r.enum_(["regular","trial","mini-batch"]);var sc=r.enum_(["running","completed","cancelled"]);var ye=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var vi=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 Xw=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:nc.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:ye.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:sc.optional(),promptVersion:r.property("prompt_version",vi.optional()),promptVersions:r.property("prompt_versions",r.list(vi).optional())});var Qe=r.object({ids:r.list(r.string())});var pc=r.enum_(["TOPIC","PII"]);var cc=r.enum_(["passed","failed"]);var lc=r.object({name:pc.optional(),result:cc.optional()});var mc=r.object({spanId:r.property("span_id",r.string().optional()),checks:r.list(lc).optional()});var dc=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",Re.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(mc).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",dc.optional()),llmSpanCount:r.property("llm_span_count",r.number().optional()),providers:r.list(r.string()).optional()});var uc=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:uc.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",Re.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 gc=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 Gw=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(gc)});var Ne=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 wc=r.enum_(["regular","trial","mini-batch"]);var hc=r.enum_(["running","completed","cancelled"]);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 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:wc.optional(),optimizationId:r.property("optimization_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(je).optional()),comments:r.list(Ne).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",Ci.optional()),promptVersions:r.property("prompt_versions",r.list(Ci).optional())});var fc=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 Rc=r.object({label:r.string().optional()});var bc=r.object({groupSorting:r.property("group_sorting",r.list(r.string()).optional())});var yc=r.object({groupsDetails:r.property("groups_details",r.list(bc).optional())});var kc=r.object({content:r.record(r.string(),Rc).optional(),details:yc.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:ye.optional(),feedbackScores:r.property("feedback_scores",r.list(ie).optional())});var zc=r.object({aggregations:Sc.optional()});var xc=r.object({content:r.record(r.string(),zc).optional()});var $w=r.object({ids:r.list(r.string())});var _c=r.object({typeName:r.string().optional()});var Qw=r.object({type:_c.optional(),closed:r.boolean().optional()});var Tc=r.object({categories:r.record(r.string(),r.number())});var Ac=r.object({details:Tc.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 Ec=r.object({max:r.number(),min:r.number()});var Pc=r.object({details:Ec.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 jd=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()}),Yw=r.union("type",{numerical:Pc.extend(jd),categorical:Ac.extend(jd)}).transform({transform:n=>n,untransform:n=>n});var vc=r.object({categories:r.record(r.string(),r.number())});var Cc=r.object({details:vc.optional()});var Ic=r.object({max:r.number(),min:r.number()});var jc=r.object({details:Ic.optional()});var Ud=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional()}),Uc=r.union("type",{numerical:jc.extend(Ud),categorical:Cc.extend(Ud)}).transform({transform:n=>n,untransform:n=>n});var Nc=r.object({categories:r.record(r.string(),r.number())});var Bo=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 Mc=r.object({max:r.number(),min:r.number()});var Lo=r.object({details:Mc.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 Nd=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()}),Dc=r.union("type",{numerical:Lo.extend(Nd),categorical:Bo.extend(Nd)}).transform({transform:n=>n,untransform:n=>n});var Fc=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Dc).optional()});var Md=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()}),Oc=r.union("type",{numerical:Lo.extend(Md),categorical:Bo.extend(Md)}).transform({transform:n=>n,untransform:n=>n});var Wc=r.object({categories:r.record(r.string(),r.number())});var Bc=r.object({details:Wc.optional()});var Lc=r.object({max:r.number(),min:r.number()});var Vc=r.object({details:Lc.optional()});var Dd=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional()}),Hc=r.union("type",{numerical:Vc.extend(Dd),categorical:Bc.extend(Dd)}).transform({transform:n=>n,untransform:n=>n});var Jc=r.enum_(["TOPIC","PII"]);var Kc=r.enum_(["passed","failed"]);var Xc=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:Jc,result:Kc,config:O,details:O});var Zw=r.object({guardrails:r.list(Xc)});var Gc=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var Vo=r.object({id:r.string().optional(),provider:Gc,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 $c=r.object({size:r.number().optional(),total:r.number().optional(),content:r.list(Vo).optional(),sortableBy:r.list(r.string()).optional()});var Qc=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var qw=r.object({id:r.string().optional(),provider:Qc,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 Ii=r.object({entitiesQueued:r.property("entities_queued",r.number().optional()),rulesApplied:r.property("rules_applied",r.number().optional())});var Yc=r.enum_(["trace","thread"]);var ji=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",Yc)});var eh=O;var Zc=r.enum_(["running","completed","cancelled"]);var rh=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:Zc,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 qc=r.enum_(["running","completed","cancelled"]);var Ui=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:qc,metadata:te.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var el=r.enum_(["running","completed","cancelled"]);var Ho=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:el,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(je).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 rl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Ho).optional(),sortableBy:r.list(r.string()).optional()});var Jo=r.object({count:r.number().optional(),deviation:r.number().optional(),deviationPercentage:r.property("deviation_percentage",r.number().optional())});var ol=r.enum_(["private","public"]);var oh=r.object({id:r.string().optional(),name:r.string(),visibility:ol.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:ye.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",Jo.optional())});var tl=r.enum_(["private","public"]);var Ko=r.object({id:r.string().optional(),name:r.string(),visibility:tl.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 il=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Ko).optional(),sortableBy:r.list(r.string()).optional()});var al=r.object({name:r.string().optional()});var nl=r.object({scores:r.list(al).optional()});var sl=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 cl=r.enum_(["HOURLY","DAILY","WEEKLY"]);var ll=r.object({name:r.string().optional(),data:r.list(sl).optional()});var ml=r.object({projectId:r.property("project_id",r.string().optional()),metricType:r.property("metric_type",pl.optional()),interval:cl.optional(),results:r.list(ll).optional()});var dl=r.object({projectId:r.property("project_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),duration:ye.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",Jo.optional())});var ul=r.object({content:r.list(dl).optional()});var gl=r.object({count:r.number().optional(),deviation:r.number().optional(),deviationPercentage:r.property("deviation_percentage",r.number().optional())});var wl=r.object({name:r.string(),value:r.number()});var hl=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var fl=r.enum_(["private","public"]);var Rl=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(wl).optional()),duration:hl.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",gl.optional())});var th=r.object({errors:r.list(r.string()).optional()});var bl=r.enum_(["mustache","jinja2"]);var yl=r.enum_(["mustache","jinja2"]);var kl=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:yl.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 ih=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:bl.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",kl.optional())});var ah=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var Sl=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 zl=r.record(r.string(),r.unknown());var xl=r.enum_(["mustache","jinja2"]);var _l=r.object({id:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),commit:r.string().optional(),template:r.string(),metadata:zl.optional(),type:xl.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 Tl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(_l).optional()});var Al=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 El=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Al).optional(),sortableBy:r.list(r.string()).optional()});var Pl=r.object({pythonEvaluatorEnabled:r.boolean(),traceThreadPythonEvaluatorEnabled:r.boolean(),guardrailsEnabled:r.boolean(),opikAiEnabled:r.property("opikAIEnabled",r.boolean()),alertsEnabled:r.boolean(),welcomeWizardEnabled:r.boolean()});var nh=r.object({spans:r.list(Oo)});var Xo=r.object({name:r.string(),author:r.string().optional()});var Go=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 Cl=r.enum_(["ui","sdk","online_scoring"]);var Il=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Cl.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var $o=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(),Il).optional())});var jl=r.enum_(["general","tool","llm","guardrail"]);var Qo=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:jl.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",Go.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($o).optional()),comments:r.list(Ne).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 Ul=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 Nl=r.enum_(["ui","sdk","online_scoring"]);var Ml=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:Nl,author:r.string().optional(),id:r.string()});var Yo=r.object({scores:r.list(Ml)});var sh=r.object({traces:r.list(Fo)});var ph=r.object({ids:r.list(r.string()),projectId:r.property("project_id",r.string().optional())});var Dl=r.enum_(["TOPIC","PII"]);var Fl=r.enum_(["passed","failed"]);var Ol=r.object({name:Dl.optional(),result:Fl.optional()});var Wl=r.object({spanId:r.property("span_id",r.string().optional()),checks:r.list(Ol).optional()});var Bl=r.enum_(["default","hidden"]);var Zo=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",Go.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($o).optional()),comments:r.list(Ne).optional(),guardrailsValidations:r.property("guardrails_validations",r.list(Wl).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",Bl.optional()),llmSpanCount:r.property("llm_span_count",r.number().optional()),providers:r.list(r.string()).optional()});var Ll=r.enum_(["active","inactive"]);var qo=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:Ll.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 Ni=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 Vl=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 Hl=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 Jl=r.object({completed:r.boolean().optional()});var Me=r.object({name:r.string().optional(),current:r.number().optional(),previous:r.number().optional()});var Ye=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 ch=r.object({time:r.date(),value:r.number().optional()});var Mi=r.object({results:r.list(Me).optional()});var lh=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 et=r.object({timeoutToMarkThreadAsInactive:r.property("timeout_to_mark_thread_as_inactive",r.string().optional()),truncationOnTables:r.property("truncation_on_tables",r.boolean().optional())});var Kl=r.object({results:r.list(Me).optional()});var Di=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":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:Ge.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":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:Ge.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":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:Ge.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":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:qn.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":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:Ge.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":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:rs.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 Fi=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,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: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":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:ys.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":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 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":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 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":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 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":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 h.fromPromise(this.__getWebhookExamples(t,e))}async __getWebhookExamples(t={},e){var c,d;let{alertType:o}=t,i={};o!=null&&(i.alert_type=Nt.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: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":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:ks.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":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:zs.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 Oi=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":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 h.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: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":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:Ps.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":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 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":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 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":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 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":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 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":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 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":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 Wi=class{constructor(t={}){this._options=t;}attachmentList(t,e){return h.fromPromise(this.__attachmentList(t,e))}async __attachmentList(t,e){var k,z;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=Dt.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"}),g.entity_id=d,g.path=u;let y=await R({url:b((z=(k=await s.get(this._options.baseUrl))!=null?k:await s.get(this._options.environment))!=null?z: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":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:Cs.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 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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:zi.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 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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:zi.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 h.fromPromise(this.__downloadAttachment(t,e))}async __downloadAttachment(t,e){var k,z;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=Ft.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}),g.entity_id=c,g.file_name=d,g.mime_type=u;let y=await R({url:b((z=(k=await s.get(this._options.baseUrl))!=null?k:await s.get(this._options.environment))!=null?z: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":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 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":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:Ns.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 h.fromPromise(this.__uploadAttachment(t,e))}async __uploadAttachment(t,e){var k,z;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=Wt.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"}),g.entity_id=d;let y=await R({url:b((z=(k=await s.get(this._options.baseUrl))!=null?k:await s.get(this._options.environment))!=null?z: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":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:Je.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 Bi=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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ms.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 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":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:Ds.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 Li=class{constructor(t={}){this._options=t;}findEvaluators(t={},e){return h.fromPromise(this.__findEvaluators(t,e))}async __findEvaluators(t={},e){var z,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=(z=await s.get(this._options.baseUrl))!=null?z: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":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:mp.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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:tp.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 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: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":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 h.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: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":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:dp.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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:yp.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 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: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":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:wp.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 Vi=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":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:Ep.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 Hi=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: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 z=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":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(z.ok)return {data:Jp.parseOrThrow(z.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:z.rawResponse};if(z.error.reason==="status-code")throw new p({statusCode:z.error.statusCode,body:z.error.body,rawResponse:z.rawResponse});switch(z.error.reason){case "non-json":throw new p({statusCode:z.error.statusCode,body:z.error.rawBody,rawResponse:z.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets.");case "unknown":throw new p({message:z.error.errorMessage,rawResponse:z.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":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 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":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 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":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 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":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 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":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:$e.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":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 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":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 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":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 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":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 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":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 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":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:Cp.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: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 z=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":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(z.ok)return {data:Vp.parseOrThrow(z.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:z.rawResponse};if(z.error.reason==="status-code")throw new p({statusCode:z.error.statusCode,body:z.error.body,rawResponse:z.rawResponse});switch(z.error.reason){case "non-json":throw new p({statusCode:z.error.statusCode,body:z.error.rawBody,rawResponse:z.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items.");case "unknown":throw new p({message:z.error.errorMessage,rawResponse:z.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":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:$e.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 d=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":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:Ue.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 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":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 h.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: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":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:rc.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 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: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":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:ic.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":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"}),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 Ji=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:d,name:u,datasetDeleted:g,promptId:y,sorting:k,filters:z}=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),z!=null&&(x.filters=z);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":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:fc.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 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":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/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":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 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":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 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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Qe.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":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 h.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: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":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:Ke.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,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: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":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:kc.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 h.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: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":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")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 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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Qe.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 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":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 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":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 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":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 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":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 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":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 Ki=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,d={};o!=null&&(d.page=o.toString()),i!=null&&(d.size=i.toString()),a!=null&&(d.name=a),c!=null&&(d.type=Yt.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":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:Fc.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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Uc.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":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:Oc.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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Hc.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":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 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":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 Xi=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":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 Gi=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":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 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":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:$c.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":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 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":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:Vo.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 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":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 $i=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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ji.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:Ii.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 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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ji.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:Ii.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 Qi=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":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 Yi=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: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: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":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:rl.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 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":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: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":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: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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Qe.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":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/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":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 Zi=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,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: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":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:il.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":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 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":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:Ko.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":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 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":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 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":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 h.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: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":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:nl.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":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:ml.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 h.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: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":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: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":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:Rl.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 qi=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: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: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":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:El.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":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 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":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: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 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 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":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:Sl.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 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":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 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":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 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":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 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":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: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 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 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 d=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":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:Tl.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 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":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: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 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 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":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: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 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 ea=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":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/toggles.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ra=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":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 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":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 h.fromPromise(this.__getSpansByProject(t,e))}async __getSpansByProject(t={},e){var q,We;let{page:o,size:i,projectName:a,projectId:c,traceId:d,type:u,filters:g,truncate:y,stripAttachments:k,sorting:z,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=li.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"})),g!=null&&(N.filters=g),y!=null&&(N.truncate=y.toString()),k!=null&&(N.strip_attachments=k.toString()),z!=null&&(N.sorting=z),x!=null&&(N.exclude=x),_!=null&&(N.from_time=_.toISOString()),M!=null&&(N.to_time=M.toISOString());let J=await R({url:b((We=(q=await s.get(this._options.baseUrl))!=null?q:await s.get(this._options.environment))!=null?We: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":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:Ul.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 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":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 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":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 h.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: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":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")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 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":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 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":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 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":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 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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Xo.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 d,u;let{projectId:o,type:i}=t,a={};o!=null&&(a.project_id=o),i!=null&&(a.type=di.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: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":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:Xe.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":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 h.fromPromise(this.__getSpanStats(t,e))}async __getSpanStats(t={},e){var z,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=ui.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=(z=await s.get(this._options.baseUrl))!=null?z: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":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:Ue.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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Yo.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":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 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":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 oa=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":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 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":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 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":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 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":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 h.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:z,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),z!=null&&(_.from_time=z.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: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":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:Hl.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":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 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":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 h.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: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":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:Zo.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":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 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":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 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":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 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":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 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":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 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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Xo.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":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 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":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 h.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: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":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:Ie.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,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: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":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:Ie.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: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: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":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:Ue.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":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 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":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 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":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: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 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 h.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:z}=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()),z!=null&&(x.to_time=z.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":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:Vl.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":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/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":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 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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Yo.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":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 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":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 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":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 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":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 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":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 ta=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":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:Jl.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":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 ia=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":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:Me.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 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":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:et.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 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":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:et.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 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 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":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 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":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:Mi.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 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":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:Mi.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 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":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:Kl.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 aa=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 d=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":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 h.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: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":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 h.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: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":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 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 d=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":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 rt=class{constructor(t={}){this._options=t;}get systemUsage(){var t;return (t=this._systemUsage)!=null?t:this._systemUsage=new Di(this._options)}get alerts(){var t;return (t=this._alerts)!=null?t:this._alerts=new Fi(this._options)}get annotationQueues(){var t;return (t=this._annotationQueues)!=null?t:this._annotationQueues=new Oi(this._options)}get attachments(){var t;return (t=this._attachments)!=null?t:this._attachments=new Wi(this._options)}get check(){var t;return (t=this._check)!=null?t:this._check=new Bi(this._options)}get automationRuleEvaluators(){var t;return (t=this._automationRuleEvaluators)!=null?t:this._automationRuleEvaluators=new Li(this._options)}get chatCompletions(){var t;return (t=this._chatCompletions)!=null?t:this._chatCompletions=new Vi(this._options)}get datasets(){var t;return (t=this._datasets)!=null?t:this._datasets=new Hi(this._options)}get experiments(){var t;return (t=this._experiments)!=null?t:this._experiments=new Ji(this._options)}get feedbackDefinitions(){var t;return (t=this._feedbackDefinitions)!=null?t:this._feedbackDefinitions=new Ki(this._options)}get guardrails(){var t;return (t=this._guardrails)!=null?t:this._guardrails=new Xi(this._options)}get llmProviderKey(){var t;return (t=this._llmProviderKey)!=null?t:this._llmProviderKey=new Gi(this._options)}get manualEvaluation(){var t;return (t=this._manualEvaluation)!=null?t:this._manualEvaluation=new $i(this._options)}get openTelemetryIngestion(){var t;return (t=this._openTelemetryIngestion)!=null?t:this._openTelemetryIngestion=new Qi(this._options)}get optimizations(){var t;return (t=this._optimizations)!=null?t:this._optimizations=new Yi(this._options)}get projects(){var t;return (t=this._projects)!=null?t:this._projects=new Zi(this._options)}get prompts(){var t;return (t=this._prompts)!=null?t:this._prompts=new qi(this._options)}get serviceToggles(){var t;return (t=this._serviceToggles)!=null?t:this._serviceToggles=new ea(this._options)}get spans(){var t;return (t=this._spans)!=null?t:this._spans=new ra(this._options)}get traces(){var t;return (t=this._traces)!=null?t:this._traces=new oa(this._options)}get welcomeWizard(){var t;return (t=this._welcomeWizard)!=null?t:this._welcomeWizard=new ta(this._options)}get workspaces(){var t;return (t=this._workspaces)!=null?t:this._workspaces=new ia(this._options)}get redirect(){var t;return (t=this._redirect)!=null?t:this._redirect=new aa(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":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 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":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 na=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 sa=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 na(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 Fd={EXPERIMENTS:"api/v1/session/redirect/experiments/",PROJECT_BY_NAME:"redirect/projects"},pa={EXPERIMENT_ID:"experiment_id",DATASET_ID:"dataset_id",PROJECT_NAME:"name",PATH:"path"},dh=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,"="),uh=n=>n.replace(/\/api$/,""),gh=n=>Buffer.from(n).toString("base64"),Od=(n,t,e)=>{let o=dh(e),i=`${t}?${o}`;return new URL(i,n).toString()},Wd=({datasetId:n,experimentId:t,baseUrl:e})=>Od(e,Fd.EXPERIMENTS,{[pa.EXPERIMENT_ID]:t,[pa.DATASET_ID]:n,[pa.PATH]:gh(e)});var Bd=({projectName:n,workspaceName:t,apiUrl:e})=>{let o=uh(e),i=`${t}/${Fd.PROJECT_BY_NAME}`;return Od(o,i,{[pa.PROJECT_NAME]:n})};var wh=300,ca=100,ot=class{constructor({action:t,batchSize:e=ca,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(),S.debug(`Adding ${t.size} items to ${this.name} promise:`,t),this.promise=this.promise.finally(()=>(S.debug(`Flushing ${this.name}:`,t),this.action(t))).catch(e=>{S.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=wh,enableCreateBatch:e=true,enableUpdateBatch:o=false,enableDeleteBatch:i=true,createBatchSize:a=ca,updateBatchSize:c=ca,deleteBatchSize:d=ca,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 ot({action:async g=>{await this.createEntities(Array.from(g.values()));},delay:t,enableBatch:e,batchSize:a,name:`${u}:createQueue`}),this.updateQueue=new ot({action:async g=>{await this.createQueue.flush();let y=Array.from(g.entries());for(let[k,z]of y)await this.updateEntity(k,z);},delay:t,enableBatch:o,batchSize:c,name:`${u}:updateQueue`}),this.deleteQueue=new ot({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 la=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 ma=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 da=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 ua=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 ga=class extends rt{constructor(e){super(e);this.setHeaders=e=>{this.requestOptions.headers=e;};this.requestOptions=(e==null?void 0:e.requestOptions)||{};}};var wa=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 Xl=null;async function Ld(){return Xl||(Xl=await hh__default.default()),Xl}var tt=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||on.Sdk,this.data={...c};}getContent(t=false){return t?{...this.data,id:this.id}:{...this.data}}async contentHash(){let t=this.getContent(),e=fh__default.default(t);return (await Ld()).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 xe(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 S.error("Error parsing experiment item:",k.errors);}catch(y){S.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):S.error("Error parsing experiment item:",u.errors);}catch(d){S.error("Error parsing remaining buffer:",d instanceof Error?d.message:String(d));}}catch(d){S.error("Error processing stream:",d instanceof Error?d.message:String(d));}return i}function it(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,S.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 Vd={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 bh={DATASET_ITEM_MISSING_ID:"DATASET_ITEM_MISSING_ID"},ha=class extends ne{constructor(t){super({message:Vd.DATASET_ITEM_MISSING_ID(t),code:bh.DATASET_ITEM_MISSING_ID});}};var yh={SEARCH_TIMEOUT:"SEARCH_TIMEOUT"},fa=class extends ne{constructor(t){super({message:t,code:yh.SEARCH_TIMEOUT});}};var Ra={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 Gl={JSON_PARSE_ERROR:"JSON_PARSE_ERROR",JSON_NOT_ARRAY:"JSON_NOT_ARRAY",JSON_ITEM_NOT_OBJECT:"JSON_ITEM_NOT_OBJECT"},ba=class extends ne{constructor(t){let e=t instanceof Error?t:new Error(String(t));super({message:Ra.JSON_PARSE_ERROR,code:Gl.JSON_PARSE_ERROR,originalError:e});}},ya=class extends ne{constructor(t){super({message:Ra.JSON_NOT_ARRAY(t),code:Gl.JSON_NOT_ARRAY});}},ka=class extends ne{constructor(t,e){super({message:Ra.JSON_ITEM_NOT_OBJECT(t,e),code:Gl.JSON_ITEM_NOT_OBJECT});}};var Ze=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=it(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,S.info(`Inserted ${Math.min(i,e.length)} of ${e.length} items into dataset ${this.id}`);}catch(i){throw S.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){S.info("No item IDs provided for deletion");return}let e=it(t,{maxBatchSize:100});for await(let o of e){S.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 xe(i,I.DatasetItemPublic,t)).map(c=>tt.fromApiModel(c))}async insertFromJson(t,e={},o=[]){let i;try{i=JSON.parse(t);}catch(c){throw new ba(c)}if(!Array.isArray(i))throw new ya(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 ka(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 fh__default.default(o)}async getDeduplicatedItems(t){let e=[];for(let o of t){let i=new tt(o),a=await i.contentHash();if(this.hashes.has(a)){S.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(){S.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);}S.debug("Dataset hash sync completed",{datasetId:this.id,itemCount:t.length});}catch(t){if(t instanceof p&&t.statusCode===404){S.debug("Dataset not found - starting with empty hash state",{datasetId:this.id}),this.clearHashState();return}throw t}}};var $l=class extends Error{constructor(t){super(t),this.name="DatasetError";}},at=class extends $l{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;}},za=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 De=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=it(e,{maxBatchSize:50});try{for(let i of o)await this.opik.api.experiments.createExperimentItems({experimentItems:i});S.debug(`Inserted ${t.length} items into experiment ${this.id}`);}catch(i){throw S.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 xe(g,I.ExperimentItemCompare,u);if(y.length===0){d=!1;break}for(let k of y){let z=za.fromRestExperimentItemCompare(k);if(e.push(z),i!==void 0&&e.length>=i){d=!1;break}}c=y[y.length-1].id;}catch(y){S.error("Error parsing experiment item: "+(y instanceof Error?y.message:String(y))),d=!1;break}}}catch(u){throw S.error("Error retrieving experiment items: "+(u instanceof Error?u.message:String(u))),u}return S.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||La.apiUrl;return Wd({datasetId:t.id,experimentId:this.id,baseUrl:e})}};var xa={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 Gl={EXPERIMENT_NOT_FOUND:"EXPERIMENT_NOT_FOUND",INVALID_CONFIG_TYPE:"INVALID_CONFIG_TYPE",CONFIG_PROMPTS_CONFLICT:"CONFIG_PROMPTS_CONFLICT"},at=class extends ne{constructor(t){super({message:Sa.EXPERIMENT_NOT_FOUND(t),code:Gl.EXPERIMENT_NOT_FOUND});}},nt=class n extends ne{constructor(t,e){super({message:t,code:e});}static invalidConfigType(t){return new n(Sa.INVALID_CONFIG_TYPE(t),Gl.INVALID_CONFIG_TYPE)}static promptsConflict(){return new n(Sa.CONFIG_PROMPTS_CONFLICT(),Gl.CONFIG_PROMPTS_CONFLICT)}};function Ld(n,t){if(n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)))throw nt.invalidConfigType(typeof n);if(t&&t.length>0&&(n!=null&&n.prompts))throw nt.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 kh(n){try{let e=yh__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 Vd(n,t,e){if(e!=="mustache")return;let o=kh(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 Ql={EXPERIMENT_NOT_FOUND:"EXPERIMENT_NOT_FOUND",INVALID_CONFIG_TYPE:"INVALID_CONFIG_TYPE",CONFIG_PROMPTS_CONFLICT:"CONFIG_PROMPTS_CONFLICT"},nt=class extends ne{constructor(t){super({message:xa.EXPERIMENT_NOT_FOUND(t),code:Ql.EXPERIMENT_NOT_FOUND});}},st=class n extends ne{constructor(t,e){super({message:t,code:e});}static invalidConfigType(t){return new n(xa.INVALID_CONFIG_TYPE(t),Ql.INVALID_CONFIG_TYPE)}static promptsConflict(){return new n(xa.CONFIG_PROMPTS_CONFLICT(),Ql.CONFIG_PROMPTS_CONFLICT)}};function Hd(n,t){if(n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)))throw st.invalidConfigType(typeof n);if(t&&t.length>0&&(n!=null&&n.prompts))throw st.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 zh(n){try{let e=Sh__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 Jd(n,t,e){if(e!=="mustache")return;let o=zh(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 qe(n,t,e){try{switch(Vd(n,t,e),e){case "mustache":return yh__default.default.render(n,t);case "jinja2":return Sh__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 st=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 qe(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 qe(n,t,e){try{switch(Jd(n,t,e),e){case "mustache":return Sh__default.default.render(n,t);case "jinja2":return _h__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 pt=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 qe(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 S.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 _e=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 qe(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=>st.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 Hd(n,t,e){try{return await n.retrievePromptVersion({name:t},e)}catch(o){if(Eh(o))return null;throw o}}function Jd(n,t,e){return t?t.template!==n.prompt||!Ah(t.metadata,n.metadata)||t.type!==e:true}function Ah(n,t){let e=n!=null?n:{},o=t!=null?t:{};return Th__default.default(e,o)}function Eh(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"]},Te={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"},Kd={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},xa={SPECIAL_FIELDS:["usage","metadata","feedback_scores"],USAGE_KEYS:["total_tokens","prompt_tokens","completion_tokens"]};function Xd(n){let t=xa.SPECIAL_FIELDS.includes(n),e=Object.keys(Te).includes(n);if(!t&&!e){let o=Object.keys(Te).join(", ");throw new Error(`Field ${n} is not supported, only the fields ${o} are supported.`)}}function Gd(n,t){if(!xa.SPECIAL_FIELDS.includes(n)){let e=Object.keys(Te).join(", ");throw new Error(`Field ${n}.${t} is not supported, only the fields ${e} are supported.`)}if(n==="usage"&&!xa.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 $l(n,t){let e=Kd[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 $d(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 _a(n,t,e){if(!n)throw new Error(`Missing closing quote for: ${e}`)}var pt=class{static parse(t){t.skipWhitespace();let e=this.parseFieldName(t);return Xd(e),t.peekChar()==="."?this.parseFieldWithKey(t,e):{type:"simple",field:e,columnType:Te[e]}}static parseFieldName(t){return t.consumeWhile(e=>re.isFieldChar(e))}static parseFieldWithKey(t,e){t.advance();let o=this.parseKey(t);if(Gd(e,o),e==="usage"){let i=`usage.${o}`;return {type:"simple",field:i,columnType:Te[i]}}return {type:"nested",field:e,key:o,columnType:Te[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 _a(a,o,c),i}};var ct=class{static parse(t,e){t.skipWhitespace();let o=t.peekChar(),i=this.tryParseSymbolicOperator(t,o);if(i)return $l(e,i),{operator:i};let a=this.parseWordOperator(t);return $l(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 lt=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();}_a(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 Ae=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=pt.parse(t),o=ct.parse(t,this.getFieldName(e)),i=lt.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 $d(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 Qd(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 xe(a,I.TracePublic,o)}async function Yd(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 Zd(n){if(!n)return null;let e=new Ae(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 Ql=[],Fe=class{constructor(t){this.displayTraceLog=t=>{if(t===this.lastProjectNameLogged||!this.config.apiUrl)return;let e=Od({apiUrl:this.config.apiUrl,projectName:t,workspaceName:this.config.workspaceName});z.info(`Started logging traces to the "${t}" project at ${ht(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 na({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 Ze(e,this)}catch(e){throw e instanceof p&&e.statusCode===404?new it(t):e}};this.createDataset=async(t,e)=>{z.debug(`Creating dataset with name "${t}"`);let o=new Ze({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 it)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 Ze(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=on.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]=Ld(o,i),g=Z(),y=new De({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 De({id:e.id,name:e.name,datasetName:e.datasetName},this)}catch(e){throw e instanceof p&&e.statusCode===404?new at(`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 xe(e,I.ExperimentPublic)).map(i=>new De({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 at(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 De({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 Hd(this.api.prompts,t.name,this.api.requestOptions),i=(e=t.type)!=null?e:de.MUSTACHE,a=Jd(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=_e.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 _e.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 Ae(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 _e.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=Zd(o),g=e!=null?e:this.config.projectName,y=()=>Qd(this.api,g,u,i,a);if(c===void 0)return await y();let k=await Yd(y,c,m*1e3,5e3);if(k.length<c)throw new ha(`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=fm(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 ua(e);let o=this.config.holdUntilFlush?24*60*60*1e3:this.config.batchDelayMs;this.spanBatchQueue=new ca(this.api,o),this.traceBatchQueue=new ma(this.api,o),this.spanFeedbackScoresBatchQueue=new la(this.api,o),this.traceFeedbackScoresBatchQueue=new da(this.api,o),this.datasetBatchQueue=new ga(this.api,o),Ql.push(this);}};var vh="track.decorator",mt=new async_hooks.AsyncLocalStorage,Ch=()=>{let{span:n,trace:t}=mt.getStore()||{};if(!(!n||!t))return {span:n,trace:t}};function Ih(n){return !!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}function jh({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=Zl().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 Uh({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 qd({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 eu({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 Ta({name:n,projectName:t,type:e,enrichSpan:o}={},i){return z.info("Executing track with enrichSpan:",JSON.stringify(o,null,2)),function(...c){let m=mt.getStore(),{span:u,trace:g}=jh({name:n!=null?n:i.name||vh,parentSpan:m==null?void 0:m.span,projectName:t,trace:m==null?void 0:m.trace,type:e}),y=!m,k=this;return mt.run({span:u,trace:g},()=>{let S=y?g:void 0;try{Uh({args:c,span:u,trace:S});let x=i.apply(k,c);return Ih(x)?x.then(_=>(qd({span:u,result:_,trace:S,enrichSpan:o}),_),_=>{throw eu({span:u,error:_,trace:S}),_}):(qd({span:u,result:x,trace:S,enrichSpan:o}),x)}catch(x){throw eu({span:u,error:x,trace:S}),x}})}}function ke(n,t){if(typeof n=="function")return Ta({},n);let e=n;return t?Ta(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 Ta(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=Ta(e,a),i}}var Yl=null;function Zl(){return Yl===null&&(Yl=new Fe),Yl}var Nh=async()=>{z.debug("Starting flushAll operation");try{await Promise.all([Zl().flush(),...Ql.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(Mh(n,t,c))}}function Mh(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 Ea=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
- 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),m=[Aa__default.default.bold(`Total time: ${c}`),Aa__default.default.bold(`Number of samples: ${t.length}`),"",...a.map(y=>{let k=this.formatScore(o.get(y)||0);return Aa__default.default.green(`${y}: ${k} (avg)`)})].join(`
15
- `),u=await e.ensureNameLoaded(),g=Dh__default.default(m,{title:`${u} (${t.length} samples)`,titleAlignment:"left",padding:1,margin:0,borderColor:"cyan",borderStyle:"round"});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 _e=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 qe(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;S.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 S.debug("Successfully retrieved prompt versions",{promptId:this.id,name:this.name,totalVersions:e.length}),e.map(a=>pt.fromApiResponse(this.name,a))}catch(e){throw S.error("Failed to get prompt versions",{promptId:this.id,name:this.name,error:e}),e}}async useVersion(t){S.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 S.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 S.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 S.error("Failed to retrieve prompt version",{promptName:this.name,commit:t,error:e}),e}}};async function Kd(n,t,e){try{return await n.retrievePromptVersion({name:t},e)}catch(o){if(vh(o))return null;throw o}}function Xd(n,t,e){return t?t.template!==n.prompt||!Ph(t.metadata,n.metadata)||t.type!==e:true}function Ph(n,t){let e=n!=null?n:{},o=t!=null?t:{};return Eh__default.default(e,o)}function vh(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"]},Te={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"},Gd={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},_a={SPECIAL_FIELDS:["usage","metadata","feedback_scores"],USAGE_KEYS:["total_tokens","prompt_tokens","completion_tokens"]};function $d(n){let t=_a.SPECIAL_FIELDS.includes(n),e=Object.keys(Te).includes(n);if(!t&&!e){let o=Object.keys(Te).join(", ");throw new Error(`Field ${n} is not supported, only the fields ${o} are supported.`)}}function Qd(n,t){if(!_a.SPECIAL_FIELDS.includes(n)){let e=Object.keys(Te).join(", ");throw new Error(`Field ${n}.${t} is not supported, only the fields ${e} are supported.`)}if(n==="usage"&&!_a.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 Yl(n,t){let e=Gd[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 Yd(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 Ta(n,t,e){if(!n)throw new Error(`Missing closing quote for: ${e}`)}var ct=class{static parse(t){t.skipWhitespace();let e=this.parseFieldName(t);return $d(e),t.peekChar()==="."?this.parseFieldWithKey(t,e):{type:"simple",field:e,columnType:Te[e]}}static parseFieldName(t){return t.consumeWhile(e=>re.isFieldChar(e))}static parseFieldWithKey(t,e){t.advance();let o=this.parseKey(t);if(Qd(e,o),e==="usage"){let i=`usage.${o}`;return {type:"simple",field:i,columnType:Te[i]}}return {type:"nested",field:e,key:o,columnType:Te[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 Ta(a,o,c),i}};var lt=class{static parse(t,e){t.skipWhitespace();let o=t.peekChar(),i=this.tryParseSymbolicOperator(t,o);if(i)return Yl(e,i),{operator:i};let a=this.parseWordOperator(t);return Yl(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 mt=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();}Ta(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 Ae=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=ct.parse(t),o=lt.parse(t,this.getFieldName(e)),i=mt.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 Yd(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 Zd(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 xe(a,I.TracePublic,o)}async function qd(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 eu(n){if(!n)return null;let e=new Ae(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 Zl=[],Fe=class{constructor(t){this.displayTraceLog=t=>{if(t===this.lastProjectNameLogged||!this.config.apiUrl)return;let e=Bd({apiUrl:this.config.apiUrl,projectName:t,workspaceName:this.config.workspaceName});S.info(`Started logging traces to the "${t}" project at ${ft(e)}`),this.lastProjectNameLogged=t;};this.trace=t=>{var i;S.debug("Creating new trace with data:",t);let e=(i=t.projectName)!=null?i:this.config.projectName,o=new sa({id:Z(),startTime:new Date,...t,projectName:e},this);return this.traceBatchQueue.create(o.data),S.debug("Trace added to the queue with ID:",o.data.id),this.displayTraceLog(e),o};this.getDataset=async t=>{S.debug(`Getting dataset with name "${t}"`);try{await this.datasetBatchQueue.flush();let e=await this.api.datasets.getDatasetByIdentifier({datasetName:t});return new Ze(e,this)}catch(e){throw e instanceof p&&e.statusCode===404?new at(t):e}};this.createDataset=async(t,e)=>{S.debug(`Creating dataset with name "${t}"`);let o=new Ze({name:t,description:e},this);try{return this.datasetBatchQueue.create({name:o.name,description:o.description,id:o.id}),S.debug("Dataset added to the queue with name:",o.name),o}catch(i){throw S.error(`Failed to create dataset "${t}"`,{error:i}),new Error(`Error creating dataset "${t}": ${i}`)}};this.getOrCreateDataset=async(t,e)=>{S.debug(`Attempting to retrieve or create dataset with name: "${t}"`);try{return await this.getDataset(t)}catch(o){if(o instanceof at)return S.info(`Dataset "${t}" not found. Proceeding to create a new one.`),this.createDataset(t,e);throw S.error(`Error retrieving dataset "${t}":`,o),o}};this.getDatasets=async(t=100)=>{S.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 Ze(i,this));return S.info(`Retrieved ${o.length} datasets`),o}catch(e){throw S.error("Failed to retrieve datasets",{error:e}),new Error("Failed to retrieve datasets")}};this.deleteDataset=async t=>{S.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 S.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=tn.Regular,optimizationId:c})=>{if(S.debug(`Creating experiment for dataset "${t}"`),!t)throw new Error("Dataset name is required to create an experiment");let[d,u]=Hd(o,i),g=Z(),y=new De({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}),S.debug("Experiment added to the queue with id:",g),y}catch(k){throw S.error(`Failed to create experiment for dataset "${t}"`,{error:k}),new Error(`Error creating experiment: ${k}`)}};this.getExperimentById=async t=>{S.debug(`Getting experiment with ID "${t}"`);try{let e=await this.api.experiments.getExperimentById(t);return new De({id:e.id,name:e.name,datasetName:e.datasetName},this)}catch(e){throw e instanceof p&&e.statusCode===404?new nt(`No experiment found with ID '${t}'`):(S.error(`Failed to get experiment with ID "${t}"`,{error:e}),e)}};this.getExperimentsByName=async t=>{S.debug(`Getting experiments with name "${t}"`);try{let e=await this.api.experiments.streamExperiments({name:t});return (await xe(e,I.ExperimentPublic)).map(i=>new De({id:i.id,name:i.name,datasetName:i.datasetName},this))}catch(e){throw S.error(`Failed to get experiments with name "${t}"`,{error:e}),e}};this.getExperiment=async t=>{S.debug(`Getting experiment with name "${t}"`);let e=await this.getExperimentsByName(t);if(e.length===0)throw new nt(t);return e[0]};this.getDatasetExperiments=async(t,e=100)=>{var c;S.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 z=0;z<k;z++){let x=g[z];a.push(new De({id:x.id,name:x.name,datasetName:x.datasetName},this));}if(k<g.length)break;d+=1;}return a}catch(d){throw S.error(`Failed to get experiments for dataset "${t}"`,{error:d}),d}};this.deleteExperiment=async t=>{S.debug(`Deleting experiment with ID "${t}"`);try{await this.api.experiments.deleteExperimentsById({ids:[t]});}catch(e){throw S.error(`Failed to delete experiment with ID "${t}"`,{error:e}),e}};this.createPrompt=async t=>{var e;S.debug("Creating prompt",{name:t.name});try{let o=await Kd(this.api.prompts,t.name,this.api.requestOptions),i=(e=t.type)!=null?e:de.MUSTACHE,a=Xd(t,o,i),c;if(a?(S.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)):(S.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=_e.fromApiResponse(d,c,this);return S.debug("Prompt created",{name:t.name}),t.description||t.tags?await u.updateProperties({description:t.description,tags:t.tags}):u}catch(o){throw S.error("Failed to create prompt",{name:t.name,error:o}),o}};this.getPrompt=async t=>{var e;S.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 S.debug("Prompt not found",{name:t.name}),null;let a=await this.api.prompts.retrievePromptVersion(t,this.api.requestOptions);return _e.fromApiResponse(i,a,this)}catch(o){if(o instanceof p&&o.statusCode===404)return null;throw S.error("Failed to get prompt",{name:t.name,error:o}),o}};this.searchPrompts=async t=>{var e;S.debug("Searching prompts",{filterString:t});try{let o;if(t){let u=new Ae(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 _e.fromApiResponse(d,u,this)}catch(u){return S.debug("Failed to get version for prompt",{name:d.name,error:u}),null}}))).filter(d=>d!==null)}catch(o){throw S.error("Failed to search prompts",{error:o}),o}};this.deletePrompts=async t=>{S.debug("Deleting prompts in batch",{count:t.length});try{await this.api.prompts.deletePromptsBatch({ids:t},this.api.requestOptions),S.info("Successfully deleted prompts",{count:t.length});}catch(e){throw S.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:{};S.debug("Searching traces",{projectName:e,filterString:o,maxResults:i,truncate:a,waitForAtLeast:c,waitForTimeout:d});let u=eu(o),g=e!=null?e:this.config.projectName,y=()=>Zd(this.api,g,u,i,a);if(c===void 0)return await y();let k=await qd(y,c,d*1e3,5e3);if(k.length<c)throw new fa(`Timeout after ${d} seconds: expected ${c} traces, but only ${k.length} were found.`);return k};this.flush=async()=>{S.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(),S.info("Successfully flushed all data to Opik");}catch(t){S.error("Error during flush operation:",{error:t instanceof Error?t.message:t});}};S.debug("Initializing OpikClient with config:",t),this.config=bm(t);let e={apiKey:this.config.apiKey,environment:this.config.apiUrl,workspaceName:this.config.workspaceName};t!=null&&t.headers&&(S.debug("Initializing OpikClient with additional headers:",t==null?void 0:t.headers),e.requestOptions={headers:t==null?void 0:t.headers}),this.api=new ga(e);let o=this.config.holdUntilFlush?24*60*60*1e3:this.config.batchDelayMs;this.spanBatchQueue=new la(this.api,o),this.traceBatchQueue=new da(this.api,o),this.spanFeedbackScoresBatchQueue=new ma(this.api,o),this.traceFeedbackScoresBatchQueue=new ua(this.api,o),this.datasetBatchQueue=new wa(this.api,o),Zl.push(this);}};var Ih="track.decorator",dt=new async_hooks.AsyncLocalStorage,jh=()=>{let{span:n,trace:t}=dt.getStore()||{};if(!(!n||!t))return {span:n,trace:t}};function Uh(n){return !!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}function Nh({name:n,parentSpan:t,projectName:e,trace:o,type:i="llm"}){S.debug("Creating new span:",{name:n,parentSpan:t==null?void 0:t.data.id,projectName:e,type:i});let a=o;a||(a=em().trace({name:n,projectName:e}));let c=a.span({name:n,parentSpanId:t==null?void 0:t.data.id,projectName:e,type:i});return S.debug("Span created with ID:",c.data.id),{span:c,trace:a}}function Mh({args:n,span:t,trace:e}){if(S.debug("Starting span execution:",{spanId:t.data.id,traceId:e==null?void 0:e.data.id}),n.length===0)return;let o={arguments:n};S.debug("Recording span input"),t.update({input:o}),e&&(S.debug("Recording trace input"),e.update({input:o}));}function ru({result:n,span:t,trace:e,enrichSpan:o}){S.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 ou({span:n,error:t,trace:e}){var o,i;S.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 Aa({name:n,projectName:t,type:e,enrichSpan:o}={},i){return S.info("Executing track with enrichSpan:",JSON.stringify(o,null,2)),function(...c){let d=dt.getStore(),{span:u,trace:g}=Nh({name:n!=null?n:i.name||Ih,parentSpan:d==null?void 0:d.span,projectName:t,trace:d==null?void 0:d.trace,type:e}),y=!d,k=this;return dt.run({span:u,trace:g},()=>{let z=y?g:void 0;try{Mh({args:c,span:u,trace:z});let x=i.apply(k,c);return Uh(x)?x.then(_=>(ru({span:u,result:_,trace:z,enrichSpan:o}),_),_=>{throw ou({span:u,error:_,trace:z}),_}):(ru({span:u,result:x,trace:z,enrichSpan:o}),x)}catch(x){throw ou({span:u,error:x,trace:z}),x}})}}function ke(n,t){if(typeof n=="function")return Aa({},n);let e=n;return t?Aa(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 Aa(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=Aa(e,a),i}}var ql=null;function em(){return ql===null&&(ql=new Fe),ql}var Dh=async()=>{S.debug("Starting flushAll operation");try{await Promise.all([em().flush(),...Zl.map(n=>n.flush())]),S.debug("flushAll operation completed successfully");}catch(n){throw S.error("Error during flushAll operation:",{error:n instanceof Error?n.message:n,stack:n instanceof Error?n.stack:void 0}),n}};function tu(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(Fh(n,t,c))}}function Fh(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 Pa=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){S.info(`
13
+ No test results available to display.`);return}if(o.size===0){S.info(`
14
+ No metrics available to display.`);return}let a=[...o.keys()].sort(),c=this.formatTime(i),d=[Ea__default.default.bold(`Total time: ${c}`),Ea__default.default.bold(`Number of samples: ${t.length}`),"",...a.map(y=>{let k=this.formatScore(o.get(y)||0);return Ea__default.default.green(`${y}: ${k} (avg)`)})].join(`
15
+ `),u=await e.ensureNameLoaded(),g=Oh__default.default(d,{title:`${u} (${t.length} samples)`,titleAlignment:"left",padding:1,margin:0,borderColor:"cyan",borderStyle:"round"});S.info(`
16
16
  `+g+`
17
- `),z.info(Aa__default.default.blue("Uploading results to Opik ... "));}static async displayExperimentLink(t){let e=await t.getUrl();z.info(`View the results ${ht(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 ou(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 tu,ql;tu=[ke({name:"metrics_calculation",type:we.General})];var er=class{constructor(t,e,o){dm(ql,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=Fh__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}),mt.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 ka({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(),Ea.processResults(m,this.experiment,g)}async executeTask(t){let e={},o=[];z.debug(`Starting evaluation task on dataset item ${t.id}`),e=await ke({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=ou(o,c);m!==void 0&&(i[a]=m);}return i}};ql=lm(),um(ql,1,"calculateScores",tu,er),Oa(ql,er);var rr=class rr{static getInstance(t){return rr.instance||(rr.instance=new Fe(t)),rr.instance}};rr.instance=null;var Pa=rr;async function iu(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:Pa.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 Oe=class{constructor(t){this.modelName=t;}};var dt=class n extends Error{constructor(t){super(t),this.name="ModelError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},or=class n extends dt{constructor(e,o){super(e);this.cause=o;this.name="ModelGenerationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},Ee=class n extends dt{constructor(t){super(t),this.name="ModelConfigurationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}};function Lh(n,t){return n.startsWith("gpt-")||n.startsWith("o1")||n.startsWith("o3")||n.startsWith("chatgpt-")}function Vh(n,t){return n.startsWith("claude-")}function Hh(n,t){return n.startsWith("gemini-")||n.startsWith("gemma-")}function em(n,t,e){if(!t)throw new Ee(`API key for ${n} is not configured. Please provide it via the 'apiKey' option or set the ${e} environment variable.`)}function rm(n,t){if(Lh(n)){let e=(t==null?void 0:t.apiKey)||process.env.OPENAI_API_KEY;return em("OpenAI",e,"OPENAI_API_KEY"),openai.createOpenAI({apiKey:e,...t})(n)}if(Vh(n)){let e=(t==null?void 0:t.apiKey)||process.env.ANTHROPIC_API_KEY;return em("Anthropic",e,"ANTHROPIC_API_KEY"),anthropic.createAnthropic({apiKey:e,...t})(n)}if(Hh(n)){let e=(t==null?void 0:t.apiKey)||process.env.GOOGLE_API_KEY;return em("Google Gemini",e,"GOOGLE_API_KEY"),google.createGoogleGenerativeAI({apiKey:e,...t})(n)}throw new Ee(`Unable to detect provider for model ID: ${n}. Supported providers are OpenAI (gpt-*, o1*, o3*, chatgpt-*), Anthropic (claude-*), and Google Gemini (gemini-*, gemma-*).`)}var Jh={inputTokens:"prompt_tokens",outputTokens:"completion_tokens",totalTokens:"total_tokens",reasoningTokens:"reasoning_tokens",cachedInputTokens:"cached_input_tokens"};function Kh(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 om(n,t){if(!Kh(n))return {model:t};let e={model:Xh(n,t)},o=Gh(n.usage);o&&(e.usage=o);let i=$h(n);i&&(e.provider=i);let a=Yh(n);a&&(e.metadata=a);let c=Zh(n);return c&&(e.output=c),e}function Xh(n,t){var e,o;return (o=(e=n.response)==null?void 0:e.modelId)!=null?o:t}function Gh(n){if(!n)return;let t={};for(let[e,o]of Object.entries(Jh)){let i=n[e];i!==void 0&&(t[o]=i);}return Object.keys(t).length>0?t:void 0}function $h(n){if(!n.providerMetadata)return;let t=Object.keys(n.providerMetadata);return t.length>0?t[0]:void 0}function Qh(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 Yh(n){let t={};n.usage&&(t.usage=n.usage),n.warnings&&n.warnings.length>0&&(t.warnings=n.warnings);let e=Qh(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 Zh(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 Oe{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=rm(t,a),z.debug(`Initialized VercelAIChatModel with model ID: ${t}`)),i?(this._generateText=ke({name:"model.generateText",type:we.Llm,enrichSpan:c=>om(c,this.modelName)},ai$1.generateText),this._generateObject=ke({name:"model.generateObject",type:we.Llm,enrichSpan:c=>om(c,this.modelName)},ai$1.generateObject)):(this._generateText=ai$1.generateText,this._generateObject=ai$1.generateObject);}catch(c){throw new Ee(`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 su="gpt-4o";function tm(n,t){return new tr(n,t)}function pu(n,t){return new tr(n,t)}function qh(n){return n instanceof Oe}function ef(n){return typeof n=="object"&&n!==null&&"modelId"in n&&typeof n.modelId=="string"}function rf(n){return typeof n=="string"&&n.length>0}function of(n){let t=typeof n,e=t==="object"?JSON.stringify(n):String(n);return new Error(`Invalid model type. Expected one of:
17
+ `),S.info(Ea__default.default.blue("Uploading results to Opik ... "));}static async displayExperimentLink(t){let e=await t.getUrl();S.info(`View the results ${ft(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 iu(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 au,rm;au=[ke({name:"metrics_calculation",type:we.General})];var er=class{constructor(t,e,o){gm(rm,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=S.settings.minLevel;S.settings.minLevel=6;let c=Wh__default.default({text:`Evaluating dataset (0/${i} items)`}).start(),d=[];for(let k=0;k<o.length;k++){let z=o[k];try{this.rootTrace=this.client.trace({projectName:this.projectName,name:"evaluation_task",createdBy:"evaluation",input:z}),dt.enterWith({trace:this.rootTrace});let x=await this.executeTask(z);d.push(x),this.rootTrace.update({output:x.testCase.taskOutput,endTime:new Date});}catch(x){let _=x instanceof Error?x.message:String(x);S.error(`Error processing dataset item: ${z.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:z.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`),S.settings.minLevel=a,this.experiment.insert(e),await this.client.flush(),Pa.processResults(d,this.experiment,g)}async executeTask(t){let e={},o=[];S.debug(`Starting evaluation task on dataset item ${t.id}`),e=await ke({name:"llm_task",type:we.General},this.task)(t),S.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){S.debug(`Calculating score for metric ${i.name}`);try{tu(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);S.error(`Metric ${i.name} failed: ${c}`);}S.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=iu(o,c);d!==void 0&&(i[a]=d);}return i}};rm=dm(),wm(rm,1,"calculateScores",au,er),Wa(rm,er);var rr=class rr{static getInstance(t){return rr.instance||(rr.instance=new Fe(t)),rr.instance}};rr.instance=null;var va=rr;async function nu(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:va.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 S.info("Starting evaluation"),i.execute()}catch(i){throw S.error(`Error during evaluation: ${i}`),i}}var Oe=class{constructor(t){this.modelName=t;}};var ut=class n extends Error{constructor(t){super(t),this.name="ModelError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},or=class n extends ut{constructor(e,o){super(e);this.cause=o;this.name="ModelGenerationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},Ee=class n extends ut{constructor(t){super(t),this.name="ModelConfigurationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}};function Hh(n,t){return n.startsWith("gpt-")||n.startsWith("o1")||n.startsWith("o3")||n.startsWith("chatgpt-")}function Jh(n,t){return n.startsWith("claude-")}function Kh(n,t){return n.startsWith("gemini-")||n.startsWith("gemma-")}function om(n,t,e){if(!t)throw new Ee(`API key for ${n} is not configured. Please provide it via the 'apiKey' option or set the ${e} environment variable.`)}function tm(n,t){if(Hh(n)){let e=(t==null?void 0:t.apiKey)||process.env.OPENAI_API_KEY;return om("OpenAI",e,"OPENAI_API_KEY"),openai.createOpenAI({apiKey:e,...t})(n)}if(Jh(n)){let e=(t==null?void 0:t.apiKey)||process.env.ANTHROPIC_API_KEY;return om("Anthropic",e,"ANTHROPIC_API_KEY"),anthropic.createAnthropic({apiKey:e,...t})(n)}if(Kh(n)){let e=(t==null?void 0:t.apiKey)||process.env.GOOGLE_API_KEY;return om("Google Gemini",e,"GOOGLE_API_KEY"),google.createGoogleGenerativeAI({apiKey:e,...t})(n)}throw new Ee(`Unable to detect provider for model ID: ${n}. Supported providers are OpenAI (gpt-*, o1*, o3*, chatgpt-*), Anthropic (claude-*), and Google Gemini (gemini-*, gemma-*).`)}var Xh={inputTokens:"prompt_tokens",outputTokens:"completion_tokens",totalTokens:"total_tokens",reasoningTokens:"reasoning_tokens",cachedInputTokens:"cached_input_tokens"};function Gh(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 im(n,t){if(!Gh(n))return {model:t};let e={model:$h(n,t)},o=Qh(n.usage);o&&(e.usage=o);let i=Yh(n);i&&(e.provider=i);let a=qh(n);a&&(e.metadata=a);let c=ef(n);return c&&(e.output=c),e}function $h(n,t){var e,o;return (o=(e=n.response)==null?void 0:e.modelId)!=null?o:t}function Qh(n){if(!n)return;let t={};for(let[e,o]of Object.entries(Xh)){let i=n[e];i!==void 0&&(t[o]=i);}return Object.keys(t).length>0?t:void 0}function Yh(n){if(!n.providerMetadata)return;let t=Object.keys(n.providerMetadata);return t.length>0?t[0]:void 0}function Zh(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 qh(n){let t={};n.usage&&(t.usage=n.usage),n.warnings&&n.warnings.length>0&&(t.warnings=n.warnings);let e=Zh(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 ef(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 Oe{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,S.debug("Initialized VercelAIChatModel with custom LanguageModel")):(this.model=tm(t,a),S.debug(`Initialized VercelAIChatModel with model ID: ${t}`)),i?(this._generateText=ke({name:"model.generateText",type:we.Llm,enrichSpan:c=>im(c,this.modelName)},ai$1.generateText),this._generateObject=ke({name:"model.generateObject",type:we.Llm,enrichSpan:c=>im(c,this.modelName)},ai$1.generateObject)):(this._generateText=ai$1.generateText,this._generateObject=ai$1.generateObject);}catch(c){throw new Ee(`Failed to initialize model ${o}: ${c instanceof Error?c.message:String(c)}`)}}async generateString(t,e,o){try{let i;if(e){S.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});S.debug(`Generated structured output with model ${this.modelName}`),i=JSON.stringify(a.object);}else {S.debug(`Generating text with model ${this.modelName}, input length: ${t.length}`);let a=await this._generateText({model:this.model,prompt:t,...o});S.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 S.error(a,{error:i}),new or(a,i instanceof Error?i:new Error(String(i)))}}async generateProviderResponse(t,e){try{S.debug(`Generating provider response with model ${this.modelName}, messages count: ${t.length}`);let o=await this._generateText({model:this.model,messages:t,...e});return S.debug(`Generated provider response with model ${this.modelName}`),o}catch(o){let i=`Failed to generate provider response with model ${this.modelName}`;throw S.error(i,{error:o}),new or(i,o instanceof Error?o:new Error(String(o)))}}};var cu="gpt-4o";function am(n,t){return new tr(n,t)}function lu(n,t){return new tr(n,t)}function rf(n){return n instanceof Oe}function of(n){return typeof n=="object"&&n!==null&&"modelId"in n&&typeof n.modelId=="string"}function tf(n){return typeof n=="string"&&n.length>0}function af(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: ${su})
21
+ - undefined (uses default model: ${cu})
22
22
 
23
- Received: ${t} ${e}`)}function ut(n,t){if(n==null)return tm(su,t);if(rf(n))return tm(n,t);if(qh(n))return n;if(ef(n))return pu(n,t);throw of(n)}function cu(n){return n.map(t=>`${t.role}: ${t.content}`).join(`
24
- `)}async function uee(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=ut(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=tf(t,n.messages,(i=n.templateType)!=null?i:de.MUSTACHE,{temperature:n.temperature,seed:n.seed});return iu({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 tf(n,t,e,o){return async i=>{let a=t.map(g=>({...g,content:qe(g.content,i,e)})),c=await n.generateProviderResponse(a,o),m=af(c);return {input:cu(a),output:m}}}function af(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=ke({name:this.name,type:we.General},o);}}};var nf=im__default.default.object({output:im__default.default.unknown(),expected:im__default.default.unknown()}),lu=class extends pe{constructor(e="exact_match",o=true){super(e,o);this.validationSchema=nf;}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 sf=im__default.default.object({output:im__default.default.string(),substring:im__default.default.string()}),mu=class extends pe{constructor(e="contains",o=true,i=false){super(e,o);this.validationSchema=sf;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 pf=im.z.object({output:im.z.string(),pattern:im.z.string(),flags:im.z.string().optional()}),du=class extends pe{constructor(e="regex_match",o=true){super(e,o);this.validationSchema=pf;}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 cf=im__default.default.object({output:im__default.default.unknown()}),gu=class extends pe{constructor(e="is_json_metric",o=true){super(e,o);this.validationSchema=cf;}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 ut(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 wu(n,t=[]){let e="";return t.length>0&&(e=`
23
+ Received: ${t} ${e}`)}function gt(n,t){if(n==null)return am(cu,t);if(tf(n))return am(n,t);if(rf(n))return n;if(of(n))return lu(n,t);throw af(n)}function mu(n){return n.map(t=>`${t.role}: ${t.content}`).join(`
24
+ `)}async function kee(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=gt(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=nf(t,n.messages,(i=n.templateType)!=null?i:de.MUSTACHE,{temperature:n.temperature,seed:n.seed});return nu({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 nf(n,t,e,o){return async i=>{let a=t.map(g=>({...g,content:qe(g.content,i,e)})),c=await n.generateProviderResponse(a,o),d=sf(c);return {input:mu(a),output:d}}}function sf(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=ke({name:this.name,type:we.General},o);}}};var pf=nm__default.default.object({output:nm__default.default.unknown(),expected:nm__default.default.unknown()}),du=class extends pe{constructor(e="exact_match",o=true){super(e,o);this.validationSchema=pf;}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 cf=nm__default.default.object({output:nm__default.default.string(),substring:nm__default.default.string()}),uu=class extends pe{constructor(e="contains",o=true,i=false){super(e,o);this.validationSchema=cf;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 lf=nm.z.object({output:nm.z.string(),pattern:nm.z.string(),flags:nm.z.string().optional()}),gu=class extends pe{constructor(e="regex_match",o=true){super(e,o);this.validationSchema=lf;}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 mf=nm__default.default.object({output:nm__default.default.unknown()}),hu=class extends pe{constructor(e="is_json_metric",o=true){super(e,o);this.validationSchema=mf;}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 gt(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 fu(n,t=[]){let e="";return t.length>0&&(e=`
25
25
 
26
26
  ###EXAMPLES###
27
27
 
@@ -83,7 +83,7 @@ ${e}
83
83
  Analyze the following text and provide your verdict score, and reason in the specified JSON format:
84
84
 
85
85
  ${n}
86
- `}var Ca=class n extends Error{constructor(t){super(t),this.name="MetricError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},ce=class n extends Ca{constructor(e,o){super(e);this.cause=o;this.name="MetricComputationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},Ia=class n extends Ca{constructor(e,o){super(e);this.cause=o;this.name="JSONParsingError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}};function Pe(n){try{return JSON.parse(n)}catch{return lf(n)}}function lf(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 Ia(`Failed to extract JSON from content: ${e}`,t instanceof Error?t:void 0)}}function hu(n,t){try{let e=Pe(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 mf=im.z.object({output:im.z.string()}),df=im.z.object({score:im.z.number(),reason:im.z.string()}),ja=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=mf;this.fewShotExamples=(a=e==null?void 0:e.fewShotExamples)!=null?a:[];}async score(e){let{output:o}=e,i=wu(o,this.fewShotExamples),a=this.buildModelOptions(),c=await this.model.generateString(i,df,a);return hu(c,this.name)}};function fu(n,t){return `
86
+ `}var Ia=class n extends Error{constructor(t){super(t),this.name="MetricError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},ce=class n extends Ia{constructor(e,o){super(e);this.cause=o;this.name="MetricComputationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},ja=class n extends Ia{constructor(e,o){super(e);this.cause=o;this.name="JSONParsingError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}};function Pe(n){try{return JSON.parse(n)}catch{return df(n)}}function df(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 ja(`Failed to extract JSON from content: ${e}`,t instanceof Error?t:void 0)}}function Ru(n,t){try{let e=Pe(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 S.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 uf=nm.z.object({output:nm.z.string()}),gf=nm.z.object({score:nm.z.number(),reason:nm.z.string()}),Ua=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=uf;this.fewShotExamples=(a=e==null?void 0:e.fewShotExamples)!=null?a:[];}async score(e){let{output:o}=e,i=fu(o,this.fewShotExamples),a=this.buildModelOptions(),c=await this.model.generateString(i,gf,a);return Ru(c,this.name)}};function bu(n,t){return `
87
87
  You are an impartial judge tasked with evaluating the quality and usefulness of AI-generated responses.
88
88
  Your evaluation should consider the following key factors:
89
89
  - Helpfulness: How well does it solve the user's problem?
@@ -119,7 +119,7 @@ ${n}
119
119
  AI Response: ${t}
120
120
 
121
121
  Provide your evaluation in the specified JSON format.
122
- `}function Ru(n,t){try{let e=Pe(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 uf=im.z.object({input:im.z.string(),output:im.z.string()}),gf=im.z.object({score:im.z.number(),reason:im.z.string()}),Ua=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=uf;}async score(e){let{input:o,output:i}=e,a=fu(o,i),c=this.buildModelOptions(),m=await this.model.generateString(a,gf,c);return Ru(m,this.name)}};var wf=`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.
122
+ `}function yu(n,t){try{let e=Pe(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 S.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 wf=nm.z.object({input:nm.z.string(),output:nm.z.string()}),hf=nm.z.object({score:nm.z.number(),reason:nm.z.string()}),Na=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=wf;}async score(e){let{input:o,output:i}=e,a=bu(o,i),c=this.buildModelOptions(),d=await this.model.generateString(a,hf,c);return yu(d,this.name)}};var ff=`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
123
 
124
124
  Guidelines:
125
125
  1. The OUTPUT must not introduce new information beyond what's provided in the CONTEXT.
@@ -154,7 +154,7 @@ It is crucial that you provide your answer in the following JSON format:
154
154
  "reason": ["reason 1", "reason 2"]
155
155
  }}
156
156
  Reasons amount is not restricted. Output must be JSON format only.
157
- `,hf=`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.
157
+ `,Rf=`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
158
 
159
159
  Guidelines:
160
160
  1. Evaluate the OUTPUT based on generally accepted facts and reliable information.
@@ -185,7 +185,7 @@ It is crucial that you provide your answer in the following JSON format:
185
185
  "reason": ["some reason 1", "some reason 2"]
186
186
  }}
187
187
  Reasons amount is not restricted. Output must be JSON format only.
188
- `;function bu(n,t){return n.length===0?"":`
188
+ `;function ku(n,t){return n.length===0?"":`
189
189
 
190
190
  EXAMPLES:
191
191
 
@@ -197,7 +197,7 @@ ${i}Output: ${o.output}
197
197
  {"score": "${o.score}", "reason": "${o.reason}"}
198
198
  </example>`}).join(`
199
199
 
200
- `)}`}function yu(n,t,e,o=[]){let i=bu(o,true);return wf.replace("{examples_str}",i).replace("{input}",n).replace("{context}",JSON.stringify(e)).replace("{output}",t)}function ku(n,t,e=[]){let o=bu(e,false);return hf.replace("{examples_str}",o).replace("{input}",n).replace("{output}",t)}function zu(n,t){try{let e=Pe(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 ff=im.z.object({input:im.z.string(),output:im.z.string(),context:im.z.array(im.z.string()).optional()}),Rf=im.z.object({score:im.z.number(),reason:im.z.union([im.z.string(),im.z.array(im.z.string())])}),Na=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=ff;this.fewShotExamples=(a=e==null?void 0:e.fewShotExamples)!=null?a:[];}async score(e){let{input:o,output:i,context:a}=e,c=a?yu(o,i,a,this.fewShotExamples):ku(o,i,this.fewShotExamples),m=this.buildModelOptions(),u=await this.model.generateString(c,Rf,m);return zu(u,this.name)}};var Su=[{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."}],xu=[{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 bf(n){return n.map((t,e)=>`#### Example ${e+1}: ${t.title}
200
+ `)}`}function Su(n,t,e,o=[]){let i=ku(o,true);return ff.replace("{examples_str}",i).replace("{input}",n).replace("{context}",JSON.stringify(e)).replace("{output}",t)}function zu(n,t,e=[]){let o=ku(e,false);return Rf.replace("{examples_str}",o).replace("{input}",n).replace("{output}",t)}function xu(n,t){try{let e=Pe(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 S.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 bf=nm.z.object({input:nm.z.string(),output:nm.z.string(),context:nm.z.array(nm.z.string()).optional()}),yf=nm.z.object({score:nm.z.number(),reason:nm.z.union([nm.z.string(),nm.z.array(nm.z.string())])}),Ma=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=bf;this.fewShotExamples=(a=e==null?void 0:e.fewShotExamples)!=null?a:[];}async score(e){let{input:o,output:i,context:a}=e,c=a?Su(o,i,a,this.fewShotExamples):zu(o,i,this.fewShotExamples),d=this.buildModelOptions(),u=await this.model.generateString(c,yf,d);return xu(u,this.name)}};var _u=[{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."}],Tu=[{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 kf(n){return n.map((t,e)=>`#### Example ${e+1}: ${t.title}
201
201
 
202
202
  - **Input:** "${t.input}"
203
203
  - **Output:** "${t.output}"
@@ -210,7 +210,7 @@ ${i}Output: ${o.output}
210
210
  }
211
211
  \`\`\``).join(`
212
212
 
213
- `)}function yf(n){return n.map((t,e)=>`#### Example ${e+1}: ${t.title}
213
+ `)}function Sf(n){return n.map((t,e)=>`#### Example ${e+1}: ${t.title}
214
214
 
215
215
  - **Input:** "${t.input}"
216
216
  - **Output:** "${t.output}"
@@ -222,7 +222,7 @@ ${i}Output: ${o.output}
222
222
  }
223
223
  \`\`\``).join(`
224
224
 
225
- `)}function _u(n,t,e,o){return `
225
+ `)}function Au(n,t,e,o){return `
226
226
  YOU ARE AN EXPERT IN NLP EVALUATION METRICS, SPECIALLY TRAINED TO ASSESS ANSWER RELEVANCE IN RESPONSES
227
227
  PROVIDED BY LANGUAGE MODELS. YOUR TASK IS TO EVALUATE THE RELEVANCE OF A GIVEN ANSWER FROM
228
228
  ANOTHER LLM BASED ON THE USER'S INPUT AND CONTEXT PROVIDED.
@@ -268,7 +268,7 @@ ${i}Output: ${o.output}
268
268
 
269
269
  ###FEW-SHOT EXAMPLES###
270
270
 
271
- ${bf(o)}
271
+ ${kf(o)}
272
272
 
273
273
  ###INPUTS:###
274
274
  ***
@@ -281,7 +281,7 @@ ${i}Output: ${o.output}
281
281
  Context:
282
282
  ${JSON.stringify(e)}
283
283
  ***
284
- `}function Tu(n,t,e){return `
284
+ `}function Eu(n,t,e){return `
285
285
  YOU ARE AN EXPERT IN NLP EVALUATION METRICS, SPECIALLY TRAINED TO ASSESS ANSWER RELEVANCE IN RESPONSES
286
286
  PROVIDED BY LANGUAGE MODELS. YOUR TASK IS TO EVALUATE THE RELEVANCE OF A GIVEN ANSWER FROM
287
287
  ANOTHER LLM BASED ON THE USER'S INPUT.
@@ -326,7 +326,7 @@ ${i}Output: ${o.output}
326
326
 
327
327
  ###FEW-SHOT EXAMPLES###
328
328
 
329
- ${yf(e)}
329
+ ${Sf(e)}
330
330
 
331
331
  ###INPUTS:###
332
332
  ***
@@ -336,4 +336,4 @@ ${i}Output: ${o.output}
336
336
  Output:
337
337
  ${t}
338
338
  ***
339
- `}function Au(n,t){try{let e=Pe(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 kf=im.z.object({input:im.z.string(),output:im.z.string(),context:im.z.array(im.z.string()).optional()}),zf=im.z.object({answer_relevance_score:im.z.number(),reason:im.z.string()}),Ma=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=kf;this.fewShotExamplesWithContext=(a=e==null?void 0:e.fewShotExamples)!=null?a:Su,this.fewShotExamplesNoContext=(c=e==null?void 0:e.fewShotExamplesNoContext)!=null?c:xu,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?_u(o,i,a,this.fewShotExamplesWithContext):Tu(o,i,this.fewShotExamplesNoContext),m=this.buildModelOptions(),u=await this.model.generateString(c,zf,m);return Au(u,this.name)}};exports.AnswerRelevance=Ma;exports.BaseLLMJudgeMetric=ue;exports.BaseMetric=pe;exports.Contains=mu;exports.ExactMatch=lu;exports.Hallucination=Na;exports.IsJson=gu;exports.ModelConfigurationError=Ee;exports.ModelError=dt;exports.ModelGenerationError=or;exports.Moderation=ja;exports.Opik=Fe;exports.OpikBaseModel=Oe;exports.OpikQueryLanguage=Ae;exports.OpikSpanType=we;exports.Prompt=_e;exports.PromptType=de;exports.RegexMatch=du;exports.Usefulness=Ua;exports.VercelAIChatModel=tr;exports.createModel=tm;exports.createModelFromInstance=pu;exports.detectProvider=rm;exports.disableLogger=Du;exports.evaluate=iu;exports.evaluatePrompt=uee;exports.flushAll=Nh;exports.generateId=Z;exports.getTrackContext=Ch;exports.logger=z;exports.resolveModel=ut;exports.setLoggerLevel=gm;exports.track=ke;
339
+ `}function Pu(n,t){try{let e=Pe(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 S.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 zf=nm.z.object({input:nm.z.string(),output:nm.z.string(),context:nm.z.array(nm.z.string()).optional()}),xf=nm.z.object({answer_relevance_score:nm.z.number(),reason:nm.z.string()}),Da=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=zf;this.fewShotExamplesWithContext=(a=e==null?void 0:e.fewShotExamples)!=null?a:_u,this.fewShotExamplesNoContext=(c=e==null?void 0:e.fewShotExamplesNoContext)!=null?c:Tu,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?Au(o,i,a,this.fewShotExamplesWithContext):Eu(o,i,this.fewShotExamplesNoContext),d=this.buildModelOptions(),u=await this.model.generateString(c,xf,d);return Pu(u,this.name)}};exports.AnswerRelevance=Da;exports.BaseLLMJudgeMetric=ue;exports.BaseMetric=pe;exports.Contains=uu;exports.ExactMatch=du;exports.Hallucination=Ma;exports.IsJson=hu;exports.ModelConfigurationError=Ee;exports.ModelError=ut;exports.ModelGenerationError=or;exports.Moderation=Ua;exports.Opik=Fe;exports.OpikBaseModel=Oe;exports.OpikQueryLanguage=Ae;exports.OpikSpanType=we;exports.Prompt=_e;exports.PromptType=de;exports.RegexMatch=gu;exports.Usefulness=Na;exports.VercelAIChatModel=tr;exports.createModel=am;exports.createModelFromInstance=lu;exports.detectProvider=tm;exports.disableLogger=Ou;exports.evaluate=nu;exports.evaluatePrompt=kee;exports.flushAll=Dh;exports.generateId=Z;exports.getTrackContext=jh;exports.logger=S;exports.resolveModel=gt;exports.setLoggerLevel=hm;exports.track=ke;