@transai/connector-runner-ai-agent 0.53.7 → 0.53.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.53.7 (2026-11-11)
2
+
3
+ This was a version bump only for connector-runner-ai-agent to align it with other projects, there were no code changes.
4
+
1
5
  ## 0.53.6 (2026-11-09)
2
6
 
3
7
  This was a version bump only for connector-runner-ai-agent to align it with other projects, there were no code changes.
package/index.cjs CHANGED
@@ -1179,7 +1179,7 @@ Caused by: `,WMt=Symbol("causeStack");function smn(t,e){let r=Ce.hasOwnProp(t,WM
1179
1179
  `);s=a===-1?"":o.slice(a+1)}if(!n.stack)n.stack=s;else if(s){let a=s.indexOf(`
1180
1180
  `),c=a===-1?-1:s.indexOf(`
1181
1181
  `,a+1),u=c===-1?s:s.slice(c+1),d=String(n.stack),p=smn(n,d),f=p===-1?d:d.slice(0,p),m=p===-1?"":d.slice(p);f.endsWith(u)||(n.stack=f+`
1182
- `+s+m)}}catch{}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=yx(this.defaults,r);let{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&fSe.assertOptions(n,{silentJSONParsing:lf.transitional(lf.boolean),forcedJSONParsing:lf.transitional(lf.boolean),clarifyTimeoutError:lf.transitional(lf.boolean),legacyInterceptorReqResOrdering:lf.transitional(lf.boolean),advertiseZstdAcceptEncoding:lf.transitional(lf.boolean),validateStatusUndefinedResolves:lf.transitional(lf.boolean),encodeBasicAuthUsername:lf.transitional(lf.boolean)},!1),i!=null&&(Ce.isFunction(i)?r.paramsSerializer={serialize:i}:fSe.assertOptions(i,{encode:lf.function,serialize:lf.function},!0)),r.allowAbsoluteUrls!==void 0||(Ce.hasOwnProp(this.defaults,"allowAbsoluteUrls")&&this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),fSe.assertOptions(r,{baseUrl:lf.spelling("baseURL"),withXsrfToken:lf.spelling("withXSRFToken")},!0),r.method=(Ce.getSafeProp(r,"method")||Ce.getSafeProp(this.defaults,"method")||"get").toLowerCase();let s=Ce.getSafeProp(o,"common"),a=Ce.getSafeProp(o,r.method),c=o&&Ce.merge(wDt(s)?s:void 0,wDt(a)?a:void 0);o&&Ce.forEach(MFe.concat("common"),v=>{wDt(Ce.getSafeProp(o,v))&&delete o[v]}),r.headers=ba.concat(c,o);let u=[],d=!0;this.interceptors.request.forEach(function(b){if(typeof b.runWhen=="function"&&b.runWhen(r)===!1)return;d=d&&b.synchronous;let w=r.transitional||f5;w&&w.legacyInterceptorReqResOrdering?u.unshift(b.fulfilled,b.rejected):u.push(b.fulfilled,b.rejected)});let p=[];this.interceptors.response.forEach(function(b){p.push(b.fulfilled,b.rejected)});let f,m=0,h;if(!d){let v=[pSe.bind(this),void 0];for(v.unshift(...u),v.push(...p),h=v.length,f=Promise.resolve(r);m<h;)f=f.then(v[m++],v[m++]);return f}h=u.length;let g=r;for(;m<h;){let v=u[m++],b=u[m++];try{g=v?v(g):g}catch(w){if(!b){f=Promise.reject(w);break}try{let E=b.call(this,w);Ce.isThenable(E)&&(f=Promise.resolve(E).then(()=>pSe.call(this,g)))}catch(E){f=Promise.reject(E)}break}}if(!f)try{f=pSe.call(this,g)}catch(v){f=Promise.reject(v)}for(m=0,h=p.length;m<h;)f=f.then(p[m++],p[m++]);return f}getUri(e){e=yx(this.defaults,e);let r=NB(e.baseURL,e.url,e.allowAbsoluteUrls,e);return kB(r,e.params,e.paramsSerializer)}};Ce.forEach(["delete","get","head","options"],function(e){yee.prototype[e]=async function(r,n){return this.request(yx(n||{},{method:e,url:r,data:n&&Ce.hasOwnProp(n,"data")?n.data:void 0}))}});Ce.forEach(["post","put","patch","query"],function(e){function r(n){return async function(o,s,a){return this.request(yx(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}yee.prototype[e]=r(),e!=="query"&&(yee.prototype[e+"Form"]=r(!0))});var mSe=yee;var EDt=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});let n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o,s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},e(function(o,s,a){n.reason||(n.reason=new Ev(o,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new t(function(i){e=i}),cancel:e}}},Zyn=EDt;function xDt(t){return function(r){return t.apply(null,r)}}function ADt(t){return Ce.isObject(t)&&t.isAxiosError===!0}var YFe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,ContentTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,UnprocessableContent:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerReturnsAnUnknownError:520,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(YFe).forEach(([t,e])=>{YFe[e]===void 0&&(YFe[e]=t)});var Qyn=YFe;function e_n(t){let e=new mSe(t),r=IB(mSe.prototype.request,e);return Ce.extend(r,mSe.prototype,e,{allOwnKeys:!0}),Ce.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return e_n(yx(t,i))},r}var xd=e_n(lee);xd.Axios=mSe;xd.CanceledError=Ev;xd.CancelToken=Zyn;xd.isCancel=Y1e;xd.VERSION=aN;xd.toFormData=p5;xd.AxiosError=Bt;xd.Cancel=xd.CanceledError;xd.all=function(e){return Promise.all(e)};xd.spread=xDt;xd.isAxiosError=ADt;xd.mergeConfig=yx;xd.AxiosHeaders=ba;xd.formToJSON=t=>NFe(Ce.isHTMLForm(t)?new FormData(t):t);xd.getAdapter=JFe.getAdapter;xd.HttpStatusCode=Qyn;xd.default=xd;var uN=xd;var{Axios:rpd,AxiosError:npd,CanceledError:ipd,isCancel:opd,CancelToken:spd,VERSION:apd,all:cpd,Cancel:upd,isAxiosError:lpd,spread:dpd,toFormData:ppd,AxiosHeaders:fpd,HttpStatusCode:mpd,formToJSON:hpd,getAdapter:gpd,mergeConfig:ypd,create:_pd}=uN;var Sta=(0,t_n.promisify)(r_n.gzip),ZFe=class{#e;#t;constructor(e,r){this.#e=e,this.#t=r}async get(e,r={},n={}){let i=r.baseUrl||this.#t.baseUrl;return this.#r(r,o=>uN.get(`${i}${e}`,{headers:{Authorization:`Bearer ${o}`},params:n,timeout:this.#t.timeout}))}async post(e,r,n={}){let i=n.baseUrl||this.#t.baseUrl,o=await this.#n(r,n);return this.#r(n,s=>uN.post(`${i}${e}`,o.body,{headers:{Authorization:`Bearer ${s}`,...o.headers},timeout:this.#t.timeout}))}async put(e,r,n={}){let i=n.baseUrl||this.#t.baseUrl;return this.#r(n,o=>uN.put(`${i}${e}`,r,{headers:{Authorization:`Bearer ${o}`},timeout:this.#t.timeout}))}async#r(e,r){let n={...this.#t,...e};try{let{data:i}=await r(await this.#e.getToken(n));return i}catch(i){if(!this.#i(i))throw i;await this.#e.invalidateToken(n);let{data:o}=await r(await this.#e.getToken(n));return o}}#i(e){return e?.response?.status===401}async#n(e,r){if(!r.compress)return{body:e,headers:{}};let n=typeof e=="string"?e:JSON.stringify(e);return{body:await Sta(n),headers:{"Content-Type":"application/json","Content-Encoding":"gzip"}}}};var jSe=require("fs");var Sx=cr(require("node:process")),Ql=cr(T1n()),I1n=(o=>(o.error="error",o.warn="warn",o.info="info",o.debug="debug",o.verbose="verbose",o))(I1n||{}),n9t={levels:{error:0,warn:1,info:2,debug:3,verbose:4},colors:{error:"red",warn:"yellow",info:"green",debug:"magenta",verbose:"blue"}},gc=class t{static instance;logger;#e;constructor(e="default",r="info"){this.logger=Ql.default.createLogger({levels:n9t.levels,level:r,format:Ql.default.format.combine(Ql.default.format.label({label:e}),Ql.default.format.timestamp(),Ql.default.format.errors({stack:!0}),Ql.default.format.json())});let n=!1;(Sx.default.env.NODE_ENV!=="production"||Sx.default.env.LOG_TO_CONSOLE==="true")&&(n=!0,this.logger.add(new Ql.default.transports.Console({format:Ql.default.format.combine(Ql.default.format.colorize({colors:n9t.colors}),Ql.default.format.label({label:e}),Ql.default.format.printf(({label:i,level:o,message:s})=>{let a=new Date().toLocaleString();return`[${i}] ${Sx.default.pid} - ${a} ${o}: ${s}`}))}))),Sx.default.env.LOG_TO_FILE==="true"&&(n=!0,this.logger.add(new Ql.default.transports.File({filename:"error.log",level:"error"})),this.logger.add(new Ql.default.transports.File({filename:"combined.log"}))),n||this.logger.add(new Ql.default.transports.Console({format:Ql.default.format.combine(Ql.default.format.colorize({colors:n9t.colors}),Ql.default.format.label({label:e}),Ql.default.format.printf(({label:i,level:o,message:s})=>`[${i}] ${o}: ${s}`))}))}static getInstance(e,r){return t.instance||(t.instance=new t(e??"default",t.#r(r))),t.instance}setDatadogTransport(e){let r=e?.apiKey??Sx.default.env.DATADOG_API_KEY;if(!r)return this.debug("DATADOG_API_KEY is not set, cannot add Datadog transport"),this;let n=new URLSearchParams({"dd-api-key":r,ddsource:e?.source??Sx.default.env.DD_SOURCE??"nodejs",service:e?.service??Sx.default.env.DD_SERVICE??"unknown",env:e?.env??Sx.default.env.DD_ENV??"prod"});e?.tags&&n.append("ddtags",Object.entries(e.tags).map(([o,s])=>`${o}:${s}`).join(","));let i={host:`http-intake.logs.${Sx.default.env.DD_SITE??"datadoghq.eu"}`,path:`/api/v2/logs?${n.toString()}`,ssl:!0,batch:!0,format:Ql.default.format.json(),level:"info"};return this.#e&&this.logger.remove(this.#e),this.#e=new Ql.default.transports.Http(i),this.logger.add(this.#e),this}info(...e){this.#t(this.logger.info,...e)}static info(...e){this.getInstance().info(...e)}debug(...e){this.#t(this.logger.debug,...e)}static debug(...e){this.getInstance().debug(...e)}error(...e){this.#t(this.logger.error,...e)}static error(...e){this.getInstance().error(...e)}warn(...e){this.#t(this.logger.warn,...e)}static warn(...e){this.getInstance().warn(...e)}verbose(...e){this.#t(this.logger.verbose,...e)}static verbose(...e){this.getInstance().verbose(...e)}#t(e,...r){try{let n=r.map(i=>typeof i=="object"?JSON.stringify(i):String(i));e(n.join(" "),...r)}catch(n){console.error("unknown error in log, function",n)}}static#r=e=>{if(e!==void 0)return e;let r=Sx.default.env.LOG_LEVEL||"info",n=Object.values(I1n),i=!n.includes(r);return i&&(r="info"),i&&console.error(`Invalid log level: ${r} only allow; ${n.join(", ")}. Using ${r} as default.`),r}};var tje=class{#e;#t;#r=!1;constructor(e){this.#e=e,this.#t=gc.getInstance()}async get(e){await this.#i();let r=await jSe.promises.readFile(`${this.#e.path}/${this.#n(e)}`,"utf8").catch(n=>{this.#t.error(n)});return r?JSON.parse(r):void 0}async set(e,r){await this.#i(),await jSe.promises.writeFile(`${this.#e.path}/${this.#n(e)}`,JSON.stringify(r)).catch(n=>{this.#t.error(n)})}async clear(){return Promise.resolve()}async#i(){if(this.#t.verbose("try to init FileSystemCacheService"),this.#r)return;let e=!0;await jSe.promises.stat(this.#e.path).catch(r=>{if(r.code==="ENOENT")e=!1,this.#t.debug("Directory does not exist");else throw this.#t.debug("Error occured"),r}),e||(this.#t.debug(`OffsetStore create ${this.#e.path}`),await jSe.promises.mkdir(this.#e.path,{recursive:!0})),this.#t.debug("Init run successfully. directory exists"),this.#r=!0}#n(e){return`${this.#e.keyPrefix?`${this.#e.keyPrefix}_`:""}${e}.json`}};var rje=class{#e=new Map;get(e){return Promise.resolve(this.#e.get(e))}set(e,r){return this.#e.set(e,r),Promise.resolve()}clear(){return this.#e.clear(),Promise.resolve()}};var w9n=cr(i$t()),Hze=class{#e;#t;constructor(e,r={}){typeof e=="string"&&(e=(0,w9n.createClient)({url:e}),e.connect()),this.#e=e,this.#t=r}async get(e){let r=await this.#e.get(this.getKey(e));return r?JSON.parse(r):void 0}async set(e,r){await this.#e.set(this.getKey(e),JSON.stringify(r))}async clear(){await this.#e.flushDb()}getKey(e){let r=`${this.#t.cacheKeyPrefix}_`;return`${this.#t.cacheKeyPrefix?r:""}${e}`}};var rEa=1e4,nEa=6e4,hwe=class{#e;#t;#r;#i;constructor(e,r){this.#e=e,this.#t=r,this.#r=gc.getInstance()}async getToken(e){let r=await this.#n(),{audience:n,tenantIdentifier:i,cacheKey:o}=this.#l(e),s=r[o];if(s&&s.expiresAt-nEa>Date.now())return this.#r.debug(`Using cached token for audience ${n} and tenantIdentifier ${i}`),s.token.access_token;this.#r.debug(`Fetching new token for audience ${n} and tenantIdentifier ${i} from ${this.#e.tokenUrl}`);let a={method:"POST",url:this.#e.tokenUrl,timeout:rEa,headers:{"content-type":"application/json"},data:JSON.stringify({client_id:this.#e.clientId,client_secret:this.#e.clientSecret,audience:n,grant_type:"client_credentials",...i?{tenantId:i}:{}})},c=Date.now(),{data:u}=await uN.request(a).catch(d=>{throw this.#r.error(`Error fetching token url ${this.#e.tokenUrl} for audience ${n} and tenantIdentifier ${i}: ${(uN.isAxiosError(d)?JSON.stringify(d.response?.data):void 0)??d.message}`),new Error("Error fetching token")});return r[o]={tenantIdentifier:i,audience:n,token:u,expiresAt:this.#a(u,c)},await this.#t.set("cachedTokens",r),u.access_token}async invalidateToken(e){let r=await this.#n(),{cacheKey:n}=this.#l(e);r[n]&&(delete r[n],await this.#t.set("cachedTokens",r))}async#n(){return this.#i===void 0&&(this.#i=await this.#t.get("cachedTokens")),(this.#i===void 0||this.#i===null||typeof this.#i!="object")&&(this.#i={}),this.#i}#l(e){let r=e.audience||this.#e.audience,n=e.tenantIdentifier||this.#e.tenantIdentifier;return{audience:r,tenantIdentifier:n,cacheKey:this.getCacheArrayKey({tenantIdentifier:n,audience:r})}}#a(e,r){let n=r+e.expires_in*1e3,i=this.#d(e.access_token);return i===void 0?n:Math.min(i*1e3,n)}#d(e){try{let r=JSON.parse(Buffer.from(e.split(".")[1]??"","base64url").toString());return typeof r.exp=="number"?r.exp:void 0}catch{return}}getCacheArrayKey(e){return`${e.tenantIdentifier??"__NONE__"}_${e.audience??"__NONE__"}`}};var gwe=class t{static build(e){let r=t.buildCacheService(e.cache??{}),n=t.buildJwtTokenService(e.jwt,r);return new ZFe(n,{baseUrl:e.baseUrl,tenantIdentifier:e.jwt.tenantIdentifier,timeout:e.timeout})}static buildFromEnv(e){return t.build({baseUrl:e.baseUrl,jwt:{tokenUrl:process.env.AUTH0_TOKEN_URL,clientId:process.env.AUTH0_CLIENT_ID,clientSecret:process.env.AUTH0_CLIENT_SECRET,audience:e.audience,tenantIdentifier:e.tenantIdentifier},cache:{type:process.env.REDIS_URL?"redis":"memory",redisUrl:process.env.REDIS_URL,keyPrefix:process.env.CACHE_KEY_PREFIX},timeout:e.timeout})}static buildCachedJwtTokenService(e,r){let n=t.buildCacheService(r??{type:process.env.REDIS_URL?"redis":"memory",redisUrl:process.env.REDIS_URL,keyPrefix:process.env.CACHE_KEY_PREFIX});return new hwe(e,n)}static buildJwtTokenService(e,r){return new hwe(e,r)}static buildCacheService(e={}){switch(e.type){case"redis":return new Hze(String(e.redisUrl),{cacheKeyPrefix:e.keyPrefix});case"filesystem":return new tje({path:e.path??"./cache",keyPrefix:e.keyPrefix});default:return new rje}}};function E9n(t,e,r,n){if(!e||!e.auth0_token_url||!e.auth0_client_id||!e.auth0_client_secret||!e.auth0_audience)throw new Error("Cube config is not valid");let i=gwe.buildCacheService({}),o=gwe.buildJwtTokenService({tokenUrl:e.auth0_token_url,clientId:e.auth0_client_id,clientSecret:e.auth0_client_secret,audience:e.auth0_audience,tenantIdentifier:r},i);return t(async()=>(n.debug(`Getting Auth0 Cube JWT Token for tenant ${r}`),o.getToken({tenantIdentifier:r})),{apiUrl:e.apiUrl})}var o$t=(oe=>(oe.API="api",oe.API_SINK="api-sink",oe.API_SOURCE="api-source",oe.DUMMY_NODE="dummy-node",oe.FILE_COPY="file-copy",oe.FILE="file",oe.FILE_SINK="file-sink",oe.FILE_SOURCE="file-source",oe.SAMBA_SINK="samba-sink",oe.SAMBA_SOURCE="samba-source",oe.SQL_SINK="sql-sink",oe.SQL_SOURCE="sql-source",oe.MQTT="mqtt",oe.CUBE_QUERY_RUNNER="cube-query-runner",oe.FACTORY_NEBULA="factory-nebula",oe.FACTORY_NEBULA_SOURCE="factory-nebula-source",oe.BYSTRONIC="bystronic",oe.IMAP_SOURCE="imap-source",oe.IMAP_SINK="imap-sink",oe.OPCUA_SOURCE="opcua-source",oe.OPCUA_SINK="opcua-sink",oe.AI_AGENT="ai-agent",oe.MICROSOFT_OFFICE365_EMAIL="microsoft-office365-email",oe.MKG="mkg",oe.EZ_MES="ez-mes",oe.OTTO_FLEET_MANAGER_V2="otto-fleet-manager-v2",oe.FRAUNHOFER_BATTERY_ASSEMBLY_CELLS="fraunhofer-battery-assembly-cells",oe.PDF_GENERATE="pdf-generate",oe.ONSHAPE="onshape",oe.OROOX="oroox",oe.GPMS="gpms",oe.KEIZERSMETAAL_TRUMPF_API="keizersmetaal-trumpf-api",oe.HP_INDIGO="hp-indigo",oe.QLINK="qlink",oe.IPP="ipp",oe.CERM="cerm",oe.JVC_TELEMETRY_TEST="jvc-telemetry-test",oe.RIDDER_IQ="ridder-iq",oe.XYLEM="xylem",oe.OSEON="oseon",oe))(o$t||{});function s$t(t){return typeof t=="string"?!1:t!=null&&t.pattern!==void 0&&typeof t.pattern=="string"&&t.flags!==void 0&&typeof t.flags=="string"}wEe();wEe();var Pjt=(n=>(n.documents="documents",n.metrics="metrics",n.events="events",n))(Pjt||{}),fy=(i=>(i.disabled="disabled",i.enabled="enabled",i.overridden="overridden",i.manual="manual",i))(fy||{}),kjt=(a=>(a.equals="=",a.notEquals="<>",a.greaterThan=">",a.greaterThanOrEqual=">=",a.lessThan="<",a.lessThanOrEqual="<=",a.in="IN",a))(kjt||{}),GHe=q.union([q.string().min(1),q.number(),q.boolean(),q.array(q.union([q.string().min(1),q.number(),q.boolean()])).min(1)]),Njt=(r=>(r.and="AND",r.or="OR",r))(Njt||{}),PFn=q.union([q.string().min(1),q.array(q.string().min(1)).min(1)]),Mjt=(i=>(i.string="string",i.number="number",i.boolean="boolean",i.time="time",i))(Mjt||{}),Djt=(o=>(o.id="image_url",o.imageUrl="image_url",o.link="link",o.percent="percent",o.currency="currency",o))(Djt||{}),$jt=(i=>(i.oneToOne="one_to_one",i.oneToMany="one_to_many",i.manyToOne="many_to_one",i.manyToMany="many_to_many",i))($jt||{}),Ljt=(p=>(p.count="count",p.countDistinct="count_distinct",p.countDistinctApprox="count_distinct_approx",p.sum="sum",p.avg="avg",p.min="min",p.max="max",p.string="string",p.time="time",p.boolean="boolean",p.number="number",p))(Ljt||{}),qjt=(r=>(r.percent="percent",r.currency="currency",r))(qjt||{}),Fjt=(A=>(A.equals="equals",A.notEquals="notEquals",A.contains="contains",A.notContains="notContains",A.startsWith="startsWith",A.notStartsWith="notStartsWith",A.endsWith="endsWith",A.notEndsWith="notEndsWith",A.gt="gt",A.gte="gte",A.lt="lt",A.lte="lte",A.set="set",A.notSet="notSet",A.inDateRange="inDateRange",A.notInDateRange="notInDateRange",A.beforeDate="beforeDate",A.beforeOrOnDate="beforeOrOnDate",A.afterDate="afterDate",A.afterOrOnDate="afterOrOnDate",A))(Fjt||{}),jjt=(r=>(r.from_template="from_template",r.manual="manual",r))(jjt||{});var kFn=q.union([q.string().min(1),q.object({name:q.string().min(1),email:q.email().optional(),website:q.url().optional()})]);var NFn=q.object({identifier:q.string(),version:q.string(),name:q.string(),description:q.string().optional(),config:q.record(q.string(),q.any()),inputParameters:q.array(q.object({name:q.string(),description:q.string().optional(),type:q.enum(["string","number","boolean","array","simple-array","unknown"]),required:q.boolean().optional(),itemType:q.enum(["string","number","boolean"]).optional(),items:q.array(q.any()).optional()})),outputParameters:q.record(q.string(),q.any()),mode:q.enum(jjt).optional(),createdAt:q.date().optional(),updatedAt:q.date().optional(),templateIdentifier:q.string().nullable().optional()});var MFn=q.object({dimension:q.string().min(1),operator:q.enum(Fjt),values:GHe});var DFn=q.record(q.string(),q.union([MFn,q.literal(!1)]));var WHe=q.object({name:q.string().min(1).optional(),description:q.string().min(1).optional(),eventType:q.string().min(1).optional(),dataset:q.string().min(1),dimensions:q.array(q.string().min(1)).min(1),measures:q.array(q.string().min(1)).optional(),segments:q.array(q.string().min(1)).optional(),limit:q.number().min(1).optional(),filters:q.union([DFn,q.literal(!1)]).optional(),cron:q.string().optional(),tz:q.string().optional(),incrementalField:q.string().optional(),keyField:q.string().optional(),ungrouped:q.boolean().optional()}),Ujt=WHe.extend({dataset:q.string().min(1).optional(),dimensions:q.array(q.string().min(1)).optional()}),FId=q.union([q.boolean(),Ujt]),XIa=WHe.extend({identifier:q.string(),key:q.string(),status:q.enum(fy)}),jId=XIa.extend({identifier:q.string().min(1),key:q.string().min(1),status:q.enum(fy)});var $Fn=q.record(q.string(),q.union([WHe,q.boolean()]));var LFn=q.lazy(()=>q.object({type:q.enum(Njt),filters:KHe}));var Jie=q.object({sql:q.string().min(1).optional(),dimension:q.string().min(1).optional(),operator:q.enum(kjt).optional(),value:GHe.optional()}).superRefine((t,e)=>{if(t.sql===void 0&&t.dimension===void 0){e.addIssue({code:q.ZodIssueCode.custom,message:"One of sql or dimension must be defined."});return}if(t.sql!==void 0&&t.dimension!==void 0){e.addIssue({code:q.ZodIssueCode.custom,message:"One of sql or dimension must be defined."});return}t.dimension!==void 0&&(t.operator===void 0||t.value===void 0)&&e.addIssue({code:q.ZodIssueCode.custom,message:"When dimension is defined, operator and values must be defined."})});var KHe=q.record(q.string(),q.union([q.lazy(()=>LFn),Jie,q.literal(!1)]));var qFn=q.object({collection:q.string().min(1),filters:KHe.optional()});var YIa=q.record(q.string().regex(/^[a-z]{2}$/),q.record(q.string(),q.string())),Xie=q.record(q.string(),q.union([YIa,q.string().min(1),q.number(),q.boolean()]));var FFn=q.intersection(Jie,q.object({label:q.string().min(1),description:q.string().min(1).optional()}));var jFn=q.record(q.string(),q.union([FFn,q.literal(!1)]));var UFn=q.object({when:jFn,else:q.string().min(1).optional(),segment:q.boolean().optional()});var zFn=q.object({name:q.string().min(1),description:q.string().min(1),type:q.enum(Mjt),format:q.enum(Djt).optional(),explode:q.boolean().optional(),index:q.union([q.boolean(),q.string()]).optional(),upperIndex:q.union([q.boolean(),q.string()]).optional(),switch:UFn.optional(),field:PFn.optional(),sql:q.string().min(1).optional(),public:q.boolean().optional(),primaryKey:q.boolean().optional(),subQuery:q.boolean().optional(),override:q.union([q.boolean(),q.literal("manual")]).optional(),meta:Xie.optional(),granularities:q.record(q.string().min(1),q.object({interval:q.string().min(1)})).optional()}).superRefine((t,e)=>{if(t.switch!==void 0&&(t.field!==void 0||t.sql!==void 0))e.addIssue({code:q.ZodIssueCode.custom,message:"If switch is chosen, do not provide field or sql."});else if(t.switch!==void 0)return;if(t.field!==void 0&&t.sql!==void 0)e.addIssue({code:q.ZodIssueCode.custom,message:"If field is chosen, do not provide sql."});else if(t.field!==void 0)return;t.sql===void 0&&e.addIssue({code:q.ZodIssueCode.custom,message:"Please provide switch, field or sql."})});var BFn=q.record(q.string(),q.union([zFn,q.literal(!1)]));var HFn=q.object({name:q.string().min(1),description:q.string().min(1).optional(),type:q.enum(Ljt),format:q.enum(qjt).optional(),index:q.string().optional(),upperIndex:q.string().optional(),sql:q.string().min(1).optional(),dimension:q.string().min(1).optional(),public:q.boolean().optional(),override:q.union([q.boolean(),q.literal("manual")]).optional(),meta:Xie.optional()}).refine(t=>!(t.sql===void 0&&t.dimension===void 0||t.sql!==void 0&&t.dimension!==void 0),{message:"One of sql or dimension must be defined.",path:["sql","dimension"]});var VFn=q.record(q.string(),q.union([HFn,q.literal(!1)]));var GFn=q.object({type:q.enum(["rollup","original_sql","rollup_join"]).optional(),measures:q.array(q.string()).optional(),dimensions:q.array(q.string()).optional(),segments:q.array(q.string()).optional(),timeDimension:q.string().optional(),granularity:q.string().optional(),partitionGranularity:q.string().optional(),rollups:q.array(q.string()).optional(),refreshKeySql:q.string().optional(),refreshKeyEvery:q.string().optional(),refreshKeyIncremental:q.boolean().optional(),refreshKeyUpdateWindow:q.string().optional(),buildRangeStartSql:q.string().optional(),buildRangeEndSql:q.string().optional(),lambda:q.boolean().optional()});var WFn=q.record(q.string(),q.union([GFn,q.literal(!1)]));var KFn=q.object({type:q.enum($jt),dimension:q.string().min(1).optional(),targetDataset:q.string().min(1),targetDimension:q.string().min(1).optional(),sql:q.string().min(1).optional(),override:q.union([q.boolean(),q.literal("manual")]).optional()}).superRefine((t,e)=>{t.sql!==void 0&&(t.dimension!==void 0||t.targetDimension!==void 0)&&e.addIssue({code:q.ZodIssueCode.custom,message:"Use sql field or dimension/targetDimension."})});var JFn=q.record(q.string(),q.union([KFn,q.literal(!1)]));var XFn=q.intersection(Jie,q.object({name:q.string().min(1).optional(),description:q.string().min(1).optional(),public:q.boolean().optional(),override:q.union([q.boolean(),q.literal("manual")]).optional()}));var YFn=q.record(q.string(),q.union([XFn,q.literal(!1)]));var JHe=q.object({name:q.string().min(1),description:q.string().min(1),type:q.enum(Pjt),prefix:q.string().min(1),parent:q.string().min(1).optional(),sql:q.string().min(1).optional(),refreshSql:q.string().min(1).optional(),meta:Xie.optional(),collection:qFn.optional(),dimensions:BFn.optional(),segments:YFn.optional(),relations:JFn.optional(),measures:VFn.optional(),preAggregations:WFn.optional()}).superRefine((t,e)=>{if(!t.parent&&t.sql===void 0&&t.collection===void 0){e.addIssue({code:q.ZodIssueCode.custom,message:"You need to define either sql or collection."});return}t.sql!==void 0&&t.collection!==void 0&&e.addIssue({code:q.ZodIssueCode.custom,message:"You need to define either sql or collection."})});var XHe=q.record(q.string(),JHe.or(q.boolean()));var ZFn=q.record(q.string(),q.union([q.string(),q.object({selector:q.string(),items:q.lazy(()=>ZFn).optional()})])),QFn=(i=>(i.equals="equals",i.contains="contains",i.startsWith="startsWith",i.endsWith="endsWith",i))(QFn||{}),ZIa=q.object({selector:q.string(),operator:q.enum(QFn).optional().default("equals"),value:q.string()}),QIa=q.array(ZIa),e7n=q.object({identifier:q.string(),name:q.string(),description:q.string().optional(),actionIdentifier:q.string(),inputParameters:ZFn.optional(),validation:QIa.optional()});var YHe=q.object({identifier:q.string(),connectorType:q.enum(o$t),name:q.string(),location:q.string(),config:q.looseObject({}),enabled:q.boolean(),actions:q.array(NFn).optional(),webhooks:q.array(e7n).optional(),templateIdentifier:q.string().nullable().optional(),createdAt:q.date().optional(),updatedAt:q.date().optional()}).superRefine((t,e)=>{let r=t.actions?.reduce((n,i)=>(n[i.identifier]=i,n),{})??{};t.webhooks?.forEach(n=>{let i=r[n.actionIdentifier];if(!i){e.addIssue({code:"custom",message:"Action identifier does not exist in the connector's actions.",params:{webhookIdentifier:n.identifier,actionIdentifier:n.actionIdentifier},input:t});return}let o=(i.inputParameters??[]).filter(a=>a.required).map(a=>a.name),s=n.inputParameters??{};o.forEach(a=>{s[a]||e.addIssue({code:"custom",message:"Required input parameters has not been defined in webhook input parameter mapping.",params:{webhookIdentifier:n.identifier,actionIdentifier:n.actionIdentifier,parameterName:a},input:t})})})});var t7n=q.record(q.string(),YHe.or(q.boolean()));var n7n=cr(ZHe());var Yie=q.string().check(t=>{let{value:e}=t;try{(0,n7n.default)(e)}catch(r){t.issues.push({code:"custom",input:e,message:r instanceof Error?r.message:"Invalid JSONata expression"})}});var AN=q.string().max(255).regex(/^[a-zA-Z0-9_.]+$/).refine(t=>t!=="__proto__");var eRa=q.object({name:q.string(),description:q.string().optional(),expr:Yie,override:q.enum(["manual"]).or(q.boolean()).optional()}),Bjt=q.record(AN,eRa.or(q.boolean()));var i7n=q.object({name:q.string(),description:q.string().optional(),expr:Yie,override:q.enum(["manual"]).or(q.boolean()).optional()}),tRa=q.record(q.string().regex(/^(?:0|-[1-9]\d*|[1-9]\d*)(?![\s\S])/),q.string().min(1)),rRa=i7n.extend({type:q.literal("state_set"),valueLabels:tRa.optional()}),nRa=i7n.extend({type:q.enum(["count","gauge","distribution"]),valueLabels:q.never().optional()}).check(t=>{Object.prototype.hasOwnProperty.call(t.value,"valueLabels")&&t.issues.push({code:"custom",input:t.value,path:["valueLabels"],message:"Numeric measures cannot define value labels"})}),iRa=q.discriminatedUnion("type",[rRa,nRa]),Hjt=q.record(AN,iRa.or(q.boolean()));var Vjt=q.union([q.string(),q.object({collection:q.string().min(1),expr:Yie.optional()})]);var o7n=t=>{let{value:e}=t,r=Object.keys(e.measures??{}),n=Object.keys(e.dimensions??{}),i=r.filter(o=>n.includes(o));i.length>0&&t.issues.push({code:"custom",input:e,message:`Measure and dimension keys must be unique. Overlapping keys: ${i.join(", ")}`})},s7n=q.object({name:q.string(),description:q.string().optional(),source:Vjt,measures:Hjt,dimensions:Bjt.optional()}).check(o7n),a7n=q.object({name:q.string().optional(),description:q.string().optional(),source:Vjt.optional(),measures:Hjt.optional(),dimensions:Bjt.optional()}).check(o7n),QHe=q.record(AN,s7n.or(q.boolean())),oRa=s7n.extend({identifier:q.string(),key:AN,status:q.enum(fy)}),O2d=oRa.extend({id:q.string(),tenantIdentifier:q.string(),createdAt:q.date(),updatedAt:q.date()});var Gjt=q.object({key:q.string().optional(),name:q.string().min(1),description:q.string(),query:q.looseObject({dataset:q.string().min(1).optional()}),inputs:q.array(q.object({name:q.string(),description:q.string().optional(),type:q.enum(["string","number","boolean","array","simple-array","unknown"]),required:q.boolean().optional(),itemType:q.enum(["string","number","boolean"]).optional(),items:q.array(q.unknown()).optional()}))}),eVe=q.record(q.string(),Gjt.or(q.boolean()));var Q2d=q.object({identifier:q.string().min(1),version:q.string().min(1),name:q.string().min(1),prefix:q.string().min(1),description:q.string(),logo:q.string().nullable().optional(),author:kFn.nullable().optional(),tenantIdentifier:q.string().nullable().optional(),datasets:XHe,semanticTriggers:$Fn,connectors:t7n.optional(),metrics:QHe.optional(),queries:eVe.optional()});var c7n=q.object({...YHe.shape,actions:q.array(q.looseObject({})).optional(),webhooks:q.array(q.looseObject({})).optional()}).partial().strict(),u7n=Ujt.extend({status:q.enum(fy).optional()}).or(q.boolean()),l7n=q.object({datasets:XHe.optional(),semanticTriggers:q.record(q.string(),u7n).optional(),connectors:q.record(q.string(),q.union([c7n,q.boolean()])).optional(),metrics:QHe.optional(),queries:eVe.optional()}),sRa=q.object({...JHe.shape,key:q.string().optional(),status:q.enum(fy).optional()}).partial().strict(),aRa=a7n.or(q.boolean()),cRa=Gjt.strict(),d7n=q.object({datasets:q.record(q.string(),q.union([sRa,q.boolean()])).optional(),semanticTriggers:q.record(q.string(),u7n).optional(),connectors:q.record(q.string(),q.union([c7n,q.boolean()])).optional(),metrics:q.record(AN,aRa).optional(),queries:q.record(q.string(),q.union([cRa,q.boolean()])).optional()}).strict();var uRa=q.object({templateVersion:q.literal("latest").or(q.string().min(1)),name:q.string().min(1),description:q.string().min(1),overrides:l7n}),yOd=uRa.extend({templateId:q.string().min(1),tenantId:q.string().min(1)}),lRa=q.object({templateVersion:q.literal("latest").or(q.string().min(1)),name:q.string().min(1),description:q.string().min(1),overrides:d7n}).strict(),_Od=lRa.extend({tenantId:q.string().min(1),templateIdentifier:q.string().min(1)}).strict();var Mm=[];for(let t=0;t<256;++t)Mm.push((t+256).toString(16).slice(1));function p7n(t,e=0){return(Mm[t[e+0]]+Mm[t[e+1]]+Mm[t[e+2]]+Mm[t[e+3]]+"-"+Mm[t[e+4]]+Mm[t[e+5]]+"-"+Mm[t[e+6]]+Mm[t[e+7]]+"-"+Mm[t[e+8]]+Mm[t[e+9]]+"-"+Mm[t[e+10]]+Mm[t[e+11]]+Mm[t[e+12]]+Mm[t[e+13]]+Mm[t[e+14]]+Mm[t[e+15]]).toLowerCase()}var dRa=new Uint8Array(16);function Wjt(){return crypto.getRandomValues(dRa)}function pRa(t,e,r){return!e&&!t&&crypto.randomUUID?crypto.randomUUID():fRa(t,e,r)}function fRa(t,e,r){t=t||{};let n=t.random??t.rng?.()??Wjt();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){if(r=r||0,r<0||r+16>e.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)e[r+i]=n[i];return e}return p7n(n)}var Kjt=pRa;var OSi=cr(jjn());var NN=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var Yh=globalThis;var GH="10.78.0";function kEe(){return NEe(Yh),Yh}function NEe(t){let e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||GH,e[GH]=e[GH]||{}}function soe(t,e,r=Yh){let n=r.__SENTRY__=r.__SENTRY__||{},i=n[GH]=n[GH]||{};return i[t]||(i[t]=e())}var M2a="Sentry Logger ",Ujn={};function D2a(t){if(!("console"in Yh))return t();let e=Yh.console,r={},n=Object.keys(Ujn);n.forEach(i=>{let o=Ujn[i];r[i]=e[i],e[i]=o});try{return t()}finally{n.forEach(i=>{e[i]=r[i]})}}function $2a(){DUt().enabled=!0}function L2a(){DUt().enabled=!1}function zjn(){return DUt().enabled}function q2a(...t){MUt("log",...t)}function F2a(...t){MUt("warn",...t)}function j2a(...t){MUt("error",...t)}function MUt(t,...e){NN&&zjn()&&D2a(()=>{Yh.console[t](`${M2a}[${t}]:`,...e)})}function DUt(){return NN?soe("loggerSettings",()=>({enabled:!1})):{enabled:!1}}var aoe={enable:$2a,disable:L2a,isEnabled:zjn,log:q2a,warn:F2a,error:j2a};var U2a=Object.prototype.toString;function z2a(t,e){return U2a.call(t)===`[object ${e}]`}function Bjn(t){return z2a(t,"Object")}function Hjn(t){return!!(t?.then&&typeof t.then=="function")}function Vjn(t,e,r){try{Object.defineProperty(t,e,{value:r,writable:!0,configurable:!0})}catch{NN&&aoe.log(`Failed to add non-enumerable property "${String(e)}" to object`,t)}}var coe;function uoe(t){if(coe!==void 0)return coe?coe(t):t();let e=Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),r=Yh;return e in r&&typeof r[e]=="function"?(coe=r[e],coe(t)):(coe=null,t())}function MEe(){return uoe(()=>Math.random())}function Gjn(){return uoe(()=>Date.now())}function Wjn(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}function B2a(){let t=Yh;return t.crypto||t.msCrypto}var $Ut;function H2a(){return MEe()*16}function q$(t=B2a()){try{if(t?.randomUUID)return uoe(()=>t.randomUUID()).replace(/-/g,"")}catch{}return $Ut||($Ut="10000000100040008000"+1e11),$Ut.replace(/[018]/g,e=>(e^(H2a()&15)>>e/4).toString(16))}var Jjn=1e3;function LUt(){return Gjn()/Jjn}function V2a(){let{performance:t}=Yh;if(!t?.now||!t.timeOrigin)return LUt;let e=t.timeOrigin;return()=>(e+uoe(()=>t.now()))/Jjn}var Kjn;function Xjn(){return(Kjn??(Kjn=V2a()))()}function Yjn(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),!t.did&&!e.did&&(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||Xjn(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=e.sid.length===32?e.sid:q$()),e.init!==void 0&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),typeof e.started=="number"&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if(typeof e.duration=="number")t.duration=e.duration;else{let r=t.timestamp-t.started;t.duration=r>=0?r:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),typeof e.errors=="number"&&(t.errors=e.errors),e.status&&(t.status=e.status)}function qUt(t,e,r=2){if(!e||typeof e!="object"||r<=0)return e;if(t&&Object.keys(e).length===0)return t;let n={...t};for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=qUt(n[i],e[i],r-1));return n}function FUt(){return q$()}function Zjn(t){try{let e=Yh.WeakRef;if(typeof e=="function")return new e(t)}catch{}return t}function Qjn(t){if(t){if(typeof t=="object"&&"deref"in t&&typeof t.deref=="function")try{return t.deref()}catch{return}return t}}var jUt="_sentrySpan";function UUt(t,e){e?Vjn(t,jUt,Zjn(e)):delete t[jUt]}function zUt(t){return Qjn(t[jUt])}var G2a=100,kx=class t{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._attributes={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:FUt(),sampleRand:MEe()}}clone(){let e=new t;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._attributes={...this._attributes},e._extra={...this._extra},e._contexts={...this._contexts},this._contexts.flags&&(e._contexts.flags={values:[...this._contexts.flags.values]}),e._user=this._user,e._level=this._level,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e._lastEventId=this._lastEventId,e._conversationId=this._conversationId,UUt(e,zUt(this)),e}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&Yjn(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setConversationId(e){return this._conversationId=e||void 0,this._notifyScopeListeners(),this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,r){return this.setTags({[e]:r})}setAttributes(e){return this._attributes={...this._attributes,...e},this._notifyScopeListeners(),this}setAttribute(e,r){return this.setAttributes({[e]:r})}removeAttribute(e){return e in this._attributes&&(delete this._attributes[e],this._notifyScopeListeners()),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,r){return this._extra={...this._extra,[e]:r},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,r){return r===null?delete this._contexts[e]:this._contexts[e]=r,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;let r=typeof e=="function"?e(this):e,n=r instanceof t?r.getScopeData():Bjn(r)?e:void 0,{tags:i,attributes:o,extra:s,user:a,contexts:c,level:u,fingerprint:d=[],propagationContext:p,conversationId:f}=n||{};return this._tags={...this._tags,...i},this._attributes={...this._attributes,...o},this._extra={...this._extra,...s},this._contexts={...this._contexts,...c},a&&Object.keys(a).length&&(this._user=a),u&&(this._level=u),d.length&&(this._fingerprint=d),p&&(this._propagationContext=p),f&&(this._conversationId=f),this}clear(){return this._breadcrumbs=[],this._tags={},this._attributes={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,this._conversationId=void 0,UUt(this,void 0),this._attachments=[],this.setPropagationContext({traceId:FUt(),sampleRand:MEe()}),this._notifyScopeListeners(),this}addBreadcrumb(e,r){let n=typeof r=="number"?r:G2a;if(n<=0)return this;let i={timestamp:LUt(),...e,message:e.message?Wjn(e.message,2048):e.message};return this._breadcrumbs.push(i),this._breadcrumbs.length>n&&(this._breadcrumbs=this._breadcrumbs.slice(-n)),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,attributes:this._attributes,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:zUt(this),conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=qUt(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,r){let n=r?.event_id||q$();if(!this._client)return NN&&aoe.warn("No client configured on scope - will not capture exception!"),n;let i=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:i,...r,event_id:n},this),n}captureMessage(e,r,n){let i=n?.event_id||q$();if(!this._client)return NN&&aoe.warn("No client configured on scope - will not capture message!"),i;let o=n?.syntheticException??new Error(e);return this._client.captureMessage(e,r,{originalException:e,syntheticException:o,...n,event_id:i},this),i}captureEvent(e,r){let n=e.event_id||r?.event_id||q$();return this._client?(this._client.captureEvent(e,{...r,event_id:n},this),n):(NN&&aoe.warn("No client configured on scope - will not capture event!"),n)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}};function eUn(){return soe("defaultCurrentScope",()=>new kx)}function tUn(){return soe("defaultIsolationScope",()=>new kx)}var rUn=t=>t instanceof Promise&&!t[nUn],nUn=Symbol("chained PromiseLike"),iUn=(t,e,r)=>{let n=t.then(i=>(e(i),i),i=>{throw r(i),i});return rUn(n)&&rUn(t)?n:W2a(t,n)},W2a=(t,e)=>{if(!e)return t;let r=!1;for(let n in t){if(n in e)continue;r=!0;let i=t[n];typeof i=="function"?Object.defineProperty(e,n,{value:(...o)=>i.apply(t,o),enumerable:!0,configurable:!0,writable:!0}):e[n]=i}return r&&Object.assign(e,{[nUn]:!0}),e};var BUt=class{constructor(e,r){let n;e?n=e:n=new kx;let i;r?i=r:i=new kx,this._stack=[{scope:n}],this._isolationScope=i}withScope(e){let r=this._pushScope(),n;try{n=e(r)}catch(i){throw this._popScope(),i}return Hjn(n)?iUn(n,()=>this._popScope(),()=>this._popScope()):(this._popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){let e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return this._stack.length<=1?!1:!!this._stack.pop()}};function loe(){let t=kEe(),e=NEe(t);return e.stack=e.stack||new BUt(eUn(),tUn())}function K2a(t){return loe().withScope(t)}function J2a(t,e){let r=loe();return r.withScope(()=>(r.getStackTop().scope=t,e(t)))}function oUn(t){return loe().withScope(()=>t(loe().getIsolationScope()))}function sUn(){return{withIsolationScope:oUn,withScope:K2a,withSetScope:J2a,withSetIsolationScope:(t,e)=>oUn(e),getCurrentScope:()=>loe().getScope(),getIsolationScope:()=>loe().getIsolationScope()}}function aUn(t){let e=NEe(t);return e.acs?e.acs:sUn()}function HUt(){let t=kEe();return aUn(t).getCurrentScope()}function cUn(t){if(t)return X2a(t)?{captureContext:t}:Z2a(t)?{captureContext:t}:t}function X2a(t){return t instanceof kx||typeof t=="function"}var Y2a=["user","level","extra","contexts","tags","fingerprint","propagationContext"];function Z2a(t){return Object.keys(t).some(e=>Y2a.includes(e))}function WH(t,e){return HUt().captureException(t,cUn(e))}var Hnt=cr(bvi()),PSi=cr(Ia());var ISi=cr(TSi());function ldc(t,e){let r=e?`: ${e}`:"";return`${t}${r}`}function RSi(t){return async e=>({success:!1,statusCode:ISi.StatusCodes.BAD_REQUEST,message:ldc("Bad request",t),meta:{testRun:e.testRun,...e.meta??{}}})}var Uce=class{constructor(e){this.baseConfig=e}baseConfig;processMessage(e){return async r=>{if(await this.isProcessed(r))return gc.getInstance().debug(`Message ${r.eventId} already processed`),RSi(`Message ${r.eventId} already processed`)(r);gc.getInstance().debug(`Processing message ${r.eventId}`);let n=await e(r);return n.success?await this.addProcessedMessage(r):gc.getInstance().debug(`Message ${r.eventId} FAILED to process: ${n.message}. Not storing in processed messages list.`),n}}};var znt=class extends Uce{constructor(r,n){super(n);this.config=r}config;processedMessages=[];async isProcessed(r){return this.processedMessages.includes(r.eventId)}async addProcessedMessage(r){this.processedMessages.push(r.eventId),this.processedMessages.length>this.config.messagesToKeep&&this.processedMessages.shift()}};var CSi=cr(i$t());var Bnt=class extends Uce{constructor(r,n){super(n);this.config=r;(0,CSi.createClient)({url:this.config.url}).on("error",i=>gc.error("[REDIS MESSAGE MONITOR] Redis Client Error",i)).connect().then(i=>{this.redisClient=i,this.initialized=!0}).catch(i=>{gc.error("[REDIS MESSAGE MONITOR] Redis Client Error",i)})}config;redisClient=void 0;initialized=!1;DEFAULT_TTL=7200;async isProcessed(r){return this.redisClient===void 0||!this.initialized?(gc.getInstance().error("[REDIS MESSAGE MONITOR] Not initialized. continue to handle message"),!1):await this.redisClient.exists(this.getMessageProcessIdentifier(r))===1}async addProcessedMessage(r){if(this.redisClient===void 0||!this.initialized){gc.getInstance().error("[REDIS MESSAGE MONITOR] Not initialized. Cannot store message details");return}await this.redisClient.set(this.getMessageProcessIdentifier(r),"1",{EX:this.config.ttl??this.DEFAULT_TTL})}getMessageProcessIdentifier(r){return`${this.baseConfig.processIdentifier}.${r.eventId}`}};var ddc=t=>()=>Promise.resolve({accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey}),pdc=t=>async()=>{let e=process.env.AWS_ROLE_SESSION_NAME??"";if(t?.accessKeyId&&t?.secretAccessKey){gc.getInstance().verbose(`Generating OAuth Bearer token using ENV variables and principal: ${e}`);let n=await(0,Hnt.generateAuthTokenFromCredentialsProvider)({region:t.region??"eu-west-1",awsCredentialsProvider:ddc({accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey})});return gc.getInstance().debug(`Token using Default Credentials Provider ${n.expiryTime} - ${n.expiryTime-Date.now()}ms`),{principal:e,value:n.token,lifetime:n.expiryTime}}gc.getInstance().verbose(`Generating OAuth Bearer token using Default Credentials Provider and principal: ${e}`);let r=await(0,Hnt.generateAuthToken)({region:t?.region??"eu-west-1",awsRoleSessionName:e,logger:gc.getInstance(),awsDebugCreds:!0});return gc.getInstance().debug(`Token using Default Credentials Provider ${r.expiryTime} - ${r.expiryTime-Date.now()}ms`),{principal:e,value:r.token,lifetime:r.expiryTime}},wRe=class t{constructor(e,r){this.baseYamlConfig=e;this.connectorTopic=r;let n={info:(c,u)=>{this.logger.info(c,u)},error:(c,u)=>{this.logger.error(c,u)},warn:(c,u)=>{this.logger.warn(c,u)},debug:()=>{},namespace:()=>n,setLogLevel:()=>{}};this.logger=gc.getInstance(),this.logger.info("RUNNING RDKAFKA SERVICE");let{kafka:i}=e,o={brokers:i.brokers,ssl:!1,clientId:`${i.clientId}-${Kjt()}`,logLevel:2,logger:n};if(i.sasl){let{sasl:c}=i;o.sasl={mechanism:"oauthbearer",oauthBearerProvider:pdc(c)},o.ssl=!0}this.messageMonitor=this.getCorrespondingMonitor(),this.disableLogs=e.kafka.disableLogs??!1,this.kafkaBase=new OSi.KafkaJS.Kafka({kafkaJS:o,"message.max.bytes":i.messageMaxBytes??t.DEFAULT_MESSAGE_MAX_BYTES});let{kafka:s}=e,a={kafkaJS:{groupId:e.kafka.groupId,autoCommitInterval:e.kafka.autoCommitInterval??5e3,fromBeginning:!0,...s.maxBytesPerPartition!==void 0&&{maxBytesPerPartition:s.maxBytesPerPartition}}};if(s.fetchMaxBytes!==void 0&&(a["fetch.max.bytes"]=s.fetchMaxBytes),s.queuedMaxMessagesKbytes!==void 0&&(a["queued.max.messages.kbytes"]=s.queuedMaxMessagesKbytes),s.queuedMinMessages!==void 0&&(a["queued.min.messages"]=s.queuedMinMessages),s.maxPollIntervalMs!==void 0&&(a["max.poll.interval.ms"]=s.maxPollIntervalMs),s.maxBatchSize!==void 0&&(a["js.consumer.max.batch.size"]=s.maxBatchSize),e.kafka.newConsumerProtocol&&(this.logger.info("RDKAFKA Using new consumer protocol"),a["group.protocol"]="consumer",a["group.protocol.type"]="consumer",a["group.remote.assignor"]="uniform"),this.#e=a,this.consumer=this.kafkaBase.consumer(a),this.producer=this.kafkaBase.producer({"compression.codec":i.compression??t.DEFAULT_COMPRESSION_CODEC}),!r&&(this.baseYamlConfig.kafka.consumerTopics===void 0||this.baseYamlConfig.kafka.consumerTopics.length===0)){this.logger.warn("No consumer topics set. skip setting of consumer events callback");return}if(typeof process>"u"){this.logger.warn("No process found. Graceful shutdown not possible");return}this.logger.debug("Setting up graceful shutdown for kafka..."),this.errorTypes.forEach(c=>{process.on(c,async(u,d)=>{try{this.logger.error(`RDKAFKA process.on ${c}`),this.logger.error(typeof u,u,{error:u},JSON.stringify(u)),this.logger.error(typeof d,d,{promise:d},JSON.stringify(d)),this.logger.error("RDKAFKA process.on current stack:",new Error().stack),await this.exitProcess(c)}catch{process.exit(1)}})}),this.signalTraps.forEach(c=>{process.on(c,async()=>{this.logger.error(`process.once ${c}`);try{await this.exitProcess(c)}finally{process.exit(0)}})})}baseYamlConfig;connectorTopic;errorTypes=["unhandledRejection","uncaughtException"];signalTraps=["SIGTERM","SIGINT","SIGUSR2"];static DEFAULT_CALLBACK_EVENT_TYPE="*";static DEFAULT_MESSAGE_MAX_BYTES=2*1024*1024;static DEFAULT_COMPRESSION_CODEC="gzip";kafkaBase;consumer;#e;#t=!1;#r=!1;producer;processedTopic="_LOGS_xod";DEFAULT_INTERVAL_CHECK_FOR_NEW_TOPICS=300;numberOfSubscribedRegexTopics=0;disableLogs;messageMonitor=void 0;logger;exitProcess=async e=>{this.logger.warn(`Got ${e}. Graceful shutdown Kafka start ${new Date().toISOString()}`),this.logger.debug("Disconnecting consumer and producer");try{await this.consumer?.disconnect(),this.logger.debug("Consumer disconnected")}catch(r){this.logger.error(`Error while disconnecting consumer: ${r}`)}try{await this.producer?.disconnect(),this.logger.debug("Producer disconnected")}catch(r){this.logger.error(`Error while disconnecting producer: ${r}`)}this.logger.info(`Graceful shutdown Kafka complete ${new Date().toISOString()}`),process.exit(0)};getCorrespondingMonitor(){if(this.baseYamlConfig.kafka.messageMonitor?.type==="in-memory")return this.logger.debug("Using in-memory message monitor"),new znt(this.baseYamlConfig.kafka.messageMonitor,this.baseYamlConfig);if(this.baseYamlConfig.kafka.messageMonitor?.type==="redis")return this.logger.debug("Using Redis message monitor"),new Bnt(this.baseYamlConfig.kafka.messageMonitor,this.baseYamlConfig);if(this.baseYamlConfig.kafka.messageMonitor?.type==="disabled"){this.logger.debug("Message monitor disabled");return}this.logger.debug("No setting, Message monitor disabled")}connectConsumer=async()=>{this.#t||(await this.consumer.connect(),this.#t=!0)};getRegularTopics=()=>(this.baseYamlConfig.kafka.consumerTopics??[]).filter(e=>!s$t(e));getRegexTopics=async()=>{let e=await this.#n();return this.numberOfSubscribedRegexTopics=e.length,this.#i(),e};#i(){let e=this.baseYamlConfig.kafka.intervalCheckForNewTopics??this.DEFAULT_INTERVAL_CHECK_FOR_NEW_TOPICS;this.#r||e<=0||(this.#r=!0,(0,PSi.interval)(e*1e3).subscribe(()=>{this.#l().catch(r=>{this.logger.error(r)})}))}#n=async()=>{let e=(this.baseYamlConfig.kafka.consumerTopics??[]).filter(o=>s$t(o));if(e.length===0)return[];let r=e.map(o=>new RegExp(o.pattern,o.flags)),n=this.kafkaBase.admin();await n.connect();let i=await n.listTopics();return await n.disconnect(),i.filter(o=>r.some(s=>s.test(o)))};#l=async()=>{if((await this.#n()).length!==this.numberOfSubscribedRegexTopics)try{this.logger.info("New topics found, restarting consumer"),await this.consumer.disconnect(),this.consumer=this.kafkaBase.consumer(this.#e),this.#t=!1,await this.init()}catch(r){this.logger.error(`Restarting consumer failed: ${r.message}`),WH(r),process.exit(1)}}};var c0t=cr(Vn()),_Or=cr(Nut());var a0t=class extends _Or.BaseExceptionFilter{catch(e,r){if(e instanceof c0t.HttpException){let i=e.getStatus();i>=500&&WH(e,{tags:{status_code:i}})}else WH(e);super.catch(e,r)}};a0t=ztn([(0,c0t.Catch)()],a0t);function Yvo(t){let e=Object.keys(t),r=e.map(o=>o.split(".")[0]),n=Array.from(new Set(r)),i={};return n.forEach(o=>{let s=e.filter(a=>a.split(".").length>1).filter(a=>a.split(".")[0]===o);s.length!==0&&(i[o]={},s.forEach(a=>{let c=a.split(".");c.length!==1&&(i[o][c[1]]=t[a])}))}),i}function Zvo(t,e){let r=/{{\s*(message|inputs)\.(\w+)\s*}}/,n=i=>{if(typeof i=="string"){let o=i.match(r);if(o){let s=o[2];return e[s]!==void 0?e[s]:i}return i}return Array.isArray(i)?i.map(n):typeof i=="object"&&i!==null?Object.fromEntries(Object.entries(i).map(([o,s])=>[o,n(s)])):i};return n(t)}var ULu=cr(ZHe());var zLu=cr(ZHe());var BLu=3,HLu=1e3,vOr=16,VLu=6e4,GLu=new Set(["ECONNABORTED","ECONNREFUSED","ECONNRESET","ENETUNREACH","ENOTFOUND","EPIPE","ETIMEDOUT"]),WLu=/network error|timeout|timed out|connection (?:reset|refused)|dns|socket hang up/i,ebo=q.object({cacheStrategy:q.string().optional(),maxRetries:q.number().int().nonnegative().max(vOr).optional().default(BLu),retryDelayMs:q.number().int().nonnegative().max(VLu).optional().default(HLu)});function KLu(t){if(typeof t!="object"||t===null||!("code"in t))return;let{code:e}=t;return typeof e=="string"?e:void 0}function Qvo(t){let{status:e}=t;return typeof e=="number"?e:void 0}function bOr(t){if(t instanceof Error&&t.name==="AbortError")return!1;if(t instanceof Error&&typeof Qvo(t)=="number"){let e=Qvo(t);return e===408||e===429||e>=500&&e<=599}return GLu.has(KLu(t)??"")||t instanceof Error&&WLu.test(t.message)}function tbo(t){return new Promise(e=>{setTimeout(e,t)})}var JLu=q.array(q.looseObject({values:q.array(q.unknown()).optional()}));function XLu(t){let e=JLu.safeParse(t.filters);return e.success&&e.data.some(r=>r.values?.length===0)}function YLu(t,e,r){let n="Error in query";return bOr(t)&&e===r&&(n+=` after attempt ${e}/${r}`),t instanceof Error&&(n+=`: (${t.name}) ${t.message}`),n}function SOr(t,e,r){return(t??[]).map(n=>({name:n.name,title:n.title,type:n.type??r??"string",kind:e}))}var Hpe=class{#e;#t;constructor(e,r){this.#e=e,this.#t=r}static prepare(e,r){let n=Zvo(e,r);return{query:n,hasEmptyFilterValues:XLu(n)}}async#r(e,r,n){let i=Math.min(n.maxRetries,vOr),o=i+1;for(let s=1;s<=o;s+=1)try{return await this.#e.load(e,{cache:r})}catch(a){if(s<o&&bOr(a)){let u=n.retryDelayMs*2**(s-1);this.#t.warn(`Cube query failed; retrying attempt ${s}/${i} in ${u}ms: ${a instanceof Error?a.message:String(a)}`),await tbo(u);continue}let c=YLu(a,s,o);throw this.#t.error(c),this.#t.verbose(JSON.stringify(e)),new u5(c,e)}throw new u5(`Retried ${i}/${o} attempts`,e)}async execute(e,r){let n=r.cacheStrategy||(e.renewQuery?"no-cache":"must-revalidate"),{renewQuery:i,...o}=e,a=(await this.#r(o,n,r)).serialize().loadResponse.results;if(this.#t.debug(`Cube query executed successfully with ${a.length} results`),this.#t.verbose(a),a.length===0)throw new u5("No results found for given query",e);return{data:a[0].data.map(Yvo),lastRefreshTime:a[0].lastRefreshTime}}async meta(){let{cubes:e}=(await this.#e.meta()).meta;return e.map(r=>({name:r.name,title:r.title,members:[...SOr(r.measures,"measure"),...SOr(r.dimensions,"dimension"),...SOr(r.segments,"segment","boolean")]}))}};xk();pc();Bb();Wfe();IJ();Cc();function mHu({apiKey:t,configuration:e={}}){let r=Ak({baseURL:e.baseURL,providerPath:"v1"});return{apiKey:t??e.apiKey??r.apiKey??(di("LANGSMITH_GATEWAY_API_KEY")||di("LANGSMITH_API_KEY")),configuration:{...e,baseURL:r.baseURL??`${Wbt}/v1`},useResponsesApi:!0}}var Jbt={openai:{package:"@langchain/openai",className:"ChatOpenAI"},anthropic:{package:"@langchain/anthropic",className:"ChatAnthropic"},azure_openai:{package:"@langchain/openai",className:"AzureChatOpenAI"},langsmith:{package:"@langchain/openai",className:"ChatOpenAI"},cohere:{package:"@langchain/cohere",className:"ChatCohere"},google:{package:"@langchain/google",className:"ChatGoogle"},"google-vertexai":{package:"@langchain/google-vertexai",className:"ChatVertexAI"},"google-vertexai-web":{package:"@langchain/google-vertexai-web",className:"ChatVertexAI"},"google-genai":{package:"@langchain/google-genai",className:"ChatGoogleGenerativeAI"},ollama:{package:"@langchain/ollama",className:"ChatOllama"},mistralai:{package:"@langchain/mistralai",className:"ChatMistralAI"},mistral:{package:"@langchain/mistralai",className:"ChatMistralAI"},groq:{package:"@langchain/groq",className:"ChatGroq"},bedrock:{package:"@langchain/aws",className:"ChatBedrockConverse"},aws:{package:"@langchain/aws",className:"ChatBedrockConverse"},deepseek:{package:"@langchain/deepseek",className:"ChatDeepSeek"},xai:{package:"@langchain/xai",className:"ChatXAI"},cerebras:{package:"@langchain/cerebras",className:"ChatCerebras"},fireworks:{package:"@langchain/fireworks",className:"ChatFireworks"},together:{package:"@langchain/together-ai",className:"ChatTogetherAI",hasCircularDependency:!0},perplexity:{package:"@langchain/perplexity",className:"ChatPerplexity"}},KIo=Object.keys(Jbt);async function hHu(t,e){let r;if(e)r=Jbt[e];else{let n=Object.entries(Jbt).find(([,i])=>i.className===t);r=n?n[1]:void 0}if(r)try{return(await import(r.package))[r.className]}catch(n){let i=n;if("code"in i&&i.code?.toString().includes("ERR_MODULE_NOT_FOUND")&&"message"in i&&typeof i.message=="string"){let o=(i.message.startsWith("Error: ")?i.message.slice(7):i.message).split("Cannot find package '")[1].split("'")[0];throw new Error(`Unable to import ${o}. Please install with \`npm install ${o}\` or \`pnpm install ${o}\``)}throw n}}async function gHu(t,e,r={}){let n=e||yHu(t);if(!n)throw new Error(`Unable to infer model provider for { model: ${t} }, please specify modelProvider directly.`);let i=Jbt[n];if(!i){let a=KIo.join(", ");throw new Error(`Unsupported { modelProvider: ${n} }.
1182
+ `+s+m)}}catch{}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=yx(this.defaults,r);let{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&fSe.assertOptions(n,{silentJSONParsing:lf.transitional(lf.boolean),forcedJSONParsing:lf.transitional(lf.boolean),clarifyTimeoutError:lf.transitional(lf.boolean),legacyInterceptorReqResOrdering:lf.transitional(lf.boolean),advertiseZstdAcceptEncoding:lf.transitional(lf.boolean),validateStatusUndefinedResolves:lf.transitional(lf.boolean),encodeBasicAuthUsername:lf.transitional(lf.boolean)},!1),i!=null&&(Ce.isFunction(i)?r.paramsSerializer={serialize:i}:fSe.assertOptions(i,{encode:lf.function,serialize:lf.function},!0)),r.allowAbsoluteUrls!==void 0||(Ce.hasOwnProp(this.defaults,"allowAbsoluteUrls")&&this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),fSe.assertOptions(r,{baseUrl:lf.spelling("baseURL"),withXsrfToken:lf.spelling("withXSRFToken")},!0),r.method=(Ce.getSafeProp(r,"method")||Ce.getSafeProp(this.defaults,"method")||"get").toLowerCase();let s=Ce.getSafeProp(o,"common"),a=Ce.getSafeProp(o,r.method),c=o&&Ce.merge(wDt(s)?s:void 0,wDt(a)?a:void 0);o&&Ce.forEach(MFe.concat("common"),v=>{wDt(Ce.getSafeProp(o,v))&&delete o[v]}),r.headers=ba.concat(c,o);let u=[],d=!0;this.interceptors.request.forEach(function(b){if(typeof b.runWhen=="function"&&b.runWhen(r)===!1)return;d=d&&b.synchronous;let w=r.transitional||f5;w&&w.legacyInterceptorReqResOrdering?u.unshift(b.fulfilled,b.rejected):u.push(b.fulfilled,b.rejected)});let p=[];this.interceptors.response.forEach(function(b){p.push(b.fulfilled,b.rejected)});let f,m=0,h;if(!d){let v=[pSe.bind(this),void 0];for(v.unshift(...u),v.push(...p),h=v.length,f=Promise.resolve(r);m<h;)f=f.then(v[m++],v[m++]);return f}h=u.length;let g=r;for(;m<h;){let v=u[m++],b=u[m++];try{g=v?v(g):g}catch(w){if(!b){f=Promise.reject(w);break}try{let E=b.call(this,w);Ce.isThenable(E)&&(f=Promise.resolve(E).then(()=>pSe.call(this,g)))}catch(E){f=Promise.reject(E)}break}}if(!f)try{f=pSe.call(this,g)}catch(v){f=Promise.reject(v)}for(m=0,h=p.length;m<h;)f=f.then(p[m++],p[m++]);return f}getUri(e){e=yx(this.defaults,e);let r=NB(e.baseURL,e.url,e.allowAbsoluteUrls,e);return kB(r,e.params,e.paramsSerializer)}};Ce.forEach(["delete","get","head","options"],function(e){yee.prototype[e]=async function(r,n){return this.request(yx(n||{},{method:e,url:r,data:n&&Ce.hasOwnProp(n,"data")?n.data:void 0}))}});Ce.forEach(["post","put","patch","query"],function(e){function r(n){return async function(o,s,a){return this.request(yx(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}yee.prototype[e]=r(),e!=="query"&&(yee.prototype[e+"Form"]=r(!0))});var mSe=yee;var EDt=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});let n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o,s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},e(function(o,s,a){n.reason||(n.reason=new Ev(o,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new t(function(i){e=i}),cancel:e}}},Zyn=EDt;function xDt(t){return function(r){return t.apply(null,r)}}function ADt(t){return Ce.isObject(t)&&t.isAxiosError===!0}var YFe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,ContentTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,UnprocessableContent:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerReturnsAnUnknownError:520,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(YFe).forEach(([t,e])=>{YFe[e]===void 0&&(YFe[e]=t)});var Qyn=YFe;function e_n(t){let e=new mSe(t),r=IB(mSe.prototype.request,e);return Ce.extend(r,mSe.prototype,e,{allOwnKeys:!0}),Ce.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return e_n(yx(t,i))},r}var xd=e_n(lee);xd.Axios=mSe;xd.CanceledError=Ev;xd.CancelToken=Zyn;xd.isCancel=Y1e;xd.VERSION=aN;xd.toFormData=p5;xd.AxiosError=Bt;xd.Cancel=xd.CanceledError;xd.all=function(e){return Promise.all(e)};xd.spread=xDt;xd.isAxiosError=ADt;xd.mergeConfig=yx;xd.AxiosHeaders=ba;xd.formToJSON=t=>NFe(Ce.isHTMLForm(t)?new FormData(t):t);xd.getAdapter=JFe.getAdapter;xd.HttpStatusCode=Qyn;xd.default=xd;var uN=xd;var{Axios:rpd,AxiosError:npd,CanceledError:ipd,isCancel:opd,CancelToken:spd,VERSION:apd,all:cpd,Cancel:upd,isAxiosError:lpd,spread:dpd,toFormData:ppd,AxiosHeaders:fpd,HttpStatusCode:mpd,formToJSON:hpd,getAdapter:gpd,mergeConfig:ypd,create:_pd}=uN;var Sta=(0,t_n.promisify)(r_n.gzip),ZFe=class{#e;#t;constructor(e,r){this.#e=e,this.#t=r}async get(e,r={},n={}){let i=r.baseUrl||this.#t.baseUrl;return this.#r(r,o=>uN.get(`${i}${e}`,{headers:{Authorization:`Bearer ${o}`},params:n,timeout:this.#t.timeout}))}async post(e,r,n={}){let i=n.baseUrl||this.#t.baseUrl,o=await this.#n(r,n);return this.#r(n,s=>uN.post(`${i}${e}`,o.body,{headers:{Authorization:`Bearer ${s}`,...o.headers},timeout:this.#t.timeout}))}async put(e,r,n={}){let i=n.baseUrl||this.#t.baseUrl;return this.#r(n,o=>uN.put(`${i}${e}`,r,{headers:{Authorization:`Bearer ${o}`},timeout:this.#t.timeout}))}async#r(e,r){let n={...this.#t,...e};try{let{data:i}=await r(await this.#e.getToken(n));return i}catch(i){if(!this.#i(i))throw i;await this.#e.invalidateToken(n);let{data:o}=await r(await this.#e.getToken(n));return o}}#i(e){return e?.response?.status===401}async#n(e,r){if(!r.compress)return{body:e,headers:{}};let n=typeof e=="string"?e:JSON.stringify(e);return{body:await Sta(n),headers:{"Content-Type":"application/json","Content-Encoding":"gzip"}}}};var jSe=require("fs");var Sx=cr(require("node:process")),Ql=cr(T1n()),I1n=(o=>(o.error="error",o.warn="warn",o.info="info",o.debug="debug",o.verbose="verbose",o))(I1n||{}),n9t={levels:{error:0,warn:1,info:2,debug:3,verbose:4},colors:{error:"red",warn:"yellow",info:"green",debug:"magenta",verbose:"blue"}},gc=class t{static instance;logger;#e;constructor(e="default",r="info"){this.logger=Ql.default.createLogger({levels:n9t.levels,level:r,format:Ql.default.format.combine(Ql.default.format.label({label:e}),Ql.default.format.timestamp(),Ql.default.format.errors({stack:!0}),Ql.default.format.json())});let n=!1;(Sx.default.env.NODE_ENV!=="production"||Sx.default.env.LOG_TO_CONSOLE==="true")&&(n=!0,this.logger.add(new Ql.default.transports.Console({format:Ql.default.format.combine(Ql.default.format.colorize({colors:n9t.colors}),Ql.default.format.label({label:e}),Ql.default.format.printf(({label:i,level:o,message:s})=>{let a=new Date().toLocaleString();return`[${i}] ${Sx.default.pid} - ${a} ${o}: ${s}`}))}))),Sx.default.env.LOG_TO_FILE==="true"&&(n=!0,this.logger.add(new Ql.default.transports.File({filename:"error.log",level:"error"})),this.logger.add(new Ql.default.transports.File({filename:"combined.log"}))),n||this.logger.add(new Ql.default.transports.Console({format:Ql.default.format.combine(Ql.default.format.colorize({colors:n9t.colors}),Ql.default.format.label({label:e}),Ql.default.format.printf(({label:i,level:o,message:s})=>`[${i}] ${o}: ${s}`))}))}static getInstance(e,r){return t.instance||(t.instance=new t(e??"default",t.#r(r))),t.instance}setDatadogTransport(e){let r=e?.apiKey??Sx.default.env.DATADOG_API_KEY;if(!r)return this.debug("DATADOG_API_KEY is not set, cannot add Datadog transport"),this;let n=new URLSearchParams({"dd-api-key":r,ddsource:e?.source??Sx.default.env.DD_SOURCE??"nodejs",service:e?.service??Sx.default.env.DD_SERVICE??"unknown",env:e?.env??Sx.default.env.DD_ENV??"prod"});e?.tags&&n.append("ddtags",Object.entries(e.tags).map(([o,s])=>`${o}:${s}`).join(","));let i={host:`http-intake.logs.${Sx.default.env.DD_SITE??"datadoghq.eu"}`,path:`/api/v2/logs?${n.toString()}`,ssl:!0,batch:!0,format:Ql.default.format.json(),level:"info"};return this.#e&&this.logger.remove(this.#e),this.#e=new Ql.default.transports.Http(i),this.logger.add(this.#e),this}info(...e){this.#t(this.logger.info,...e)}static info(...e){this.getInstance().info(...e)}debug(...e){this.#t(this.logger.debug,...e)}static debug(...e){this.getInstance().debug(...e)}error(...e){this.#t(this.logger.error,...e)}static error(...e){this.getInstance().error(...e)}warn(...e){this.#t(this.logger.warn,...e)}static warn(...e){this.getInstance().warn(...e)}verbose(...e){this.#t(this.logger.verbose,...e)}static verbose(...e){this.getInstance().verbose(...e)}#t(e,...r){try{let n=r.map(i=>typeof i=="object"?JSON.stringify(i):String(i));e(n.join(" "),...r)}catch(n){console.error("unknown error in log, function",n)}}static#r=e=>{if(e!==void 0)return e;let r=Sx.default.env.LOG_LEVEL||"info",n=Object.values(I1n),i=!n.includes(r);return i&&(r="info"),i&&console.error(`Invalid log level: ${r} only allow; ${n.join(", ")}. Using ${r} as default.`),r}};var tje=class{#e;#t;#r=!1;constructor(e){this.#e=e,this.#t=gc.getInstance()}async get(e){await this.#i();let r=await jSe.promises.readFile(`${this.#e.path}/${this.#n(e)}`,"utf8").catch(n=>{this.#t.error(n)});return r?JSON.parse(r):void 0}async set(e,r){await this.#i(),await jSe.promises.writeFile(`${this.#e.path}/${this.#n(e)}`,JSON.stringify(r)).catch(n=>{this.#t.error(n)})}async clear(){return Promise.resolve()}async#i(){if(this.#t.verbose("try to init FileSystemCacheService"),this.#r)return;let e=!0;await jSe.promises.stat(this.#e.path).catch(r=>{if(r.code==="ENOENT")e=!1,this.#t.debug("Directory does not exist");else throw this.#t.debug("Error occured"),r}),e||(this.#t.debug(`OffsetStore create ${this.#e.path}`),await jSe.promises.mkdir(this.#e.path,{recursive:!0})),this.#t.debug("Init run successfully. directory exists"),this.#r=!0}#n(e){return`${this.#e.keyPrefix?`${this.#e.keyPrefix}_`:""}${e}.json`}};var rje=class{#e=new Map;get(e){return Promise.resolve(this.#e.get(e))}set(e,r){return this.#e.set(e,r),Promise.resolve()}clear(){return this.#e.clear(),Promise.resolve()}};var w9n=cr(i$t()),Hze=class{#e;#t;constructor(e,r={}){typeof e=="string"&&(e=(0,w9n.createClient)({url:e}),e.connect()),this.#e=e,this.#t=r}async get(e){let r=await this.#e.get(this.getKey(e));return r?JSON.parse(r):void 0}async set(e,r){await this.#e.set(this.getKey(e),JSON.stringify(r))}async clear(){await this.#e.flushDb()}getKey(e){let r=`${this.#t.cacheKeyPrefix}_`;return`${this.#t.cacheKeyPrefix?r:""}${e}`}};var rEa=1e4,nEa=6e4,hwe=class{#e;#t;#r;#i;constructor(e,r){this.#e=e,this.#t=r,this.#r=gc.getInstance()}async getToken(e){let r=await this.#n(),{audience:n,tenantIdentifier:i,cacheKey:o}=this.#l(e),s=r[o];if(s&&s.expiresAt-nEa>Date.now())return this.#r.debug(`Using cached token for audience ${n} and tenantIdentifier ${i}`),s.token.access_token;this.#r.debug(`Fetching new token for audience ${n} and tenantIdentifier ${i} from ${this.#e.tokenUrl}`);let a={method:"POST",url:this.#e.tokenUrl,timeout:rEa,headers:{"content-type":"application/json"},data:JSON.stringify({client_id:this.#e.clientId,client_secret:this.#e.clientSecret,audience:n,grant_type:"client_credentials",...i?{tenantId:i}:{}})},c=Date.now(),{data:u}=await uN.request(a).catch(d=>{throw this.#r.error(`Error fetching token url ${this.#e.tokenUrl} for audience ${n} and tenantIdentifier ${i}: ${(uN.isAxiosError(d)?JSON.stringify(d.response?.data):void 0)??d.message}`),new Error("Error fetching token")});return r[o]={tenantIdentifier:i,audience:n,token:u,expiresAt:this.#a(u,c)},await this.#t.set("cachedTokens",r),u.access_token}async invalidateToken(e){let r=await this.#n(),{cacheKey:n}=this.#l(e);r[n]&&(delete r[n],await this.#t.set("cachedTokens",r))}async#n(){return this.#i===void 0&&(this.#i=await this.#t.get("cachedTokens")),(this.#i===void 0||this.#i===null||typeof this.#i!="object")&&(this.#i={}),this.#i}#l(e){let r=e.audience||this.#e.audience,n=e.tenantIdentifier||this.#e.tenantIdentifier;return{audience:r,tenantIdentifier:n,cacheKey:this.getCacheArrayKey({tenantIdentifier:n,audience:r})}}#a(e,r){let n=r+e.expires_in*1e3,i=this.#d(e.access_token);return i===void 0?n:Math.min(i*1e3,n)}#d(e){try{let r=JSON.parse(Buffer.from(e.split(".")[1]??"","base64url").toString());return typeof r.exp=="number"?r.exp:void 0}catch{return}}getCacheArrayKey(e){return`${e.tenantIdentifier??"__NONE__"}_${e.audience??"__NONE__"}`}};var gwe=class t{static build(e){let r=t.buildCacheService(e.cache??{}),n=t.buildJwtTokenService(e.jwt,r);return new ZFe(n,{baseUrl:e.baseUrl,tenantIdentifier:e.jwt.tenantIdentifier,timeout:e.timeout})}static buildFromEnv(e){return t.build({baseUrl:e.baseUrl,jwt:{tokenUrl:process.env.AUTH0_TOKEN_URL,clientId:process.env.AUTH0_CLIENT_ID,clientSecret:process.env.AUTH0_CLIENT_SECRET,audience:e.audience,tenantIdentifier:e.tenantIdentifier},cache:{type:process.env.REDIS_URL?"redis":"memory",redisUrl:process.env.REDIS_URL,keyPrefix:process.env.CACHE_KEY_PREFIX},timeout:e.timeout})}static buildCachedJwtTokenService(e,r){let n=t.buildCacheService(r??{type:process.env.REDIS_URL?"redis":"memory",redisUrl:process.env.REDIS_URL,keyPrefix:process.env.CACHE_KEY_PREFIX});return new hwe(e,n)}static buildJwtTokenService(e,r){return new hwe(e,r)}static buildCacheService(e={}){switch(e.type){case"redis":return new Hze(String(e.redisUrl),{cacheKeyPrefix:e.keyPrefix});case"filesystem":return new tje({path:e.path??"./cache",keyPrefix:e.keyPrefix});default:return new rje}}};function E9n(t,e,r,n){if(!e||!e.auth0_token_url||!e.auth0_client_id||!e.auth0_client_secret||!e.auth0_audience)throw new Error("Cube config is not valid");let i=gwe.buildCacheService({}),o=gwe.buildJwtTokenService({tokenUrl:e.auth0_token_url,clientId:e.auth0_client_id,clientSecret:e.auth0_client_secret,audience:e.auth0_audience,tenantIdentifier:r},i);return t(async()=>(n.debug(`Getting Auth0 Cube JWT Token for tenant ${r}`),o.getToken({tenantIdentifier:r})),{apiUrl:e.apiUrl})}var o$t=(oe=>(oe.API="api",oe.API_SINK="api-sink",oe.API_SOURCE="api-source",oe.DUMMY_NODE="dummy-node",oe.FILE_COPY="file-copy",oe.FILE="file",oe.FILE_SINK="file-sink",oe.FILE_SOURCE="file-source",oe.SAMBA_SINK="samba-sink",oe.SAMBA_SOURCE="samba-source",oe.SQL_SINK="sql-sink",oe.SQL_SOURCE="sql-source",oe.MQTT="mqtt",oe.CUBE_QUERY_RUNNER="cube-query-runner",oe.FACTORY_NEBULA="factory-nebula",oe.FACTORY_NEBULA_SOURCE="factory-nebula-source",oe.BYSTRONIC="bystronic",oe.IMAP_SOURCE="imap-source",oe.IMAP_SINK="imap-sink",oe.OPCUA_SOURCE="opcua-source",oe.OPCUA_SINK="opcua-sink",oe.AI_AGENT="ai-agent",oe.MICROSOFT_OFFICE365_EMAIL="microsoft-office365-email",oe.MKG="mkg",oe.EZ_MES="ez-mes",oe.OTTO_FLEET_MANAGER_V2="otto-fleet-manager-v2",oe.FRAUNHOFER_BATTERY_ASSEMBLY_CELLS="fraunhofer-battery-assembly-cells",oe.PDF_GENERATE="pdf-generate",oe.ONSHAPE="onshape",oe.OROOX="oroox",oe.GPMS="gpms",oe.KEIZERSMETAAL_TRUMPF_API="keizersmetaal-trumpf-api",oe.HP_INDIGO="hp-indigo",oe.QLINK="qlink",oe.IPP="ipp",oe.CERM="cerm",oe.JVC_TELEMETRY_TEST="jvc-telemetry-test",oe.RIDDER_IQ="ridder-iq",oe.XYLEM="xylem",oe.OSEON="oseon",oe))(o$t||{});function s$t(t){return typeof t=="string"?!1:t!=null&&t.pattern!==void 0&&typeof t.pattern=="string"&&t.flags!==void 0&&typeof t.flags=="string"}wEe();wEe();var Pjt=(n=>(n.documents="documents",n.metrics="metrics",n.events="events",n))(Pjt||{}),fy=(i=>(i.disabled="disabled",i.enabled="enabled",i.overridden="overridden",i.manual="manual",i))(fy||{}),kjt=(a=>(a.equals="=",a.notEquals="<>",a.greaterThan=">",a.greaterThanOrEqual=">=",a.lessThan="<",a.lessThanOrEqual="<=",a.in="IN",a))(kjt||{}),GHe=q.union([q.string().min(1),q.number(),q.boolean(),q.array(q.union([q.string().min(1),q.number(),q.boolean()])).min(1)]),Njt=(r=>(r.and="AND",r.or="OR",r))(Njt||{}),PFn=q.union([q.string().min(1),q.array(q.string().min(1)).min(1)]),Mjt=(i=>(i.string="string",i.number="number",i.boolean="boolean",i.time="time",i))(Mjt||{}),Djt=(o=>(o.id="image_url",o.imageUrl="image_url",o.link="link",o.percent="percent",o.currency="currency",o))(Djt||{}),$jt=(i=>(i.oneToOne="one_to_one",i.oneToMany="one_to_many",i.manyToOne="many_to_one",i.manyToMany="many_to_many",i))($jt||{}),Ljt=(p=>(p.count="count",p.countDistinct="count_distinct",p.countDistinctApprox="count_distinct_approx",p.sum="sum",p.avg="avg",p.min="min",p.max="max",p.string="string",p.time="time",p.boolean="boolean",p.number="number",p))(Ljt||{}),qjt=(r=>(r.percent="percent",r.currency="currency",r))(qjt||{}),Fjt=(A=>(A.equals="equals",A.notEquals="notEquals",A.contains="contains",A.notContains="notContains",A.startsWith="startsWith",A.notStartsWith="notStartsWith",A.endsWith="endsWith",A.notEndsWith="notEndsWith",A.gt="gt",A.gte="gte",A.lt="lt",A.lte="lte",A.set="set",A.notSet="notSet",A.inDateRange="inDateRange",A.notInDateRange="notInDateRange",A.beforeDate="beforeDate",A.beforeOrOnDate="beforeOrOnDate",A.afterDate="afterDate",A.afterOrOnDate="afterOrOnDate",A))(Fjt||{}),jjt=(r=>(r.from_template="from_template",r.manual="manual",r))(jjt||{});var kFn=q.union([q.string().min(1),q.object({name:q.string().min(1),email:q.email().optional(),website:q.url().optional()})]);var NFn=q.object({identifier:q.string(),version:q.string(),name:q.string(),description:q.string().optional(),config:q.record(q.string(),q.any()),inputParameters:q.array(q.object({name:q.string(),description:q.string().optional(),type:q.enum(["string","number","boolean","array","simple-array","unknown"]),required:q.boolean().optional(),itemType:q.enum(["string","number","boolean"]).optional(),items:q.array(q.any()).optional()})),outputParameters:q.record(q.string(),q.any()),mode:q.enum(jjt).optional(),createdAt:q.date().optional(),updatedAt:q.date().optional(),templateIdentifier:q.string().nullable().optional()});var MFn=q.object({dimension:q.string().min(1),operator:q.enum(Fjt),values:GHe});var DFn=q.record(q.string(),q.union([MFn,q.literal(!1)]));var WHe=q.object({name:q.string().min(1).optional(),description:q.string().min(1).optional(),eventType:q.string().min(1).optional(),dataset:q.string().min(1),dimensions:q.array(q.string().min(1)).min(1),measures:q.array(q.string().min(1)).optional(),segments:q.array(q.string().min(1)).optional(),limit:q.number().min(1).optional(),filters:q.union([DFn,q.literal(!1)]).optional(),cron:q.string().optional(),tz:q.string().optional(),incrementalField:q.string().optional(),keyField:q.string().optional(),ungrouped:q.boolean().optional()}),Ujt=WHe.extend({dataset:q.string().min(1).optional(),dimensions:q.array(q.string().min(1)).optional()}),FId=q.union([q.boolean(),Ujt]),XIa=WHe.extend({identifier:q.string(),key:q.string(),status:q.enum(fy)}),jId=XIa.extend({identifier:q.string().min(1),key:q.string().min(1),status:q.enum(fy)});var $Fn=q.record(q.string(),q.union([WHe,q.boolean()]));var LFn=q.lazy(()=>q.object({type:q.enum(Njt),filters:KHe}));var Jie=q.object({sql:q.string().min(1).optional(),dimension:q.string().min(1).optional(),operator:q.enum(kjt).optional(),value:GHe.optional()}).superRefine((t,e)=>{if(t.sql===void 0&&t.dimension===void 0){e.addIssue({code:q.ZodIssueCode.custom,message:"One of sql or dimension must be defined."});return}if(t.sql!==void 0&&t.dimension!==void 0){e.addIssue({code:q.ZodIssueCode.custom,message:"One of sql or dimension must be defined."});return}t.dimension!==void 0&&(t.operator===void 0||t.value===void 0)&&e.addIssue({code:q.ZodIssueCode.custom,message:"When dimension is defined, operator and values must be defined."})});var KHe=q.record(q.string(),q.union([q.lazy(()=>LFn),Jie,q.literal(!1)]));var qFn=q.object({collection:q.string().min(1),filters:KHe.optional()});var YIa=q.record(q.string().regex(/^[a-z]{2}$/),q.record(q.string(),q.string())),Xie=q.record(q.string(),q.union([YIa,q.string().min(1),q.number(),q.boolean()]));var FFn=q.intersection(Jie,q.object({label:q.string().min(1),description:q.string().min(1).optional()}));var jFn=q.record(q.string(),q.union([FFn,q.literal(!1)]));var UFn=q.object({when:jFn,else:q.string().min(1).optional(),segment:q.boolean().optional()});var zFn=q.object({name:q.string().min(1),description:q.string().min(1),type:q.enum(Mjt),format:q.enum(Djt).optional(),explode:q.boolean().optional(),index:q.union([q.boolean(),q.string()]).optional(),upperIndex:q.union([q.boolean(),q.string()]).optional(),switch:UFn.optional(),field:PFn.optional(),sql:q.string().min(1).optional(),public:q.boolean().optional(),primaryKey:q.boolean().optional(),subQuery:q.boolean().optional(),override:q.union([q.boolean(),q.literal("manual")]).optional(),meta:Xie.optional(),granularities:q.record(q.string().min(1),q.object({interval:q.string().min(1)})).optional()}).superRefine((t,e)=>{if(t.switch!==void 0&&(t.field!==void 0||t.sql!==void 0))e.addIssue({code:q.ZodIssueCode.custom,message:"If switch is chosen, do not provide field or sql."});else if(t.switch!==void 0)return;if(t.field!==void 0&&t.sql!==void 0)e.addIssue({code:q.ZodIssueCode.custom,message:"If field is chosen, do not provide sql."});else if(t.field!==void 0)return;t.sql===void 0&&e.addIssue({code:q.ZodIssueCode.custom,message:"Please provide switch, field or sql."})});var BFn=q.record(q.string(),q.union([zFn,q.literal(!1)]));var HFn=q.object({name:q.string().min(1),description:q.string().min(1).optional(),type:q.enum(Ljt),format:q.enum(qjt).optional(),index:q.string().optional(),upperIndex:q.string().optional(),sql:q.string().min(1).optional(),dimension:q.string().min(1).optional(),public:q.boolean().optional(),override:q.union([q.boolean(),q.literal("manual")]).optional(),meta:Xie.optional()}).refine(t=>!(t.sql===void 0&&t.dimension===void 0||t.sql!==void 0&&t.dimension!==void 0),{message:"One of sql or dimension must be defined.",path:["sql","dimension"]});var VFn=q.record(q.string(),q.union([HFn,q.literal(!1)]));var GFn=q.object({type:q.enum(["rollup","original_sql","rollup_join"]).optional(),measures:q.array(q.string()).optional(),dimensions:q.array(q.string()).optional(),segments:q.array(q.string()).optional(),timeDimension:q.string().optional(),granularity:q.string().optional(),partitionGranularity:q.string().optional(),rollups:q.array(q.string()).optional(),refreshKeySql:q.string().optional(),refreshKeyEvery:q.string().optional(),refreshKeyIncremental:q.boolean().optional(),refreshKeyUpdateWindow:q.string().optional(),buildRangeStartSql:q.string().optional(),buildRangeEndSql:q.string().optional(),lambda:q.boolean().optional()});var WFn=q.record(q.string(),q.union([GFn,q.literal(!1)]));var KFn=q.object({type:q.enum($jt),dimension:q.string().min(1).optional(),targetDataset:q.string().min(1),targetDimension:q.string().min(1).optional(),sql:q.string().min(1).optional(),override:q.union([q.boolean(),q.literal("manual")]).optional()}).superRefine((t,e)=>{t.sql!==void 0&&(t.dimension!==void 0||t.targetDimension!==void 0)&&e.addIssue({code:q.ZodIssueCode.custom,message:"Use sql field or dimension/targetDimension."})});var JFn=q.record(q.string(),q.union([KFn,q.literal(!1)]));var XFn=q.intersection(Jie,q.object({name:q.string().min(1).optional(),description:q.string().min(1).optional(),public:q.boolean().optional(),override:q.union([q.boolean(),q.literal("manual")]).optional()}));var YFn=q.record(q.string(),q.union([XFn,q.literal(!1)]));var JHe=q.object({name:q.string().min(1),description:q.string().min(1),type:q.enum(Pjt),prefix:q.string().min(1),parent:q.string().min(1).optional(),sql:q.string().min(1).optional(),refreshSql:q.string().min(1).optional(),meta:Xie.optional(),collection:qFn.optional(),dimensions:BFn.optional(),segments:YFn.optional(),relations:JFn.optional(),measures:VFn.optional(),preAggregations:WFn.optional()}).superRefine((t,e)=>{if(!t.parent&&t.sql===void 0&&t.collection===void 0){e.addIssue({code:q.ZodIssueCode.custom,message:"You need to define either sql or collection."});return}t.sql!==void 0&&t.collection!==void 0&&e.addIssue({code:q.ZodIssueCode.custom,message:"You need to define either sql or collection."})});var XHe=q.record(q.string(),JHe.or(q.boolean()));var ZFn=q.record(q.string(),q.union([q.string(),q.object({selector:q.string(),items:q.lazy(()=>ZFn).optional()})])),QFn=(i=>(i.equals="equals",i.contains="contains",i.startsWith="startsWith",i.endsWith="endsWith",i))(QFn||{}),ZIa=q.object({selector:q.string(),operator:q.enum(QFn).optional().default("equals"),value:q.string()}),QIa=q.array(ZIa),e7n=q.object({identifier:q.string(),name:q.string(),description:q.string().optional(),actionIdentifier:q.string(),inputParameters:ZFn.optional(),validation:QIa.optional()});var YHe=q.object({identifier:q.string(),connectorType:q.enum(o$t),name:q.string(),location:q.string(),config:q.looseObject({}),enabled:q.boolean(),actions:q.array(NFn).optional(),webhooks:q.array(e7n).optional(),templateIdentifier:q.string().nullable().optional(),createdAt:q.date().optional(),updatedAt:q.date().optional()}).superRefine((t,e)=>{let r=t.actions?.reduce((n,i)=>(n[i.identifier]=i,n),{})??{};t.webhooks?.forEach(n=>{let i=r[n.actionIdentifier];if(!i){e.addIssue({code:"custom",message:"Action identifier does not exist in the connector's actions.",params:{webhookIdentifier:n.identifier,actionIdentifier:n.actionIdentifier},input:t});return}let o=(i.inputParameters??[]).filter(a=>a.required).map(a=>a.name),s=n.inputParameters??{};o.forEach(a=>{s[a]||e.addIssue({code:"custom",message:"Required input parameters has not been defined in webhook input parameter mapping.",params:{webhookIdentifier:n.identifier,actionIdentifier:n.actionIdentifier,parameterName:a},input:t})})})});var t7n=q.record(q.string(),YHe.or(q.boolean()));var n7n=cr(ZHe());var Yie=q.string().check(t=>{let{value:e}=t;try{(0,n7n.default)(e)}catch(r){t.issues.push({code:"custom",input:e,message:r instanceof Error?r.message:"Invalid JSONata expression"})}});var AN=q.string().max(255).regex(/^[a-zA-Z0-9_.]+$/).refine(t=>t!=="__proto__");var eRa=q.object({name:q.string(),description:q.string().optional(),expr:Yie,override:q.enum(["manual"]).or(q.boolean()).optional()}),Bjt=q.record(AN,eRa.or(q.boolean()));var i7n=q.object({name:q.string(),description:q.string().optional(),expr:Yie,override:q.enum(["manual"]).or(q.boolean()).optional()}),tRa=q.record(q.string().regex(/^(?:0|-[1-9]\d*|[1-9]\d*)(?![\s\S])/),q.string().min(1)),rRa=i7n.extend({type:q.literal("state_set"),valueLabels:tRa.optional()}),nRa=i7n.extend({type:q.enum(["count","gauge","distribution"]),valueLabels:q.never().optional()}).check(t=>{Object.prototype.hasOwnProperty.call(t.value,"valueLabels")&&t.issues.push({code:"custom",input:t.value,path:["valueLabels"],message:"Numeric measures cannot define value labels"})}),iRa=q.discriminatedUnion("type",[rRa,nRa]),Hjt=q.record(AN,iRa.or(q.boolean()));var Vjt=q.union([q.string(),q.object({collection:q.string().min(1),expr:Yie.optional()})]);var o7n=t=>{let{value:e}=t,r=Object.keys(e.measures??{}),n=Object.keys(e.dimensions??{}),i=r.filter(o=>n.includes(o));i.length>0&&t.issues.push({code:"custom",input:e,message:`Measure and dimension keys must be unique. Overlapping keys: ${i.join(", ")}`})},s7n=q.object({name:q.string(),description:q.string().optional(),source:Vjt,measures:Hjt,dimensions:Bjt.optional()}).check(o7n),a7n=q.object({name:q.string().optional(),description:q.string().optional(),source:Vjt.optional(),measures:Hjt.optional(),dimensions:Bjt.optional()}).check(o7n),QHe=q.record(AN,s7n.or(q.boolean())),oRa=s7n.extend({identifier:q.string(),key:AN,status:q.enum(fy)}),O2d=oRa.extend({id:q.string(),tenantIdentifier:q.string(),createdAt:q.date(),updatedAt:q.date()});var Gjt=q.object({key:q.string().optional(),name:q.string().min(1),description:q.string(),query:q.looseObject({dataset:q.string().min(1).optional()}),inputs:q.array(q.object({name:q.string(),description:q.string().optional(),type:q.enum(["string","number","boolean","array","simple-array","unknown"]),required:q.boolean().optional(),itemType:q.enum(["string","number","boolean"]).optional(),items:q.array(q.unknown()).optional()}))}),eVe=q.record(q.string(),Gjt.or(q.boolean()));var Q2d=q.object({identifier:q.string().min(1),version:q.string().min(1),name:q.string().min(1),prefix:q.string().min(1),description:q.string(),logo:q.string().nullable().optional(),author:kFn.nullable().optional(),tenantIdentifier:q.string().nullable().optional(),internal:q.boolean().optional(),datasets:XHe,semanticTriggers:$Fn,connectors:t7n.optional(),metrics:QHe.optional(),queries:eVe.optional()});var c7n=q.object({...YHe.shape,actions:q.array(q.looseObject({})).optional(),webhooks:q.array(q.looseObject({})).optional()}).partial().strict(),u7n=Ujt.extend({status:q.enum(fy).optional()}).or(q.boolean()),l7n=q.object({datasets:XHe.optional(),semanticTriggers:q.record(q.string(),u7n).optional(),connectors:q.record(q.string(),q.union([c7n,q.boolean()])).optional(),metrics:QHe.optional(),queries:eVe.optional()}),sRa=q.object({...JHe.shape,key:q.string().optional(),status:q.enum(fy).optional()}).partial().strict(),aRa=a7n.or(q.boolean()),cRa=Gjt.strict(),d7n=q.object({datasets:q.record(q.string(),q.union([sRa,q.boolean()])).optional(),semanticTriggers:q.record(q.string(),u7n).optional(),connectors:q.record(q.string(),q.union([c7n,q.boolean()])).optional(),metrics:q.record(AN,aRa).optional(),queries:q.record(q.string(),q.union([cRa,q.boolean()])).optional()}).strict();var uRa=q.object({templateVersion:q.literal("latest").or(q.string().min(1)),name:q.string().min(1),description:q.string().min(1),overrides:l7n}),yOd=uRa.extend({templateId:q.string().min(1),tenantId:q.string().min(1)}),lRa=q.object({templateVersion:q.literal("latest").or(q.string().min(1)),name:q.string().min(1),description:q.string().min(1),overrides:d7n}).strict(),_Od=lRa.extend({tenantId:q.string().min(1),templateIdentifier:q.string().min(1)}).strict();var Mm=[];for(let t=0;t<256;++t)Mm.push((t+256).toString(16).slice(1));function p7n(t,e=0){return(Mm[t[e+0]]+Mm[t[e+1]]+Mm[t[e+2]]+Mm[t[e+3]]+"-"+Mm[t[e+4]]+Mm[t[e+5]]+"-"+Mm[t[e+6]]+Mm[t[e+7]]+"-"+Mm[t[e+8]]+Mm[t[e+9]]+"-"+Mm[t[e+10]]+Mm[t[e+11]]+Mm[t[e+12]]+Mm[t[e+13]]+Mm[t[e+14]]+Mm[t[e+15]]).toLowerCase()}var dRa=new Uint8Array(16);function Wjt(){return crypto.getRandomValues(dRa)}function pRa(t,e,r){return!e&&!t&&crypto.randomUUID?crypto.randomUUID():fRa(t,e,r)}function fRa(t,e,r){t=t||{};let n=t.random??t.rng?.()??Wjt();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){if(r=r||0,r<0||r+16>e.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)e[r+i]=n[i];return e}return p7n(n)}var Kjt=pRa;var OSi=cr(jjn());var NN=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var Yh=globalThis;var GH="10.78.0";function kEe(){return NEe(Yh),Yh}function NEe(t){let e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||GH,e[GH]=e[GH]||{}}function soe(t,e,r=Yh){let n=r.__SENTRY__=r.__SENTRY__||{},i=n[GH]=n[GH]||{};return i[t]||(i[t]=e())}var M2a="Sentry Logger ",Ujn={};function D2a(t){if(!("console"in Yh))return t();let e=Yh.console,r={},n=Object.keys(Ujn);n.forEach(i=>{let o=Ujn[i];r[i]=e[i],e[i]=o});try{return t()}finally{n.forEach(i=>{e[i]=r[i]})}}function $2a(){DUt().enabled=!0}function L2a(){DUt().enabled=!1}function zjn(){return DUt().enabled}function q2a(...t){MUt("log",...t)}function F2a(...t){MUt("warn",...t)}function j2a(...t){MUt("error",...t)}function MUt(t,...e){NN&&zjn()&&D2a(()=>{Yh.console[t](`${M2a}[${t}]:`,...e)})}function DUt(){return NN?soe("loggerSettings",()=>({enabled:!1})):{enabled:!1}}var aoe={enable:$2a,disable:L2a,isEnabled:zjn,log:q2a,warn:F2a,error:j2a};var U2a=Object.prototype.toString;function z2a(t,e){return U2a.call(t)===`[object ${e}]`}function Bjn(t){return z2a(t,"Object")}function Hjn(t){return!!(t?.then&&typeof t.then=="function")}function Vjn(t,e,r){try{Object.defineProperty(t,e,{value:r,writable:!0,configurable:!0})}catch{NN&&aoe.log(`Failed to add non-enumerable property "${String(e)}" to object`,t)}}var coe;function uoe(t){if(coe!==void 0)return coe?coe(t):t();let e=Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),r=Yh;return e in r&&typeof r[e]=="function"?(coe=r[e],coe(t)):(coe=null,t())}function MEe(){return uoe(()=>Math.random())}function Gjn(){return uoe(()=>Date.now())}function Wjn(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}function B2a(){let t=Yh;return t.crypto||t.msCrypto}var $Ut;function H2a(){return MEe()*16}function q$(t=B2a()){try{if(t?.randomUUID)return uoe(()=>t.randomUUID()).replace(/-/g,"")}catch{}return $Ut||($Ut="10000000100040008000"+1e11),$Ut.replace(/[018]/g,e=>(e^(H2a()&15)>>e/4).toString(16))}var Jjn=1e3;function LUt(){return Gjn()/Jjn}function V2a(){let{performance:t}=Yh;if(!t?.now||!t.timeOrigin)return LUt;let e=t.timeOrigin;return()=>(e+uoe(()=>t.now()))/Jjn}var Kjn;function Xjn(){return(Kjn??(Kjn=V2a()))()}function Yjn(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),!t.did&&!e.did&&(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||Xjn(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=e.sid.length===32?e.sid:q$()),e.init!==void 0&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),typeof e.started=="number"&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if(typeof e.duration=="number")t.duration=e.duration;else{let r=t.timestamp-t.started;t.duration=r>=0?r:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),typeof e.errors=="number"&&(t.errors=e.errors),e.status&&(t.status=e.status)}function qUt(t,e,r=2){if(!e||typeof e!="object"||r<=0)return e;if(t&&Object.keys(e).length===0)return t;let n={...t};for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=qUt(n[i],e[i],r-1));return n}function FUt(){return q$()}function Zjn(t){try{let e=Yh.WeakRef;if(typeof e=="function")return new e(t)}catch{}return t}function Qjn(t){if(t){if(typeof t=="object"&&"deref"in t&&typeof t.deref=="function")try{return t.deref()}catch{return}return t}}var jUt="_sentrySpan";function UUt(t,e){e?Vjn(t,jUt,Zjn(e)):delete t[jUt]}function zUt(t){return Qjn(t[jUt])}var G2a=100,kx=class t{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._attributes={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:FUt(),sampleRand:MEe()}}clone(){let e=new t;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._attributes={...this._attributes},e._extra={...this._extra},e._contexts={...this._contexts},this._contexts.flags&&(e._contexts.flags={values:[...this._contexts.flags.values]}),e._user=this._user,e._level=this._level,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e._lastEventId=this._lastEventId,e._conversationId=this._conversationId,UUt(e,zUt(this)),e}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&Yjn(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setConversationId(e){return this._conversationId=e||void 0,this._notifyScopeListeners(),this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,r){return this.setTags({[e]:r})}setAttributes(e){return this._attributes={...this._attributes,...e},this._notifyScopeListeners(),this}setAttribute(e,r){return this.setAttributes({[e]:r})}removeAttribute(e){return e in this._attributes&&(delete this._attributes[e],this._notifyScopeListeners()),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,r){return this._extra={...this._extra,[e]:r},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,r){return r===null?delete this._contexts[e]:this._contexts[e]=r,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;let r=typeof e=="function"?e(this):e,n=r instanceof t?r.getScopeData():Bjn(r)?e:void 0,{tags:i,attributes:o,extra:s,user:a,contexts:c,level:u,fingerprint:d=[],propagationContext:p,conversationId:f}=n||{};return this._tags={...this._tags,...i},this._attributes={...this._attributes,...o},this._extra={...this._extra,...s},this._contexts={...this._contexts,...c},a&&Object.keys(a).length&&(this._user=a),u&&(this._level=u),d.length&&(this._fingerprint=d),p&&(this._propagationContext=p),f&&(this._conversationId=f),this}clear(){return this._breadcrumbs=[],this._tags={},this._attributes={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,this._conversationId=void 0,UUt(this,void 0),this._attachments=[],this.setPropagationContext({traceId:FUt(),sampleRand:MEe()}),this._notifyScopeListeners(),this}addBreadcrumb(e,r){let n=typeof r=="number"?r:G2a;if(n<=0)return this;let i={timestamp:LUt(),...e,message:e.message?Wjn(e.message,2048):e.message};return this._breadcrumbs.push(i),this._breadcrumbs.length>n&&(this._breadcrumbs=this._breadcrumbs.slice(-n)),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,attributes:this._attributes,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:zUt(this),conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=qUt(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,r){let n=r?.event_id||q$();if(!this._client)return NN&&aoe.warn("No client configured on scope - will not capture exception!"),n;let i=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:i,...r,event_id:n},this),n}captureMessage(e,r,n){let i=n?.event_id||q$();if(!this._client)return NN&&aoe.warn("No client configured on scope - will not capture message!"),i;let o=n?.syntheticException??new Error(e);return this._client.captureMessage(e,r,{originalException:e,syntheticException:o,...n,event_id:i},this),i}captureEvent(e,r){let n=e.event_id||r?.event_id||q$();return this._client?(this._client.captureEvent(e,{...r,event_id:n},this),n):(NN&&aoe.warn("No client configured on scope - will not capture event!"),n)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}};function eUn(){return soe("defaultCurrentScope",()=>new kx)}function tUn(){return soe("defaultIsolationScope",()=>new kx)}var rUn=t=>t instanceof Promise&&!t[nUn],nUn=Symbol("chained PromiseLike"),iUn=(t,e,r)=>{let n=t.then(i=>(e(i),i),i=>{throw r(i),i});return rUn(n)&&rUn(t)?n:W2a(t,n)},W2a=(t,e)=>{if(!e)return t;let r=!1;for(let n in t){if(n in e)continue;r=!0;let i=t[n];typeof i=="function"?Object.defineProperty(e,n,{value:(...o)=>i.apply(t,o),enumerable:!0,configurable:!0,writable:!0}):e[n]=i}return r&&Object.assign(e,{[nUn]:!0}),e};var BUt=class{constructor(e,r){let n;e?n=e:n=new kx;let i;r?i=r:i=new kx,this._stack=[{scope:n}],this._isolationScope=i}withScope(e){let r=this._pushScope(),n;try{n=e(r)}catch(i){throw this._popScope(),i}return Hjn(n)?iUn(n,()=>this._popScope(),()=>this._popScope()):(this._popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){let e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return this._stack.length<=1?!1:!!this._stack.pop()}};function loe(){let t=kEe(),e=NEe(t);return e.stack=e.stack||new BUt(eUn(),tUn())}function K2a(t){return loe().withScope(t)}function J2a(t,e){let r=loe();return r.withScope(()=>(r.getStackTop().scope=t,e(t)))}function oUn(t){return loe().withScope(()=>t(loe().getIsolationScope()))}function sUn(){return{withIsolationScope:oUn,withScope:K2a,withSetScope:J2a,withSetIsolationScope:(t,e)=>oUn(e),getCurrentScope:()=>loe().getScope(),getIsolationScope:()=>loe().getIsolationScope()}}function aUn(t){let e=NEe(t);return e.acs?e.acs:sUn()}function HUt(){let t=kEe();return aUn(t).getCurrentScope()}function cUn(t){if(t)return X2a(t)?{captureContext:t}:Z2a(t)?{captureContext:t}:t}function X2a(t){return t instanceof kx||typeof t=="function"}var Y2a=["user","level","extra","contexts","tags","fingerprint","propagationContext"];function Z2a(t){return Object.keys(t).some(e=>Y2a.includes(e))}function WH(t,e){return HUt().captureException(t,cUn(e))}var Hnt=cr(bvi()),PSi=cr(Ia());var ISi=cr(TSi());function ldc(t,e){let r=e?`: ${e}`:"";return`${t}${r}`}function RSi(t){return async e=>({success:!1,statusCode:ISi.StatusCodes.BAD_REQUEST,message:ldc("Bad request",t),meta:{testRun:e.testRun,...e.meta??{}}})}var Uce=class{constructor(e){this.baseConfig=e}baseConfig;processMessage(e){return async r=>{if(await this.isProcessed(r))return gc.getInstance().debug(`Message ${r.eventId} already processed`),RSi(`Message ${r.eventId} already processed`)(r);gc.getInstance().debug(`Processing message ${r.eventId}`);let n=await e(r);return n.success?await this.addProcessedMessage(r):gc.getInstance().debug(`Message ${r.eventId} FAILED to process: ${n.message}. Not storing in processed messages list.`),n}}};var znt=class extends Uce{constructor(r,n){super(n);this.config=r}config;processedMessages=[];async isProcessed(r){return this.processedMessages.includes(r.eventId)}async addProcessedMessage(r){this.processedMessages.push(r.eventId),this.processedMessages.length>this.config.messagesToKeep&&this.processedMessages.shift()}};var CSi=cr(i$t());var Bnt=class extends Uce{constructor(r,n){super(n);this.config=r;(0,CSi.createClient)({url:this.config.url}).on("error",i=>gc.error("[REDIS MESSAGE MONITOR] Redis Client Error",i)).connect().then(i=>{this.redisClient=i,this.initialized=!0}).catch(i=>{gc.error("[REDIS MESSAGE MONITOR] Redis Client Error",i)})}config;redisClient=void 0;initialized=!1;DEFAULT_TTL=7200;async isProcessed(r){return this.redisClient===void 0||!this.initialized?(gc.getInstance().error("[REDIS MESSAGE MONITOR] Not initialized. continue to handle message"),!1):await this.redisClient.exists(this.getMessageProcessIdentifier(r))===1}async addProcessedMessage(r){if(this.redisClient===void 0||!this.initialized){gc.getInstance().error("[REDIS MESSAGE MONITOR] Not initialized. Cannot store message details");return}await this.redisClient.set(this.getMessageProcessIdentifier(r),"1",{EX:this.config.ttl??this.DEFAULT_TTL})}getMessageProcessIdentifier(r){return`${this.baseConfig.processIdentifier}.${r.eventId}`}};var ddc=t=>()=>Promise.resolve({accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey}),pdc=t=>async()=>{let e=process.env.AWS_ROLE_SESSION_NAME??"";if(t?.accessKeyId&&t?.secretAccessKey){gc.getInstance().verbose(`Generating OAuth Bearer token using ENV variables and principal: ${e}`);let n=await(0,Hnt.generateAuthTokenFromCredentialsProvider)({region:t.region??"eu-west-1",awsCredentialsProvider:ddc({accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey})});return gc.getInstance().debug(`Token using Default Credentials Provider ${n.expiryTime} - ${n.expiryTime-Date.now()}ms`),{principal:e,value:n.token,lifetime:n.expiryTime}}gc.getInstance().verbose(`Generating OAuth Bearer token using Default Credentials Provider and principal: ${e}`);let r=await(0,Hnt.generateAuthToken)({region:t?.region??"eu-west-1",awsRoleSessionName:e,logger:gc.getInstance(),awsDebugCreds:!0});return gc.getInstance().debug(`Token using Default Credentials Provider ${r.expiryTime} - ${r.expiryTime-Date.now()}ms`),{principal:e,value:r.token,lifetime:r.expiryTime}},wRe=class t{constructor(e,r){this.baseYamlConfig=e;this.connectorTopic=r;let n={info:(c,u)=>{this.logger.info(c,u)},error:(c,u)=>{this.logger.error(c,u)},warn:(c,u)=>{this.logger.warn(c,u)},debug:()=>{},namespace:()=>n,setLogLevel:()=>{}};this.logger=gc.getInstance(),this.logger.info("RUNNING RDKAFKA SERVICE");let{kafka:i}=e,o={brokers:i.brokers,ssl:!1,clientId:`${i.clientId}-${Kjt()}`,logLevel:2,logger:n};if(i.sasl){let{sasl:c}=i;o.sasl={mechanism:"oauthbearer",oauthBearerProvider:pdc(c)},o.ssl=!0}this.messageMonitor=this.getCorrespondingMonitor(),this.disableLogs=e.kafka.disableLogs??!1,this.kafkaBase=new OSi.KafkaJS.Kafka({kafkaJS:o,"message.max.bytes":i.messageMaxBytes??t.DEFAULT_MESSAGE_MAX_BYTES});let{kafka:s}=e,a={kafkaJS:{groupId:e.kafka.groupId,autoCommitInterval:e.kafka.autoCommitInterval??5e3,fromBeginning:!0,...s.maxBytesPerPartition!==void 0&&{maxBytesPerPartition:s.maxBytesPerPartition}}};if(s.fetchMaxBytes!==void 0&&(a["fetch.max.bytes"]=s.fetchMaxBytes),s.queuedMaxMessagesKbytes!==void 0&&(a["queued.max.messages.kbytes"]=s.queuedMaxMessagesKbytes),s.queuedMinMessages!==void 0&&(a["queued.min.messages"]=s.queuedMinMessages),s.maxPollIntervalMs!==void 0&&(a["max.poll.interval.ms"]=s.maxPollIntervalMs),s.maxBatchSize!==void 0&&(a["js.consumer.max.batch.size"]=s.maxBatchSize),e.kafka.newConsumerProtocol&&(this.logger.info("RDKAFKA Using new consumer protocol"),a["group.protocol"]="consumer",a["group.protocol.type"]="consumer",a["group.remote.assignor"]="uniform"),this.#e=a,this.consumer=this.kafkaBase.consumer(a),this.producer=this.kafkaBase.producer({"compression.codec":i.compression??t.DEFAULT_COMPRESSION_CODEC}),!r&&(this.baseYamlConfig.kafka.consumerTopics===void 0||this.baseYamlConfig.kafka.consumerTopics.length===0)){this.logger.warn("No consumer topics set. skip setting of consumer events callback");return}if(typeof process>"u"){this.logger.warn("No process found. Graceful shutdown not possible");return}this.logger.debug("Setting up graceful shutdown for kafka..."),this.errorTypes.forEach(c=>{process.on(c,async(u,d)=>{try{this.logger.error(`RDKAFKA process.on ${c}`),this.logger.error(typeof u,u,{error:u},JSON.stringify(u)),this.logger.error(typeof d,d,{promise:d},JSON.stringify(d)),this.logger.error("RDKAFKA process.on current stack:",new Error().stack),await this.exitProcess(c)}catch{process.exit(1)}})}),this.signalTraps.forEach(c=>{process.on(c,async()=>{this.logger.error(`process.once ${c}`);try{await this.exitProcess(c)}finally{process.exit(0)}})})}baseYamlConfig;connectorTopic;errorTypes=["unhandledRejection","uncaughtException"];signalTraps=["SIGTERM","SIGINT","SIGUSR2"];static DEFAULT_CALLBACK_EVENT_TYPE="*";static DEFAULT_MESSAGE_MAX_BYTES=2*1024*1024;static DEFAULT_COMPRESSION_CODEC="gzip";kafkaBase;consumer;#e;#t=!1;#r=!1;producer;processedTopic="_LOGS_xod";DEFAULT_INTERVAL_CHECK_FOR_NEW_TOPICS=300;numberOfSubscribedRegexTopics=0;disableLogs;messageMonitor=void 0;logger;exitProcess=async e=>{this.logger.warn(`Got ${e}. Graceful shutdown Kafka start ${new Date().toISOString()}`),this.logger.debug("Disconnecting consumer and producer");try{await this.consumer?.disconnect(),this.logger.debug("Consumer disconnected")}catch(r){this.logger.error(`Error while disconnecting consumer: ${r}`)}try{await this.producer?.disconnect(),this.logger.debug("Producer disconnected")}catch(r){this.logger.error(`Error while disconnecting producer: ${r}`)}this.logger.info(`Graceful shutdown Kafka complete ${new Date().toISOString()}`),process.exit(0)};getCorrespondingMonitor(){if(this.baseYamlConfig.kafka.messageMonitor?.type==="in-memory")return this.logger.debug("Using in-memory message monitor"),new znt(this.baseYamlConfig.kafka.messageMonitor,this.baseYamlConfig);if(this.baseYamlConfig.kafka.messageMonitor?.type==="redis")return this.logger.debug("Using Redis message monitor"),new Bnt(this.baseYamlConfig.kafka.messageMonitor,this.baseYamlConfig);if(this.baseYamlConfig.kafka.messageMonitor?.type==="disabled"){this.logger.debug("Message monitor disabled");return}this.logger.debug("No setting, Message monitor disabled")}connectConsumer=async()=>{this.#t||(await this.consumer.connect(),this.#t=!0)};getRegularTopics=()=>(this.baseYamlConfig.kafka.consumerTopics??[]).filter(e=>!s$t(e));getRegexTopics=async()=>{let e=await this.#n();return this.numberOfSubscribedRegexTopics=e.length,this.#i(),e};#i(){let e=this.baseYamlConfig.kafka.intervalCheckForNewTopics??this.DEFAULT_INTERVAL_CHECK_FOR_NEW_TOPICS;this.#r||e<=0||(this.#r=!0,(0,PSi.interval)(e*1e3).subscribe(()=>{this.#l().catch(r=>{this.logger.error(r)})}))}#n=async()=>{let e=(this.baseYamlConfig.kafka.consumerTopics??[]).filter(o=>s$t(o));if(e.length===0)return[];let r=e.map(o=>new RegExp(o.pattern,o.flags)),n=this.kafkaBase.admin();await n.connect();let i=await n.listTopics();return await n.disconnect(),i.filter(o=>r.some(s=>s.test(o)))};#l=async()=>{if((await this.#n()).length!==this.numberOfSubscribedRegexTopics)try{this.logger.info("New topics found, restarting consumer"),await this.consumer.disconnect(),this.consumer=this.kafkaBase.consumer(this.#e),this.#t=!1,await this.init()}catch(r){this.logger.error(`Restarting consumer failed: ${r.message}`),WH(r),process.exit(1)}}};var c0t=cr(Vn()),_Or=cr(Nut());var a0t=class extends _Or.BaseExceptionFilter{catch(e,r){if(e instanceof c0t.HttpException){let i=e.getStatus();i>=500&&WH(e,{tags:{status_code:i}})}else WH(e);super.catch(e,r)}};a0t=ztn([(0,c0t.Catch)()],a0t);function Yvo(t){let e=Object.keys(t),r=e.map(o=>o.split(".")[0]),n=Array.from(new Set(r)),i={};return n.forEach(o=>{let s=e.filter(a=>a.split(".").length>1).filter(a=>a.split(".")[0]===o);s.length!==0&&(i[o]={},s.forEach(a=>{let c=a.split(".");c.length!==1&&(i[o][c[1]]=t[a])}))}),i}function Zvo(t,e){let r=/{{\s*(message|inputs)\.(\w+)\s*}}/,n=i=>{if(typeof i=="string"){let o=i.match(r);if(o){let s=o[2];return e[s]!==void 0?e[s]:i}return i}return Array.isArray(i)?i.map(n):typeof i=="object"&&i!==null?Object.fromEntries(Object.entries(i).map(([o,s])=>[o,n(s)])):i};return n(t)}var ULu=cr(ZHe());var zLu=cr(ZHe());var BLu=3,HLu=1e3,vOr=16,VLu=6e4,GLu=new Set(["ECONNABORTED","ECONNREFUSED","ECONNRESET","ENETUNREACH","ENOTFOUND","EPIPE","ETIMEDOUT"]),WLu=/network error|timeout|timed out|connection (?:reset|refused)|dns|socket hang up/i,ebo=q.object({cacheStrategy:q.string().optional(),maxRetries:q.number().int().nonnegative().max(vOr).optional().default(BLu),retryDelayMs:q.number().int().nonnegative().max(VLu).optional().default(HLu)});function KLu(t){if(typeof t!="object"||t===null||!("code"in t))return;let{code:e}=t;return typeof e=="string"?e:void 0}function Qvo(t){let{status:e}=t;return typeof e=="number"?e:void 0}function bOr(t){if(t instanceof Error&&t.name==="AbortError")return!1;if(t instanceof Error&&typeof Qvo(t)=="number"){let e=Qvo(t);return e===408||e===429||e>=500&&e<=599}return GLu.has(KLu(t)??"")||t instanceof Error&&WLu.test(t.message)}function tbo(t){return new Promise(e=>{setTimeout(e,t)})}var JLu=q.array(q.looseObject({values:q.array(q.unknown()).optional()}));function XLu(t){let e=JLu.safeParse(t.filters);return e.success&&e.data.some(r=>r.values?.length===0)}function YLu(t,e,r){let n="Error in query";return bOr(t)&&e===r&&(n+=` after attempt ${e}/${r}`),t instanceof Error&&(n+=`: (${t.name}) ${t.message}`),n}function SOr(t,e,r){return(t??[]).map(n=>({name:n.name,title:n.title,type:n.type??r??"string",kind:e}))}var Hpe=class{#e;#t;constructor(e,r){this.#e=e,this.#t=r}static prepare(e,r){let n=Zvo(e,r);return{query:n,hasEmptyFilterValues:XLu(n)}}async#r(e,r,n){let i=Math.min(n.maxRetries,vOr),o=i+1;for(let s=1;s<=o;s+=1)try{return await this.#e.load(e,{cache:r})}catch(a){if(s<o&&bOr(a)){let u=n.retryDelayMs*2**(s-1);this.#t.warn(`Cube query failed; retrying attempt ${s}/${i} in ${u}ms: ${a instanceof Error?a.message:String(a)}`),await tbo(u);continue}let c=YLu(a,s,o);throw this.#t.error(c),this.#t.verbose(JSON.stringify(e)),new u5(c,e)}throw new u5(`Retried ${i}/${o} attempts`,e)}async execute(e,r){let n=r.cacheStrategy||(e.renewQuery?"no-cache":"must-revalidate"),{renewQuery:i,...o}=e,a=(await this.#r(o,n,r)).serialize().loadResponse.results;if(this.#t.debug(`Cube query executed successfully with ${a.length} results`),this.#t.verbose(a),a.length===0)throw new u5("No results found for given query",e);return{data:a[0].data.map(Yvo),lastRefreshTime:a[0].lastRefreshTime}}async meta(){let{cubes:e}=(await this.#e.meta()).meta;return e.map(r=>({name:r.name,title:r.title,members:[...SOr(r.measures,"measure"),...SOr(r.dimensions,"dimension"),...SOr(r.segments,"segment","boolean")]}))}};xk();pc();Bb();Wfe();IJ();Cc();function mHu({apiKey:t,configuration:e={}}){let r=Ak({baseURL:e.baseURL,providerPath:"v1"});return{apiKey:t??e.apiKey??r.apiKey??(di("LANGSMITH_GATEWAY_API_KEY")||di("LANGSMITH_API_KEY")),configuration:{...e,baseURL:r.baseURL??`${Wbt}/v1`},useResponsesApi:!0}}var Jbt={openai:{package:"@langchain/openai",className:"ChatOpenAI"},anthropic:{package:"@langchain/anthropic",className:"ChatAnthropic"},azure_openai:{package:"@langchain/openai",className:"AzureChatOpenAI"},langsmith:{package:"@langchain/openai",className:"ChatOpenAI"},cohere:{package:"@langchain/cohere",className:"ChatCohere"},google:{package:"@langchain/google",className:"ChatGoogle"},"google-vertexai":{package:"@langchain/google-vertexai",className:"ChatVertexAI"},"google-vertexai-web":{package:"@langchain/google-vertexai-web",className:"ChatVertexAI"},"google-genai":{package:"@langchain/google-genai",className:"ChatGoogleGenerativeAI"},ollama:{package:"@langchain/ollama",className:"ChatOllama"},mistralai:{package:"@langchain/mistralai",className:"ChatMistralAI"},mistral:{package:"@langchain/mistralai",className:"ChatMistralAI"},groq:{package:"@langchain/groq",className:"ChatGroq"},bedrock:{package:"@langchain/aws",className:"ChatBedrockConverse"},aws:{package:"@langchain/aws",className:"ChatBedrockConverse"},deepseek:{package:"@langchain/deepseek",className:"ChatDeepSeek"},xai:{package:"@langchain/xai",className:"ChatXAI"},cerebras:{package:"@langchain/cerebras",className:"ChatCerebras"},fireworks:{package:"@langchain/fireworks",className:"ChatFireworks"},together:{package:"@langchain/together-ai",className:"ChatTogetherAI",hasCircularDependency:!0},perplexity:{package:"@langchain/perplexity",className:"ChatPerplexity"}},KIo=Object.keys(Jbt);async function hHu(t,e){let r;if(e)r=Jbt[e];else{let n=Object.entries(Jbt).find(([,i])=>i.className===t);r=n?n[1]:void 0}if(r)try{return(await import(r.package))[r.className]}catch(n){let i=n;if("code"in i&&i.code?.toString().includes("ERR_MODULE_NOT_FOUND")&&"message"in i&&typeof i.message=="string"){let o=(i.message.startsWith("Error: ")?i.message.slice(7):i.message).split("Cannot find package '")[1].split("'")[0];throw new Error(`Unable to import ${o}. Please install with \`npm install ${o}\` or \`pnpm install ${o}\``)}throw n}}async function gHu(t,e,r={}){let n=e||yHu(t);if(!n)throw new Error(`Unable to infer model provider for { model: ${t} }, please specify modelProvider directly.`);let i=Jbt[n];if(!i){let a=KIo.join(", ");throw new Error(`Unsupported { modelProvider: ${n} }.
1183
1183
 
1184
1184
  Supported model providers are: ${a}`)}let{modelProvider:o,...s}=r;return new(await hHu(i.className,n))({model:t,...s,...n==="langsmith"?mHu(s):{}})}function yHu(t){return t.startsWith("gpt-3")||t.startsWith("gpt-4")||t.startsWith("gpt-5")||t.startsWith("o1")||t.startsWith("o3")||t.startsWith("o4")?"openai":t.startsWith("claude")?"anthropic":t.startsWith("command")?"cohere":t.startsWith("accounts/fireworks")?"fireworks":t.startsWith("gemini")?"google-vertexai":t.startsWith("amazon.")?"bedrock":t.startsWith("mistral")?"mistralai":t.startsWith("sonar")||t.startsWith("pplx")?"perplexity":void 0}var WIo=class Kbt extends Lp{_llmType(){return"chat_model"}lc_namespace=["langchain","chat_models"];_defaultConfig={};_configurableFields="any";_configPrefix;_queuedMethodOperations={};_modelInstanceCache=new Map;_profile;constructor(e){super(e),this._defaultConfig=e.defaultConfig??{},e.configurableFields==="any"?this._configurableFields="any":this._configurableFields=e.configurableFields??["model","modelProvider"],e.configPrefix?this._configPrefix=e.configPrefix.endsWith("_")?e.configPrefix:`${e.configPrefix}_`:this._configPrefix="",this._queuedMethodOperations=e.queuedMethodOperations??this._queuedMethodOperations,this._profile=e.profile??void 0,this.metadata={...this.metadata,ls_integration:"langchain_init_chat_model"}}async _getModelInstance(e){let r=this._getCacheKey(e),n=this._modelInstanceCache.get(r);if(n)return n;let i={...this._defaultConfig,...this._modelParams(e)},o=await gHu(i.model,i.modelProvider,i);for(let[s,a]of Object.entries(this._queuedMethodOperations))s in o&&typeof o[s]=="function"&&(o=await o[s](...a));return this._modelInstanceCache.set(r,o),o}async _generate(e,r,n){return(await this._getModelInstance(r))._generate(e,r??{},n)}bindTools(e,r){let n={...this._queuedMethodOperations};return n.bindTools=[e,r],new Kbt({defaultConfig:this._defaultConfig,configurableFields:this._configurableFields,configPrefix:this._configPrefix,queuedMethodOperations:n})}withStructuredOutput=(e,...r)=>{let n={...this._queuedMethodOperations};return n.withStructuredOutput=[e,...r],new Kbt({defaultConfig:this._defaultConfig,configurableFields:this._configurableFields,configPrefix:this._configPrefix,queuedMethodOperations:n})};_modelParams(e){let r=e?.configurable??{},n={};for(let[i,o]of Object.entries(r))if(i.startsWith(this._configPrefix)){let s=this._removePrefix(i,this._configPrefix);n[s]=o}return this._configurableFields!=="any"&&(n=Object.fromEntries(Object.entries(n).filter(([i])=>this._configurableFields.includes(i)))),n}_removePrefix(e,r){return e.startsWith(r)?e.slice(r.length):e}withConfig(e){let r={...e||{}},n=this._modelParams(r),i=Object.fromEntries(Object.entries(r).filter(([s])=>s!=="configurable"));i.configurable=Object.fromEntries(Object.entries(r.configurable||{}).filter(([s])=>this._configPrefix&&!Object.keys(n).includes(this._removePrefix(s,this._configPrefix))));let o=new Kbt({defaultConfig:{...this._defaultConfig,...n},configurableFields:Array.isArray(this._configurableFields)?[...this._configurableFields]:this._configurableFields,configPrefix:this._configPrefix,queuedMethodOperations:this._queuedMethodOperations});return new Ou({config:r,bound:o})}async invoke(e,r){let n=await this._getModelInstance(r),i=Ui(r);return n.invoke(e,i)}async stream(e,r){let n=await this._getModelInstance(r),i=new lk({generator:await n.stream(e,r),config:r});return await i.setup,ol.fromAsyncGenerator(i)}async batch(e,r,n){return super.batch(e,r,n)}async*transform(e,r){let n=await this._getModelInstance(r),i=Ui(r);yield*n.transform(e,i)}async*streamLog(e,r,n){let i=await this._getModelInstance(r),o=Ui(r);yield*i.streamLog(e,o,{...n,_schemaFormat:"original",includeNames:n?.includeNames,includeTypes:n?.includeTypes,includeTags:n?.includeTags,excludeNames:n?.excludeNames,excludeTypes:n?.excludeTypes,excludeTags:n?.excludeTags})}streamEvents(e,r,n){if(r?.version==="v1"||r?.version==="v2"){let s=this,a=r;async function*c(){let u=await s._getModelInstance(a),d={...Ui(a),version:a.version,...a.encoding!==void 0?{encoding:a.encoding}:{}},p;a.version==="v1"&&a.encoding==="text/event-stream"||a.version==="v1"||a.version==="v2"&&a.encoding,p=u.streamEvents(e,d,n);for await(let f of p)yield f}return ol.fromAsyncGenerator(c())}let i=this;async function*o(){let s=await i._getModelInstance(r),a=Ui(r);yield*s.streamEvents(e,a)}return new nE(o())}get profile(){if(this._profile)return this._profile;let e=this._getCacheKey({});return this._modelInstanceCache.get(e)?.profile??{}}_getCacheKey(e){let r=e??{};if(r.configurable){let{configurable:n}=r,i={};for(let[o,s]of Object.entries(n))o.startsWith("__pregel_")||(i[o]=s);r={...r,configurable:i}}return JSON.stringify(r)}};async function k3(t,e){let{configurableFields:r,configPrefix:n,modelProvider:i,profile:o,...s}={configPrefix:"",...e??{}};if(i===void 0&&t?.includes(":")){let[d,...p]=t.split(":"),f=p.length===0?[d]:[d,p.join(":")];KIo.includes(f[0])&&([i,t]=f)}let a=Array.isArray(r)?[...r]:r;!t&&a===void 0&&(a=["model","modelProvider"]),n&&a===void 0&&console.warn(`{ configPrefix: ${n} } has been set but no fields are configurable. Set { configurableFields: [...] } to specify the model params that are configurable.`);let c={...s},u;return a===void 0?u=new WIo({defaultConfig:{...c,model:t,modelProvider:i},configPrefix:n,profile:o}):(t&&(c.model=t),i&&(c.modelProvider=i),u=new WIo({defaultConfig:c,configPrefix:n,configurableFields:a,profile:o})),await u._getModelInstance(),u}qp();function xWu(t){let{name:e,description:r,schema:n}=t,i=Gb(async(s,a)=>{let{interrupt:c}=await Promise.resolve().then(()=>(Lg(),eko));return c({type:"tool",toolCall:{id:a?.toolCall?.id,name:e,args:s}})},{name:e,description:r,schema:n,metadata:{headlessTool:!0}}),o=Object.assign(i,{implement:s=>({tool:o,execute:s})});return o}var eX=((t,e)=>typeof t!="function"?xWu(t):Gb(t,e));Lg();var iDe=class extends Error{constructor(){super("The provided LLM already has bound tools. Please provide an LLM without bound tools to createAgent. The agent will bind the tools provided in the 'tools' parameter.")}},oDe=class extends Error{toolNames;constructor(t){super(`The model has called multiple tools: ${t.join(", ")} to return a structured output. This is not supported. Please provide a single structured output.`),this.toolNames=t}},Qme=class extends Error{toolName;errors;constructor(t,e){super(`Failed to parse structured output for tool '${t}':${e.map(r=>`
1185
1185
  - ${r}`).join("")}.`),this.toolName=t,this.errors=e}},ehe=class extends Error{"~brand"="ToolInvocationError";toolCall;toolError;constructor(t,e){let r=t instanceof Error?t:new Error(String(t)),n=JSON.stringify(e.args);super(`Error invoking tool '${e.name}' with kwargs ${n} with error: ${r.stack}
package/index.cjs.map CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/index.cjs.map
3
- size: 43273367 bytes
4
- sha256: 7c054923315a9f2ae20ddeadc6c587b99fe6f3c957a6e7be74f69622d8297e5f
3
+ size: 43273459 bytes
4
+ sha256: 82c47825ab35d3991da6cb69aa8c769c9d970daffd0896f5d3392d4810857dc2
@@ -15,6 +15,7 @@ export declare const TemplateSchema: z.ZodObject<{
15
15
  website: z.ZodOptional<z.ZodURL>;
16
16
  }, z.core.$strip>]>>>;
17
17
  tenantIdentifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
18
+ internal: z.ZodOptional<z.ZodBoolean>;
18
19
  datasets: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
19
20
  name: z.ZodString;
20
21
  description: z.ZodString;
@@ -265,6 +266,7 @@ export interface TemplateInterface {
265
266
  logo?: string;
266
267
  author?: string | AuthorInterface;
267
268
  tenantIdentifier?: string;
269
+ internal?: boolean;
268
270
  datasets: DatasetsInterface;
269
271
  semanticTriggers: SemanticTriggersInterface;
270
272
  connectors?: ConnectorsInterface;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transai/connector-runner-ai-agent",
3
- "version": "0.53.7",
3
+ "version": "0.53.8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },