opik 1.9.12 → 1.9.14
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 +26 -25
- package/dist/index.d.cts +89 -38
- package/dist/index.d.ts +89 -38
- package/dist/index.js +25 -24
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
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
|
|
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
|
|
1
|
+
'use strict';var ansiEscapes=require('ansi-escapes'),tslog=require('tslog'),vm=require('fs'),$u=require('ini');require('dotenv/config');var Cw=require('qs'),uuid=require('uuid'),Af=require('fast-json-stable-stringify'),Tf=require('xxhash-wasm'),util=require('util'),If=require('mustache'),Nf=require('nunjucks'),dateFns=require('date-fns'),jestDiff=require('jest-diff'),Ff=require('fast-deep-equal'),async_hooks=require('async_hooks'),Pa=require('chalk'),$f=require('boxen'),Qf=require('ora'),ai$1=require('ai'),openai=require('@ai-sdk/openai'),anthropic=require('@ai-sdk/anthropic'),google=require('@ai-sdk/google'),bm=require('zod');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var vm__default=/*#__PURE__*/_interopDefault(vm);var $u__default=/*#__PURE__*/_interopDefault($u);var Cw__default=/*#__PURE__*/_interopDefault(Cw);var Af__default=/*#__PURE__*/_interopDefault(Af);var Tf__default=/*#__PURE__*/_interopDefault(Tf);var If__default=/*#__PURE__*/_interopDefault(If);var Nf__default=/*#__PURE__*/_interopDefault(Nf);var Ff__default=/*#__PURE__*/_interopDefault(Ff);var Pa__default=/*#__PURE__*/_interopDefault(Pa);var $f__default=/*#__PURE__*/_interopDefault($f);var Qf__default=/*#__PURE__*/_interopDefault(Qf);var bm__default=/*#__PURE__*/_interopDefault(bm);var Ou=Object.create;var ht=Object.defineProperty;var Wu=Object.getOwnPropertyDescriptor;var xm=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),nr=n=>{throw TypeError(n)};var Bu=(n,t,e)=>t in n?ht(n,t,{enumerable:true,configurable:true,writable:true,value:e}):n[t]=e;var Wa=(n,t)=>()=>(n&&(t=n(n=0)),t);var P=(n,t)=>{for(var e in t)ht(n,e,{get:t[e],enumerable:true});};var _m=n=>{var t;return [,,,Ou((t=void 0)!=null?t:null)]},Tm=["class","method","getter","setter","accessor","field","value","get","set"],ar=n=>n!==void 0&&typeof n!="function"?nr("Function expected"):n,Lu=(n,t,e,o,i)=>({kind:Tm[n],name:t,metadata:o,addInitializer:a=>e._?nr("Already initialized"):i.push(ar(a||null))}),Ba=(n,t)=>Bu(t,xm("metadata"),n[3]),Am=(n,t,e,o)=>{for(var i=0,a=n[t>>1],c=a&&a.length;i<c;i++)a[i].call(e);return o},Em=(n,t,e,o,i,a)=>{var d,u,g,y,k=t&7,S=false,x=false,_=2,M=Tm[k+5],J=n[_]||(n[_]=[]),q=((i=i.prototype),Wu(i,e));for(var Be=o.length-1;Be>=0;Be--)g=Lu(k,e,u={},n[3],J),(g.static=S,g.private=x,y=g.access={has:oe=>e in oe},(y.get=oe=>oe[e]),k>2),d=(0, o[Be])(q[M],g),u._=1,ar(d)&&(q[M]=d);return q&&ht(i,e,q),i};var sd={};P(sd,{Node18UniversalStreamWrapper:()=>nn});var nn,pd=Wa(()=>{nn=class n{constructor(t){this.readableStream=t,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=false,this.resumeCallback=null,this.encoding=null;}on(t,e){var o;(o=this.events[t])==null||o.push(e);}off(t,e){var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(i=>i!==e);}pipe(t){return this.on("data",async e=>{if(t instanceof n)t._write(e);else if(t instanceof WritableStream){let o=t.getWriter();o.write(e).then(()=>o.releaseLock());}else t.write(e);}),this.on("end",async()=>{t instanceof n?t._end():t instanceof WritableStream?t.getWriter().close():t.end();}),this.on("error",async e=>{t instanceof n?t._error(e):t instanceof WritableStream?t.getWriter().abort(e):t.destroy(e);}),this._startReading(),t}pipeTo(t){return this.pipe(t)}unpipe(t){this.off("data",async e=>{if(t instanceof n)t._write(e);else if(t instanceof WritableStream){let o=t.getWriter();o.write(e).then(()=>o.releaseLock());}else t.write(e);}),this.off("end",async()=>{t instanceof n?t._end():t instanceof WritableStream?t.getWriter().close():t.end();}),this.off("error",async e=>{t instanceof n?t._error(e):t instanceof WritableStream?t.getWriter().abort(e):t.destroy(e);});}destroy(t){this.reader.cancel(t).then(()=>{this._emit("close");}).catch(e=>{this._emit("error",e);});}pause(){this.paused=true,this._emit("pause");}resume(){this.paused&&(this.paused=false,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null));}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();if(!t)return e}setEncoding(t){this.encoding=t;}async text(){let t=[];for(;;){let{done:o,value:i}=await this.reader.read();if(o)break;i&&t.push(i);}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(t).arrayBuffer())}async json(){let t=await this.text();return JSON.parse(t)}_write(t){this._emit("data",t);}_end(){this._emit("end");}_error(t){this._emit("error",t);}_emit(t,e){if(this.events[t])for(let o of this.events[t]||[])o(e);}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();if(t){this._emit("end"),this._emit("close");break}e&&this._emit("data",e);}}catch(t){this._emit("error",t);}}[Symbol.asyncIterator](){return {next:async()=>{this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();return t?{done:true,value:void 0}:{done:false,value:e}},[Symbol.asyncIterator](){return this}}}};});var cd={};P(cd,{UndiciStreamWrapper:()=>sn});var sn,ld=Wa(()=>{sn=class n{constructor(t){this.readableStream=t,this.reader=this.readableStream.getReader(),this.events={data:[],end:[],error:[],readable:[],close:[],pause:[],resume:[]},this.paused=false,this.resumeCallback=null,this.encoding=null;}on(t,e){var o;(o=this.events[t])==null||o.push(e);}off(t,e){var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(i=>i!==e);}pipe(t){return this.on("data",e=>{if(t instanceof n)t._write(e);else {let o=t.getWriter();o.write(e).then(()=>o.releaseLock());}}),this.on("end",()=>{t instanceof n?t._end():t.getWriter().close();}),this.on("error",e=>{t instanceof n?t._error(e):t.getWriter().abort(e);}),this._startReading(),t}pipeTo(t){return this.pipe(t)}unpipe(t){this.off("data",e=>{if(t instanceof n)t._write(e);else {let o=t.getWriter();o.write(e).then(()=>o.releaseLock());}}),this.off("end",()=>{t instanceof n?t._end():t.getWriter().close();}),this.off("error",e=>{t instanceof n?t._error(e):t.getWriter().abort(e);});}destroy(t){this.reader.cancel(t).then(()=>{this._emit("close");}).catch(e=>{this._emit("error",e);});}pause(){this.paused=true,this._emit("pause");}resume(){this.paused&&(this.paused=false,this._emit("resume"),this.resumeCallback&&(this.resumeCallback(),this.resumeCallback=null));}get isPaused(){return this.paused}async read(){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();if(!t)return e}setEncoding(t){this.encoding=t;}async text(){let t=[];for(;;){let{done:o,value:i}=await this.reader.read();if(o)break;i&&t.push(i);}return new TextDecoder(this.encoding||"utf-8").decode(await new Blob(t).arrayBuffer())}async json(){let t=await this.text();return JSON.parse(t)}_write(t){this._emit("data",t);}_end(){this._emit("end");}_error(t){this._emit("error",t);}_emit(t,e){if(this.events[t])for(let o of this.events[t]||[])o(e);}async _startReading(){try{for(this._emit("readable");;){this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();if(t){this._emit("end"),this._emit("close");break}e&&this._emit("data",e);}}catch(t){this._emit("error",t);}}[Symbol.asyncIterator](){return {next:async()=>{this.paused&&await new Promise(o=>{this.resumeCallback=o;});let{done:t,value:e}=await this.reader.read();return t?{done:true,value:void 0}:{done:false,value:e}},[Symbol.asyncIterator](){return this}}}};});var md={};P(md,{NodePre18StreamWrapper:()=>pn});var pn,dd=Wa(()=>{pn=class{constructor(t){this.readableStream=t;}on(t,e){this.readableStream.on(t,e);}off(t,e){this.readableStream.off(t,e);}pipe(t){return this.readableStream.pipe(t),t}pipeTo(t){return this.pipe(t)}unpipe(t){t?this.readableStream.unpipe(t):this.readableStream.unpipe();}destroy(t){this.readableStream.destroy(t);}pause(){this.readableStream.pause();}resume(){this.readableStream.resume();}get isPaused(){return this.readableStream.isPaused()}async read(){return new Promise((t,e)=>{let o=this.readableStream.read();o?t(o):(this.readableStream.once("readable",()=>{let i=this.readableStream.read();t(i);}),this.readableStream.once("error",e));})}setEncoding(t){this.readableStream.setEncoding(t),this.encoding=t;}async text(){let t=[],e=new TextEncoder;this.readableStream.setEncoding(this.encoding||"utf-8");for await(let i of this.readableStream)t.push(e.encode(i));return new TextDecoder(this.encoding||"utf-8").decode(Buffer.concat(t))}async json(){let t=await this.text();return JSON.parse(t)}[Symbol.asyncIterator](){let e=this.readableStream[Symbol.asyncIterator]();return {async next(){let{value:o,done:i}=await e.next();return {value:o,done:i}},[Symbol.asyncIterator](){return this}}}};});var Xu={SILLY:0,TRACE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,FATAL:6};function Rt(n,t=n){return ansiEscapes.link(t,n)}var z=new tslog.Logger({hideLogPositionForProduction:true,prettyLogTemplate:"{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}} {{logLevelName}} "}),Pm=n=>{z.settings.minLevel=Xu[n];},Gu=()=>{z.settings.minLevel=100;};Pm(process.env.OPIK_LOG_LEVEL||"INFO");var Qu="~/.opik.config",Va={apiKey:"",apiUrl:"https://www.comet.com/opik/api",projectName:"Default Project",workspaceName:"default",batchDelayMs:300,holdUntilFlush:false};function Cm(n){return Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0))}function Yu(){return Cm({apiKey:process.env.OPIK_API_KEY,apiUrl:process.env.OPIK_URL_OVERRIDE,projectName:process.env.OPIK_PROJECT_NAME,workspaceName:process.env.OPIK_WORKSPACE,batchDelayMs:process.env.OPIK_BATCH_DELAY_MS?Number(process.env.OPIK_BATCH_DELAY_MS):void 0,holdUntilFlush:process.env.OPIK_HOLD_UNTIL_FLUSH===void 0?void 0:["1","true","yes"].includes(String(process.env.OPIK_HOLD_UNTIL_FLUSH).toLowerCase())})}function Zu(){let n=process.env.OPIK_CONFIG_PATH||Qu;if(!vm__default.default.existsSync(n)){if(process.env.OPIK_CONFIG_PATH)throw new Error(`Config file not found at ${n}`);return {}}try{let t=$u__default.default.parse(vm__default.default.readFileSync(n,"utf8"));return t.opik?Cm({apiKey:t.opik.api_key,apiUrl:t.opik.url_override,projectName:t.opik.project_name,workspaceName:t.opik.workspace}):{}}catch(t){return z.error(`Error loading config file ${n}: ${t}`),{}}}function Im(n){let t=Yu(),e=Zu(),{headers:o,...i}=n||{};return qu({...Va,...e,...t,...i})}function qu(n){if(!n.apiUrl)throw new Error("OPIK_URL_OVERRIDE is not set");let t=eg(n.apiUrl);if(t&&!n.apiKey)throw new Error("OPIK_API_KEY is not set");if(t&&!n.workspaceName)throw new Error("OPIK_WORKSPACE is not set");return n}function eg(n){return new URL(n).hostname.endsWith("comet.com")}var X={};P(X,{AlertAlertType:()=>rg,AlertPublicAlertType:()=>cg,AlertTriggerConfigPublicType:()=>sg,AlertTriggerConfigType:()=>tg,AlertTriggerConfigWriteType:()=>ig,AlertTriggerEventType:()=>og,AlertTriggerPublicEventType:()=>pg,AlertTriggerWriteEventType:()=>ag,AlertWriteAlertType:()=>ng,AnnotationQueuePublicScope:()=>ug,AnnotationQueueScope:()=>mg,AnnotationQueueWriteScope:()=>dg,AssistantMessageRole:()=>Tg,AttachmentListRequestEntityType:()=>Um,BadRequestError:()=>T,CheckName:()=>Hg,CheckPublicName:()=>xw,CheckPublicResult:()=>_w,CheckResult:()=>Jg,ColumnCompareTypesItem:()=>jg,ColumnPublicTypesItem:()=>Bg,ColumnTypesItem:()=>Lg,CompleteMultipartUploadRequestEntityType:()=>gg,ConflictError:()=>L,DatasetItemCompareSource:()=>Ug,DatasetItemPublicSource:()=>Og,DatasetItemSource:()=>Pg,DatasetItemWriteSource:()=>tn,DatasetPublicVisibility:()=>Fg,DatasetUpdateVisibility:()=>Om,DatasetVisibility:()=>Eg,DatasetWriteVisibility:()=>Fm,DeleteAttachmentsRequestEntityType:()=>wg,DownloadAttachmentRequestEntityType:()=>Nm,ExperimentItemCompareTraceVisibilityMode:()=>Ng,ExperimentItemPublicTraceVisibilityMode:()=>Wg,ExperimentItemTraceVisibilityMode:()=>vg,ExperimentPublicStatus:()=>Yg,ExperimentPublicType:()=>Qg,ExperimentStatus:()=>Vg,ExperimentType:()=>an,ExperimentUpdateStatus:()=>Vm,ExperimentUpdateType:()=>Lm,ExperimentWriteStatus:()=>Bm,ExperimentWriteType:()=>Wm,FeedbackScoreBatchItemSource:()=>zw,FeedbackScoreBatchItemThreadSource:()=>Ew,FeedbackScoreCompareSource:()=>Mg,FeedbackScoreExperimentItemBulkWriteViewSource:()=>Xg,FeedbackScorePublicSource:()=>bw,FeedbackScoreSource:()=>Cg,FindFeedbackDefinitionsRequestType:()=>Hm,FindFeedbackScoreNames1RequestType:()=>ed,ForbiddenError:()=>$,GetSpanStatsRequestType:()=>rd,GetSpansByProjectRequestType:()=>Zm,GetWebhookExamplesRequestAlertType:()=>jm,GuardrailName:()=>Zg,GuardrailResult:()=>qg,GuardrailWriteName:()=>ew,GuardrailWriteResult:()=>rw,LlmAsJudgeMessagePublicRole:()=>zg,LlmAsJudgeMessageRole:()=>fg,LlmAsJudgeMessageWriteRole:()=>bg,LlmAsJudgeOutputSchemaPublicType:()=>Sg,LlmAsJudgeOutputSchemaType:()=>hg,LlmAsJudgeOutputSchemaWriteType:()=>yg,LogItemLevel:()=>_g,ManualEvaluationRequestEntityType:()=>iw,NotFoundError:()=>A,NotImplementedError:()=>sr,OptimizationPublicStatus:()=>sw,OptimizationStatus:()=>aw,OptimizationUpdateStatus:()=>Km,OptimizationWriteStatus:()=>nw,ProjectDetailedVisibility:()=>uw,ProjectMetricRequestPublicInterval:()=>Qm,ProjectMetricRequestPublicMetricType:()=>$m,ProjectMetricResponsePublicInterval:()=>mw,ProjectMetricResponsePublicMetricType:()=>lw,ProjectPublicVisibility:()=>cw,ProjectUpdateVisibility:()=>Gm,ProjectVisibility:()=>pw,ProjectWriteVisibility:()=>Xm,PromptType:()=>gw,PromptVersionDetailType:()=>fw,PromptVersionPublicType:()=>hw,PromptVersionType:()=>ww,PromptWriteType:()=>Ym,ProviderApiKeyProvider:()=>tw,ProviderApiKeyPublicProvider:()=>ow,ProviderApiKeyWriteProvider:()=>Jm,ResponseFormatType:()=>Ag,SpanExperimentItemBulkWriteViewType:()=>Gg,SpanFilterPublicOperator:()=>Sw,SpanPublicType:()=>yw,SpanSearchStreamRequestPublicType:()=>od,SpanType:()=>we,SpanUpdateType:()=>qm,SpanWriteType:()=>Rw,StartMultipartUploadRequestEntityType:()=>Mm,TraceFilterOperator:()=>Rg,TraceFilterPublicOperator:()=>xg,TraceFilterWriteOperator:()=>kg,TracePublicVisibilityMode:()=>Tw,TraceThreadFilterOperator:()=>Pw,TraceThreadFilterPublicOperator:()=>dw,TraceThreadStatus:()=>Aw,TraceVisibilityMode:()=>Kg,UnauthorizedError:()=>K,UnprocessableEntityError:()=>F,UploadAttachmentRequestEntityType:()=>Dm,ValueEntryCompareSource:()=>Dg,ValueEntryExperimentItemBulkWriteViewSource:()=>$g,ValueEntryPublicSource:()=>kw,ValueEntrySource:()=>Ig,WebhookTestResultStatus:()=>lg,alerts:()=>bt,annotationQueues:()=>Ja,attachments:()=>yt,automationRuleEvaluators:()=>Xa,chatCompletions:()=>Ga,check:()=>Ka,datasets:()=>kt,experiments:()=>zt,feedbackDefinitions:()=>St,guardrails:()=>$a,llmProviderKey:()=>xt,manualEvaluation:()=>Qa,openTelemetryIngestion:()=>Ya,optimizations:()=>_t,projects:()=>Tt,prompts:()=>At,redirect:()=>on,serviceToggles:()=>Za,spans:()=>Et,systemUsage:()=>Ha,traces:()=>qa,welcomeWizard:()=>en,workspaces:()=>rn});var bt={};P(bt,{GetWebhookExamplesRequestAlertType:()=>jm});var jm={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var yt={};P(yt,{AttachmentListRequestEntityType:()=>Um,DownloadAttachmentRequestEntityType:()=>Nm,StartMultipartUploadRequestEntityType:()=>Mm,UploadAttachmentRequestEntityType:()=>Dm});var Um={Trace:"trace",Span:"span"};var Nm={Trace:"trace",Span:"span"};var Mm={Trace:"trace",Span:"span"};var Dm={Trace:"trace",Span:"span"};var kt={};P(kt,{DatasetUpdateVisibility:()=>Om,DatasetWriteVisibility:()=>Fm});var Fm={Private:"private",Public:"public"};var Om={Private:"private",Public:"public"};var zt={};P(zt,{ExperimentUpdateStatus:()=>Vm,ExperimentUpdateType:()=>Lm,ExperimentWriteStatus:()=>Bm,ExperimentWriteType:()=>Wm});var Wm={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Bm={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Lm={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Vm={Running:"running",Completed:"completed",Cancelled:"cancelled"};var St={};P(St,{FindFeedbackDefinitionsRequestType:()=>Hm});var Hm={Numerical:"numerical",Categorical:"categorical",Boolean:"boolean"};var xt={};P(xt,{ProviderApiKeyWriteProvider:()=>Jm});var Jm={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var _t={};P(_t,{OptimizationUpdateStatus:()=>Km});var Km={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Tt={};P(Tt,{ProjectMetricRequestPublicInterval:()=>Qm,ProjectMetricRequestPublicMetricType:()=>$m,ProjectUpdateVisibility:()=>Gm,ProjectWriteVisibility:()=>Xm});var Xm={Private:"private",Public:"public"};var Gm={Private:"private",Public:"public"};var $m={FeedbackScores:"FEEDBACK_SCORES",TraceCount:"TRACE_COUNT",TokenUsage:"TOKEN_USAGE",Duration:"DURATION",Cost:"COST",GuardrailsFailedCount:"GUARDRAILS_FAILED_COUNT",ThreadCount:"THREAD_COUNT",ThreadDuration:"THREAD_DURATION",ThreadFeedbackScores:"THREAD_FEEDBACK_SCORES"};var Qm={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var At={};P(At,{PromptWriteType:()=>Ym});var Ym={Mustache:"mustache",Jinja2:"jinja2"};var Et={};P(Et,{FindFeedbackScoreNames1RequestType:()=>ed,GetSpanStatsRequestType:()=>rd,GetSpansByProjectRequestType:()=>Zm,SpanSearchStreamRequestPublicType:()=>od,SpanUpdateType:()=>qm});var Zm={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var qm={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var ed={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var rd={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var od={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Ha={};var Ja={};var Ka={};var Xa={};var Ga={};var $a={};var Qa={};var Ya={};var Za={};var qa={};var en={};var rn={};var on={};var rg={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var og={TraceErrors:"trace:errors",TraceFeedbackScore:"trace:feedback_score",TraceThreadFeedbackScore:"trace_thread:feedback_score",PromptCreated:"prompt:created",PromptCommitted:"prompt:committed",TraceGuardrailsTriggered:"trace:guardrails_triggered",PromptDeleted:"prompt:deleted",ExperimentFinished:"experiment:finished",TraceCost:"trace:cost",TraceLatency:"trace:latency"};var tg={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score",ThresholdCost:"threshold:cost",ThresholdLatency:"threshold:latency"};var ig={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score",ThresholdCost:"threshold:cost",ThresholdLatency:"threshold:latency"};var ag={TraceErrors:"trace:errors",TraceFeedbackScore:"trace:feedback_score",TraceThreadFeedbackScore:"trace_thread:feedback_score",PromptCreated:"prompt:created",PromptCommitted:"prompt:committed",TraceGuardrailsTriggered:"trace:guardrails_triggered",PromptDeleted:"prompt:deleted",ExperimentFinished:"experiment:finished",TraceCost:"trace:cost",TraceLatency:"trace:latency"};var ng={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var sg={ScopeProject:"scope:project",ThresholdFeedbackScore:"threshold:feedback_score",ThresholdCost:"threshold:cost",ThresholdLatency:"threshold:latency"};var pg={TraceErrors:"trace:errors",TraceFeedbackScore:"trace:feedback_score",TraceThreadFeedbackScore:"trace_thread:feedback_score",PromptCreated:"prompt:created",PromptCommitted:"prompt:committed",TraceGuardrailsTriggered:"trace:guardrails_triggered",PromptDeleted:"prompt:deleted",ExperimentFinished:"experiment:finished",TraceCost:"trace:cost",TraceLatency:"trace:latency"};var cg={General:"general",Slack:"slack",Pagerduty:"pagerduty"};var lg={Success:"success",Failure:"failure"};var mg={Trace:"trace",Thread:"thread"};var dg={Trace:"trace",Thread:"thread"};var ug={Trace:"trace",Thread:"thread"};var gg={Trace:"trace",Span:"span"};var wg={Trace:"trace",Span:"span"};var fg={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var hg={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var Rg={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var bg={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var yg={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var kg={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var zg={System:"SYSTEM",User:"USER",Ai:"AI",ToolExecutionResult:"TOOL_EXECUTION_RESULT",Custom:"CUSTOM"};var Sg={Boolean:"BOOLEAN",Integer:"INTEGER",Double:"DOUBLE"};var xg={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var _g={Info:"INFO",Warn:"WARN",Error:"ERROR",Debug:"DEBUG",Trace:"TRACE"};var Tg={System:"system",User:"user",Assistant:"assistant",Tool:"tool",Function:"function"};var Ag={Text:"text",JsonObject:"json_object",JsonSchema:"json_schema"};var Eg={Private:"private",Public:"public"};var Pg={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var vg={Default:"default",Hidden:"hidden"};var Cg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Ig={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var tn={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var jg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var Ug={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Ng={Default:"default",Hidden:"hidden"};var Mg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Dg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Fg={Private:"private",Public:"public"};var Og={Manual:"manual",Trace:"trace",Span:"span",Sdk:"sdk"};var Wg={Default:"default",Hidden:"hidden"};var Bg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var Lg={String:"string",Number:"number",Object:"object",Boolean:"boolean",Array:"array",Null:"null"};var an={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Vg={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Hg={Topic:"TOPIC",Pii:"PII"};var Jg={Passed:"passed",Failed:"failed"};var we={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var Kg={Default:"default",Hidden:"hidden"};var Xg={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Gg={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var $g={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Qg={Regular:"regular",Trial:"trial",MiniBatch:"mini-batch"};var Yg={Running:"running",Completed:"completed",Cancelled:"cancelled"};var Zg={Topic:"TOPIC",Pii:"PII"};var qg={Passed:"passed",Failed:"failed"};var ew={Topic:"TOPIC",Pii:"PII"};var rw={Passed:"passed",Failed:"failed"};var ow={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var tw={Openai:"openai",Anthropic:"anthropic",Gemini:"gemini",Openrouter:"openrouter",VertexAi:"vertex-ai",CustomLlm:"custom-llm"};var iw={Trace:"trace",Thread:"thread"};var aw={Running:"running",Completed:"completed",Cancelled:"cancelled"};var nw={Running:"running",Completed:"completed",Cancelled:"cancelled"};var sw={Running:"running",Completed:"completed",Cancelled:"cancelled"};var pw={Private:"private",Public:"public"};var cw={Private:"private",Public:"public"};var lw={FeedbackScores:"FEEDBACK_SCORES",TraceCount:"TRACE_COUNT",TokenUsage:"TOKEN_USAGE",Duration:"DURATION",Cost:"COST",GuardrailsFailedCount:"GUARDRAILS_FAILED_COUNT",ThreadCount:"THREAD_COUNT",ThreadDuration:"THREAD_DURATION",ThreadFeedbackScores:"THREAD_FEEDBACK_SCORES"};var mw={Hourly:"HOURLY",Daily:"DAILY",Weekly:"WEEKLY"};var dw={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var uw={Private:"private",Public:"public"};var gw={Mustache:"mustache",Jinja2:"jinja2"};var ww={Mustache:"mustache",Jinja2:"jinja2"};var fw={Mustache:"mustache",Jinja2:"jinja2"};var hw={Mustache:"mustache",Jinja2:"jinja2"};var Rw={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var bw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var yw={General:"general",Tool:"tool",Llm:"llm",Guardrail:"guardrail"};var kw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var zw={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Sw={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var xw={Topic:"TOPIC",Pii:"PII"};var _w={Passed:"passed",Failed:"failed"};var Tw={Default:"default",Hidden:"hidden"};var Aw={Active:"active",Inactive:"inactive"};var Ew={Ui:"ui",Sdk:"sdk",OnlineScoring:"online_scoring"};var Pw={Contains:"contains",NotContains:"not_contains",StartsWith:"starts_with",EndsWith:"ends_with",EqualTo:"=",NotEquals:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",IsEmpty:"is_empty",IsNotEmpty:"is_not_empty"};var Le=(n,t,e)=>JSON.stringify(n,t,e);var p=class n extends Error{constructor({message:t,statusCode:e,body:o,rawResponse:i}){super(vw({message:t,statusCode:e,body:o})),Object.setPrototypeOf(this,n.prototype),this.statusCode=e,this.body=o,this.rawResponse=i;}};function vw({message:n,statusCode:t,body:e}){let o=[];return n!=null&&o.push(n),t!=null&&o.push(`Status code: ${t.toString()}`),e!=null&&o.push(`Body: ${Le(e,void 0,2)}`),o.join(`
|
|
2
|
+
`)}var w=class n extends Error{constructor(t){super(t),Object.setPrototypeOf(this,n.prototype);}};var T=class n extends p{constructor(t,e){super({message:"BadRequestError",statusCode:400,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var L=class n extends p{constructor(t,e){super({message:"ConflictError",statusCode:409,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var F=class n extends p{constructor(t,e){super({message:"UnprocessableEntityError",statusCode:422,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var A=class n extends p{constructor(t,e){super({message:"NotFoundError",statusCode:404,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var K=class n extends p{constructor(t,e){super({message:"UnauthorizedError",statusCode:401,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var $=class n extends p{constructor(t,e){super({message:"ForbiddenError",statusCode:403,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var sr=class n extends p{constructor(t,e){super({message:"NotImplementedError",statusCode:501,body:t,rawResponse:e}),Object.setPrototypeOf(this,n.prototype);}};var h={Default:"http://localhost:5173/api"};var pr;typeof globalThis.Headers!="undefined"?pr=globalThis.Headers:pr=class td{constructor(t){if(this.headers=new Map,t)if(t instanceof td)t.forEach((e,o)=>this.append(o,e));else if(Array.isArray(t))for(let[e,o]of t)if(typeof e=="string"&&typeof o=="string")this.append(e,o);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[e,o]of Object.entries(t))if(typeof o=="string")this.append(e,o);else throw new TypeError("Header values must be strings")}append(t,e){let o=t.toLowerCase(),i=this.headers.get(o)||[];this.headers.set(o,[...i,e]);}delete(t){let e=t.toLowerCase();this.headers.delete(e);}get(t){let e=t.toLowerCase(),o=this.headers.get(e);return o?o.join(", "):null}has(t){let e=t.toLowerCase();return this.headers.has(e)}set(t,e){let o=t.toLowerCase();this.headers.set(o,[e]);}forEach(t,e){let o=e?t.bind(e):t;this.headers.forEach((i,a)=>o(i.join(", "),a,this));}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[t,e]of this.headers.entries())yield [t,e.join(", ")];}*keys(){yield*this.headers.keys();}*values(){for(let t of this.headers.values())yield t.join(", ");}[Symbol.iterator](){return this.entries()}};var Pt={headers:new pr,redirected:false,status:499,statusText:"Client Closed Request",type:"error",url:""},vt={headers:new pr,redirected:false,status:0,statusText:"Unknown Error",type:"error",url:""};function Ct(n){return {headers:n.headers,redirected:n.redirected,status:n.status,statusText:n.statusText,type:n.type,url:n.url}}function id(n,t){return Object.keys(t!=null?t:{}).length>0?`${n}?${Cw__default.default.stringify(t,{arrayFormat:"repeat"})}`:n}var m=Iw();function Iw(){var u,g,y,k,S;return typeof window!="undefined"&&typeof window.document!="undefined"?{type:"browser",version:window.navigator.userAgent}:typeof globalThis!="undefined"&&((u=globalThis==null?void 0:globalThis.navigator)==null?void 0:u.userAgent)==="Cloudflare-Workers"?{type:"workerd"}:typeof EdgeRuntime=="string"?{type:"edge-runtime"}:typeof self=="object"&&typeof(self==null?void 0:self.importScripts)=="function"&&(((g=self.constructor)==null?void 0:g.name)==="DedicatedWorkerGlobalScope"||((y=self.constructor)==null?void 0:y.name)==="ServiceWorkerGlobalScope"||((k=self.constructor)==null?void 0:k.name)==="SharedWorkerGlobalScope")?{type:"web-worker"}:typeof Deno!="undefined"&&typeof Deno.version!="undefined"&&typeof Deno.version.deno!="undefined"?{type:"deno",version:Deno.version.deno}:typeof Bun!="undefined"&&typeof Bun.version!="undefined"?{type:"bun",version:Bun.version}:typeof process!="undefined"&&"version"in process&&!!process.version&&"versions"in process&&!!((S=process.versions)!=null&&S.node)?{type:"node",version:process.versions.node,parsedVersion:Number(process.versions.node.split(".")[0])}:typeof navigator!="undefined"&&(navigator==null?void 0:navigator.product)==="ReactNative"?{type:"react-native"}:{type:"unknown"}}async function ad(){return m.type==="node"&&m.parsedVersion!=null&&m.parsedVersion>=18?fetch:m.type==="node"?(await import('node-fetch')).default:typeof fetch=="function"?fetch:(await import('node-fetch')).default}async function nd({body:n,type:t}){return t.includes("json")?Le(n):n}async function ud(n){return m.type==="node"&&m.parsedVersion!=null&&m.parsedVersion>=18?new(await Promise.resolve().then(()=>(pd(),sd))).Node18UniversalStreamWrapper(n):m.type!=="node"&&typeof fetch=="function"?new(await Promise.resolve().then(()=>(ld(),cd))).UndiciStreamWrapper(n):new(await Promise.resolve().then(()=>(dd(),md))).NodePre18StreamWrapper(n)}async function gd(n,t){if(n.body!=null&&t==="blob")return await n.blob();if(n.body!=null&&t==="arrayBuffer")return await n.arrayBuffer();if(n.body!=null&&t==="sse")return n.body;if(n.body!=null&&t==="streaming")return ud(n.body);if(n.body!=null&&t==="text")return await n.text();{let e=await n.text();if(e.length>0)try{return JSON.parse(e)}catch{return {ok:false,error:{reason:"non-json",statusCode:n.status,rawBody:e}}}else return}}var jw="timeout";function wd(n){let t=new AbortController,e=setTimeout(()=>t.abort(jw),n);return {signal:t.signal,abortId:e}}function fd(...n){let t=n.length===1&&Array.isArray(n[0])?n[0]:n,e=new AbortController;for(let o of t){if(o.aborted){e.abort(o==null?void 0:o.reason);break}o.addEventListener("abort",()=>e.abort(o==null?void 0:o.reason),{signal:e.signal});}return e.signal}var hd=async(n,t,e,o,i,a,c,d,u)=>{let g=[],y;if(a!=null){let{signal:x,abortId:_}=wd(a);y=_,g.push(x);}c!=null&&g.push(c);let k=fd(g),S=await n(t,{method:e,headers:o,body:i,signal:k,credentials:d?"include":void 0,duplex:u});return y!=null&&clearTimeout(y),S};function Uw(n){let t=1+(Math.random()*2-1)*.2;return n*t}async function Rd(n,t=2){let e=await n();for(let o=0;o<t&&([408,429].includes(e.status)||e.status>=500);++o){let i=Math.min(1e3*Math.pow(2,o),6e4),a=Uw(i);await new Promise(c=>setTimeout(c,a)),e=await n();}return e}async function Nw(n){let t={};if(n.body!==void 0&&n.contentType!=null&&(t["Content-Type"]=n.contentType),n.headers!=null)for(let[a,c]of Object.entries(n.headers))c!=null&&(t[a]=c);let e=id(n.url,n.queryParameters),o=await nd({body:n.body,type:n.requestType==="json"?"json":"other"}),i=await ad();try{let a=await Rd(async()=>hd(i,e,n.method,t,o,n.timeoutMs,n.abortSignal,n.withCredentials,n.duplex),n.maxRetries),c=await gd(a,n.responseType);return a.status>=200&&a.status<400?{ok:!0,body:c,headers:a.headers,rawResponse:Ct(a)}:{ok:!1,error:{reason:"status-code",statusCode:a.status,body:c},rawResponse:Ct(a)}}catch(a){return n.abortSignal!=null&&n.abortSignal.aborted?{ok:false,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:Pt}:a instanceof Error&&a.name==="AbortError"?{ok:false,error:{reason:"timeout"},rawResponse:Pt}:a instanceof Error?{ok:false,error:{reason:"unknown",errorMessage:a.message},rawResponse:vt}:{ok:false,error:{reason:"unknown",errorMessage:Le(a)},rawResponse:vt}}}var R=Nw;var s={get:async n=>typeof n=="function"?n():n};var f=class n extends Promise{constructor(t){super(e=>{e(void 0);}),this.innerPromise=t;}static fromFunction(t,...e){return new n(t(...e))}static interceptFunction(t){return (...e)=>n.fromPromise(t(...e))}static fromPromise(t){return new n(t)}static fromExecutor(t){let e=new Promise(t);return new n(e)}static fromResult(t){let e=Promise.resolve(t);return new n(e)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:t})=>t)),this.unwrappedPromise}then(t,e){return this.unwrap().then(t,e)}catch(t){return this.unwrap().catch(t)}finally(t){return this.unwrap().finally(t)}async withRawResponse(){return await this.innerPromise}};var r={};P(r,{JsonError:()=>Ve,ParseError:()=>He,any:()=>jd,bigint:()=>yd,boolean:()=>Ud,booleanLiteral:()=>Id,date:()=>kd,discriminant:()=>Vd,enum_:()=>jt,getObjectLikeUtils:()=>le,getObjectUtils:()=>Ie,getSchemaUtils:()=>C,isProperty:()=>xe,lazy:()=>zd,lazyObject:()=>Pd,list:()=>Nt,number:()=>Nd,object:()=>Ut,objectWithoutOptionalProperties:()=>Ed,optional:()=>cn,property:()=>xd,record:()=>Od,set:()=>Wd,string:()=>Md,stringLiteral:()=>Cd,transform:()=>ln,undiscriminatedUnion:()=>Ld,union:()=>Jd,unknown:()=>Dd,withParsedProperties:()=>dn});var E={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function v(n,t){return `Expected ${t}. Received ${Mw(n)}.`}function Mw(n){if(Array.isArray(n))return "list";if(n===null)return "null";if(n instanceof BigInt)return "BigInt";switch(typeof n){case "string":return `"${n}"`;case "bigint":case "number":case "boolean":case "undefined":return `${n}`}return typeof n}function G(n){return {...n,json:bd(n.json),parse:bd(n.parse)}}function bd(n){return (t,e)=>{let o=n(t,e),{skipValidation:i=false}=e!=null?e:{};return !o.ok&&i?(console.warn(["Failed to validate.",...o.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
3
|
+
`)),{ok:true,value:t}):o}}function It(n){return n.path.length===0?n.message:`${n.path.join(" -> ")}: ${n.message}`}var Ve=class n extends Error{constructor(e){super(e.map(It).join("; "));this.errors=e;Object.setPrototypeOf(this,n.prototype);}};var He=class n extends Error{constructor(e){super(e.map(It).join("; "));this.errors=e;Object.setPrototypeOf(this,n.prototype);}};function C(n){return {nullable:()=>Dw(n),optional:()=>cn(n),optionalNullable:()=>Fw(n),transform:t=>ln(n,t),parseOrThrow:(t,e)=>{let o=n.parse(t,e);if(o.ok)return o.value;throw new He(o.errors)},jsonOrThrow:(t,e)=>{let o=n.json(t,e);if(o.ok)return o.value;throw new Ve(o.errors)}}}function Dw(n){let t={parse:(e,o)=>e==null?{ok:true,value:null}:n.parse(e,o),json:(e,o)=>e==null?{ok:true,value:null}:n.json(e,o),getType:()=>E.NULLABLE};return {...t,...C(t)}}function cn(n){let t={parse:(e,o)=>e==null?{ok:true,value:void 0}:n.parse(e,o),json:(e,o)=>o!=null&&o.omitUndefined&&e===void 0?{ok:true,value:void 0}:e==null?{ok:true,value:null}:n.json(e,o),getType:()=>E.OPTIONAL};return {...t,...C(t)}}function Fw(n){let t={parse:(e,o)=>e===void 0?{ok:true,value:void 0}:e===null?{ok:true,value:null}:n.parse(e,o),json:(e,o)=>e===void 0?{ok:true,value:void 0}:e===null?{ok:true,value:null}:n.json(e,o),getType:()=>E.OPTIONAL_NULLABLE};return {...t,...C(t)}}function ln(n,t){let e={parse:(o,i)=>{let a=n.parse(o,i);return a.ok?{ok:true,value:t.transform(a.value)}:a},json:(o,i)=>{let a=t.untransform(o);return n.json(a,i)},getType:()=>n.getType()};return {...e,...C(e)}}function yd(){let n={parse:(t,{breadcrumbsPrefix:e=[]}={})=>typeof t=="bigint"?{ok:true,value:t}:typeof t=="number"?{ok:true,value:BigInt(t)}:{ok:false,errors:[{path:e,message:v(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:e=[]}={})=>typeof t!="bigint"?{ok:false,errors:[{path:e,message:v(t,"bigint")}]}:{ok:true,value:t},getType:()=>E.BIGINT};return {...G(n),...C(n)}}var Ow=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function kd(){let n={parse:(t,{breadcrumbsPrefix:e=[]}={})=>typeof t!="string"?{ok:false,errors:[{path:e,message:v(t,"string")}]}:Ow.test(t)?{ok:true,value:new Date(t)}:{ok:false,errors:[{path:e,message:v(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:e=[]}={})=>t instanceof Date?{ok:true,value:t.toISOString()}:{ok:false,errors:[{path:e,message:v(t,"Date object")}]},getType:()=>E.DATE};return {...G(n),...C(n)}}function Q(n,t){return ()=>{let e={parse:t,json:t,getType:()=>n};return {...G(e),...C(e)}}}function jt(n){let t=new Set(n);return Q(E.ENUM,(o,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof o!="string"?{ok:false,errors:[{path:a,message:v(o,"string")}]}:!t.has(o)&&!i?{ok:false,errors:[{path:a,message:v(o,"enum")}]}:{ok:true,value:o})()}function zd(n){let t=mn(n);return {...t,...C(t)}}function mn(n){return {parse:(t,e)=>Je(n).parse(t,e),json:(t,e)=>Je(n).json(t,e),getType:()=>Je(n).getType()}}function Je(n){let t=n;return t.__zurg_memoized==null&&(t.__zurg_memoized=n()),t.__zurg_memoized}function cr(n){return Object.entries(n)}function lr(n,t){let e=new Set(t);return Object.entries(n).reduce((o,[i,a])=>(e.has(i)&&(o[i]=a),o),{})}function Se(n){if(typeof n!="object"||n===null)return false;if(Object.getPrototypeOf(n)===null)return true;let t=n;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(n)===t}function mr(n){return Object.keys(n)}function Sd(n,t){let e=[],o=[];for(let i of n)t(i)?e.push(i):o.push(i);return [e,o]}function le(n){return {withParsedProperties:t=>dn(n,t)}}function dn(n,t){let e={parse:(o,i)=>{let a=n.parse(o,i);if(!a.ok)return a;let c=Object.entries(t).reduce((d,[u,g])=>({...d,[u]:typeof g=="function"?g(a.value):g}),{});return {ok:true,value:{...a.value,...c}}},json:(o,i)=>{var d;if(!Se(o))return {ok:false,errors:[{path:(d=i==null?void 0:i.breadcrumbsPrefix)!=null?d:[],message:v(o,"object")}]};let a=new Set(Object.keys(t)),c=lr(o,Object.keys(o).filter(u=>!a.has(u)));return n.json(c,i)},getType:()=>n.getType()};return {...e,...C(e),...le(e)}}function xd(n,t){return {rawKey:n,valueSchema:t,isProperty:true}}function xe(n){return n.isProperty}function Ut(n){let t={_getRawProperties:()=>Object.entries(n).map(([e,o])=>xe(o)?o.rawKey:e),_getParsedProperties:()=>mr(n),parse:(e,o)=>{let i={},a=[];for(let[c,d]of cr(n)){let u=xe(d)?d.rawKey:c,g=xe(d)?d.valueSchema:d,y={rawKey:u,parsedKey:c,valueSchema:g};i[u]=y,Ad(g)&&a.push(u);}return _d({value:e,requiredKeys:a,getProperty:c=>{let d=i[c];if(d!=null)return {transformedKey:d.parsedKey,transform:u=>{var g;return d.valueSchema.parse(u,{...o,breadcrumbsPrefix:[...(g=o==null?void 0:o.breadcrumbsPrefix)!=null?g:[],c]})}}},unrecognizedObjectKeys:o==null?void 0:o.unrecognizedObjectKeys,skipValidation:o==null?void 0:o.skipValidation,breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix,omitUndefined:o==null?void 0:o.omitUndefined})},json:(e,o)=>{let i=[];for(let[a,c]of cr(n)){let d=xe(c)?c.valueSchema:c;Ad(d)&&i.push(a);}return _d({value:e,requiredKeys:i,getProperty:a=>{let c=n[a];if(c!=null)return xe(c)?{transformedKey:c.rawKey,transform:d=>{var u;return c.valueSchema.json(d,{...o,breadcrumbsPrefix:[...(u=o==null?void 0:o.breadcrumbsPrefix)!=null?u:[],a]})}}:{transformedKey:a,transform:d=>{var u;return c.json(d,{...o,breadcrumbsPrefix:[...(u=o==null?void 0:o.breadcrumbsPrefix)!=null?u:[],a]})}}},unrecognizedObjectKeys:o==null?void 0:o.unrecognizedObjectKeys,skipValidation:o==null?void 0:o.skipValidation,breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix,omitUndefined:o==null?void 0:o.omitUndefined})},getType:()=>E.OBJECT};return {...G(t),...C(t),...le(t),...Ie(t)}}function _d({value:n,requiredKeys:t,getProperty:e,unrecognizedObjectKeys:o="fail",skipValidation:i=false,breadcrumbsPrefix:a=[]}){if(!Se(n))return {ok:false,errors:[{path:a,message:v(n,"object")}]};let c=new Set(t),d=[],u={};for(let[g,y]of Object.entries(n)){let k=e(g);if(k!=null){c.delete(g);let S=k.transform(y);S.ok?u[k.transformedKey]=S.value:(u[g]=y,d.push(...S.errors));}else switch(o){case "fail":d.push({path:[...a,g],message:`Unexpected key "${g}"`});break;case "strip":break;case "passthrough":u[g]=y;break}}return d.push(...t.filter(g=>c.has(g)).map(g=>({path:a,message:`Missing required key "${g}"`}))),d.length===0||i?{ok:true,value:u}:{ok:false,errors:d}}function Ie(n){return {extend:t=>{let e={_getParsedProperties:()=>[...n._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...n._getRawProperties(),...t._getRawProperties()],parse:(o,i)=>Td({extensionKeys:t._getRawProperties(),value:o,transformBase:a=>n.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(o,i)=>Td({extensionKeys:t._getParsedProperties(),value:o,transformBase:a=>n.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>E.OBJECT};return {...e,...C(e),...le(e),...Ie(e)}},passthrough:()=>{let t={_getParsedProperties:()=>n._getParsedProperties(),_getRawProperties:()=>n._getRawProperties(),parse:(e,o)=>{let i=n.parse(e,{...o,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:true,value:{...e,...i.value}}:i},json:(e,o)=>{let i=n.json(e,{...o,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:true,value:{...e,...i.value}}:i},getType:()=>E.OBJECT};return {...t,...C(t),...le(t),...Ie(t)}}}}function Td({extensionKeys:n,value:t,transformBase:e,transformExtension:o}){let i=new Set(n),[a,c]=Sd(mr(t),g=>i.has(g)),d=e(lr(t,c)),u=o(lr(t,a));return d.ok&&u.ok?{ok:true,value:{...d.value,...u.value}}:{ok:false,errors:[...d.ok?[]:d.errors,...u.ok?[]:u.errors]}}function Ad(n){return !Ww(n)}function Ww(n){switch(n.getType()){case E.ANY:case E.UNKNOWN:case E.OPTIONAL:case E.OPTIONAL_NULLABLE:return true;default:return false}}function Ed(n){return Ut(n)}function Pd(n){let t={...mn(n),_getRawProperties:()=>Je(n)._getRawProperties(),_getParsedProperties:()=>Je(n)._getParsedProperties()};return {...t,...C(t),...le(t),...Ie(t)}}function Nt(n){let t={parse:(e,o)=>vd(e,(i,a)=>{var c;return n.parse(i,{...o,breadcrumbsPrefix:[...(c=o==null?void 0:o.breadcrumbsPrefix)!=null?c:[],`[${a}]`]})}),json:(e,o)=>vd(e,(i,a)=>{var c;return n.json(i,{...o,breadcrumbsPrefix:[...(c=o==null?void 0:o.breadcrumbsPrefix)!=null?c:[],`[${a}]`]})}),getType:()=>E.LIST};return {...G(t),...C(t)}}function vd(n,t){return Array.isArray(n)?n.map((o,i)=>t(o,i)).reduce((o,i)=>{if(o.ok&&i.ok)return {ok:true,value:[...o.value,i.value]};let a=[];return o.ok||a.push(...o.errors),i.ok||a.push(...i.errors),{ok:false,errors:a}},{ok:true,value:[]}):{ok:false,errors:[{message:v(n,"list"),path:[]}]}}function Cd(n){return Q(E.STRING_LITERAL,(e,{breadcrumbsPrefix:o=[]}={})=>e===n?{ok:true,value:n}:{ok:false,errors:[{path:o,message:v(e,`"${n}"`)}]})()}function Id(n){return Q(E.BOOLEAN_LITERAL,(e,{breadcrumbsPrefix:o=[]}={})=>e===n?{ok:true,value:n}:{ok:false,errors:[{path:o,message:v(e,`${n.toString()}`)}]})()}var jd=Q(E.ANY,n=>({ok:true,value:n}));var Ud=Q(E.BOOLEAN,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="boolean"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:v(n,"boolean")}]});var Nd=Q(E.NUMBER,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="number"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:v(n,"number")}]});var Md=Q(E.STRING,(n,{breadcrumbsPrefix:t=[]}={})=>typeof n=="string"?{ok:true,value:n}:{ok:false,errors:[{path:t,message:v(n,"string")}]});var Dd=Q(E.UNKNOWN,n=>({ok:true,value:n}));function Od(n,t){let e={parse:(o,i)=>Fd({value:o,isKeyNumeric:n.getType()===E.NUMBER,transformKey:a=>{var c;return n.parse(a,{...i,breadcrumbsPrefix:[...(c=i==null?void 0:i.breadcrumbsPrefix)!=null?c:[],`${a} (key)`]})},transformValue:(a,c)=>{var d;return t.parse(a,{...i,breadcrumbsPrefix:[...(d=i==null?void 0:i.breadcrumbsPrefix)!=null?d:[],`${c}`]})},breadcrumbsPrefix:i==null?void 0:i.breadcrumbsPrefix}),json:(o,i)=>Fd({value:o,isKeyNumeric:n.getType()===E.NUMBER,transformKey:a=>{var c;return n.json(a,{...i,breadcrumbsPrefix:[...(c=i==null?void 0:i.breadcrumbsPrefix)!=null?c:[],`${a} (key)`]})},transformValue:(a,c)=>{var d;return t.json(a,{...i,breadcrumbsPrefix:[...(d=i==null?void 0:i.breadcrumbsPrefix)!=null?d:[],`${c}`]})},breadcrumbsPrefix:i==null?void 0:i.breadcrumbsPrefix}),getType:()=>E.RECORD};return {...G(e),...C(e)}}function Fd({value:n,isKeyNumeric:t,transformKey:e,transformValue:o,breadcrumbsPrefix:i=[]}){return Se(n)?cr(n).reduce((a,[c,d])=>{if(d===void 0)return a;let u=a,g=c;if(t){let x=c.length>0?Number(c):NaN;isNaN(x)||(g=x);}let y=e(g),k=o(d,g);if(u.ok&&y.ok&&k.ok)return {ok:true,value:{...u.value,[y.value]:k.value}};let S=[];return u.ok||S.push(...u.errors),y.ok||S.push(...y.errors),k.ok||S.push(...k.errors),{ok:false,errors:S}},{ok:true,value:{}}):{ok:false,errors:[{path:i,message:v(n,"object")}]}}function Wd(n){let t=Nt(n),e={parse:(o,i)=>{let a=t.parse(o,i);return a.ok?{ok:true,value:new Set(a.value)}:a},json:(o,i)=>{var c;return o instanceof Set?t.json([...o],i):{ok:false,errors:[{path:(c=i==null?void 0:i.breadcrumbsPrefix)!=null?c:[],message:v(o,"Set")}]}},getType:()=>E.SET};return {...G(e),...C(e)}}function Ld(n){let t={parse:(e,o)=>Bd((i,a)=>i.parse(e,a),n,o),json:(e,o)=>Bd((i,a)=>i.json(e,a),n,o),getType:()=>E.UNDISCRIMINATED_UNION};return {...G(t),...C(t)}}function Bd(n,t,e){let o=[];for(let[i,a]of t.entries()){let c=n(a,{...e,skipValidation:false});if(c.ok)return c;for(let d of c.errors)o.push({path:d.path,message:`[Variant ${i}] ${d.message}`});}return {ok:false,errors:o}}function Vd(n,t){return {parsedDiscriminant:n,rawDiscriminant:t}}function Jd(n,t){let e=typeof n=="string"?n:n.rawDiscriminant,o=typeof n=="string"?n:n.parsedDiscriminant,i=jt(mr(t)),a={parse:(c,d)=>Hd({value:c,discriminant:e,transformedDiscriminant:o,transformDiscriminantValue:u=>{var g;return i.parse(u,{allowUnrecognizedEnumValues:d==null?void 0:d.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(g=d==null?void 0:d.breadcrumbsPrefix)!=null?g:[],e]})},getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:d==null?void 0:d.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,g)=>g.parse(u,d),breadcrumbsPrefix:d==null?void 0:d.breadcrumbsPrefix}),json:(c,d)=>Hd({value:c,discriminant:o,transformedDiscriminant:e,transformDiscriminantValue:u=>{var g;return i.json(u,{allowUnrecognizedEnumValues:d==null?void 0:d.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(g=d==null?void 0:d.breadcrumbsPrefix)!=null?g:[],o]})},getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:d==null?void 0:d.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,g)=>g.json(u,d),breadcrumbsPrefix:d==null?void 0:d.breadcrumbsPrefix}),getType:()=>E.UNION};return {...G(a),...C(a),...le(a)}}function Hd({value:n,discriminant:t,transformedDiscriminant:e,transformDiscriminantValue:o,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=false,transformAdditionalProperties:c,breadcrumbsPrefix:d=[]}){if(!Se(n))return {ok:false,errors:[{path:d,message:v(n,"object")}]};let{[t]:u,...g}=n;if(u==null)return {ok:false,errors:[{path:d,message:`Missing discriminant ("${t}")`}]};let y=o(u);if(!y.ok)return {ok:false,errors:y.errors};let k=i(y.value);if(k==null)return a?{ok:true,value:{[e]:y.value,...g}}:{ok:false,errors:[{path:[...d,t],message:"Unexpected discriminant value"}]};let S=c(g,k);return S.ok?{ok:true,value:{[e]:u,...S.value}}:S}function Bw(n){var t=[];if(n.length===0)return "";if(typeof n[0]!="string")throw new TypeError("Url must be a string. Received "+n[0]);if(n[0].match(/^[^/:]+:\/*$/)&&n.length>1){var e=n.shift();n[0]=e+n[0];}n[0].match(/^file:\/\/\//)?n[0]=n[0].replace(/^([^/:]+):\/*/,"$1:///"):n[0]=n[0].replace(/^([^/:]+):\/*/,"$1://");for(var o=0;o<n.length;o++){var i=n[o];if(typeof i!="string")throw new TypeError("Url must be a string. Received "+i);i!==""&&(o>0&&(i=i.replace(/^[\/]+/,"")),o<n.length-1?i=i.replace(/[\/]+$/,""):i=i.replace(/[\/]+$/,"/"),t.push(i));}var a=t.join("/");a=a.replace(/\/(\?|&|#[^!])/g,"$1");var c=a.split("?");return a=c.shift()+(c.length>0?"?":"")+c.join("&"),a}function b(){var n;return typeof arguments[0]=="object"?n=arguments[0]:n=[].slice.call(arguments),Bw(n)}var I={};P(I,{AggregationData:()=>Sc,Alert:()=>Xw,AlertAlertType:()=>ts,AlertPagePublic:()=>ks,AlertPublic:()=>uo,AlertPublicAlertType:()=>ws,AlertTrigger:()=>ps,AlertTriggerConfig:()=>ss,AlertTriggerConfigPublic:()=>bs,AlertTriggerConfigPublicType:()=>Rs,AlertTriggerConfigType:()=>ns,AlertTriggerConfigWrite:()=>ls,AlertTriggerConfigWriteType:()=>cs,AlertTriggerEventType:()=>as,AlertTriggerPublic:()=>ys,AlertTriggerPublicEventType:()=>hs,AlertTriggerWrite:()=>ds,AlertTriggerWriteEventType:()=>ms,AlertWrite:()=>mo,AlertWriteAlertType:()=>us,AnnotationQueue:()=>As,AnnotationQueueBatch:()=>$w,AnnotationQueueBatchWrite:()=>ao,AnnotationQueueItemIds:()=>Si,AnnotationQueuePagePublic:()=>vs,AnnotationQueuePublic:()=>go,AnnotationQueuePublicScope:()=>Es,AnnotationQueueReviewer:()=>Ts,AnnotationQueueReviewerPublic:()=>Ps,AnnotationQueueScope:()=>_s,AnnotationQueueUpdate:()=>no,AnnotationQueueWrite:()=>io,AnnotationQueueWriteScope:()=>Ln,AssistantMessage:()=>Sp,AssistantMessageRole:()=>zp,Attachment:()=>Cs,AttachmentListRequestEntityType:()=>Ft,AttachmentPage:()=>Is,AuthDetailsHolder:()=>Ds,AutomationRuleEvaluator:()=>Yw,AutomationRuleEvaluatorLlmAsJudge:()=>Ls,AutomationRuleEvaluatorLlmAsJudgePublic:()=>Po,AutomationRuleEvaluatorLlmAsJudgeWrite:()=>$s,AutomationRuleEvaluatorObjectPublic:()=>mp,AutomationRuleEvaluatorPagePublic:()=>dp,AutomationRuleEvaluatorPublic:()=>up,AutomationRuleEvaluatorTraceThreadLlmAsJudge:()=>Hs,AutomationRuleEvaluatorTraceThreadLlmAsJudgePublic:()=>Co,AutomationRuleEvaluatorTraceThreadLlmAsJudgeWrite:()=>Ys,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPython:()=>Js,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPythonPublic:()=>Io,AutomationRuleEvaluatorTraceThreadUserDefinedMetricPythonWrite:()=>qs,AutomationRuleEvaluatorUpdate:()=>kp,AutomationRuleEvaluatorUpdateLlmAsJudge:()=>hp,AutomationRuleEvaluatorUpdateTraceThreadLlmAsJudge:()=>bp,AutomationRuleEvaluatorUpdateTraceThreadUserDefinedMetricPython:()=>yp,AutomationRuleEvaluatorUpdateUserDefinedMetricPython:()=>Rp,AutomationRuleEvaluatorUserDefinedMetricPython:()=>Vs,AutomationRuleEvaluatorUserDefinedMetricPythonPublic:()=>vo,AutomationRuleEvaluatorUserDefinedMetricPythonWrite:()=>rp,AutomationRuleEvaluatorWrite:()=>ip,AvgValueStatPublic:()=>Xp,BatchDelete:()=>W,BatchDeleteByProject:()=>Rf,BiInformation:()=>Zn,BiInformationResponse:()=>$e,BooleanFeedbackDefinition:()=>Ec,BooleanFeedbackDefinitionCreate:()=>Nc,BooleanFeedbackDefinitionPublic:()=>Bo,BooleanFeedbackDefinitionUpdate:()=>Yc,BooleanFeedbackDetail:()=>Ac,BooleanFeedbackDetailCreate:()=>Uc,BooleanFeedbackDetailPublic:()=>Lc,BooleanFeedbackDetailUpdate:()=>Qc,CategoricalFeedbackDefinition:()=>vc,CategoricalFeedbackDefinitionCreate:()=>Dc,CategoricalFeedbackDefinitionPublic:()=>Lo,CategoricalFeedbackDefinitionUpdate:()=>qc,CategoricalFeedbackDetail:()=>Pc,CategoricalFeedbackDetailCreate:()=>Mc,CategoricalFeedbackDetailPublic:()=>Vc,CategoricalFeedbackDetailUpdate:()=>Zc,ChatCompletionChoice:()=>_p,ChatCompletionRequest:()=>po,ChatCompletionResponse:()=>Pp,Check:()=>mc,CheckName:()=>cc,CheckPublic:()=>Zl,CheckPublicName:()=>Ql,CheckPublicResult:()=>Yl,CheckResult:()=>lc,ChunkedOutputJsonNode:()=>rf,ChunkedOutputJsonNodePublic:()=>nf,ChunkedOutputJsonNodePublicType:()=>Tc,ChunkedOutputJsonNodeType:()=>nc,Column:()=>ic,ColumnCompare:()=>Up,ColumnCompareTypesItem:()=>jp,ColumnPublic:()=>rc,ColumnPublicTypesItem:()=>ec,ColumnTypesItem:()=>tc,Comment:()=>B,CommentCompare:()=>Np,CommentPublic:()=>Me,CompleteMultipartUploadRequest:()=>xi,CompleteMultipartUploadRequestEntityType:()=>js,CompletionTokensDetails:()=>Ap,CountValueStatPublic:()=>Gp,CreateDatasetItemsFromSpansRequest:()=>wr,CreateDatasetItemsFromTracesRequest:()=>fr,CreatePromptVersionDetail:()=>Wr,DataPointDouble:()=>bf,DataPointNumberPublic:()=>yl,Dataset:()=>Zw,DatasetExpansion:()=>ef,DatasetExpansionResponse:()=>Ip,DatasetExpansionWrite:()=>yr,DatasetIdentifier:()=>Rr,DatasetIdentifierPublic:()=>kr,DatasetItem:()=>Uo,DatasetItemBatch:()=>qw,DatasetItemBatchWrite:()=>gr,DatasetItemCompare:()=>Vp,DatasetItemCompareSource:()=>Mp,DatasetItemPageCompare:()=>Hp,DatasetItemPagePublic:()=>oc,DatasetItemPublic:()=>Do,DatasetItemPublicSource:()=>Zp,DatasetItemSource:()=>Cp,DatasetItemStreamRequest:()=>zr,DatasetItemWrite:()=>gn,DatasetItemWriteSource:()=>un,DatasetItemsDelete:()=>br,DatasetPagePublic:()=>Kp,DatasetPublic:()=>Qe,DatasetPublicVisibility:()=>Jp,DatasetUpdate:()=>hr,DatasetUpdateVisibility:()=>Ht,DatasetVisibility:()=>vp,DatasetWrite:()=>ur,DatasetWriteVisibility:()=>Vt,DeleteAttachmentsRequest:()=>Qw,DeleteAttachmentsRequestEntityType:()=>Ns,DeleteFeedbackScore:()=>Go,DeleteIdsHolder:()=>Ye,DeleteThreadFeedbackScores:()=>Zr,DeleteTraceThreads:()=>qr,Delta:()=>xp,DownloadAttachmentRequestEntityType:()=>Ot,ErrorCountWithDeviation:()=>Ko,ErrorCountWithDeviationDetailed:()=>Al,ErrorInfo:()=>be,ErrorInfoExperimentItemBulkWriteView:()=>Ar,ErrorInfoPublic:()=>$o,ErrorInfoWrite:()=>Vr,ErrorMessage:()=>ee,ErrorMessageDetail:()=>wf,ErrorMessageDetailed:()=>uf,ErrorMessagePublic:()=>Gw,Experiment:()=>of,ExperimentGroupAggregationsResponse:()=>_c,ExperimentGroupResponse:()=>zc,ExperimentItem:()=>xr,ExperimentItemBulkRecord:()=>wc,ExperimentItemBulkRecordExperimentItemBulkWriteView:()=>En,ExperimentItemBulkUpload:()=>tf,ExperimentItemBulkUploadExperimentItemBulkWriteView:()=>Er,ExperimentItemCompare:()=>Lp,ExperimentItemCompareTraceVisibilityMode:()=>Bp,ExperimentItemPublic:()=>Mo,ExperimentItemPublicTraceVisibilityMode:()=>qp,ExperimentItemStreamRequest:()=>vr,ExperimentItemTraceVisibilityMode:()=>yn,ExperimentItemsBatch:()=>_r,ExperimentItemsDelete:()=>Tr,ExperimentPagePublic:()=>Rc,ExperimentPublic:()=>Wo,ExperimentPublicStatus:()=>hc,ExperimentPublicType:()=>fc,ExperimentStatus:()=>pc,ExperimentStreamRequestPublic:()=>Cr,ExperimentType:()=>sc,ExperimentUpdate:()=>Pr,ExperimentUpdateStatus:()=>$t,ExperimentUpdateType:()=>Gt,ExperimentWrite:()=>Sr,ExperimentWriteStatus:()=>Xt,ExperimentWriteType:()=>Kt,ExportTraceServiceRequest:()=>lf,Feedback:()=>sf,FeedbackCreate:()=>Bc,FeedbackDefinitionPagePublic:()=>Xc,FeedbackObjectPublic:()=>Kc,FeedbackPublic:()=>$c,FeedbackScore:()=>Y,FeedbackScoreAverage:()=>ie,FeedbackScoreAverageDetailed:()=>El,FeedbackScoreAveragePublic:()=>Ue,FeedbackScoreBatch:()=>Zo,FeedbackScoreBatchItem:()=>$l,FeedbackScoreBatchItemSource:()=>Gl,FeedbackScoreBatchItemThread:()=>On,FeedbackScoreBatchItemThreadSource:()=>Fn,FeedbackScoreBatchThread:()=>eo,FeedbackScoreCompare:()=>Wp,FeedbackScoreCompareSource:()=>Dp,FeedbackScoreExperimentItemBulkWriteView:()=>An,FeedbackScoreExperimentItemBulkWriteViewSource:()=>xn,FeedbackScoreNames:()=>bl,FeedbackScorePublic:()=>Qo,FeedbackScorePublicSource:()=>Vl,FeedbackScoreSource:()=>hn,FeedbackUpdate:()=>tl,FindFeedbackDefinitionsRequestType:()=>Zt,FindFeedbackScoreNames1RequestType:()=>ui,Function:()=>so,FunctionCall:()=>ye,GetSpanStatsRequestType:()=>gi,GetSpansByProjectRequestType:()=>mi,GetWebhookExamplesRequestAlertType:()=>Mt,GroupContent:()=>bc,GroupContentWithAggregations:()=>xc,GroupDetail:()=>yc,GroupDetails:()=>kc,Guardrail:()=>nl,GuardrailBatch:()=>pf,GuardrailBatchWrite:()=>co,GuardrailName:()=>il,GuardrailResult:()=>al,GuardrailWrite:()=>Yn,GuardrailWriteName:()=>$n,GuardrailWriteResult:()=>Qn,GuardrailsValidation:()=>dc,GuardrailsValidationPublic:()=>ql,IdsHolder:()=>af,JsonListString:()=>U,JsonListStringCompare:()=>vi,JsonListStringExperimentItemBulkWriteView:()=>me,JsonListStringPublic:()=>ae,JsonListStringWrite:()=>te,JsonNode:()=>O,JsonNodeDetail:()=>jn,JsonNodePublic:()=>Ml,JsonNodeWrite:()=>In,JsonSchema:()=>Kn,LlmAsJudgeCode:()=>bo,LlmAsJudgeCodePublic:()=>sp,LlmAsJudgeCodeWrite:()=>Gs,LlmAsJudgeMessage:()=>ho,LlmAsJudgeMessagePublic:()=>Ao,LlmAsJudgeMessagePublicRole:()=>ap,LlmAsJudgeMessageRole:()=>Ws,LlmAsJudgeMessageWrite:()=>xo,LlmAsJudgeMessageWriteRole:()=>Ks,LlmAsJudgeModelParameters:()=>fo,LlmAsJudgeModelParametersPublic:()=>To,LlmAsJudgeModelParametersWrite:()=>So,LlmAsJudgeOutputSchema:()=>Ro,LlmAsJudgeOutputSchemaPublic:()=>Eo,LlmAsJudgeOutputSchemaPublicType:()=>np,LlmAsJudgeOutputSchemaType:()=>Bs,LlmAsJudgeOutputSchemaWrite:()=>_o,LlmAsJudgeOutputSchemaWriteType:()=>Xs,LogItem:()=>wp,LogItemLevel:()=>gp,LogPage:()=>fp,ManualEvaluationRequest:()=>Ui,ManualEvaluationRequestEntityType:()=>ll,ManualEvaluationResponse:()=>ji,Message:()=>Vn,MultipartUploadPart:()=>Us,NumericalFeedbackDefinition:()=>Ic,NumericalFeedbackDefinitionCreate:()=>Oc,NumericalFeedbackDefinitionPublic:()=>Vo,NumericalFeedbackDefinitionUpdate:()=>rl,NumericalFeedbackDetail:()=>Cc,NumericalFeedbackDetailCreate:()=>Fc,NumericalFeedbackDetailPublic:()=>Hc,NumericalFeedbackDetailUpdate:()=>el,Optimization:()=>mf,OptimizationPagePublic:()=>gl,OptimizationPublic:()=>Jo,OptimizationPublicStatus:()=>ul,OptimizationStatus:()=>ml,OptimizationUpdate:()=>Ur,OptimizationUpdateStatus:()=>oi,OptimizationWrite:()=>Ni,OptimizationWriteStatus:()=>dl,PageColumns:()=>ac,PercentageValueStatPublic:()=>$p,PercentageValues:()=>ke,PercentageValuesDetailed:()=>Pl,PercentageValuesPublic:()=>No,Project:()=>df,ProjectDetailed:()=>Cl,ProjectDetailedVisibility:()=>vl,ProjectMetricRequestPublic:()=>Dr,ProjectMetricRequestPublicInterval:()=>si,ProjectMetricRequestPublicMetricType:()=>ni,ProjectMetricResponsePublic:()=>xl,ProjectMetricResponsePublicInterval:()=>zl,ProjectMetricResponsePublicMetricType:()=>kl,ProjectPagePublic:()=>hl,ProjectPublic:()=>Xo,ProjectPublicVisibility:()=>fl,ProjectRetrieveDetailed:()=>Fr,ProjectStatItemObjectPublic:()=>Yp,ProjectStatsPublic:()=>Ne,ProjectStatsSummary:()=>Tl,ProjectStatsSummaryItem:()=>_l,ProjectUpdate:()=>Mr,ProjectUpdateVisibility:()=>ai,ProjectVisibility:()=>wl,ProjectWrite:()=>Nr,ProjectWriteVisibility:()=>ii,Prompt:()=>gf,PromptDetail:()=>Nl,PromptPagePublic:()=>Bl,PromptPublic:()=>Wl,PromptTokensDetails:()=>Tp,PromptType:()=>Il,PromptUpdatable:()=>Br,PromptVersion:()=>Ul,PromptVersionDetail:()=>fe,PromptVersionDetailType:()=>Un,PromptVersionLink:()=>Ci,PromptVersionLinkPublic:()=>Ii,PromptVersionLinkWrite:()=>Yt,PromptVersionPagePublic:()=>Ol,PromptVersionPublic:()=>Fl,PromptVersionPublicType:()=>Dl,PromptVersionRetrieveDetail:()=>Lr,PromptVersionType:()=>jl,PromptWrite:()=>Or,PromptWriteType:()=>ci,ProviderApiKey:()=>cf,ProviderApiKeyPagePublic:()=>pl,ProviderApiKeyProvider:()=>cl,ProviderApiKeyPublic:()=>Ho,ProviderApiKeyPublicProvider:()=>sl,ProviderApiKeyUpdate:()=>jr,ProviderApiKeyWrite:()=>Ir,ProviderApiKeyWriteProvider:()=>ei,ResponseFormat:()=>Xn,ResponseFormatType:()=>Jn,Result:()=>De,ResultsNumberPublic:()=>Sl,ScoreName:()=>Rl,ServiceTogglesConfig:()=>Ll,Span:()=>Oo,SpanBatch:()=>ff,SpanBatchWrite:()=>Jr,SpanEnrichmentOptions:()=>wn,SpanExperimentItemBulkWriteView:()=>Sn,SpanExperimentItemBulkWriteViewType:()=>zn,SpanFilterPublic:()=>Dn,SpanFilterPublicOperator:()=>Mn,SpanPagePublic:()=>Xl,SpanPublic:()=>Yo,SpanPublicType:()=>Kl,SpanSearchStreamRequestPublic:()=>Xr,SpanSearchStreamRequestPublicType:()=>wi,SpanType:()=>gc,SpanUpdate:()=>Kr,SpanUpdateType:()=>di,SpanWrite:()=>Hr,SpanWriteType:()=>Nn,SpansCountResponse:()=>es,StartMultipartUploadRequest:()=>dr,StartMultipartUploadRequestEntityType:()=>Wt,StartMultipartUploadResponse:()=>Ms,StreamOptions:()=>Hn,Tool:()=>Gn,ToolCall:()=>jo,Trace:()=>Fo,TraceBatch:()=>hf,TraceBatchWrite:()=>Qr,TraceCountResponse:()=>os,TraceEnrichmentOptions:()=>fn,TraceExperimentItemBulkWriteView:()=>kn,TraceFilter:()=>wo,TraceFilterOperator:()=>Os,TraceFilterPublic:()=>Re,TraceFilterPublicOperator:()=>Pn,TraceFilterWrite:()=>tp,TraceFilterWriteOperator:()=>op,TracePagePublic:()=>tm,TracePublic:()=>qo,TracePublicVisibilityMode:()=>em,TraceSearchStreamRequestPublic:()=>oo,TraceThread:()=>et,TraceThreadBatchIdentifier:()=>Gr,TraceThreadFilter:()=>Bn,TraceThreadFilterOperator:()=>Wn,TraceThreadFilterPublic:()=>Cn,TraceThreadFilterPublicOperator:()=>vn,TraceThreadIdentifier:()=>Mi,TraceThreadLlmAsJudgeCode:()=>ko,TraceThreadLlmAsJudgeCodePublic:()=>cp,TraceThreadLlmAsJudgeCodeWrite:()=>Qs,TraceThreadPage:()=>om,TraceThreadSearchStreamRequest:()=>ro,TraceThreadStatus:()=>rm,TraceThreadUpdate:()=>to,TraceThreadUserDefinedMetricPythonCode:()=>zo,TraceThreadUserDefinedMetricPythonCodePublic:()=>lp,TraceThreadUserDefinedMetricPythonCodeWrite:()=>Zs,TraceUpdate:()=>Yr,TraceVisibilityMode:()=>uc,TraceWrite:()=>$r,UploadAttachmentRequestEntityType:()=>Bt,Usage:()=>Ep,UserDefinedMetricPythonCode:()=>yo,UserDefinedMetricPythonCodePublic:()=>pp,UserDefinedMetricPythonCodeWrite:()=>ep,ValueEntry:()=>bn,ValueEntryCompare:()=>Op,ValueEntryCompareSource:()=>Fp,ValueEntryExperimentItemBulkWriteView:()=>Tn,ValueEntryExperimentItemBulkWriteViewSource:()=>_n,ValueEntryPublic:()=>Jl,ValueEntryPublicSource:()=>Hl,ValueEntrySource:()=>Rn,Webhook:()=>is,WebhookExamples:()=>zs,WebhookPublic:()=>fs,WebhookTestResult:()=>xs,WebhookTestResultStatus:()=>Ss,WebhookWrite:()=>gs,WelcomeWizardSubmission:()=>lo,WelcomeWizardTracking:()=>im,WorkspaceConfiguration:()=>rt,WorkspaceMetricRequest:()=>yf,WorkspaceMetricResponse:()=>Di,WorkspaceMetricsSummaryRequest:()=>Ze,WorkspaceMetricsSummaryResponse:()=>am,WorkspaceNameHolder:()=>Fs,WorkspaceSpansCount:()=>qn,WorkspaceTraceCount:()=>rs,alerts:()=>Dt,annotationQueues:()=>bi,attachments:()=>Ke,chatCompletions:()=>yi,datasets:()=>Jt,experiments:()=>Xe,feedbackDefinitions:()=>qt,guardrails:()=>ki,llmProviderKey:()=>ri,optimizations:()=>ti,projects:()=>pi,prompts:()=>li,spans:()=>Ge,traces:()=>je,welcomeWizard:()=>zi});var Dt={};P(Dt,{GetWebhookExamplesRequestAlertType:()=>Mt});var Mt=r.enum_(["general","slack","pagerduty"]);var Ke={};P(Ke,{AttachmentListRequestEntityType:()=>Ft,DownloadAttachmentRequestEntityType:()=>Ot,StartMultipartUploadRequest:()=>dr,StartMultipartUploadRequestEntityType:()=>Wt,UploadAttachmentRequestEntityType:()=>Bt,uploadAttachment:()=>Lt});var Ft=r.enum_(["trace","span"]);var Ot=r.enum_(["trace","span"]);var Wt=r.enum_(["trace","span"]);var Bt=r.enum_(["trace","span"]);var Lt={};P(Lt,{Request:()=>Lw});var Lw=r.record(r.string(),r.unknown());var dr=r.object({fileName:r.property("file_name",r.string()),numOfFileParts:r.property("num_of_file_parts",r.number()),mimeType:r.property("mime_type",r.string().optional()),projectName:r.property("project_name",r.string().optional()),entityType:r.property("entity_type",Wt),entityId:r.property("entity_id",r.string()),path:r.string()});var Jt={};P(Jt,{CreateDatasetItemsFromSpansRequest:()=>wr,CreateDatasetItemsFromTracesRequest:()=>fr,DatasetExpansionWrite:()=>yr,DatasetIdentifier:()=>Rr,DatasetIdentifierPublic:()=>kr,DatasetItemBatchWrite:()=>gr,DatasetItemStreamRequest:()=>zr,DatasetItemsDelete:()=>br,DatasetUpdate:()=>hr,DatasetUpdateVisibility:()=>Ht,DatasetWrite:()=>ur,DatasetWriteVisibility:()=>Vt});var Vt=r.enum_(["private","public"]);var Ht=r.enum_(["private","public"]);var ur=r.object({id:r.string().optional(),name:r.string(),visibility:Vt.optional(),tags:r.list(r.string()).optional(),description:r.string().optional()});var un=r.enum_(["manual","trace","span","sdk"]);var O=r.record(r.string(),r.unknown());var gn=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:un,data:O});var gr=r.object({datasetName:r.property("dataset_name",r.string().optional()),datasetId:r.property("dataset_id",r.string().optional()),items:r.list(gn)});var wn=r.object({includeTags:r.boolean().optional(),includeFeedbackScores:r.boolean().optional(),includeComments:r.boolean().optional(),includeUsage:r.boolean().optional(),includeMetadata:r.boolean().optional()});var wr=r.object({spanIds:r.property("span_ids",r.list(r.string())),enrichmentOptions:r.property("enrichment_options",wn)});var fn=r.object({includeSpans:r.boolean().optional(),includeTags:r.boolean().optional(),includeFeedbackScores:r.boolean().optional(),includeComments:r.boolean().optional(),includeUsage:r.boolean().optional(),includeMetadata:r.boolean().optional()});var fr=r.object({traceIds:r.property("trace_ids",r.list(r.string())),enrichmentOptions:r.property("enrichment_options",fn)});var hr=r.object({name:r.string(),description:r.string().optional(),visibility:Ht.optional(),tags:r.list(r.string()).optional()});var Rr=r.object({datasetName:r.property("dataset_name",r.string())});var br=r.object({itemIds:r.property("item_ids",r.list(r.string()))});var yr=r.object({model:r.string(),sampleCount:r.property("sample_count",r.number().optional()),preserveFields:r.property("preserve_fields",r.list(r.string()).optional()),variationInstructions:r.property("variation_instructions",r.string().optional()),customPrompt:r.property("custom_prompt",r.string().optional())});var kr=r.object({datasetName:r.property("dataset_name",r.string())});var zr=r.object({datasetName:r.property("dataset_name",r.string()),lastRetrievedId:r.property("last_retrieved_id",r.string().optional()),steamLimit:r.property("steam_limit",r.number().optional())});var Xe={};P(Xe,{ExperimentItemBulkUploadExperimentItemBulkWriteView:()=>Er,ExperimentItemStreamRequest:()=>vr,ExperimentItemsBatch:()=>_r,ExperimentItemsDelete:()=>Tr,ExperimentStreamRequestPublic:()=>Cr,ExperimentUpdate:()=>Pr,ExperimentUpdateStatus:()=>$t,ExperimentUpdateType:()=>Gt,ExperimentWrite:()=>Sr,ExperimentWriteStatus:()=>Xt,ExperimentWriteType:()=>Kt,findFeedbackScoreNames:()=>Qt});var Kt=r.enum_(["regular","trial","mini-batch"]);var Xt=r.enum_(["running","completed","cancelled"]);var Gt=r.enum_(["regular","trial","mini-batch"]);var $t=r.enum_(["running","completed","cancelled"]);var Qt={};P(Qt,{Response:()=>Vw});var Vw=r.list(r.string());var te=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var Yt=r.object({id:r.string()});var Sr=r.object({id:r.string().optional(),datasetName:r.property("dataset_name",r.string()),name:r.string().optional(),metadata:te.optional(),type:Kt.optional(),optimizationId:r.property("optimization_id",r.string().optional()),status:Xt.optional(),promptVersion:r.property("prompt_version",Yt.optional()),promptVersions:r.property("prompt_versions",r.list(Yt).optional())});var U=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var hn=r.enum_(["ui","sdk","online_scoring"]);var Rn=r.enum_(["ui","sdk","online_scoring"]);var bn=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Rn.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Y=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:hn,createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),valueByAuthor:r.property("value_by_author",r.record(r.string(),bn).optional())});var B=r.object({id:r.string().optional(),text:r.string(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var yn=r.enum_(["default","hidden"]);var xr=r.object({id:r.string().optional(),experimentId:r.property("experiment_id",r.string()),datasetItemId:r.property("dataset_item_id",r.string()),traceId:r.property("trace_id",r.string()),input:U.optional(),output:U.optional(),feedbackScores:r.property("feedback_scores",r.list(Y).optional()),comments:r.list(B).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),duration:r.number().optional(),usage:r.record(r.string(),r.number()).optional(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),traceVisibilityMode:r.property("trace_visibility_mode",yn.optional())});var _r=r.object({experimentItems:r.property("experiment_items",r.list(xr))});var Tr=r.object({ids:r.list(r.string())});var me=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var Ar=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var kn=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),name:r.string().optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:me.optional(),output:me.optional(),metadata:me.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",Ar.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),threadId:r.property("thread_id",r.string().optional())});var zn=r.enum_(["general","tool","llm","guardrail"]);var Sn=r.object({id:r.string().optional(),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:zn.optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:me.optional(),output:me.optional(),metadata:me.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),errorInfo:r.property("error_info",Ar.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostVersion:r.property("total_estimated_cost_version",r.string().optional())});var xn=r.enum_(["ui","sdk","online_scoring"]);var _n=r.enum_(["ui","sdk","online_scoring"]);var Tn=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:_n.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var An=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:xn,createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),valueByAuthor:r.property("value_by_author",r.record(r.string(),Tn).optional())});var En=r.object({datasetItemId:r.property("dataset_item_id",r.string()),evaluateTaskResult:r.property("evaluate_task_result",me.optional()),trace:kn.optional(),spans:r.list(Sn).optional(),feedbackScores:r.property("feedback_scores",r.list(An).optional())});var Er=r.object({experimentName:r.property("experiment_name",r.string()),datasetName:r.property("dataset_name",r.string()),experimentId:r.property("experiment_id",r.string().optional()),items:r.list(En)});var Pr=r.object({name:r.string().optional(),metadata:O.optional(),type:Gt.optional(),status:$t.optional()});var vr=r.object({experimentName:r.property("experiment_name",r.string()),limit:r.number().optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional()),truncate:r.boolean().optional()});var Cr=r.object({name:r.string(),limit:r.number().optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional())});var qt={};P(qt,{FindFeedbackDefinitionsRequestType:()=>Zt});var Zt=r.enum_(["numerical","categorical","boolean"]);var ri={};P(ri,{ProviderApiKeyUpdate:()=>jr,ProviderApiKeyWrite:()=>Ir,ProviderApiKeyWriteProvider:()=>ei});var ei=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var Ir=r.object({provider:ei,apiKey:r.property("api_key",r.string().optional()),name:r.string().optional(),providerName:r.property("provider_name",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),configuration:r.record(r.string(),r.string()).optional(),baseUrl:r.property("base_url",r.string().optional())});var jr=r.object({apiKey:r.property("api_key",r.string().optional()),name:r.string().optional(),providerName:r.property("provider_name",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),configuration:r.record(r.string(),r.string()).optional(),baseUrl:r.property("base_url",r.string().optional())});var ti={};P(ti,{OptimizationUpdate:()=>Ur,OptimizationUpdateStatus:()=>oi});var oi=r.enum_(["running","completed","cancelled"]);var Ur=r.object({name:r.string().optional(),status:oi.optional()});var pi={};P(pi,{ProjectMetricRequestPublic:()=>Dr,ProjectMetricRequestPublicInterval:()=>si,ProjectMetricRequestPublicMetricType:()=>ni,ProjectRetrieveDetailed:()=>Fr,ProjectUpdate:()=>Mr,ProjectUpdateVisibility:()=>ai,ProjectWrite:()=>Nr,ProjectWriteVisibility:()=>ii});var ii=r.enum_(["private","public"]);var ai=r.enum_(["private","public"]);var ni=r.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST","GUARDRAILS_FAILED_COUNT","THREAD_COUNT","THREAD_DURATION","THREAD_FEEDBACK_SCORES"]);var si=r.enum_(["HOURLY","DAILY","WEEKLY"]);var Nr=r.object({name:r.string(),visibility:ii.optional(),description:r.string().optional()});var Mr=r.object({name:r.string().optional(),description:r.string().optional(),visibility:ai.optional()});var Pn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Re=r.object({field:r.string().optional(),operator:Pn.optional(),key:r.string().optional(),value:r.string().optional()});var vn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Cn=r.object({field:r.string().optional(),operator:vn.optional(),key:r.string().optional(),value:r.string().optional()});var Dr=r.object({metricType:r.property("metric_type",ni.optional()),interval:si.optional(),intervalStart:r.property("interval_start",r.date().optional()),intervalEnd:r.property("interval_end",r.date().optional()),traceFilters:r.property("trace_filters",r.list(Re).optional()),threadFilters:r.property("thread_filters",r.list(Cn).optional())});var Fr=r.object({name:r.string()});var li={};P(li,{CreatePromptVersionDetail:()=>Wr,PromptUpdatable:()=>Br,PromptVersionRetrieveDetail:()=>Lr,PromptWrite:()=>Or,PromptWriteType:()=>ci});var ci=r.enum_(["mustache","jinja2"]);var In=r.record(r.string(),r.unknown());var Or=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),template:r.string().optional(),metadata:In.optional(),changeDescription:r.property("change_description",r.string().optional()),type:ci.optional(),tags:r.list(r.string()).optional()});var jn=r.record(r.string(),r.unknown());var Un=r.enum_(["mustache","jinja2"]);var fe=r.object({id:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),commit:r.string().optional(),template:r.string(),metadata:jn.optional(),type:Un.optional(),changeDescription:r.property("change_description",r.string().optional()),variables:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var Wr=r.object({name:r.string(),version:fe});var Br=r.object({name:r.string(),description:r.string().optional(),tags:r.list(r.string()).optional()});var Lr=r.object({name:r.string(),commit:r.string().optional()});var Ge={};P(Ge,{FindFeedbackScoreNames1RequestType:()=>ui,GetSpanStatsRequestType:()=>gi,GetSpansByProjectRequestType:()=>mi,SpanBatchWrite:()=>Jr,SpanSearchStreamRequestPublic:()=>Xr,SpanSearchStreamRequestPublicType:()=>wi,SpanUpdate:()=>Kr,SpanUpdateType:()=>di,findFeedbackScoreNames1:()=>fi});var mi=r.enum_(["general","tool","llm","guardrail"]);var di=r.enum_(["general","tool","llm","guardrail"]);var ui=r.enum_(["general","tool","llm","guardrail"]);var gi=r.enum_(["general","tool","llm","guardrail"]);var wi=r.enum_(["general","tool","llm","guardrail"]);var fi={};P(fi,{Response:()=>Hw});var Hw=r.list(r.string());var Nn=r.enum_(["general","tool","llm","guardrail"]);var Vr=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var Hr=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),traceId:r.property("trace_id",r.string().optional()),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:Nn.optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:te.optional(),output:te.optional(),metadata:te.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),errorInfo:r.property("error_info",Vr.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostVersion:r.property("total_estimated_cost_version",r.string().optional())});var Jr=r.object({spans:r.list(Hr)});var be=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var Kr=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),traceId:r.property("trace_id",r.string()),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:di.optional(),endTime:r.property("end_time",r.date().optional()),input:U.optional(),output:U.optional(),metadata:U.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),errorInfo:r.property("error_info",be.optional())});var Mn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Dn=r.object({field:r.string().optional(),operator:Mn.optional(),key:r.string().optional(),value:r.string().optional()});var Xr=r.object({traceId:r.property("trace_id",r.string().optional()),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),type:wi.optional(),filters:r.list(Dn).optional(),limit:r.number().optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional()),truncate:r.boolean().optional(),fromTime:r.property("from_time",r.date().optional()),toTime:r.property("to_time",r.date().optional())});var je={};P(je,{DeleteThreadFeedbackScores:()=>Zr,DeleteTraceThreads:()=>qr,FeedbackScoreBatchThread:()=>eo,TraceBatchWrite:()=>Qr,TraceSearchStreamRequestPublic:()=>oo,TraceThreadBatchIdentifier:()=>Gr,TraceThreadSearchStreamRequest:()=>ro,TraceThreadUpdate:()=>to,TraceUpdate:()=>Yr,findFeedbackScoreNames2:()=>hi,findTraceThreadsFeedbackScoreNames:()=>Ri});var hi={};P(hi,{Response:()=>Jw});var Jw=r.list(r.string());var Ri={};P(Ri,{Response:()=>Kw});var Kw=r.list(r.string());var Gr=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),threadId:r.property("thread_id",r.string().optional()),threadIds:r.property("thread_ids",r.list(r.string()).optional())});var $r=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),name:r.string().optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:te.optional(),output:te.optional(),metadata:te.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",Vr.optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),threadId:r.property("thread_id",r.string().optional())});var Qr=r.object({traces:r.list($r)});var Yr=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:r.string().optional(),endTime:r.property("end_time",r.date().optional()),input:U.optional(),output:U.optional(),metadata:U.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",be.optional()),threadId:r.property("thread_id",r.string().optional())});var Zr=r.object({projectName:r.property("project_name",r.string()),threadId:r.property("thread_id",r.string()),names:r.list(r.string()),author:r.string().optional()});var qr=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),threadIds:r.property("thread_ids",r.list(r.string()))});var Fn=r.enum_(["ui","sdk","online_scoring"]);var On=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Fn,author:r.string().optional(),threadId:r.property("thread_id",r.string())});var eo=r.object({scores:r.list(On)});var Wn=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var Bn=r.object({field:r.string().optional(),operator:Wn.optional(),key:r.string().optional(),value:r.string().optional()});var ro=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),filters:r.list(Bn).optional(),lastRetrievedThreadModelId:r.property("last_retrieved_thread_model_id",r.string().optional()),limit:r.number().optional(),truncate:r.boolean().optional(),stripAttachments:r.property("strip_attachments",r.boolean().optional()),fromTime:r.property("from_time",r.date().optional()),toTime:r.property("to_time",r.date().optional())});var oo=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),filters:r.list(Re).optional(),lastRetrievedId:r.property("last_retrieved_id",r.string().optional()),limit:r.number().optional(),truncate:r.boolean().optional(),stripAttachments:r.property("strip_attachments",r.boolean().optional()),fromTime:r.property("from_time",r.date().optional()),toTime:r.property("to_time",r.date().optional())});var to=r.object({tags:r.list(r.string()).optional()});var bi={};P(bi,{AnnotationQueueBatchWrite:()=>ao,AnnotationQueueUpdate:()=>no});var Ln=r.enum_(["trace","thread"]);var io=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),name:r.string(),description:r.string().optional(),instructions:r.string().optional(),scope:Ln,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional())});var ao=r.object({annotationQueues:r.property("annotation_queues",r.list(io))});var no=r.object({name:r.string().optional(),description:r.string().optional(),instructions:r.string().optional(),commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional())});var yi={};P(yi,{ChatCompletionRequest:()=>po});var Vn=r.record(r.string(),r.unknown());var Hn=r.object({includeUsage:r.property("include_usage",r.boolean().optional())});var Jn=r.enum_(["text","json_object","json_schema"]);var Kn=r.object({name:r.string().optional(),strict:r.boolean().optional(),schema:r.record(r.string(),r.record(r.string(),r.unknown())).optional()});var Xn=r.object({type:Jn.optional(),jsonSchema:r.property("json_schema",Kn.optional())});var so=r.object({name:r.string().optional(),description:r.string().optional(),strict:r.boolean().optional(),parameters:r.record(r.string(),r.record(r.string(),r.unknown())).optional()});var Gn=r.object({type:r.stringLiteral("function").optional(),function:so.optional()});var ye=r.object({name:r.string().optional(),arguments:r.string().optional()});var po=r.object({model:r.string().optional(),messages:r.list(Vn).optional(),temperature:r.number().optional(),topP:r.property("top_p",r.number().optional()),n:r.number().optional(),stream:r.boolean().optional(),streamOptions:r.property("stream_options",Hn.optional()),stop:r.list(r.string()).optional(),maxTokens:r.property("max_tokens",r.number().optional()),maxCompletionTokens:r.property("max_completion_tokens",r.number().optional()),presencePenalty:r.property("presence_penalty",r.number().optional()),frequencyPenalty:r.property("frequency_penalty",r.number().optional()),logitBias:r.property("logit_bias",r.record(r.string(),r.number()).optional()),user:r.string().optional(),responseFormat:r.property("response_format",Xn.optional()),seed:r.number().optional(),tools:r.list(Gn).optional(),toolChoice:r.property("tool_choice",r.record(r.string(),r.unknown()).optional()),parallelToolCalls:r.property("parallel_tool_calls",r.boolean().optional()),store:r.boolean().optional(),metadata:r.record(r.string(),r.string()).optional(),reasoningEffort:r.property("reasoning_effort",r.string().optional()),serviceTier:r.property("service_tier",r.string().optional()),functions:r.list(so).optional(),functionCall:r.property("function_call",ye.optional())});var ki={};P(ki,{GuardrailBatchWrite:()=>co});var $n=r.enum_(["TOPIC","PII"]);var Qn=r.enum_(["passed","failed"]);var Yn=r.object({entityId:r.property("entity_id",r.string()),secondaryId:r.property("secondary_id",r.string()),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:$n,result:Qn,config:O,details:O});var co=r.object({guardrails:r.list(Yn)});var zi={};P(zi,{WelcomeWizardSubmission:()=>lo});var lo=r.object({role:r.string().optional(),integrations:r.list(r.string()).optional(),email:r.string().optional(),joinBetaProgram:r.property("join_beta_program",r.boolean().optional())});var Zn=r.object({workspaceId:r.property("workspace_id",r.string().optional()),user:r.string().optional(),count:r.number().optional()});var $e=r.object({biInformation:r.property("bi_information",r.list(Zn).optional())});var qn=r.object({workspace:r.string().optional(),spanCount:r.property("span_count",r.number().optional())});var es=r.object({workspacesSpansCount:r.property("workspaces_spans_count",r.list(qn).optional())});var rs=r.object({workspace:r.string().optional(),traceCount:r.property("trace_count",r.number().optional())});var os=r.object({workspacesTracesCount:r.property("workspaces_traces_count",r.list(rs).optional())});var ee=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var ts=r.enum_(["general","slack","pagerduty"]);var is=r.object({id:r.string().optional(),name:r.string().optional(),url:r.string(),secretToken:r.property("secret_token",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var as=r.enum_(["trace:errors","trace:feedback_score","trace_thread:feedback_score","prompt:created","prompt:committed","trace:guardrails_triggered","prompt:deleted","experiment:finished","trace:cost","trace:latency"]);var ns=r.enum_(["scope:project","threshold:feedback_score","threshold:cost","threshold:latency"]);var ss=r.object({id:r.string().optional(),alertTriggerId:r.property("alert_trigger_id",r.string().optional()),type:ns,configValue:r.property("config_value",r.record(r.string(),r.string()).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ps=r.object({id:r.string().optional(),alertId:r.property("alert_id",r.string().optional()),eventType:r.property("event_type",as),triggerConfigs:r.property("trigger_configs",r.list(ss).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var Xw=r.object({id:r.string().optional(),name:r.string().optional(),enabled:r.boolean().optional(),alertType:r.property("alert_type",ts.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:is,triggers:r.list(ps).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var cs=r.enum_(["scope:project","threshold:feedback_score","threshold:cost","threshold:latency"]);var ls=r.object({id:r.string().optional(),type:cs,configValue:r.property("config_value",r.record(r.string(),r.string()).optional())});var ms=r.enum_(["trace:errors","trace:feedback_score","trace_thread:feedback_score","prompt:created","prompt:committed","trace:guardrails_triggered","prompt:deleted","experiment:finished","trace:cost","trace:latency"]);var ds=r.object({id:r.string().optional(),eventType:r.property("event_type",ms),triggerConfigs:r.property("trigger_configs",r.list(ls).optional())});var us=r.enum_(["general","slack","pagerduty"]);var gs=r.object({id:r.string().optional(),name:r.string().optional(),url:r.string(),secretToken:r.property("secret_token",r.string().optional()),headers:r.record(r.string(),r.string()).optional()});var mo=r.object({id:r.string().optional(),name:r.string().optional(),enabled:r.boolean().optional(),alertType:r.property("alert_type",us.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:gs,triggers:r.list(ds).optional()});var W=r.object({ids:r.list(r.string())});var ws=r.enum_(["general","slack","pagerduty"]);var fs=r.object({id:r.string().optional(),name:r.string().optional(),url:r.string(),secretToken:r.property("secret_token",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var hs=r.enum_(["trace:errors","trace:feedback_score","trace_thread:feedback_score","prompt:created","prompt:committed","trace:guardrails_triggered","prompt:deleted","experiment:finished","trace:cost","trace:latency"]);var Rs=r.enum_(["scope:project","threshold:feedback_score","threshold:cost","threshold:latency"]);var bs=r.object({id:r.string().optional(),alertTriggerId:r.property("alert_trigger_id",r.string().optional()),type:Rs,configValue:r.property("config_value",r.record(r.string(),r.string()).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ys=r.object({id:r.string().optional(),alertId:r.property("alert_id",r.string().optional()),eventType:r.property("event_type",hs),triggerConfigs:r.property("trigger_configs",r.list(bs).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var uo=r.object({id:r.string().optional(),name:r.string().optional(),enabled:r.boolean().optional(),alertType:r.property("alert_type",ws.optional()),metadata:r.record(r.string(),r.string()).optional(),webhook:fs,triggers:r.list(ys).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ks=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(uo).optional(),sortableBy:r.property("sortable_by",r.list(r.string()).optional())});var Gw=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var zs=r.object({responseExamples:r.property("response_examples",r.record(r.string(),r.record(r.string(),r.unknown())).optional())});var Ss=r.enum_(["success","failure"]);var xs=r.object({status:Ss.optional(),statusCode:r.property("status_code",r.number().optional()),requestBody:r.property("request_body",r.string().optional()),errorMessage:r.property("error_message",r.string().optional())});var Si=r.object({ids:r.list(r.string())});var _s=r.enum_(["trace","thread"]);var Ts=r.object({username:r.string().optional(),status:r.number().optional()});var ie=r.object({name:r.string(),value:r.number()});var As=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),description:r.string().optional(),instructions:r.string().optional(),scope:_s,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional()),reviewers:r.list(Ts).optional(),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),itemsCount:r.property("items_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var $w=r.object({annotationQueues:r.property("annotation_queues",r.list(As))});var Es=r.enum_(["trace","thread"]);var Ps=r.object({username:r.string().optional(),status:r.number().optional()});var Ue=r.object({name:r.string(),value:r.number()});var go=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),description:r.string().optional(),instructions:r.string().optional(),scope:Es,commentsEnabled:r.property("comments_enabled",r.boolean().optional()),feedbackDefinitionNames:r.property("feedback_definition_names",r.list(r.string()).optional()),reviewers:r.list(Ps).optional(),feedbackScores:r.property("feedback_scores",r.list(Ue).optional()),itemsCount:r.property("items_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var vs=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(go).optional(),sortableBy:r.list(r.string()).optional()});var Cs=r.object({link:r.string().optional(),fileName:r.property("file_name",r.string()),fileSize:r.property("file_size",r.number()),mimeType:r.property("mime_type",r.string())});var Is=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Cs).optional(),sortableBy:r.list(r.string()).optional()});var js=r.enum_(["trace","span"]);var Us=r.object({eTag:r.property("e_tag",r.string()),partNumber:r.property("part_number",r.number())});var xi=r.object({fileName:r.property("file_name",r.string()),projectName:r.property("project_name",r.string().optional()),entityType:r.property("entity_type",js),entityId:r.property("entity_id",r.string()),containerId:r.property("container_id",r.string().optional()),fileSize:r.property("file_size",r.number()),mimeType:r.property("mime_type",r.string().optional()),uploadId:r.property("upload_id",r.string()),uploadedFileParts:r.property("uploaded_file_parts",r.list(Us))});var Ns=r.enum_(["trace","span"]);var Qw=r.object({fileNames:r.property("file_names",r.list(r.string())),entityType:r.property("entity_type",Ns),entityId:r.property("entity_id",r.string()),containerId:r.property("container_id",r.string())});var Ms=r.object({uploadId:r.property("upload_id",r.string()),preSignUrls:r.property("pre_sign_urls",r.list(r.string()))});var Ds=r.record(r.string(),r.unknown());var Fs=r.object({workspaceName:r.property("workspace_name",r.string().optional())});var Os=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var wo=r.object({field:r.string().optional(),operator:Os.optional(),key:r.string().optional(),value:r.string().optional()});var fo=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional()});var Ws=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var ho=r.object({role:Ws,content:r.string()});var Bs=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var Ro=r.object({name:r.string(),type:Bs,description:r.string()});var bo=r.object({model:fo,messages:r.list(ho),variables:r.record(r.string(),r.string()),schema:r.list(Ro)});var Ls=r.object({code:bo.optional()});var yo=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var Vs=r.object({code:yo.optional()});var ko=r.object({model:fo,messages:r.list(ho),schema:r.list(Ro)});var Hs=r.object({code:ko.optional()});var zo=r.object({metric:r.string()});var Js=r.object({code:zo.optional()});var _i=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(wo).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),action:r.stringLiteral("evaluator")}),Yw=r.union("type",{llm_as_judge:Ls.extend(_i),user_defined_metric_python:Vs.extend(_i),trace_thread_llm_as_judge:Hs.extend(_i),trace_thread_user_defined_metric_python:Js.extend(_i)}).transform({transform:n=>n,untransform:n=>n});var So=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional()});var Ks=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var xo=r.object({role:Ks,content:r.string()});var Xs=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var _o=r.object({name:r.string(),type:Xs,description:r.string()});var Gs=r.object({model:So,messages:r.list(xo),variables:r.record(r.string(),r.string()),schema:r.list(_o)});var $s=r.object({code:Gs.optional()});var Qs=r.object({model:So,messages:r.list(xo),schema:r.list(_o)});var Ys=r.object({code:Qs.optional()});var Zs=r.object({metric:r.string()});var qs=r.object({code:Zs.optional()});var ep=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var rp=r.object({code:ep.optional()});var op=r.enum_(["contains","not_contains","starts_with","ends_with","=","!=",">",">=","<","<=","is_empty","is_not_empty"]);var tp=r.object({field:r.string().optional(),operator:op.optional(),key:r.string().optional(),value:r.string().optional()});var Ti=r.object({projectId:r.property("project_id",r.string()),name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(tp).optional(),action:r.stringLiteral("evaluator")}),ip=r.union("type",{llm_as_judge:$s.extend(Ti),user_defined_metric_python:rp.extend(Ti),trace_thread_llm_as_judge:Ys.extend(Ti),trace_thread_user_defined_metric_python:qs.extend(Ti)}).transform({transform:n=>n,untransform:n=>n});var To=r.object({name:r.string(),temperature:r.number(),seed:r.number().optional()});var ap=r.enum_(["SYSTEM","USER","AI","TOOL_EXECUTION_RESULT","CUSTOM"]);var Ao=r.object({role:ap,content:r.string()});var np=r.enum_(["BOOLEAN","INTEGER","DOUBLE"]);var Eo=r.object({name:r.string(),type:np,description:r.string()});var sp=r.object({model:To,messages:r.list(Ao),variables:r.record(r.string(),r.string()),schema:r.list(Eo)});var Po=r.object({code:sp.optional()});var pp=r.object({metric:r.string(),arguments:r.record(r.string(),r.string())});var vo=r.object({code:pp.optional()});var cp=r.object({model:To,messages:r.list(Ao),schema:r.list(Eo)});var Co=r.object({code:cp.optional()});var lp=r.object({metric:r.string()});var Io=r.object({code:lp.optional()});var Ai=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(Re).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),action:r.stringLiteral("evaluator")}),mp=r.union("type",{llm_as_judge:Po.extend(Ai),user_defined_metric_python:vo.extend(Ai),trace_thread_llm_as_judge:Co.extend(Ai),trace_thread_user_defined_metric_python:Io.extend(Ai)}).transform({transform:n=>n,untransform:n=>n});var dp=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(mp).optional(),sortableBy:r.property("sortable_by",r.list(r.string()).optional())});var Ei=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string()),projectName:r.property("project_name",r.string().optional()),name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(Re).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),action:r.stringLiteral("evaluator")}),up=r.union("type",{llm_as_judge:Po.extend(Ei),user_defined_metric_python:vo.extend(Ei),trace_thread_llm_as_judge:Co.extend(Ei),trace_thread_user_defined_metric_python:Io.extend(Ei)}).transform({transform:n=>n,untransform:n=>n});var gp=r.enum_(["INFO","WARN","ERROR","DEBUG","TRACE"]);var wp=r.object({timestamp:r.date().optional(),ruleId:r.property("rule_id",r.string().optional()),level:gp.optional(),message:r.string().optional(),markers:r.record(r.string(),r.string()).optional()});var fp=r.object({content:r.list(wp).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional()});var hp=r.object({code:bo.optional()});var Rp=r.object({code:yo.optional()});var bp=r.object({code:ko.optional()});var yp=r.object({code:zo.optional()});var Pi=r.object({name:r.string(),samplingRate:r.property("sampling_rate",r.number().optional()),enabled:r.boolean().optional(),filters:r.list(wo).optional(),projectId:r.property("project_id",r.string()),action:r.stringLiteral("evaluator")}),kp=r.union("type",{llm_as_judge:hp.extend(Pi),user_defined_metric_python:Rp.extend(Pi),trace_thread_llm_as_judge:bp.extend(Pi),trace_thread_user_defined_metric_python:yp.extend(Pi)}).transform({transform:n=>n,untransform:n=>n});var zp=r.enum_(["system","user","assistant","tool","function"]);var jo=r.object({id:r.string().optional(),index:r.number().optional(),type:r.stringLiteral("function").optional(),function:ye.optional()});var Sp=r.object({role:zp.optional(),content:r.string().optional(),reasoningContent:r.property("reasoning_content",r.string().optional()),name:r.string().optional(),toolCalls:r.property("tool_calls",r.list(jo).optional()),refusal:r.string().optional(),functionCall:r.property("function_call",ye.optional())});var xp=r.object({role:r.string().optional(),content:r.string().optional(),reasoningContent:r.property("reasoning_content",r.string().optional()),toolCalls:r.property("tool_calls",r.list(jo).optional()),functionCall:r.property("function_call",ye.optional())});var _p=r.object({index:r.number().optional(),message:Sp.optional(),delta:xp.optional(),finishReason:r.property("finish_reason",r.string().optional())});var Tp=r.object({cachedTokens:r.property("cached_tokens",r.number().optional())});var Ap=r.object({reasoningTokens:r.property("reasoning_tokens",r.number().optional())});var Ep=r.object({totalTokens:r.property("total_tokens",r.number().optional()),promptTokens:r.property("prompt_tokens",r.number().optional()),promptTokensDetails:r.property("prompt_tokens_details",Tp.optional()),completionTokens:r.property("completion_tokens",r.number().optional()),completionTokensDetails:r.property("completion_tokens_details",Ap.optional())});var Pp=r.object({id:r.string().optional(),created:r.number().optional(),model:r.string().optional(),choices:r.list(_p).optional(),usage:Ep.optional(),systemFingerprint:r.property("system_fingerprint",r.string().optional()),serviceTier:r.property("service_tier",r.string().optional())});var vp=r.enum_(["private","public"]);var Zw=r.object({id:r.string().optional(),name:r.string(),visibility:vp.optional(),tags:r.list(r.string()).optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),experimentCount:r.property("experiment_count",r.number().optional()),datasetItemsCount:r.property("dataset_items_count",r.number().optional()),optimizationCount:r.property("optimization_count",r.number().optional()),mostRecentExperimentAt:r.property("most_recent_experiment_at",r.date().optional()),lastCreatedExperimentAt:r.property("last_created_experiment_at",r.date().optional()),mostRecentOptimizationAt:r.property("most_recent_optimization_at",r.date().optional()),lastCreatedOptimizationAt:r.property("last_created_optimization_at",r.date().optional())});var Cp=r.enum_(["manual","trace","span","sdk"]);var Uo=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:Cp,data:O,experimentItems:r.property("experiment_items",r.list(xr).optional()),datasetId:r.property("dataset_id",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var qw=r.object({datasetName:r.property("dataset_name",r.string().optional()),datasetId:r.property("dataset_id",r.string().optional()),items:r.list(Uo)});var Ip=r.object({generatedSamples:r.property("generated_samples",r.list(Uo).optional()),model:r.string().optional(),totalGenerated:r.property("total_generated",r.number().optional()),generationTime:r.property("generation_time",r.date().optional())});var ef=r.object({model:r.string(),sampleCount:r.property("sample_count",r.number().optional()),preserveFields:r.property("preserve_fields",r.list(r.string()).optional()),variationInstructions:r.property("variation_instructions",r.string().optional()),customPrompt:r.property("custom_prompt",r.string().optional())});var jp=r.enum_(["string","number","object","boolean","array","null"]);var Up=r.object({name:r.string().optional(),types:r.list(jp).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var Np=r.object({id:r.string().optional(),text:r.string(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Mp=r.enum_(["manual","trace","span","sdk"]);var vi=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var Dp=r.enum_(["ui","sdk","online_scoring"]);var Fp=r.enum_(["ui","sdk","online_scoring"]);var Op=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Fp.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Wp=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Dp,createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),valueByAuthor:r.property("value_by_author",r.record(r.string(),Op).optional())});var Bp=r.enum_(["default","hidden"]);var Lp=r.object({id:r.string().optional(),experimentId:r.property("experiment_id",r.string()),datasetItemId:r.property("dataset_item_id",r.string()),traceId:r.property("trace_id",r.string()),input:vi.optional(),output:vi.optional(),feedbackScores:r.property("feedback_scores",r.list(Wp).optional()),comments:r.list(Np).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),duration:r.number().optional(),usage:r.record(r.string(),r.number()).optional(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),traceVisibilityMode:r.property("trace_visibility_mode",Bp.optional())});var Vp=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:Mp,data:O,experimentItems:r.property("experiment_items",r.list(Lp).optional()),datasetId:r.property("dataset_id",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Hp=r.object({content:r.list(Vp).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),columns:r.list(Up).optional(),sortableBy:r.list(r.string()).optional()});var Jp=r.enum_(["private","public"]);var Qe=r.object({id:r.string().optional(),name:r.string(),visibility:Jp.optional(),tags:r.list(r.string()).optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),experimentCount:r.property("experiment_count",r.number().optional()),datasetItemsCount:r.property("dataset_items_count",r.number().optional()),optimizationCount:r.property("optimization_count",r.number().optional()),mostRecentExperimentAt:r.property("most_recent_experiment_at",r.date().optional()),lastCreatedExperimentAt:r.property("last_created_experiment_at",r.date().optional()),mostRecentOptimizationAt:r.property("most_recent_optimization_at",r.date().optional()),lastCreatedOptimizationAt:r.property("last_created_optimization_at",r.date().optional())});var Kp=r.object({content:r.list(Qe).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),sortableBy:r.list(r.string()).optional()});var Xp=r.object({value:r.number().optional()});var Gp=r.object({value:r.number().optional()});var No=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var $p=r.object({value:No.optional()});var Qp=r.object({name:r.string().optional()}),Yp=r.union("type",{PERCENTAGE:$p.extend(Qp),COUNT:Gp.extend(Qp),AVG:Xp.extend(Qp)}).transform({transform:n=>n,untransform:n=>n});var Ne=r.object({stats:r.list(Yp).optional()});var Zp=r.enum_(["manual","trace","span","sdk"]);var qp=r.enum_(["default","hidden"]);var Mo=r.object({id:r.string().optional(),experimentId:r.property("experiment_id",r.string()),datasetItemId:r.property("dataset_item_id",r.string()),traceId:r.property("trace_id",r.string()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),traceVisibilityMode:r.property("trace_visibility_mode",qp.optional())});var Do=r.object({id:r.string().optional(),traceId:r.property("trace_id",r.string().optional()),spanId:r.property("span_id",r.string().optional()),source:Zp,data:O,experimentItems:r.property("experiment_items",r.list(Mo).optional()),datasetId:r.property("dataset_id",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ec=r.enum_(["string","number","object","boolean","array","null"]);var rc=r.object({name:r.string().optional(),types:r.list(ec).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var oc=r.object({content:r.list(Do).optional(),page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),columns:r.list(rc).optional(),sortableBy:r.list(r.string()).optional()});var tc=r.enum_(["string","number","object","boolean","array","null"]);var ic=r.object({name:r.string().optional(),types:r.list(tc).optional(),filterFieldPrefix:r.property("filter_field_prefix",r.string().optional()),filterField:r.string().optional()});var ac=r.object({columns:r.list(ic).optional()});var nc=r.object({typeName:r.string().optional()});var rf=r.object({type:nc.optional(),closed:r.boolean().optional()});var sc=r.enum_(["regular","trial","mini-batch"]);var pc=r.enum_(["running","completed","cancelled"]);var ke=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var Ci=r.object({id:r.string(),commit:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),promptName:r.property("prompt_name",r.string().optional())});var of=r.object({id:r.string().optional(),datasetName:r.property("dataset_name",r.string()),datasetId:r.property("dataset_id",r.string().optional()),name:r.string().optional(),metadata:U.optional(),type:sc.optional(),optimizationId:r.property("optimization_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),comments:r.list(B).optional(),traceCount:r.property("trace_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),duration:ke.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostAvg:r.property("total_estimated_cost_avg",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),status:pc.optional(),promptVersion:r.property("prompt_version",Ci.optional()),promptVersions:r.property("prompt_versions",r.list(Ci).optional())});var Ye=r.object({ids:r.list(r.string())});var cc=r.enum_(["TOPIC","PII"]);var lc=r.enum_(["passed","failed"]);var mc=r.object({name:cc.optional(),result:lc.optional()});var dc=r.object({spanId:r.property("span_id",r.string().optional()),checks:r.list(mc).optional()});var uc=r.enum_(["default","hidden"]);var Fo=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:r.string().optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:U.optional(),output:U.optional(),metadata:U.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",be.optional()),usage:r.record(r.string(),r.number()).optional(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Y).optional()),comments:r.list(B).optional(),guardrailsValidations:r.property("guardrails_validations",r.list(dc).optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),spanCount:r.property("span_count",r.number().optional()),duration:r.number().optional(),threadId:r.property("thread_id",r.string().optional()),visibilityMode:r.property("visibility_mode",uc.optional()),llmSpanCount:r.property("llm_span_count",r.number().optional()),providers:r.list(r.string()).optional()});var gc=r.enum_(["general","tool","llm","guardrail"]);var Oo=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),traceId:r.property("trace_id",r.string().optional()),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:gc.optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:U.optional(),output:U.optional(),metadata:U.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),errorInfo:r.property("error_info",be.optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Y).optional()),comments:r.list(B).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostVersion:r.property("total_estimated_cost_version",r.string().optional()),duration:r.number().optional()});var wc=r.object({datasetItemId:r.property("dataset_item_id",r.string()),evaluateTaskResult:r.property("evaluate_task_result",U.optional()),trace:Fo.optional(),spans:r.list(Oo).optional(),feedbackScores:r.property("feedback_scores",r.list(Y).optional())});var tf=r.object({experimentName:r.property("experiment_name",r.string()),datasetName:r.property("dataset_name",r.string()),experimentId:r.property("experiment_id",r.string().optional()),items:r.list(wc)});var Me=r.object({id:r.string().optional(),text:r.string(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ae=r.undiscriminatedUnion([r.record(r.string(),r.unknown()),r.list(r.record(r.string(),r.unknown())),r.string()]);var fc=r.enum_(["regular","trial","mini-batch"]);var hc=r.enum_(["running","completed","cancelled"]);var Ii=r.object({id:r.string(),commit:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),promptName:r.property("prompt_name",r.string().optional())});var Wo=r.object({id:r.string().optional(),datasetName:r.property("dataset_name",r.string()),datasetId:r.property("dataset_id",r.string().optional()),name:r.string().optional(),metadata:ae.optional(),type:fc.optional(),optimizationId:r.property("optimization_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Ue).optional()),comments:r.list(Me).optional(),traceCount:r.property("trace_count",r.number().optional()),createdAt:r.property("created_at",r.date().optional()),duration:No.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostAvg:r.property("total_estimated_cost_avg",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),status:hc.optional(),promptVersion:r.property("prompt_version",Ii.optional()),promptVersions:r.property("prompt_versions",r.list(Ii).optional())});var Rc=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Wo).optional(),sortableBy:r.list(r.string()).optional()});var bc=r.object({label:r.string().optional()});var yc=r.object({groupSorting:r.property("group_sorting",r.list(r.string()).optional())});var kc=r.object({groupsDetails:r.property("groups_details",r.list(yc).optional())});var zc=r.object({content:r.record(r.string(),bc).optional(),details:kc.optional()});var Sc=r.object({experimentCount:r.property("experiment_count",r.number().optional()),traceCount:r.property("trace_count",r.number().optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostAvg:r.property("total_estimated_cost_avg",r.number().optional()),duration:ke.optional(),feedbackScores:r.property("feedback_scores",r.list(ie).optional())});var xc=r.object({aggregations:Sc.optional()});var _c=r.object({content:r.record(r.string(),xc).optional()});var af=r.object({ids:r.list(r.string())});var Tc=r.object({typeName:r.string().optional()});var nf=r.object({type:Tc.optional(),closed:r.boolean().optional()});var Ac=r.object({trueLabel:r.string(),falseLabel:r.string()});var Ec=r.object({details:Ac.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Pc=r.object({categories:r.record(r.string(),r.number())});var vc=r.object({details:Pc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Cc=r.object({max:r.number(),min:r.number()});var Ic=r.object({details:Cc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var jc=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),createdAt:r.date().optional(),createdBy:r.string().optional(),lastUpdatedAt:r.date().optional(),lastUpdatedBy:r.string().optional()}),sf=r.union("type",{numerical:Ic.extend(jc),categorical:vc.extend(jc),boolean:Ec.extend(jc)}).transform({transform:n=>n,untransform:n=>n});var Uc=r.object({trueLabel:r.string(),falseLabel:r.string()});var Nc=r.object({details:Uc.optional()});var Mc=r.object({categories:r.record(r.string(),r.number())});var Dc=r.object({details:Mc.optional()});var Fc=r.object({max:r.number(),min:r.number()});var Oc=r.object({details:Fc.optional()});var Wc=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional()}),Bc=r.union("type",{numerical:Oc.extend(Wc),categorical:Dc.extend(Wc),boolean:Nc.extend(Wc)}).transform({transform:n=>n,untransform:n=>n});var Lc=r.object({trueLabel:r.string(),falseLabel:r.string()});var Bo=r.object({details:Lc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Vc=r.object({categories:r.record(r.string(),r.number())});var Lo=r.object({details:Vc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Hc=r.object({max:r.number(),min:r.number()});var Vo=r.object({details:Hc.optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var Jc=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),createdAt:r.date().optional(),createdBy:r.string().optional(),lastUpdatedAt:r.date().optional(),lastUpdatedBy:r.string().optional()}),Kc=r.union("type",{numerical:Vo.extend(Jc),categorical:Lo.extend(Jc),boolean:Bo.extend(Jc)}).transform({transform:n=>n,untransform:n=>n});var Xc=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Kc).optional()});var Gc=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),createdAt:r.date().optional(),createdBy:r.string().optional(),lastUpdatedAt:r.date().optional(),lastUpdatedBy:r.string().optional()}),$c=r.union("type",{numerical:Vo.extend(Gc),categorical:Lo.extend(Gc),boolean:Bo.extend(Gc)}).transform({transform:n=>n,untransform:n=>n});var Qc=r.object({trueLabel:r.string(),falseLabel:r.string()});var Yc=r.object({details:Qc.optional()});var Zc=r.object({categories:r.record(r.string(),r.number())});var qc=r.object({details:Zc.optional()});var el=r.object({max:r.number(),min:r.number()});var rl=r.object({details:el.optional()});var ol=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional()}),tl=r.union("type",{numerical:rl.extend(ol),categorical:qc.extend(ol),boolean:Yc.extend(ol)}).transform({transform:n=>n,untransform:n=>n});var il=r.enum_(["TOPIC","PII"]);var al=r.enum_(["passed","failed"]);var nl=r.object({id:r.string().optional(),entityId:r.property("entity_id",r.string()),secondaryId:r.property("secondary_id",r.string()),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:il,result:al,config:O,details:O});var pf=r.object({guardrails:r.list(nl)});var sl=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var Ho=r.object({id:r.string().optional(),provider:sl,apiKey:r.property("api_key",r.string().optional()),name:r.string().optional(),providerName:r.property("provider_name",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),configuration:r.record(r.string(),r.string()).optional(),baseUrl:r.property("base_url",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var pl=r.object({size:r.number().optional(),total:r.number().optional(),content:r.list(Ho).optional(),sortableBy:r.list(r.string()).optional()});var cl=r.enum_(["openai","anthropic","gemini","openrouter","vertex-ai","custom-llm"]);var cf=r.object({id:r.string().optional(),provider:cl,apiKey:r.property("api_key",r.string().optional()),name:r.string().optional(),providerName:r.property("provider_name",r.string().optional()),headers:r.record(r.string(),r.string()).optional(),configuration:r.record(r.string(),r.string()).optional(),baseUrl:r.property("base_url",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var ji=r.object({entitiesQueued:r.property("entities_queued",r.number().optional()),rulesApplied:r.property("rules_applied",r.number().optional())});var ll=r.enum_(["trace","thread"]);var Ui=r.object({projectId:r.property("project_id",r.string()),entityIds:r.property("entity_ids",r.list(r.string())),ruleIds:r.property("rule_ids",r.list(r.string())),entityType:r.property("entity_type",ll)});var lf=O;var ml=r.enum_(["running","completed","cancelled"]);var mf=r.object({id:r.string().optional(),name:r.string().optional(),datasetName:r.property("dataset_name",r.string()),objectiveName:r.property("objective_name",r.string()),status:ml,metadata:U.optional(),datasetId:r.property("dataset_id",r.string().optional()),numTrials:r.property("num_trials",r.number().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var dl=r.enum_(["running","completed","cancelled"]);var Ni=r.object({id:r.string().optional(),name:r.string().optional(),datasetName:r.property("dataset_name",r.string()),objectiveName:r.property("objective_name",r.string()),status:dl,metadata:te.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var ul=r.enum_(["running","completed","cancelled"]);var Jo=r.object({id:r.string().optional(),name:r.string().optional(),datasetName:r.property("dataset_name",r.string()),objectiveName:r.property("objective_name",r.string()),status:ul,metadata:ae.optional(),datasetId:r.property("dataset_id",r.string().optional()),numTrials:r.property("num_trials",r.number().optional()),feedbackScores:r.property("feedback_scores",r.list(Ue).optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional())});var gl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Jo).optional(),sortableBy:r.list(r.string()).optional()});var Ko=r.object({count:r.number().optional(),deviation:r.number().optional(),deviationPercentage:r.property("deviation_percentage",r.number().optional())});var wl=r.enum_(["private","public"]);var df=r.object({id:r.string().optional(),name:r.string(),visibility:wl.optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),lastUpdatedTraceAt:r.property("last_updated_trace_at",r.date().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),duration:ke.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostSum:r.property("total_estimated_cost_sum",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),traceCount:r.property("trace_count",r.number().optional()),guardrailsFailedCount:r.property("guardrails_failed_count",r.number().optional()),errorCount:r.property("error_count",Ko.optional())});var fl=r.enum_(["private","public"]);var Xo=r.object({id:r.string().optional(),name:r.string(),visibility:fl.optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),lastUpdatedTraceAt:r.property("last_updated_trace_at",r.date().optional())});var hl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Xo).optional(),sortableBy:r.list(r.string()).optional()});var Rl=r.object({name:r.string().optional()});var bl=r.object({scores:r.list(Rl).optional()});var yl=r.object({time:r.date(),value:r.number().optional()});var kl=r.enum_(["FEEDBACK_SCORES","TRACE_COUNT","TOKEN_USAGE","DURATION","COST","GUARDRAILS_FAILED_COUNT","THREAD_COUNT","THREAD_DURATION","THREAD_FEEDBACK_SCORES"]);var zl=r.enum_(["HOURLY","DAILY","WEEKLY"]);var Sl=r.object({name:r.string().optional(),data:r.list(yl).optional()});var xl=r.object({projectId:r.property("project_id",r.string().optional()),metricType:r.property("metric_type",kl.optional()),interval:zl.optional(),results:r.list(Sl).optional()});var _l=r.object({projectId:r.property("project_id",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(ie).optional()),duration:ke.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostSum:r.property("total_estimated_cost_sum",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),traceCount:r.property("trace_count",r.number().optional()),guardrailsFailedCount:r.property("guardrails_failed_count",r.number().optional()),errorCount:r.property("error_count",Ko.optional())});var Tl=r.object({content:r.list(_l).optional()});var Al=r.object({count:r.number().optional(),deviation:r.number().optional(),deviationPercentage:r.property("deviation_percentage",r.number().optional())});var El=r.object({name:r.string(),value:r.number()});var Pl=r.object({p50:r.number().optional(),p90:r.number().optional(),p99:r.number().optional()});var vl=r.enum_(["private","public"]);var Cl=r.object({id:r.string().optional(),name:r.string(),visibility:vl.optional(),description:r.string().optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),lastUpdatedTraceAt:r.property("last_updated_trace_at",r.date().optional()),feedbackScores:r.property("feedback_scores",r.list(El).optional()),duration:Pl.optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostSum:r.property("total_estimated_cost_sum",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),traceCount:r.property("trace_count",r.number().optional()),guardrailsFailedCount:r.property("guardrails_failed_count",r.number().optional()),errorCount:r.property("error_count",Al.optional())});var uf=r.object({errors:r.list(r.string()).optional()});var Il=r.enum_(["mustache","jinja2"]);var jl=r.enum_(["mustache","jinja2"]);var Ul=r.object({id:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),commit:r.string().optional(),template:r.string(),metadata:O.optional(),type:jl.optional(),changeDescription:r.property("change_description",r.string().optional()),variables:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var gf=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),template:r.string().optional(),metadata:O.optional(),changeDescription:r.property("change_description",r.string().optional()),type:Il.optional(),tags:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),versionCount:r.property("version_count",r.number().optional()),latestVersion:r.property("latest_version",Ul.optional())});var wf=r.object({code:r.number().optional(),message:r.string().optional(),details:r.string().optional()});var Nl=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),tags:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),versionCount:r.property("version_count",r.number().optional()),latestVersion:r.property("latest_version",fe.optional())});var Ml=r.record(r.string(),r.unknown());var Dl=r.enum_(["mustache","jinja2"]);var Fl=r.object({id:r.string().optional(),promptId:r.property("prompt_id",r.string().optional()),commit:r.string().optional(),template:r.string(),metadata:Ml.optional(),type:Dl.optional(),changeDescription:r.property("change_description",r.string().optional()),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional())});var Ol=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Fl).optional()});var Wl=r.object({id:r.string().optional(),name:r.string(),description:r.string().optional(),tags:r.list(r.string()).optional(),createdAt:r.property("created_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),versionCount:r.property("version_count",r.number().optional())});var Bl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Wl).optional(),sortableBy:r.list(r.string()).optional()});var Ll=r.object({pythonEvaluatorEnabled:r.boolean(),traceThreadPythonEvaluatorEnabled:r.boolean(),guardrailsEnabled:r.boolean(),opikAiEnabled:r.property("opikAIEnabled",r.boolean()),alertsEnabled:r.boolean(),welcomeWizardEnabled:r.boolean()});var ff=r.object({spans:r.list(Oo)});var Go=r.object({name:r.string(),author:r.string().optional()});var $o=r.object({exceptionType:r.property("exception_type",r.string()),message:r.string().optional(),traceback:r.string()});var Vl=r.enum_(["ui","sdk","online_scoring"]);var Hl=r.enum_(["ui","sdk","online_scoring"]);var Jl=r.object({value:r.number().optional(),reason:r.string().optional(),categoryName:r.property("category_name",r.string().optional()),source:Hl.optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional())});var Qo=r.object({name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Vl,createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),valueByAuthor:r.property("value_by_author",r.record(r.string(),Jl).optional())});var Kl=r.enum_(["general","tool","llm","guardrail"]);var Yo=r.object({id:r.string().optional(),projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),traceId:r.property("trace_id",r.string().optional()),parentSpanId:r.property("parent_span_id",r.string().optional()),name:r.string().optional(),type:Kl.optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:ae.optional(),output:ae.optional(),metadata:ae.optional(),model:r.string().optional(),provider:r.string().optional(),tags:r.list(r.string()).optional(),usage:r.record(r.string(),r.number()).optional(),errorInfo:r.property("error_info",$o.optional()),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Qo).optional()),comments:r.list(Me).optional(),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),totalEstimatedCostVersion:r.property("total_estimated_cost_version",r.string().optional()),duration:r.number().optional()});var Xl=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(Yo).optional(),sortableBy:r.list(r.string()).optional()});var Gl=r.enum_(["ui","sdk","online_scoring"]);var $l=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),name:r.string(),categoryName:r.property("category_name",r.string().optional()),value:r.number(),reason:r.string().optional(),source:Gl,author:r.string().optional(),id:r.string()});var Zo=r.object({scores:r.list($l)});var hf=r.object({traces:r.list(Fo)});var Rf=r.object({ids:r.list(r.string()),projectId:r.property("project_id",r.string().optional())});var Ql=r.enum_(["TOPIC","PII"]);var Yl=r.enum_(["passed","failed"]);var Zl=r.object({name:Ql.optional(),result:Yl.optional()});var ql=r.object({spanId:r.property("span_id",r.string().optional()),checks:r.list(Zl).optional()});var em=r.enum_(["default","hidden"]);var qo=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string().optional()),name:r.string().optional(),startTime:r.property("start_time",r.date()),endTime:r.property("end_time",r.date().optional()),input:ae.optional(),output:ae.optional(),metadata:ae.optional(),tags:r.list(r.string()).optional(),errorInfo:r.property("error_info",$o.optional()),usage:r.record(r.string(),r.number()).optional(),createdAt:r.property("created_at",r.date().optional()),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),createdBy:r.property("created_by",r.string().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),feedbackScores:r.property("feedback_scores",r.list(Qo).optional()),comments:r.list(Me).optional(),guardrailsValidations:r.property("guardrails_validations",r.list(ql).optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),spanCount:r.property("span_count",r.number().optional()),duration:r.number().optional(),threadId:r.property("thread_id",r.string().optional()),visibilityMode:r.property("visibility_mode",em.optional()),llmSpanCount:r.property("llm_span_count",r.number().optional()),providers:r.list(r.string()).optional()});var rm=r.enum_(["active","inactive"]);var et=r.object({id:r.string().optional(),projectId:r.property("project_id",r.string().optional()),threadModelId:r.property("thread_model_id",r.string().optional()),startTime:r.property("start_time",r.date().optional()),endTime:r.property("end_time",r.date().optional()),duration:r.number().optional(),firstMessage:r.property("first_message",U.optional()),lastMessage:r.property("last_message",U.optional()),feedbackScores:r.property("feedback_scores",r.list(Y).optional()),status:rm.optional(),numberOfMessages:r.property("number_of_messages",r.number().optional()),totalEstimatedCost:r.property("total_estimated_cost",r.number().optional()),usage:r.record(r.string(),r.number()).optional(),comments:r.list(B).optional(),tags:r.list(r.string()).optional(),lastUpdatedAt:r.property("last_updated_at",r.date().optional()),lastUpdatedBy:r.property("last_updated_by",r.string().optional()),createdBy:r.property("created_by",r.string().optional()),createdAt:r.property("created_at",r.date().optional())});var Mi=r.object({projectName:r.property("project_name",r.string().optional()),projectId:r.property("project_id",r.string().optional()),threadId:r.property("thread_id",r.string()),truncate:r.boolean().optional()});var om=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(et).optional(),sortableBy:r.list(r.string()).optional()});var tm=r.object({page:r.number().optional(),size:r.number().optional(),total:r.number().optional(),content:r.list(qo).optional(),sortableBy:r.list(r.string()).optional()});var im=r.object({completed:r.boolean().optional()});var De=r.object({name:r.string().optional(),current:r.number().optional(),previous:r.number().optional()});var Ze=r.object({projectIds:r.property("project_ids",r.list(r.string()).optional()),intervalStart:r.property("interval_start",r.date()),intervalEnd:r.property("interval_end",r.date()),startBeforeEnd:r.property("start_before_end",r.boolean().optional())});var bf=r.object({time:r.date(),value:r.number().optional()});var Di=r.object({results:r.list(De).optional()});var yf=r.object({projectIds:r.property("project_ids",r.list(r.string()).optional()),name:r.string().optional(),intervalStart:r.property("interval_start",r.date()),intervalEnd:r.property("interval_end",r.date()),startBeforeEnd:r.property("start_before_end",r.boolean().optional())});var rt=r.object({timeoutToMarkThreadAsInactive:r.property("timeout_to_mark_thread_as_inactive",r.string().optional()),truncationOnTables:r.property("truncation_on_tables",r.boolean().optional())});var am=r.object({results:r.list(De).optional()});var Fi=class{constructor(t={}){this._options=t;}getDatasetBiInfo(t){return f.fromPromise(this.__getDatasetBiInfo(t))}async __getDatasetBiInfo(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/internal/usage/bi-datasets"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:$e.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/bi-datasets.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getExperimentBiInfo(t){return f.fromPromise(this.__getExperimentBiInfo(t))}async __getExperimentBiInfo(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/internal/usage/bi-experiments"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:$e.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/bi-experiments.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getSpansBiInfo(t){return f.fromPromise(this.__getSpansBiInfo(t))}async __getSpansBiInfo(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/internal/usage/bi-spans"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:$e.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/bi-spans.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getSpansCountForWorkspaces(t){return f.fromPromise(this.__getSpansCountForWorkspaces(t))}async __getSpansCountForWorkspaces(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/internal/usage/workspace-span-counts"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:es.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/workspace-span-counts.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getTracesBiInfo(t){return f.fromPromise(this.__getTracesBiInfo(t))}async __getTracesBiInfo(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/internal/usage/bi-traces"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:$e.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/bi-traces.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getTracesCountForWorkspaces(t){return f.fromPromise(this.__getTracesCountForWorkspaces(t))}async __getTracesCountForWorkspaces(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/internal/usage/workspace-trace-counts"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:os.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/internal/usage/workspace-trace-counts.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Oi=class{constructor(t={}){this._options=t;}findAlerts(t={},e){return f.fromPromise(this.__findAlerts(t,e))}async __findAlerts(t={},e){var g,y;let{page:o,size:i,sorting:a,filters:c}=t,d={};o!=null&&(d.page=o.toString()),i!=null&&(d.size=i.toString()),a!=null&&(d.sorting=a),c!=null&&(d.filters=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/private/alerts"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:ks.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse});switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/alerts.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}createAlert(t,e){return f.fromPromise(this.__createAlert(t,e))}async __createAlert(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/alerts"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:mo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 409:throw new L(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/alerts.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteAlertBatch(t,e){return f.fromPromise(this.__deleteAlertBatch(t,e))}async __deleteAlertBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/alerts/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/alerts/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getAlertById(t,e){return f.fromPromise(this.__getAlertById(t,e))}async __getAlertById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/alerts/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:uo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/alerts/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateAlert(t,e,o){return f.fromPromise(this.__updateAlert(t,e,o))}async __updateAlert(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/alerts/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:mo.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);case 409:throw new L(i.error.body,i.rawResponse);case 422:throw new F(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/alerts/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getWebhookExamples(t={},e){return f.fromPromise(this.__getWebhookExamples(t,e))}async __getWebhookExamples(t={},e){var c,d;let{alertType:o}=t,i={};o!=null&&(i.alert_type=Mt.jsonOrThrow(o,{unrecognizedObjectKeys:"strip"}));let a=await R({url:b((d=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?d:h.Default,"v1/private/alerts/webhooks/examples"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:zs.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/alerts/webhooks/examples.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}testWebhook(t,e){return f.fromPromise(this.__testWebhook(t,e))}async __testWebhook(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/alerts/webhooks/tests"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:mo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:xs.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/alerts/webhooks/tests.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Wi=class{constructor(t={}){this._options=t;}addItemsToAnnotationQueue(t,e,o){return f.fromPromise(this.__addItemsToAnnotationQueue(t,e,o))}async __addItemsToAnnotationQueue(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/annotation-queues/${encodeURIComponent(t)}/items/add`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Si.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues/{id}/items/add.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}findAnnotationQueues(t={},e){return f.fromPromise(this.__findAnnotationQueues(t,e))}async __findAnnotationQueues(t={},e){var y,k;let{page:o,size:i,name:a,filters:c,sorting:d}=t,u={};o!=null&&(u.page=o.toString()),i!=null&&(u.size=i.toString()),a!=null&&(u.name=a),c!=null&&(u.filters=c),d!=null&&(u.sorting=d);let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:h.Default,"v1/private/annotation-queues"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(g.ok)return {data:vs.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse});switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/annotation-queues.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}createAnnotationQueue(t,e){return f.fromPromise(this.__createAnnotationQueue(t,e))}async __createAnnotationQueue(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/annotation-queues"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:io.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createAnnotationQueueBatch(t,e){return f.fromPromise(this.__createAnnotationQueueBatch(t,e))}async __createAnnotationQueueBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/annotation-queues/batch"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ao.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 409:throw new L(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues/batch.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteAnnotationQueueBatch(t,e){return f.fromPromise(this.__deleteAnnotationQueueBatch(t,e))}async __deleteAnnotationQueueBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/annotation-queues/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getAnnotationQueueById(t,e){return f.fromPromise(this.__getAnnotationQueueById(t,e))}async __getAnnotationQueueById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/annotation-queues/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:go.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/annotation-queues/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateAnnotationQueue(t,e={},o){return f.fromPromise(this.__updateAnnotationQueue(t,e,o))}async __updateAnnotationQueue(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/annotation-queues/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:no.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/annotation-queues/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}removeItemsFromAnnotationQueue(t,e,o){return f.fromPromise(this.__removeItemsFromAnnotationQueue(t,e,o))}async __removeItemsFromAnnotationQueue(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/annotation-queues/${encodeURIComponent(t)}/items/delete`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Si.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/annotation-queues/{id}/items/delete.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Bi=class{constructor(t={}){this._options=t;}attachmentList(t,e){return f.fromPromise(this.__attachmentList(t,e))}async __attachmentList(t,e){var k,S;let{page:o,size:i,projectId:a,entityType:c,entityId:d,path:u}=t,g={};o!=null&&(g.page=o.toString()),i!=null&&(g.size=i.toString()),g.project_id=a,g.entity_type=Ft.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"}),g.entity_id=d,g.path=u;let y=await R({url:b((S=(k=await s.get(this._options.baseUrl))!=null?k:await s.get(this._options.environment))!=null?S:h.Default,"v1/private/attachment/list"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:g,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(y.ok)return {data:Is.parseOrThrow(y.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new K(y.error.body,y.rawResponse);case 403:throw new $(ee.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new p({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}switch(y.error.reason){case "non-json":throw new p({statusCode:y.error.statusCode,body:y.error.rawBody,rawResponse:y.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/attachment/list.");case "unknown":throw new p({message:y.error.errorMessage,rawResponse:y.rawResponse})}}completeMultiPartUpload(t,e){return f.fromPromise(this.__completeMultiPartUpload(t,e))}async __completeMultiPartUpload(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/attachment/upload-complete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:xi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new K(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/attachment/upload-complete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteAttachments(t,e){return f.fromPromise(this.__deleteAttachments(t,e))}async __deleteAttachments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/attachment/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:xi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new K(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/attachment/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}downloadAttachment(t,e){return f.fromPromise(this.__downloadAttachment(t,e))}async __downloadAttachment(t,e){var k,S;let{workspaceName:o,containerId:i,entityType:a,entityId:c,fileName:d,mimeType:u}=t,g={};o!=null&&(g.workspace_name=o),g.container_id=i,g.entity_type=Ot.jsonOrThrow(a,{unrecognizedObjectKeys:"strip"}),g.entity_id=c,g.file_name=d,g.mime_type=u;let y=await R({url:b((S=(k=await s.get(this._options.baseUrl))!=null?k:await s.get(this._options.environment))!=null?S:h.Default,"v1/private/attachment/download"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:g,requestType:"json",responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(y.ok)return {data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new K(y.error.body,y.rawResponse);case 403:throw new $(ee.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new p({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}switch(y.error.reason){case "non-json":throw new p({statusCode:y.error.statusCode,body:y.error.rawBody,rawResponse:y.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/attachment/download.");case "unknown":throw new p({message:y.error.errorMessage,rawResponse:y.rawResponse})}}startMultiPartUpload(t,e){return f.fromPromise(this.__startMultiPartUpload(t,e))}async __startMultiPartUpload(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/attachment/upload-start"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:dr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Ms.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new K(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/attachment/upload-start.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}uploadAttachment(t,e){return f.fromPromise(this.__uploadAttachment(t,e))}async __uploadAttachment(t,e){var k,S;let{fileName:o,projectName:i,mimeType:a,entityType:c,entityId:d,body:u}=t,g={};g.file_name=o,i!=null&&(g.project_name=i),a!=null&&(g.mime_type=a),g.entity_type=Bt.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"}),g.entity_id=d;let y=await R({url:b((S=(k=await s.get(this._options.baseUrl))!=null?k:await s.get(this._options.environment))!=null?S:h.Default,"v1/private/attachment/upload"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:g,requestType:"json",body:Ke.uploadAttachment.Request.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(y.ok)return {data:void 0,rawResponse:y.rawResponse};if(y.error.reason==="status-code")switch(y.error.statusCode){case 401:throw new K(y.error.body,y.rawResponse);case 403:throw new $(ee.parseOrThrow(y.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),y.rawResponse);default:throw new p({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse})}switch(y.error.reason){case "non-json":throw new p({statusCode:y.error.statusCode,body:y.error.rawBody,rawResponse:y.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/attachment/upload.");case "unknown":throw new p({message:y.error.errorMessage,rawResponse:y.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Li=class{constructor(t={}){this._options=t;}access(t,e){return f.fromPromise(this.__access(t,e))}async __access(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/auth"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ds.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new K(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/auth.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getWorkspaceName(t){return f.fromPromise(this.__getWorkspaceName(t))}async __getWorkspaceName(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/auth/workspace"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:Fs.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")switch(e.error.statusCode){case 401:throw new K(e.error.body,e.rawResponse);case 403:throw new $(ee.parseOrThrow(e.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),e.rawResponse);default:throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse})}switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/auth/workspace.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Vi=class{constructor(t={}){this._options=t;}findEvaluators(t={},e){return f.fromPromise(this.__findEvaluators(t,e))}async __findEvaluators(t={},e){var S,x;let{projectId:o,id:i,name:a,filters:c,sorting:d,page:u,size:g}=t,y={};o!=null&&(y.project_id=o),i!=null&&(y.id=i),a!=null&&(y.name=a),c!=null&&(y.filters=c),d!=null&&(y.sorting=d),u!=null&&(y.page=u.toString()),g!=null&&(y.size=g.toString());let k=await R({url:b((x=(S=await s.get(this._options.baseUrl))!=null?S:await s.get(this._options.environment))!=null?x:h.Default,"v1/private/automations/evaluators"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:y,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(k.ok)return {data:dp.parseOrThrow(k.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:k.rawResponse};if(k.error.reason==="status-code")throw new p({statusCode:k.error.statusCode,body:k.error.body,rawResponse:k.rawResponse});switch(k.error.reason){case "non-json":throw new p({statusCode:k.error.statusCode,body:k.error.rawBody,rawResponse:k.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/automations/evaluators.");case "unknown":throw new p({message:k.error.errorMessage,rawResponse:k.rawResponse})}}createAutomationRuleEvaluator(t,e){return f.fromPromise(this.__createAutomationRuleEvaluator(t,e))}async __createAutomationRuleEvaluator(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/automations/evaluators"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ip.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/automations/evaluators.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteAutomationRuleEvaluatorBatch(t,e){return f.fromPromise(this.__deleteAutomationRuleEvaluatorBatch(t,e))}async __deleteAutomationRuleEvaluatorBatch(t,e){var d,u;let{projectId:o,body:i}=t,a={};o!=null&&(a.project_id=o);let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,"v1/private/automations/evaluators/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:a,requestType:"json",body:W.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(c.ok)return {data:void 0,rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/automations/evaluators/delete.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}getEvaluatorById(t,e={},o){return f.fromPromise(this.__getEvaluatorById(t,e,o))}async __getEvaluatorById(t,e={},o){var d,u;let{projectId:i}=e,a={};i!=null&&(a.project_id=i);let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(c.ok)return {data:up.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/automations/evaluators/{id}.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}updateAutomationRuleEvaluator(t,e,o){return f.fromPromise(this.__updateAutomationRuleEvaluator(t,e,o))}async __updateAutomationRuleEvaluator(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:kp.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/automations/evaluators/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getEvaluatorLogsById(t,e={},o){return f.fromPromise(this.__getEvaluatorLogsById(t,e,o))}async __getEvaluatorLogsById(t,e={},o){var d,u;let{size:i}=e,a={};i!=null&&(a.size=i.toString());let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,`v1/private/automations/evaluators/${encodeURIComponent(t)}/logs`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(c.ok)return {data:fp.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/automations/evaluators/{id}/logs.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Hi=class{constructor(t={}){this._options=t;}createChatCompletions(t={},e){return f.fromPromise(this.__createChatCompletions(t,e))}async __createChatCompletions(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/chat/completions"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:po.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Pp.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/chat/completions.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Ji=class{constructor(t={}){this._options=t;}findDatasets(t={},e){return f.fromPromise(this.__findDatasets(t,e))}async __findDatasets(t={},e){var x,_;let{page:o,size:i,withExperimentsOnly:a,withOptimizationsOnly:c,promptId:d,name:u,sorting:g,filters:y}=t,k={};o!=null&&(k.page=o.toString()),i!=null&&(k.size=i.toString()),a!=null&&(k.with_experiments_only=a.toString()),c!=null&&(k.with_optimizations_only=c.toString()),d!=null&&(k.prompt_id=d),u!=null&&(k.name=u),g!=null&&(k.sorting=g),y!=null&&(k.filters=y);let S=await R({url:b((_=(x=await s.get(this._options.baseUrl))!=null?x:await s.get(this._options.environment))!=null?_:h.Default,"v1/private/datasets"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:k,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(S.ok)return {data:Kp.parseOrThrow(S.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:S.rawResponse};if(S.error.reason==="status-code")throw new p({statusCode:S.error.statusCode,body:S.error.body,rawResponse:S.rawResponse});switch(S.error.reason){case "non-json":throw new p({statusCode:S.error.statusCode,body:S.error.rawBody,rawResponse:S.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets.");case "unknown":throw new p({message:S.error.errorMessage,rawResponse:S.rawResponse})}}createDataset(t,e){return f.fromPromise(this.__createDataset(t,e))}async __createDataset(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ur.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createOrUpdateDatasetItems(t,e){return f.fromPromise(this.__createOrUpdateDatasetItems(t,e))}async __createOrUpdateDatasetItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets/items"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:gr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/datasets/items.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createDatasetItemsFromSpans(t,e,o){return f.fromPromise(this.__createDatasetItemsFromSpans(t,e,o))}async __createDatasetItemsFromSpans(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/from-spans`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:wr.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/{dataset_id}/items/from-spans.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}createDatasetItemsFromTraces(t,e,o){return f.fromPromise(this.__createDatasetItemsFromTraces(t,e,o))}async __createDatasetItemsFromTraces(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/from-traces`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:fr.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/{dataset_id}/items/from-traces.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getDatasetById(t,e){return f.fromPromise(this.__getDatasetById(t,e))}async __getDatasetById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Qe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateDataset(t,e,o){return f.fromPromise(this.__updateDataset(t,e,o))}async __updateDataset(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:hr.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/datasets/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteDataset(t,e){return f.fromPromise(this.__deleteDataset(t,e))}async __deleteDataset(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/datasets/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/datasets/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteDatasetByName(t,e){return f.fromPromise(this.__deleteDatasetByName(t,e))}async __deleteDatasetByName(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Rr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteDatasetItems(t,e){return f.fromPromise(this.__deleteDatasetItems(t,e))}async __deleteDatasetItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets/items/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:br.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/items/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteDatasetsBatch(t,e){return f.fromPromise(this.__deleteDatasetsBatch(t,e))}async __deleteDatasetsBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets/delete-batch"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/delete-batch.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}expandDataset(t,e,o){return f.fromPromise(this.__expandDataset(t,e,o))}async __expandDataset(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/expansions`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:yr.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:Ip.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/{id}/expansions.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}findDatasetItemsWithExperimentItems(t,e,o){return f.fromPromise(this.__findDatasetItemsWithExperimentItems(t,e,o))}async __findDatasetItemsWithExperimentItems(t,e,o){var x,_;let{page:i,size:a,experimentIds:c,filters:d,sorting:u,search:g,truncate:y}=e,k={};i!=null&&(k.page=i.toString()),a!=null&&(k.size=a.toString()),k.experiment_ids=c,d!=null&&(k.filters=d),u!=null&&(k.sorting=u),g!=null&&(k.search=g),y!=null&&(k.truncate=y.toString());let S=await R({url:b((_=(x=await s.get(this._options.baseUrl))!=null?x:await s.get(this._options.environment))!=null?_:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:k,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(S.ok)return {data:Hp.parseOrThrow(S.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:S.rawResponse};if(S.error.reason==="status-code")throw new p({statusCode:S.error.statusCode,body:S.error.body,rawResponse:S.rawResponse});switch(S.error.reason){case "non-json":throw new p({statusCode:S.error.statusCode,body:S.error.rawBody,rawResponse:S.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items.");case "unknown":throw new p({message:S.error.errorMessage,rawResponse:S.rawResponse})}}getDatasetByIdentifier(t,e){return f.fromPromise(this.__getDatasetByIdentifier(t,e))}async __getDatasetByIdentifier(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets/retrieve"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:kr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Qe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/retrieve.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getDatasetExperimentItemsStats(t,e,o){return f.fromPromise(this.__getDatasetExperimentItemsStats(t,e,o))}async __getDatasetExperimentItemsStats(t,e,o){var u,g;let{experimentIds:i,filters:a}=e,c={};c.experiment_ids=i,a!=null&&(c.filters=a);let d=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items/stats`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:c,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(d.ok)return {data:Ne.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")throw new p({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse});switch(d.error.reason){case "non-json":throw new p({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items/stats.");case "unknown":throw new p({message:d.error.errorMessage,rawResponse:d.rawResponse})}}getDatasetItemById(t,e){return f.fromPromise(this.__getDatasetItemById(t,e))}async __getDatasetItemById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/datasets/items/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Do.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/items/{itemId}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getDatasetItems(t,e={},o){return f.fromPromise(this.__getDatasetItems(t,e,o))}async __getDatasetItems(t,e={},o){var y,k;let{page:i,size:a,filters:c,truncate:d}=e,u={};i!=null&&(u.page=i.toString()),a!=null&&(u.size=a.toString()),c!=null&&(u.filters=c),d!=null&&(u.truncate=d.toString());let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/items`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(g.ok)return {data:oc.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse});switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}getDatasetItemsOutputColumns(t,e={},o){return f.fromPromise(this.__getDatasetItemsOutputColumns(t,e,o))}async __getDatasetItemsOutputColumns(t,e={},o){var d,u;let{experimentIds:i}=e,a={};i!=null&&(a.experiment_ids=i);let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,`v1/private/datasets/${encodeURIComponent(t)}/items/experiments/items/output/columns`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(c.ok)return {data:ac.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/datasets/{id}/items/experiments/items/output/columns.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}streamDatasetItems(t,e){return f.fromPromise(this.__streamDatasetItems(t,e))}async __streamDatasetItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/datasets/items/stream"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:zr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/datasets/items/stream.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Ki=class{constructor(t={}){this._options=t;}findExperiments(t={},e){return f.fromPromise(this.__findExperiments(t,e))}async __findExperiments(t={},e){var M,N;let{page:o,size:i,datasetId:a,optimizationId:c,types:d,name:u,datasetDeleted:g,promptId:y,sorting:k,filters:S}=t,x={};o!=null&&(x.page=o.toString()),i!=null&&(x.size=i.toString()),a!=null&&(x.datasetId=a),c!=null&&(x.optimization_id=c),d!=null&&(x.types=d),u!=null&&(x.name=u),g!=null&&(x.dataset_deleted=g.toString()),y!=null&&(x.prompt_id=y),k!=null&&(x.sorting=k),S!=null&&(x.filters=S);let _=await R({url:b((N=(M=await s.get(this._options.baseUrl))!=null?M:await s.get(this._options.environment))!=null?N:h.Default,"v1/private/experiments"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:x,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(_.ok)return {data:Rc.parseOrThrow(_.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:_.rawResponse};if(_.error.reason==="status-code")switch(_.error.statusCode){case 400:throw new T(_.error.body,_.rawResponse);default:throw new p({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse})}switch(_.error.reason){case "non-json":throw new p({statusCode:_.error.statusCode,body:_.error.rawBody,rawResponse:_.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments.");case "unknown":throw new p({message:_.error.errorMessage,rawResponse:_.rawResponse})}}createExperiment(t,e){return f.fromPromise(this.__createExperiment(t,e))}async __createExperiment(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Sr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createExperimentItems(t,e){return f.fromPromise(this.__createExperimentItems(t,e))}async __createExperimentItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/items"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:_r.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/items.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteExperimentItems(t,e){return f.fromPromise(this.__deleteExperimentItems(t,e))}async __deleteExperimentItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/items/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Tr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/items/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteExperimentsById(t,e){return f.fromPromise(this.__deleteExperimentsById(t,e))}async __deleteExperimentsById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ye.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}experimentItemsBulk(t,e){return f.fromPromise(this.__experimentItemsBulk(t,e))}async __experimentItemsBulk(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/items/bulk"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Er.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 409:throw new L(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/experiments/items/bulk.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}findFeedbackScoreNames(t={},e){return f.fromPromise(this.__findFeedbackScoreNames(t,e))}async __findFeedbackScoreNames(t={},e){var c,d;let{experimentIds:o}=t,i={};o!=null&&(i.experiment_ids=o);let a=await R({url:b((d=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?d:h.Default,"v1/private/experiments/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:Xe.findFeedbackScoreNames.Response.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/feedback-scores/names.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}findExperimentGroups(t={},e){return f.fromPromise(this.__findExperimentGroups(t,e))}async __findExperimentGroups(t={},e){var g,y;let{groups:o,types:i,name:a,filters:c}=t,d={};o!=null&&(d.groups=o),i!=null&&(d.types=i),a!=null&&(d.name=a),c!=null&&(d.filters=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/private/experiments/groups"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:zc.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new T(u.error.body,u.rawResponse);default:throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/groups.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}findExperimentGroupsAggregations(t={},e){return f.fromPromise(this.__findExperimentGroupsAggregations(t,e))}async __findExperimentGroupsAggregations(t={},e){var g,y;let{groups:o,types:i,name:a,filters:c}=t,d={};o!=null&&(d.groups=o),i!=null&&(d.types=i),a!=null&&(d.name=a),c!=null&&(d.filters=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/private/experiments/groups/aggregations"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:_c.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new T(u.error.body,u.rawResponse);default:throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/groups/aggregations.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}finishExperiments(t,e){return f.fromPromise(this.__finishExperiments(t,e))}async __finishExperiments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/finish"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ye.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/finish.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getExperimentById(t,e){return f.fromPromise(this.__getExperimentById(t,e))}async __getExperimentById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/experiments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Wo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateExperiment(t,e={},o){return f.fromPromise(this.__updateExperiment(t,e,o))}async __updateExperiment(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/experiments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Pr.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/experiments/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getExperimentItemById(t,e){return f.fromPromise(this.__getExperimentItemById(t,e))}async __getExperimentItemById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/experiments/items/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Mo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/experiments/items/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}streamExperimentItems(t,e){return f.fromPromise(this.__streamExperimentItems(t,e))}async __streamExperimentItems(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/items/stream"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:vr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/items/stream.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}streamExperiments(t,e){return f.fromPromise(this.__streamExperiments(t,e))}async __streamExperiments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/experiments/stream"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Cr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/experiments/stream.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Xi=class{constructor(t={}){this._options=t;}findFeedbackDefinitions(t={},e){return f.fromPromise(this.__findFeedbackDefinitions(t,e))}async __findFeedbackDefinitions(t={},e){var g,y;let{page:o,size:i,name:a,type:c}=t,d={};o!=null&&(d.page=o.toString()),i!=null&&(d.size=i.toString()),a!=null&&(d.name=a),c!=null&&(d.type=Zt.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"}));let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/private/feedback-definitions"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:Xc.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse});switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/feedback-definitions.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}createFeedbackDefinition(t,e){return f.fromPromise(this.__createFeedbackDefinition(t,e))}async __createFeedbackDefinition(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/feedback-definitions"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Bc.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/feedback-definitions.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getFeedbackDefinitionById(t,e){return f.fromPromise(this.__getFeedbackDefinitionById(t,e))}async __getFeedbackDefinitionById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:$c.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/feedback-definitions/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateFeedbackDefinition(t,e,o){return f.fromPromise(this.__updateFeedbackDefinition(t,e,o))}async __updateFeedbackDefinition(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:tl.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/feedback-definitions/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteFeedbackDefinitionById(t,e){return f.fromPromise(this.__deleteFeedbackDefinitionById(t,e))}async __deleteFeedbackDefinitionById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/feedback-definitions/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new L(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/feedback-definitions/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteFeedbackDefinitionsBatch(t,e){return f.fromPromise(this.__deleteFeedbackDefinitionsBatch(t,e))}async __deleteFeedbackDefinitionsBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/feedback-definitions/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new L(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/feedback-definitions/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Gi=class{constructor(t={}){this._options=t;}createGuardrails(t,e){return f.fromPromise(this.__createGuardrails(t,e))}async __createGuardrails(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/guardrails"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:co.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/guardrails.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var $i=class{constructor(t={}){this._options=t;}deleteLlmProviderApiKeysBatch(t,e){return f.fromPromise(this.__deleteLlmProviderApiKeysBatch(t,e))}async __deleteLlmProviderApiKeysBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/llm-provider-key/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/llm-provider-key/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}findLlmProviderKeys(t){return f.fromPromise(this.__findLlmProviderKeys(t))}async __findLlmProviderKeys(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/llm-provider-key"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:pl.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/llm-provider-key.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}storeLlmProviderApiKey(t,e){return f.fromPromise(this.__storeLlmProviderApiKey(t,e))}async __storeLlmProviderApiKey(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/llm-provider-key"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ir.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new K(o.error.body,o.rawResponse);case 403:throw new $(ee.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/llm-provider-key.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getLlmProviderApiKeyById(t,e){return f.fromPromise(this.__getLlmProviderApiKeyById(t,e))}async __getLlmProviderApiKeyById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/llm-provider-key/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Ho.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/llm-provider-key/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateLlmProviderApiKey(t,e={},o){return f.fromPromise(this.__updateLlmProviderApiKey(t,e,o))}async __updateLlmProviderApiKey(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/llm-provider-key/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:jr.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 401:throw new K(i.error.body,i.rawResponse);case 403:throw new $(ee.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/llm-provider-key/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Qi=class{constructor(t={}){this._options=t;}evaluateThreads(t,e){return f.fromPromise(this.__evaluateThreads(t,e))}async __evaluateThreads(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/manual-evaluation/threads"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ui.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:ji.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/manual-evaluation/threads.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}evaluateTraces(t,e){return f.fromPromise(this.__evaluateTraces(t,e))}async __evaluateTraces(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/manual-evaluation/traces"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ui.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:ji.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/manual-evaluation/traces.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Yi=class{constructor(t={}){this._options=t;}receiveProtobufTraces(t){return f.fromPromise(this.__receiveProtobufTraces(t))}async __receiveProtobufTraces(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/otel/v1/traces"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:e.body,rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/otel/v1/traces.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Zi=class{constructor(t={}){this._options=t;}findOptimizations(t={},e){return f.fromPromise(this.__findOptimizations(t,e))}async __findOptimizations(t={},e){var y,k;let{page:o,size:i,datasetId:a,name:c,datasetDeleted:d}=t,u={};o!=null&&(u.page=o.toString()),i!=null&&(u.size=i.toString()),a!=null&&(u.dataset_id=a),c!=null&&(u.name=c),d!=null&&(u.dataset_deleted=d.toString());let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:h.Default,"v1/private/optimizations"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(g.ok)return {data:gl.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new T(g.error.body,g.rawResponse);default:throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/optimizations.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}createOptimization(t,e){return f.fromPromise(this.__createOptimization(t,e))}async __createOptimization(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/optimizations"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ni.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/optimizations.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}upsertOptimization(t,e){return f.fromPromise(this.__upsertOptimization(t,e))}async __upsertOptimization(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/optimizations"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ni.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/optimizations.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteOptimizationsById(t,e){return f.fromPromise(this.__deleteOptimizationsById(t,e))}async __deleteOptimizationsById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/optimizations/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ye.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/optimizations/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getOptimizationById(t,e){return f.fromPromise(this.__getOptimizationById(t,e))}async __getOptimizationById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/optimizations/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Jo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/optimizations/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateOptimizationsById(t,e={},o){return f.fromPromise(this.__updateOptimizationsById(t,e,o))}async __updateOptimizationsById(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/optimizations/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Ur.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/optimizations/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var qi=class{constructor(t={}){this._options=t;}findProjects(t={},e){return f.fromPromise(this.__findProjects(t,e))}async __findProjects(t={},e){var g,y;let{page:o,size:i,name:a,sorting:c}=t,d={};o!=null&&(d.page=o.toString()),i!=null&&(d.size=i.toString()),a!=null&&(d.name=a),c!=null&&(d.sorting=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/private/projects"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:hl.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse});switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/projects.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}createProject(t,e){return f.fromPromise(this.__createProject(t,e))}async __createProject(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/projects"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Nr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/projects.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getProjectById(t,e){return f.fromPromise(this.__getProjectById(t,e))}async __getProjectById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Xo.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/projects/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteProjectById(t,e){return f.fromPromise(this.__deleteProjectById(t,e))}async __deleteProjectById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new L(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/projects/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateProject(t,e={},o){return f.fromPromise(this.__updateProject(t,e,o))}async __updateProject(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/projects/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Mr.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);case 422:throw new F(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/projects/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteProjectsBatch(t,e){return f.fromPromise(this.__deleteProjectsBatch(t,e))}async __deleteProjectsBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/projects/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/projects/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}findFeedbackScoreNamesByProjectIds(t={},e){return f.fromPromise(this.__findFeedbackScoreNamesByProjectIds(t,e))}async __findFeedbackScoreNamesByProjectIds(t={},e){var c,d;let{projectIds:o}=t,i={};o!=null&&(i.project_ids=o);let a=await R({url:b((d=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?d:h.Default,"v1/private/projects/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:bl.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/projects/feedback-scores/names.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}getProjectMetrics(t,e={},o){return f.fromPromise(this.__getProjectMetrics(t,e,o))}async __getProjectMetrics(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/projects/${encodeURIComponent(t)}/metrics`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Dr.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:xl.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/projects/{id}/metrics.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getProjectStats(t={},e){return f.fromPromise(this.__getProjectStats(t,e))}async __getProjectStats(t={},e){var g,y;let{page:o,size:i,name:a,sorting:c}=t,d={};o!=null&&(d.page=o.toString()),i!=null&&(d.size=i.toString()),a!=null&&(d.name=a),c!=null&&(d.sorting=c);let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/private/projects/stats"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:Tl.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse});switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/projects/stats.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}retrieveProject(t,e){return f.fromPromise(this.__retrieveProject(t,e))}async __retrieveProject(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/projects/retrieve"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Fr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Cl.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 404:throw new A(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/projects/retrieve.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ea=class{constructor(t={}){this._options=t;}getPrompts(t={},e){return f.fromPromise(this.__getPrompts(t,e))}async __getPrompts(t={},e){var y,k;let{page:o,size:i,name:a,sorting:c,filters:d}=t,u={};o!=null&&(u.page=o.toString()),i!=null&&(u.size=i.toString()),a!=null&&(u.name=a),c!=null&&(u.sorting=c),d!=null&&(u.filters=d);let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:h.Default,"v1/private/prompts"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(g.ok)return {data:Bl.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse});switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/prompts.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}createPrompt(t,e){return f.fromPromise(this.__createPrompt(t,e))}async __createPrompt(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/prompts"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Or.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 409:throw new L(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createPromptVersion(t,e){return f.fromPromise(this.__createPromptVersion(t,e))}async __createPromptVersion(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/prompts/versions"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Wr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:fe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 409:throw new L(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts/versions.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getPromptById(t,e){return f.fromPromise(this.__getPromptById(t,e))}async __getPromptById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Nl.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/prompts/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updatePrompt(t,e,o){return f.fromPromise(this.__updatePrompt(t,e,o))}async __updatePrompt(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Br.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);case 404:throw new A(i.error.body,i.rawResponse);case 409:throw new L(i.error.body,i.rawResponse);case 422:throw new F(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/prompts/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deletePrompt(t,e){return f.fromPromise(this.__deletePrompt(t,e))}async __deletePrompt(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/prompts/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/prompts/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deletePromptsBatch(t,e){return f.fromPromise(this.__deletePromptsBatch(t,e))}async __deletePromptsBatch(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/prompts/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getPromptVersionById(t,e){return f.fromPromise(this.__getPromptVersionById(t,e))}async __getPromptVersionById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/prompts/versions/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:fe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/prompts/versions/{versionId}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getPromptVersions(t,e={},o){return f.fromPromise(this.__getPromptVersions(t,e,o))}async __getPromptVersions(t,e={},o){var u,g;let{page:i,size:a}=e,c={};i!=null&&(c.page=i.toString()),a!=null&&(c.size=a.toString());let d=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:h.Default,`v1/private/prompts/${encodeURIComponent(t)}/versions`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:c,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(d.ok)return {data:Ol.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")throw new p({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse});switch(d.error.reason){case "non-json":throw new p({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/prompts/{id}/versions.");case "unknown":throw new p({message:d.error.errorMessage,rawResponse:d.rawResponse})}}restorePromptVersion(t,e,o){return f.fromPromise(this.__restorePromptVersion(t,e,o))}async __restorePromptVersion(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/prompts/${encodeURIComponent(t)}/versions/${encodeURIComponent(e)}/restore`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:fe.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new T(i.error.body,i.rawResponse);case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts/{promptId}/versions/{versionId}/restore.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}retrievePromptVersion(t,e){return f.fromPromise(this.__retrievePromptVersion(t,e))}async __retrievePromptVersion(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/prompts/versions/retrieve"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Lr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:fe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 404:throw new A(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/prompts/versions/retrieve.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ra=class{constructor(t={}){this._options=t;}getServiceToggles(t){return f.fromPromise(this.__getServiceToggles(t))}async __getServiceToggles(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/toggles"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:Ll.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/toggles.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var oa=class{constructor(t={}){this._options=t;}addSpanComment(t,e,o){return f.fromPromise(this.__addSpanComment(t,e,o))}async __addSpanComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/spans/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/{id}/comments.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}addSpanFeedbackScore(t,e,o){return f.fromPromise(this.__addSpanFeedbackScore(t,e,o))}async __addSpanFeedbackScore(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/spans/${encodeURIComponent(t)}/feedback-scores`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Y.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/spans/{id}/feedback-scores.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getSpansByProject(t={},e){return f.fromPromise(this.__getSpansByProject(t,e))}async __getSpansByProject(t={},e){var q,Be;let{page:o,size:i,projectName:a,projectId:c,traceId:d,type:u,filters:g,truncate:y,stripAttachments:k,sorting:S,exclude:x,fromTime:_,toTime:M}=t,N={};o!=null&&(N.page=o.toString()),i!=null&&(N.size=i.toString()),a!=null&&(N.project_name=a),c!=null&&(N.project_id=c),d!=null&&(N.trace_id=d),u!=null&&(N.type=mi.jsonOrThrow(u,{unrecognizedObjectKeys:"strip"})),g!=null&&(N.filters=g),y!=null&&(N.truncate=y.toString()),k!=null&&(N.strip_attachments=k.toString()),S!=null&&(N.sorting=S),x!=null&&(N.exclude=x),_!=null&&(N.from_time=_.toISOString()),M!=null&&(N.to_time=M.toISOString());let J=await R({url:b((Be=(q=await s.get(this._options.baseUrl))!=null?q:await s.get(this._options.environment))!=null?Be:h.Default,"v1/private/spans"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:N,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(J.ok)return {data:Xl.parseOrThrow(J.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:J.rawResponse};if(J.error.reason==="status-code")throw new p({statusCode:J.error.statusCode,body:J.error.body,rawResponse:J.rawResponse});switch(J.error.reason){case "non-json":throw new p({statusCode:J.error.statusCode,body:J.error.rawBody,rawResponse:J.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans.");case "unknown":throw new p({message:J.error.errorMessage,rawResponse:J.rawResponse})}}createSpan(t,e){return f.fromPromise(this.__createSpan(t,e))}async __createSpan(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/spans"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Hr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new L(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createSpans(t,e){return f.fromPromise(this.__createSpans(t,e))}async __createSpans(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/spans/batch"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Jr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/batch.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getSpanById(t,e={},o){return f.fromPromise(this.__getSpanById(t,e,o))}async __getSpanById(t,e={},o){var d,u;let{stripAttachments:i}=e,a={};i!=null&&(a.strip_attachments=i.toString());let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(c.ok)return {data:Yo.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 404:throw new A(c.error.body,c.rawResponse);default:throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans/{id}.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}deleteSpanById(t,e){return f.fromPromise(this.__deleteSpanById(t,e))}async __deleteSpanById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 501:throw new sr(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/spans/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateSpan(t,e,o){return f.fromPromise(this.__updateSpan(t,e,o))}async __updateSpan(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/spans/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Kr.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/spans/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteSpanComments(t,e){return f.fromPromise(this.__deleteSpanComments(t,e))}async __deleteSpanComments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/spans/comments/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/comments/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteSpanFeedbackScore(t,e,o){return f.fromPromise(this.__deleteSpanFeedbackScore(t,e,o))}async __deleteSpanFeedbackScore(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/spans/${encodeURIComponent(t)}/feedback-scores/delete`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Go.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/{id}/feedback-scores/delete.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}findFeedbackScoreNames1(t={},e){return f.fromPromise(this.__findFeedbackScoreNames1(t,e))}async __findFeedbackScoreNames1(t={},e){var d,u;let{projectId:o,type:i}=t,a={};o!=null&&(a.project_id=o),i!=null&&(a.type=ui.jsonOrThrow(i,{unrecognizedObjectKeys:"strip"}));let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,"v1/private/spans/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(c.ok)return {data:Ge.findFeedbackScoreNames1.Response.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans/feedback-scores/names.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}getSpanComment(t,e,o){return f.fromPromise(this.__getSpanComment(t,e,o))}async __getSpanComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/spans/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:B.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans/{spanId}/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getSpanStats(t={},e){return f.fromPromise(this.__getSpanStats(t,e))}async __getSpanStats(t={},e){var S,x;let{projectId:o,projectName:i,traceId:a,type:c,filters:d,fromTime:u,toTime:g}=t,y={};o!=null&&(y.project_id=o),i!=null&&(y.project_name=i),a!=null&&(y.trace_id=a),c!=null&&(y.type=gi.jsonOrThrow(c,{unrecognizedObjectKeys:"strip"})),d!=null&&(y.filters=d),u!=null&&(y.from_time=u.toISOString()),g!=null&&(y.to_time=g.toISOString());let k=await R({url:b((x=(S=await s.get(this._options.baseUrl))!=null?S:await s.get(this._options.environment))!=null?x:h.Default,"v1/private/spans/stats"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:y,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(k.ok)return {data:Ne.parseOrThrow(k.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:k.rawResponse};if(k.error.reason==="status-code")throw new p({statusCode:k.error.statusCode,body:k.error.body,rawResponse:k.rawResponse});switch(k.error.reason){case "non-json":throw new p({statusCode:k.error.statusCode,body:k.error.rawBody,rawResponse:k.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/spans/stats.");case "unknown":throw new p({message:k.error.errorMessage,rawResponse:k.rawResponse})}}scoreBatchOfSpans(t,e){return f.fromPromise(this.__scoreBatchOfSpans(t,e))}async __scoreBatchOfSpans(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/spans/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Zo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/spans/feedback-scores.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}searchSpans(t={},e){return f.fromPromise(this.__searchSpans(t,e))}async __searchSpans(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/spans/search"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Xr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/spans/search.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateSpanComment(t,e,o){return f.fromPromise(this.__updateSpanComment(t,e,o))}async __updateSpanComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/spans/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/spans/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ta=class{constructor(t={}){this._options=t;}addThreadComment(t,e,o){return f.fromPromise(this.__addThreadComment(t,e,o))}async __addThreadComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/threads/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/{id}/comments.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}addTraceComment(t,e,o){return f.fromPromise(this.__addTraceComment(t,e,o))}async __addTraceComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/${encodeURIComponent(t)}/comments`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/{id}/comments.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}addTraceFeedbackScore(t,e,o){return f.fromPromise(this.__addTraceFeedbackScore(t,e,o))}async __addTraceFeedbackScore(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/${encodeURIComponent(t)}/feedback-scores`),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Y.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/{id}/feedback-scores.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}closeTraceThread(t={},e){return f.fromPromise(this.__closeTraceThread(t,e))}async __closeTraceThread(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/close"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Gr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/threads/close.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getTracesByProject(t={},e){return f.fromPromise(this.__getTracesByProject(t,e))}async __getTracesByProject(t={},e){var N,J;let{page:o,size:i,projectName:a,projectId:c,filters:d,truncate:u,stripAttachments:g,sorting:y,exclude:k,fromTime:S,toTime:x}=t,_={};o!=null&&(_.page=o.toString()),i!=null&&(_.size=i.toString()),a!=null&&(_.project_name=a),c!=null&&(_.project_id=c),d!=null&&(_.filters=d),u!=null&&(_.truncate=u.toString()),g!=null&&(_.strip_attachments=g.toString()),y!=null&&(_.sorting=y),k!=null&&(_.exclude=k),S!=null&&(_.from_time=S.toISOString()),x!=null&&(_.to_time=x.toISOString());let M=await R({url:b((J=(N=await s.get(this._options.baseUrl))!=null?N:await s.get(this._options.environment))!=null?J:h.Default,"v1/private/traces"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:_,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(M.ok)return {data:tm.parseOrThrow(M.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:M.rawResponse};if(M.error.reason==="status-code")throw new p({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse});switch(M.error.reason){case "non-json":throw new p({statusCode:M.error.statusCode,body:M.error.rawBody,rawResponse:M.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces.");case "unknown":throw new p({message:M.error.errorMessage,rawResponse:M.rawResponse})}}createTrace(t,e){return f.fromPromise(this.__createTrace(t,e))}async __createTrace(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:$r.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createTraces(t,e){return f.fromPromise(this.__createTraces(t,e))}async __createTraces(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/batch"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Qr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/batch.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getTraceById(t,e={},o){return f.fromPromise(this.__getTraceById(t,e,o))}async __getTraceById(t,e={},o){var d,u;let{stripAttachments:i}=e,a={};i!=null&&(a.strip_attachments=i.toString());let c=await R({url:b((u=(d=await s.get(this._options.baseUrl))!=null?d:await s.get(this._options.environment))!=null?u:h.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",queryParameters:a,requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(c.ok)return {data:qo.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")throw new p({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse});switch(c.error.reason){case "non-json":throw new p({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/{id}.");case "unknown":throw new p({message:c.error.errorMessage,rawResponse:c.rawResponse})}}deleteTraceById(t,e){return f.fromPromise(this.__deleteTraceById(t,e))}async __deleteTraceById(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/traces/{id}.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateTrace(t,e={},o){return f.fromPromise(this.__updateTrace(t,e,o))}async __updateTrace(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Yr.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/traces/{id}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteThreadComments(t,e){return f.fromPromise(this.__deleteThreadComments(t,e))}async __deleteThreadComments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/comments/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/comments/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteThreadFeedbackScores(t,e){return f.fromPromise(this.__deleteThreadFeedbackScores(t,e))}async __deleteThreadFeedbackScores(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/feedback-scores/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Zr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/feedback-scores/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteTraceComments(t,e){return f.fromPromise(this.__deleteTraceComments(t,e))}async __deleteTraceComments(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/comments/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/comments/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteTraceFeedbackScore(t,e,o){return f.fromPromise(this.__deleteTraceFeedbackScore(t,e,o))}async __deleteTraceFeedbackScore(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/${encodeURIComponent(t)}/feedback-scores/delete`),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:Go.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse});switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/{id}/feedback-scores/delete.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}deleteTraceThreads(t,e){return f.fromPromise(this.__deleteTraceThreads(t,e))}async __deleteTraceThreads(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:qr.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteTraces(t,e){return f.fromPromise(this.__deleteTraces(t,e))}async __deleteTraces(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/delete"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:W.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/delete.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}findFeedbackScoreNames2(t={},e){return f.fromPromise(this.__findFeedbackScoreNames2(t,e))}async __findFeedbackScoreNames2(t={},e){var c,d;let{projectId:o}=t,i={};o!=null&&(i.project_id=o);let a=await R({url:b((d=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?d:h.Default,"v1/private/traces/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:je.findFeedbackScoreNames2.Response.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/feedback-scores/names.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}findTraceThreadsFeedbackScoreNames(t,e){return f.fromPromise(this.__findTraceThreadsFeedbackScoreNames(t,e))}async __findTraceThreadsFeedbackScoreNames(t,e){var c,d;let{projectId:o}=t,i={};i.project_id=o;let a=await R({url:b((d=(c=await s.get(this._options.baseUrl))!=null?c:await s.get(this._options.environment))!=null?d:h.Default,"v1/private/traces/threads/feedback-scores/names"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:i,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(a.ok)return {data:je.findTraceThreadsFeedbackScoreNames.Response.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")throw new p({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse});switch(a.error.reason){case "non-json":throw new p({statusCode:a.error.statusCode,body:a.error.rawBody,rawResponse:a.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/threads/feedback-scores/names.");case "unknown":throw new p({message:a.error.errorMessage,rawResponse:a.rawResponse})}}getTraceStats(t={},e){return f.fromPromise(this.__getTraceStats(t,e))}async __getTraceStats(t={},e){var y,k;let{projectId:o,projectName:i,filters:a,fromTime:c,toTime:d}=t,u={};o!=null&&(u.project_id=o),i!=null&&(u.project_name=i),a!=null&&(u.filters=a),c!=null&&(u.from_time=c.toISOString()),d!=null&&(u.to_time=d.toISOString());let g=await R({url:b((k=(y=await s.get(this._options.baseUrl))!=null?y:await s.get(this._options.environment))!=null?k:h.Default,"v1/private/traces/stats"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:u,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(g.ok)return {data:Ne.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")throw new p({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse});switch(g.error.reason){case "non-json":throw new p({statusCode:g.error.statusCode,body:g.error.rawBody,rawResponse:g.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/stats.");case "unknown":throw new p({message:g.error.errorMessage,rawResponse:g.rawResponse})}}getThreadComment(t,e,o){return f.fromPromise(this.__getThreadComment(t,e,o))}async __getThreadComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/threads/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:B.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/threads/{threadId}/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getTraceComment(t,e,o){return f.fromPromise(this.__getTraceComment(t,e,o))}async __getTraceComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:B.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/{traceId}/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}getTraceThread(t,e){return f.fromPromise(this.__getTraceThread(t,e))}async __getTraceThread(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/retrieve"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Mi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:et.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new A(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/retrieve.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getTraceThreads(t={},e){return f.fromPromise(this.__getTraceThreads(t,e))}async __getTraceThreads(t={},e){var M,N;let{page:o,size:i,projectName:a,projectId:c,truncate:d,stripAttachments:u,filters:g,sorting:y,fromTime:k,toTime:S}=t,x={};o!=null&&(x.page=o.toString()),i!=null&&(x.size=i.toString()),a!=null&&(x.project_name=a),c!=null&&(x.project_id=c),d!=null&&(x.truncate=d.toString()),u!=null&&(x.strip_attachments=u.toString()),g!=null&&(x.filters=g),y!=null&&(x.sorting=y),k!=null&&(x.from_time=k.toISOString()),S!=null&&(x.to_time=S.toISOString());let _=await R({url:b((N=(M=await s.get(this._options.baseUrl))!=null?M:await s.get(this._options.environment))!=null?N:h.Default,"v1/private/traces/threads"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:x,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(_.ok)return {data:om.parseOrThrow(_.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:_.rawResponse};if(_.error.reason==="status-code")throw new p({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse});switch(_.error.reason){case "non-json":throw new p({statusCode:_.error.statusCode,body:_.error.rawBody,rawResponse:_.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/traces/threads.");case "unknown":throw new p({message:_.error.errorMessage,rawResponse:_.rawResponse})}}openTraceThread(t,e){return f.fromPromise(this.__openTraceThread(t,e))}async __openTraceThread(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/open"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Mi.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/threads/open.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}scoreBatchOfThreads(t,e){return f.fromPromise(this.__scoreBatchOfThreads(t,e))}async __scoreBatchOfThreads(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:eo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/threads/feedback-scores.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}scoreBatchOfTraces(t,e){return f.fromPromise(this.__scoreBatchOfTraces(t,e))}async __scoreBatchOfTraces(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/feedback-scores"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Zo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/traces/feedback-scores.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}searchTraceThreads(t={},e){return f.fromPromise(this.__searchTraceThreads(t,e))}async __searchTraceThreads(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/threads/search"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:ro.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/threads/search.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}searchTraces(t={},e){return f.fromPromise(this.__searchTraces(t,e))}async __searchTraces(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/traces/search"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:oo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),responseType:"streaming",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 401:throw new K(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/traces/search.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateThread(t,e={},o){return f.fromPromise(this.__updateThread(t,e,o))}async __updateThread(t,e={},o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/threads/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:to.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/traces/threads/{threadModelId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}updateThreadComment(t,e,o){return f.fromPromise(this.__updateThreadComment(t,e,o))}async __updateThreadComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/threads/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/traces/threads/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}updateTraceComment(t,e,o){return f.fromPromise(this.__updateTraceComment(t,e,o))}async __updateTraceComment(t,e,o){var a,c;let i=await R({url:b((c=(a=await s.get(this._options.baseUrl))!=null?a:await s.get(this._options.environment))!=null?c:h.Default,`v1/private/traces/comments/${encodeURIComponent(t)}`),method:"PATCH",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...o==null?void 0:o.headers},contentType:"application/json",requestType:"json",body:B.jsonOrThrow(e,{unrecognizedObjectKeys:"strip"}),timeoutMs:(o==null?void 0:o.timeoutInSeconds)!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o==null?void 0:o.maxRetries,withCredentials:true,abortSignal:o==null?void 0:o.abortSignal});if(i.ok)return {data:void 0,rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 404:throw new A(i.error.body,i.rawResponse);default:throw new p({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}switch(i.error.reason){case "non-json":throw new p({statusCode:i.error.statusCode,body:i.error.rawBody,rawResponse:i.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PATCH /v1/private/traces/comments/{commentId}.");case "unknown":throw new p({message:i.error.errorMessage,rawResponse:i.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ia=class{constructor(t={}){this._options=t;}getWelcomeWizardStatus(t){return f.fromPromise(this.__getWelcomeWizardStatus(t))}async __getWelcomeWizardStatus(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/welcome-wizard"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:im.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/welcome-wizard.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}submitWelcomeWizard(t={},e){return f.fromPromise(this.__submitWelcomeWizard(t,e))}async __submitWelcomeWizard(t={},e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/welcome-wizard"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:lo.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/welcome-wizard.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var aa=class{constructor(t={}){this._options=t;}costsSummary(t,e){return f.fromPromise(this.__costsSummary(t,e))}async __costsSummary(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/workspaces/costs/summaries"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ze.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:De.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/workspaces/costs/summaries.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getWorkspaceConfiguration(t){return f.fromPromise(this.__getWorkspaceConfiguration(t))}async __getWorkspaceConfiguration(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/workspaces/configurations"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:rt.parseOrThrow(e.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:e.rawResponse};if(e.error.reason==="status-code")switch(e.error.statusCode){case 404:throw new A(e.error.body,e.rawResponse);default:throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse})}switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/private/workspaces/configurations.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}upsertWorkspaceConfiguration(t,e){return f.fromPromise(this.__upsertWorkspaceConfiguration(t,e))}async __upsertWorkspaceConfiguration(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/workspaces/configurations"),method:"PUT",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:rt.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:rt.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);case 422:throw new F(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling PUT /v1/private/workspaces/configurations.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteWorkspaceConfiguration(t){return f.fromPromise(this.__deleteWorkspaceConfiguration(t))}async __deleteWorkspaceConfiguration(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"v1/private/workspaces/configurations"),method:"DELETE",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:void 0,rawResponse:e.rawResponse};if(e.error.reason==="status-code")switch(e.error.statusCode){case 404:throw new A(e.error.body,e.rawResponse);default:throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse})}switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling DELETE /v1/private/workspaces/configurations.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}getCost(t,e){return f.fromPromise(this.__getCost(t,e))}async __getCost(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/workspaces/costs"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ze.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Di.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/workspaces/costs.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getMetric(t,e){return f.fromPromise(this.__getMetric(t,e))}async __getMetric(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/workspaces/metrics"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ze.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:Di.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/workspaces/metrics.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}metricsSummary(t,e){return f.fromPromise(this.__metricsSummary(t,e))}async __metricsSummary(t,e){var i,a;let o=await R({url:b((a=(i=await s.get(this._options.baseUrl))!=null?i:await s.get(this._options.environment))!=null?a:h.Default,"v1/private/workspaces/metrics/summaries"),method:"POST",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",requestType:"json",body:Ze.jsonOrThrow(t,{unrecognizedObjectKeys:"strip"}),timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(o.ok)return {data:am.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:true,allowUnrecognizedEnumValues:true,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new T(o.error.body,o.rawResponse);default:throw new p({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case "non-json":throw new p({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case "timeout":throw new w("Timeout exceeded when calling POST /v1/private/workspaces/metrics/summaries.");case "unknown":throw new p({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var na=class{constructor(t={}){this._options=t;}datasetsRedirect(t,e){return f.fromPromise(this.__datasetsRedirect(t,e))}async __datasetsRedirect(t,e){var u,g;let{datasetId:o,workspaceName:i,path:a}=t,c={};c.dataset_id=o,i!=null&&(c.workspace_name=i),c.path=a;let d=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:h.Default,"v1/session/redirect/datasets"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:c,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(d.ok)return {data:void 0,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new T(d.error.body,d.rawResponse);case 404:throw new A(d.error.body,d.rawResponse);default:throw new p({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case "non-json":throw new p({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/session/redirect/datasets.");case "unknown":throw new p({message:d.error.errorMessage,rawResponse:d.rawResponse})}}experimentsRedirect(t,e){return f.fromPromise(this.__experimentsRedirect(t,e))}async __experimentsRedirect(t,e){var g,y;let{datasetId:o,experimentId:i,workspaceName:a,path:c}=t,d={};d.dataset_id=o,d.experiment_id=i,a!=null&&(d.workspace_name=a),d.path=c;let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/session/redirect/experiments"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:void 0,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new T(u.error.body,u.rawResponse);case 404:throw new A(u.error.body,u.rawResponse);default:throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/session/redirect/experiments.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}optimizationsRedirect(t,e){return f.fromPromise(this.__optimizationsRedirect(t,e))}async __optimizationsRedirect(t,e){var g,y;let{datasetId:o,optimizationId:i,workspaceName:a,path:c}=t,d={};d.dataset_id=o,d.optimization_id=i,a!=null&&(d.workspace_name=a),d.path=c;let u=await R({url:b((y=(g=await s.get(this._options.baseUrl))!=null?g:await s.get(this._options.environment))!=null?y:h.Default,"v1/session/redirect/optimizations"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:d,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(u.ok)return {data:void 0,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new T(u.error.body,u.rawResponse);case 404:throw new A(u.error.body,u.rawResponse);default:throw new p({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case "non-json":throw new p({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/session/redirect/optimizations.");case "unknown":throw new p({message:u.error.errorMessage,rawResponse:u.rawResponse})}}projectsRedirect(t,e){return f.fromPromise(this.__projectsRedirect(t,e))}async __projectsRedirect(t,e){var u,g;let{traceId:o,workspaceName:i,path:a}=t,c={};c.trace_id=o,i!=null&&(c.workspace_name=i),c.path=a;let d=await R({url:b((g=(u=await s.get(this._options.baseUrl))!=null?u:await s.get(this._options.environment))!=null?g:h.Default,"v1/session/redirect/projects"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...e==null?void 0:e.headers},contentType:"application/json",queryParameters:c,requestType:"json",timeoutMs:(e==null?void 0:e.timeoutInSeconds)!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e==null?void 0:e.maxRetries,withCredentials:true,abortSignal:e==null?void 0:e.abortSignal});if(d.ok)return {data:void 0,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new T(d.error.body,d.rawResponse);case 404:throw new A(d.error.body,d.rawResponse);default:throw new p({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case "non-json":throw new p({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /v1/session/redirect/projects.");case "unknown":throw new p({message:d.error.errorMessage,rawResponse:d.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var ot=class{constructor(t={}){this._options=t;}get systemUsage(){var t;return (t=this._systemUsage)!=null?t:this._systemUsage=new Fi(this._options)}get alerts(){var t;return (t=this._alerts)!=null?t:this._alerts=new Oi(this._options)}get annotationQueues(){var t;return (t=this._annotationQueues)!=null?t:this._annotationQueues=new Wi(this._options)}get attachments(){var t;return (t=this._attachments)!=null?t:this._attachments=new Bi(this._options)}get check(){var t;return (t=this._check)!=null?t:this._check=new Li(this._options)}get automationRuleEvaluators(){var t;return (t=this._automationRuleEvaluators)!=null?t:this._automationRuleEvaluators=new Vi(this._options)}get chatCompletions(){var t;return (t=this._chatCompletions)!=null?t:this._chatCompletions=new Hi(this._options)}get datasets(){var t;return (t=this._datasets)!=null?t:this._datasets=new Ji(this._options)}get experiments(){var t;return (t=this._experiments)!=null?t:this._experiments=new Ki(this._options)}get feedbackDefinitions(){var t;return (t=this._feedbackDefinitions)!=null?t:this._feedbackDefinitions=new Xi(this._options)}get guardrails(){var t;return (t=this._guardrails)!=null?t:this._guardrails=new Gi(this._options)}get llmProviderKey(){var t;return (t=this._llmProviderKey)!=null?t:this._llmProviderKey=new $i(this._options)}get manualEvaluation(){var t;return (t=this._manualEvaluation)!=null?t:this._manualEvaluation=new Qi(this._options)}get openTelemetryIngestion(){var t;return (t=this._openTelemetryIngestion)!=null?t:this._openTelemetryIngestion=new Yi(this._options)}get optimizations(){var t;return (t=this._optimizations)!=null?t:this._optimizations=new Zi(this._options)}get projects(){var t;return (t=this._projects)!=null?t:this._projects=new qi(this._options)}get prompts(){var t;return (t=this._prompts)!=null?t:this._prompts=new ea(this._options)}get serviceToggles(){var t;return (t=this._serviceToggles)!=null?t:this._serviceToggles=new ra(this._options)}get spans(){var t;return (t=this._spans)!=null?t:this._spans=new oa(this._options)}get traces(){var t;return (t=this._traces)!=null?t:this._traces=new ta(this._options)}get welcomeWizard(){var t;return (t=this._welcomeWizard)!=null?t:this._welcomeWizard=new ia(this._options)}get workspaces(){var t;return (t=this._workspaces)!=null?t:this._workspaces=new aa(this._options)}get redirect(){var t;return (t=this._redirect)!=null?t:this._redirect=new na(this._options)}isAlive(t){return f.fromPromise(this.__isAlive(t))}async __isAlive(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"is-alive/ping"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:e.body,rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /is-alive/ping.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}version(t){return f.fromPromise(this.__version(t))}async __version(t){var o,i;let e=await R({url:b((i=(o=await s.get(this._options.baseUrl))!=null?o:await s.get(this._options.environment))!=null?i:h.Default,"is-alive/ver"),method:"GET",headers:{"Comet-Workspace":await s.get(this._options.workspaceName)!=null?await s.get(this._options.workspaceName):void 0,"X-Fern-Language":"JavaScript","X-Fern-Runtime":m.type,"X-Fern-Runtime-Version":m.version,...await this._getCustomAuthorizationHeaders(),...t==null?void 0:t.headers},contentType:"application/json",requestType:"json",timeoutMs:(t==null?void 0:t.timeoutInSeconds)!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t==null?void 0:t.maxRetries,withCredentials:true,abortSignal:t==null?void 0:t.abortSignal});if(e.ok)return {data:e.body,rawResponse:e.rawResponse};if(e.error.reason==="status-code")throw new p({statusCode:e.error.statusCode,body:e.error.body,rawResponse:e.rawResponse});switch(e.error.reason){case "non-json":throw new p({statusCode:e.error.statusCode,body:e.error.rawBody,rawResponse:e.rawResponse});case "timeout":throw new w("Timeout exceeded when calling GET /is-alive/ver.");case "unknown":throw new p({message:e.error.errorMessage,rawResponse:e.rawResponse})}}async _getCustomAuthorizationHeaders(){return {Authorization:await s.get(this._options.apiKey)}}};var Z=()=>uuid.v7();var sa=class n{constructor(t,e){this.data=t;this.opik=e;this.childSpans=[];this.end=()=>this.update({endTime:new Date});this.score=t=>{var e;this.opik.spanFeedbackScoresBatchQueue.create({...t,projectName:(e=this.data.projectName)!=null?e:this.opik.config.projectName,id:this.data.id,source:"sdk"});};this.update=t=>{var o;let e={parentSpanId:this.data.parentSpanId,projectName:(o=this.data.projectName)!=null?o:this.opik.config.projectName,traceId:this.data.traceId,...t};return this.opik.spanBatchQueue.update(this.data.id,e),this.data={...this.data,...t},this};this.span=t=>{var a;let e=(a=this.data.projectName)!=null?a:this.opik.config.projectName,o={id:Z(),startTime:new Date,...t,projectName:e,traceId:this.data.traceId,parentSpanId:this.data.id};this.opik.spanBatchQueue.create(o);let i=new n(o,this.opik);return this.childSpans.push(i),i};}};var pa=class{constructor(t,e){this.data=t;this.opik=e;this.spans=[];this.end=()=>this.update({endTime:new Date});this.score=t=>{var e;this.opik.traceFeedbackScoresBatchQueue.create({...t,projectName:(e=this.data.projectName)!=null?e:this.opik.config.projectName,id:this.data.id,source:"sdk"});};this.span=t=>{var a,c;let e=(c=(a=this.data.projectName)!=null?a:t.projectName)!=null?c:this.opik.config.projectName,o={id:Z(),startTime:new Date,...t,projectName:e,traceId:this.data.id};this.opik.spanBatchQueue.create(o);let i=new sa(o,this.opik);return this.spans.push(i),i};this.update=t=>{var o;let e={projectName:(o=this.data.projectName)!=null?o:this.opik.config.projectName,...t};return this.opik.traceBatchQueue.update(this.data.id,e),this.data={...this.data,...e},this};}};var Kd={EXPERIMENTS:"api/v1/session/redirect/experiments/",PROJECT_BY_NAME:"redirect/projects"},ca={EXPERIMENT_ID:"experiment_id",DATASET_ID:"dataset_id",PROJECT_NAME:"name",PATH:"path"},zf=n=>Object.entries(n).map(([t,e])=>`${t}=${encodeURIComponent(e)}`).join("&").replace(/%3A/g,":").replace(/%2F/g,"/").replace(/%26/g,"&").replace(/%3F/g,"?").replace(/%3D/g,"="),Sf=n=>n.replace(/\/api$/,""),xf=n=>Buffer.from(n).toString("base64"),Xd=(n,t,e)=>{let o=zf(e),i=`${t}?${o}`;return new URL(i,n).toString()},Gd=({datasetId:n,experimentId:t,baseUrl:e})=>Xd(e,Kd.EXPERIMENTS,{[ca.EXPERIMENT_ID]:t,[ca.DATASET_ID]:n,[ca.PATH]:xf(e)});var $d=({projectName:n,workspaceName:t,apiUrl:e})=>{let o=Sf(e),i=`${t}/${Kd.PROJECT_BY_NAME}`;return Xd(o,i,{[ca.PROJECT_NAME]:n})};var _f=300,la=100,tt=class{constructor({action:t,batchSize:e=la,delay:o,enableBatch:i,name:a="ActionQueue"}){this.timerId=null;this.promise=Promise.resolve();this.queue=new Map;this.debounceFlush=()=>{this.timerId&&clearTimeout(this.timerId),this.timerId=setTimeout(()=>this.flush(),this.delay);};this.add=(t,e)=>{if(this.queue.set(t,e),!this.enableBatch){this.flush();return}if(this.queue.size>=this.batchSize){this.flush();return}this.debounceFlush();};this.update=(t,e)=>{let o=this.queue.get(t);o&&(this.queue.set(t,{...o,...e}),this.debounceFlush());};this.flush=async()=>{if(this.queue.size===0)return this.promise;let t=new Map(this.queue);this.queue.clear(),z.debug(`Adding ${t.size} items to ${this.name} promise:`,t),this.promise=this.promise.finally(()=>(z.debug(`Flushing ${this.name}:`,t),this.action(t))).catch(e=>{z.error(`Failed to flush ${this.name}:`,e,t);}),await this.promise;};this.action=t,this.batchSize=e,this.delay=o,this.enableBatch=i,this.name=a;}},se=class{constructor({delay:t=_f,enableCreateBatch:e=true,enableUpdateBatch:o=false,enableDeleteBatch:i=true,createBatchSize:a=la,updateBatchSize:c=la,deleteBatchSize:d=la,name:u="BatchQueue"}={}){this.create=t=>{let e=this.getId(t);this.createQueue.add(e,t);};this.get=async t=>{let e=this.createQueue.queue.get(t);return e||this.getEntity(t)};this.update=(t,e)=>{if(this.createQueue.queue.get(t)){this.createQueue.update(t,e);return}this.updateQueue.add(t,e);};this.delete=t=>{if(this.createQueue.queue.has(t)){this.createQueue.queue.delete(t);return}this.deleteQueue.add(t);};this.flush=async()=>{await this.createQueue.flush(),await this.updateQueue.flush(),await this.deleteQueue.flush();};this.name=u,this.createQueue=new tt({action:async g=>{await this.createEntities(Array.from(g.values()));},delay:t,enableBatch:e,batchSize:a,name:`${u}:createQueue`}),this.updateQueue=new tt({action:async g=>{await this.createQueue.flush();let y=Array.from(g.entries());for(let[k,S]of y)await this.updateEntity(k,S);},delay:t,enableBatch:o,batchSize:c,name:`${u}:updateQueue`}),this.deleteQueue=new tt({action:async g=>{await this.createQueue.flush(),await this.updateQueue.flush(),await this.deleteEntities(Array.from(g.keys()));},delay:t,enableBatch:i,batchSize:d,name:`${u}:deleteQueue`});}};var ma=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"SpanBatchQueue"});this.api=e;}getId(e){return e.id}async createEntities(e){await this.api.spans.createSpans({spans:e},this.api.requestOptions);}async getEntity(e){return await this.api.spans.getSpanById(e,{},this.api.requestOptions)}async updateEntity(e,o){await this.api.spans.updateSpan(e,o,this.api.requestOptions);}async deleteEntities(e){for(let o of e)await this.api.spans.deleteSpanById(o,this.api.requestOptions);}};var da=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"SpanFeedbackScoresBatchQueue"});this.api=e;}getId(e){return {id:e.id,name:e.name}}async createEntities(e){await this.api.spans.scoreBatchOfSpans({scores:e},this.api.requestOptions);}async getEntity(){throw new Error("Not implemented")}async updateEntity(){throw new Error("Not implemented")}async deleteEntities(e){for(let o of e)await this.api.spans.deleteSpanFeedbackScore(o.id,{name:o.name},this.api.requestOptions);}};var ua=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"TraceBatchQueue"});this.api=e;}getId(e){return e.id}async createEntities(e){await this.api.traces.createTraces({traces:e},this.api.requestOptions);}async getEntity(e){return await this.api.traces.getTraceById(e,{},this.api.requestOptions)}async updateEntity(e,o){await this.api.traces.updateTrace(e,o,this.api.requestOptions);}async deleteEntities(e){await this.api.traces.deleteTraces({ids:e},this.api.requestOptions);}};var ga=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"TraceFeedbackScoresBatchQueue"});this.api=e;}getId(e){return {id:e.id,name:e.name}}async createEntities(e){await this.api.traces.scoreBatchOfTraces({scores:e},this.api.requestOptions);}async getEntity(){throw new Error("Not implemented")}async updateEntity(){throw new Error("Not implemented")}async deleteEntities(e){for(let o of e)await this.api.traces.deleteTraceFeedbackScore(o.id,{name:o.name},this.api.requestOptions);}};var wa=class extends ot{constructor(e){super(e);this.setHeaders=e=>{this.requestOptions.headers=e;};this.requestOptions=(e==null?void 0:e.requestOptions)||{};}};var fa=class extends se{constructor(e,o){super({delay:o,enableCreateBatch:true,enableUpdateBatch:true,enableDeleteBatch:true,name:"DatasetBatchQueue"});this.api=e;}getId(e){return e.id||""}async createEntities(e){for(let o of e)await this.api.datasets.createDataset(o,this.api.requestOptions);}async getEntity(e){try{return await this.api.datasets.getDatasetById(e,this.api.requestOptions)}catch{return}}async updateEntity(e,o){await this.api.datasets.updateDataset(e,{name:o.name||"",visibility:o.visibility,description:o.description},this.api.requestOptions);}async deleteEntities(e){await this.api.datasets.deleteDatasetsBatch({ids:e},this.api.requestOptions);}};var nm=null;async function Qd(){return nm||(nm=await Tf__default.default()),nm}var it=class n{constructor(t){let{id:e,traceId:o,spanId:i,source:a,...c}=t;this.id=e||Z(),this.traceId=o,this.spanId=i,this.source=a||tn.Sdk,this.data={...c};}getContent(t=false){return t?{...this.data,id:this.id}:{...this.data}}async contentHash(){let t=this.getContent(),e=Af__default.default(t);return (await Qd()).h32(e,43981).toString(16)}toApiModel(){return {id:this.id,traceId:this.traceId,spanId:this.spanId,source:this.source,data:this.getContent()}}static fromApiModel(t){return new n({id:t.id,traceId:t.traceId,spanId:t.spanId,source:t.source,...t.data})}};async function _e(n,t,e){var c;if(e===0)return [];let o=new util.TextDecoder("utf-8"),i=[],a="";try{for await(let d of n){a+=o.decode(d,{stream:!0});let u=a.split(`
|
|
4
|
+
`);a=(c=u.pop())!=null?c:"";for(let g of u)if(!(!g.trim()||g==="{}"||g==="[]"||g==="null"))try{let y=JSON.parse(g),k=t.parse(y);if(k.ok){if(i.push(k.value),e!==void 0&&i.length>=e)return i}else z.error("Error parsing experiment item:",k.errors);}catch(y){z.error("Error parsing JSON line:",y instanceof Error?y.message:String(y));}}if(a.trim()&&a!=="{}"&&a!=="[]"&&a!=="null")try{let d=JSON.parse(a),u=t.parse(d);u.ok?i.push(u.value):z.error("Error parsing experiment item:",u.errors);}catch(d){z.error("Error parsing remaining buffer:",d instanceof Error?d.message:String(d));}}catch(d){z.error("Error processing stream:",d instanceof Error?d.message:String(d));}return i}function at(n,t){let e=[];for(let o=0;o<n.length;o+=t.maxBatchSize)e.push(n.slice(o,o+t.maxBatchSize));return e}var ne=class extends Error{constructor(t){var e;super(t.message),this.name=this.constructor.name,this.code=t.code,this.statusCode=t.statusCode,this.details=t.details,this.originalError=t.originalError,z.error(this.message),(e=Error.captureStackTrace)==null||e.call(Error,this,this.constructor);}toJSON(){return {name:this.name,message:this.message,code:this.code,statusCode:this.statusCode,details:this.details,originalError:this.originalError,stack:this.stack}}};var Yd={DATASET_NOT_FOUND:n=>`Dataset with name '${n}' not found`,DATASET_ITEM_NOT_FOUND:n=>`Dataset item with id '${n}' not found`,DATASET_ITEM_MISSING_ID:n=>`Item at index ${n} is missing an ID required for update`,INVALID_JSON_FORMAT:n=>`Invalid JSON format${n?": "+n:""}`,JSON_NOT_ARRAY:"JSON input must be an array of objects",ITEM_NOT_OBJECT:(n,t)=>`Item at position ${n} is not an object (${t})`,INSERTION_FAILED:n=>`Failed to insert items from JSON: ${n}`,DATASET_JSON_PARSE_ERROR:n=>`Failed to parse JSON input: ${n}`};var Pf={DATASET_ITEM_MISSING_ID:"DATASET_ITEM_MISSING_ID"},ha=class extends ne{constructor(t){super({message:Yd.DATASET_ITEM_MISSING_ID(t),code:Pf.DATASET_ITEM_MISSING_ID});}};var vf={SEARCH_TIMEOUT:"SEARCH_TIMEOUT"},Ra=class extends ne{constructor(t){super({message:t,code:vf.SEARCH_TIMEOUT});}};var ba={JSON_NOT_ARRAY:n=>`JSON input must be an array of objects${n?` (${n})`:""}`,JSON_PARSE_ERROR:"Failed to parse JSON input",JSON_ITEM_NOT_OBJECT:(n,t)=>`Item at position ${n} is not an object (${t})`};var sm={JSON_PARSE_ERROR:"JSON_PARSE_ERROR",JSON_NOT_ARRAY:"JSON_NOT_ARRAY",JSON_ITEM_NOT_OBJECT:"JSON_ITEM_NOT_OBJECT"},ya=class extends ne{constructor(t){let e=t instanceof Error?t:new Error(String(t));super({message:ba.JSON_PARSE_ERROR,code:sm.JSON_PARSE_ERROR,originalError:e});}},ka=class extends ne{constructor(t){super({message:ba.JSON_NOT_ARRAY(t),code:sm.JSON_NOT_ARRAY});}},za=class extends ne{constructor(t,e){super({message:ba.JSON_ITEM_NOT_OBJECT(t,e),code:sm.JSON_ITEM_NOT_OBJECT});}};var qe=class{constructor({name:t,description:e,id:o},i){this.opik=i;this.idToHash=new Map;this.hashes=new Set;this.id=o||Z(),this.name=t,this.description=e;}async insert(t){if(!t||t.length===0)return;await this.opik.datasetBatchQueue.flush(),await this.syncHashes();let e=await this.getDeduplicatedItems(t),o=at(e,{maxBatchSize:1e3});try{let i=0;for(let a of o)await this.opik.api.datasets.createOrUpdateDatasetItems({datasetId:this.id,items:a}),i+=a.length,z.info(`Inserted ${Math.min(i,e.length)} of ${e.length} items into dataset ${this.id}`);}catch(i){throw z.error(`Error inserting items into dataset: ${i instanceof Error?i.message:String(i)}`),i}}async update(t){if(!(!t||t.length===0)){for(let e=0;e<t.length;e++)if(!t[e].id)throw new ha(e);await this.insert(t);}}async delete(t){if(!t||t.length===0){z.info("No item IDs provided for deletion");return}let e=at(t,{maxBatchSize:100});for await(let o of e){z.debug("Deleting dataset items batch",{batchSize:o.length,datasetId:this.id}),await this.opik.api.datasets.deleteDatasetItems({itemIds:o});for(let i of o)if(this.idToHash.has(i)){let a=this.idToHash.get(i);this.hashes.delete(a),this.idToHash.delete(i);}}}async clear(){let e=(await this.getItems()).map(o=>o.id).filter(Boolean);e.length!==0&&await this.delete(e);}async getItems(t,e){return (await this.getItemsAsDataclasses(t,e)).map(i=>i.getContent(true))}async getItemsAsDataclasses(t,e){let o=t?Math.min(t,2e3):2e3,i=await this.opik.api.datasets.streamDatasetItems({datasetName:this.name,lastRetrievedId:e,steamLimit:o});return (await _e(i,I.DatasetItemPublic,t)).map(c=>it.fromApiModel(c))}async insertFromJson(t,e={},o=[]){let i;try{i=JSON.parse(t);}catch(c){throw new ya(c)}if(!Array.isArray(i))throw new ka(typeof i);if(i.length===0)return;for(let c=0;c<i.length;c++){let d=i[c];if(typeof d!="object"||d===null)throw new za(c,typeof d)}let a=i.map(c=>{let d=c,u={};for(let[g,y]of Object.entries(d)){if(o.includes(g))continue;let k=e[g]||g;u[k]=y;}return u});await this.insert(a);}async toJson(t={}){let o=(await this.getItems()).map(i=>{let a={...i};if(Object.keys(t).length>0){for(let[c,d]of Object.entries(t))if(c in a){let u=a[c];delete a[c],a[d]=u;}}return a});return Af__default.default(o)}async getDeduplicatedItems(t){let e=[];for(let o of t){let i=new it(o),a=await i.contentHash();if(this.hashes.has(a)){z.debug("Duplicate item found - skipping",{contentHash:a,datasetId:this.id});continue}e.push(i.toApiModel()),this.hashes.add(a),this.idToHash.set(i.id,a);}return e}clearHashState(){this.idToHash.clear(),this.hashes.clear();}async syncHashes(){z.debug("Syncing dataset hashes with backend",{datasetId:this.id});try{let t=await this.getItemsAsDataclasses();this.clearHashState();for(let e of t){let o=await e.contentHash();this.idToHash.set(e.id,o),this.hashes.add(o);}z.debug("Dataset hash sync completed",{datasetId:this.id,itemCount:t.length});}catch(t){if(t instanceof p&&t.statusCode===404){z.debug("Dataset not found - starting with empty hash state",{datasetId:this.id}),this.clearHashState();return}throw t}}};var pm=class extends Error{constructor(t){super(t),this.name="DatasetError";}},nt=class extends pm{constructor(t){super(`Dataset with name '${t}' not found`),this.name="DatasetNotFoundError";}};var Sa=class{constructor(t){if(!t.datasetItemId)throw new Error("datasetItemId is required");if(!t.traceId)throw new Error("traceId is required");this.datasetItemId=t.datasetItemId,this.traceId=t.traceId;}},xa=class n{constructor(t){this.id=t.id,this.datasetItemId=t.datasetItemId,this.traceId=t.traceId,this.datasetItemData=t.datasetItemData,this.evaluationTaskOutput=t.evaluationTaskOutput,this.feedbackScores=[...t.feedbackScores];}static fromRestExperimentItemCompare(t){var o,i;let e=(i=(o=t.feedbackScores)==null?void 0:o.map(a=>({categoryName:a.categoryName,name:a.name,reason:a.reason,value:a.value,source:a.source})))!=null?i:[];return new n({id:t.id,traceId:t.traceId,datasetItemId:t.datasetItemId,datasetItemData:t.input,evaluationTaskOutput:t.output,feedbackScores:e})}};var Fe=class{constructor({id:t,name:e,datasetName:o,prompts:i},a){this.opik=a;this.id=t||Z(),this._name=e,this.datasetName=o,this.prompts=i;}get name(){return this._name}async ensureNameLoaded(){if(this._name!==void 0)return this._name;let t=await this.opik.api.experiments.getExperimentById(this.id);if(this._name=t.name,!this._name)throw new Error("Experiment name is not loaded");return this._name}async insert(t){if(t.length===0)return;let e=t.map(i=>({id:Z(),experimentId:this.id,datasetItemId:i.datasetItemId,traceId:i.traceId})),o=at(e,{maxBatchSize:50});try{for(let i of o)await this.opik.api.experiments.createExperimentItems({experimentItems:i});z.debug(`Inserted ${t.length} items into experiment ${this.id}`);}catch(i){throw z.error(`Error inserting items into experiment: ${i instanceof Error?i.message:String(i)}`),i}}async getItems(t){let e=[],{maxResults:i,truncate:a=false}=t||{},c,d=true;try{for(;d&&!(i!==void 0&&e.length>=i);){let u=i?Math.min(i-e.length,2e3):2e3,g=await this.opik.api.experiments.streamExperimentItems({experimentName:this.name,limit:u,lastRetrievedId:c,truncate:a});try{let y=await _e(g,I.ExperimentItemCompare,u);if(y.length===0){d=!1;break}for(let k of y){let S=xa.fromRestExperimentItemCompare(k);if(e.push(S),i!==void 0&&e.length>=i){d=!1;break}}c=y[y.length-1].id;}catch(y){z.error("Error parsing experiment item: "+(y instanceof Error?y.message:String(y))),d=!1;break}}}catch(u){throw z.error("Error retrieving experiment items: "+(u instanceof Error?u.message:String(u))),u}return z.info(`Retrieved ${e.length} items${i?` (limited by maxResults=${i})`:""}`),e}async getUrl(){let t=await this.opik.getDataset(this.datasetName),e=this.opik.config.apiUrl||Va.apiUrl;return Gd({datasetId:t.id,experimentId:this.id,baseUrl:e})}};var _a={EXPERIMENT_NOT_FOUND:n=>`Experiment with name '${n}' not found`,INVALID_CONFIG_TYPE:n=>`experimentConfig must be a plain object, but ${n} was provided. Please provide a valid configuration object like { model: 'gpt-4', temperature: 0.7 }`,CONFIG_PROMPTS_CONFLICT:()=>`Cannot specify both 'prompts' parameter and 'experimentConfig.prompts'. Choose one approach:
|
|
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
|
|
8
|
+
The prompts parameter is recommended for prompt version tracking.`};var cm={EXPERIMENT_NOT_FOUND:"EXPERIMENT_NOT_FOUND",INVALID_CONFIG_TYPE:"INVALID_CONFIG_TYPE",CONFIG_PROMPTS_CONFLICT:"CONFIG_PROMPTS_CONFLICT"},st=class extends ne{constructor(t){super({message:_a.EXPERIMENT_NOT_FOUND(t),code:cm.EXPERIMENT_NOT_FOUND});}},pt=class n extends ne{constructor(t,e){super({message:t,code:e});}static invalidConfigType(t){return new n(_a.INVALID_CONFIG_TYPE(t),cm.INVALID_CONFIG_TYPE)}static promptsConflict(){return new n(_a.CONFIG_PROMPTS_CONFLICT(),cm.CONFIG_PROMPTS_CONFLICT)}};function Zd(n,t){if(n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)))throw pt.invalidConfigType(typeof n);if(t&&t.length>0&&(n!=null&&n.prompts))throw pt.promptsConflict();if(!n&&(!t||t.length===0))return [void 0,void 0];let e=n?structuredClone(n):{},o;if(t&&t.length>0){o=[];let i={};for(let a of t)o.push({id:a.versionId}),i[a.name]=a.prompt;e.prompts=i;}return Object.keys(e).length===0?[void 0,void 0]:[e,o]}var de={MUSTACHE:"mustache",JINJA2:"jinja2"};var H=class n extends Error{constructor(t){super(t),this.name="PromptValidationError",Object.setPrototypeOf(this,n.prototype);}};function jf(n){try{let e=If__default.default.parse(n).filter(o=>{let i=o[0];return i==="name"||i==="#"||i==="&"||i==="^"}).map(o=>o[1].split(".")[0]);return new Set(e)}catch(t){throw new H(`Invalid Mustache template syntax: ${t instanceof Error?t.message:String(t)}`)}}function qd(n,t,e){if(e!=="mustache")return;let o=jf(n),i=new Set(Object.keys(t)),a=new Set([...o].filter(c=>!i.has(c)));if(a.size>0){let c=[];throw c.push(`Missing required variables: ${[...a].join(", ")}`),c.push(`Template placeholders: {${[...o].join(", ")}}`),c.push(`Provided variables: {${[...i].join(", ")}}`),new H(`Template variables validation failed:
|
|
9
9
|
${c.join(`
|
|
10
|
-
`)}`)}}function
|
|
10
|
+
`)}`)}}function he(n,t,e){try{switch(qd(n,t,e),e){case "mustache":return If__default.default.render(n,t,{},{escape:o=>o});case "jinja2":return Nf__default.default.renderString(n,t);default:return n}}catch(o){if(o instanceof H)throw o;let i=o instanceof Error?o.message:String(o);throw new H(`Failed to format prompt template: ${i}`)}}var ct=class n{constructor(t){this.id=t.versionId,this.name=t.name,this.prompt=t.prompt,this.commit=t.commit,this.type=t.type,this.metadata=t.metadata,this.changeDescription=t.changeDescription,this.createdAt=t.createdAt,this.createdBy=t.createdBy;}format(t){return he(this.prompt,t,this.type)}getVersionAge(){return this.createdAt?dateFns.formatDistanceToNow(new Date(this.createdAt),{addSuffix:true}):"Unknown"}getVersionInfo(){let t=[`[${this.commit}]`];if(this.createdAt){let e=new Date(this.createdAt);t.push(e.toISOString().split("T")[0]);}return this.createdBy&&t.push(`by ${this.createdBy}`),this.changeDescription&&t.push(`- ${this.changeDescription}`),t.join(" ")}compareTo(t){let e=`Current version [${this.commit}]`,o=`Other version [${t.commit}]`,i=jestDiff.diffStringsUnified(t.prompt,this.prompt,{aAnnotation:o,bAnnotation:e,includeChangeCounts:true,contextLines:3,expand:false});return z.info(`
|
|
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: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){
|
|
14
|
-
No metrics available to display.`);return}let a=[...o.keys()].sort(),c=this.formatTime(i),d=[
|
|
15
|
-
`),u=await e.ensureNameLoaded(),g
|
|
12
|
+
${i}`),i}static fromApiResponse(t,e){var o;if(!e.template)throw new H("Invalid API response: missing required field 'template'");if(!e.commit)throw new H("Invalid API response: missing required field 'commit'");if(!e.promptId)throw new H("Invalid API response: missing required field 'promptId'");if(!e.id)throw new H("Invalid API response: missing required field 'id'");return new n({name:t,prompt:e.template,commit:e.commit,promptId:e.promptId,versionId:e.id,type:(o=e.type)!=null?o:de.MUSTACHE,metadata:e.metadata,changeDescription:e.changeDescription,createdAt:e.createdAt?new Date(e.createdAt):void 0,createdBy:e.createdBy})}};var Te=class n{constructor({promptId:t,versionId:e,name:o,prompt:i,commit:a,metadata:c,type:d,changeDescription:u,description:g,tags:y=[]},k){this.opik=k;this.id=t,this.versionId=e,this.prompt=i,this.commit=a,this.type=d!=null?d:de.MUSTACHE,this.changeDescription=u,this._name=o,this._description=g,this._tags=[...y],this._metadata=c;}get name(){return this._name}get description(){return this._description}get tags(){return Object.freeze([...this._tags])}get metadata(){if(this._metadata)return structuredClone(this._metadata)}format(t){return he(this.prompt,t,this.type)}static fromApiResponse(t,e,o){var a;if(!e.template)throw new H("Invalid API response: missing required field 'template'");if(!e.commit)throw new H("Invalid API response: missing required field 'commit'");if(!e.promptId)throw new H("Invalid API response: missing required field 'promptId'");if(!e.id)throw new H("Invalid API response: missing required field 'id' (version ID)");let i=(a=e.type)!=null?a:de.MUSTACHE;if(i!=="mustache"&&i!=="jinja2")throw new H(`Invalid API response: unknown prompt type '${i}'`);return new n({promptId:e.promptId,versionId:e.id,name:t.name,prompt:e.template,commit:e.commit,metadata:e.metadata,type:i,changeDescription:e.changeDescription,description:t.description,tags:t.tags},o)}async updateProperties(t){var e,o,i,a;return await this.opik.api.prompts.updatePrompt(this.id,{name:(e=t.name)!=null?e:this._name,description:t.description,tags:t.tags},this.opik.api.requestOptions),this._name=(o=t.name)!=null?o:this._name,this._description=(i=t.description)!=null?i:this._description,this._tags=(a=t.tags)!=null?a:this._tags,this}async delete(){await this.opik.deletePrompts([this.id]);}async getVersions(){var t;z.debug("Getting versions for prompt",{promptId:this.id,name:this.name});try{let e=[],o=1,i=100;for(;;){let c=(t=(await this.opik.api.prompts.getPromptVersions(this.id,{page:o,size:i},this.opik.api.requestOptions)).content)!=null?t:[];if(e.push(...c),c.length<i)break;o++;}return z.debug("Successfully retrieved prompt versions",{promptId:this.id,name:this.name,totalVersions:e.length}),e.map(a=>ct.fromApiResponse(this.name,a))}catch(e){throw z.error("Failed to get prompt versions",{promptId:this.id,name:this.name,error:e}),e}}async useVersion(t){z.debug("Restoring prompt version",{promptId:this.id,name:this.name,versionId:t.id,versionCommit:t.commit});try{let e=await this.opik.api.prompts.restorePromptVersion(this.id,t.id,this.opik.api.requestOptions);return z.debug("Successfully restored prompt version",{promptId:this.id,name:this.name,restoredVersionId:e.id,restoredCommit:e.commit}),n.fromApiResponse({name:this.name,description:this.description,tags:this._tags},e,this.opik)}catch(e){throw z.error("Failed to restore prompt version",{promptId:this.id,name:this.name,versionId:t.id,versionCommit:t.commit,error:e}),e}}async getVersion(t){try{let e=await this.opik.api.prompts.retrievePromptVersion({name:this.name,commit:t},this.opik.api.requestOptions);return n.fromApiResponse({name:this.name,description:this.description,tags:this._tags},e,this.opik)}catch(e){if(e&&typeof e=="object"&&"statusCode"in e&&e.statusCode===404)return null;throw z.error("Failed to retrieve prompt version",{promptName:this.name,commit:t,error:e}),e}}};async function eu(n,t,e){try{return await n.retrievePromptVersion({name:t},e)}catch(o){if(Wf(o))return null;throw o}}function ru(n,t,e){return t?t.template!==n.prompt||!Of(t.metadata,n.metadata)||t.type!==e:true}function Of(n,t){let e=n!=null?n:{},o=t!=null?t:{};return Ff__default.default(e,o)}function Wf(n){return typeof n=="object"&&n!==null&&"statusCode"in n&&n.statusCode===404}var re=class{constructor(t){this.input=t;this.cursor=0;}getPosition(){return this.cursor}getRemainingInput(){return this.input.slice(this.cursor)}getFullInput(){return this.input}isAtEnd(){return this.cursor>=this.input.length}peekChar(){return this.input[this.cursor]}peekCharAt(t){return this.input[this.cursor+t]}consumeChar(){return this.input[this.cursor++]}advance(t=1){this.cursor+=t;}skipWhitespace(){for(;this.cursor<this.input.length&&/\s/.test(this.input[this.cursor]);)this.cursor++;}consumeWhile(t){let e=this.cursor;for(;this.cursor<this.input.length&&t(this.input[this.cursor]);)this.cursor++;return this.input.slice(e,this.cursor)}sliceFrom(t){return this.input.slice(t,this.cursor)}static isFieldChar(t){return /[a-zA-Z0-9_]/.test(t)}static isLetterChar(t){return /[a-zA-Z]/.test(t)}static isDigitChar(t){return /\d/.test(t)}static isWhitespaceChar(t){return /\s/.test(t)}static isQuoteChar(t){return t==='"'||t==="'"}};var V={STRING_OPS:["=","contains","not_contains","starts_with","ends_with","!=",">","<"],NUMERIC_OPS:["=","!=",">","<",">=","<="],DATETIME_OPS:["=",">","<",">=","<="],LIST_OPS:["contains"],DICT_OPS:["=","contains",">","<"],LIMITED_STRING_OPS:["=","contains","not_contains"]},Ae={id:"string",name:"string",status:"string",start_time:"date_time",end_time:"date_time",input:"string",output:"string",metadata:"dictionary",feedback_scores:"feedback_scores_number",tags:"list","usage.total_tokens":"number","usage.prompt_tokens":"number","usage.completion_tokens":"number",duration:"number",number_of_messages:"number",created_by:"string",thread_id:"string",total_estimated_cost:"number",type:"string",model:"string",provider:"string"},ou={id:V.STRING_OPS,name:V.STRING_OPS,status:V.LIMITED_STRING_OPS,start_time:V.DATETIME_OPS,end_time:V.DATETIME_OPS,input:V.LIMITED_STRING_OPS,output:V.LIMITED_STRING_OPS,metadata:V.DICT_OPS,feedback_scores:V.NUMERIC_OPS,tags:V.LIST_OPS,"usage.total_tokens":V.NUMERIC_OPS,"usage.prompt_tokens":V.NUMERIC_OPS,"usage.completion_tokens":V.NUMERIC_OPS,duration:V.NUMERIC_OPS,number_of_messages:V.NUMERIC_OPS,created_by:V.STRING_OPS,thread_id:V.STRING_OPS,total_estimated_cost:V.NUMERIC_OPS,type:V.STRING_OPS,model:V.STRING_OPS,provider:V.STRING_OPS},Ta={SPECIAL_FIELDS:["usage","metadata","feedback_scores"],USAGE_KEYS:["total_tokens","prompt_tokens","completion_tokens"]};function tu(n){let t=Ta.SPECIAL_FIELDS.includes(n),e=Object.keys(Ae).includes(n);if(!t&&!e){let o=Object.keys(Ae).join(", ");throw new Error(`Field ${n} is not supported, only the fields ${o} are supported.`)}}function iu(n,t){if(!Ta.SPECIAL_FIELDS.includes(n)){let e=Object.keys(Ae).join(", ");throw new Error(`Field ${n}.${t} is not supported, only the fields ${e} are supported.`)}if(n==="usage"&&!Ta.USAGE_KEYS.includes(t))throw new Error(`When querying usage, ${t} is not supported, only usage.total_tokens, usage.prompt_tokens and usage.completion_tokens are supported.`)}function lm(n,t){let e=ou[n];if(!(e!=null&&e.includes(t))){let o=(e==null?void 0:e.join(", "))||"none";throw new Error(`Operator ${t} is not supported for field ${n}, only the operators ${o} are supported.`)}}function au(n){let t=n.toLowerCase();if(t==="and")return true;throw t==="or"?new Error("Invalid filter string, OR is not currently supported"):new Error(`Invalid filter string, trailing characters ${n}`)}function Aa(n,t,e){if(!n)throw new Error(`Missing closing quote for: ${e}`)}var lt=class{static parse(t){t.skipWhitespace();let e=this.parseFieldName(t);return tu(e),t.peekChar()==="."?this.parseFieldWithKey(t,e):{type:"simple",field:e,columnType:Ae[e]}}static parseFieldName(t){return t.consumeWhile(e=>re.isFieldChar(e))}static parseFieldWithKey(t,e){t.advance();let o=this.parseKey(t);if(iu(e,o),e==="usage"){let i=`usage.${o}`;return {type:"simple",field:i,columnType:Ae[i]}}return {type:"nested",field:e,key:o,columnType:Ae[e]}}static parseKey(t){let e=t.peekChar();return re.isQuoteChar(e)?this.parseQuotedKey(t,e):this.parseUnquotedKey(t)}static parseUnquotedKey(t){return t.consumeWhile(e=>re.isFieldChar(e))}static parseQuotedKey(t,e){let o=t.getPosition();t.advance();let i="",a=false;for(;!t.isAtEnd();){let d=t.peekChar();if(d===e){if(t.peekCharAt(1)===e){i+=e,t.advance(2);continue}a=true,t.advance();break}i+=d,t.advance();}let c=t.getFullInput().slice(o);return Aa(a,o,c),i}};var mt=class{static parse(t,e){t.skipWhitespace();let o=t.peekChar(),i=this.tryParseSymbolicOperator(t,o);if(i)return lm(e,i),{operator:i};let a=this.parseWordOperator(t);return lm(e,a),{operator:a}}static tryParseSymbolicOperator(t,e){if(e==="=")return t.advance(),"=";if(e==="<"||e===">"){let o=e;return t.advance(),t.peekChar()==="="?(t.advance(),o+"="):o}return e==="!"&&t.peekCharAt(1)==="="?(t.advance(2),"!="):null}static parseWordOperator(t){return t.consumeWhile(e=>!re.isWhitespaceChar(e))}};var dt=class{static parse(t){t.skipWhitespace();let e=t.getPosition(),o=t.peekChar();if(o==='"')return this.parseQuotedString(t,e);if(re.isDigitChar(o)||o==="-")return this.parseNumber(t);let i=t.getRemainingInput();throw new Error(`Invalid value ${i.slice(0,20)}, expected a string in double quotes("value") or a number`)}static parseQuotedString(t,e){t.advance();let o=t.getPosition(),i=false;for(;!t.isAtEnd();){if(t.peekChar()==='"'){i=true;break}t.advance();}Aa(i,e,`value starting at position ${e}`);let a=t.sliceFrom(o);return t.advance(),{value:a}}static parseNumber(t){let e="";return t.peekChar()==="-"&&(e+=t.consumeChar()),e+=this.parseDigits(t),t.peekChar()==="."&&(e+=t.consumeChar(),e+=this.parseDigits(t)),{value:e}}static parseDigits(t){return t.consumeWhile(e=>re.isDigitChar(e))}};var Ee=class{constructor(t){let e=t||"";this.filterExpressions=e?this.parse(e):null,this.parsedFilters=this.filterExpressions?JSON.stringify(this.filterExpressions):null;}getFilterExpressions(){return this.filterExpressions}parse(t){let e=new re(t),o=[];for(;!e.isAtEnd();){let i=this.parseExpression(e);if(o.push(i),e.skipWhitespace(),!e.isAtEnd()&&!this.parseConnector(e))break}return o}parseExpression(t){let e=lt.parse(t),o=mt.parse(t,this.getFieldName(e)),i=dt.parse(t);return this.buildExpression(e,o,i)}getFieldName(t){return t.field}buildExpression(t,e,o){let i={field:t.field,operator:e.operator,value:o.value,type:t.columnType};return t.type==="nested"&&(i.key=t.key),i}parseConnector(t){let e=t.getPosition(),o=t.consumeWhile(i=>re.isLetterChar(i));try{return au(o)}catch(i){if(i instanceof Error&&i.message.includes("trailing characters")){let a=t.getFullInput().slice(e);throw new Error(`Invalid filter string, trailing characters ${a}`)}throw i}}};async function nu(n,t,e,o,i){let a=await n.traces.searchTraces({projectName:t,filters:e!=null?e:void 0,limit:o,truncate:i});return await _e(a,I.TracePublic,o)}async function su(n,t,e,o){let i=Date.now(),a=[];for(;;){if(a=await n(),a.length>=t||Date.now()-i>=e)return a;await new Promise(d=>setTimeout(d,o));}}function pu(n){if(!n)return null;let e=new Ee(n).getFilterExpressions();return e?e.map(o=>{let i={field:o.field,operator:o.operator,value:o.value};return o.key&&(i.key=o.key),i}):null}var mm=[],Oe=class{constructor(t){this.displayTraceLog=t=>{if(t===this.lastProjectNameLogged||!this.config.apiUrl)return;let e=$d({apiUrl:this.config.apiUrl,projectName:t,workspaceName:this.config.workspaceName});z.info(`Started logging traces to the "${t}" project at ${Rt(e)}`),this.lastProjectNameLogged=t;};this.trace=t=>{var i;z.debug("Creating new trace with data:",t);let e=(i=t.projectName)!=null?i:this.config.projectName,o=new pa({id:Z(),startTime:new Date,...t,projectName:e},this);return this.traceBatchQueue.create(o.data),z.debug("Trace added to the queue with ID:",o.data.id),this.displayTraceLog(e),o};this.getDataset=async t=>{z.debug(`Getting dataset with name "${t}"`);try{await this.datasetBatchQueue.flush();let e=await this.api.datasets.getDatasetByIdentifier({datasetName:t});return new qe(e,this)}catch(e){throw e instanceof p&&e.statusCode===404?new nt(t):e}};this.createDataset=async(t,e)=>{z.debug(`Creating dataset with name "${t}"`);let o=new qe({name:t,description:e},this);try{return this.datasetBatchQueue.create({name:o.name,description:o.description,id:o.id}),z.debug("Dataset added to the queue with name:",o.name),o}catch(i){throw z.error(`Failed to create dataset "${t}"`,{error:i}),new Error(`Error creating dataset "${t}": ${i}`)}};this.getOrCreateDataset=async(t,e)=>{z.debug(`Attempting to retrieve or create dataset with name: "${t}"`);try{return await this.getDataset(t)}catch(o){if(o instanceof nt)return z.info(`Dataset "${t}" not found. Proceeding to create a new one.`),this.createDataset(t,e);throw z.error(`Error retrieving dataset "${t}":`,o),o}};this.getDatasets=async(t=100)=>{z.debug(`Getting all datasets (limit: ${t})`);try{await this.datasetBatchQueue.flush();let e=await this.api.datasets.findDatasets({size:t}),o=[];for(let i of e.content||[])o.push(new qe(i,this));return z.info(`Retrieved ${o.length} datasets`),o}catch(e){throw z.error("Failed to retrieve datasets",{error:e}),new Error("Failed to retrieve datasets")}};this.deleteDataset=async t=>{z.debug(`Deleting dataset with name "${t}"`);try{let e=await this.getDataset(t);if(!e.id)throw new Error(`Cannot delete dataset "${t}": ID not available`);this.datasetBatchQueue.delete(e.id);}catch(e){throw z.error(`Failed to delete dataset "${t}"`,{error:e}),new Error(`Failed to delete dataset "${t}": ${e}`)}};this.createExperiment=async({datasetName:t,name:e,experimentConfig:o,prompts:i,type:a=an.Regular,optimizationId:c})=>{if(z.debug(`Creating experiment for dataset "${t}"`),!t)throw new Error("Dataset name is required to create an experiment");let[d,u]=Zd(o,i),g=Z(),y=new Fe({id:g,name:e,datasetName:t,prompts:i},this);try{return this.api.experiments.createExperiment({id:g,datasetName:t,name:e,metadata:d,promptVersions:u,type:a,optimizationId:c}),z.debug("Experiment added to the queue with id:",g),y}catch(k){throw z.error(`Failed to create experiment for dataset "${t}"`,{error:k}),new Error(`Error creating experiment: ${k}`)}};this.getExperimentById=async t=>{z.debug(`Getting experiment with ID "${t}"`);try{let e=await this.api.experiments.getExperimentById(t);return new Fe({id:e.id,name:e.name,datasetName:e.datasetName},this)}catch(e){throw e instanceof p&&e.statusCode===404?new st(`No experiment found with ID '${t}'`):(z.error(`Failed to get experiment with ID "${t}"`,{error:e}),e)}};this.getExperimentsByName=async t=>{z.debug(`Getting experiments with name "${t}"`);try{let e=await this.api.experiments.streamExperiments({name:t});return (await _e(e,I.ExperimentPublic)).map(i=>new Fe({id:i.id,name:i.name,datasetName:i.datasetName},this))}catch(e){throw z.error(`Failed to get experiments with name "${t}"`,{error:e}),e}};this.getExperiment=async t=>{z.debug(`Getting experiment with name "${t}"`);let e=await this.getExperimentsByName(t);if(e.length===0)throw new st(t);return e[0]};this.getDatasetExperiments=async(t,e=100)=>{var c;z.debug(`Getting experiments for dataset "${t}"`);let o=await this.getDataset(t),i=Math.min(100,e),a=[];try{let d=1;for(;a.length<e;){let u=await this.api.experiments.findExperiments({page:d,size:i,datasetId:o.id}),g=(c=u==null?void 0:u.content)!=null?c:[];if(g.length===0)break;let y=e-a.length,k=Math.min(g.length,y);for(let S=0;S<k;S++){let x=g[S];a.push(new Fe({id:x.id,name:x.name,datasetName:x.datasetName},this));}if(k<g.length)break;d+=1;}return a}catch(d){throw z.error(`Failed to get experiments for dataset "${t}"`,{error:d}),d}};this.deleteExperiment=async t=>{z.debug(`Deleting experiment with ID "${t}"`);try{await this.api.experiments.deleteExperimentsById({ids:[t]});}catch(e){throw z.error(`Failed to delete experiment with ID "${t}"`,{error:e}),e}};this.createPrompt=async t=>{var e;z.debug("Creating prompt",{name:t.name});try{let o=await eu(this.api.prompts,t.name,this.api.requestOptions),i=(e=t.type)!=null?e:de.MUSTACHE,a=ru(t,o,i),c;if(a?(z.debug("Creating new prompt version",{name:t.name}),c=await this.api.prompts.createPromptVersion({name:t.name,version:{template:t.prompt,metadata:t.metadata,type:i}},this.api.requestOptions)):(z.debug("Returning existing prompt version",{name:t.name}),c=o),!c.promptId)throw new Error("Invalid API response: missing promptId");let d=await this.api.prompts.getPromptById(c.promptId,this.api.requestOptions),u=Te.fromApiResponse(d,c,this);return z.debug("Prompt created",{name:t.name}),t.description||t.tags?await u.updateProperties({description:t.description,tags:t.tags}):u}catch(o){throw z.error("Failed to create prompt",{name:t.name,error:o}),o}};this.getPrompt=async t=>{var e;z.debug("Getting prompt",t);try{let i=(e=(await this.api.prompts.getPrompts({filters:JSON.stringify([{field:"name",operator:"=",value:t.name}]),size:1},this.api.requestOptions)).content)==null?void 0:e[0];if(!i)return z.debug("Prompt not found",{name:t.name}),null;let a=await this.api.prompts.retrievePromptVersion(t,this.api.requestOptions);return Te.fromApiResponse(i,a,this)}catch(o){if(o instanceof p&&o.statusCode===404)return null;throw z.error("Failed to get prompt",{name:t.name,error:o}),o}};this.searchPrompts=async t=>{var e;z.debug("Searching prompts",{filterString:t});try{let o;if(t){let u=new Ee(t).getFilterExpressions();o=u?JSON.stringify(u):void 0;}let a=(e=(await this.api.prompts.getPrompts({filters:o,size:1e3},this.api.requestOptions)).content)!=null?e:[];return (await Promise.all(a.map(async d=>{if(!d.name)return null;try{let u=await this.api.prompts.retrievePromptVersion({name:d.name},this.api.requestOptions);return Te.fromApiResponse(d,u,this)}catch(u){return z.debug("Failed to get version for prompt",{name:d.name,error:u}),null}}))).filter(d=>d!==null)}catch(o){throw z.error("Failed to search prompts",{error:o}),o}};this.deletePrompts=async t=>{z.debug("Deleting prompts in batch",{count:t.length});try{await this.api.prompts.deletePromptsBatch({ids:t},this.api.requestOptions),z.info("Successfully deleted prompts",{count:t.length});}catch(e){throw z.error("Failed to delete prompts",{count:t.length,error:e}),e}};this.searchTraces=async t=>{let{projectName:e,filterString:o,maxResults:i=1e3,truncate:a=true,waitForAtLeast:c,waitForTimeout:d=60}=t!=null?t:{};z.debug("Searching traces",{projectName:e,filterString:o,maxResults:i,truncate:a,waitForAtLeast:c,waitForTimeout:d});let u=pu(o),g=e!=null?e:this.config.projectName,y=()=>nu(this.api,g,u,i,a);if(c===void 0)return await y();let k=await su(y,c,d*1e3,5e3);if(k.length<c)throw new Ra(`Timeout after ${d} seconds: expected ${c} traces, but only ${k.length} were found.`);return k};this.flush=async()=>{z.debug("Starting flush operation");try{await this.traceBatchQueue.flush(),await this.spanBatchQueue.flush(),await this.traceFeedbackScoresBatchQueue.flush(),await this.spanFeedbackScoresBatchQueue.flush(),await this.datasetBatchQueue.flush(),z.info("Successfully flushed all data to Opik");}catch(t){z.error("Error during flush operation:",{error:t instanceof Error?t.message:t});}};z.debug("Initializing OpikClient with config:",t),this.config=Im(t);let e={apiKey:this.config.apiKey,environment:this.config.apiUrl,workspaceName:this.config.workspaceName};t!=null&&t.headers&&(z.debug("Initializing OpikClient with additional headers:",t==null?void 0:t.headers),e.requestOptions={headers:t==null?void 0:t.headers}),this.api=new wa(e);let o=this.config.holdUntilFlush?24*60*60*1e3:this.config.batchDelayMs;this.spanBatchQueue=new ma(this.api,o),this.traceBatchQueue=new ua(this.api,o),this.spanFeedbackScoresBatchQueue=new da(this.api,o),this.traceFeedbackScoresBatchQueue=new ga(this.api,o),this.datasetBatchQueue=new fa(this.api,o),mm.push(this);}};var Lf="track.decorator",ut=new async_hooks.AsyncLocalStorage,Vf=()=>{let{span:n,trace:t}=ut.getStore()||{};if(!(!n||!t))return {span:n,trace:t}};function Hf(n){return !!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}function Jf({name:n,parentSpan:t,projectName:e,trace:o,type:i="llm"}){z.debug("Creating new span:",{name:n,parentSpan:t==null?void 0:t.data.id,projectName:e,type:i});let a=o;a||(a=um().trace({name:n,projectName:e}));let c=a.span({name:n,parentSpanId:t==null?void 0:t.data.id,projectName:e,type:i});return z.debug("Span created with ID:",c.data.id),{span:c,trace:a}}function Kf({args:n,span:t,trace:e}){if(z.debug("Starting span execution:",{spanId:t.data.id,traceId:e==null?void 0:e.data.id}),n.length===0)return;let o={arguments:n};z.debug("Recording span input"),t.update({input:o}),e&&(z.debug("Recording trace input"),e.update({input:o}));}function cu({result:n,span:t,trace:e,enrichSpan:o}){z.debug("Recording successful execution:",{spanId:t.data.id,traceId:e==null?void 0:e.data.id});let i=typeof n=="object"?n:{result:n},a=new Date,c={endTime:a,output:i};if(o){let d=o(n);Object.assign(c,d);}t.update(c),e&&e.update({endTime:a,output:i});}function lu({span:n,error:t,trace:e}){var o,i;z.error("Recording execution error:",{spanId:n.data.id,traceId:e==null?void 0:e.data.id,error:t instanceof Error?{name:t.name,message:t.message,stack:t.stack}:t}),t instanceof Error&&n.update({errorInfo:{message:t.message,exceptionType:t.name,traceback:(o=t.stack)!=null?o:""}}),n.end(),e&&(e.update({errorInfo:{message:t.message,exceptionType:t.name,traceback:(i=t.stack)!=null?i:""}}),e.end());}function Ea({name:n,projectName:t,type:e,enrichSpan:o}={},i){return function(...c){let d=ut.getStore(),{span:u,trace:g}=Jf({name:n!=null?n:i.name||Lf,parentSpan:d==null?void 0:d.span,projectName:t,trace:d==null?void 0:d.trace,type:e}),y=!d,k=this;return ut.run({span:u,trace:g},()=>{let S=y?g:void 0;try{Kf({args:c,span:u,trace:S});let x=i.apply(k,c);return Hf(x)?x.then(_=>(cu({span:u,result:_,trace:S,enrichSpan:o}),_),_=>{throw lu({span:u,error:_,trace:S}),_}):(cu({span:u,result:x,trace:S,enrichSpan:o}),x)}catch(x){throw lu({span:u,error:x,trace:S}),x}})}}function ze(n,t){if(typeof n=="function")return Ea({},n);let e=n;return t?Ea(e,t):function(...o){if(o.length===2&&typeof o[1]=="object"&&o[1]!==null&&"kind"in o[1]){let[c,d]=o;if(d.kind!=="method")throw new Error("track decorator is only applicable to methods");return Ea(e,c)}let[,,i]=o;if(!i||typeof i.value!="function")throw new Error("track decorator can only be applied to methods");let a=i.value;return i.value=Ea(e,a),i}}var dm=null;function um(){return dm===null&&(dm=new Oe),dm}var Xf=async()=>{z.debug("Starting flushAll operation");try{await Promise.all([um().flush(),...mm.map(n=>n.flush())]),z.debug("flushAll operation completed successfully");}catch(n){throw z.error("Error during flushAll operation:",{error:n instanceof Error?n.message:n,stack:n instanceof Error?n.stack:void 0}),n}};function mu(n,t){if(!t||typeof t!="object")throw new Error("Arguments must be an object");let e=n.validationSchema,i=e.extend(Object.fromEntries(Object.entries(e.shape).map(([a,c])=>[a,c.refine(d=>d!==void 0,{message:`${a} cannot be undefined`,path:[a]})]))).safeParse(t);if(!i.success){let a=i.error.issues.map(d=>d.path[0]).filter(Boolean),c=[...new Set(a)];throw new Error(Gf(n,t,c))}}function Gf(n,t,e){let o=Object.keys(t),i=e.filter(a=>!(a in t));return `Metric '${n.name}' is skipped, missing required arguments: ${i.join(", ")}. Available arguments: ${o.join(", ")}.`}var va=class{static calculateAverageScores(t){if(!t||t.length===0)return new Map;let e=new Map;for(let i of t)if(!(!i||!i.scoreResults||i.scoreResults.length===0))for(let a of i.scoreResults){if(!a||a.scoringFailed||typeof a.value!="number")continue;let c=e.get(a.name)||{sum:0,count:0};c.sum+=a.value,c.count+=1,e.set(a.name,c);}let o=new Map;return e.forEach((i,a)=>{o.set(a,i.count>0?i.sum/i.count:0);}),o}static formatScore(t){return t.toFixed(4)}static formatTime(t){let e=Math.floor(t/3600),o=Math.floor(t%3600/60),i=Math.floor(t%60);return `${e.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}static async generateResultTable(t,e,o,i){if(t.length===0){z.info(`
|
|
13
|
+
No test results available to display.`);return}if(o.size===0){z.info(`
|
|
14
|
+
No metrics available to display.`);return}let a=[...o.keys()].sort(),c=this.formatTime(i),d=[Pa__default.default.bold(`Total time: ${c}`),Pa__default.default.bold(`Number of samples: ${t.length}`),"",...a.map(y=>{let k=this.formatScore(o.get(y)||0);return Pa__default.default.green(`${y}: ${k} (avg)`)})].join(`
|
|
15
|
+
`),u=await e.ensureNameLoaded(),g=$f__default.default(d,{title:`${u} (${t.length} samples)`,titleAlignment:"left",padding:1,margin:0,borderColor:"cyan",borderStyle:"round"});z.info(`
|
|
16
16
|
`+g+`
|
|
17
|
-
`),
|
|
17
|
+
`),z.info(Pa__default.default.blue("Uploading results to Opik ... "));}static async displayExperimentLink(t){let e=await t.getUrl();z.info(`View the results ${Rt(e,"in your Opik dashboard")}`);}static async processResults(t,e,o=0){let i=this.calculateAverageScores(t);await this.generateResultTable(t,e,i,o),await this.displayExperimentLink(e);let a=await e.ensureNameLoaded();return {experimentId:e.id,experimentName:a,testResults:t}}};function du(n,t,e){if(!n||typeof t!="string"||t.trim()==="")return e;let o=t.replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split("."),i=n;for(let a of o)if(typeof i=="object"&&i!==null&&a in i)i=i[a];else return e;return i===void 0?e:i}var uu,gm;uu=[ze({name:"metrics_calculation",type:we.General})];var er=class{constructor(t,e,o){Am(gm,5,this);this.client=void 0;this.dataset=void 0;this.task=void 0;this.scoringMetrics=void 0;this.projectName=void 0;this.nbSamples=void 0;this.scoringKeyMapping=void 0;this.experiment=void 0;this.rootTrace=void 0;this.client=e,this.dataset=t.dataset,this.experiment=o,this.task=t.task,this.scoringMetrics=t.scoringMetrics||[],this.projectName=t.projectName,this.nbSamples=t.nbSamples,this.scoringKeyMapping=t.scoringKeyMapping;}async execute(){var y;let t=performance.now(),e=[],o=await this.dataset.getItems(this.nbSamples),i=o.length,a=z.settings.minLevel;z.settings.minLevel=6;let c=Qf__default.default({text:`Evaluating dataset (0/${i} items)`}).start(),d=[];for(let k=0;k<o.length;k++){let S=o[k];try{this.rootTrace=this.client.trace({projectName:this.projectName,name:"evaluation_task",createdBy:"evaluation",input:S}),ut.enterWith({trace:this.rootTrace});let x=await this.executeTask(S);d.push(x),this.rootTrace.update({output:x.testCase.taskOutput,endTime:new Date});}catch(x){let _=x instanceof Error?x.message:String(x);z.error(`Error processing dataset item: ${S.id} - ${_}`),x instanceof Error&&this.rootTrace.update({errorInfo:{message:x.message,exceptionType:x.name,traceback:(y=x.stack)!=null?y:""},endTime:new Date});}e.push(new Sa({datasetItemId:S.id,traceId:this.rootTrace.data.id})),c.text=`Evaluating dataset (${k+1}/${i} items, ${Math.round((k+1)/i*100)}%)`;}let g=(performance.now()-t)/1e3;return c.succeed(`Evaluation complete: ${i} items processed in ${g.toFixed(2)}s`),z.settings.minLevel=a,this.experiment.insert(e),await this.client.flush(),va.processResults(d,this.experiment,g)}async executeTask(t){let e={},o=[];z.debug(`Starting evaluation task on dataset item ${t.id}`),e=await ze({name:"llm_task",type:we.General},this.task)(t),z.debug(`Finished evaluation task on dataset item ${t.id}`);let i=this.prepareScoringInputs(t,e),a={traceId:this.rootTrace.data.id,datasetItemId:t.id,scoringInputs:i,taskOutput:e};return this.scoringMetrics.length>0?this.calculateScores(a):{testCase:a,scoreResults:o}}async calculateScores(t){let e=[],{scoringInputs:o}=t;for(let i of this.scoringMetrics){z.debug(`Calculating score for metric ${i.name}`);try{mu(i,o);let a=await i.score(o),c=Array.isArray(a)?a:[a];e.push(...c);}catch(a){let c=a instanceof Error?a.message:String(a);z.error(`Metric ${i.name} failed: ${c}`);}z.debug(`Finished calculating score for metric ${i.name}`);}return e.forEach(i=>{var a;return (a=this.rootTrace)==null?void 0:a.score({name:i.name,value:i.value,reason:i.reason})}),{testCase:t,scoreResults:e}}prepareScoringInputs(t,e){let o={...t,...e};if(!this.scoringKeyMapping)return o;let i={...o};for(let[a,c]of Object.entries(this.scoringKeyMapping)){let d=du(o,c);d!==void 0&&(i[a]=d);}return i}};gm=_m(),Em(gm,1,"calculateScores",uu,er),Ba(gm,er);var rr=class rr{static getInstance(t){return rr.instance||(rr.instance=new Oe(t)),rr.instance}};rr.instance=null;var Ca=rr;async function gu(n){var o;if(!n.dataset)throw new Error("Dataset is required for evaluation");if(!n.task)throw new Error("Task function is required for evaluation");let t=(o=n.client)!=null?o:Ca.getInstance(),e=await t.createExperiment({name:n.experimentName,datasetName:n.dataset.name,experimentConfig:n.experimentConfig,prompts:n.prompts});try{let i=new er(n,t,e);return z.info("Starting evaluation"),i.execute()}catch(i){throw z.error(`Error during evaluation: ${i}`),i}}var We=class{constructor(t){this.modelName=t;}};var gt=class n extends Error{constructor(t){super(t),this.name="ModelError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},or=class n extends gt{constructor(e,o){super(e);this.cause=o;this.name="ModelGenerationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},Pe=class n extends gt{constructor(t){super(t),this.name="ModelConfigurationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}};function eh(n,t){return n.startsWith("gpt-")||n.startsWith("o1")||n.startsWith("o3")||n.startsWith("chatgpt-")}function rh(n,t){return n.startsWith("claude-")}function oh(n,t){return n.startsWith("gemini-")||n.startsWith("gemma-")}function wm(n,t,e){if(!t)throw new Pe(`API key for ${n} is not configured. Please provide it via the 'apiKey' option or set the ${e} environment variable.`)}function fm(n,t){if(eh(n)){let e=(t==null?void 0:t.apiKey)||process.env.OPENAI_API_KEY;return wm("OpenAI",e,"OPENAI_API_KEY"),openai.createOpenAI({apiKey:e,...t})(n)}if(rh(n)){let e=(t==null?void 0:t.apiKey)||process.env.ANTHROPIC_API_KEY;return wm("Anthropic",e,"ANTHROPIC_API_KEY"),anthropic.createAnthropic({apiKey:e,...t})(n)}if(oh(n)){let e=(t==null?void 0:t.apiKey)||process.env.GOOGLE_API_KEY;return wm("Google Gemini",e,"GOOGLE_API_KEY"),google.createGoogleGenerativeAI({apiKey:e,...t})(n)}throw new Pe(`Unable to detect provider for model ID: ${n}. Supported providers are OpenAI (gpt-*, o1*, o3*, chatgpt-*), Anthropic (claude-*), and Google Gemini (gemini-*, gemma-*).`)}var th={inputTokens:"prompt_tokens",outputTokens:"completion_tokens",totalTokens:"total_tokens",reasoningTokens:"reasoning_tokens",cachedInputTokens:"cached_input_tokens"};function ih(n){if(!n||typeof n!="object")return false;let t=n,e="usage"in t,o="response"in t,i="text"in t,a="object"in t;return e||o||i||a}function hm(n,t){if(!ih(n))return {model:t};let e={model:ah(n,t)},o=nh(n.usage);o&&(e.usage=o);let i=sh(n);i&&(e.provider=i);let a=ch(n);a&&(e.metadata=a);let c=lh(n);return c&&(e.output=c),e}function ah(n,t){var e,o;return (o=(e=n.response)==null?void 0:e.modelId)!=null?o:t}function nh(n){if(!n)return;let t={};for(let[e,o]of Object.entries(th)){let i=n[e];i!==void 0&&(t[o]=i);}return Object.keys(t).length>0?t:void 0}function sh(n){if(!n.providerMetadata)return;let t=Object.keys(n.providerMetadata);return t.length>0?t[0]:void 0}function ph(n){if(!n)return;let t={};return n.id&&(t.id=n.id),n.timestamp&&(t.timestamp=n.timestamp.toISOString()),Object.keys(t).length>0?t:void 0}function ch(n){let t={};n.usage&&(t.usage=n.usage),n.warnings&&n.warnings.length>0&&(t.warnings=n.warnings);let e=ph(n.response);return e&&(t.response=e),n.providerMetadata&&(t.providerMetadata=n.providerMetadata),n.finishReason&&(t.finishReason=n.finishReason),Object.keys(t).length>0?t:void 0}function lh(n){let t={};return "text"in n&&n.text&&(t.text=n.text),"object"in n&&n.object!==void 0&&(t.object=n.object),"toolCalls"in n&&Array.isArray(n.toolCalls)&&(t.toolCalls=n.toolCalls),"toolResults"in n&&Array.isArray(n.toolResults)&&(t.toolResults=n.toolResults),"sources"in n&&Array.isArray(n.sources)&&(t.sources=n.sources),Object.keys(t).length>0?t:void 0}var tr=class extends We{constructor(t,e={trackGenerations:true}){let o=typeof t=="string"?t:t.modelId;super(o);let{trackGenerations:i,...a}=e;try{typeof t!="string"?(this.model=t,z.debug("Initialized VercelAIChatModel with custom LanguageModel")):(this.model=fm(t,a),z.debug(`Initialized VercelAIChatModel with model ID: ${t}`)),i?(this._generateText=ze({name:"model.generateText",type:we.Llm,enrichSpan:c=>hm(c,this.modelName)},ai$1.generateText),this._generateObject=ze({name:"model.generateObject",type:we.Llm,enrichSpan:c=>hm(c,this.modelName)},ai$1.generateObject)):(this._generateText=ai$1.generateText,this._generateObject=ai$1.generateObject);}catch(c){throw new Pe(`Failed to initialize model ${o}: ${c instanceof Error?c.message:String(c)}`)}}async generateString(t,e,o){try{let i;if(e){z.debug(`Generating structured output with model ${this.modelName}, input length: ${t.length}`);let a=await this._generateObject({model:this.model,prompt:t,schema:e,...o});z.debug(`Generated structured output with model ${this.modelName}`),i=JSON.stringify(a.object);}else {z.debug(`Generating text with model ${this.modelName}, input length: ${t.length}`);let a=await this._generateText({model:this.model,prompt:t,...o});z.debug(`Generated text with model ${this.modelName}, output length: ${a.text.length}`),i=a.text;}return i}catch(i){let a=e?`Failed to generate structured output with model ${this.modelName}`:`Failed to generate text with model ${this.modelName}`;throw z.error(a,{error:i}),new or(a,i instanceof Error?i:new Error(String(i)))}}async generateProviderResponse(t,e){try{z.debug(`Generating provider response with model ${this.modelName}, messages count: ${t.length}`);let o=await this._generateText({model:this.model,messages:t,...e});return z.debug(`Generated provider response with model ${this.modelName}`),o}catch(o){let i=`Failed to generate provider response with model ${this.modelName}`;throw z.error(i,{error:o}),new or(i,o instanceof Error?o:new Error(String(o)))}}};var hu="gpt-4o";function Rm(n,t){return new tr(n,t)}function Ru(n,t){return new tr(n,t)}function mh(n){return n instanceof We}function dh(n){return typeof n=="object"&&n!==null&&"modelId"in n&&typeof n.modelId=="string"}function uh(n){return typeof n=="string"&&n.length>0}function gh(n){let t=typeof n,e=t==="object"?JSON.stringify(n):String(n);return new Error(`Invalid model type. Expected one of:
|
|
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: ${
|
|
21
|
+
- undefined (uses default model: ${hu})
|
|
22
22
|
|
|
23
|
-
Received: ${t} ${e}`)}function
|
|
24
|
-
`)}
|
|
23
|
+
Received: ${t} ${e}`)}function wt(n,t){if(n==null)return Rm(hu,t);if(uh(n))return Rm(n,t);if(mh(n))return n;if(dh(n))return Ru(n,t);throw gh(n)}function bu(n){return n.map(t=>{let e=Array.isArray(t.content)?wh(t.content):t.content;return `${t.role}: ${e}`}).join(`
|
|
24
|
+
`)}function wh(n){return n.map(t=>t.type==="text"?t.text:t.type==="file"?`[file: ${t.filename||"unknown"}]`:t.type==="tool-call"?`[tool-call: ${t.toolName}]`:t.type==="tool-result"?`[tool-result: ${t.toolName}]`:t.type==="reasoning"?`[reasoning: ${t.text}]`:"").filter(t=>t.length>0).join(`
|
|
25
|
+
`)}function fh(n,t,e){return typeof n=="string"?he(n,t,e):Array.isArray(n)?n.map(i=>i.type==="text"&&typeof i.text=="string"?{...i,text:he(i.text,t,e)}:i.type==="image"&&typeof i.image=="string"?{...i,image:he(i.image,t,e)}:i.type==="file"&&typeof i.data=="string"?{...i,data:he(i.data,t,e)}:i.type==="reasoning"&&typeof i.text=="string"?{...i,text:he(i.text,t,e)}:i):n}function yu(n,t,e){let o=fh(n.content,t,e);return {...n,content:o}}async function mre(n){var i;if(!n.dataset)throw new Error("Dataset is required for prompt evaluation");if(!n.messages||n.messages.length===0)throw new Error("Messages array is required and cannot be empty");if(n.experimentConfig!==void 0&&(typeof n.experimentConfig!="object"||n.experimentConfig===null||Array.isArray(n.experimentConfig)))throw new Error("experimentConfig must be a plain object, not an array or primitive value");let t=wt(n.model),e={...n.experimentConfig,prompt_template:n.messages,model:t.modelName,...n.temperature!==void 0&&{temperature:n.temperature},...n.seed!==void 0&&{seed:n.seed}},o=hh(t,n.messages,(i=n.templateType)!=null?i:de.MUSTACHE,{temperature:n.temperature,seed:n.seed});return gu({dataset:n.dataset,task:o,scoringMetrics:n.scoringMetrics,experimentName:n.experimentName,projectName:n.projectName,experimentConfig:e,prompts:n.prompts,client:n.client,nbSamples:n.nbSamples,scoringKeyMapping:n.scoringKeyMapping})}function hh(n,t,e,o){return async i=>{let a=t.map(g=>yu(g,i,e)),c=await n.generateProviderResponse(a,o),d=Rh(c);return {input:bu(a),output:d}}}function Rh(n){return n&&typeof n=="object"?"text"in n&&typeof n.text=="string"?n.text:"content"in n&&typeof n.content=="string"?n.content:JSON.stringify(n):String(n)}var pe=class{constructor(t,e=true){if(this.name=t,this.trackMetric=e,e){let o=this.score.bind(this);this.score=ze({name:this.name,type:we.General},o);}}};var bh=bm__default.default.object({output:bm__default.default.unknown(),expected:bm__default.default.unknown()}),ku=class extends pe{constructor(e="exact_match",o=true){super(e,o);this.validationSchema=bh;}async score(e){let{output:o,expected:i}=e,a=o===i?1:0;return {name:this.name,value:a,reason:`Exact match: ${a===1?"Match":"No match"}`}}};var yh=bm__default.default.object({output:bm__default.default.string(),substring:bm__default.default.string()}),zu=class extends pe{constructor(e="contains",o=true,i=false){super(e,o);this.validationSchema=yh;this.caseSensitive=i;}async score(e){let{output:o,substring:i}=e,a=this.caseSensitive?o:o.toLowerCase(),c=this.caseSensitive?i:i.toLowerCase();return a.includes(c)?{name:this.name,value:1,reason:`Contains: "${i}" found in output.`}:{name:this.name,value:0,reason:`Contains: "${i}" not found in output.`}}};var kh=bm.z.object({output:bm.z.string(),pattern:bm.z.string(),flags:bm.z.string().optional()}),Su=class extends pe{constructor(e="regex_match",o=true){super(e,o);this.validationSchema=kh;}async score(e){let{output:o,pattern:i,flags:a}=e,c;typeof i=="string"&&a?c=new RegExp(i,a):c=new RegExp(i);let d=c.test(o);return {name:this.name,value:d?1:0,reason:d?`Regex: Output matches the regex pattern: ${i}`:`Regex: Output does not match the regex pattern: ${i}`}}};var zh=bm__default.default.object({output:bm__default.default.unknown()}),_u=class extends pe{constructor(e="is_json_metric",o=true){super(e,o);this.validationSchema=zh;}async score(e){let{output:o}=e;try{return JSON.parse(o),{name:this.name,value:1,reason:"IsJson: Output is valid JSON."}}catch{return {name:this.name,value:0,reason:"IsJson: Output is not valid JSON"}}}};var ue=class extends pe{constructor(t,e){var i;let o=(i=e==null?void 0:e.trackMetric)!=null?i:true;super(t,o),this.temperature=e==null?void 0:e.temperature,this.seed=e==null?void 0:e.seed,this.maxTokens=e==null?void 0:e.maxTokens,this.modelSettings=e==null?void 0:e.modelSettings,this.model=this.initModel(e==null?void 0:e.model,{trackGenerations:o});}initModel(t,e){return wt(t,e)}buildModelOptions(){return {...this.modelSettings,...this.temperature!==void 0&&{temperature:this.temperature},...this.seed!==void 0&&{seed:this.seed},...this.maxTokens!==void 0&&{maxTokens:this.maxTokens}}}};function Tu(n,t=[]){let e="";return t.length>0&&(e=`
|
|
25
26
|
|
|
26
27
|
###EXAMPLES###
|
|
27
28
|
|
|
@@ -83,7 +84,7 @@ ${e}
|
|
|
83
84
|
Analyze the following text and provide your verdict score, and reason in the specified JSON format:
|
|
84
85
|
|
|
85
86
|
${n}
|
|
86
|
-
`}var
|
|
87
|
+
`}var ja=class n extends Error{constructor(t){super(t),this.name="MetricError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},ce=class n extends ja{constructor(e,o){super(e);this.cause=o;this.name="MetricComputationError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}},Ua=class n extends ja{constructor(e,o){super(e);this.cause=o;this.name="JSONParsingError",Error.captureStackTrace&&Error.captureStackTrace(this,n);}};function ve(n){try{return JSON.parse(n)}catch{return Sh(n)}}function Sh(n){try{let t=n.indexOf("{"),e=n.lastIndexOf("}");if(t===-1||e===-1||t>=e)throw new Error("No valid JSON object found in content");let o=n.substring(t,e+1);return JSON.parse(o)}catch(t){let e=t instanceof Error?t.message:String(t);throw new Ua(`Failed to extract JSON from content: ${e}`,t instanceof Error?t:void 0)}}function Au(n,t){try{let e=ve(n),o=Number(e.score);if(isNaN(o)||o<0||o>1)throw new Error(`Moderation score must be between 0.0 and 1.0, got ${o}`);return {name:t,value:o,reason:String(e.reason||"")}}catch(e){let o=e instanceof Error?e.message:String(e);throw z.error(`Failed to parse model output: ${o}`),new ce("Failed to calculate moderation score. The model output could not be parsed.",e instanceof Error?e:void 0)}}var xh=bm.z.object({output:bm.z.string()}),_h=bm.z.object({score:bm.z.number(),reason:bm.z.string()}),Na=class extends ue{constructor(e){var i,a;let o=(i=e==null?void 0:e.name)!=null?i:"moderation_metric";super(o,{model:e==null?void 0:e.model,trackMetric:e==null?void 0:e.trackMetric,temperature:e==null?void 0:e.temperature,seed:e==null?void 0:e.seed,maxTokens:e==null?void 0:e.maxTokens,modelSettings:e==null?void 0:e.modelSettings});this.validationSchema=xh;this.fewShotExamples=(a=e==null?void 0:e.fewShotExamples)!=null?a:[];}async score(e){let{output:o}=e,i=Tu(o,this.fewShotExamples),a=this.buildModelOptions(),c=await this.model.generateString(i,_h,a);return Au(c,this.name)}};function Eu(n,t){return `
|
|
87
88
|
You are an impartial judge tasked with evaluating the quality and usefulness of AI-generated responses.
|
|
88
89
|
Your evaluation should consider the following key factors:
|
|
89
90
|
- Helpfulness: How well does it solve the user's problem?
|
|
@@ -119,7 +120,7 @@ ${n}
|
|
|
119
120
|
AI Response: ${t}
|
|
120
121
|
|
|
121
122
|
Provide your evaluation in the specified JSON format.
|
|
122
|
-
`}function
|
|
123
|
+
`}function Pu(n,t){try{let e=ve(n),o=Number(e.score);if(isNaN(o)||o<0||o>1)throw new Error(`Usefulness score must be between 0.0 and 1.0, got ${o}`);return {name:t,value:o,reason:String(e.reason||"")}}catch(e){let o=e instanceof Error?e.message:String(e);throw z.error(`Failed to parse model output: ${o}`),new ce("Failed to calculate usefulness score. The model output could not be parsed.",e instanceof Error?e:void 0)}}var Th=bm.z.object({input:bm.z.string(),output:bm.z.string()}),Ah=bm.z.object({score:bm.z.number(),reason:bm.z.string()}),Ma=class extends ue{constructor(e){var i;let o=(i=e==null?void 0:e.name)!=null?i:"usefulness_metric";super(o,{model:e==null?void 0:e.model,trackMetric:e==null?void 0:e.trackMetric,temperature:e==null?void 0:e.temperature,seed:e==null?void 0:e.seed,maxTokens:e==null?void 0:e.maxTokens,modelSettings:e==null?void 0:e.modelSettings});this.validationSchema=Th;}async score(e){let{input:o,output:i}=e,a=Eu(o,i),c=this.buildModelOptions(),d=await this.model.generateString(a,Ah,c);return Pu(d,this.name)}};var Eh=`You are an expert judge tasked with evaluating the faithfulness of an AI-generated answer to the given context. Analyze the provided INPUT, CONTEXT, and OUTPUT to determine if the OUTPUT contains any hallucinations or unfaithful information.
|
|
123
124
|
|
|
124
125
|
Guidelines:
|
|
125
126
|
1. The OUTPUT must not introduce new information beyond what's provided in the CONTEXT.
|
|
@@ -154,7 +155,7 @@ It is crucial that you provide your answer in the following JSON format:
|
|
|
154
155
|
"reason": ["reason 1", "reason 2"]
|
|
155
156
|
}}
|
|
156
157
|
Reasons amount is not restricted. Output must be JSON format only.
|
|
157
|
-
`,
|
|
158
|
+
`,Ph=`You are an expert judge tasked with evaluating the factual accuracy and reliability of an AI-generated answer. Analyze the provided INPUT, and OUTPUT to determine if the OUTPUT contains any hallucinations or unfaithful information.
|
|
158
159
|
|
|
159
160
|
Guidelines:
|
|
160
161
|
1. Evaluate the OUTPUT based on generally accepted facts and reliable information.
|
|
@@ -185,7 +186,7 @@ It is crucial that you provide your answer in the following JSON format:
|
|
|
185
186
|
"reason": ["some reason 1", "some reason 2"]
|
|
186
187
|
}}
|
|
187
188
|
Reasons amount is not restricted. Output must be JSON format only.
|
|
188
|
-
`;function
|
|
189
|
+
`;function vu(n,t){return n.length===0?"":`
|
|
189
190
|
|
|
190
191
|
EXAMPLES:
|
|
191
192
|
|
|
@@ -197,7 +198,7 @@ ${i}Output: ${o.output}
|
|
|
197
198
|
{"score": "${o.score}", "reason": "${o.reason}"}
|
|
198
199
|
</example>`}).join(`
|
|
199
200
|
|
|
200
|
-
`)}`}function
|
|
201
|
+
`)}`}function Cu(n,t,e,o=[]){let i=vu(o,true);return Eh.replace("{examples_str}",i).replace("{input}",n).replace("{context}",JSON.stringify(e)).replace("{output}",t)}function Iu(n,t,e=[]){let o=vu(e,false);return Ph.replace("{examples_str}",o).replace("{input}",n).replace("{output}",t)}function ju(n,t){try{let e=ve(n),o=e.score;if(o==null)throw new Error(`Hallucination score is required but got ${o}`);let i=Number(o);if(isNaN(i)||i<0||i>1)throw new Error(`Hallucination score must be between 0.0 and 1.0, got ${i}`);let a="",c=e.reason;return Array.isArray(c)?a=c.map(d=>String(d)).join(" "):c&&(a=String(c)),{name:t,value:i,reason:a}}catch(e){let o=e instanceof Error?e.message:String(e);throw z.error(`Failed to parse model output: ${o}`),new ce("Failed to calculate hallucination score. The model output could not be parsed.",e instanceof Error?e:void 0)}}var vh=bm.z.object({input:bm.z.string(),output:bm.z.string(),context:bm.z.array(bm.z.string()).optional()}),Ch=bm.z.object({score:bm.z.number(),reason:bm.z.union([bm.z.string(),bm.z.array(bm.z.string())])}),Da=class extends ue{constructor(e){var i,a;let o=(i=e==null?void 0:e.name)!=null?i:"hallucination_metric";super(o,{model:e==null?void 0:e.model,trackMetric:e==null?void 0:e.trackMetric,temperature:e==null?void 0:e.temperature,seed:e==null?void 0:e.seed,maxTokens:e==null?void 0:e.maxTokens,modelSettings:e==null?void 0:e.modelSettings});this.validationSchema=vh;this.fewShotExamples=(a=e==null?void 0:e.fewShotExamples)!=null?a:[];}async score(e){let{input:o,output:i,context:a}=e,c=a?Cu(o,i,a,this.fewShotExamples):Iu(o,i,this.fewShotExamples),d=this.buildModelOptions(),u=await this.model.generateString(c,Ch,d);return ju(u,this.name)}};var Uu=[{title:"Low Relevance Score",input:"What's the capital of France?",output:"The Eiffel Tower is a famous landmark.",context:["France is a country in Europe.","Paris is known for its iconic Eiffel Tower."],answer_relevance_score:.2,reason:"The answer provides information about the Eiffel Tower, which is related to France, but fails to address the specific question about the capital city. It doesn't directly answer the user's query, resulting in low relevance."},{title:"Medium Relevance Score",input:"What's the capital of France?",output:"France has many beautiful cities, including Paris.",context:["France is a country in Europe.","Paris is the capital and largest city of France."],answer_relevance_score:.6,reason:"The answer mentions Paris, which is the correct capital, but it's presented as just one of many cities rather than explicitly stating it's the capital. The response is partially relevant but lacks directness in addressing the specific question."},{title:"High Relevance Score",input:"What's the capital of France?",output:"The capital of France is Paris, a city known for its iconic Eiffel Tower.",context:["France is a country in Europe.","Paris is the capital and largest city of France."],answer_relevance_score:.9,reason:"The answer directly and correctly identifies Paris as the capital of France, which is highly relevant to the user's question. It also provides additional context about the Eiffel Tower, which aligns with the provided context. The response is comprehensive and relevant, though slightly more detailed than necessary, preventing a perfect score."}],Nu=[{title:"Low Relevance Score",input:"What's the capital of France?",output:"The Eiffel Tower is a famous landmark.",answer_relevance_score:.2,reason:"The answer provides information about the Eiffel Tower, which is related to France, but fails to address the specific question about the capital city. It doesn't directly answer the user's query, resulting in low relevance."},{title:"Medium Relevance Score",input:"What's the capital of France?",output:"France has many beautiful cities, including Paris.",answer_relevance_score:.6,reason:"The answer mentions Paris, which is the correct capital, but it's presented as just one of many cities rather than explicitly stating it's the capital. The response is partially relevant but lacks directness in addressing the specific question."},{title:"High Relevance Score",input:"What's the capital of France?",output:"The capital of France is Paris, a city known for its iconic Eiffel Tower.",answer_relevance_score:.9,reason:"The answer directly and correctly identifies Paris as the capital of France, which is highly relevant to the user's question. It also provides additional context about the Eiffel Tower, which aligns with the provided context. The response is comprehensive and relevant, though slightly more detailed than necessary, preventing a perfect score."}];function Ih(n){return n.map((t,e)=>`#### Example ${e+1}: ${t.title}
|
|
201
202
|
|
|
202
203
|
- **Input:** "${t.input}"
|
|
203
204
|
- **Output:** "${t.output}"
|
|
@@ -210,7 +211,7 @@ ${i}Output: ${o.output}
|
|
|
210
211
|
}
|
|
211
212
|
\`\`\``).join(`
|
|
212
213
|
|
|
213
|
-
`)}function
|
|
214
|
+
`)}function jh(n){return n.map((t,e)=>`#### Example ${e+1}: ${t.title}
|
|
214
215
|
|
|
215
216
|
- **Input:** "${t.input}"
|
|
216
217
|
- **Output:** "${t.output}"
|
|
@@ -222,7 +223,7 @@ ${i}Output: ${o.output}
|
|
|
222
223
|
}
|
|
223
224
|
\`\`\``).join(`
|
|
224
225
|
|
|
225
|
-
`)}function
|
|
226
|
+
`)}function Mu(n,t,e,o){return `
|
|
226
227
|
YOU ARE AN EXPERT IN NLP EVALUATION METRICS, SPECIALLY TRAINED TO ASSESS ANSWER RELEVANCE IN RESPONSES
|
|
227
228
|
PROVIDED BY LANGUAGE MODELS. YOUR TASK IS TO EVALUATE THE RELEVANCE OF A GIVEN ANSWER FROM
|
|
228
229
|
ANOTHER LLM BASED ON THE USER'S INPUT AND CONTEXT PROVIDED.
|
|
@@ -268,7 +269,7 @@ ${i}Output: ${o.output}
|
|
|
268
269
|
|
|
269
270
|
###FEW-SHOT EXAMPLES###
|
|
270
271
|
|
|
271
|
-
${
|
|
272
|
+
${Ih(o)}
|
|
272
273
|
|
|
273
274
|
###INPUTS:###
|
|
274
275
|
***
|
|
@@ -281,7 +282,7 @@ ${i}Output: ${o.output}
|
|
|
281
282
|
Context:
|
|
282
283
|
${JSON.stringify(e)}
|
|
283
284
|
***
|
|
284
|
-
`}function
|
|
285
|
+
`}function Du(n,t,e){return `
|
|
285
286
|
YOU ARE AN EXPERT IN NLP EVALUATION METRICS, SPECIALLY TRAINED TO ASSESS ANSWER RELEVANCE IN RESPONSES
|
|
286
287
|
PROVIDED BY LANGUAGE MODELS. YOUR TASK IS TO EVALUATE THE RELEVANCE OF A GIVEN ANSWER FROM
|
|
287
288
|
ANOTHER LLM BASED ON THE USER'S INPUT.
|
|
@@ -326,7 +327,7 @@ ${i}Output: ${o.output}
|
|
|
326
327
|
|
|
327
328
|
###FEW-SHOT EXAMPLES###
|
|
328
329
|
|
|
329
|
-
${
|
|
330
|
+
${jh(e)}
|
|
330
331
|
|
|
331
332
|
###INPUTS:###
|
|
332
333
|
***
|
|
@@ -336,4 +337,4 @@ ${i}Output: ${o.output}
|
|
|
336
337
|
Output:
|
|
337
338
|
${t}
|
|
338
339
|
***
|
|
339
|
-
`}function
|
|
340
|
+
`}function Fu(n,t){try{let e=ve(n),o=e.answer_relevance_score;if(o==null)throw new Error(`Answer relevance score is required but got ${o}`);let i=Number(o);if(isNaN(i)||i<0||i>1)throw new Error(`Answer relevance score must be between 0.0 and 1.0, got ${i}`);return {name:t,value:i,reason:String(e.reason||"")}}catch(e){let o=e instanceof Error?e.message:String(e);throw z.error(`Failed to parse model output: ${o}`),new ce("Failed to calculate answer relevance score. The model output could not be parsed.",e instanceof Error?e:void 0)}}var Uh=bm.z.object({input:bm.z.string(),output:bm.z.string(),context:bm.z.array(bm.z.string()).optional()}),Nh=bm.z.object({answer_relevance_score:bm.z.number(),reason:bm.z.string()}),Fa=class extends ue{constructor(e){var i,a,c,d;let o=(i=e==null?void 0:e.name)!=null?i:"answer_relevance_metric";super(o,{model:e==null?void 0:e.model,trackMetric:e==null?void 0:e.trackMetric,temperature:e==null?void 0:e.temperature,seed:e==null?void 0:e.seed,maxTokens:e==null?void 0:e.maxTokens,modelSettings:e==null?void 0:e.modelSettings});this.validationSchema=Uh;this.fewShotExamplesWithContext=(a=e==null?void 0:e.fewShotExamples)!=null?a:Uu,this.fewShotExamplesNoContext=(c=e==null?void 0:e.fewShotExamplesNoContext)!=null?c:Nu,this.requireContext=(d=e==null?void 0:e.requireContext)!=null?d:true;}async score(e){let{input:o,output:i,context:a}=e;if(!a&&this.requireContext)throw new ce(`${this.name} requires context by default. If you want to allow execution in no-context mode, enable it via 'new AnswerRelevance({ requireContext: false })'`);let c=a?Mu(o,i,a,this.fewShotExamplesWithContext):Du(o,i,this.fewShotExamplesNoContext),d=this.buildModelOptions(),u=await this.model.generateString(c,Nh,d);return Fu(u,this.name)}};exports.AnswerRelevance=Fa;exports.BaseLLMJudgeMetric=ue;exports.BaseMetric=pe;exports.Contains=zu;exports.ExactMatch=ku;exports.Hallucination=Da;exports.IsJson=_u;exports.ModelConfigurationError=Pe;exports.ModelError=gt;exports.ModelGenerationError=or;exports.Moderation=Na;exports.Opik=Oe;exports.OpikBaseModel=We;exports.OpikQueryLanguage=Ee;exports.OpikSpanType=we;exports.Prompt=Te;exports.PromptType=de;exports.RegexMatch=Su;exports.Usefulness=Ma;exports.VercelAIChatModel=tr;exports.createModel=Rm;exports.createModelFromInstance=Ru;exports.detectProvider=fm;exports.disableLogger=Gu;exports.evaluate=gu;exports.evaluatePrompt=mre;exports.flushAll=Xf;exports.generateId=Z;exports.getTrackContext=Vf;exports.logger=z;exports.resolveModel=wt;exports.setLoggerLevel=Pm;exports.track=ze;
|