opik 1.6.13 → 1.6.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,55 +0,0 @@
1
- import { BaseCallbackHandler, BaseCallbackHandlerInput } from '@langchain/core/callbacks/base';
2
- import { Serialized } from '@langchain/core/load/serializable';
3
- import { ChainValues } from '@langchain/core/utils/types';
4
- import { J as JsonNode, O as OpikClient } from '../Client-CgkZJ_1L.cjs';
5
- import { RunnableConfig } from '@langchain/core/runnables';
6
- import { LLMResult, ChatResult } from '@langchain/core/outputs';
7
- import { BaseMessage } from '@langchain/core/messages';
8
- import { AgentAction, AgentFinish } from '@langchain/core/agents';
9
- import 'stream';
10
-
11
- interface OpikCallbackHandlerOptions {
12
- tags?: [];
13
- metadata?: JsonNode;
14
- projectName?: string;
15
- client?: OpikClient;
16
- }
17
- declare class OpikCallbackHandler extends BaseCallbackHandler implements BaseCallbackHandlerInput {
18
- name: string;
19
- private options;
20
- private client;
21
- private rootTraceId?;
22
- private rootTrace?;
23
- private spansMap;
24
- constructor(options?: Partial<OpikCallbackHandlerOptions>);
25
- private startTracing;
26
- private endTracing;
27
- handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: {
28
- options: RunnableConfig;
29
- invocation_params?: Record<string, unknown>;
30
- batch_size: number;
31
- cache?: boolean;
32
- }, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
33
- handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: {
34
- options: RunnableConfig;
35
- invocation_params?: Record<string, unknown>;
36
- batch_size: number;
37
- cache?: boolean;
38
- }, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
39
- handleLLMError(error: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
40
- handleLLMEnd(output: LLMResult | ChatResult, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
41
- handleChainStart(chain: Serialized, input: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runType?: string, runName?: string): Promise<void>;
42
- handleChainError(error: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
43
- handleChainEnd(output: ChainValues, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
44
- handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
45
- handleToolError(error: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
46
- handleToolEnd(output: unknown, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
47
- handleAgentAction(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
48
- handleAgentEnd(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
49
- handleRetrieverStart(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<void>;
50
- handleRetrieverEnd(documents: unknown[], runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
51
- handleRetrieverError(error: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
52
- flushAsync(): Promise<void>;
53
- }
54
-
55
- export { OpikCallbackHandler };
@@ -1,55 +0,0 @@
1
- import { BaseCallbackHandler, BaseCallbackHandlerInput } from '@langchain/core/callbacks/base';
2
- import { Serialized } from '@langchain/core/load/serializable';
3
- import { ChainValues } from '@langchain/core/utils/types';
4
- import { J as JsonNode, O as OpikClient } from '../Client-CgkZJ_1L.js';
5
- import { RunnableConfig } from '@langchain/core/runnables';
6
- import { LLMResult, ChatResult } from '@langchain/core/outputs';
7
- import { BaseMessage } from '@langchain/core/messages';
8
- import { AgentAction, AgentFinish } from '@langchain/core/agents';
9
- import 'stream';
10
-
11
- interface OpikCallbackHandlerOptions {
12
- tags?: [];
13
- metadata?: JsonNode;
14
- projectName?: string;
15
- client?: OpikClient;
16
- }
17
- declare class OpikCallbackHandler extends BaseCallbackHandler implements BaseCallbackHandlerInput {
18
- name: string;
19
- private options;
20
- private client;
21
- private rootTraceId?;
22
- private rootTrace?;
23
- private spansMap;
24
- constructor(options?: Partial<OpikCallbackHandlerOptions>);
25
- private startTracing;
26
- private endTracing;
27
- handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: {
28
- options: RunnableConfig;
29
- invocation_params?: Record<string, unknown>;
30
- batch_size: number;
31
- cache?: boolean;
32
- }, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
33
- handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: {
34
- options: RunnableConfig;
35
- invocation_params?: Record<string, unknown>;
36
- batch_size: number;
37
- cache?: boolean;
38
- }, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
39
- handleLLMError(error: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
40
- handleLLMEnd(output: LLMResult | ChatResult, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
41
- handleChainStart(chain: Serialized, input: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runType?: string, runName?: string): Promise<void>;
42
- handleChainError(error: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
43
- handleChainEnd(output: ChainValues, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
44
- handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
45
- handleToolError(error: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
46
- handleToolEnd(output: unknown, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
47
- handleAgentAction(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
48
- handleAgentEnd(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
49
- handleRetrieverStart(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<void>;
50
- handleRetrieverEnd(documents: unknown[], runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
51
- handleRetrieverError(error: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
52
- flushAsync(): Promise<void>;
53
- }
54
-
55
- export { OpikCallbackHandler };
@@ -1,17 +0,0 @@
1
- import {f,a as a$1,d}from'../chunk-OKUDNHYJ.js';import {a,c,b}from'../chunk-5TBO732O.js';import*as Se from'uuid';var Dr=a((Oc,Mr)=>{Mr.exports=function(n,e){if(typeof n!="string")throw new TypeError("Expected a string");return e=typeof e=="undefined"?"_":e,n.replace(/([a-z\d])([A-Z])/g,"$1"+e+"$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1"+e+"$2").toLowerCase()};});var zr=a((xc,kt)=>{var Ja=/[\p{Lu}]/u,Wa=/[\p{Ll}]/u,Fr=/^[\p{Lu}](?![\p{Lu}])/gu,Br=/([\p{Alpha}\p{N}_]|$)/u,Hr=/[_.\- ]+/,Za=new RegExp("^"+Hr.source),Ur=new RegExp(Hr.source+Br.source,"gu"),qr=new RegExp("\\d+"+Br.source,"gu"),Ka=(n,e,t)=>{let r=false,i=false,a=false;for(let s=0;s<n.length;s++){let o=n[s];r&&Ja.test(o)?(n=n.slice(0,s)+"-"+n.slice(s),r=false,a=i,i=true,s++):i&&a&&Wa.test(o)?(n=n.slice(0,s-1)+"-"+n.slice(s-1),a=i,i=false,r=true):(r=e(o)===o&&t(o)!==o,a=i,i=t(o)===o&&e(o)!==o);}return n},Xa=(n,e)=>(Fr.lastIndex=0,n.replace(Fr,t=>e(t))),Ya=(n,e)=>(Ur.lastIndex=0,qr.lastIndex=0,n.replace(Ur,(t,r)=>e(r)).replace(qr,t=>e(t))),Gr=(n,e)=>{if(!(typeof n=="string"||Array.isArray(n)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:false,preserveConsecutiveUppercase:false,...e},Array.isArray(n)?n=n.map(a=>a.trim()).filter(a=>a.length).join("-"):n=n.trim(),n.length===0)return "";let t=e.locale===false?a=>a.toLowerCase():a=>a.toLocaleLowerCase(e.locale),r=e.locale===false?a=>a.toUpperCase():a=>a.toLocaleUpperCase(e.locale);return n.length===1?e.pascalCase?r(n):t(n):(n!==t(n)&&(n=Ka(n,t,r)),n=n.replace(Za,""),e.preserveConsecutiveUppercase?n=Xa(n,t):n=t(n),e.pascalCase&&(n=r(n.charAt(0))+n.slice(1)),Ya(n,r))};kt.exports=Gr;kt.exports.default=Gr;});var tn=a((bd,en)=>{function J(n,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(n)),this._timeouts=n,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0));}en.exports=J;J.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0);};J.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null;};J.prototype.retry=function(n){if(this._timeout&&clearTimeout(this._timeout),!n)return false;var e=new Date().getTime();if(n&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(n),this._errors.unshift(new Error("RetryOperation timeout occurred")),false;this._errors.push(n);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return false;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts);},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts);},t),this._options.unref&&this._timer.unref(),true};J.prototype.attempt=function(n,e){this._fn=n,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb();},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts);};J.prototype.try=function(n){console.log("Using RetryOperation.try() is deprecated"),this.attempt(n);};J.prototype.start=function(n){console.log("Using RetryOperation.start() is deprecated"),this.attempt(n);};J.prototype.start=J.prototype.try;J.prototype.errors=function(){return this._errors};J.prototype.attempts=function(){return this._attempts};J.prototype.mainError=function(){if(this._errors.length===0)return null;for(var n={},e=null,t=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,s=(n[a]||0)+1;n[a]=s,s>=t&&(e=i,t=s);}return e};});var rn=a(pe=>{var _s=tn();pe.operation=function(n){var e=pe.timeouts(n);return new _s(e,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})};pe.timeouts=function(n){if(n instanceof Array)return [].concat(n);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:false};for(var t in n)e[t]=n[t];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],i=0;i<e.retries;i++)r.push(this.createTimeout(i,e));return n&&n.forever&&!r.length&&r.push(this.createTimeout(i,e)),r.sort(function(a,s){return a-s}),r};pe.createTimeout=function(n,e){var t=e.randomize?Math.random()+1:1,r=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,n));return r=Math.min(r,e.maxTimeout),r};pe.wrap=function(n,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var r in n)typeof n[r]=="function"&&t.push(r);}for(var i=0;i<t.length;i++){var a=t[i],s=n[a];n[a]=function(u){var l=pe.operation(e),c=Array.prototype.slice.call(arguments,1),d=c.pop();c.push(function(h){l.retry(h)||(h&&(arguments[0]=l.mainError()),d.apply(this,arguments));}),l.attempt(function(){u.apply(n,c);});}.bind(n,s),n[a].options=e;}};});var an=a((vd,nn)=>{nn.exports=rn();});var Qe=a((Ed,Ye)=>{var ys=an(),bs=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"],Xe=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e;}},ws=(n,e,t)=>{let r=t.retries-(e-1);return n.attemptNumber=e,n.retriesLeft=r,n},vs=n=>bs.includes(n),sn=(n,e)=>new Promise((t,r)=>{e={onFailedAttempt:()=>{},retries:10,...e};let i=ys.operation(e);i.attempt(async a=>{try{t(await n(a));}catch(s){if(!(s instanceof Error)){r(new TypeError(`Non-error was thrown: "${s}". You should only throw errors.`));return}if(s instanceof Xe)i.stop(),r(s.originalError);else if(s instanceof TypeError&&!vs(s.message))i.stop(),r(s);else {ws(s,a,e);try{await e.onFailedAttempt(s);}catch(o){r(o);return}i.retry(s)||r(i.mainError());}}});});Ye.exports=sn;Ye.exports.default=sn;Ye.exports.AbortError=Xe;});var un=a((Td,Ut)=>{var Es=Object.prototype.hasOwnProperty,D="~";function je(){}Object.create&&(je.prototype=Object.create(null),new je().__proto__||(D=false));function Ts(n,e,t){this.fn=n,this.context=e,this.once=t||false;}function on(n,e,t,r,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var a=new Ts(t,r||n,i),s=D?D+e:e;return n._events[s]?n._events[s].fn?n._events[s]=[n._events[s],a]:n._events[s].push(a):(n._events[s]=a,n._eventsCount++),n}function et(n,e){--n._eventsCount===0?n._events=new je:delete n._events[e];}function j(){this._events=new je,this._eventsCount=0;}j.prototype.eventNames=function(){var e=[],t,r;if(this._eventsCount===0)return e;for(r in t=this._events)Es.call(t,r)&&e.push(D?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};j.prototype.listeners=function(e){var t=D?D+e:e,r=this._events[t];if(!r)return [];if(r.fn)return [r.fn];for(var i=0,a=r.length,s=new Array(a);i<a;i++)s[i]=r[i].fn;return s};j.prototype.listenerCount=function(e){var t=D?D+e:e,r=this._events[t];return r?r.fn?1:r.length:0};j.prototype.emit=function(e,t,r,i,a,s){var o=D?D+e:e;if(!this._events[o])return false;var u=this._events[o],l=arguments.length,c,d;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,true),l){case 1:return u.fn.call(u.context),true;case 2:return u.fn.call(u.context,t),true;case 3:return u.fn.call(u.context,t,r),true;case 4:return u.fn.call(u.context,t,r,i),true;case 5:return u.fn.call(u.context,t,r,i,a),true;case 6:return u.fn.call(u.context,t,r,i,a,s),true}for(d=1,c=new Array(l-1);d<l;d++)c[d-1]=arguments[d];u.fn.apply(u.context,c);}else {var h=u.length,f;for(d=0;d<h;d++)switch(u[d].once&&this.removeListener(e,u[d].fn,void 0,true),l){case 1:u[d].fn.call(u[d].context);break;case 2:u[d].fn.call(u[d].context,t);break;case 3:u[d].fn.call(u[d].context,t,r);break;case 4:u[d].fn.call(u[d].context,t,r,i);break;default:if(!c)for(f=1,c=new Array(l-1);f<l;f++)c[f-1]=arguments[f];u[d].fn.apply(u[d].context,c);}}return true};j.prototype.on=function(e,t,r){return on(this,e,t,r,false)};j.prototype.once=function(e,t,r){return on(this,e,t,r,true)};j.prototype.removeListener=function(e,t,r,i){var a=D?D+e:e;if(!this._events[a])return this;if(!t)return et(this,a),this;var s=this._events[a];if(s.fn)s.fn===t&&(!i||s.once)&&(!r||s.context===r)&&et(this,a);else {for(var o=0,u=[],l=s.length;o<l;o++)(s[o].fn!==t||i&&!s[o].once||r&&s[o].context!==r)&&u.push(s[o]);u.length?this._events[a]=u.length===1?u[0]:u:et(this,a);}return this};j.prototype.removeAllListeners=function(e){var t;return e?(t=D?D+e:e,this._events[t]&&et(this,t)):(this._events=new je,this._eventsCount=0),this};j.prototype.off=j.prototype.removeListener;j.prototype.addListener=j.prototype.on;j.prefixed=D;j.EventEmitter=j;typeof Ut!="undefined"&&(Ut.exports=j);});var cn=a((Sd,ln)=>{ln.exports=(n,e)=>(e=e||(()=>{}),n.then(t=>new Promise(r=>{r(e());}).then(()=>t),t=>new Promise(r=>{r(e());}).then(()=>{throw t})));});var hn=a((Od,rt)=>{var Ss=cn(),tt=class extends Error{constructor(e){super(e),this.name="TimeoutError";}},dn=(n,e,t)=>new Promise((r,i)=>{if(typeof e!="number"||e<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(e===1/0){r(n);return}let a=setTimeout(()=>{if(typeof t=="function"){try{r(t());}catch(u){i(u);}return}let s=typeof t=="string"?t:`Promise timed out after ${e} milliseconds`,o=t instanceof Error?t:new tt(s);typeof n.cancel=="function"&&n.cancel(),i(o);},e);Ss(n.then(r,i),()=>{clearTimeout(a);});});rt.exports=dn;rt.exports.default=dn;rt.exports.TimeoutError=tt;});var fn=a(qt=>{Object.defineProperty(qt,"__esModule",{value:true});function Os(n,e,t){let r=0,i=n.length;for(;i>0;){let a=i/2|0,s=r+a;t(n[s],e)<=0?(r=++s,i-=a+1):i=a;}return r}qt.default=Os;});var pn=a(Ht=>{Object.defineProperty(Ht,"__esModule",{value:true});var xs=fn(),Bt=class{constructor(){this._queue=[];}enqueue(e,t){t=Object.assign({priority:0},t);let r={priority:t.priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority){this._queue.push(r);return}let i=xs.default(this._queue,r,(a,s)=>s.priority-a.priority);this._queue.splice(i,0,r);}dequeue(){let e=this._queue.shift();return e==null?void 0:e.run}filter(e){return this._queue.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this._queue.length}};Ht.default=Bt;});var it=a(zt=>{Object.defineProperty(zt,"__esModule",{value:true});var Is=un(),mn=hn(),As=pn(),nt=()=>{},Rs=new mn.TimeoutError,Gt=class extends Is{constructor(e){var t,r,i,a;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=nt,this._resolveIdle=nt,e=Object.assign({carryoverConcurrencyCount:false,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:true,queueClass:As.default},e),!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(r=(t=e.intervalCap)===null||t===void 0?void 0:t.toString())!==null&&r!==void 0?r:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&a!==void 0?a:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||e.interval===0,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=e.throwOnTimeout===true,this._isPaused=e.autoStart===false;}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next");}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=nt,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=nt,this.emit("idle"));}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0;}_isIntervalPaused(){let e=Date.now();if(this._intervalId===void 0){let t=this._intervalEnd-e;if(t<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval();},t)),true}return false}_tryToStartAnother(){if(this._queue.size===0)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),false;if(!this._isPaused){let e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){let t=this._queue.dequeue();return t?(this.emit("active"),t(),e&&this._initializeIntervalIfNeeded(),true):false}}return false}_initializeIntervalIfNeeded(){this._isIntervalIgnored||this._intervalId!==void 0||(this._intervalId=setInterval(()=>{this._onInterval();},this._interval),this._intervalEnd=Date.now()+this._interval);}_onInterval(){this._intervalCount===0&&this._pendingCount===0&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue();}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue();}async add(e,t={}){return new Promise((r,i)=>{let a=async()=>{this._pendingCount++,this._intervalCount++;try{let s=this._timeout===void 0&&t.timeout===void 0?e():mn.default(Promise.resolve(e()),t.timeout===void 0?this._timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?this._throwOnTimeout:t.throwOnTimeout)&&i(Rs);});r(await s);}catch(s){i(s);}this._next();};this._queue.enqueue(a,t),this._tryToStartAnother(),this.emit("add");})}async addAll(e,t){return Promise.all(e.map(async r=>this.add(r,t)))}start(){return this._isPaused?(this._isPaused=false,this._processQueue(),this):this}pause(){this._isPaused=true;}clear(){this._queue=new this._queueClass;}async onEmpty(){if(this._queue.size!==0)return new Promise(e=>{let t=this._resolveEmpty;this._resolveEmpty=()=>{t(),e();};})}async onIdle(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(e=>{let t=this._resolveIdle;this._resolveIdle=()=>{t(),e();};})}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e;}};zt.default=Gt;});var De=a((Ld,bn)=>{var ks="2.0.0",Ls=Number.MAX_SAFE_INTEGER||9007199254740991,js=16,Ms=250,Ds=["major","premajor","minor","preminor","patch","prepatch","prerelease"];bn.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:js,MAX_SAFE_BUILD_LENGTH:Ms,MAX_SAFE_INTEGER:Ls,RELEASE_TYPES:Ds,SEMVER_SPEC_VERSION:ks,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2};});var Fe=a((jd,wn)=>{var Fs=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{};wn.exports=Fs;});var ve=a((re,vn)=>{var{MAX_SAFE_COMPONENT_LENGTH:Wt,MAX_SAFE_BUILD_LENGTH:Us,MAX_LENGTH:qs}=De(),Bs=Fe();re=vn.exports={};var Hs=re.re=[],Gs=re.safeRe=[],m=re.src=[],g=re.t={},zs=0,Zt="[a-zA-Z0-9-]",Vs=[["\\s",1],["\\d",qs],[Zt,Us]],Js=n=>{for(let[e,t]of Vs)n=n.split(`${e}*`).join(`${e}{0,${t}}`).split(`${e}+`).join(`${e}{1,${t}}`);return n},v=(n,e,t)=>{let r=Js(e),i=zs++;Bs(n,i,e),g[n]=i,m[i]=e,Hs[i]=new RegExp(e,t?"g":void 0),Gs[i]=new RegExp(r,t?"g":void 0);};v("NUMERICIDENTIFIER","0|[1-9]\\d*");v("NUMERICIDENTIFIERLOOSE","\\d+");v("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${Zt}*`);v("MAINVERSION",`(${m[g.NUMERICIDENTIFIER]})\\.(${m[g.NUMERICIDENTIFIER]})\\.(${m[g.NUMERICIDENTIFIER]})`);v("MAINVERSIONLOOSE",`(${m[g.NUMERICIDENTIFIERLOOSE]})\\.(${m[g.NUMERICIDENTIFIERLOOSE]})\\.(${m[g.NUMERICIDENTIFIERLOOSE]})`);v("PRERELEASEIDENTIFIER",`(?:${m[g.NUMERICIDENTIFIER]}|${m[g.NONNUMERICIDENTIFIER]})`);v("PRERELEASEIDENTIFIERLOOSE",`(?:${m[g.NUMERICIDENTIFIERLOOSE]}|${m[g.NONNUMERICIDENTIFIER]})`);v("PRERELEASE",`(?:-(${m[g.PRERELEASEIDENTIFIER]}(?:\\.${m[g.PRERELEASEIDENTIFIER]})*))`);v("PRERELEASELOOSE",`(?:-?(${m[g.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${m[g.PRERELEASEIDENTIFIERLOOSE]})*))`);v("BUILDIDENTIFIER",`${Zt}+`);v("BUILD",`(?:\\+(${m[g.BUILDIDENTIFIER]}(?:\\.${m[g.BUILDIDENTIFIER]})*))`);v("FULLPLAIN",`v?${m[g.MAINVERSION]}${m[g.PRERELEASE]}?${m[g.BUILD]}?`);v("FULL",`^${m[g.FULLPLAIN]}$`);v("LOOSEPLAIN",`[v=\\s]*${m[g.MAINVERSIONLOOSE]}${m[g.PRERELEASELOOSE]}?${m[g.BUILD]}?`);v("LOOSE",`^${m[g.LOOSEPLAIN]}$`);v("GTLT","((?:<|>)?=?)");v("XRANGEIDENTIFIERLOOSE",`${m[g.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);v("XRANGEIDENTIFIER",`${m[g.NUMERICIDENTIFIER]}|x|X|\\*`);v("XRANGEPLAIN",`[v=\\s]*(${m[g.XRANGEIDENTIFIER]})(?:\\.(${m[g.XRANGEIDENTIFIER]})(?:\\.(${m[g.XRANGEIDENTIFIER]})(?:${m[g.PRERELEASE]})?${m[g.BUILD]}?)?)?`);v("XRANGEPLAINLOOSE",`[v=\\s]*(${m[g.XRANGEIDENTIFIERLOOSE]})(?:\\.(${m[g.XRANGEIDENTIFIERLOOSE]})(?:\\.(${m[g.XRANGEIDENTIFIERLOOSE]})(?:${m[g.PRERELEASELOOSE]})?${m[g.BUILD]}?)?)?`);v("XRANGE",`^${m[g.GTLT]}\\s*${m[g.XRANGEPLAIN]}$`);v("XRANGELOOSE",`^${m[g.GTLT]}\\s*${m[g.XRANGEPLAINLOOSE]}$`);v("COERCEPLAIN",`(^|[^\\d])(\\d{1,${Wt}})(?:\\.(\\d{1,${Wt}}))?(?:\\.(\\d{1,${Wt}}))?`);v("COERCE",`${m[g.COERCEPLAIN]}(?:$|[^\\d])`);v("COERCEFULL",m[g.COERCEPLAIN]+`(?:${m[g.PRERELEASE]})?(?:${m[g.BUILD]})?(?:$|[^\\d])`);v("COERCERTL",m[g.COERCE],true);v("COERCERTLFULL",m[g.COERCEFULL],true);v("LONETILDE","(?:~>?)");v("TILDETRIM",`(\\s*)${m[g.LONETILDE]}\\s+`,true);re.tildeTrimReplace="$1~";v("TILDE",`^${m[g.LONETILDE]}${m[g.XRANGEPLAIN]}$`);v("TILDELOOSE",`^${m[g.LONETILDE]}${m[g.XRANGEPLAINLOOSE]}$`);v("LONECARET","(?:\\^)");v("CARETTRIM",`(\\s*)${m[g.LONECARET]}\\s+`,true);re.caretTrimReplace="$1^";v("CARET",`^${m[g.LONECARET]}${m[g.XRANGEPLAIN]}$`);v("CARETLOOSE",`^${m[g.LONECARET]}${m[g.XRANGEPLAINLOOSE]}$`);v("COMPARATORLOOSE",`^${m[g.GTLT]}\\s*(${m[g.LOOSEPLAIN]})$|^$`);v("COMPARATOR",`^${m[g.GTLT]}\\s*(${m[g.FULLPLAIN]})$|^$`);v("COMPARATORTRIM",`(\\s*)${m[g.GTLT]}\\s*(${m[g.LOOSEPLAIN]}|${m[g.XRANGEPLAIN]})`,true);re.comparatorTrimReplace="$1$2$3";v("HYPHENRANGE",`^\\s*(${m[g.XRANGEPLAIN]})\\s+-\\s+(${m[g.XRANGEPLAIN]})\\s*$`);v("HYPHENRANGELOOSE",`^\\s*(${m[g.XRANGEPLAINLOOSE]})\\s+-\\s+(${m[g.XRANGEPLAINLOOSE]})\\s*$`);v("STAR","(<|>)?=?\\s*\\*");v("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");v("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$");});var ot=a((Md,En)=>{var Ws=Object.freeze({loose:true}),Zs=Object.freeze({}),Ks=n=>n?typeof n!="object"?Ws:n:Zs;En.exports=Ks;});var Kt=a((Dd,On)=>{var Tn=/^[0-9]+$/,Sn=(n,e)=>{let t=Tn.test(n),r=Tn.test(e);return t&&r&&(n=+n,e=+e),n===e?0:t&&!r?-1:r&&!t?1:n<e?-1:1},Xs=(n,e)=>Sn(e,n);On.exports={compareIdentifiers:Sn,rcompareIdentifiers:Xs};});var M=a((Fd,Rn)=>{var ut=Fe(),{MAX_LENGTH:xn,MAX_SAFE_INTEGER:lt}=De(),{safeRe:In,t:An}=ve(),Ys=ot(),{compareIdentifiers:Ee}=Kt(),Xt=class n{constructor(e,t){if(t=Ys(t),e instanceof n){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version;}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>xn)throw new TypeError(`version is longer than ${xn} characters`);ut("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let r=e.trim().match(t.loose?In[An.LOOSE]:In[An.FULL]);if(!r)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>lt||this.major<0)throw new TypeError("Invalid major version");if(this.minor>lt||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>lt||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){let a=+i;if(a>=0&&a<lt)return a}return i}):this.prerelease=[],this.build=r[5]?r[5].split("."):[],this.format();}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(ut("SemVer.compare",this.version,this.options,e),!(e instanceof n)){if(typeof e=="string"&&e===this.version)return 0;e=new n(e,this.options);}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof n||(e=new n(e,this.options)),Ee(this.major,e.major)||Ee(this.minor,e.minor)||Ee(this.patch,e.patch)}comparePre(e){if(e instanceof n||(e=new n(e,this.options)),this.prerelease.length&&!e.prerelease.length)return -1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let r=this.prerelease[t],i=e.prerelease[t];if(ut("prerelease compare",t,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return -1;if(r===i)continue;return Ee(r,i)}while(++t)}compareBuild(e){e instanceof n||(e=new n(e,this.options));let t=0;do{let r=this.build[t],i=e.build[t];if(ut("build compare",t,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return -1;if(r===i)continue;return Ee(r,i)}while(++t)}inc(e,t,r){switch(e){case "premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,r);break;case "preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,r);break;case "prepatch":this.prerelease.length=0,this.inc("patch",t,r),this.inc("pre",t,r);break;case "prerelease":this.prerelease.length===0&&this.inc("patch",t,r),this.inc("pre",t,r);break;case "major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case "minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case "patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case "pre":{let i=Number(r)?1:0;if(!t&&r===false)throw new Error("invalid increment argument: identifier is empty");if(this.prerelease.length===0)this.prerelease=[i];else {let a=this.prerelease.length;for(;--a>=0;)typeof this.prerelease[a]=="number"&&(this.prerelease[a]++,a=-2);if(a===-1){if(t===this.prerelease.join(".")&&r===false)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i);}}if(t){let a=[t,i];r===false&&(a=[t]),Ee(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=a):this.prerelease=a;}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};Rn.exports=Xt;});var me=a((Ud,$n)=>{var Cn=M(),Qs=(n,e,t=false)=>{if(n instanceof Cn)return n;try{return new Cn(n,e)}catch(r){if(!t)return null;throw r}};$n.exports=Qs;});var Nn=a((qd,Pn)=>{var eo=me(),to=(n,e)=>{let t=eo(n,e);return t?t.version:null};Pn.exports=to;});var Ln=a((Bd,kn)=>{var ro=me(),no=(n,e)=>{let t=ro(n.trim().replace(/^[=v]+/,""),e);return t?t.version:null};kn.exports=no;});var Dn=a((Hd,Mn)=>{var jn=M(),io=(n,e,t,r,i)=>{typeof t=="string"&&(i=r,r=t,t=void 0);try{return new jn(n instanceof jn?n.version:n,t).inc(e,r,i).version}catch{return null}};Mn.exports=io;});var qn=a((Gd,Un)=>{var Fn=me(),ao=(n,e)=>{let t=Fn(n,null,true),r=Fn(e,null,true),i=t.compare(r);if(i===0)return null;let a=i>0,s=a?t:r,o=a?r:t,u=!!s.prerelease.length;if(!!o.prerelease.length&&!u)return !o.patch&&!o.minor?"major":s.patch?"patch":s.minor?"minor":"major";let c=u?"pre":"";return t.major!==r.major?c+"major":t.minor!==r.minor?c+"minor":t.patch!==r.patch?c+"patch":"prerelease"};Un.exports=ao;});var Hn=a((zd,Bn)=>{var so=M(),oo=(n,e)=>new so(n,e).major;Bn.exports=oo;});var zn=a((Vd,Gn)=>{var uo=M(),lo=(n,e)=>new uo(n,e).minor;Gn.exports=lo;});var Jn=a((Jd,Vn)=>{var co=M(),ho=(n,e)=>new co(n,e).patch;Vn.exports=ho;});var Zn=a((Wd,Wn)=>{var fo=me(),po=(n,e)=>{let t=fo(n,e);return t&&t.prerelease.length?t.prerelease:null};Wn.exports=po;});var W=a((Zd,Xn)=>{var Kn=M(),mo=(n,e,t)=>new Kn(n,t).compare(new Kn(e,t));Xn.exports=mo;});var Qn=a((Kd,Yn)=>{var go=W(),_o=(n,e,t)=>go(e,n,t);Yn.exports=_o;});var ti=a((Xd,ei)=>{var yo=W(),bo=(n,e)=>yo(n,e,true);ei.exports=bo;});var ct=a((Yd,ni)=>{var ri=M(),wo=(n,e,t)=>{let r=new ri(n,t),i=new ri(e,t);return r.compare(i)||r.compareBuild(i)};ni.exports=wo;});var ai=a((Qd,ii)=>{var vo=ct(),Eo=(n,e)=>n.sort((t,r)=>vo(t,r,e));ii.exports=Eo;});var oi=a((eh,si)=>{var To=ct(),So=(n,e)=>n.sort((t,r)=>To(r,t,e));si.exports=So;});var Ue=a((th,ui)=>{var Oo=W(),xo=(n,e,t)=>Oo(n,e,t)>0;ui.exports=xo;});var dt=a((rh,li)=>{var Io=W(),Ao=(n,e,t)=>Io(n,e,t)<0;li.exports=Ao;});var Yt=a((nh,ci)=>{var Ro=W(),Co=(n,e,t)=>Ro(n,e,t)===0;ci.exports=Co;});var Qt=a((ih,di)=>{var $o=W(),Po=(n,e,t)=>$o(n,e,t)!==0;di.exports=Po;});var ht=a((ah,hi)=>{var No=W(),ko=(n,e,t)=>No(n,e,t)>=0;hi.exports=ko;});var ft=a((sh,fi)=>{var Lo=W(),jo=(n,e,t)=>Lo(n,e,t)<=0;fi.exports=jo;});var er=a((oh,pi)=>{var Mo=Yt(),Do=Qt(),Fo=Ue(),Uo=ht(),qo=dt(),Bo=ft(),Ho=(n,e,t,r)=>{switch(e){case "===":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n===t;case "!==":return typeof n=="object"&&(n=n.version),typeof t=="object"&&(t=t.version),n!==t;case "":case "=":case "==":return Mo(n,t,r);case "!=":return Do(n,t,r);case ">":return Fo(n,t,r);case ">=":return Uo(n,t,r);case "<":return qo(n,t,r);case "<=":return Bo(n,t,r);default:throw new TypeError(`Invalid operator: ${e}`)}};pi.exports=Ho;});var gi=a((uh,mi)=>{var Go=M(),zo=me(),{safeRe:pt,t:mt}=ve(),Vo=(n,e)=>{if(n instanceof Go)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;e=e||{};let t=null;if(!e.rtl)t=n.match(e.includePrerelease?pt[mt.COERCEFULL]:pt[mt.COERCE]);else {let u=e.includePrerelease?pt[mt.COERCERTLFULL]:pt[mt.COERCERTL],l;for(;(l=u.exec(n))&&(!t||t.index+t[0].length!==n.length);)(!t||l.index+l[0].length!==t.index+t[0].length)&&(t=l),u.lastIndex=l.index+l[1].length+l[2].length;u.lastIndex=-1;}if(t===null)return null;let r=t[2],i=t[3]||"0",a=t[4]||"0",s=e.includePrerelease&&t[5]?`-${t[5]}`:"",o=e.includePrerelease&&t[6]?`+${t[6]}`:"";return zo(`${r}.${i}.${a}${s}${o}`,e)};mi.exports=Vo;});var yi=a((lh,_i)=>{var tr=class{constructor(){this.max=1e3,this.map=new Map;}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let i=this.map.keys().next().value;this.delete(i);}this.map.set(e,t);}return this}};_i.exports=tr;});var Z=a((ch,Ei)=>{var Jo=/\s+/g,rr=class n{constructor(e,t){if(t=Zo(t),e instanceof n)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new n(e.raw,t);if(e instanceof nr)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(Jo," "),this.set=this.raw.split("||").map(r=>this.parseRange(r.trim())).filter(r=>r.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let r=this.set[0];if(this.set=this.set.filter(i=>!wi(i[0])),this.set.length===0)this.set=[r];else if(this.set.length>1){for(let i of this.set)if(i.length===1&&ru(i[0])){this.set=[i];break}}}this.formatted=void 0;}get range(){if(this.formatted===void 0){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");let t=this.set[e];for(let r=0;r<t.length;r++)r>0&&(this.formatted+=" "),this.formatted+=t[r].toString().trim();}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let r=((this.options.includePrerelease&&eu)|(this.options.loose&&tu))+":"+e,i=bi.get(r);if(i)return i;let a=this.options.loose,s=a?B[F.HYPHENRANGELOOSE]:B[F.HYPHENRANGE];e=e.replace(s,hu(this.options.includePrerelease)),A("hyphen replace",e),e=e.replace(B[F.COMPARATORTRIM],Xo),A("comparator trim",e),e=e.replace(B[F.TILDETRIM],Yo),A("tilde trim",e),e=e.replace(B[F.CARETTRIM],Qo),A("caret trim",e);let o=e.split(" ").map(d=>nu(d,this.options)).join(" ").split(/\s+/).map(d=>du(d,this.options));a&&(o=o.filter(d=>(A("loose invalid filter",d,this.options),!!d.match(B[F.COMPARATORLOOSE])))),A("range list",o);let u=new Map,l=o.map(d=>new nr(d,this.options));for(let d of l){if(wi(d))return [d];u.set(d.value,d);}u.size>1&&u.has("")&&u.delete("");let c=[...u.values()];return bi.set(r,c),c}intersects(e,t){if(!(e instanceof n))throw new TypeError("a Range is required");return this.set.some(r=>vi(r,t)&&e.set.some(i=>vi(i,t)&&r.every(a=>i.every(s=>a.intersects(s,t)))))}test(e){if(!e)return false;if(typeof e=="string")try{e=new Ko(e,this.options);}catch{return false}for(let t=0;t<this.set.length;t++)if(fu(this.set[t],e,this.options))return true;return false}};Ei.exports=rr;var Wo=yi(),bi=new Wo,Zo=ot(),nr=qe(),A=Fe(),Ko=M(),{safeRe:B,t:F,comparatorTrimReplace:Xo,tildeTrimReplace:Yo,caretTrimReplace:Qo}=ve(),{FLAG_INCLUDE_PRERELEASE:eu,FLAG_LOOSE:tu}=De(),wi=n=>n.value==="<0.0.0-0",ru=n=>n.value==="",vi=(n,e)=>{let t=true,r=n.slice(),i=r.pop();for(;t&&r.length;)t=r.every(a=>i.intersects(a,e)),i=r.pop();return t},nu=(n,e)=>(A("comp",n,e),n=su(n,e),A("caret",n),n=iu(n,e),A("tildes",n),n=uu(n,e),A("xrange",n),n=cu(n,e),A("stars",n),n),U=n=>!n||n.toLowerCase()==="x"||n==="*",iu=(n,e)=>n.trim().split(/\s+/).map(t=>au(t,e)).join(" "),au=(n,e)=>{let t=e.loose?B[F.TILDELOOSE]:B[F.TILDE];return n.replace(t,(r,i,a,s,o)=>{A("tilde",n,r,i,a,s,o);let u;return U(i)?u="":U(a)?u=`>=${i}.0.0 <${+i+1}.0.0-0`:U(s)?u=`>=${i}.${a}.0 <${i}.${+a+1}.0-0`:o?(A("replaceTilde pr",o),u=`>=${i}.${a}.${s}-${o} <${i}.${+a+1}.0-0`):u=`>=${i}.${a}.${s} <${i}.${+a+1}.0-0`,A("tilde return",u),u})},su=(n,e)=>n.trim().split(/\s+/).map(t=>ou(t,e)).join(" "),ou=(n,e)=>{A("caret",n,e);let t=e.loose?B[F.CARETLOOSE]:B[F.CARET],r=e.includePrerelease?"-0":"";return n.replace(t,(i,a,s,o,u)=>{A("caret",n,i,a,s,o,u);let l;return U(a)?l="":U(s)?l=`>=${a}.0.0${r} <${+a+1}.0.0-0`:U(o)?a==="0"?l=`>=${a}.${s}.0${r} <${a}.${+s+1}.0-0`:l=`>=${a}.${s}.0${r} <${+a+1}.0.0-0`:u?(A("replaceCaret pr",u),a==="0"?s==="0"?l=`>=${a}.${s}.${o}-${u} <${a}.${s}.${+o+1}-0`:l=`>=${a}.${s}.${o}-${u} <${a}.${+s+1}.0-0`:l=`>=${a}.${s}.${o}-${u} <${+a+1}.0.0-0`):(A("no pr"),a==="0"?s==="0"?l=`>=${a}.${s}.${o}${r} <${a}.${s}.${+o+1}-0`:l=`>=${a}.${s}.${o}${r} <${a}.${+s+1}.0-0`:l=`>=${a}.${s}.${o} <${+a+1}.0.0-0`),A("caret return",l),l})},uu=(n,e)=>(A("replaceXRanges",n,e),n.split(/\s+/).map(t=>lu(t,e)).join(" ")),lu=(n,e)=>{n=n.trim();let t=e.loose?B[F.XRANGELOOSE]:B[F.XRANGE];return n.replace(t,(r,i,a,s,o,u)=>{A("xRange",n,r,i,a,s,o,u);let l=U(a),c=l||U(s),d=c||U(o),h=d;return i==="="&&h&&(i=""),u=e.includePrerelease?"-0":"",l?i===">"||i==="<"?r="<0.0.0-0":r="*":i&&h?(c&&(s=0),o=0,i===">"?(i=">=",c?(a=+a+1,s=0,o=0):(s=+s+1,o=0)):i==="<="&&(i="<",c?a=+a+1:s=+s+1),i==="<"&&(u="-0"),r=`${i+a}.${s}.${o}${u}`):c?r=`>=${a}.0.0${u} <${+a+1}.0.0-0`:d&&(r=`>=${a}.${s}.0${u} <${a}.${+s+1}.0-0`),A("xRange return",r),r})},cu=(n,e)=>(A("replaceStars",n,e),n.trim().replace(B[F.STAR],"")),du=(n,e)=>(A("replaceGTE0",n,e),n.trim().replace(B[e.includePrerelease?F.GTE0PRE:F.GTE0],"")),hu=n=>(e,t,r,i,a,s,o,u,l,c,d,h)=>(U(r)?t="":U(i)?t=`>=${r}.0.0${n?"-0":""}`:U(a)?t=`>=${r}.${i}.0${n?"-0":""}`:s?t=`>=${t}`:t=`>=${t}${n?"-0":""}`,U(l)?u="":U(c)?u=`<${+l+1}.0.0-0`:U(d)?u=`<${l}.${+c+1}.0-0`:h?u=`<=${l}.${c}.${d}-${h}`:n?u=`<${l}.${c}.${+d+1}-0`:u=`<=${u}`,`${t} ${u}`.trim()),fu=(n,e,t)=>{for(let r=0;r<n.length;r++)if(!n[r].test(e))return false;if(e.prerelease.length&&!t.includePrerelease){for(let r=0;r<n.length;r++)if(A(n[r].semver),n[r].semver!==nr.ANY&&n[r].semver.prerelease.length>0){let i=n[r].semver;if(i.major===e.major&&i.minor===e.minor&&i.patch===e.patch)return true}return false}return true};});var qe=a((dh,Ai)=>{var Be=Symbol("SemVer ANY"),sr=class n{static get ANY(){return Be}constructor(e,t){if(t=Ti(t),e instanceof n){if(e.loose===!!t.loose)return e;e=e.value;}e=e.trim().split(/\s+/).join(" "),ar("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===Be?this.value="":this.value=this.operator+this.semver.version,ar("comp",this);}parse(e){let t=this.options.loose?Si[Oi.COMPARATORLOOSE]:Si[Oi.COMPARATOR],r=e.match(t);if(!r)throw new TypeError(`Invalid comparator: ${e}`);this.operator=r[1]!==void 0?r[1]:"",this.operator==="="&&(this.operator=""),r[2]?this.semver=new xi(r[2],this.options.loose):this.semver=Be;}toString(){return this.value}test(e){if(ar("Comparator.test",e,this.options.loose),this.semver===Be||e===Be)return true;if(typeof e=="string")try{e=new xi(e,this.options);}catch{return false}return ir(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof n))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?true:new Ii(e.value,t).test(this.value):e.operator===""?e.value===""?true:new Ii(this.value,t).test(e.semver):(t=Ti(t),t.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0")||!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))?false:!!(this.operator.startsWith(">")&&e.operator.startsWith(">")||this.operator.startsWith("<")&&e.operator.startsWith("<")||this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")||ir(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<")||ir(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}};Ai.exports=sr;var Ti=ot(),{safeRe:Si,t:Oi}=ve(),ir=er(),ar=Fe(),xi=M(),Ii=Z();});var He=a((hh,Ri)=>{var pu=Z(),mu=(n,e,t)=>{try{e=new pu(e,t);}catch{return false}return e.test(n)};Ri.exports=mu;});var $i=a((fh,Ci)=>{var gu=Z(),_u=(n,e)=>new gu(n,e).set.map(t=>t.map(r=>r.value).join(" ").trim().split(" "));Ci.exports=_u;});var Ni=a((ph,Pi)=>{var yu=M(),bu=Z(),wu=(n,e,t)=>{let r=null,i=null,a=null;try{a=new bu(e,t);}catch{return null}return n.forEach(s=>{a.test(s)&&(!r||i.compare(s)===-1)&&(r=s,i=new yu(r,t));}),r};Pi.exports=wu;});var Li=a((mh,ki)=>{var vu=M(),Eu=Z(),Tu=(n,e,t)=>{let r=null,i=null,a=null;try{a=new Eu(e,t);}catch{return null}return n.forEach(s=>{a.test(s)&&(!r||i.compare(s)===1)&&(r=s,i=new vu(r,t));}),r};ki.exports=Tu;});var Di=a((gh,Mi)=>{var or=M(),Su=Z(),ji=Ue(),Ou=(n,e)=>{n=new Su(n,e);let t=new or("0.0.0");if(n.test(t)||(t=new or("0.0.0-0"),n.test(t)))return t;t=null;for(let r=0;r<n.set.length;++r){let i=n.set[r],a=null;i.forEach(s=>{let o=new or(s.semver.version);switch(s.operator){case ">":o.prerelease.length===0?o.patch++:o.prerelease.push(0),o.raw=o.format();case "":case ">=":(!a||ji(o,a))&&(a=o);break;case "<":case "<=":break;default:throw new Error(`Unexpected operation: ${s.operator}`)}}),a&&(!t||ji(t,a))&&(t=a);}return t&&n.test(t)?t:null};Mi.exports=Ou;});var Ui=a((_h,Fi)=>{var xu=Z(),Iu=(n,e)=>{try{return new xu(n,e).range||"*"}catch{return null}};Fi.exports=Iu;});var gt=a((yh,Gi)=>{var Au=M(),Hi=qe(),{ANY:Ru}=Hi,Cu=Z(),$u=He(),qi=Ue(),Bi=dt(),Pu=ft(),Nu=ht(),ku=(n,e,t,r)=>{n=new Au(n,r),e=new Cu(e,r);let i,a,s,o,u;switch(t){case ">":i=qi,a=Pu,s=Bi,o=">",u=">=";break;case "<":i=Bi,a=Nu,s=qi,o="<",u="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if($u(n,e,r))return false;for(let l=0;l<e.set.length;++l){let c=e.set[l],d=null,h=null;if(c.forEach(f=>{f.semver===Ru&&(f=new Hi(">=0.0.0")),d=d||f,h=h||f,i(f.semver,d.semver,r)?d=f:s(f.semver,h.semver,r)&&(h=f);}),d.operator===o||d.operator===u||(!h.operator||h.operator===o)&&a(n,h.semver))return false;if(h.operator===u&&s(n,h.semver))return false}return true};Gi.exports=ku;});var Vi=a((bh,zi)=>{var Lu=gt(),ju=(n,e,t)=>Lu(n,e,">",t);zi.exports=ju;});var Wi=a((wh,Ji)=>{var Mu=gt(),Du=(n,e,t)=>Mu(n,e,"<",t);Ji.exports=Du;});var Xi=a((vh,Ki)=>{var Zi=Z(),Fu=(n,e,t)=>(n=new Zi(n,t),e=new Zi(e,t),n.intersects(e,t));Ki.exports=Fu;});var Qi=a((Eh,Yi)=>{var Uu=He(),qu=W();Yi.exports=(n,e,t)=>{let r=[],i=null,a=null,s=n.sort((c,d)=>qu(c,d,t));for(let c of s)Uu(c,e,t)?(a=c,i||(i=c)):(a&&r.push([i,a]),a=null,i=null);i&&r.push([i,null]);let o=[];for(let[c,d]of r)c===d?o.push(c):!d&&c===s[0]?o.push("*"):d?c===s[0]?o.push(`<=${d}`):o.push(`${c} - ${d}`):o.push(`>=${c}`);let u=o.join(" || "),l=typeof e.raw=="string"?e.raw:String(e);return u.length<l.length?u:e};});var aa=a((Th,ia)=>{var ea=Z(),lr=qe(),{ANY:ur}=lr,Ge=He(),cr=W(),Bu=(n,e,t={})=>{if(n===e)return true;n=new ea(n,t),e=new ea(e,t);let r=false;e:for(let i of n.set){for(let a of e.set){let s=Gu(i,a,t);if(r=r||s!==null,s)continue e}if(r)return false}return true},Hu=[new lr(">=0.0.0-0")],ta=[new lr(">=0.0.0")],Gu=(n,e,t)=>{if(n===e)return true;if(n.length===1&&n[0].semver===ur){if(e.length===1&&e[0].semver===ur)return true;t.includePrerelease?n=Hu:n=ta;}if(e.length===1&&e[0].semver===ur){if(t.includePrerelease)return true;e=ta;}let r=new Set,i,a;for(let f of n)f.operator===">"||f.operator===">="?i=ra(i,f,t):f.operator==="<"||f.operator==="<="?a=na(a,f,t):r.add(f.semver);if(r.size>1)return null;let s;if(i&&a){if(s=cr(i.semver,a.semver,t),s>0)return null;if(s===0&&(i.operator!==">="||a.operator!=="<="))return null}for(let f of r){if(i&&!Ge(f,String(i),t)||a&&!Ge(f,String(a),t))return null;for(let p of e)if(!Ge(f,String(p),t))return false;return true}let o,u,l,c,d=a&&!t.includePrerelease&&a.semver.prerelease.length?a.semver:false,h=i&&!t.includePrerelease&&i.semver.prerelease.length?i.semver:false;d&&d.prerelease.length===1&&a.operator==="<"&&d.prerelease[0]===0&&(d=false);for(let f of e){if(c=c||f.operator===">"||f.operator===">=",l=l||f.operator==="<"||f.operator==="<=",i){if(h&&f.semver.prerelease&&f.semver.prerelease.length&&f.semver.major===h.major&&f.semver.minor===h.minor&&f.semver.patch===h.patch&&(h=false),f.operator===">"||f.operator===">="){if(o=ra(i,f,t),o===f&&o!==i)return false}else if(i.operator===">="&&!Ge(i.semver,String(f),t))return false}if(a){if(d&&f.semver.prerelease&&f.semver.prerelease.length&&f.semver.major===d.major&&f.semver.minor===d.minor&&f.semver.patch===d.patch&&(d=false),f.operator==="<"||f.operator==="<="){if(u=na(a,f,t),u===f&&u!==a)return false}else if(a.operator==="<="&&!Ge(a.semver,String(f),t))return false}if(!f.operator&&(a||i)&&s!==0)return false}return !(i&&l&&!a&&s!==0||a&&c&&!i&&s!==0||h||d)},ra=(n,e,t)=>{if(!n)return e;let r=cr(n.semver,e.semver,t);return r>0?n:r<0||e.operator===">"&&n.operator===">="?e:n},na=(n,e,t)=>{if(!n)return e;let r=cr(n.semver,e.semver,t);return r<0?n:r>0||e.operator==="<"&&n.operator==="<="?e:n};ia.exports=Bu;});var la=a((Sh,ua)=>{var dr=ve(),sa=De(),zu=M(),oa=Kt(),Vu=me(),Ju=Nn(),Wu=Ln(),Zu=Dn(),Ku=qn(),Xu=Hn(),Yu=zn(),Qu=Jn(),el=Zn(),tl=W(),rl=Qn(),nl=ti(),il=ct(),al=ai(),sl=oi(),ol=Ue(),ul=dt(),ll=Yt(),cl=Qt(),dl=ht(),hl=ft(),fl=er(),pl=gi(),ml=qe(),gl=Z(),_l=He(),yl=$i(),bl=Ni(),wl=Li(),vl=Di(),El=Ui(),Tl=gt(),Sl=Vi(),Ol=Wi(),xl=Xi(),Il=Qi(),Al=aa();ua.exports={parse:Vu,valid:Ju,clean:Wu,inc:Zu,diff:Ku,major:Xu,minor:Yu,patch:Qu,prerelease:el,compare:tl,rcompare:rl,compareLoose:nl,compareBuild:il,sort:al,rsort:sl,gt:ol,lt:ul,eq:ll,neq:cl,gte:dl,lte:hl,cmp:fl,coerce:pl,Comparator:ml,Range:gl,satisfies:_l,toComparators:yl,maxSatisfying:bl,minSatisfying:wl,minVersion:vl,validRange:El,outside:Tl,gtr:Sl,ltr:Ol,intersects:xl,simplifyRange:Il,subset:Al,SemVer:zu,re:dr.re,src:dr.src,tokens:dr.t,SEMVER_SPEC_VERSION:sa.SEMVER_SPEC_VERSION,RELEASE_TYPES:sa.RELEASE_TYPES,compareIdentifiers:oa.compareIdentifiers,rcompareIdentifiers:oa.rcompareIdentifiers};});var Aa=a((wf,Ia)=>{var Oa=(n=0)=>e=>`\x1B[${38+n};5;${e}m`,xa=(n=0)=>(e,t,r)=>`\x1B[${38+n};2;${e};${t};${r}m`;function ac(){let n=new Map,e={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};e.color.gray=e.color.blackBright,e.bgColor.bgGray=e.bgColor.bgBlackBright,e.color.grey=e.color.blackBright,e.bgColor.bgGrey=e.bgColor.bgBlackBright;for(let[t,r]of Object.entries(e)){for(let[i,a]of Object.entries(r))e[i]={open:`\x1B[${a[0]}m`,close:`\x1B[${a[1]}m`},r[i]=e[i],n.set(a[0],a[1]);Object.defineProperty(e,t,{value:r,enumerable:false});}return Object.defineProperty(e,"codes",{value:n,enumerable:false}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",e.color.ansi256=Oa(),e.color.ansi16m=xa(),e.bgColor.ansi256=Oa(10),e.bgColor.ansi16m=xa(10),Object.defineProperties(e,{rgbToAnsi256:{value:(t,r,i)=>t===r&&r===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5),enumerable:false},hexToRgb:{value:t=>{let r=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(t.toString(16));if(!r)return [0,0,0];let{colorString:i}=r.groups;i.length===3&&(i=i.split("").map(s=>s+s).join(""));let a=Number.parseInt(i,16);return [a>>16&255,a>>8&255,a&255]},enumerable:false},hexToAnsi256:{value:t=>e.rgbToAnsi256(...e.hexToRgb(t)),enumerable:false}}),e}Object.defineProperty(Ia,"exports",{enumerable:true,get:ac});});var Vr=c(Dr(),1);c(zr(),1);function Jr(n,e){return (e==null?void 0:e[n])||(0, Vr.default)(n)}function Wr(n,e,t){let r={};for(let i in n)Object.hasOwn(n,i)&&(r[e(i,t)]=n[i]);return r}function Zr(n){return Array.isArray(n)?[...n]:{...n}}function es(n,e){let t=Zr(n);for(let[r,i]of Object.entries(e)){let[a,...s]=r.split(".").reverse(),o=t;for(let u of s.reverse()){if(o[u]===void 0)break;o[u]=Zr(o[u]),o=o[u];}o[a]!==void 0&&(o[a]={lc:1,type:"secret",id:[i]});}return t}function Lt(n){let e=Object.getPrototypeOf(n);return typeof n.lc_name=="function"&&(typeof e.lc_name!="function"||n.lc_name()!==e.lc_name())?n.lc_name():n.name}var ue=class n{static lc_name(){return this.name}get lc_id(){return [...this.lc_namespace,Lt(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(e,...t){Object.defineProperty(this,"lc_serializable",{enumerable:true,configurable:true,writable:true,value:false}),Object.defineProperty(this,"lc_kwargs",{enumerable:true,configurable:true,writable:true,value:void 0}),this.lc_serializable_keys!==void 0?this.lc_kwargs=Object.fromEntries(Object.entries(e||{}).filter(([r])=>{var i;return (i=this.lc_serializable_keys)==null?void 0:i.includes(r)})):this.lc_kwargs=e!=null?e:{};}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof n||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let e={},t={},r=Object.keys(this.lc_kwargs).reduce((i,a)=>(i[a]=a in this?this[a]:this.lc_kwargs[a],i),{});for(let i=Object.getPrototypeOf(this);i;i=Object.getPrototypeOf(i))Object.assign(e,Reflect.get(i,"lc_aliases",this)),Object.assign(t,Reflect.get(i,"lc_secrets",this)),Object.assign(r,Reflect.get(i,"lc_attributes",this));return Object.keys(t).forEach(i=>{let a=this,s=r,[o,...u]=i.split(".").reverse();for(let l of u.reverse()){if(!(l in a)||a[l]===void 0)return;(!(l in s)||s[l]===void 0)&&(typeof a[l]=="object"&&a[l]!=null?s[l]={}:Array.isArray(a[l])&&(s[l]=[])),a=a[l],s=s[l];}o in a&&a[o]!==void 0&&(s[o]=s[o]||a[o]);}),{lc:1,type:"constructor",id:this.lc_id,kwargs:Wr(Object.keys(t).length?es(r,t):r,Jr,e)}}toJSONNotImplemented(){return {lc:1,type:"not_implemented",id:this.lc_id}}};var Mt=()=>typeof Deno!="undefined";function z(n){var e;try{return typeof process!="undefined"?(e=process.env)==null?void 0:e[n]:Mt()?Deno==null?void 0:Deno.env.get(n):void 0}catch{return}}var Dt=class{};var te=class n extends Dt{get lc_namespace(){return ["langchain_core","callbacks",this.name]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}static lc_name(){return this.name}get lc_id(){return [...this.lc_namespace,Lt(this.constructor)]}constructor(e){var t,r,i,a,s,o,u;super(),Object.defineProperty(this,"lc_serializable",{enumerable:true,configurable:true,writable:true,value:false}),Object.defineProperty(this,"lc_kwargs",{enumerable:true,configurable:true,writable:true,value:void 0}),Object.defineProperty(this,"ignoreLLM",{enumerable:true,configurable:true,writable:true,value:false}),Object.defineProperty(this,"ignoreChain",{enumerable:true,configurable:true,writable:true,value:false}),Object.defineProperty(this,"ignoreAgent",{enumerable:true,configurable:true,writable:true,value:false}),Object.defineProperty(this,"ignoreRetriever",{enumerable:true,configurable:true,writable:true,value:false}),Object.defineProperty(this,"ignoreCustomEvent",{enumerable:true,configurable:true,writable:true,value:false}),Object.defineProperty(this,"raiseError",{enumerable:true,configurable:true,writable:true,value:false}),Object.defineProperty(this,"awaitHandlers",{enumerable:true,configurable:true,writable:true,value:z("LANGCHAIN_CALLBACKS_BACKGROUND")==="false"}),this.lc_kwargs=e||{},e&&(this.ignoreLLM=(t=e.ignoreLLM)!=null?t:this.ignoreLLM,this.ignoreChain=(r=e.ignoreChain)!=null?r:this.ignoreChain,this.ignoreAgent=(i=e.ignoreAgent)!=null?i:this.ignoreAgent,this.ignoreRetriever=(a=e.ignoreRetriever)!=null?a:this.ignoreRetriever,this.ignoreCustomEvent=(s=e.ignoreCustomEvent)!=null?s:this.ignoreCustomEvent,this.raiseError=(o=e.raiseError)!=null?o:this.raiseError,this.awaitHandlers=this.raiseError||((u=e._awaitHandler)!=null?u:this.awaitHandlers));}copy(){return new this.constructor(this)}toJSON(){return ue.prototype.toJSON.call(this)}toJSONNotImplemented(){return ue.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends n{constructor(){super(),Object.defineProperty(this,"name",{enumerable:true,configurable:true,writable:true,value:Se.v4()}),Object.assign(this,e);}}return new t}};function ss(n,e){function t(r,i){if(typeof r!="object"||r===null||r===void 0)return r;if(i>=e)return Array.isArray(r)?"[Array]":"[Object]";if(Array.isArray(r))return r.map(s=>t(s,i+1));let a={};for(let s of Object.keys(r))a[s]=t(r[s],i+1);return a}return JSON.stringify(t(n,0),null,2)}var ee=class extends ue{get lc_aliases(){return {additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}get text(){return typeof this.content=="string"?this.content:""}getType(){return this._getType()}constructor(e,t){typeof e=="string"&&(e={content:e,additional_kwargs:t,response_metadata:{}}),e.additional_kwargs||(e.additional_kwargs={}),e.response_metadata||(e.response_metadata={}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:true,configurable:true,writable:true,value:["langchain_core","messages"]}),Object.defineProperty(this,"lc_serializable",{enumerable:true,configurable:true,writable:true,value:true}),Object.defineProperty(this,"content",{enumerable:true,configurable:true,writable:true,value:void 0}),Object.defineProperty(this,"name",{enumerable:true,configurable:true,writable:true,value:void 0}),Object.defineProperty(this,"additional_kwargs",{enumerable:true,configurable:true,writable:true,value:void 0}),Object.defineProperty(this,"response_metadata",{enumerable:true,configurable:true,writable:true,value:void 0}),Object.defineProperty(this,"id",{enumerable:true,configurable:true,writable:true,value:void 0}),this.name=e.name,this.content=e.content,this.additional_kwargs=e.additional_kwargs,this.response_metadata=e.response_metadata,this.id=e.id;}toDict(){return {type:this._getType(),data:this.toJSON().kwargs}}static lc_name(){return "BaseMessage"}get _printableFields(){return {id:this.id,content:this.content,name:this.name,additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata}}_updateId(e){this.id=e,this.lc_kwargs.id=e;}get[Symbol.toStringTag](){return this.constructor.lc_name()}[Symbol.for("nodejs.util.inspect.custom")](e){if(e===null)return this;let t=ss(this._printableFields,Math.max(4,e));return `${this.constructor.lc_name()} ${t}`}};var fe=class extends ee{static lc_name(){return "ToolMessage"}get lc_aliases(){return {tool_call_id:"tool_call_id"}}constructor(e,t,r){typeof e=="string"&&(e={content:e,name:r,tool_call_id:t}),super(e),Object.defineProperty(this,"lc_direct_tool_output",{enumerable:true,configurable:true,writable:true,value:true}),Object.defineProperty(this,"status",{enumerable:true,configurable:true,writable:true,value:void 0}),Object.defineProperty(this,"tool_call_id",{enumerable:true,configurable:true,writable:true,value:void 0}),Object.defineProperty(this,"artifact",{enumerable:true,configurable:true,writable:true,value:void 0}),this.tool_call_id=e.tool_call_id,this.artifact=e.artifact,this.status=e.status;}_getType(){return "tool"}static isInstance(e){return e._getType()==="tool"}get _printableFields(){return {...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}};c(Qe(),1);c(Qe(),1);c(it(),1);c(la(),1);new TextEncoder;var Er={};b(Er,{JsonPatchError:()=>C,_areEquals:()=>Ve,applyOperation:()=>ye,applyPatch:()=>Rt,applyReducer:()=>rc,deepClone:()=>ec,getValueByPointer:()=>It,validate:()=>Sa,validator:()=>At});var Ql=Object.prototype.hasOwnProperty;function Ea(n,e){return Ql.call(n,e)}function Ta(n){if(Array.isArray(n)){let t=new Array(n.length);for(let r=0;r<t.length;r++)t[r]=""+r;return t}if(Object.keys)return Object.keys(n);let e=[];for(let t in n)Ea(n,t)&&e.push(t);return e}function K(n){switch(typeof n){case "object":return JSON.parse(JSON.stringify(n));case "undefined":return null;default:return n}}function Ot(n){let e=0,t=n.length,r;for(;e<t;){if(r=n.charCodeAt(e),r>=48&&r<=57){e++;continue}return false}return true}function ze(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}function St(n){if(n===void 0)return true;if(n){if(Array.isArray(n)){for(let t=0,r=n.length;t<r;t++)if(St(n[t]))return true}else if(typeof n=="object"){let t=Ta(n),r=t.length;for(var e=0;e<r;e++)if(St(n[t[e]]))return true}}return false}function va(n,e){let t=[n];for(let r in e){let i=typeof e[r]=="object"?JSON.stringify(e[r],null,2):e[r];typeof i!="undefined"&&t.push(`${r}: ${i}`);}return t.join(`
2
- `)}var _e=class extends Error{constructor(e,t,r,i,a){super(va(e,{name:t,index:r,operation:i,tree:a})),Object.defineProperty(this,"name",{enumerable:true,configurable:true,writable:true,value:t}),Object.defineProperty(this,"index",{enumerable:true,configurable:true,writable:true,value:r}),Object.defineProperty(this,"operation",{enumerable:true,configurable:true,writable:true,value:i}),Object.defineProperty(this,"tree",{enumerable:true,configurable:true,writable:true,value:a}),Object.setPrototypeOf(this,new.target.prototype),this.message=va(e,{name:t,index:r,operation:i,tree:a});}};var C=_e,ec=K,Oe={add:function(n,e,t){return n[e]=this.value,{newDocument:t}},remove:function(n,e,t){var r=n[e];return delete n[e],{newDocument:t,removed:r}},replace:function(n,e,t){var r=n[e];return n[e]=this.value,{newDocument:t,removed:r}},move:function(n,e,t){let r=It(t,this.path);r&&(r=K(r));let i=ye(t,{op:"remove",path:this.from}).removed;return ye(t,{op:"add",path:this.path,value:i}),{newDocument:t,removed:r}},copy:function(n,e,t){let r=It(t,this.from);return ye(t,{op:"add",path:this.path,value:K(r)}),{newDocument:t}},test:function(n,e,t){return {newDocument:t,test:Ve(n[e],this.value)}},_get:function(n,e,t){return this.value=n[e],{newDocument:t}}},tc={add:function(n,e,t){return Ot(e)?n.splice(e,0,this.value):n[e]=this.value,{newDocument:t,index:e}},remove:function(n,e,t){var r=n.splice(e,1);return {newDocument:t,removed:r[0]}},replace:function(n,e,t){var r=n[e];return n[e]=this.value,{newDocument:t,removed:r}},move:Oe.move,copy:Oe.copy,test:Oe.test,_get:Oe._get};function It(n,e){if(e=="")return n;var t={op:"_get",path:e};return ye(n,t),t.value}function ye(n,e,t=false,r=true,i=true,a=0){if(t&&(typeof t=="function"?t(e,0,n,e.path):At(e,0)),e.path===""){let s={newDocument:n};if(e.op==="add")return s.newDocument=e.value,s;if(e.op==="replace")return s.newDocument=e.value,s.removed=n,s;if(e.op==="move"||e.op==="copy")return s.newDocument=It(n,e.from),e.op==="move"&&(s.removed=n),s;if(e.op==="test"){if(s.test=Ve(n,e.value),s.test===false)throw new C("Test operation failed","TEST_OPERATION_FAILED",a,e,n);return s.newDocument=n,s}else {if(e.op==="remove")return s.removed=n,s.newDocument=null,s;if(e.op==="_get")return e.value=n,s;if(t)throw new C("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",a,e,n);return s}}else {r||(n=K(n));let o=(e.path||"").split("/"),u=n,l=1,c=o.length,d,h,f;for(typeof t=="function"?f=t:f=At;;){if(h=o[l],h&&h.indexOf("~")!=-1&&(h=ze(h)),i&&(h=="__proto__"||h=="prototype"&&l>0&&o[l-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(t&&d===void 0&&(u[h]===void 0?d=o.slice(0,l).join("/"):l==c-1&&(d=e.path),d!==void 0&&f(e,0,n,d)),l++,Array.isArray(u)){if(h==="-")h=u.length;else {if(t&&!Ot(h))throw new C("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",a,e,n);Ot(h)&&(h=~~h);}if(l>=c){if(t&&e.op==="add"&&h>u.length)throw new C("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",a,e,n);let p=tc[e.op].call(e,u,h,n);if(p.test===false)throw new C("Test operation failed","TEST_OPERATION_FAILED",a,e,n);return p}}else if(l>=c){let p=Oe[e.op].call(e,u,h,n);if(p.test===false)throw new C("Test operation failed","TEST_OPERATION_FAILED",a,e,n);return p}if(u=u[h],t&&l<c&&(!u||typeof u!="object"))throw new C("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",a,e,n)}}}function Rt(n,e,t,r=true,i=true){if(t&&!Array.isArray(e))throw new C("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(n=K(n));let a=new Array(e.length);for(let s=0,o=e.length;s<o;s++)a[s]=ye(n,e[s],t,true,i,s),n=a[s].newDocument;return a.newDocument=n,a}function rc(n,e,t){let r=ye(n,e);if(r.test===false)throw new C("Test operation failed","TEST_OPERATION_FAILED",t,e,n);return r.newDocument}function At(n,e,t,r){if(typeof n!="object"||n===null||Array.isArray(n))throw new C("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,n,t);if(Oe[n.op]){if(typeof n.path!="string")throw new C("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,n,t);if(n.path.indexOf("/")!==0&&n.path.length>0)throw new C('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,n,t);if((n.op==="move"||n.op==="copy")&&typeof n.from!="string")throw new C("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,n,t);if((n.op==="add"||n.op==="replace"||n.op==="test")&&n.value===void 0)throw new C("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,n,t);if((n.op==="add"||n.op==="replace"||n.op==="test")&&St(n.value))throw new C("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,n,t);if(t){if(n.op=="add"){var i=n.path.split("/").length,a=r.split("/").length;if(i!==a+1&&i!==a)throw new C("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,n,t)}else if(n.op==="replace"||n.op==="remove"||n.op==="_get"){if(n.path!==r)throw new C("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,n,t)}else if(n.op==="move"||n.op==="copy"){var s={op:"_get",path:n.from,value:void 0},o=Sa([s],t);if(o&&o.name==="OPERATION_PATH_UNRESOLVABLE")throw new C("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,n,t)}}}else throw new C("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,n,t)}function Sa(n,e,t){try{if(!Array.isArray(n))throw new C("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)Rt(K(e),K(n),t||!0);else {t=t||At;for(var r=0;r<n.length;r++)t(n[r],r,e,void 0);}}catch(i){if(i instanceof C)return i;throw i}}function Ve(n,e){if(n===e)return true;if(n&&e&&typeof n=="object"&&typeof e=="object"){var t=Array.isArray(n),r=Array.isArray(e),i,a,s;if(t&&r){if(a=n.length,a!=e.length)return false;for(i=a;i--!==0;)if(!Ve(n[i],e[i]))return false;return true}if(t!=r)return false;var o=Object.keys(n);if(a=o.length,a!==Object.keys(e).length)return false;for(i=a;i--!==0;)if(!e.hasOwnProperty(o[i]))return false;for(i=a;i--!==0;)if(s=o[i],!Ve(n[s],e[s]))return false;return true}return n!==n&&e!==e}({...Er});var Sr=c(Aa(),1);var {color:G}=Sr.default;c(it(),1);c(Qe(),1);c(it(),1);new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");var he=n=>typeof n=="object"&&n!==null,vc=n=>he(n)&&"content"in n,Ec=n=>he(n)&&"messages"in n,Tc=n=>he(n)&&"value"in n,Sc=n=>he(n)&&"kwargs"in n,Ce=(...n)=>n.find(e=>e!=null),Da=n=>Object.fromEntries(Object.entries(n).filter(([,e])=>!(e==null||Array.isArray(e)&&e.length===0||he(e)&&Object.keys(e).length===0))),Fa=n=>{try{return JSON.parse(n)}catch{return {value:n}}},kr=n=>{var i;let e=(i=n.name)!=null?i:n.getType();n.getType()==="human"?e="user":n.getType()==="ai"?e="assistant":n.getType()==="system"&&(e="system");let t={},r=n;return "tool_calls"in r&&(t.tool_calls=r.tool_calls),"status"in r&&(t.status=r.status),"artifact"in r&&(t.artifact=r.artifact),Da({content:n.content,role:e,...t})},Ua=n=>({messages:n.flatMap(t=>t.map(kr))}),Ma=n=>"message"in n?kr(n.message):"text"in n&&n.text?n.text:n,qa=n=>({generations:n.flatMap(t=>Array.isArray(t)?t.map(Ma):Ma(t))}),Ba=n=>n instanceof fe?kr(n):void 0,Pe=(n,e,t)=>{let r=Da({model:Ce(e==null?void 0:e.model,t==null?void 0:t.ls_model_name,n.name),temperature:Ce(e==null?void 0:e.temperature,t==null?void 0:t.ls_temperature),top_p:Ce(e==null?void 0:e.top_p,e==null?void 0:e.topP),top_k:Ce(e==null?void 0:e.top_k,e==null?void 0:e.topK),max_tokens:Ce(e==null?void 0:e.max_tokens,e==null?void 0:e.maxOutputTokens),frequency_penalty:e==null?void 0:e.frequency_penalty,presence_penalty:e==null?void 0:e.presence_penalty,response_format:e==null?void 0:e.response_format,tool_choice:e==null?void 0:e.tool_choice,function_call:e==null?void 0:e.function_call,n:e==null?void 0:e.n,stop:Ce(e==null?void 0:e.stop,e==null?void 0:e.stop_sequence)});return Object.keys(r).length?r:e},$e=n=>{if(n==null)return {value:n};if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return {value:n};if(!he(n))return {value:n};if(vc(n)&&n.content!==void 0){let e=n.content;return he(e)?e:{value:e}}if(Ec(n)&&n.messages!==void 0)return {messages:Array.isArray(n.messages)?n.messages.map($e):[$e(n.messages)]};if(Tc(n)&&n.value!==void 0){let e=n.value;return he(e)?e:{value:e}}return Sc(n)&&n.kwargs!==void 0?$e(n.kwargs):Object.fromEntries(Object.entries(n).map(([e,t])=>[e,$e(t)]))},Ha=n=>{try{let e=(Array.isArray(n)?n:[n]).filter(t=>t!=null).flatMap($e);return e.length===1?e[0]:e.length>1?{values:e}:{}}catch(e){return console.warn("Error processing chain outputs:",e),{error:String(e)}}},Nt=n=>{try{let e=(Array.isArray(n)?n:[n]).filter(t=>t!=null).flatMap($e);return e.length===1?e[0]:e.length>1?{values:e}:{}}catch(e){return console.warn("Error processing chain inputs:",e),{error:String(e)}}};var Lr=class extends te{constructor(t){var r;super();this.name="OpikCallbackHandler";this.spansMap=new Map;this.options={...t},this.client=(r=t==null?void 0:t.client)!=null?r:new f,t!=null&&t.projectName&&(this.client.config.projectName=t==null?void 0:t.projectName);}startTracing({runId:t,parentRunId:r,name:i,input:a,tags:s,metadata:o,type:u}){let l=o==null?void 0:o.ls_provider,c=o==null?void 0:o.ls_model_name;if(!r&&t===this.rootTraceId)return;if(r||(this.rootTraceId=t,this.rootTrace=this.client.trace({name:i,input:a,tags:this.options.tags,metadata:o})),!this.rootTrace){a$1.debug(`handleChainStart error ${t} has no parent`);return}let d$1;this.rootTraceId&&this.rootTraceId!==r&&(d$1=r);let h=this.spansMap.get(t),f;h?f=h.update({input:Nt(a),tags:s,metadata:o,model:c,provider:l}):f=this.rootTrace.span({type:u||d.General,name:i,input:Nt(a),tags:s,metadata:o,model:c,provider:l,parentSpanId:d$1}),this.spansMap.set(t,f);}endTracing({runId:t,output:r,error:i,tags:a,usage:s,metadata:o}){var c,d;let u;i&&(a$1.debug(`End tracing because of error ${i.message}`),u={message:i.message,exceptionType:i.name,traceback:(c=i.stack)!=null?c:""});let l=this.spansMap.get(t);if(!l){a$1.debug(`handleChainEnd span ${t} has not found`);return}l.update({output:r,errorInfo:u,tags:a,usage:s,metadata:o}),l.end(),this.spansMap.delete(t),t===this.rootTraceId&&(this.rootTraceId=void 0,(d=this.rootTrace)==null||d.end(),this.rootTrace=void 0);}async handleChatModelStart(t,r,i,a,s,o,u,l){var c,d$1,h;a$1.debug(`handleChatModelStart runId - ${i}, parentRunId ${a}`),this.startTracing({runId:i,parentRunId:a,name:(d$1=l!=null?l:(c=t.id.at(-1))==null?void 0:c.toString())!=null?d$1:"Chat Model",type:d.Llm,input:Ua(r),tags:o,metadata:{...u,...Pe(t,(s==null?void 0:s.invocation_params)||{},u),tools:(h=s==null?void 0:s.invocation_params)==null?void 0:h.tools}});}async handleLLMStart(t,r,i,a,s,o,u,l){var c,d$1;a$1.debug(`handleLLMStart runId - ${i}, parentRunId ${a}`),this.startTracing({runId:i,parentRunId:a,name:(d$1=l!=null?l:(c=t.id.at(-1))==null?void 0:c.toString())!=null?d$1:"LLM",type:d.Llm,input:{prompts:r},tags:o,metadata:{...u,...Pe(t,(s==null?void 0:s.invocation_params)||{},u)}});}async handleLLMError(t,r,i,a){a$1.debug(`handleLLMError runId - ${r}, parentRunId ${i}`),this.endTracing({runId:r,error:t,tags:a});}async handleLLMEnd(t,r,i,a){a$1.debug(`handleLLMEnd runId - ${r}, parentRunId ${i}`);let{llmOutput:s,generations:o,...u}=t,l=(s==null?void 0:s.tokenUsage)||(s==null?void 0:s.estimatedTokens)||{};this.endTracing({runId:r,output:qa(o),usage:{prompt_tokens:l.completionTokens,completion_tokens:l.promptTokens,total_tokens:l.totalTokens},tags:a,metadata:u});}async handleChainStart(t,r,i,a,s,o,u,l){var h,f;if(a$1.debug(`handleChainStart runId - ${i}, parentRunId ${a}`),s!=null&&s.includes("langsmith:hidden"))return;let c=(f=l!=null?l:(h=t.id.at(-1))==null?void 0:h.toString())!=null?f:"Chain",d={runId:i,parentRunId:a,name:c,input:Nt(r),tags:this.options.tags,metadata:{...o,...Pe(t,{},o)}};a||(d.metadata={...o,...this.options.metadata}),this.startTracing(d);}async handleChainError(t,r,i,a){a$1.debug(`handleChainError runId - ${r}, parentRunId ${i}`),this.endTracing({runId:r,tags:a,error:t});}async handleChainEnd(t,r,i,a){a$1.debug(`handleChainEnd runId - ${r}, parentRunId ${i}`),this.endTracing({runId:r,output:Ha(t),tags:a});}async handleToolStart(t,r,i,a,s,o,u){var l,c;a$1.debug(`handleToolStart runId - ${i}, parentRunId ${a}`),this.startTracing({runId:i,parentRunId:a,name:(c=u!=null?u:(l=t.id.at(-1))==null?void 0:l.toString())!=null?c:"Tool",input:Fa(r),tags:s,type:d.Tool,metadata:{...o,...Pe(t,{},o)}});}async handleToolError(t,r,i,a){a$1.debug(`handleToolError runId - ${r}, parentRunId ${i}`),this.endTracing({runId:r,tags:a,error:t});}async handleToolEnd(t,r,i,a){a$1.debug(`handleToolEnd runId - ${r}, parentRunId ${i}`),this.endTracing({runId:r,output:Ba(t),tags:a});}async handleAgentAction(t,r,i,a){a$1.debug(`handleAgentAction runId - ${r}, parentRunId ${i}`),this.startTracing({runId:r,parentRunId:i,name:t.tool,input:t,tags:a});}async handleAgentEnd(t,r,i,a){a$1.debug(`handleAgentEnd runId - ${r}, parentRunId ${i}`),this.endTracing({runId:r,output:t,tags:a});}async handleRetrieverStart(t,r,i,a,s,o,u){var l,c;a$1.debug(`handleRetrieverStart runId - ${i}, parentRunId ${a}`),this.startTracing({runId:i,parentRunId:a,name:(c=u!=null?u:(l=t.id.at(-1))==null?void 0:l.toString())!=null?c:"Retriever",type:d.Tool,input:{query:r},tags:s,metadata:{...o,...Pe(t,{},o)}});}async handleRetrieverEnd(t,r,i,a){a$1.debug(`handleRetrieverEnd runId - ${r}, parentRunId ${i}`),this.endTracing({runId:r,output:{documents:t},tags:a});}async handleRetrieverError(t,r,i,a){a$1.debug(`handleRetrieverError runId - ${r}, parentRunId ${i}`),this.endTracing({runId:r,error:t,tags:a});}async flushAsync(){return this.client.flush()}};/*! Bundled license information:
3
-
4
- @langchain/core/dist/utils/fast-json-patch/src/helpers.js:
5
- (*!
6
- * https://github.com/Starcounter-Jack/JSON-Patch
7
- * (c) 2017-2022 Joachim Wester
8
- * MIT licensed
9
- *)
10
-
11
- @langchain/core/dist/utils/fast-json-patch/src/duplex.js:
12
- (*!
13
- * https://github.com/Starcounter-Jack/JSON-Patch
14
- * (c) 2013-2021 Joachim Wester
15
- * MIT license
16
- *)
17
- */export{Lr as OpikCallbackHandler};