lody 0.2.8 → 0.2.9

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.
Files changed (2) hide show
  1. package/dist/index.cjs +2 -2
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -158,7 +158,7 @@ Url: ${SN(t)}`),!0}return!1}function _yt(t,e){return e?.length?mN(t).some(r=>Qp(
158
158
  `;let c=MAe(i);i.write(`${a}\r
159
159
  `);let{connect:u,buffered:l}=await c;if(e.emit("proxyConnect",u),this.emit("proxyConnect",u,e),u.statusCode===200){if(e.once("socket",ext),r.secureEndpoint){W1("Upgrading socket connection to TLS");let d=r.servername||r.host;return Y$.connect({...LAe(r,"host","path","port"),socket:i,servername:dh.isIP(d)?void 0:d})}return i}i.destroy();let f=new dh.Socket({writable:!1});return f.readable=!0,e.once("socket",d=>{W1("Replaying proxy buffer for failed request"),d.push(l),d.push(null)}),f}};Y1.__initStatic();function ext(t){t.resume()}function LAe(t,...e){let r={},n;for(n in t)e.includes(n)||(r[n]=t[n]);return r}var nxt=1024*32;function ixt(t){return new FAe.Readable({read(){this.push(t),this.push(null)}})}function z$(t){let e;try{e=new URL(t.url)}catch{return hi(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),g1(t,()=>Promise.resolve({}))}let r=e.protocol==="https:",n=sxt(e,t.proxy||(r?process.env.https_proxy:void 0)||process.env.http_proxy),i=r?rxt:txt,s=t.keepAlive===void 0?!1:t.keepAlive,o=n?new Y1(n):new i.Agent({keepAlive:s,maxSockets:30,timeout:2e3}),a=oxt(t,t.httpModule??i,o);return g1(t,a)}function sxt(t,e){let{no_proxy:r}=process.env;if(!r?.split(",").some(i=>t.host.endsWith(i)||t.hostname.endsWith(i)))return e}function oxt(t,e,r){let{hostname:n,pathname:i,port:s,protocol:o,search:a}=new URL(t.url);return function(u){return new Promise((l,f)=>{AS(()=>{let d=ixt(u.body),h={...t.headers};u.body.length>nxt&&(h["content-encoding"]="gzip",d=d.pipe((0,BAe.createGzip)()));let p=e.request({method:"POST",agent:r,headers:h,hostname:n,path:`${i}${a}`,port:s,protocol:o,ca:t.caCerts},_=>{_.on("data",()=>{}),_.on("end",()=>{}),_.setEncoding("utf8");let g=_.headers["retry-after"]??null,S=_.headers["x-sentry-rate-limits"]??null;l({statusCode:_.statusCode,headers:{"retry-after":g,"x-sentry-rate-limits":Array.isArray(S)?S[0]||null:S}})});p.on("error",f),d.pipe(p)})})}}var axt=new Set(["false","f","n","no","off","0"]),cxt=new Set(["true","t","y","yes","on","1"]);function VP(t,e){let r=String(t).toLowerCase();return axt.has(r)?!1:cxt.has(r)?!0:e?.strict?null:!!t}var WP=require("node:path");function UAe(t){return t.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}function K$(t=process.argv[1]?eG(process.argv[1]):process.cwd(),e=WP.sep==="\\"){let r=e?UAe(t):t;return n=>{if(!n)return;let i=e?UAe(n):n,{dir:s,base:o,ext:a}=WP.posix.parse(i);(a===".js"||a===".mjs"||a===".cjs")&&(o=o.slice(0,a.length*-1));let c=decodeURIComponent(o);s||(s=".");let u=s.lastIndexOf("/node_modules");if(u>-1)return`${s.slice(u+14).replace(/\//g,".")}:${c}`;if(s.startsWith(r)){let l=s.slice(r.length+1).replace(/\//g,".");return l?`${l}:${c}`:c}return c}}function Q$(t){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;if(Ut.SENTRY_RELEASE?.id)return Ut.SENTRY_RELEASE.id;let e=process.env.GITHUB_SHA||process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA||process.env.CI_BUILD_REF||process.env.CI_COMMIT_SHA||process.env.BITBUCKET_COMMIT,r=process.env.APPVEYOR_PULL_REQUEST_HEAD_COMMIT||process.env.APPVEYOR_REPO_COMMIT||process.env.CODEBUILD_RESOLVED_SOURCE_VERSION||process.env.AWS_COMMIT_ID||process.env.BUILD_SOURCEVERSION||process.env.GIT_CLONE_COMMIT_HASH||process.env.BUDDY_EXECUTION_REVISION||process.env.BUILDKITE_COMMIT||process.env.CIRCLE_SHA1||process.env.CIRRUS_CHANGE_IN_REPO||process.env.CF_REVISION||process.env.CM_COMMIT||process.env.CF_PAGES_COMMIT_SHA||process.env.DRONE_COMMIT_SHA||process.env.FC_GIT_COMMIT_SHA||process.env.HEROKU_TEST_RUN_COMMIT_VERSION||process.env.HEROKU_SLUG_COMMIT||process.env.RAILWAY_GIT_COMMIT_SHA||process.env.RENDER_GIT_COMMIT||process.env.SEMAPHORE_GIT_SHA||process.env.TRAVIS_PULL_REQUEST_SHA||process.env.VERCEL_GIT_COMMIT_SHA||process.env.VERCEL_GITHUB_COMMIT_SHA||process.env.VERCEL_GITLAB_COMMIT_SHA||process.env.VERCEL_BITBUCKET_COMMIT_SHA||process.env.ZEIT_GITHUB_COMMIT_SHA||process.env.ZEIT_GITLAB_COMMIT_SHA||process.env.ZEIT_BITBUCKET_COMMIT_SHA,n=process.env.CI_COMMIT_ID||process.env.SOURCE_COMMIT||process.env.SOURCE_VERSION||process.env.GIT_COMMIT||process.env.COMMIT_REF||process.env.BUILD_VCS_NUMBER||process.env.CI_COMMIT_SHA;return e||r||n||t}var J$=U2(TG(K$()));var qAe=he(require("node:os"),1);Fe();var jAe=he(Qt(),1);var YP=require("worker_threads");var uxt=6e4,z1=class extends E1{constructor(e){let r=e.includeServerName===!1?void 0:e.serverName||global.process.env.SENTRY_NAME||qAe.hostname(),n={...e,platform:"node",runtime:{name:"node",version:global.process.version},serverName:r};e.openTelemetryInstrumentations&&(0,jAe.registerInstrumentations)({instrumentations:e.openTelemetryInstrumentations}),Eg(n,"node"),ne.log(`Initializing Sentry: process: ${process.pid}, thread: ${YP.isMainThread?"main":`worker-${YP.threadId}`}.`),super(n),this.getOptions().enableLogs&&(this._logOnExitFlushListener=()=>{IS(this)},r&&this.on("beforeCaptureLog",i=>{i.attributes={...i.attributes,"server.address":r}}),process.on("beforeExit",this._logOnExitFlushListener))}get tracer(){if(this._tracer)return this._tracer;let e="@sentry/node",r=kr,n=Ft.getTracer(e,r);return this._tracer=n,n}async flush(e){return await this.traceProvider?.forceFlush(),this.getOptions().sendClientReports&&this._flushOutcomes(),super.flush(e)}async close(e){this._clientReportInterval&&clearInterval(this._clientReportInterval),this._clientReportOnExitFlushListener&&process.off("beforeExit",this._clientReportOnExitFlushListener),this._logOnExitFlushListener&&process.off("beforeExit",this._logOnExitFlushListener);let r=await super.close(e);return this.traceProvider&&await this.traceProvider.shutdown(),r}startClientReportTracking(){let e=this.getOptions();e.sendClientReports&&(this._clientReportOnExitFlushListener=()=>{this._flushOutcomes()},this._clientReportInterval=setInterval(()=>{yr&&ne.log("Flushing client reports based on interval."),this._flushOutcomes()},e.clientReportFlushInterval??uxt).unref(),process.on("beforeExit",this._clientReportOnExitFlushListener))}_setupIntegrations(){zH(),super._setupIntegrations()}_getTraceInfoFromScope(e){return e?qTe(this,e):[void 0,void 0]}};var HAe=he(Bj(),1),GAe=he(require("module"),1);var lxt={};function X$(){if(xAe()&&!Ut._sentryEsmLoaderHookRegistered){Ut._sentryEsmLoaderHookRegistered=!0;try{let{addHookMessagePort:t}=(0,HAe.createAddHookMessageChannel)();GAe.register("import-in-the-middle/hook.mjs",lxt.url,{data:{addHookMessagePort:t,include:[]},transferList:[t]})}catch(t){ne.warn("Failed to register 'import-in-the-middle' hook",t)}}}function zP(){return[bN(),yN(),vN(),TN(),B$(),AN(),tAe(),sAe(),k$(),M$(),D$(),O$(),C$(),q$(),kAe(),P$()]}function Z$(t={}){return fxt(t,zP)}function fxt(t={},e){let r=dxt(t,e);r.debug===!0&&(yr?ne.enable():hi(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),r.registerEsmLoaderHooks!==!1&&X$(),GTe(),Gr().update(r.initialScope),r.spotlight&&!r.integrations.some(({name:s})=>s===L$)&&r.integrations.push(F$({sidecarUrl:typeof r.spotlight=="string"?r.spotlight:void 0})),Eg(r,"node-core");let i=new z1(r);return Gr().setClient(i),i.init(),Ut._sentryInjectLoaderHookRegister?.(),ne.log(`SDK initialized from ${H1()?"CommonJS":"ESM"}`),i.startClientReportTracking(),mxt(),CTe(i),HTe(i),i}function KP(){if(!yr)return;let t=OTe(),e=["SentryContextManager","SentryPropagator"];Hi()&&e.push("SentrySpanProcessor");for(let r of e)t.includes(r)||ne.error(`You have to set up the ${r}. Without this, the OpenTelemetry & Sentry integration will not work properly.`);t.includes("SentrySampler")||ne.warn("You have to set up the SentrySampler. Without this, the OpenTelemetry & Sentry integration may still work, but sample rates set for the Sentry SDK will not be respected. If you use a custom sampler, make sure to use `wrapSamplingDecision`.")}function dxt(t,e){let r=hxt(t.release),n;if(t.spotlight===!1)n=!1;else if(typeof t.spotlight=="string")n=t.spotlight;else{let c=VP(process.env.SENTRY_SPOTLIGHT,{strict:!0}),u=c===null&&process.env.SENTRY_SPOTLIGHT?process.env.SENTRY_SPOTLIGHT:void 0;n=t.spotlight===!0?u??!0:c??u}let i=pxt(t.tracesSampleRate),s={...t,dsn:t.dsn??process.env.SENTRY_DSN,environment:t.environment??"production",sendClientReports:t.sendClientReports??!0,transport:t.transport??z$,stackParser:Zj(t.stackParser||J$),release:r,tracesSampleRate:i,spotlight:n,debug:VP(t.debug??process.env.SENTRY_DEBUG)},o=t.integrations,a=t.defaultIntegrations??e(s);return{...s,integrations:BH({defaultIntegrations:a,integrations:o})}}function hxt(t){if(t!==void 0)return t;let e=Q$();if(e!==void 0)return e}function pxt(t){if(t!==void 0)return t;let e=process.env.SENTRY_TRACES_SAMPLE_RATE;if(!e)return;let r=parseFloat(e);return isFinite(r)?r:void 0}function mxt(){if(VP(process.env.SENTRY_USE_ENVIRONMENT)!==!1){let t=process.env.SENTRY_TRACE,e=process.env.SENTRY_BAGGAGE,r=s1(t,e);Gr().setPropagationContext(r)}}function An(t,e){t.setAttribute(zt,e)}var eV="Http",$Ae="@opentelemetry_sentry-patched/instrumentation-http",_xt=at(`${eV}.sentry`,t=>new wg(t)),gxt=at(eV,t=>{let e=new VAe.HttpInstrumentation({...t,disableIncomingRequestInstrumentation:!0});try{e._diag=Zo.createComponentLogger({namespace:$Ae}),e.instrumentationName=$Ae}catch{}return e});function Ext(t,e={}){return typeof t.spans=="boolean"?t.spans:!(e.skipOpenTelemetrySetup||!Hi(e)&&_m.major>=22)}var WAe=(t={})=>{let e=t.spans??!0,r=t.disableIncomingRequestSpans,n={sessions:t.trackIncomingRequestsAsSessions,sessionFlushingDelayMS:t.sessionFlushingDelayMS,ignoreRequestBody:t.ignoreIncomingRequestBody,maxRequestBodySize:t.maxIncomingRequestBodySize},i={ignoreIncomingRequests:t.ignoreIncomingRequests,ignoreStaticAssets:t.ignoreStaticAssets,ignoreStatusCodes:t.dropSpansForIncomingRequestStatusCodes,instrumentation:t.instrumentation,onSpanCreated:t.incomingRequestSpanHook},s=FS(n),o=BS(i),a=e&&!r;return{name:eV,setup(c){let u=c.getOptions();a&&Hi(u)&&o.setup(c)},setupOnce(){let c=Ve()?.getOptions()||{},u=Ext(t,c);s.setupOnce();let l={breadcrumbs:t.breadcrumbs,propagateTraceInOutgoingRequests:!u,ignoreOutgoingRequests:t.ignoreOutgoingRequests};if(_xt(l),u){let f=yxt(t);gxt(f)}},processEvent(c){return o.processEvent(c)}}};function yxt(t={}){return{ignoreOutgoingRequestHook:r=>{let n=I1(r);if(!n)return!1;let i=t.ignoreOutgoingRequests;return!!i?.(n,r)},requireParentforOutgoingSpans:!1,requestHook:(r,n)=>{An(r,"auto.http.otel.http"),t.instrumentation?.requestHook?.(r,n)},responseHook:(r,n)=>{t.instrumentation?.responseHook?.(r,n)},applyCustomAttributesOnSpan:(r,n,i)=>{t.instrumentation?.applyCustomAttributesOnSpan?.(r,n,i)}}}var JAe=he(QAe(),1);var XAe="NodeFetch",vxt=at(XAe,JAe.UndiciInstrumentation,t=>Cxt(t)),Txt=at(`${XAe}.sentry`,Cg,t=>t),Axt=(t={})=>({name:"NodeFetch",setupOnce(){wxt(t,Ve()?.getOptions())&&vxt(t),Txt(t)}}),ZAe=Axt;function xxt(t,e="/"){let r=`${t}`;return r.endsWith("/")&&e.startsWith("/")?`${r}${e.slice(1)}`:!r.endsWith("/")&&!e.startsWith("/")?`${r}/${e.slice(1)}`:`${r}${e}`}function wxt(t,e={}){return typeof t.spans=="boolean"?t.spans:!e.skipOpenTelemetrySetup&&Hi(e)}function Cxt(t={}){return{requireParentforSpans:!1,ignoreRequestHook:r=>{let n=xxt(r.origin,r.path),i=t.ignoreOutgoingRequests;return!!(i&&n&&i(n))},startSpanHook:()=>({[zt]:"auto.http.otel.node_fetch"}),requestHook:t.requestHook,responseHook:t.responseHook}}var lxe=he(uxe(),1);var Zc=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var fxe="Express";function Gxt(t){An(t,"auto.http.otel.express");let e=It(t).data,r=e["express.type"];r&&t.setAttribute(bt,`${r}.express`);let n=e["express.name"];typeof n=="string"&&t.updateName(n)}function $xt(t,e){if(vr()===zc())return Zc&&ne.warn("Isolation scope is still default isolation scope - skipping setting transactionName"),e;if(t.layerType==="request_handler"){let r=t.request,n=r.method?r.method.toUpperCase():"GET";vr().setTransactionName(`${n} ${t.route}`)}return e}var dxe=at(fxe,()=>new lxe.ExpressInstrumentation({requestHook:t=>Gxt(t),spanNameHook:(t,e)=>$xt(t,e)})),Vxt=()=>({name:fxe,setupOnce(){dxe()}}),hxe=Vxt;var dV=he(require("node:diagnostics_channel"),1);var lV=he(require("node:diagnostics_channel"),1);Fe();var ak=he(sn(),1),Gxe=he(Qt(),1);mn();var kxe=he(wxe(),1);var Z1=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};var Zxt={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},ew=t=>t.replace(/[[\]\\-]/g,"\\$&"),e1t=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Cxe=t=>t.join(""),Ixe=(t,e)=>{let r=e;if(t.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,o=!1,a=!1,c=!1,u=!1,l=r,f="";e:for(;s<t.length;){let _=t.charAt(s);if((_==="!"||_==="^")&&s===r+1){u=!0,s++;continue}if(_==="]"&&o&&!c){l=s+1;break}if(o=!0,_==="\\"&&!c){c=!0,s++;continue}if(_==="["&&!c){for(let[g,[S,b,x]]of Object.entries(Zxt))if(t.startsWith(g,s)){if(f)return["$.",!1,t.length-r,!0];s+=g.length,x?i.push(S):n.push(S),a=a||b;continue e}}if(c=!1,f){_>f?n.push(ew(f)+"-"+ew(_)):_===f&&n.push(ew(_)),f="",s++;continue}if(t.startsWith("-]",s+1)){n.push(ew(_+"-")),s+=2;continue}if(t.startsWith("-",s+1)){f=_,s+=2;continue}n.push(ew(_)),s++}if(l<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,t.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let _=n[0].length===2?n[0].slice(-1):n[0];return[e1t(_),!1,l-r,!1]}let d="["+(u?"^":"")+Cxe(n)+"]",h="["+(u?"":"^")+Cxe(i)+"]";return[n.length&&i.length?"("+d+"|"+h+")":n.length?d:h,a,l-r,!0]};var Em=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var t1t=new Set(["!","?","+","*","@"]),Dxe=t=>t1t.has(t),r1t="(?!(?:^|/)\\.\\.?(?:$|/))",ik="(?!\\.)",n1t=new Set(["[","."]),i1t=new Set(["..","."]),s1t=new Set("().*{}+?[]^$\\!"),o1t=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),cV="[^/]",Rxe=cV+"*?",Oxe=cV+"+?",ib=class t{type;#e;#n;#t=!1;#r=[];#s;#i;#a;#o=!1;#c;#h;#l=!1;constructor(e,r,n={}){this.type=e,e&&(this.#n=!0),this.#s=r,this.#e=this.#s?this.#s.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#a=this.#e===this?[]:this.#e.#a,e==="!"&&!this.#e.#o&&this.#a.push(this),this.#i=this.#s?this.#s.#r.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let e of this.#r)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#h!==void 0?this.#h:this.type?this.#h=this.type+"("+this.#r.map(e=>String(e)).join("|")+")":this.#h=this.#r.map(e=>String(e)).join("")}#f(){if(this!==this.#e)throw new Error("should only call on root");if(this.#o)return this;this.toString(),this.#o=!0;let e;for(;e=this.#a.pop();){if(e.type!=="!")continue;let r=e,n=r.#s;for(;n;){for(let i=r.#i+1;!n.type&&i<n.#r.length;i++)for(let s of e.#r){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#r[i])}r=n,n=r.#s}}return this}push(...e){for(let r of e)if(r!==""){if(typeof r!="string"&&!(r instanceof t&&r.#s===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let e=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#o&&this.#s?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#s?.isStart())return!1;if(this.#i===0)return!0;let e=this.#s;for(let r=0;r<this.#i;r++){let n=e.#r[r];if(!(n instanceof t&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#s?.type==="!")return!0;if(!this.#s?.isEnd())return!1;if(!this.type)return this.#s?.isEnd();let e=this.#s?this.#s.#r.length:0;return this.#i===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let r=new t(this.type,e);for(let n of this.#r)r.copyIn(n);return r}static#u(e,r,n,i){let s=!1,o=!1,a=-1,c=!1;if(r.type===null){let h=n,p="";for(;h<e.length;){let _=e.charAt(h++);if(s||_==="\\"){s=!s,p+=_;continue}if(o){h===a+1?(_==="^"||_==="!")&&(c=!0):_==="]"&&!(h===a+2&&c)&&(o=!1),p+=_;continue}else if(_==="["){o=!0,a=h,c=!1,p+=_;continue}if(!i.noext&&Dxe(_)&&e.charAt(h)==="("){r.push(p),p="";let g=new t(_,r);h=t.#u(e,g,h,i),r.push(g);continue}p+=_}return r.push(p),h}let u=n+1,l=new t(null,r),f=[],d="";for(;u<e.length;){let h=e.charAt(u++);if(s||h==="\\"){s=!s,d+=h;continue}if(o){u===a+1?(h==="^"||h==="!")&&(c=!0):h==="]"&&!(u===a+2&&c)&&(o=!1),d+=h;continue}else if(h==="["){o=!0,a=u,c=!1,d+=h;continue}if(Dxe(h)&&e.charAt(u)==="("){l.push(d),d="";let p=new t(h,l);l.push(p),u=t.#u(e,p,u,i);continue}if(h==="|"){l.push(d),d="",f.push(l),l=new t(null,r);continue}if(h===")")return d===""&&r.#r.length===0&&(r.#l=!0),l.push(d),d="",r.push(...f,l),u;d+=h}return r.type=null,r.#n=void 0,r.#r=[e.substring(n-1)],u}static fromGlob(e,r={}){let n=new t(null,void 0,r);return t.#u(e,n,0,r),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#n||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:e})}get options(){return this.#c}toRegExpSource(e){let r=e??!!this.#c.dot;if(this.#e===this&&this.#f(),!this.type){let c=this.isStart()&&this.isEnd(),u=this.#r.map(h=>{let[p,_,g,S]=typeof h=="string"?t.#p(h,this.#n,c):h.toRegExpSource(e);return this.#n=this.#n||g,this.#t=this.#t||S,p}).join(""),l="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&i1t.has(this.#r[0]))){let p=n1t,_=r&&p.has(u.charAt(0))||u.startsWith("\\.")&&p.has(u.charAt(2))||u.startsWith("\\.\\.")&&p.has(u.charAt(4)),g=!r&&!e&&p.has(u.charAt(0));l=_?r1t:g?ik:""}let f="";return this.isEnd()&&this.#e.#o&&this.#s?.type==="!"&&(f="(?:$|\\/)"),[l+u+f,Em(u),this.#n=!!this.#n,this.#t]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#d(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString();return this.#r=[c],this.type=null,this.#n=void 0,[c,Em(this.toString()),!1,!1]}let o=!n||e||r||!ik?"":this.#d(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let a="";if(this.type==="!"&&this.#l)a=(this.isStart()&&!r?ik:"")+Oxe;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!e?ik:"")+Rxe+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=i+s+c}return[a,Em(s),this.#n=!!this.#n,this.#t]}#d(e){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,o]=r.toRegExpSource(e);return this.#t=this.#t||o,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#p(e,r,n=!1){let i=!1,s="",o=!1;for(let a=0;a<e.length;a++){let c=e.charAt(a);if(i){i=!1,s+=(s1t.has(c)?"\\":"")+c;continue}if(c==="\\"){a===e.length-1?s+="\\\\":i=!0;continue}if(c==="["){let[u,l,f,d]=Ixe(e,a);if(f){s+=u,o=o||l,a+=f-1,r=r||d;continue}}if(c==="*"){n&&e==="*"?s+=Oxe:s+=Rxe,r=!0;continue}if(c==="?"){s+=cV,r=!0;continue}s+=o1t(c)}return[s,Em(e),!!r,o]}};var uV=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var oo=(t,e,r={})=>(Z1(e),!r.nocomment&&e.charAt(0)==="#"?!1:new sb(e,r).match(t)),a1t=/^\*+([^+@!?\*\[\(]*)$/,c1t=t=>e=>!e.startsWith(".")&&e.endsWith(t),u1t=t=>e=>e.endsWith(t),l1t=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),f1t=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),d1t=/^\*+\.\*+$/,h1t=t=>!t.startsWith(".")&&t.includes("."),p1t=t=>t!=="."&&t!==".."&&t.includes("."),m1t=/^\.\*+$/,_1t=t=>t!=="."&&t!==".."&&t.startsWith("."),g1t=/^\*+$/,E1t=t=>t.length!==0&&!t.startsWith("."),y1t=t=>t.length!==0&&t!=="."&&t!=="..",S1t=/^\?+([^+@!?\*\[\(]*)?$/,b1t=([t,e=""])=>{let r=Mxe([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},v1t=([t,e=""])=>{let r=Lxe([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},T1t=([t,e=""])=>{let r=Lxe([t]);return e?n=>r(n)&&n.endsWith(e):r},A1t=([t,e=""])=>{let r=Mxe([t]);return e?n=>r(n)&&n.endsWith(e):r},Mxe=([t])=>{let e=t.length;return r=>r.length===e&&!r.startsWith(".")},Lxe=([t])=>{let e=t.length;return r=>r.length===e&&r!=="."&&r!==".."},Fxe=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Nxe={win32:{sep:"\\"},posix:{sep:"/"}},x1t=Fxe==="win32"?Nxe.win32.sep:Nxe.posix.sep;oo.sep=x1t;var tu=Symbol("globstar **");oo.GLOBSTAR=tu;var w1t="[^/]",C1t=w1t+"*?",I1t="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",D1t="(?:(?!(?:\\/|^)\\.).)*?",R1t=(t,e={})=>r=>oo(r,t,e);oo.filter=R1t;var eu=(t,e={})=>Object.assign({},t,e),O1t=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return oo;let e=oo;return Object.assign((n,i,s={})=>e(n,i,eu(t,s)),{Minimatch:class extends e.Minimatch{constructor(i,s={}){super(i,eu(t,s))}static defaults(i){return e.defaults(eu(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,s,o={}){super(i,s,eu(t,o))}static fromGlob(i,s={}){return e.AST.fromGlob(i,eu(t,s))}},unescape:(n,i={})=>e.unescape(n,eu(t,i)),escape:(n,i={})=>e.escape(n,eu(t,i)),filter:(n,i={})=>e.filter(n,eu(t,i)),defaults:n=>e.defaults(eu(t,n)),makeRe:(n,i={})=>e.makeRe(n,eu(t,i)),braceExpand:(n,i={})=>e.braceExpand(n,eu(t,i)),match:(n,i,s={})=>e.match(n,i,eu(t,s)),sep:e.sep,GLOBSTAR:tu})};oo.defaults=O1t;var Bxe=(t,e={})=>(Z1(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:(0,kxe.default)(t));oo.braceExpand=Bxe;var N1t=(t,e={})=>new sb(t,e).makeRe();oo.makeRe=N1t;var P1t=(t,e,r={})=>{let n=new sb(e,r);return t=t.filter(i=>n.match(i)),n.options.nonull&&!t.length&&t.push(e),t};oo.match=P1t;var Pxe=/[?*]|[+@!]\(.*?\)|\[|\]/,k1t=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),sb=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,r={}){Z1(e),r=r||{},this.options=r,this.pattern=e,this.platform=r.platform||Fxe,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let r of e)if(typeof r!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,r=this.options;if(!r.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!Pxe.test(s[2]))&&!Pxe.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(l=>this.parse(l))];if(u)return[s[0],...s.slice(1).map(l=>this.parse(l))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let n=0;n<e.length;n++)for(let i=0;i<e[n].length;i++)e[n][i]==="**"&&(e[n][i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):r>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(e){return e.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let s=e[i];i===1&&s===""&&e[0]===""||(s==="."||s==="")&&(r=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(r=!0,e.pop())}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let i=e[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(r=!0,e.splice(n-1,2),n-=2)}}while(r);return e.length===0?[""]:e}firstPhasePreProcess(e){let r=!1;do{r=!1;for(let n of e){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let a=n[i+1],c=n[i+2],u=n[i+3];if(a!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(i,1);let l=n.slice(0);l[i]="**",e.push(l),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let o=n[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){r=!0;let c=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...c),n.length===0&&n.push(""),s-=2}}}}while(r);return e}secondPhasePreProcess(e){for(let r=0;r<e.length-1;r++)for(let n=r+1;n<e.length;n++){let i=this.partsMatch(e[r],e[n],!this.preserveMultipleSlashes);if(i){e[r]=[],e[n]=i;break}}return e.filter(r=>r.length)}partsMatch(e,r,n=!1){let i=0,s=0,o=[],a="";for(;i<e.length&&s<r.length;)if(e[i]===r[s])o.push(a==="b"?r[s]:e[i]),i++,s++;else if(n&&e[i]==="**"&&r[s]===e[i+1])o.push(e[i]),i++;else if(n&&r[s]==="**"&&e[i]===r[s+1])o.push(r[s]),s++;else if(e[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(a==="b")return!1;a="a",o.push(e[i]),i++,s++}else if(r[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return!1;a="b",o.push(r[s]),i++,s++}else return!1;return e.length===r.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,r=!1,n=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=e.slice(n)),this.negate=r}matchOne(e,r,n=!1){let i=this.options;if(this.isWindows){let _=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),g=!_&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),S=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),b=!S&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),x=g?3:_?0:void 0,A=b?3:S?0:void 0;if(typeof x=="number"&&typeof A=="number"){let[N,C]=[e[x],r[A]];N.toLowerCase()===C.toLowerCase()&&(r[A]=N,A>x?r=r.slice(A):x>A&&(e=e.slice(x)))}}let{optimizationLevel:s=1}=this.options;s>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:r}),this.debug("matchOne",e.length,r.length);for(var o=0,a=0,c=e.length,u=r.length;o<c&&a<u;o++,a++){this.debug("matchOne loop");var l=r[a],f=e[o];if(this.debug(r,l,f),l===!1)return!1;if(l===tu){this.debug("GLOBSTAR",[r,l,f]);var d=o,h=a+1;if(h===u){for(this.debug("** at the end");o<c;o++)if(e[o]==="."||e[o]===".."||!i.dot&&e[o].charAt(0)===".")return!1;return!0}for(;d<c;){var p=e[d];if(this.debug(`
160
160
  globstar while`,e,d,r,h,p),this.matchOne(e.slice(d),r.slice(h),n))return this.debug("globstar found match!",d,c,p),!0;if(p==="."||p===".."||!i.dot&&p.charAt(0)==="."){this.debug("dot detected!",e,d,r,h);break}this.debug("globstar swallow a segment, and continue"),d++}return!!(n&&(this.debug(`
161
- >>> no match, partial?`,e,d,r,h),d===c))}let _;if(typeof l=="string"?(_=f===l,this.debug("string match",l,f,_)):(_=l.test(f),this.debug("pattern match",l,f,_)),!_)return!1}if(o===c&&a===u)return!0;if(o===c)return n;if(a===u)return o===c-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return Bxe(this.pattern,this.options)}parse(e){Z1(e);let r=this.options;if(e==="**")return tu;if(e==="")return"";let n,i=null;(n=e.match(g1t))?i=r.dot?y1t:E1t:(n=e.match(a1t))?i=(r.nocase?r.dot?f1t:l1t:r.dot?u1t:c1t)(n[1]):(n=e.match(S1t))?i=(r.nocase?r.dot?v1t:b1t:r.dot?T1t:A1t)(n):(n=e.match(d1t))?i=r.dot?p1t:h1t:(n=e.match(m1t))&&(i=_1t);let s=ib.fromGlob(e,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?C1t:r.dot?I1t:D1t,i=new Set(r.nocase?["i"]:[]),s=e.map(c=>{let u=c.map(l=>{if(l instanceof RegExp)for(let f of l.flags.split(""))i.add(f);return typeof l=="string"?k1t(l):l===tu?tu:l._src});return u.forEach((l,f)=>{let d=u[f+1],h=u[f-1];l!==tu||h===tu||(h===void 0?d!==void 0&&d!==tu?u[f+1]="(?:\\/|"+n+"\\/)?"+d:u[f]=n:d===void 0?u[f-1]=h+"(?:\\/|"+n+")?":d!==tu&&(u[f-1]=h+"(?:\\/|\\/"+n+"\\/)"+d,u[f+1]=tu))}),u.filter(l=>l!==tu).join("/")}).join("|"),[o,a]=e.length>1?["(?:",")"]:["",""];s="^"+o+s+a+"$",this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,r=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&r)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a=0;a<s.length;a++){let c=s[a],u=i;if(n.matchBase&&c.length===1&&(u=[o]),this.matchOne(u,c,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return oo.defaults(e).Minimatch}};oo.AST=ib;oo.Minimatch=sb;oo.escape=uV;oo.unescape=Em;var Uxe="@fastify/otel",L1t="0.8.0",F1t=">=4.0.0 <6",qxe=["onRequest","preParsing","preValidation","preHandler","preSerialization","onSend","onResponse","onError"],Yn={HOOK_NAME:"hook.name",FASTIFY_TYPE:"fastify.type",HOOK_CALLBACK_NAME:"hook.callback.name",ROOT:"fastify.root"},ym={ROUTE:"route-hook",INSTANCE:"hook",HANDLER:"request-handler"},hh="anonymous",aa=Symbol("fastify otel instance"),Sm=Symbol("fastify otel request spans"),tw=Symbol("fastify otel request context"),jxe=Symbol("fastify otel addhook original"),Hxe=Symbol("fastify otel setnotfound original"),sk=Symbol("fastify otel ignore path"),ok=class extends Gxe.InstrumentationBase{constructor(e){if(super(Uxe,L1t,e),this.servername=e?.servername??process.env.OTEL_SERVICE_NAME??"fastify",this[sk]=null,this._logger=Zo.createComponentLogger({namespace:Uxe}),e?.ignorePaths!=null||process.env.OTEL_FASTIFY_IGNORE_PATHS!=null){let r=e?.ignorePaths??process.env.OTEL_FASTIFY_IGNORE_PATHS;if((typeof r!="string"||r.length===0)&&typeof r!="function")throw new TypeError("ignorePaths must be a string or a function");let n=oo;this[sk]=i=>typeof r=="function"?r(i):n(i.url,r)}}enable(){if(this._handleInitialization===void 0&&this.getConfig().registerOnInitialization){let e=this.plugin();this._handleInitialization=r=>{r.fastify.register(e)},lV.default.subscribe("fastify.initialization",this._handleInitialization)}return super.enable()}disable(){return this._handleInitialization&&(lV.default.unsubscribe("fastify.initialization",this._handleInitialization),this._handleInitialization=void 0),super.disable()}init(){return[]}plugin(){let e=this;return r[Symbol.for("skip-override")]=!0,r[Symbol.for("fastify.display-name")]="@fastify/otel",r[Symbol.for("plugin-meta")]={fastify:F1t,name:"@fastify/otel"},r;function r(n,i,s){n.decorate(aa,e),n.decorate(jxe,n.addHook),n.decorate(Hxe,n.setNotFoundHandler),n.decorateRequest("opentelemetry",function(){let d=this[tw];return{span:this[Sm],tracer:e.tracer,context:d,inject:(p,_)=>ea.inject(d,p,_),extract:(p,_)=>ea.extract(d,p,_)}}),n.decorateRequest(Sm,null),n.decorateRequest(tw,null),n.addHook("onRoute",function(f){if(e[sk]?.(f)===!0){e._logger.debug(`Ignoring route instrumentation ${f.method} ${f.url} because it matches the ignore path`);return}for(let d of qxe)if(f[d]!=null){let h=f[d];if(typeof h=="function")f[d]=l(h,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - route -> ${d}`,[Yn.FASTIFY_TYPE]:ym.ROUTE,[ba]:f.url,[Yn.HOOK_CALLBACK_NAME]:h.name?.length>0?h.name:hh});else if(Array.isArray(h)){let p=[];for(let _ of h)p.push(l(_,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - route -> ${d}`,[Yn.FASTIFY_TYPE]:ym.ROUTE,[ba]:f.url,[Yn.HOOK_CALLBACK_NAME]:_.name?.length>0?_.name:hh}));f[d]=p}}f.onSend!=null?f.onSend=Array.isArray(f.onSend)?[...f.onSend,o]:[f.onSend,o]:f.onSend=o,f.onError!=null?f.onError=Array.isArray(f.onError)?[...f.onError,a]:[f.onError,a]:f.onError=a,f.handler=l(f.handler,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - route-handler`,[Yn.FASTIFY_TYPE]:ym.HANDLER,[ba]:f.url,[Yn.HOOK_CALLBACK_NAME]:f.handler.name.length>0?f.handler.name:hh})}),n.addHook("onRequest",function(f,d,h){if(this[aa].isEnabled()===!1)return h();if(this[aa][sk]?.({url:f.url,method:f.method})===!0)return this[aa]._logger.debug(`Ignoring request ${f.method} ${f.url} because it matches the ignore path`),h();let p=Je.active();Ft.getSpan(p)==null&&(p=ea.extract(p,f.headers));let _=(0,ak.getRPCMetadata)(p);f.routeOptions.url!=null&&_?.type===ak.RPCType.HTTP&&(_.route=f.routeOptions.url);let g=this[aa].tracer.startSpan("request",{attributes:{[lc]:n[aa].servername,[Yn.ROOT]:"@fastify/otel",[ba]:f.url,[Xd]:f.method}},p);f[tw]=Ft.setSpan(p,g),f[Sm]=g,Je.with(f[tw],()=>{h()})}),n.addHook("onResponse",function(f,d,h){let p=f[Sm];p!=null&&(p.setStatus({code:ti.OK,message:"OK"}),p.setAttributes({[cf]:404}),p.end()),f[Sm]=null,h()}),n.addHook=c,n.setNotFoundHandler=u,s();function o(f,d,h,p){let _=f[Sm];_!=null&&(d.statusCode<500&&_.setStatus({code:ti.OK,message:"OK"}),_.setAttributes({[cf]:d.statusCode}),_.end()),f[Sm]=null,p(null,h)}function a(f,d,h,p){let _=f[Sm];_!=null&&(_.setStatus({code:ti.ERROR,message:h.message}),_.recordException(h)),p()}function c(f,d){let h=this[jxe];return qxe.includes(f)?h.call(this,f,l(d,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - ${f}`,[Yn.FASTIFY_TYPE]:ym.INSTANCE,[Yn.HOOK_CALLBACK_NAME]:d.name?.length>0?d.name:hh})):h.call(this,f,d)}function u(f,d){let h=this[Hxe];typeof f=="function"?(d=l(f,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - not-found-handler`,[Yn.FASTIFY_TYPE]:ym.INSTANCE,[Yn.HOOK_CALLBACK_NAME]:f.name?.length>0?f.name:hh}),h.call(this,d)):(f.preValidation!=null&&(f.preValidation=l(f.preValidation,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - not-found-handler - preValidation`,[Yn.FASTIFY_TYPE]:ym.INSTANCE,[Yn.HOOK_CALLBACK_NAME]:f.preValidation.name?.length>0?f.preValidation.name:hh})),f.preHandler!=null&&(f.preHandler=l(f.preHandler,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - not-found-handler - preHandler`,[Yn.FASTIFY_TYPE]:ym.INSTANCE,[Yn.HOOK_CALLBACK_NAME]:f.preHandler.name?.length>0?f.preHandler.name:hh})),d=l(d,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - not-found-handler`,[Yn.FASTIFY_TYPE]:ym.INSTANCE,[Yn.HOOK_CALLBACK_NAME]:d.name?.length>0?d.name:hh}),h.call(this,f,d))}function l(f,d={}){return function(...p){let _=this[aa],[g]=p;if(_.isEnabled()===!1)return f.call(this,...p);let S=g[tw]??Je.active(),b=_.tracer.startSpan(`handler - ${f.name?.length>0?f.name:this.pluginName??hh}`,{attributes:d},S);return Je.with(Ft.setSpan(S,b),function(){try{let x=f.call(this,...p);return typeof x?.then=="function"?x.then(A=>(b.end(),A),A=>(b.setStatus({code:ti.ERROR,message:A.message}),b.recordException(A),b.end(),Promise.reject(A))):(b.end(),x)}catch(x){throw b.setStatus({code:ti.ERROR,message:x.message}),b.recordException(x),b.end(),x}},this)}}}}};Fe();var lk=he(sn(),1),Dg=he(Qt(),1);mn();var ph;(function(t){let e="fastify.name";t.FASTIFY_NAME=e;let r="fastify.type";t.FASTIFY_TYPE=r;let n="hook.name";t.HOOK_NAME=n;let i="plugin.name";t.PLUGIN_NAME=i})(ph||(ph={}));var rw;(function(t){let e="middleware";t.MIDDLEWARE=e;let r="request_handler";t.REQUEST_HANDLER=r})(rw||(rw={}));var nw;(function(t){let e="middleware";t.MIDDLEWARE=e;let r="request handler";t.REQUEST_HANDLER=r})(nw||(nw={}));Fe();var iw=Symbol("opentelemetry.instrumentation.fastify.request_active_span");function fV(t,e,r,n={}){let i=e.startSpan(r,{attributes:n}),s=t[iw]||[];return s.push(i),Object.defineProperty(t,iw,{enumerable:!1,configurable:!0,value:s}),i}function ck(t,e){let r=t[iw]||[];r.length&&(r.forEach(n=>{e&&(n.setStatus({code:ti.ERROR,message:e.message}),n.recordException(e)),n.end()}),delete t[iw])}function Vxe(t,e,r){let n,i;try{i=t(),$xe(i)&&i.then(s=>e(void 0,s),s=>e(s))}catch(s){n=s}finally{if(!$xe(i)&&(e(n,i),n))throw n;return i}}function $xe(t){return typeof t=="object"&&t&&typeof Object.getOwnPropertyDescriptor(t,"then")?.value=="function"||!1}var B1t="0.1.0",U1t="@sentry/instrumentation-fastify-v3",Wxe="anonymous",q1t=new Set(["onTimeout","onRequest","preParsing","preValidation","preSerialization","preHandler","onSend","onResponse","onError"]),uk=class extends Dg.InstrumentationBase{constructor(e={}){super(U1t,B1t,e)}init(){return[new Dg.InstrumentationNodeModuleDefinition("fastify",[">=3.0.0 <4"],e=>this._patchConstructor(e))]}_hookOnRequest(){let e=this;return function(n,i,s){if(!e.isEnabled())return s();e._wrap(i,"send",e._patchSend());let o=n,a=(0,lk.getRPCMetadata)(Je.active()),c=o.routeOptions?o.routeOptions.url:n.routerPath;c&&a?.type===lk.RPCType.HTTP&&(a.route=c);let u=n.method||"GET";vr().setTransactionName(`${u} ${c}`),s()}}_wrapHandler(e,r,n,i){let s=this;return this._diag.debug("Patching fastify route.handler function"),function(...o){if(!s.isEnabled())return n.apply(this,o);let a=n.name||e||Wxe,c=`${nw.MIDDLEWARE} - ${a}`,u=o[1],l=fV(u,s.tracer,c,{[ph.FASTIFY_TYPE]:rw.MIDDLEWARE,[ph.PLUGIN_NAME]:e,[ph.HOOK_NAME]:r}),f=i&&o[o.length-1];return f&&(o[o.length-1]=function(...d){ck(u),f.apply(this,d)}),Je.with(Ft.setSpan(Je.active(),l),()=>Vxe(()=>n.apply(this,o),d=>{d instanceof Error&&(l.setStatus({code:ti.ERROR,message:d.message}),l.recordException(d)),i||ck(u)}))}}_wrapAddHook(){let e=this;return this._diag.debug("Patching fastify server.addHook function"),function(r){return function(...i){let s=i[0],o=i[1],a=this.pluginName;if(!q1t.has(s))return r.apply(this,i);let c=typeof i[i.length-1]=="function"&&o.constructor.name!=="AsyncFunction";return r.apply(this,[s,e._wrapHandler(a,s,o,c)])}}}_patchConstructor(e){let r=this;function n(...i){let s=e.fastify.apply(this,i);return s.addHook("onRequest",r._hookOnRequest()),s.addHook("preHandler",r._hookPreHandler()),j1t(),r._wrap(s,"addHook",r._wrapAddHook()),s}return e.errorCodes!==void 0&&(n.errorCodes=e.errorCodes),n.fastify=n,n.default=n,n}_patchSend(){let e=this;return this._diag.debug("Patching fastify reply.send function"),function(n){return function(...s){let o=s[0];return e.isEnabled()?(0,Dg.safeExecuteInTheMiddle)(()=>n.apply(this,s),a=>{!a&&o instanceof Error&&(a=o),ck(this,a)}):n.apply(this,s)}}}_hookPreHandler(){let e=this;return this._diag.debug("Patching fastify preHandler function"),function(n,i,s){if(!e.isEnabled())return s();let o=n,a=o.routeOptions?.handler||o.context?.handler,c=a?.name.startsWith("bound ")?a.name.substring(6):a?.name,u=`${nw.REQUEST_HANDLER} - ${c||this.pluginName||Wxe}`,l={[ph.PLUGIN_NAME]:this.pluginName,[ph.FASTIFY_TYPE]:rw.REQUEST_HANDLER,[F9]:o.routeOptions?o.routeOptions.url:n.routerPath};c&&(l[ph.FASTIFY_NAME]=c);let f=fV(i,e.tracer,u,l);Yxe(f);let{requestHook:d}=e.getConfig();return d&&(0,Dg.safeExecuteInTheMiddle)(()=>d(f,{request:n}),h=>{h&&e._diag.error("request hook failed",h)},!0),Je.with(Ft.setSpan(Je.active(),f),()=>{s()})}}};function j1t(){let t=Ve();t&&t.on("spanStart",e=>{Yxe(e)})}function Yxe(t){let e=It(t).data,r=e["fastify.type"];if(e[bt]||!r)return;t.setAttributes({[zt]:"auto.http.otel.fastify",[bt]:`${r}.fastify`});let n=e["fastify.name"]||e["plugin.name"]||e["hook.name"];if(typeof n=="string"){let i=n.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");t.updateName(i)}}var fk="Fastify",Kxe=at(`${fk}.v3`,()=>new uk);function H1t(){let t=Ve();if(t)return t.getIntegrationByName(fk)}function zxe(t,e,r,n){let i=H1t()?.getShouldHandleError()||Xxe;if(n==="diagnostics-channel"&&(this.diagnosticsChannelExists=!0),this.diagnosticsChannelExists&&n==="onError-hook"){Zc&&ne.warn("Fastify error handler was already registered via diagnostics channel.","You can safely remove `setupFastifyErrorHandler` call and set `shouldHandleError` on the integration options.");return}i(t,e,r)&&tr(t,{mechanism:{handled:!1,type:"auto.function.fastify"}})}var Qxe=at(`${fk}.v5`,()=>{let t=new ok,e=t.plugin();return dV.subscribe("fastify.initialization",r=>{let n=r.fastify;n?.register(e).after(i=>{i?Zc&&ne.error("Failed to setup Fastify instrumentation",i):($1t(),n&&V1t(n))})}),dV.subscribe("tracing:fastify.request.handler:error",r=>{let{error:n,request:i,reply:s}=r;zxe.call(zxe,n,i,s,"diagnostics-channel")}),t}),G1t=({shouldHandleError:t})=>{let e;return{name:fk,setupOnce(){e=t||Xxe,Kxe(),Qxe()},getShouldHandleError(){return e},setShouldHandleError(r){e=r}}},Jxe=(t={})=>G1t(t);function Xxe(t,e,r){let n=r.statusCode;return n>=500||n<=299}function Zxe(t){let e=It(t),r=e.description,n=e.data,i=n["fastify.type"],s=i==="hook",o=i===r?.startsWith("handler -"),a=r==="request"||i==="request-handler";if(n[bt]||!o&&!a&&!s)return;let c=s?"hook":o?"middleware":a?"request-handler":"<unknown>";t.setAttributes({[zt]:"auto.http.otel.fastify",[bt]:`${c}.fastify`});let u=n["fastify.name"]||n["plugin.name"]||n["hook.name"];if(typeof u=="string"){let l=u.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");t.updateName(l)}}function $1t(){let t=Ve();t&&t.on("spanStart",e=>{Zxe(e)})}function V1t(t){t.addHook("onRequest",async(e,r)=>{if(e.opentelemetry){let{span:s}=e.opentelemetry();s&&Zxe(s)}let n=e.routeOptions?.url,i=e.method||"GET";vr().setTransactionName(`${i} ${n}`)})}Fe();var S1e=he(y1e(),1);var b1e="Graphql",v1e=at(b1e,S1e.GraphQLInstrumentation,t=>{let e=A1e(t);return{...e,responseHook(r,n){An(r,"auto.graphql.otel.graphql"),n.errors?.length&&!It(r).status&&r.setStatus({code:ti.ERROR});let s=It(r).data,o=s["graphql.operation.type"],a=s["graphql.operation.name"];if(e.useOperationNameForRootSpan&&o){let c=Ai(r),l=It(c).data[KS]||[],f=a?`${o} ${a}`:`${o}`;Array.isArray(l)?(l.push(f),c.setAttribute(KS,l)):typeof l=="string"?c.setAttribute(KS,[l,f]):c.setAttribute(KS,f),It(c).data["original-description"]||c.setAttribute("original-description",It(c).description),c.updateName(`${It(c).data["original-description"]} (${dwt(l)})`)}}}}),fwt=(t={})=>({name:b1e,setupOnce(){v1e(A1e(t))}}),T1e=fwt;function A1e(t){return{ignoreResolveSpans:!0,ignoreTrivialResolveSpans:!0,useOperationNameForRootSpan:!0,...t}}function dwt(t){if(Array.isArray(t)){let e=t.slice().sort();return e.length<=5?e.join(", "):`${e.slice(0,5).join(", ")}, +${e.length-5}`}return`${t}`}var L1e=he(M1e(),1);var F1e="Kafka",B1e=at(F1e,()=>new L1e.KafkaJsInstrumentation({consumerHook(t){An(t,"auto.kafkajs.otel.consumer")},producerHook(t){An(t,"auto.kafkajs.otel.producer")}})),pwt=()=>({name:F1e,setupOnce(){B1e()}}),U1e=pwt;var W1e=he(V1e(),1);var Y1e="LruMemoizer",z1e=at(Y1e,()=>new W1e.LruMemoizerInstrumentation),_wt=()=>({name:Y1e,setupOnce(){z1e()}}),K1e=_wt;var iwe=he(nwe(),1);var swe="Mongo",owe=at(swe,()=>new iwe.MongoDBInstrumentation({dbStatementSerializer:bwt,responseHook(t){An(t,"auto.db.otel.mongo")}}));function bwt(t){let e=bV(t);return JSON.stringify(e)}function bV(t){if(Array.isArray(t))return t.map(e=>bV(e));if(vwt(t)){let e={};return Object.entries(t).map(([r,n])=>[r,bV(n)]).reduce((r,n)=>(Awt(n)&&(r[n[0]]=n[1]),r),e)}return"?"}function vwt(t){return typeof t=="object"&&t!==null&&!Twt(t)}function Twt(t){let e=!1;return typeof Buffer<"u"&&(e=Buffer.isBuffer(t)),e}function Awt(t){return Array.isArray(t)}var xwt=()=>({name:swe,setupOnce(){owe()}}),awe=xwt;var Ewe=he(gwe(),1);var ywe="Mongoose",Swe=at(ywe,()=>new Ewe.MongooseInstrumentation({responseHook(t){An(t,"auto.db.otel.mongoose")}})),Mwt=()=>({name:ywe,setupOnce(){Swe()}}),bwe=Mwt;var Dwe=he(Iwe(),1);var Rwe="Mysql",Owe=at(Rwe,()=>new Dwe.MySQLInstrumentation({})),Vwt=()=>({name:Rwe,setupOnce(){Owe()}}),Nwe=Vwt;var qwe=he(Uwe(),1);var jwe="Mysql2",Hwe=at(jwe,()=>new qwe.MySQL2Instrumentation({responseHook(t){An(t,"auto.db.otel.mysql2")}})),oCt=()=>({name:jwe,setupOnce(){Hwe()}}),Gwe=oCt;var _Ce=he(Jwe(),1),gCe=he(fCe(),1);var xCt=["get","set","setex"],HV=["get","mget"],wCt=["set","setex"];function gw(t,e){return t.includes(e.toLowerCase())}function GV(t){return gw(HV,t)?"cache.get":gw(wCt,t)?"cache.put":void 0}function CCt(t,e){return e.some(r=>t.startsWith(r))}function hCe(t,e){try{if(e.length===0)return;let r=i=>typeof i=="string"||typeof i=="number"||Buffer.isBuffer(i)?[i.toString()]:Array.isArray(i)?dCe(i.map(s=>r(s))):["<unknown>"],n=e[0];return gw(xCt,t)&&n!=null?r(n):dCe(e.map(i=>r(i)))}catch{return}}function pCe(t,e,r){if(!GV(t))return!1;for(let n of e)if(CCt(n,r))return!0;return!1}function mCe(t){let e=r=>{try{return Buffer.isBuffer(r)?r.byteLength:typeof r=="string"?r.length:typeof r=="number"?r.toString().length:r==null?0:JSON.stringify(r).length}catch{return}};return Array.isArray(t)?t.reduce((r,n)=>{let i=e(n);return typeof i=="number"?r!==void 0?r+i:i:r},0):e(t)}function dCe(t){let e=[],r=n=>{n.forEach(i=>{Array.isArray(i)?r(i):e.push(i)})};return r(t),e}var Kk="Redis",Ew={},ECe=(t,e,r,n)=>{t.setAttribute(zt,"auto.db.otel.redis");let i=hCe(e,r),s=GV(e);if(!i||!s||!Ew.cachePrefixes||!pCe(e,i,Ew.cachePrefixes))return;let o=It(t).data["net.peer.name"],a=It(t).data["net.peer.port"];a&&o&&t.setAttributes({"network.peer.address":o,"network.peer.port":a});let c=mCe(n);c&&t.setAttribute(AH,c),gw(HV,e)&&c!==void 0&&t.setAttribute(vH,c>0),t.setAttributes({[bt]:s,[TH]:i});let u=i.join(", ");t.updateName(Ew.maxCacheKeyLength?Kp(u,Ew.maxCacheKeyLength):u)},ICt=at(`${Kk}.IORedis`,()=>new _Ce.IORedisInstrumentation({responseHook:ECe})),DCt=at(`${Kk}.Redis`,()=>new gCe.RedisInstrumentation({responseHook:ECe})),yCe=Object.assign(()=>{ICt(),DCt()},{id:Kk}),RCt=(t={})=>({name:Kk,setupOnce(){Ew=t,yCe()}}),SCe=RCt;var FCe=he(LCe(),1);var BCe="Postgres",UCe=at(BCe,()=>new FCe.PgInstrumentation({requireParentSpan:!0,requestHook(t){An(t,"auto.db.otel.postgres")}})),VCt=()=>({name:BCe,setupOnce(){UCe()}}),qCe=VCt;Fe();var Eh=he(Qt(),1);mn();var QV="PostgresJs",jCe=[">=3.0.0 <4"],HCe=at(QV,t=>new KV({requireParentSpan:t?.requireParentSpan??!0,requestHook:t?.requestHook})),KV=class extends Eh.InstrumentationBase{constructor(e){super("sentry-postgres-js",kr,e)}init(){let e=new Eh.InstrumentationNodeModuleDefinition("postgres",jCe);return["src","cf/src","cjs/src"].forEach(r=>{e.files.push(new Eh.InstrumentationNodeModuleFile(`postgres/${r}/connection.js`,["*"],this._patchConnection.bind(this),this._unwrap.bind(this))),e.files.push(new Eh.InstrumentationNodeModuleFile(`postgres/${r}/query.js`,jCe,this._patchQuery.bind(this),this._unwrap.bind(this)))}),[e]}_shouldCreateSpans(){let e=this.getConfig();return Ft.getSpan(Je.active())!==void 0||!e.requireParentSpan}_patchReject(e,r){return new Proxy(e,{apply:(n,i,s)=>{r.setStatus({code:2,message:s?.[0]?.message||"internal_error"});let o=Reflect.apply(n,i,s);return r.setAttribute($9,s?.[0]?.code||"Unknown error"),r.setAttribute(V9,s?.[0]?.name||"Unknown error"),r.end(),o}})}_patchResolve(e,r){return new Proxy(e,{apply:(n,i,s)=>{let o=Reflect.apply(n,i,s),a=s?.[0]?.command;return a&&r.setAttribute(kx,a),r.end(),o}})}_patchQuery(e){return e.Query.prototype.handle=new Proxy(e.Query.prototype.handle,{apply:async(r,n,i)=>{if(!this._shouldCreateSpans())return Reflect.apply(r,n,i);let s=this._sanitizeSqlQuery(n.strings?.[0]);return Po({name:s||"postgresjs.query",op:"db"},o=>{let c=Gr().getScopeData().contexts.postgresjsConnection;An(o,"auto.db.otel.postgres");let{requestHook:u}=this.getConfig();u&&(0,Eh.safeExecuteInTheMiddle)(()=>u(o,s,c),h=>{h&&ne.error(`Error in requestHook for ${QV} integration:`,h)});let l=c?.ATTR_DB_NAMESPACE||"<unknown database>",f=c?.ATTR_SERVER_ADDRESS||"<unknown host>",d=c?.ATTR_SERVER_PORT||"<unknown port>";o.setAttribute(Mx,"postgres"),o.setAttribute(Px,l),o.setAttribute(Lx,f),o.setAttribute(Fx,d),o.setAttribute(G9,s),n.resolve=this._patchResolve(n.resolve,o),n.reject=this._patchReject(n.reject,o);try{return Reflect.apply(r,n,i)}catch(h){throw o.setStatus({code:2}),o.end(),h}})}}),e}_patchConnection(e){return new Proxy(e,{apply:(r,n,i)=>{let s=i[0]?.database||"<unknown database>",o=i[0]?.host?.[0]||"<unknown host>",a=i[0]?.port?.[0]||"<unknown port>";return Gr().setContext("postgresjsConnection",{ATTR_DB_NAMESPACE:s,ATTR_SERVER_ADDRESS:o,ATTR_SERVER_PORT:a}),Reflect.apply(r,n,i)}})}_sanitizeSqlQuery(e){return e?e.replace(/\s+/g," ").trim().substring(0,1024).replace(/--.*?(\r?\n|$)/g,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/;\s*$/,"").replace(/\b\d+\b/g,"?").replace(/\s+/g," ").replace(/\bIN\b\s*\(\s*\?(?:\s*,\s*\?)*\s*\)/g,"IN (?)"):"Unknown SQL Query"}},WCt=()=>({name:QV,setupOnce(){HCe()}}),GCe=WCt;Fe();Fe();var rM=he(Qt(),1);Fe();var YCt=process.env.PRISMA_SHOW_ALL_TRACES==="true",zCt="00-10-10-00";function KCt(t){switch(t){case"client":return Un.CLIENT;case"internal":default:return Un.INTERNAL}}var QCt=class{tracerProvider;ignoreSpanTypes;constructor({tracerProvider:t,ignoreSpanTypes:e}){this.tracerProvider=t,this.ignoreSpanTypes=e}isEnabled(){return!0}getTraceParent(t){let e=Ft.getSpanContext(t??Je.active());return e?`00-${e.traceId}-${e.spanId}-0${e.traceFlags}`:zCt}dispatchEngineSpans(t){let e=this.tracerProvider.getTracer("prisma"),r=new Map,n=t.filter(i=>i.parentId===null);for(let i of n)WCe(e,i,t,r,this.ignoreSpanTypes)}getActiveContext(){return Je.active()}runInChildSpan(t,e){if(typeof t=="string"&&(t={name:t}),t.internal&&!YCt)return e();let r=this.tracerProvider.getTracer("prisma"),n=t.context??this.getActiveContext(),i=`prisma:client:${t.name}`;if(YCe(i,this.ignoreSpanTypes))return e();if(t.active===!1){let s=r.startSpan(i,t,n);return $Ce(s,e(s,n))}return r.startActiveSpan(i,t,s=>$Ce(s,e(s,n)))}};function WCe(t,e,r,n,i){if(YCe(e.name,i))return;let s={attributes:e.attributes,kind:KCt(e.kind),startTime:e.startTime};t.startActiveSpan(e.name,s,o=>{n.set(e.id,o.spanContext().spanId),e.links&&o.addLinks(e.links.flatMap(c=>{let u=n.get(c);return u?{context:{spanId:u,traceId:o.spanContext().traceId,traceFlags:o.spanContext().traceFlags}}:[]}));let a=r.filter(c=>c.parentId===e.id);for(let c of a)WCe(t,c,r,n,i);o.end(e.endTime)})}function $Ce(t,e){return JCt(e)?e.then(r=>(t.end(),r),r=>{throw t.end(),r}):(t.end(),e)}function JCt(t){return t!=null&&typeof t.then=="function"}function YCe(t,e){return e.some(r=>typeof r=="string"?r===t:r.test(t))}var zCe={name:"@prisma/instrumentation",version:"6.19.0",description:"OpenTelemetry compliant instrumentation for Prisma Client",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{require:{types:"./dist/index.d.ts",default:"./dist/index.js"},import:{types:"./dist/index.d.ts",default:"./dist/index.mjs"}}},license:"Apache-2.0",homepage:"https://www.prisma.io",repository:{type:"git",url:"https://github.com/prisma/prisma.git",directory:"packages/instrumentation"},bugs:"https://github.com/prisma/prisma/issues",devDependencies:{"@prisma/internals":"workspace:*","@types/node":"18.19.76","@opentelemetry/api":"1.9.0",typescript:"5.4.5"},dependencies:{"@opentelemetry/instrumentation":">=0.52.0 <1"},peerDependencies:{"@opentelemetry/api":"^1.8"},files:["dist"],keywords:["prisma","instrumentation","opentelemetry","otel"],scripts:{dev:"DEV=true tsx helpers/build.ts",build:"tsx helpers/build.ts",prepublishOnly:"pnpm run build",test:"vitest run"},sideEffects:!1},XV=zCe.version,XCt=XV.split(".")[0],VCe="PRISMA_INSTRUMENTATION",JV=`V${XCt}_PRISMA_INSTRUMENTATION`,ZCt=zCe.name,eIt="@prisma/client",KCe=class extends rM.InstrumentationBase{tracerProvider;constructor(t={}){super(ZCt,XV,t)}setTracerProvider(t){this.tracerProvider=t}init(){return[new rM.InstrumentationNodeModuleDefinition(eIt,[XV])]}enable(){let t=this._config,e={helper:new QCt({tracerProvider:this.tracerProvider??Ft.getTracerProvider(),ignoreSpanTypes:t.ignoreSpanTypes??[]})};global[VCe]=e,global[JV]=e}disable(){delete global[VCe],delete global[JV]}isEnabled(){return!!global[JV]}};var QCe="Prisma";function tIt(t){return!!t&&typeof t=="object"&&"dispatchEngineSpans"in t}function JCe(){let t=globalThis.PRISMA_INSTRUMENTATION;return t&&typeof t=="object"&&"helper"in t?t.helper:void 0}var ZV=class extends KCe{constructor(){super()}enable(){super.enable();let e=JCe();tIt(e)&&(e.createEngineSpan=r=>{let n=Ft.getTracer("prismaV5Compatibility"),i=n._idGenerator;if(!i){hi(()=>{console.warn("[Sentry] Could not find _idGenerator on tracer, skipping Prisma v5 compatibility - some Prisma spans may be missing!")});return}try{r.spans.forEach(s=>{let o=rIt(s.kind),a=s.parent_span_id,c=s.span_id,u=s.trace_id,l=s.links?.map(d=>({context:{traceId:d.trace_id,spanId:d.span_id,traceFlags:Xo.SAMPLED}})),f=Ft.setSpanContext(Je.active(),{traceId:u,spanId:a,traceFlags:Xo.SAMPLED});Je.with(f,()=>{let d={generateTraceId:()=>u,generateSpanId:()=>c};n._idGenerator=d,n.startSpan(s.name,{kind:o,links:l,startTime:s.start_time,attributes:s.attributes}).end(s.end_time),n._idGenerator=i})})}finally{n._idGenerator=i}})}};function rIt(t){switch(t){case"client":return Un.CLIENT;case"internal":default:return Un.INTERNAL}}var nIt=at(QCe,t=>new ZV),XCe=t=>({name:QCe,setupOnce(){nIt()},setup(e){JCe()&&e.on("spanStart",r=>{let n=It(r);n.description?.startsWith("prisma:")&&r.setAttribute(zt,"auto.db.otel.prisma"),n.description==="prisma:engine:db_query"&&n.data["db.query.text"]&&r.updateName(n.data["db.query.text"]),n.description==="prisma:engine:db_query"&&!n.data["db.system"]&&r.setAttribute("db.system","prisma")})}});var cIe=he(aIe(),1);var uIe="Hapi",lIe=at(uIe,()=>new cIe.HapiInstrumentation),_It=()=>({name:uIe,setupOnce(){lIe()}}),fIe=_It;mn();var Im={HONO_TYPE:"hono.type",HONO_NAME:"hono.name"},ww={MIDDLEWARE:"middleware",REQUEST_HANDLER:"request_handler"};Fe();var oM=he(Qt(),1);var gIt="@sentry/instrumentation-hono",EIt="0.0.1",sM=class extends oM.InstrumentationBase{constructor(e={}){super(gIt,EIt,e)}init(){return[new oM.InstrumentationNodeModuleDefinition("hono",[">=4.0.0 <5"],e=>this._patch(e))]}_patch(e){let r=this;class n extends e.Hono{constructor(...s){super(...s),r._wrap(this,"get",r._patchHandler()),r._wrap(this,"post",r._patchHandler()),r._wrap(this,"put",r._patchHandler()),r._wrap(this,"delete",r._patchHandler()),r._wrap(this,"options",r._patchHandler()),r._wrap(this,"patch",r._patchHandler()),r._wrap(this,"all",r._patchHandler()),r._wrap(this,"on",r._patchOnHandler()),r._wrap(this,"use",r._patchMiddlewareHandler())}}try{e.Hono=n}catch{return{...e,Hono:n}}return e}_patchHandler(){let e=this;return function(r){return function(...i){if(typeof i[0]=="string"){let s=i[0];if(i.length===1)return r.apply(this,[s]);let o=i.slice(1);return r.apply(this,[s,...o.map(a=>e._wrapHandler(a))])}return r.apply(this,i.map(s=>e._wrapHandler(s)))}}}_patchOnHandler(){let e=this;return function(r){return function(...i){let s=i.slice(2);return r.apply(this,[...i.slice(0,2),...s.map(o=>e._wrapHandler(o))])}}}_patchMiddlewareHandler(){let e=this;return function(r){return function(...i){if(typeof i[0]=="string"){let s=i[0];if(i.length===1)return r.apply(this,[s]);let o=i.slice(1);return r.apply(this,[s,...o.map(a=>e._wrapHandler(a))])}return r.apply(this,i.map(s=>e._wrapHandler(s)))}}}_wrapHandler(e){let r=this;return function(n,i){if(!r.isEnabled())return e.apply(this,[n,i]);let s=n.req.path,o=r.tracer.startSpan(s);return Je.with(Ft.setSpan(Je.active(),o),()=>r._safeExecute(()=>{let a=e.apply(this,[n,i]);if(ia(a))return a.then(c=>{let u=r._determineHandlerType(c);return o.setAttributes({[Im.HONO_TYPE]:u,[Im.HONO_NAME]:u===ww.REQUEST_HANDLER?s:e.name||"anonymous"}),r.getConfig().responseHook?.(o),c});{let c=r._determineHandlerType(a);return o.setAttributes({[Im.HONO_TYPE]:c,[Im.HONO_NAME]:c===ww.REQUEST_HANDLER?s:e.name||"anonymous"}),r.getConfig().responseHook?.(o),a}},()=>o.end(),a=>{r._handleError(o,a),o.end()}))}}_safeExecute(e,r,n){try{let i=e();return ia(i)?i.then(()=>r(),s=>n(s)):r(),i}catch(i){throw n(i),i}}_determineHandlerType(e){return e===void 0?ww.MIDDLEWARE:ww.REQUEST_HANDLER}_handleError(e,r){r instanceof Error&&(e.setStatus({code:ti.ERROR,message:r.message}),e.recordException(r))}};var dIe="Hono";function yIt(t){let e=It(t).data,r=e[Im.HONO_TYPE];if(e[bt]||!r)return;t.setAttributes({[zt]:"auto.http.otel.hono",[bt]:`${r}.hono`});let n=e[Im.HONO_NAME];if(typeof n=="string"&&t.updateName(n),vr()===zc()){Zc&&ne.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let i=e[ba],s=e[Xd];typeof i=="string"&&typeof s=="string"&&vr().setTransactionName(`${s} ${i}`)}var hIe=at(dIe,()=>new sM({responseHook:t=>{yIt(t)}})),SIt=()=>({name:dIe,setupOnce(){hIe()}}),pIe=SIt;var wIe=he(xIe(),1);mn();var CIe="Koa",IIe=at(CIe,wIe.KoaInstrumentation,(t={})=>({ignoreLayersType:t.ignoreLayersType,requestHook(e,r){An(e,"auto.http.otel.koa");let n=It(e).data,i=n["koa.type"];i&&e.setAttribute(bt,`${i}.koa`);let s=n["koa.name"];if(typeof s=="string"&&e.updateName(s||"< unknown >"),vr()===zc()){Zc&&ne.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let o=n[ba],a=r.context?.request?.method?.toUpperCase()||"GET";o&&vr().setTransactionName(`${a} ${o}`)}})),DIt=(t={})=>({name:CIe,setupOnce(){IIe(t)}}),DIe=DIt;var BIe=he(FIe(),1);var UIe="Connect",qIe=at(UIe,()=>new BIe.ConnectInstrumentation),UIt=()=>({name:UIe,setupOnce(){qIe()}}),jIe=UIt;var JIe=he(QIe(),1);var $It=new Set(["callProcedure","execSql","execSqlBatch","execBulkLoad","prepare","execute"]),XIe="Tedious",ZIe=at(XIe,()=>new JIe.TediousInstrumentation({})),VIt=()=>{let t;return{name:XIe,setupOnce(){let e=ZIe();t=C1(e)},setup(e){t?.(()=>e.on("spanStart",r=>{let{description:n,data:i}=It(r);if(!n||i["db.system"]!=="mssql")return;let s=n.split(" ")[0]||"";$It.has(s)&&r.setAttribute(zt,"auto.db.otel.tedious")}))}}},eDe=VIt;var sDe=he(iDe(),1);var oDe="GenericPool",aDe=at(oDe,()=>new sDe.GenericPoolInstrumentation({})),YIt=()=>{let t;return{name:oDe,setupOnce(){let e=aDe();t=C1(e)},setup(e){t?.(()=>e.on("spanStart",r=>{let i=It(r).description;(i==="generic-pool.aquire"||i==="generic-pool.acquire")&&r.setAttribute(zt,"auto.db.otel.generic_pool")}))}}},cDe=YIt;var EDe=he(gDe(),1);var yDe="Amqplib",iDt={consumeEndHook:t=>{An(t,"auto.amqplib.otel.consumer")},publishHook:t=>{An(t,"auto.amqplib.otel.publisher")}},SDe=at(yDe,()=>new EDe.AmqplibInstrumentation(iDt)),sDt=()=>({name:yDe,setupOnce(){SDe()}}),bDe=sDt;var Ow="VercelAI";var TM=he(Qt(),1);var vDe=["generateText","streamText","generateObject","streamObject","embed","embedMany"];function oDt(t){if(typeof t!="object"||t===null)return!1;let e=t;return"type"in e&&"error"in e&&"toolName"in e&&"toolCallId"in e&&e.type==="tool-error"&&e.error instanceof Error}function aDt(t){if(typeof t!="object"||t===null||!("content"in t))return;let e=t;if(Array.isArray(e.content)){for(let r of e.content)if(oDt(r)){let n=uG(r.toolCallId);if(n){let i=n.spanContext();Kc(s=>{s.setContext("trace",{trace_id:i.traceId,span_id:i.spanId}),s.setTag("vercel.ai.tool.name",r.toolName),s.setTag("vercel.ai.tool.callId",r.toolCallId),s.setLevel("error"),tr(r.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})}),lG(r.toolCallId)}else Kc(i=>{i.setTag("vercel.ai.tool.name",r.toolName),i.setTag("vercel.ai.tool.callId",r.toolCallId),i.setLevel("error"),tr(r.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})})}}}function cDt(t,e,r,n){let i=t?.recordInputs!==void 0?t.recordInputs:e.recordInputs!==void 0?e.recordInputs:r===!0?!0:n,s=t?.recordOutputs!==void 0?t.recordOutputs:e.recordOutputs!==void 0?e.recordOutputs:r===!0?!0:n;return{recordInputs:i,recordOutputs:s}}var vM=class t extends TM.InstrumentationBase{__init(){this._isPatched=!1}__init2(){this._callbacks=[]}constructor(e={}){super("@sentry/instrumentation-vercel-ai",kr,e),t.prototype.__init.call(this),t.prototype.__init2.call(this)}init(){return new TM.InstrumentationNodeModuleDefinition("ai",[">=3.0.0 <6"],this._patch.bind(this))}callWhenPatched(e){this._isPatched?e():this._callbacks.push(e)}_patch(e){this._isPatched=!0,this._callbacks.forEach(n=>n()),this._callbacks=[];let r=n=>new Proxy(n,{apply:(i,s,o)=>{let a=o[0].experimental_telemetry||{},c=a.isEnabled,u=Ve(),l=u?.getIntegrationByName(Ow),f=l?.options,d=l?!!u?.getOptions().sendDefaultPii:!1,{recordInputs:h,recordOutputs:p}=cDt(f,a,c,d);return o[0].experimental_telemetry={...a,isEnabled:c!==void 0?c:!0,recordInputs:h,recordOutputs:p},hc(()=>Reflect.apply(i,s,o),_=>{_&&typeof _=="object"&&ss(_,"_sentry_active_span",mf())},()=>{},_=>{aDt(_)})}});if(Object.prototype.toString.call(e)==="[object Module]"){for(let n of vDe)e[n]=r(e[n]);return e}else{let n=vDe.reduce((i,s)=>(i[s]=r(e[s]),i),{});return{...e,...n}}}};var TDe=at(Ow,()=>new vM({}));function uDt(t){return!!t.getIntegrationByName("Modules")?.getModules?.()?.ai}var lDt=(t={})=>{let e;return{name:Ow,options:t,setupOnce(){e=TDe()},afterAllSetup(r){t.force??uDt(r)?NN(r):e?.callWhenPatched(()=>NN(r))}}},ADe=lDt;var xM=he(Qt(),1);var fDt=[">=4.0.0 <7"],AM=class extends xM.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-openai",kr,e)}init(){return new xM.InstrumentationNodeModuleDefinition("openai",fDt,this._patch.bind(this))}_patch(e){let r=e;return r=this._patchClient(r,"OpenAI"),r=this._patchClient(r,"AzureOpenAI"),r}_patchClient(e,r){let n=e[r];if(!n)return e;let i=this.getConfig(),s=function(...o){if(gg(um))return Reflect.construct(n,o);let a=Reflect.construct(n,o),u=!!Ve()?.getOptions().sendDefaultPii,l=i.recordInputs??u,f=i.recordOutputs??u;return dG(a,{recordInputs:l,recordOutputs:f})};Object.setPrototypeOf(s,n),Object.setPrototypeOf(s.prototype,n.prototype);for(let o of Object.getOwnPropertyNames(n))if(!["length","name","prototype"].includes(o)){let a=Object.getOwnPropertyDescriptor(n,o);a&&Object.defineProperty(s,o,a)}try{e[r]=s}catch{Object.defineProperty(e,r,{value:s,writable:!0,configurable:!0,enumerable:!0})}if(e.default===n)try{e.default=s}catch{Object.defineProperty(e,"default",{value:s,writable:!0,configurable:!0,enumerable:!0})}return e}};var xDe=at(um,t=>new AM(t)),dDt=(t={})=>({name:um,setupOnce(){xDe(t)}}),wDe=dDt;var CM=he(Qt(),1);var hDt=[">=0.19.2 <1.0.0"],wM=class extends CM.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-anthropic-ai",kr,e)}init(){return new CM.InstrumentationNodeModuleDefinition("@anthropic-ai/sdk",hDt,this._patch.bind(this))}_patch(e){let r=e.Anthropic,n=this.getConfig(),i=function(...s){if(gg(lm))return Reflect.construct(r,s);let o=Reflect.construct(r,s),c=!!Ve()?.getOptions().sendDefaultPii,u=n.recordInputs??c,l=n.recordOutputs??c;return pG(o,{recordInputs:u,recordOutputs:l})};Object.setPrototypeOf(i,r),Object.setPrototypeOf(i.prototype,r.prototype);for(let s of Object.getOwnPropertyNames(r))if(!["length","name","prototype"].includes(s)){let o=Object.getOwnPropertyDescriptor(r,s);o&&Object.defineProperty(i,s,o)}try{e.Anthropic=i}catch{Object.defineProperty(e,"Anthropic",{value:i,writable:!0,configurable:!0,enumerable:!0})}if(e.default===r)try{e.default=i}catch{Object.defineProperty(e,"default",{value:i,writable:!0,configurable:!0,enumerable:!0})}return e}};var CDe=at(lm,t=>new wM(t)),pDt=(t={})=>({name:lm,options:t,setupOnce(){CDe(t)}}),IDe=pDt;var jb=he(Qt(),1);var DDe=[">=0.10.0 <2"],IM=class extends jb.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-google-genai",kr,e)}init(){return new jb.InstrumentationNodeModuleDefinition("@google/genai",DDe,r=>this._patch(r),r=>r,[new jb.InstrumentationNodeModuleFile("@google/genai/dist/node/index.cjs",DDe,r=>this._patch(r),r=>r)])}_patch(e){let r=e.GoogleGenAI,n=this.getConfig();if(typeof r!="function")return e;let i=function(...s){if(gg(fm))return Reflect.construct(r,s);let o=Reflect.construct(r,s),c=!!Ve()?.getOptions().sendDefaultPii,u=n,l=u?.recordInputs??c,f=u?.recordOutputs??c;return EG(o,{recordInputs:l,recordOutputs:f})};Object.setPrototypeOf(i,r),Object.setPrototypeOf(i.prototype,r.prototype);for(let s of Object.getOwnPropertyNames(r))if(!["length","name","prototype"].includes(s)){let o=Object.getOwnPropertyDescriptor(r,s);o&&Object.defineProperty(i,s,o)}return vG(e,"GoogleGenAI",i),e}};var RDe=at(fm,t=>new IM(t)),mDt=(t={})=>({name:fm,setupOnce(){RDe(t)}}),ODe=mDt;var Lm=he(Qt(),1);var DM=[">=0.1.0 <2.0.0"];function _Dt(t,e){return t?Array.isArray(t)?t.includes(e)?t:[...t,e]:typeof t=="object"?[t,e]:t:[e]}function gDt(t,e,r){return new Proxy(t,{apply(n,i,s){let a=s[1];(!a||typeof a!="object"||Array.isArray(a))&&(a={},s[1]=a);let c=a.callbacks,u=_Dt(c,e);return a.callbacks=u,Reflect.apply(n,i,s)}})}var RM=class extends Lm.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-langchain",kr,e)}init(){let e=[],r=["@langchain/anthropic","@langchain/openai","@langchain/google-genai","@langchain/mistralai","@langchain/google-vertexai","@langchain/groq"];for(let n of r)e.push(new Lm.InstrumentationNodeModuleDefinition(n,DM,this._patch.bind(this),i=>i,[new Lm.InstrumentationNodeModuleFile(`${n}/dist/index.cjs`,DM,this._patch.bind(this),i=>i)]));return e.push(new Lm.InstrumentationNodeModuleDefinition("langchain",DM,this._patch.bind(this),n=>n,[new Lm.InstrumentationNodeModuleFile("langchain/dist/chat_models/universal.cjs",DM,this._patch.bind(this),n=>n)])),e}_patch(e){YH([um,lm,fm]);let n=!!Ve()?.getOptions().sendDefaultPii,i=this.getConfig(),s=i?.recordInputs??n,o=i?.recordOutputs??n,a=LN({recordInputs:s,recordOutputs:o});return this._patchRunnableMethods(e,a),e}_patchRunnableMethods(e,r){let n=["ChatAnthropic","ChatOpenAI","ChatGoogleGenerativeAI","ChatMistralAI","ChatVertexAI","ChatGroq","ConfigurableModel"],i=e.universal_exports??e,s=Object.values(i).find(c=>typeof c=="function"&&n.includes(c.name));if(!s)return;let o=s.prototype,a=["invoke","stream","batch"];for(let c of a){let u=o[c];typeof u=="function"&&(o[c]=gDt(u,r))}}};var NDe=at(MN,t=>new RM(t)),EDt=(t={})=>({name:MN,setupOnce(){NDe(t)}}),PDe=EDt;var Hb=he(Qt(),1);var kDe=[">=0.0.0 <2.0.0"],OM=class extends Hb.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-langgraph",kr,e)}init(){return new Hb.InstrumentationNodeModuleDefinition("@langchain/langgraph",kDe,this._patch.bind(this),r=>r,[new Hb.InstrumentationNodeModuleFile("@langchain/langgraph/dist/index.cjs",kDe,this._patch.bind(this),r=>r)])}_patch(e){let n=!!Ve()?.getOptions().sendDefaultPii,i=this.getConfig(),s=i.recordInputs??n,o=i.recordOutputs??n,a={recordInputs:s,recordOutputs:o};if(e.StateGraph&&typeof e.StateGraph=="function"){let c=e.StateGraph;c.prototype.compile=bG(c.prototype.compile,a)}return e}};var MDe=at(FN,t=>new OM(t)),yDt=(t={})=>({name:FN,setupOnce(){MDe(t)}}),LDe=yDt;var $De=he(Qt(),1);var BDe=he(require("node:net"),1);Fe();var Sh=he(Qt(),1);mn();function UDe(t,e,r,n,i){let o=()=>{},a=i.firestoreSpanCreationHook;typeof a=="function"&&(o=l=>{(0,Sh.safeExecuteInTheMiddle)(()=>a(l),f=>{f&&Zo.error(f?.message)},!0)});let c=new Sh.InstrumentationNodeModuleDefinition("@firebase/firestore",e,l=>FDe(l,r,n,t,o)),u=["@firebase/firestore/dist/lite/index.node.cjs.js","@firebase/firestore/dist/lite/index.node.mjs.js","@firebase/firestore/dist/lite/index.rn.esm2017.js","@firebase/firestore/dist/lite/index.cjs.js"];for(let l of u)c.files.push(new Sh.InstrumentationNodeModuleFile(l,e,f=>FDe(f,r,n,t,o),f=>qDe(f,n)));return c}function FDe(t,e,r,n,i){return qDe(t,r),e(t,"addDoc",SDt(n,i)),e(t,"getDocs",vDt(n,i)),e(t,"setDoc",TDt(n,i)),e(t,"deleteDoc",bDt(n,i)),t}function qDe(t,e){for(let r of["addDoc","getDocs","setDoc","deleteDoc"])(0,Sh.isWrapped)(t[r])&&e(t,r);return t}function SDt(t,e){return function(n){return function(i,s){let o=PM(t,"addDoc",i);return e(o),NM(o,()=>n(i,s))}}}function bDt(t,e){return function(n){return function(i){let s=PM(t,"deleteDoc",i.parent||i);return e(s),NM(s,()=>n(i))}}}function vDt(t,e){return function(n){return function(i){let s=PM(t,"getDocs",i);return e(s),NM(s,()=>n(i))}}}function TDt(t,e){return function(n){return function(i,s,o){let a=PM(t,"setDoc",i.parent||i);return e(a),NM(a,()=>typeof o<"u"?n(i,s,o):n(i,s))}}}function NM(t,e){return Je.with(Ft.setSpan(Je.active(),t),()=>(0,Sh.safeExecuteInTheMiddle)(()=>e(),r=>{r&&t.recordException(r),t.end()},!0))}function PM(t,e,r){let n=t.startSpan(`${e} ${r.path}`,{kind:Un.CLIENT});return xDt(n,r),n.setAttribute(kx,e),n}function ADt(t){let e,r;if(typeof t.host=="string")if(t.host.startsWith("[")){if(t.host.endsWith("]"))e=t.host.replace(/^\[|\]$/g,"");else if(t.host.includes("]:")){let n=t.host.lastIndexOf(":");n!==-1&&(e=t.host.slice(1,n).replace(/^\[|\]$/g,""),r=t.host.slice(n+1))}}else if(BDe.isIPv6(t.host))e=t.host;else{let n=t.host.lastIndexOf(":");n!==-1?(e=t.host.slice(0,n),r=t.host.slice(n+1)):e=t.host}return{address:e,port:r?parseInt(r,10):void 0}}function xDt(t,e){let r=e.firestore.app,n=r.options,s=(e.firestore.toJSON()||{}).settings||{},o={[H9]:e.path,[Px]:r.name,[Mx]:"firebase.firestore","firebase.firestore.type":e.type,"firebase.firestore.options.projectId":n.projectId,"firebase.firestore.options.appId":n.appId,"firebase.firestore.options.messagingSenderId":n.messagingSenderId,"firebase.firestore.options.storageBucket":n.storageBucket},{address:a,port:c}=ADt(s);a&&(o[Lx]=a),c&&(o[Fx]=c),t.setAttributes(o)}Fe();var bh=he(Qt(),1);function jDe(t,e,r,n,i){let s=()=>{},o=()=>{},a=i.functions?.errorHook,c=i.functions?.requestHook,u=i.functions?.responseHook;typeof u=="function"&&(o=(d,h)=>{(0,bh.safeExecuteInTheMiddle)(()=>u(d,h),p=>{p&&Zo.error(p?.message)},!0)}),typeof c=="function"&&(s=d=>{(0,bh.safeExecuteInTheMiddle)(()=>c(d),h=>{h&&Zo.error(h?.message)},!0)});let l=new bh.InstrumentationNodeModuleDefinition("firebase-functions",e);return[{name:"firebase-functions/lib/v2/providers/https.js",triggerType:"function"},{name:"firebase-functions/lib/v2/providers/firestore.js",triggerType:"firestore"},{name:"firebase-functions/lib/v2/providers/scheduler.js",triggerType:"scheduler"},{name:"firebase-functions/lib/v2/storage.js",triggerType:"storage"}].forEach(({name:d,triggerType:h})=>{l.files.push(new bh.InstrumentationNodeModuleFile(d,e,p=>wDt(p,r,n,t,{requestHook:s,responseHook:o,errorHook:a},h),p=>HDe(p,n)))}),l}function la(t,e,r){return function(i){return function(...s){let o=typeof s[0]=="function"?s[0]:s[1],a=typeof s[0]=="function"?void 0:s[0];if(!o)return i.call(this,...s);let c=async function(...u){let l=process.env.FUNCTION_TARGET||process.env.K_SERVICE||"unknown",f=t.startSpan(`firebase.function.${r}`,{kind:Un.SERVER}),d={"faas.name":l,"faas.trigger":r,"faas.provider":"firebase"};return process.env.GCLOUD_PROJECT&&(d["cloud.project_id"]=process.env.GCLOUD_PROJECT),process.env.EVENTARC_CLOUD_EVENT_SOURCE&&(d["cloud.event_source"]=process.env.EVENTARC_CLOUD_EVENT_SOURCE),f.setAttributes(d),e?.requestHook?.(f),Je.with(Ft.setSpan(Je.active(),f),async()=>{let h,p;try{p=await o.apply(this,u)}catch(_){h=_}if(e?.responseHook?.(f,h),h&&f.recordException(h),f.end(),h)throw await e?.errorHook?.(f,h),h;return p})};return a?i.call(this,a,c):i.call(this,c)}}}function wDt(t,e,r,n,i,s){switch(HDe(t,r),s){case"function":e(t,"onRequest",la(n,i,"http.request")),e(t,"onCall",la(n,i,"http.call"));break;case"firestore":e(t,"onDocumentCreated",la(n,i,"firestore.document.created")),e(t,"onDocumentUpdated",la(n,i,"firestore.document.updated")),e(t,"onDocumentDeleted",la(n,i,"firestore.document.deleted")),e(t,"onDocumentWritten",la(n,i,"firestore.document.written")),e(t,"onDocumentCreatedWithAuthContext",la(n,i,"firestore.document.created")),e(t,"onDocumentUpdatedWithAuthContext",la(n,i,"firestore.document.updated")),e(t,"onDocumentDeletedWithAuthContext",la(n,i,"firestore.document.deleted")),e(t,"onDocumentWrittenWithAuthContext",la(n,i,"firestore.document.written"));break;case"scheduler":e(t,"onSchedule",la(n,i,"scheduler.scheduled"));break;case"storage":e(t,"onObjectFinalized",la(n,i,"storage.object.finalized")),e(t,"onObjectArchived",la(n,i,"storage.object.archived")),e(t,"onObjectDeleted",la(n,i,"storage.object.deleted")),e(t,"onObjectMetadataUpdated",la(n,i,"storage.object.metadataUpdated"));break}return t}function HDe(t,e){let r=["onSchedule","onRequest","onCall","onObjectFinalized","onObjectArchived","onObjectDeleted","onObjectMetadataUpdated","onDocumentCreated","onDocumentUpdated","onDocumentDeleted","onDocumentWritten","onDocumentCreatedWithAuthContext","onDocumentUpdatedWithAuthContext","onDocumentDeletedWithAuthContext","onDocumentWrittenWithAuthContext"];for(let n of r)(0,bh.isWrapped)(t[n])&&e(t,n);return t}var GDe={},CDt=[">=3.0.0 <5"],IDt=[">=6.0.0 <7"],kM=class extends $De.InstrumentationBase{constructor(e=GDe){super("@sentry/instrumentation-firebase",kr,e)}setConfig(e={}){super.setConfig({...GDe,...e})}init(){let e=[];return e.push(UDe(this.tracer,CDt,this._wrap,this._unwrap,this.getConfig())),e.push(jDe(this.tracer,IDt,this._wrap,this._unwrap,this.getConfig())),e}};var VDe="Firebase",DDt={firestoreSpanCreationHook:t=>{An(t,"auto.firebase.otel.firestore"),t.setAttribute(bt,"db.query")},functions:{requestHook:t=>{An(t,"auto.firebase.otel.functions"),t.setAttribute(bt,"http.request")},errorHook:async(t,e)=>{e&&(tr(e,{mechanism:{type:"auto.firebase.otel.functions",handled:!1}}),await CS(2e3))}}},WDe=at(VDe,()=>new kM(DDt)),RDt=()=>({name:VDe,setupOnce(){WDe()}}),YDe=RDt;function zDe(){return[hxe(),Jxe(),T1e(),pIe(),awe(),bwe(),Nwe(),Gwe(),SCe(),qCe(),XCe(),fIe(),DIe(),jIe(),eDe(),cDe(),U1e(),bDe(),K1e(),PDe(),LDe(),ADe(),wDe(),IDe(),ODe(),GCe(),YDe()]}Fe();var MM=he(UG(),1),KDe=he(l$(),1);mn();var EW=1e6;function QDe(t,e={}){t.getOptions().debug&&V$();let r=ODt(t,e);t.traceProvider=r}function ODt(t,e={}){let r=new KDe.BasicTracerProvider({sampler:new OP(t),resource:(0,MM.defaultResource)().merge((0,MM.resourceFromAttributes)({[lc]:"node",[j9]:"sentry",[W9]:kr})),forceFlushTimeoutMillis:500,spanProcessors:[new RP({timeout:NDt(t.getOptions().maxSpanWaitDuration)}),...e.spanProcessors||[]]});return Ft.setGlobalTracerProvider(r),ea.setGlobalPropagator(new DP),Je.setGlobalContextManager(new HP),r}function NDt(t){if(t!=null){if(t>EW)return Zc&&ne.warn(`\`maxSpanWaitDuration\` is too high, using the maximum value of ${EW}`),EW;if(t<=0||Number.isNaN(t)){Zc&&ne.warn("`maxSpanWaitDuration` must be a positive number, using default value instead.");return}return t}}function JDe(){return zP().filter(e=>e.name!=="Http"&&e.name!=="NodeFetch").concat(WAe(),ZAe())}function XDe(t){return[...JDe(),...Hi(t)?zDe():[]]}function yW(t={}){return PDt(t,XDe)}function PDt(t={},e){Eg(t,"node");let r=Z$({...t,defaultIntegrations:t.defaultIntegrations??e(t)});return r&&!t.skipOpenTelemetrySetup&&(QDe(r,{spanProcessors:t.openTelemetrySpanProcessors}),KP()),r}var tRe=he(require("os"),1);var ZDe="lody",LM="0.2.8";var eRe={name:ZDe,version:LM,description:"Lody Agent CLI tool for managing remote command execution",type:"module",main:"dist/index.cjs",bin:{lody:"dist/index.cjs"},scripts:{dev:"tsx src/index.ts",build:"pnpm run clean && pnpm run typecheck && pnpm run build:bundle && pnpm run copy:wasm","build:watch":"pnpm run build:bundle -- --watch","build:bundle":'esbuild src/index.ts --bundle --platform=node --target=node18 --format=cjs --outfile=dist/index.cjs --minify --legal-comments=none --external:cpu-features --external:*.node --define:process.env.NODE_ENV=\\"production\\" --define:process.env.SENTRY_ENVIRONMENT=\\"production\\"',"copy:wasm":"node scripts/copy-loro-wasm.js",clean:"rimraf dist",format:"prettier --write src/**/*.ts","format:check":"prettier --check src/**/*.ts",typecheck:"tsc --noEmit",test:"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage",prepublishOnly:"npm run clean && npm run build && node scripts/prepare-publish.js",postpublish:"node scripts/prepare-publish.js --restore","serve:dev":"NODE_ENV=development npm run dev serve","serve:prod":"NODE_ENV=production npm run dev serve"},keywords:["cli","typescript","command-line","agent","remote-execution"],author:"Leon Zhao",license:"MIT",engines:{node:">=18.0.0"},devDependencies:{"@agentclientprotocol/sdk":"^0.5.1","@lody/convex":"workspace:*","@lody/shared":"workspace:*","@modelcontextprotocol/sdk":"^1.22.0","@types/dockerode":"^3.3.47","@types/express":"^5.0.5","@types/fs-extra":"^11.0.4","@types/inquirer":"^9.0.9","@types/js-yaml":"^4.0.9","@types/node":"catalog:","@types/throttle-debounce":"^5.0.2","@types/uuid":"^9.0.8","@types/ws":"^8.18.1","@vitest/coverage-v8":"^3.2.4",chalk:"^5.6.2",commander:"^12.1.0",convex:"1.25.4",dockerode:"^4.0.9",dotenv:"^16.6.1",esbuild:"^0.24.2",eventemitter3:"^5.0.1",express:"^4.21.2",inquirer:"^10.2.2","js-yaml":"^4.1.1","loro-adaptors":"catalog:","loro-crdt":"catalog:","loro-mirror":"catalog:","loro-repo":"catalog:","loro-websocket":"catalog:",ora:"^8.2.0",prettier:"^3.6.2",rimraf:"^6.1.2","ts-node":"^10.9.2",tsx:"^4.20.6",typescript:"catalog:",uuid:"^13.0.0",vitest:"^3.2.4",winston:"^3.18.3","winston-daily-rotate-file":"^5.0.0",ws:"^8.18.3"},files:["dist","README.md","LICENSE"],dependencies:{"@sentry/node":"^10.29.0","winston-transport":"^4.7.1","throttle-debounce":"^5.0.2"}};var Nw="production",rRe=process.env.SENTRY_DSN||"https://3ae9811b38d970851d27d1b728ee5e31@o4510491299086336.ingest.us.sentry.io/4510496828882944",kDt=Number(process.env.SENTRY_TRACES_SAMPLE_RATE)||(Nw==="production"?.2:1),MDt=Number(process.env.SENTRY_PROFILES_SAMPLE_RATE)||(Nw==="production"?.1:.25);console.log("en",Nw);var vW=Nw!=="development"&&!!rRe;vW&&(yW({dsn:rRe,environment:Nw,release:`${ZDe}@${LM}`,sendDefaultPii:!0,enableLogs:!0,attachStacktrace:!0,tracesSampleRate:kDt,profilesSampleRate:MDt}),uN({service:"lody-cli",hostname:tRe.default.hostname(),node:process.version}));var TW=(t=2e3)=>vW?CS(t):Promise.resolve(),nRe=(t,e)=>{if(!vW)return Promise.resolve();let r=t instanceof Error?t:new Error(String(t));return tr(r,{tags:e?.component?{component:e.component}:void 0,extra:e?.extra}),TW()};var _Re=he(mRe(),1),{program:Tjr,createCommand:Ajr,createArgument:xjr,createOption:wjr,CommanderError:Cjr,InvalidArgumentError:kw,InvalidOptionArgumentError:Ijr,Command:bc,Argument:Djr,Option:Rjr,Help:Ojr}=_Re.default;var gRe=(t=0)=>e=>`\x1B[${e+t}m`,ERe=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,yRe=(t=0)=>(e,r,n)=>`\x1B[${38+t};2;${e};${r};${n}m`,ni={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Pjr=Object.keys(ni.modifier),JDt=Object.keys(ni.color),XDt=Object.keys(ni.bgColor),kjr=[...JDt,...XDt];function ZDt(){let t=new Map;for(let[e,r]of Object.entries(ni)){for(let[n,i]of Object.entries(r))ni[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[n]=ni[n],t.set(i[0],i[1]);Object.defineProperty(ni,e,{value:r,enumerable:!1})}return Object.defineProperty(ni,"codes",{value:t,enumerable:!1}),ni.color.close="\x1B[39m",ni.bgColor.close="\x1B[49m",ni.color.ansi=gRe(),ni.color.ansi256=ERe(),ni.color.ansi16m=yRe(),ni.bgColor.ansi=gRe(10),ni.bgColor.ansi256=ERe(10),ni.bgColor.ansi16m=yRe(10),Object.defineProperties(ni,{rgbToAnsi256:{value(e,r,n){return e===r&&r===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(s=>s+s).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:e=>ni.rgbToAnsi256(...ni.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,n,i;if(e>=232)r=((e-232)*10+8)/255,n=r,i=r;else{e-=16;let a=e%36;r=Math.floor(e/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let s=Math.max(r,n,i)*2;if(s===0)return 30;let o=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(r));return s===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(e,r,n)=>ni.ansi256ToAnsi(ni.rgbToAnsi256(e,r,n)),enumerable:!1},hexToAnsi:{value:e=>ni.ansi256ToAnsi(ni.hexToAnsi256(e)),enumerable:!1}}),ni}var eRt=ZDt(),pl=eRt;var qM=he(require("node:process"),1),bRe=he(require("node:os"),1),UW=he(require("node:tty"),1);function lu(t,e=globalThis.Deno?globalThis.Deno.args:qM.default.argv){let r=t.startsWith("-")?"":t.length===1?"-":"--",n=e.indexOf(r+t),i=e.indexOf("--");return n!==-1&&(i===-1||n<i)}var{env:ii}=qM.default,UM;lu("no-color")||lu("no-colors")||lu("color=false")||lu("color=never")?UM=0:(lu("color")||lu("colors")||lu("color=true")||lu("color=always"))&&(UM=1);function tRt(){if("FORCE_COLOR"in ii)return ii.FORCE_COLOR==="true"?1:ii.FORCE_COLOR==="false"?0:ii.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(ii.FORCE_COLOR,10),3)}function rRt(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function nRt(t,{streamIsTTY:e,sniffFlags:r=!0}={}){let n=tRt();n!==void 0&&(UM=n);let i=r?UM:n;if(i===0)return 0;if(r){if(lu("color=16m")||lu("color=full")||lu("color=truecolor"))return 3;if(lu("color=256"))return 2}if("TF_BUILD"in ii&&"AGENT_NAME"in ii)return 1;if(t&&!e&&i===void 0)return 0;let s=i||0;if(ii.TERM==="dumb")return s;if(qM.default.platform==="win32"){let o=bRe.default.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in ii)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(o=>o in ii)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(o=>o in ii)||ii.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in ii)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(ii.TEAMCITY_VERSION)?1:0;if(ii.COLORTERM==="truecolor"||ii.TERM==="xterm-kitty"||ii.TERM==="xterm-ghostty"||ii.TERM==="wezterm")return 3;if("TERM_PROGRAM"in ii){let o=Number.parseInt((ii.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(ii.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(ii.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(ii.TERM)||"COLORTERM"in ii?1:s}function SRe(t,e={}){let r=nRt(t,{streamIsTTY:t&&t.isTTY,...e});return rRt(r)}var iRt={stdout:SRe({isTTY:UW.default.isatty(1)}),stderr:SRe({isTTY:UW.default.isatty(2)})},vRe=iRt;function TRe(t,e,r){let n=t.indexOf(e);if(n===-1)return t;let i=e.length,s=0,o="";do o+=t.slice(s,n)+e+r,s=n+i,n=t.indexOf(e,s);while(n!==-1);return o+=t.slice(s),o}function ARe(t,e,r,n){let i=0,s="";do{let o=t[n-1]==="\r";s+=t.slice(i,o?n-1:n)+e+(o?`\r
161
+ >>> no match, partial?`,e,d,r,h),d===c))}let _;if(typeof l=="string"?(_=f===l,this.debug("string match",l,f,_)):(_=l.test(f),this.debug("pattern match",l,f,_)),!_)return!1}if(o===c&&a===u)return!0;if(o===c)return n;if(a===u)return o===c-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return Bxe(this.pattern,this.options)}parse(e){Z1(e);let r=this.options;if(e==="**")return tu;if(e==="")return"";let n,i=null;(n=e.match(g1t))?i=r.dot?y1t:E1t:(n=e.match(a1t))?i=(r.nocase?r.dot?f1t:l1t:r.dot?u1t:c1t)(n[1]):(n=e.match(S1t))?i=(r.nocase?r.dot?v1t:b1t:r.dot?T1t:A1t)(n):(n=e.match(d1t))?i=r.dot?p1t:h1t:(n=e.match(m1t))&&(i=_1t);let s=ib.fromGlob(e,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?C1t:r.dot?I1t:D1t,i=new Set(r.nocase?["i"]:[]),s=e.map(c=>{let u=c.map(l=>{if(l instanceof RegExp)for(let f of l.flags.split(""))i.add(f);return typeof l=="string"?k1t(l):l===tu?tu:l._src});return u.forEach((l,f)=>{let d=u[f+1],h=u[f-1];l!==tu||h===tu||(h===void 0?d!==void 0&&d!==tu?u[f+1]="(?:\\/|"+n+"\\/)?"+d:u[f]=n:d===void 0?u[f-1]=h+"(?:\\/|"+n+")?":d!==tu&&(u[f-1]=h+"(?:\\/|\\/"+n+"\\/)"+d,u[f+1]=tu))}),u.filter(l=>l!==tu).join("/")}).join("|"),[o,a]=e.length>1?["(?:",")"]:["",""];s="^"+o+s+a+"$",this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,r=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&r)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a=0;a<s.length;a++){let c=s[a],u=i;if(n.matchBase&&c.length===1&&(u=[o]),this.matchOne(u,c,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return oo.defaults(e).Minimatch}};oo.AST=ib;oo.Minimatch=sb;oo.escape=uV;oo.unescape=Em;var Uxe="@fastify/otel",L1t="0.8.0",F1t=">=4.0.0 <6",qxe=["onRequest","preParsing","preValidation","preHandler","preSerialization","onSend","onResponse","onError"],Yn={HOOK_NAME:"hook.name",FASTIFY_TYPE:"fastify.type",HOOK_CALLBACK_NAME:"hook.callback.name",ROOT:"fastify.root"},ym={ROUTE:"route-hook",INSTANCE:"hook",HANDLER:"request-handler"},hh="anonymous",aa=Symbol("fastify otel instance"),Sm=Symbol("fastify otel request spans"),tw=Symbol("fastify otel request context"),jxe=Symbol("fastify otel addhook original"),Hxe=Symbol("fastify otel setnotfound original"),sk=Symbol("fastify otel ignore path"),ok=class extends Gxe.InstrumentationBase{constructor(e){if(super(Uxe,L1t,e),this.servername=e?.servername??process.env.OTEL_SERVICE_NAME??"fastify",this[sk]=null,this._logger=Zo.createComponentLogger({namespace:Uxe}),e?.ignorePaths!=null||process.env.OTEL_FASTIFY_IGNORE_PATHS!=null){let r=e?.ignorePaths??process.env.OTEL_FASTIFY_IGNORE_PATHS;if((typeof r!="string"||r.length===0)&&typeof r!="function")throw new TypeError("ignorePaths must be a string or a function");let n=oo;this[sk]=i=>typeof r=="function"?r(i):n(i.url,r)}}enable(){if(this._handleInitialization===void 0&&this.getConfig().registerOnInitialization){let e=this.plugin();this._handleInitialization=r=>{r.fastify.register(e)},lV.default.subscribe("fastify.initialization",this._handleInitialization)}return super.enable()}disable(){return this._handleInitialization&&(lV.default.unsubscribe("fastify.initialization",this._handleInitialization),this._handleInitialization=void 0),super.disable()}init(){return[]}plugin(){let e=this;return r[Symbol.for("skip-override")]=!0,r[Symbol.for("fastify.display-name")]="@fastify/otel",r[Symbol.for("plugin-meta")]={fastify:F1t,name:"@fastify/otel"},r;function r(n,i,s){n.decorate(aa,e),n.decorate(jxe,n.addHook),n.decorate(Hxe,n.setNotFoundHandler),n.decorateRequest("opentelemetry",function(){let d=this[tw];return{span:this[Sm],tracer:e.tracer,context:d,inject:(p,_)=>ea.inject(d,p,_),extract:(p,_)=>ea.extract(d,p,_)}}),n.decorateRequest(Sm,null),n.decorateRequest(tw,null),n.addHook("onRoute",function(f){if(e[sk]?.(f)===!0){e._logger.debug(`Ignoring route instrumentation ${f.method} ${f.url} because it matches the ignore path`);return}for(let d of qxe)if(f[d]!=null){let h=f[d];if(typeof h=="function")f[d]=l(h,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - route -> ${d}`,[Yn.FASTIFY_TYPE]:ym.ROUTE,[ba]:f.url,[Yn.HOOK_CALLBACK_NAME]:h.name?.length>0?h.name:hh});else if(Array.isArray(h)){let p=[];for(let _ of h)p.push(l(_,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - route -> ${d}`,[Yn.FASTIFY_TYPE]:ym.ROUTE,[ba]:f.url,[Yn.HOOK_CALLBACK_NAME]:_.name?.length>0?_.name:hh}));f[d]=p}}f.onSend!=null?f.onSend=Array.isArray(f.onSend)?[...f.onSend,o]:[f.onSend,o]:f.onSend=o,f.onError!=null?f.onError=Array.isArray(f.onError)?[...f.onError,a]:[f.onError,a]:f.onError=a,f.handler=l(f.handler,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - route-handler`,[Yn.FASTIFY_TYPE]:ym.HANDLER,[ba]:f.url,[Yn.HOOK_CALLBACK_NAME]:f.handler.name.length>0?f.handler.name:hh})}),n.addHook("onRequest",function(f,d,h){if(this[aa].isEnabled()===!1)return h();if(this[aa][sk]?.({url:f.url,method:f.method})===!0)return this[aa]._logger.debug(`Ignoring request ${f.method} ${f.url} because it matches the ignore path`),h();let p=Je.active();Ft.getSpan(p)==null&&(p=ea.extract(p,f.headers));let _=(0,ak.getRPCMetadata)(p);f.routeOptions.url!=null&&_?.type===ak.RPCType.HTTP&&(_.route=f.routeOptions.url);let g=this[aa].tracer.startSpan("request",{attributes:{[lc]:n[aa].servername,[Yn.ROOT]:"@fastify/otel",[ba]:f.url,[Xd]:f.method}},p);f[tw]=Ft.setSpan(p,g),f[Sm]=g,Je.with(f[tw],()=>{h()})}),n.addHook("onResponse",function(f,d,h){let p=f[Sm];p!=null&&(p.setStatus({code:ti.OK,message:"OK"}),p.setAttributes({[cf]:404}),p.end()),f[Sm]=null,h()}),n.addHook=c,n.setNotFoundHandler=u,s();function o(f,d,h,p){let _=f[Sm];_!=null&&(d.statusCode<500&&_.setStatus({code:ti.OK,message:"OK"}),_.setAttributes({[cf]:d.statusCode}),_.end()),f[Sm]=null,p(null,h)}function a(f,d,h,p){let _=f[Sm];_!=null&&(_.setStatus({code:ti.ERROR,message:h.message}),_.recordException(h)),p()}function c(f,d){let h=this[jxe];return qxe.includes(f)?h.call(this,f,l(d,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - ${f}`,[Yn.FASTIFY_TYPE]:ym.INSTANCE,[Yn.HOOK_CALLBACK_NAME]:d.name?.length>0?d.name:hh})):h.call(this,f,d)}function u(f,d){let h=this[Hxe];typeof f=="function"?(d=l(f,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - not-found-handler`,[Yn.FASTIFY_TYPE]:ym.INSTANCE,[Yn.HOOK_CALLBACK_NAME]:f.name?.length>0?f.name:hh}),h.call(this,d)):(f.preValidation!=null&&(f.preValidation=l(f.preValidation,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - not-found-handler - preValidation`,[Yn.FASTIFY_TYPE]:ym.INSTANCE,[Yn.HOOK_CALLBACK_NAME]:f.preValidation.name?.length>0?f.preValidation.name:hh})),f.preHandler!=null&&(f.preHandler=l(f.preHandler,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - not-found-handler - preHandler`,[Yn.FASTIFY_TYPE]:ym.INSTANCE,[Yn.HOOK_CALLBACK_NAME]:f.preHandler.name?.length>0?f.preHandler.name:hh})),d=l(d,{[lc]:n[aa].servername,[Yn.HOOK_NAME]:`${this.pluginName} - not-found-handler`,[Yn.FASTIFY_TYPE]:ym.INSTANCE,[Yn.HOOK_CALLBACK_NAME]:d.name?.length>0?d.name:hh}),h.call(this,f,d))}function l(f,d={}){return function(...p){let _=this[aa],[g]=p;if(_.isEnabled()===!1)return f.call(this,...p);let S=g[tw]??Je.active(),b=_.tracer.startSpan(`handler - ${f.name?.length>0?f.name:this.pluginName??hh}`,{attributes:d},S);return Je.with(Ft.setSpan(S,b),function(){try{let x=f.call(this,...p);return typeof x?.then=="function"?x.then(A=>(b.end(),A),A=>(b.setStatus({code:ti.ERROR,message:A.message}),b.recordException(A),b.end(),Promise.reject(A))):(b.end(),x)}catch(x){throw b.setStatus({code:ti.ERROR,message:x.message}),b.recordException(x),b.end(),x}},this)}}}}};Fe();var lk=he(sn(),1),Dg=he(Qt(),1);mn();var ph;(function(t){let e="fastify.name";t.FASTIFY_NAME=e;let r="fastify.type";t.FASTIFY_TYPE=r;let n="hook.name";t.HOOK_NAME=n;let i="plugin.name";t.PLUGIN_NAME=i})(ph||(ph={}));var rw;(function(t){let e="middleware";t.MIDDLEWARE=e;let r="request_handler";t.REQUEST_HANDLER=r})(rw||(rw={}));var nw;(function(t){let e="middleware";t.MIDDLEWARE=e;let r="request handler";t.REQUEST_HANDLER=r})(nw||(nw={}));Fe();var iw=Symbol("opentelemetry.instrumentation.fastify.request_active_span");function fV(t,e,r,n={}){let i=e.startSpan(r,{attributes:n}),s=t[iw]||[];return s.push(i),Object.defineProperty(t,iw,{enumerable:!1,configurable:!0,value:s}),i}function ck(t,e){let r=t[iw]||[];r.length&&(r.forEach(n=>{e&&(n.setStatus({code:ti.ERROR,message:e.message}),n.recordException(e)),n.end()}),delete t[iw])}function Vxe(t,e,r){let n,i;try{i=t(),$xe(i)&&i.then(s=>e(void 0,s),s=>e(s))}catch(s){n=s}finally{if(!$xe(i)&&(e(n,i),n))throw n;return i}}function $xe(t){return typeof t=="object"&&t&&typeof Object.getOwnPropertyDescriptor(t,"then")?.value=="function"||!1}var B1t="0.1.0",U1t="@sentry/instrumentation-fastify-v3",Wxe="anonymous",q1t=new Set(["onTimeout","onRequest","preParsing","preValidation","preSerialization","preHandler","onSend","onResponse","onError"]),uk=class extends Dg.InstrumentationBase{constructor(e={}){super(U1t,B1t,e)}init(){return[new Dg.InstrumentationNodeModuleDefinition("fastify",[">=3.0.0 <4"],e=>this._patchConstructor(e))]}_hookOnRequest(){let e=this;return function(n,i,s){if(!e.isEnabled())return s();e._wrap(i,"send",e._patchSend());let o=n,a=(0,lk.getRPCMetadata)(Je.active()),c=o.routeOptions?o.routeOptions.url:n.routerPath;c&&a?.type===lk.RPCType.HTTP&&(a.route=c);let u=n.method||"GET";vr().setTransactionName(`${u} ${c}`),s()}}_wrapHandler(e,r,n,i){let s=this;return this._diag.debug("Patching fastify route.handler function"),function(...o){if(!s.isEnabled())return n.apply(this,o);let a=n.name||e||Wxe,c=`${nw.MIDDLEWARE} - ${a}`,u=o[1],l=fV(u,s.tracer,c,{[ph.FASTIFY_TYPE]:rw.MIDDLEWARE,[ph.PLUGIN_NAME]:e,[ph.HOOK_NAME]:r}),f=i&&o[o.length-1];return f&&(o[o.length-1]=function(...d){ck(u),f.apply(this,d)}),Je.with(Ft.setSpan(Je.active(),l),()=>Vxe(()=>n.apply(this,o),d=>{d instanceof Error&&(l.setStatus({code:ti.ERROR,message:d.message}),l.recordException(d)),i||ck(u)}))}}_wrapAddHook(){let e=this;return this._diag.debug("Patching fastify server.addHook function"),function(r){return function(...i){let s=i[0],o=i[1],a=this.pluginName;if(!q1t.has(s))return r.apply(this,i);let c=typeof i[i.length-1]=="function"&&o.constructor.name!=="AsyncFunction";return r.apply(this,[s,e._wrapHandler(a,s,o,c)])}}}_patchConstructor(e){let r=this;function n(...i){let s=e.fastify.apply(this,i);return s.addHook("onRequest",r._hookOnRequest()),s.addHook("preHandler",r._hookPreHandler()),j1t(),r._wrap(s,"addHook",r._wrapAddHook()),s}return e.errorCodes!==void 0&&(n.errorCodes=e.errorCodes),n.fastify=n,n.default=n,n}_patchSend(){let e=this;return this._diag.debug("Patching fastify reply.send function"),function(n){return function(...s){let o=s[0];return e.isEnabled()?(0,Dg.safeExecuteInTheMiddle)(()=>n.apply(this,s),a=>{!a&&o instanceof Error&&(a=o),ck(this,a)}):n.apply(this,s)}}}_hookPreHandler(){let e=this;return this._diag.debug("Patching fastify preHandler function"),function(n,i,s){if(!e.isEnabled())return s();let o=n,a=o.routeOptions?.handler||o.context?.handler,c=a?.name.startsWith("bound ")?a.name.substring(6):a?.name,u=`${nw.REQUEST_HANDLER} - ${c||this.pluginName||Wxe}`,l={[ph.PLUGIN_NAME]:this.pluginName,[ph.FASTIFY_TYPE]:rw.REQUEST_HANDLER,[F9]:o.routeOptions?o.routeOptions.url:n.routerPath};c&&(l[ph.FASTIFY_NAME]=c);let f=fV(i,e.tracer,u,l);Yxe(f);let{requestHook:d}=e.getConfig();return d&&(0,Dg.safeExecuteInTheMiddle)(()=>d(f,{request:n}),h=>{h&&e._diag.error("request hook failed",h)},!0),Je.with(Ft.setSpan(Je.active(),f),()=>{s()})}}};function j1t(){let t=Ve();t&&t.on("spanStart",e=>{Yxe(e)})}function Yxe(t){let e=It(t).data,r=e["fastify.type"];if(e[bt]||!r)return;t.setAttributes({[zt]:"auto.http.otel.fastify",[bt]:`${r}.fastify`});let n=e["fastify.name"]||e["plugin.name"]||e["hook.name"];if(typeof n=="string"){let i=n.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");t.updateName(i)}}var fk="Fastify",Kxe=at(`${fk}.v3`,()=>new uk);function H1t(){let t=Ve();if(t)return t.getIntegrationByName(fk)}function zxe(t,e,r,n){let i=H1t()?.getShouldHandleError()||Xxe;if(n==="diagnostics-channel"&&(this.diagnosticsChannelExists=!0),this.diagnosticsChannelExists&&n==="onError-hook"){Zc&&ne.warn("Fastify error handler was already registered via diagnostics channel.","You can safely remove `setupFastifyErrorHandler` call and set `shouldHandleError` on the integration options.");return}i(t,e,r)&&tr(t,{mechanism:{handled:!1,type:"auto.function.fastify"}})}var Qxe=at(`${fk}.v5`,()=>{let t=new ok,e=t.plugin();return dV.subscribe("fastify.initialization",r=>{let n=r.fastify;n?.register(e).after(i=>{i?Zc&&ne.error("Failed to setup Fastify instrumentation",i):($1t(),n&&V1t(n))})}),dV.subscribe("tracing:fastify.request.handler:error",r=>{let{error:n,request:i,reply:s}=r;zxe.call(zxe,n,i,s,"diagnostics-channel")}),t}),G1t=({shouldHandleError:t})=>{let e;return{name:fk,setupOnce(){e=t||Xxe,Kxe(),Qxe()},getShouldHandleError(){return e},setShouldHandleError(r){e=r}}},Jxe=(t={})=>G1t(t);function Xxe(t,e,r){let n=r.statusCode;return n>=500||n<=299}function Zxe(t){let e=It(t),r=e.description,n=e.data,i=n["fastify.type"],s=i==="hook",o=i===r?.startsWith("handler -"),a=r==="request"||i==="request-handler";if(n[bt]||!o&&!a&&!s)return;let c=s?"hook":o?"middleware":a?"request-handler":"<unknown>";t.setAttributes({[zt]:"auto.http.otel.fastify",[bt]:`${c}.fastify`});let u=n["fastify.name"]||n["plugin.name"]||n["hook.name"];if(typeof u=="string"){let l=u.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");t.updateName(l)}}function $1t(){let t=Ve();t&&t.on("spanStart",e=>{Zxe(e)})}function V1t(t){t.addHook("onRequest",async(e,r)=>{if(e.opentelemetry){let{span:s}=e.opentelemetry();s&&Zxe(s)}let n=e.routeOptions?.url,i=e.method||"GET";vr().setTransactionName(`${i} ${n}`)})}Fe();var S1e=he(y1e(),1);var b1e="Graphql",v1e=at(b1e,S1e.GraphQLInstrumentation,t=>{let e=A1e(t);return{...e,responseHook(r,n){An(r,"auto.graphql.otel.graphql"),n.errors?.length&&!It(r).status&&r.setStatus({code:ti.ERROR});let s=It(r).data,o=s["graphql.operation.type"],a=s["graphql.operation.name"];if(e.useOperationNameForRootSpan&&o){let c=Ai(r),l=It(c).data[KS]||[],f=a?`${o} ${a}`:`${o}`;Array.isArray(l)?(l.push(f),c.setAttribute(KS,l)):typeof l=="string"?c.setAttribute(KS,[l,f]):c.setAttribute(KS,f),It(c).data["original-description"]||c.setAttribute("original-description",It(c).description),c.updateName(`${It(c).data["original-description"]} (${dwt(l)})`)}}}}),fwt=(t={})=>({name:b1e,setupOnce(){v1e(A1e(t))}}),T1e=fwt;function A1e(t){return{ignoreResolveSpans:!0,ignoreTrivialResolveSpans:!0,useOperationNameForRootSpan:!0,...t}}function dwt(t){if(Array.isArray(t)){let e=t.slice().sort();return e.length<=5?e.join(", "):`${e.slice(0,5).join(", ")}, +${e.length-5}`}return`${t}`}var L1e=he(M1e(),1);var F1e="Kafka",B1e=at(F1e,()=>new L1e.KafkaJsInstrumentation({consumerHook(t){An(t,"auto.kafkajs.otel.consumer")},producerHook(t){An(t,"auto.kafkajs.otel.producer")}})),pwt=()=>({name:F1e,setupOnce(){B1e()}}),U1e=pwt;var W1e=he(V1e(),1);var Y1e="LruMemoizer",z1e=at(Y1e,()=>new W1e.LruMemoizerInstrumentation),_wt=()=>({name:Y1e,setupOnce(){z1e()}}),K1e=_wt;var iwe=he(nwe(),1);var swe="Mongo",owe=at(swe,()=>new iwe.MongoDBInstrumentation({dbStatementSerializer:bwt,responseHook(t){An(t,"auto.db.otel.mongo")}}));function bwt(t){let e=bV(t);return JSON.stringify(e)}function bV(t){if(Array.isArray(t))return t.map(e=>bV(e));if(vwt(t)){let e={};return Object.entries(t).map(([r,n])=>[r,bV(n)]).reduce((r,n)=>(Awt(n)&&(r[n[0]]=n[1]),r),e)}return"?"}function vwt(t){return typeof t=="object"&&t!==null&&!Twt(t)}function Twt(t){let e=!1;return typeof Buffer<"u"&&(e=Buffer.isBuffer(t)),e}function Awt(t){return Array.isArray(t)}var xwt=()=>({name:swe,setupOnce(){owe()}}),awe=xwt;var Ewe=he(gwe(),1);var ywe="Mongoose",Swe=at(ywe,()=>new Ewe.MongooseInstrumentation({responseHook(t){An(t,"auto.db.otel.mongoose")}})),Mwt=()=>({name:ywe,setupOnce(){Swe()}}),bwe=Mwt;var Dwe=he(Iwe(),1);var Rwe="Mysql",Owe=at(Rwe,()=>new Dwe.MySQLInstrumentation({})),Vwt=()=>({name:Rwe,setupOnce(){Owe()}}),Nwe=Vwt;var qwe=he(Uwe(),1);var jwe="Mysql2",Hwe=at(jwe,()=>new qwe.MySQL2Instrumentation({responseHook(t){An(t,"auto.db.otel.mysql2")}})),oCt=()=>({name:jwe,setupOnce(){Hwe()}}),Gwe=oCt;var _Ce=he(Jwe(),1),gCe=he(fCe(),1);var xCt=["get","set","setex"],HV=["get","mget"],wCt=["set","setex"];function gw(t,e){return t.includes(e.toLowerCase())}function GV(t){return gw(HV,t)?"cache.get":gw(wCt,t)?"cache.put":void 0}function CCt(t,e){return e.some(r=>t.startsWith(r))}function hCe(t,e){try{if(e.length===0)return;let r=i=>typeof i=="string"||typeof i=="number"||Buffer.isBuffer(i)?[i.toString()]:Array.isArray(i)?dCe(i.map(s=>r(s))):["<unknown>"],n=e[0];return gw(xCt,t)&&n!=null?r(n):dCe(e.map(i=>r(i)))}catch{return}}function pCe(t,e,r){if(!GV(t))return!1;for(let n of e)if(CCt(n,r))return!0;return!1}function mCe(t){let e=r=>{try{return Buffer.isBuffer(r)?r.byteLength:typeof r=="string"?r.length:typeof r=="number"?r.toString().length:r==null?0:JSON.stringify(r).length}catch{return}};return Array.isArray(t)?t.reduce((r,n)=>{let i=e(n);return typeof i=="number"?r!==void 0?r+i:i:r},0):e(t)}function dCe(t){let e=[],r=n=>{n.forEach(i=>{Array.isArray(i)?r(i):e.push(i)})};return r(t),e}var Kk="Redis",Ew={},ECe=(t,e,r,n)=>{t.setAttribute(zt,"auto.db.otel.redis");let i=hCe(e,r),s=GV(e);if(!i||!s||!Ew.cachePrefixes||!pCe(e,i,Ew.cachePrefixes))return;let o=It(t).data["net.peer.name"],a=It(t).data["net.peer.port"];a&&o&&t.setAttributes({"network.peer.address":o,"network.peer.port":a});let c=mCe(n);c&&t.setAttribute(AH,c),gw(HV,e)&&c!==void 0&&t.setAttribute(vH,c>0),t.setAttributes({[bt]:s,[TH]:i});let u=i.join(", ");t.updateName(Ew.maxCacheKeyLength?Kp(u,Ew.maxCacheKeyLength):u)},ICt=at(`${Kk}.IORedis`,()=>new _Ce.IORedisInstrumentation({responseHook:ECe})),DCt=at(`${Kk}.Redis`,()=>new gCe.RedisInstrumentation({responseHook:ECe})),yCe=Object.assign(()=>{ICt(),DCt()},{id:Kk}),RCt=(t={})=>({name:Kk,setupOnce(){Ew=t,yCe()}}),SCe=RCt;var FCe=he(LCe(),1);var BCe="Postgres",UCe=at(BCe,()=>new FCe.PgInstrumentation({requireParentSpan:!0,requestHook(t){An(t,"auto.db.otel.postgres")}})),VCt=()=>({name:BCe,setupOnce(){UCe()}}),qCe=VCt;Fe();var Eh=he(Qt(),1);mn();var QV="PostgresJs",jCe=[">=3.0.0 <4"],HCe=at(QV,t=>new KV({requireParentSpan:t?.requireParentSpan??!0,requestHook:t?.requestHook})),KV=class extends Eh.InstrumentationBase{constructor(e){super("sentry-postgres-js",kr,e)}init(){let e=new Eh.InstrumentationNodeModuleDefinition("postgres",jCe);return["src","cf/src","cjs/src"].forEach(r=>{e.files.push(new Eh.InstrumentationNodeModuleFile(`postgres/${r}/connection.js`,["*"],this._patchConnection.bind(this),this._unwrap.bind(this))),e.files.push(new Eh.InstrumentationNodeModuleFile(`postgres/${r}/query.js`,jCe,this._patchQuery.bind(this),this._unwrap.bind(this)))}),[e]}_shouldCreateSpans(){let e=this.getConfig();return Ft.getSpan(Je.active())!==void 0||!e.requireParentSpan}_patchReject(e,r){return new Proxy(e,{apply:(n,i,s)=>{r.setStatus({code:2,message:s?.[0]?.message||"internal_error"});let o=Reflect.apply(n,i,s);return r.setAttribute($9,s?.[0]?.code||"Unknown error"),r.setAttribute(V9,s?.[0]?.name||"Unknown error"),r.end(),o}})}_patchResolve(e,r){return new Proxy(e,{apply:(n,i,s)=>{let o=Reflect.apply(n,i,s),a=s?.[0]?.command;return a&&r.setAttribute(kx,a),r.end(),o}})}_patchQuery(e){return e.Query.prototype.handle=new Proxy(e.Query.prototype.handle,{apply:async(r,n,i)=>{if(!this._shouldCreateSpans())return Reflect.apply(r,n,i);let s=this._sanitizeSqlQuery(n.strings?.[0]);return Po({name:s||"postgresjs.query",op:"db"},o=>{let c=Gr().getScopeData().contexts.postgresjsConnection;An(o,"auto.db.otel.postgres");let{requestHook:u}=this.getConfig();u&&(0,Eh.safeExecuteInTheMiddle)(()=>u(o,s,c),h=>{h&&ne.error(`Error in requestHook for ${QV} integration:`,h)});let l=c?.ATTR_DB_NAMESPACE||"<unknown database>",f=c?.ATTR_SERVER_ADDRESS||"<unknown host>",d=c?.ATTR_SERVER_PORT||"<unknown port>";o.setAttribute(Mx,"postgres"),o.setAttribute(Px,l),o.setAttribute(Lx,f),o.setAttribute(Fx,d),o.setAttribute(G9,s),n.resolve=this._patchResolve(n.resolve,o),n.reject=this._patchReject(n.reject,o);try{return Reflect.apply(r,n,i)}catch(h){throw o.setStatus({code:2}),o.end(),h}})}}),e}_patchConnection(e){return new Proxy(e,{apply:(r,n,i)=>{let s=i[0]?.database||"<unknown database>",o=i[0]?.host?.[0]||"<unknown host>",a=i[0]?.port?.[0]||"<unknown port>";return Gr().setContext("postgresjsConnection",{ATTR_DB_NAMESPACE:s,ATTR_SERVER_ADDRESS:o,ATTR_SERVER_PORT:a}),Reflect.apply(r,n,i)}})}_sanitizeSqlQuery(e){return e?e.replace(/\s+/g," ").trim().substring(0,1024).replace(/--.*?(\r?\n|$)/g,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/;\s*$/,"").replace(/\b\d+\b/g,"?").replace(/\s+/g," ").replace(/\bIN\b\s*\(\s*\?(?:\s*,\s*\?)*\s*\)/g,"IN (?)"):"Unknown SQL Query"}},WCt=()=>({name:QV,setupOnce(){HCe()}}),GCe=WCt;Fe();Fe();var rM=he(Qt(),1);Fe();var YCt=process.env.PRISMA_SHOW_ALL_TRACES==="true",zCt="00-10-10-00";function KCt(t){switch(t){case"client":return Un.CLIENT;case"internal":default:return Un.INTERNAL}}var QCt=class{tracerProvider;ignoreSpanTypes;constructor({tracerProvider:t,ignoreSpanTypes:e}){this.tracerProvider=t,this.ignoreSpanTypes=e}isEnabled(){return!0}getTraceParent(t){let e=Ft.getSpanContext(t??Je.active());return e?`00-${e.traceId}-${e.spanId}-0${e.traceFlags}`:zCt}dispatchEngineSpans(t){let e=this.tracerProvider.getTracer("prisma"),r=new Map,n=t.filter(i=>i.parentId===null);for(let i of n)WCe(e,i,t,r,this.ignoreSpanTypes)}getActiveContext(){return Je.active()}runInChildSpan(t,e){if(typeof t=="string"&&(t={name:t}),t.internal&&!YCt)return e();let r=this.tracerProvider.getTracer("prisma"),n=t.context??this.getActiveContext(),i=`prisma:client:${t.name}`;if(YCe(i,this.ignoreSpanTypes))return e();if(t.active===!1){let s=r.startSpan(i,t,n);return $Ce(s,e(s,n))}return r.startActiveSpan(i,t,s=>$Ce(s,e(s,n)))}};function WCe(t,e,r,n,i){if(YCe(e.name,i))return;let s={attributes:e.attributes,kind:KCt(e.kind),startTime:e.startTime};t.startActiveSpan(e.name,s,o=>{n.set(e.id,o.spanContext().spanId),e.links&&o.addLinks(e.links.flatMap(c=>{let u=n.get(c);return u?{context:{spanId:u,traceId:o.spanContext().traceId,traceFlags:o.spanContext().traceFlags}}:[]}));let a=r.filter(c=>c.parentId===e.id);for(let c of a)WCe(t,c,r,n,i);o.end(e.endTime)})}function $Ce(t,e){return JCt(e)?e.then(r=>(t.end(),r),r=>{throw t.end(),r}):(t.end(),e)}function JCt(t){return t!=null&&typeof t.then=="function"}function YCe(t,e){return e.some(r=>typeof r=="string"?r===t:r.test(t))}var zCe={name:"@prisma/instrumentation",version:"6.19.0",description:"OpenTelemetry compliant instrumentation for Prisma Client",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{require:{types:"./dist/index.d.ts",default:"./dist/index.js"},import:{types:"./dist/index.d.ts",default:"./dist/index.mjs"}}},license:"Apache-2.0",homepage:"https://www.prisma.io",repository:{type:"git",url:"https://github.com/prisma/prisma.git",directory:"packages/instrumentation"},bugs:"https://github.com/prisma/prisma/issues",devDependencies:{"@prisma/internals":"workspace:*","@types/node":"18.19.76","@opentelemetry/api":"1.9.0",typescript:"5.4.5"},dependencies:{"@opentelemetry/instrumentation":">=0.52.0 <1"},peerDependencies:{"@opentelemetry/api":"^1.8"},files:["dist"],keywords:["prisma","instrumentation","opentelemetry","otel"],scripts:{dev:"DEV=true tsx helpers/build.ts",build:"tsx helpers/build.ts",prepublishOnly:"pnpm run build",test:"vitest run"},sideEffects:!1},XV=zCe.version,XCt=XV.split(".")[0],VCe="PRISMA_INSTRUMENTATION",JV=`V${XCt}_PRISMA_INSTRUMENTATION`,ZCt=zCe.name,eIt="@prisma/client",KCe=class extends rM.InstrumentationBase{tracerProvider;constructor(t={}){super(ZCt,XV,t)}setTracerProvider(t){this.tracerProvider=t}init(){return[new rM.InstrumentationNodeModuleDefinition(eIt,[XV])]}enable(){let t=this._config,e={helper:new QCt({tracerProvider:this.tracerProvider??Ft.getTracerProvider(),ignoreSpanTypes:t.ignoreSpanTypes??[]})};global[VCe]=e,global[JV]=e}disable(){delete global[VCe],delete global[JV]}isEnabled(){return!!global[JV]}};var QCe="Prisma";function tIt(t){return!!t&&typeof t=="object"&&"dispatchEngineSpans"in t}function JCe(){let t=globalThis.PRISMA_INSTRUMENTATION;return t&&typeof t=="object"&&"helper"in t?t.helper:void 0}var ZV=class extends KCe{constructor(){super()}enable(){super.enable();let e=JCe();tIt(e)&&(e.createEngineSpan=r=>{let n=Ft.getTracer("prismaV5Compatibility"),i=n._idGenerator;if(!i){hi(()=>{console.warn("[Sentry] Could not find _idGenerator on tracer, skipping Prisma v5 compatibility - some Prisma spans may be missing!")});return}try{r.spans.forEach(s=>{let o=rIt(s.kind),a=s.parent_span_id,c=s.span_id,u=s.trace_id,l=s.links?.map(d=>({context:{traceId:d.trace_id,spanId:d.span_id,traceFlags:Xo.SAMPLED}})),f=Ft.setSpanContext(Je.active(),{traceId:u,spanId:a,traceFlags:Xo.SAMPLED});Je.with(f,()=>{let d={generateTraceId:()=>u,generateSpanId:()=>c};n._idGenerator=d,n.startSpan(s.name,{kind:o,links:l,startTime:s.start_time,attributes:s.attributes}).end(s.end_time),n._idGenerator=i})})}finally{n._idGenerator=i}})}};function rIt(t){switch(t){case"client":return Un.CLIENT;case"internal":default:return Un.INTERNAL}}var nIt=at(QCe,t=>new ZV),XCe=t=>({name:QCe,setupOnce(){nIt()},setup(e){JCe()&&e.on("spanStart",r=>{let n=It(r);n.description?.startsWith("prisma:")&&r.setAttribute(zt,"auto.db.otel.prisma"),n.description==="prisma:engine:db_query"&&n.data["db.query.text"]&&r.updateName(n.data["db.query.text"]),n.description==="prisma:engine:db_query"&&!n.data["db.system"]&&r.setAttribute("db.system","prisma")})}});var cIe=he(aIe(),1);var uIe="Hapi",lIe=at(uIe,()=>new cIe.HapiInstrumentation),_It=()=>({name:uIe,setupOnce(){lIe()}}),fIe=_It;mn();var Im={HONO_TYPE:"hono.type",HONO_NAME:"hono.name"},ww={MIDDLEWARE:"middleware",REQUEST_HANDLER:"request_handler"};Fe();var oM=he(Qt(),1);var gIt="@sentry/instrumentation-hono",EIt="0.0.1",sM=class extends oM.InstrumentationBase{constructor(e={}){super(gIt,EIt,e)}init(){return[new oM.InstrumentationNodeModuleDefinition("hono",[">=4.0.0 <5"],e=>this._patch(e))]}_patch(e){let r=this;class n extends e.Hono{constructor(...s){super(...s),r._wrap(this,"get",r._patchHandler()),r._wrap(this,"post",r._patchHandler()),r._wrap(this,"put",r._patchHandler()),r._wrap(this,"delete",r._patchHandler()),r._wrap(this,"options",r._patchHandler()),r._wrap(this,"patch",r._patchHandler()),r._wrap(this,"all",r._patchHandler()),r._wrap(this,"on",r._patchOnHandler()),r._wrap(this,"use",r._patchMiddlewareHandler())}}try{e.Hono=n}catch{return{...e,Hono:n}}return e}_patchHandler(){let e=this;return function(r){return function(...i){if(typeof i[0]=="string"){let s=i[0];if(i.length===1)return r.apply(this,[s]);let o=i.slice(1);return r.apply(this,[s,...o.map(a=>e._wrapHandler(a))])}return r.apply(this,i.map(s=>e._wrapHandler(s)))}}}_patchOnHandler(){let e=this;return function(r){return function(...i){let s=i.slice(2);return r.apply(this,[...i.slice(0,2),...s.map(o=>e._wrapHandler(o))])}}}_patchMiddlewareHandler(){let e=this;return function(r){return function(...i){if(typeof i[0]=="string"){let s=i[0];if(i.length===1)return r.apply(this,[s]);let o=i.slice(1);return r.apply(this,[s,...o.map(a=>e._wrapHandler(a))])}return r.apply(this,i.map(s=>e._wrapHandler(s)))}}}_wrapHandler(e){let r=this;return function(n,i){if(!r.isEnabled())return e.apply(this,[n,i]);let s=n.req.path,o=r.tracer.startSpan(s);return Je.with(Ft.setSpan(Je.active(),o),()=>r._safeExecute(()=>{let a=e.apply(this,[n,i]);if(ia(a))return a.then(c=>{let u=r._determineHandlerType(c);return o.setAttributes({[Im.HONO_TYPE]:u,[Im.HONO_NAME]:u===ww.REQUEST_HANDLER?s:e.name||"anonymous"}),r.getConfig().responseHook?.(o),c});{let c=r._determineHandlerType(a);return o.setAttributes({[Im.HONO_TYPE]:c,[Im.HONO_NAME]:c===ww.REQUEST_HANDLER?s:e.name||"anonymous"}),r.getConfig().responseHook?.(o),a}},()=>o.end(),a=>{r._handleError(o,a),o.end()}))}}_safeExecute(e,r,n){try{let i=e();return ia(i)?i.then(()=>r(),s=>n(s)):r(),i}catch(i){throw n(i),i}}_determineHandlerType(e){return e===void 0?ww.MIDDLEWARE:ww.REQUEST_HANDLER}_handleError(e,r){r instanceof Error&&(e.setStatus({code:ti.ERROR,message:r.message}),e.recordException(r))}};var dIe="Hono";function yIt(t){let e=It(t).data,r=e[Im.HONO_TYPE];if(e[bt]||!r)return;t.setAttributes({[zt]:"auto.http.otel.hono",[bt]:`${r}.hono`});let n=e[Im.HONO_NAME];if(typeof n=="string"&&t.updateName(n),vr()===zc()){Zc&&ne.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let i=e[ba],s=e[Xd];typeof i=="string"&&typeof s=="string"&&vr().setTransactionName(`${s} ${i}`)}var hIe=at(dIe,()=>new sM({responseHook:t=>{yIt(t)}})),SIt=()=>({name:dIe,setupOnce(){hIe()}}),pIe=SIt;var wIe=he(xIe(),1);mn();var CIe="Koa",IIe=at(CIe,wIe.KoaInstrumentation,(t={})=>({ignoreLayersType:t.ignoreLayersType,requestHook(e,r){An(e,"auto.http.otel.koa");let n=It(e).data,i=n["koa.type"];i&&e.setAttribute(bt,`${i}.koa`);let s=n["koa.name"];if(typeof s=="string"&&e.updateName(s||"< unknown >"),vr()===zc()){Zc&&ne.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let o=n[ba],a=r.context?.request?.method?.toUpperCase()||"GET";o&&vr().setTransactionName(`${a} ${o}`)}})),DIt=(t={})=>({name:CIe,setupOnce(){IIe(t)}}),DIe=DIt;var BIe=he(FIe(),1);var UIe="Connect",qIe=at(UIe,()=>new BIe.ConnectInstrumentation),UIt=()=>({name:UIe,setupOnce(){qIe()}}),jIe=UIt;var JIe=he(QIe(),1);var $It=new Set(["callProcedure","execSql","execSqlBatch","execBulkLoad","prepare","execute"]),XIe="Tedious",ZIe=at(XIe,()=>new JIe.TediousInstrumentation({})),VIt=()=>{let t;return{name:XIe,setupOnce(){let e=ZIe();t=C1(e)},setup(e){t?.(()=>e.on("spanStart",r=>{let{description:n,data:i}=It(r);if(!n||i["db.system"]!=="mssql")return;let s=n.split(" ")[0]||"";$It.has(s)&&r.setAttribute(zt,"auto.db.otel.tedious")}))}}},eDe=VIt;var sDe=he(iDe(),1);var oDe="GenericPool",aDe=at(oDe,()=>new sDe.GenericPoolInstrumentation({})),YIt=()=>{let t;return{name:oDe,setupOnce(){let e=aDe();t=C1(e)},setup(e){t?.(()=>e.on("spanStart",r=>{let i=It(r).description;(i==="generic-pool.aquire"||i==="generic-pool.acquire")&&r.setAttribute(zt,"auto.db.otel.generic_pool")}))}}},cDe=YIt;var EDe=he(gDe(),1);var yDe="Amqplib",iDt={consumeEndHook:t=>{An(t,"auto.amqplib.otel.consumer")},publishHook:t=>{An(t,"auto.amqplib.otel.publisher")}},SDe=at(yDe,()=>new EDe.AmqplibInstrumentation(iDt)),sDt=()=>({name:yDe,setupOnce(){SDe()}}),bDe=sDt;var Ow="VercelAI";var TM=he(Qt(),1);var vDe=["generateText","streamText","generateObject","streamObject","embed","embedMany"];function oDt(t){if(typeof t!="object"||t===null)return!1;let e=t;return"type"in e&&"error"in e&&"toolName"in e&&"toolCallId"in e&&e.type==="tool-error"&&e.error instanceof Error}function aDt(t){if(typeof t!="object"||t===null||!("content"in t))return;let e=t;if(Array.isArray(e.content)){for(let r of e.content)if(oDt(r)){let n=uG(r.toolCallId);if(n){let i=n.spanContext();Kc(s=>{s.setContext("trace",{trace_id:i.traceId,span_id:i.spanId}),s.setTag("vercel.ai.tool.name",r.toolName),s.setTag("vercel.ai.tool.callId",r.toolCallId),s.setLevel("error"),tr(r.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})}),lG(r.toolCallId)}else Kc(i=>{i.setTag("vercel.ai.tool.name",r.toolName),i.setTag("vercel.ai.tool.callId",r.toolCallId),i.setLevel("error"),tr(r.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})})}}}function cDt(t,e,r,n){let i=t?.recordInputs!==void 0?t.recordInputs:e.recordInputs!==void 0?e.recordInputs:r===!0?!0:n,s=t?.recordOutputs!==void 0?t.recordOutputs:e.recordOutputs!==void 0?e.recordOutputs:r===!0?!0:n;return{recordInputs:i,recordOutputs:s}}var vM=class t extends TM.InstrumentationBase{__init(){this._isPatched=!1}__init2(){this._callbacks=[]}constructor(e={}){super("@sentry/instrumentation-vercel-ai",kr,e),t.prototype.__init.call(this),t.prototype.__init2.call(this)}init(){return new TM.InstrumentationNodeModuleDefinition("ai",[">=3.0.0 <6"],this._patch.bind(this))}callWhenPatched(e){this._isPatched?e():this._callbacks.push(e)}_patch(e){this._isPatched=!0,this._callbacks.forEach(n=>n()),this._callbacks=[];let r=n=>new Proxy(n,{apply:(i,s,o)=>{let a=o[0].experimental_telemetry||{},c=a.isEnabled,u=Ve(),l=u?.getIntegrationByName(Ow),f=l?.options,d=l?!!u?.getOptions().sendDefaultPii:!1,{recordInputs:h,recordOutputs:p}=cDt(f,a,c,d);return o[0].experimental_telemetry={...a,isEnabled:c!==void 0?c:!0,recordInputs:h,recordOutputs:p},hc(()=>Reflect.apply(i,s,o),_=>{_&&typeof _=="object"&&ss(_,"_sentry_active_span",mf())},()=>{},_=>{aDt(_)})}});if(Object.prototype.toString.call(e)==="[object Module]"){for(let n of vDe)e[n]=r(e[n]);return e}else{let n=vDe.reduce((i,s)=>(i[s]=r(e[s]),i),{});return{...e,...n}}}};var TDe=at(Ow,()=>new vM({}));function uDt(t){return!!t.getIntegrationByName("Modules")?.getModules?.()?.ai}var lDt=(t={})=>{let e;return{name:Ow,options:t,setupOnce(){e=TDe()},afterAllSetup(r){t.force??uDt(r)?NN(r):e?.callWhenPatched(()=>NN(r))}}},ADe=lDt;var xM=he(Qt(),1);var fDt=[">=4.0.0 <7"],AM=class extends xM.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-openai",kr,e)}init(){return new xM.InstrumentationNodeModuleDefinition("openai",fDt,this._patch.bind(this))}_patch(e){let r=e;return r=this._patchClient(r,"OpenAI"),r=this._patchClient(r,"AzureOpenAI"),r}_patchClient(e,r){let n=e[r];if(!n)return e;let i=this.getConfig(),s=function(...o){if(gg(um))return Reflect.construct(n,o);let a=Reflect.construct(n,o),u=!!Ve()?.getOptions().sendDefaultPii,l=i.recordInputs??u,f=i.recordOutputs??u;return dG(a,{recordInputs:l,recordOutputs:f})};Object.setPrototypeOf(s,n),Object.setPrototypeOf(s.prototype,n.prototype);for(let o of Object.getOwnPropertyNames(n))if(!["length","name","prototype"].includes(o)){let a=Object.getOwnPropertyDescriptor(n,o);a&&Object.defineProperty(s,o,a)}try{e[r]=s}catch{Object.defineProperty(e,r,{value:s,writable:!0,configurable:!0,enumerable:!0})}if(e.default===n)try{e.default=s}catch{Object.defineProperty(e,"default",{value:s,writable:!0,configurable:!0,enumerable:!0})}return e}};var xDe=at(um,t=>new AM(t)),dDt=(t={})=>({name:um,setupOnce(){xDe(t)}}),wDe=dDt;var CM=he(Qt(),1);var hDt=[">=0.19.2 <1.0.0"],wM=class extends CM.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-anthropic-ai",kr,e)}init(){return new CM.InstrumentationNodeModuleDefinition("@anthropic-ai/sdk",hDt,this._patch.bind(this))}_patch(e){let r=e.Anthropic,n=this.getConfig(),i=function(...s){if(gg(lm))return Reflect.construct(r,s);let o=Reflect.construct(r,s),c=!!Ve()?.getOptions().sendDefaultPii,u=n.recordInputs??c,l=n.recordOutputs??c;return pG(o,{recordInputs:u,recordOutputs:l})};Object.setPrototypeOf(i,r),Object.setPrototypeOf(i.prototype,r.prototype);for(let s of Object.getOwnPropertyNames(r))if(!["length","name","prototype"].includes(s)){let o=Object.getOwnPropertyDescriptor(r,s);o&&Object.defineProperty(i,s,o)}try{e.Anthropic=i}catch{Object.defineProperty(e,"Anthropic",{value:i,writable:!0,configurable:!0,enumerable:!0})}if(e.default===r)try{e.default=i}catch{Object.defineProperty(e,"default",{value:i,writable:!0,configurable:!0,enumerable:!0})}return e}};var CDe=at(lm,t=>new wM(t)),pDt=(t={})=>({name:lm,options:t,setupOnce(){CDe(t)}}),IDe=pDt;var jb=he(Qt(),1);var DDe=[">=0.10.0 <2"],IM=class extends jb.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-google-genai",kr,e)}init(){return new jb.InstrumentationNodeModuleDefinition("@google/genai",DDe,r=>this._patch(r),r=>r,[new jb.InstrumentationNodeModuleFile("@google/genai/dist/node/index.cjs",DDe,r=>this._patch(r),r=>r)])}_patch(e){let r=e.GoogleGenAI,n=this.getConfig();if(typeof r!="function")return e;let i=function(...s){if(gg(fm))return Reflect.construct(r,s);let o=Reflect.construct(r,s),c=!!Ve()?.getOptions().sendDefaultPii,u=n,l=u?.recordInputs??c,f=u?.recordOutputs??c;return EG(o,{recordInputs:l,recordOutputs:f})};Object.setPrototypeOf(i,r),Object.setPrototypeOf(i.prototype,r.prototype);for(let s of Object.getOwnPropertyNames(r))if(!["length","name","prototype"].includes(s)){let o=Object.getOwnPropertyDescriptor(r,s);o&&Object.defineProperty(i,s,o)}return vG(e,"GoogleGenAI",i),e}};var RDe=at(fm,t=>new IM(t)),mDt=(t={})=>({name:fm,setupOnce(){RDe(t)}}),ODe=mDt;var Lm=he(Qt(),1);var DM=[">=0.1.0 <2.0.0"];function _Dt(t,e){return t?Array.isArray(t)?t.includes(e)?t:[...t,e]:typeof t=="object"?[t,e]:t:[e]}function gDt(t,e,r){return new Proxy(t,{apply(n,i,s){let a=s[1];(!a||typeof a!="object"||Array.isArray(a))&&(a={},s[1]=a);let c=a.callbacks,u=_Dt(c,e);return a.callbacks=u,Reflect.apply(n,i,s)}})}var RM=class extends Lm.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-langchain",kr,e)}init(){let e=[],r=["@langchain/anthropic","@langchain/openai","@langchain/google-genai","@langchain/mistralai","@langchain/google-vertexai","@langchain/groq"];for(let n of r)e.push(new Lm.InstrumentationNodeModuleDefinition(n,DM,this._patch.bind(this),i=>i,[new Lm.InstrumentationNodeModuleFile(`${n}/dist/index.cjs`,DM,this._patch.bind(this),i=>i)]));return e.push(new Lm.InstrumentationNodeModuleDefinition("langchain",DM,this._patch.bind(this),n=>n,[new Lm.InstrumentationNodeModuleFile("langchain/dist/chat_models/universal.cjs",DM,this._patch.bind(this),n=>n)])),e}_patch(e){YH([um,lm,fm]);let n=!!Ve()?.getOptions().sendDefaultPii,i=this.getConfig(),s=i?.recordInputs??n,o=i?.recordOutputs??n,a=LN({recordInputs:s,recordOutputs:o});return this._patchRunnableMethods(e,a),e}_patchRunnableMethods(e,r){let n=["ChatAnthropic","ChatOpenAI","ChatGoogleGenerativeAI","ChatMistralAI","ChatVertexAI","ChatGroq","ConfigurableModel"],i=e.universal_exports??e,s=Object.values(i).find(c=>typeof c=="function"&&n.includes(c.name));if(!s)return;let o=s.prototype,a=["invoke","stream","batch"];for(let c of a){let u=o[c];typeof u=="function"&&(o[c]=gDt(u,r))}}};var NDe=at(MN,t=>new RM(t)),EDt=(t={})=>({name:MN,setupOnce(){NDe(t)}}),PDe=EDt;var Hb=he(Qt(),1);var kDe=[">=0.0.0 <2.0.0"],OM=class extends Hb.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-langgraph",kr,e)}init(){return new Hb.InstrumentationNodeModuleDefinition("@langchain/langgraph",kDe,this._patch.bind(this),r=>r,[new Hb.InstrumentationNodeModuleFile("@langchain/langgraph/dist/index.cjs",kDe,this._patch.bind(this),r=>r)])}_patch(e){let n=!!Ve()?.getOptions().sendDefaultPii,i=this.getConfig(),s=i.recordInputs??n,o=i.recordOutputs??n,a={recordInputs:s,recordOutputs:o};if(e.StateGraph&&typeof e.StateGraph=="function"){let c=e.StateGraph;c.prototype.compile=bG(c.prototype.compile,a)}return e}};var MDe=at(FN,t=>new OM(t)),yDt=(t={})=>({name:FN,setupOnce(){MDe(t)}}),LDe=yDt;var $De=he(Qt(),1);var BDe=he(require("node:net"),1);Fe();var Sh=he(Qt(),1);mn();function UDe(t,e,r,n,i){let o=()=>{},a=i.firestoreSpanCreationHook;typeof a=="function"&&(o=l=>{(0,Sh.safeExecuteInTheMiddle)(()=>a(l),f=>{f&&Zo.error(f?.message)},!0)});let c=new Sh.InstrumentationNodeModuleDefinition("@firebase/firestore",e,l=>FDe(l,r,n,t,o)),u=["@firebase/firestore/dist/lite/index.node.cjs.js","@firebase/firestore/dist/lite/index.node.mjs.js","@firebase/firestore/dist/lite/index.rn.esm2017.js","@firebase/firestore/dist/lite/index.cjs.js"];for(let l of u)c.files.push(new Sh.InstrumentationNodeModuleFile(l,e,f=>FDe(f,r,n,t,o),f=>qDe(f,n)));return c}function FDe(t,e,r,n,i){return qDe(t,r),e(t,"addDoc",SDt(n,i)),e(t,"getDocs",vDt(n,i)),e(t,"setDoc",TDt(n,i)),e(t,"deleteDoc",bDt(n,i)),t}function qDe(t,e){for(let r of["addDoc","getDocs","setDoc","deleteDoc"])(0,Sh.isWrapped)(t[r])&&e(t,r);return t}function SDt(t,e){return function(n){return function(i,s){let o=PM(t,"addDoc",i);return e(o),NM(o,()=>n(i,s))}}}function bDt(t,e){return function(n){return function(i){let s=PM(t,"deleteDoc",i.parent||i);return e(s),NM(s,()=>n(i))}}}function vDt(t,e){return function(n){return function(i){let s=PM(t,"getDocs",i);return e(s),NM(s,()=>n(i))}}}function TDt(t,e){return function(n){return function(i,s,o){let a=PM(t,"setDoc",i.parent||i);return e(a),NM(a,()=>typeof o<"u"?n(i,s,o):n(i,s))}}}function NM(t,e){return Je.with(Ft.setSpan(Je.active(),t),()=>(0,Sh.safeExecuteInTheMiddle)(()=>e(),r=>{r&&t.recordException(r),t.end()},!0))}function PM(t,e,r){let n=t.startSpan(`${e} ${r.path}`,{kind:Un.CLIENT});return xDt(n,r),n.setAttribute(kx,e),n}function ADt(t){let e,r;if(typeof t.host=="string")if(t.host.startsWith("[")){if(t.host.endsWith("]"))e=t.host.replace(/^\[|\]$/g,"");else if(t.host.includes("]:")){let n=t.host.lastIndexOf(":");n!==-1&&(e=t.host.slice(1,n).replace(/^\[|\]$/g,""),r=t.host.slice(n+1))}}else if(BDe.isIPv6(t.host))e=t.host;else{let n=t.host.lastIndexOf(":");n!==-1?(e=t.host.slice(0,n),r=t.host.slice(n+1)):e=t.host}return{address:e,port:r?parseInt(r,10):void 0}}function xDt(t,e){let r=e.firestore.app,n=r.options,s=(e.firestore.toJSON()||{}).settings||{},o={[H9]:e.path,[Px]:r.name,[Mx]:"firebase.firestore","firebase.firestore.type":e.type,"firebase.firestore.options.projectId":n.projectId,"firebase.firestore.options.appId":n.appId,"firebase.firestore.options.messagingSenderId":n.messagingSenderId,"firebase.firestore.options.storageBucket":n.storageBucket},{address:a,port:c}=ADt(s);a&&(o[Lx]=a),c&&(o[Fx]=c),t.setAttributes(o)}Fe();var bh=he(Qt(),1);function jDe(t,e,r,n,i){let s=()=>{},o=()=>{},a=i.functions?.errorHook,c=i.functions?.requestHook,u=i.functions?.responseHook;typeof u=="function"&&(o=(d,h)=>{(0,bh.safeExecuteInTheMiddle)(()=>u(d,h),p=>{p&&Zo.error(p?.message)},!0)}),typeof c=="function"&&(s=d=>{(0,bh.safeExecuteInTheMiddle)(()=>c(d),h=>{h&&Zo.error(h?.message)},!0)});let l=new bh.InstrumentationNodeModuleDefinition("firebase-functions",e);return[{name:"firebase-functions/lib/v2/providers/https.js",triggerType:"function"},{name:"firebase-functions/lib/v2/providers/firestore.js",triggerType:"firestore"},{name:"firebase-functions/lib/v2/providers/scheduler.js",triggerType:"scheduler"},{name:"firebase-functions/lib/v2/storage.js",triggerType:"storage"}].forEach(({name:d,triggerType:h})=>{l.files.push(new bh.InstrumentationNodeModuleFile(d,e,p=>wDt(p,r,n,t,{requestHook:s,responseHook:o,errorHook:a},h),p=>HDe(p,n)))}),l}function la(t,e,r){return function(i){return function(...s){let o=typeof s[0]=="function"?s[0]:s[1],a=typeof s[0]=="function"?void 0:s[0];if(!o)return i.call(this,...s);let c=async function(...u){let l=process.env.FUNCTION_TARGET||process.env.K_SERVICE||"unknown",f=t.startSpan(`firebase.function.${r}`,{kind:Un.SERVER}),d={"faas.name":l,"faas.trigger":r,"faas.provider":"firebase"};return process.env.GCLOUD_PROJECT&&(d["cloud.project_id"]=process.env.GCLOUD_PROJECT),process.env.EVENTARC_CLOUD_EVENT_SOURCE&&(d["cloud.event_source"]=process.env.EVENTARC_CLOUD_EVENT_SOURCE),f.setAttributes(d),e?.requestHook?.(f),Je.with(Ft.setSpan(Je.active(),f),async()=>{let h,p;try{p=await o.apply(this,u)}catch(_){h=_}if(e?.responseHook?.(f,h),h&&f.recordException(h),f.end(),h)throw await e?.errorHook?.(f,h),h;return p})};return a?i.call(this,a,c):i.call(this,c)}}}function wDt(t,e,r,n,i,s){switch(HDe(t,r),s){case"function":e(t,"onRequest",la(n,i,"http.request")),e(t,"onCall",la(n,i,"http.call"));break;case"firestore":e(t,"onDocumentCreated",la(n,i,"firestore.document.created")),e(t,"onDocumentUpdated",la(n,i,"firestore.document.updated")),e(t,"onDocumentDeleted",la(n,i,"firestore.document.deleted")),e(t,"onDocumentWritten",la(n,i,"firestore.document.written")),e(t,"onDocumentCreatedWithAuthContext",la(n,i,"firestore.document.created")),e(t,"onDocumentUpdatedWithAuthContext",la(n,i,"firestore.document.updated")),e(t,"onDocumentDeletedWithAuthContext",la(n,i,"firestore.document.deleted")),e(t,"onDocumentWrittenWithAuthContext",la(n,i,"firestore.document.written"));break;case"scheduler":e(t,"onSchedule",la(n,i,"scheduler.scheduled"));break;case"storage":e(t,"onObjectFinalized",la(n,i,"storage.object.finalized")),e(t,"onObjectArchived",la(n,i,"storage.object.archived")),e(t,"onObjectDeleted",la(n,i,"storage.object.deleted")),e(t,"onObjectMetadataUpdated",la(n,i,"storage.object.metadataUpdated"));break}return t}function HDe(t,e){let r=["onSchedule","onRequest","onCall","onObjectFinalized","onObjectArchived","onObjectDeleted","onObjectMetadataUpdated","onDocumentCreated","onDocumentUpdated","onDocumentDeleted","onDocumentWritten","onDocumentCreatedWithAuthContext","onDocumentUpdatedWithAuthContext","onDocumentDeletedWithAuthContext","onDocumentWrittenWithAuthContext"];for(let n of r)(0,bh.isWrapped)(t[n])&&e(t,n);return t}var GDe={},CDt=[">=3.0.0 <5"],IDt=[">=6.0.0 <7"],kM=class extends $De.InstrumentationBase{constructor(e=GDe){super("@sentry/instrumentation-firebase",kr,e)}setConfig(e={}){super.setConfig({...GDe,...e})}init(){let e=[];return e.push(UDe(this.tracer,CDt,this._wrap,this._unwrap,this.getConfig())),e.push(jDe(this.tracer,IDt,this._wrap,this._unwrap,this.getConfig())),e}};var VDe="Firebase",DDt={firestoreSpanCreationHook:t=>{An(t,"auto.firebase.otel.firestore"),t.setAttribute(bt,"db.query")},functions:{requestHook:t=>{An(t,"auto.firebase.otel.functions"),t.setAttribute(bt,"http.request")},errorHook:async(t,e)=>{e&&(tr(e,{mechanism:{type:"auto.firebase.otel.functions",handled:!1}}),await CS(2e3))}}},WDe=at(VDe,()=>new kM(DDt)),RDt=()=>({name:VDe,setupOnce(){WDe()}}),YDe=RDt;function zDe(){return[hxe(),Jxe(),T1e(),pIe(),awe(),bwe(),Nwe(),Gwe(),SCe(),qCe(),XCe(),fIe(),DIe(),jIe(),eDe(),cDe(),U1e(),bDe(),K1e(),PDe(),LDe(),ADe(),wDe(),IDe(),ODe(),GCe(),YDe()]}Fe();var MM=he(UG(),1),KDe=he(l$(),1);mn();var EW=1e6;function QDe(t,e={}){t.getOptions().debug&&V$();let r=ODt(t,e);t.traceProvider=r}function ODt(t,e={}){let r=new KDe.BasicTracerProvider({sampler:new OP(t),resource:(0,MM.defaultResource)().merge((0,MM.resourceFromAttributes)({[lc]:"node",[j9]:"sentry",[W9]:kr})),forceFlushTimeoutMillis:500,spanProcessors:[new RP({timeout:NDt(t.getOptions().maxSpanWaitDuration)}),...e.spanProcessors||[]]});return Ft.setGlobalTracerProvider(r),ea.setGlobalPropagator(new DP),Je.setGlobalContextManager(new HP),r}function NDt(t){if(t!=null){if(t>EW)return Zc&&ne.warn(`\`maxSpanWaitDuration\` is too high, using the maximum value of ${EW}`),EW;if(t<=0||Number.isNaN(t)){Zc&&ne.warn("`maxSpanWaitDuration` must be a positive number, using default value instead.");return}return t}}function JDe(){return zP().filter(e=>e.name!=="Http"&&e.name!=="NodeFetch").concat(WAe(),ZAe())}function XDe(t){return[...JDe(),...Hi(t)?zDe():[]]}function yW(t={}){return PDt(t,XDe)}function PDt(t={},e){Eg(t,"node");let r=Z$({...t,defaultIntegrations:t.defaultIntegrations??e(t)});return r&&!t.skipOpenTelemetrySetup&&(QDe(r,{spanProcessors:t.openTelemetrySpanProcessors}),KP()),r}var tRe=he(require("os"),1);var ZDe="lody",LM="0.2.9";var eRe={name:ZDe,version:LM,description:"Lody Agent CLI tool for managing remote command execution",type:"module",main:"dist/index.cjs",bin:{lody:"dist/index.cjs"},scripts:{dev:"tsx src/index.ts",build:"pnpm run clean && pnpm run typecheck && pnpm run build:bundle && pnpm run copy:wasm","build:watch":"pnpm run build:bundle -- --watch","build:bundle":'esbuild src/index.ts --bundle --platform=node --target=node18 --format=cjs --outfile=dist/index.cjs --minify --legal-comments=none --external:cpu-features --external:*.node --define:process.env.NODE_ENV=\\"production\\" --define:process.env.SENTRY_ENVIRONMENT=\\"production\\"',"copy:wasm":"node scripts/copy-loro-wasm.js",clean:"rimraf dist",format:"prettier --write src/**/*.ts","format:check":"prettier --check src/**/*.ts",typecheck:"tsc --noEmit",test:"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage",prepublishOnly:"npm run clean && npm run build && node scripts/prepare-publish.js",postpublish:"node scripts/prepare-publish.js --restore","serve:dev":"NODE_ENV=development npm run dev serve","serve:prod":"NODE_ENV=production npm run dev serve"},keywords:["cli","typescript","command-line","agent","remote-execution"],author:"Leon Zhao",license:"MIT",engines:{node:">=18.0.0"},devDependencies:{"@agentclientprotocol/sdk":"^0.5.1","@lody/convex":"workspace:*","@lody/shared":"workspace:*","@modelcontextprotocol/sdk":"^1.22.0","@types/dockerode":"^3.3.47","@types/express":"^5.0.5","@types/fs-extra":"^11.0.4","@types/inquirer":"^9.0.9","@types/js-yaml":"^4.0.9","@types/node":"catalog:","@types/throttle-debounce":"^5.0.2","@types/uuid":"^9.0.8","@types/ws":"^8.18.1","@vitest/coverage-v8":"^3.2.4",chalk:"^5.6.2",commander:"^12.1.0",convex:"1.25.4",dockerode:"^4.0.9",dotenv:"^16.6.1",esbuild:"^0.24.2",eventemitter3:"^5.0.1",express:"^4.21.2",inquirer:"^10.2.2","js-yaml":"^4.1.1","loro-adaptors":"catalog:","loro-crdt":"catalog:","loro-mirror":"catalog:","loro-repo":"catalog:","loro-websocket":"catalog:",ora:"^8.2.0",prettier:"^3.6.2",rimraf:"^6.1.2","ts-node":"^10.9.2",tsx:"^4.20.6",typescript:"catalog:",uuid:"^13.0.0",vitest:"^3.2.4",winston:"^3.18.3","winston-daily-rotate-file":"^5.0.0",ws:"^8.18.3"},files:["dist","README.md","LICENSE"],dependencies:{"@sentry/node":"^10.29.0","winston-transport":"^4.7.1","throttle-debounce":"^5.0.2"}};var Nw="production",rRe=process.env.SENTRY_DSN||"https://3ae9811b38d970851d27d1b728ee5e31@o4510491299086336.ingest.us.sentry.io/4510496828882944",kDt=Number(process.env.SENTRY_TRACES_SAMPLE_RATE)||(Nw==="production"?.2:1),MDt=Number(process.env.SENTRY_PROFILES_SAMPLE_RATE)||(Nw==="production"?.1:.25);console.log("en",Nw);var vW=Nw!=="development"&&!!rRe;vW&&(yW({dsn:rRe,environment:Nw,release:`${ZDe}@${LM}`,sendDefaultPii:!0,enableLogs:!0,attachStacktrace:!0,tracesSampleRate:kDt,profilesSampleRate:MDt}),uN({service:"lody-cli",hostname:tRe.default.hostname(),node:process.version}));var TW=(t=2e3)=>vW?CS(t):Promise.resolve(),nRe=(t,e)=>{if(!vW)return Promise.resolve();let r=t instanceof Error?t:new Error(String(t));return tr(r,{tags:e?.component?{component:e.component}:void 0,extra:e?.extra}),TW()};var _Re=he(mRe(),1),{program:Tjr,createCommand:Ajr,createArgument:xjr,createOption:wjr,CommanderError:Cjr,InvalidArgumentError:kw,InvalidOptionArgumentError:Ijr,Command:bc,Argument:Djr,Option:Rjr,Help:Ojr}=_Re.default;var gRe=(t=0)=>e=>`\x1B[${e+t}m`,ERe=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,yRe=(t=0)=>(e,r,n)=>`\x1B[${38+t};2;${e};${r};${n}m`,ni={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Pjr=Object.keys(ni.modifier),JDt=Object.keys(ni.color),XDt=Object.keys(ni.bgColor),kjr=[...JDt,...XDt];function ZDt(){let t=new Map;for(let[e,r]of Object.entries(ni)){for(let[n,i]of Object.entries(r))ni[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[n]=ni[n],t.set(i[0],i[1]);Object.defineProperty(ni,e,{value:r,enumerable:!1})}return Object.defineProperty(ni,"codes",{value:t,enumerable:!1}),ni.color.close="\x1B[39m",ni.bgColor.close="\x1B[49m",ni.color.ansi=gRe(),ni.color.ansi256=ERe(),ni.color.ansi16m=yRe(),ni.bgColor.ansi=gRe(10),ni.bgColor.ansi256=ERe(10),ni.bgColor.ansi16m=yRe(10),Object.defineProperties(ni,{rgbToAnsi256:{value(e,r,n){return e===r&&r===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(s=>s+s).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:e=>ni.rgbToAnsi256(...ni.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,n,i;if(e>=232)r=((e-232)*10+8)/255,n=r,i=r;else{e-=16;let a=e%36;r=Math.floor(e/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let s=Math.max(r,n,i)*2;if(s===0)return 30;let o=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(r));return s===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(e,r,n)=>ni.ansi256ToAnsi(ni.rgbToAnsi256(e,r,n)),enumerable:!1},hexToAnsi:{value:e=>ni.ansi256ToAnsi(ni.hexToAnsi256(e)),enumerable:!1}}),ni}var eRt=ZDt(),pl=eRt;var qM=he(require("node:process"),1),bRe=he(require("node:os"),1),UW=he(require("node:tty"),1);function lu(t,e=globalThis.Deno?globalThis.Deno.args:qM.default.argv){let r=t.startsWith("-")?"":t.length===1?"-":"--",n=e.indexOf(r+t),i=e.indexOf("--");return n!==-1&&(i===-1||n<i)}var{env:ii}=qM.default,UM;lu("no-color")||lu("no-colors")||lu("color=false")||lu("color=never")?UM=0:(lu("color")||lu("colors")||lu("color=true")||lu("color=always"))&&(UM=1);function tRt(){if("FORCE_COLOR"in ii)return ii.FORCE_COLOR==="true"?1:ii.FORCE_COLOR==="false"?0:ii.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(ii.FORCE_COLOR,10),3)}function rRt(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function nRt(t,{streamIsTTY:e,sniffFlags:r=!0}={}){let n=tRt();n!==void 0&&(UM=n);let i=r?UM:n;if(i===0)return 0;if(r){if(lu("color=16m")||lu("color=full")||lu("color=truecolor"))return 3;if(lu("color=256"))return 2}if("TF_BUILD"in ii&&"AGENT_NAME"in ii)return 1;if(t&&!e&&i===void 0)return 0;let s=i||0;if(ii.TERM==="dumb")return s;if(qM.default.platform==="win32"){let o=bRe.default.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in ii)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(o=>o in ii)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(o=>o in ii)||ii.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in ii)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(ii.TEAMCITY_VERSION)?1:0;if(ii.COLORTERM==="truecolor"||ii.TERM==="xterm-kitty"||ii.TERM==="xterm-ghostty"||ii.TERM==="wezterm")return 3;if("TERM_PROGRAM"in ii){let o=Number.parseInt((ii.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(ii.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(ii.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(ii.TERM)||"COLORTERM"in ii?1:s}function SRe(t,e={}){let r=nRt(t,{streamIsTTY:t&&t.isTTY,...e});return rRt(r)}var iRt={stdout:SRe({isTTY:UW.default.isatty(1)}),stderr:SRe({isTTY:UW.default.isatty(2)})},vRe=iRt;function TRe(t,e,r){let n=t.indexOf(e);if(n===-1)return t;let i=e.length,s=0,o="";do o+=t.slice(s,n)+e+r,s=n+i,n=t.indexOf(e,s);while(n!==-1);return o+=t.slice(s),o}function ARe(t,e,r,n){let i=0,s="";do{let o=t[n-1]==="\r";s+=t.slice(i,o?n-1:n)+e+(o?`\r
162
162
  `:`
163
163
  `)+r,i=n+1,n=t.indexOf(`
164
164
  `,i)}while(n!==-1);return s+=t.slice(i),s}var{stdout:xRe,stderr:wRe}=vRe,qW=Symbol("GENERATOR"),Gb=Symbol("STYLER"),Mw=Symbol("IS_EMPTY"),CRe=["ansi","ansi","ansi256","ansi16m"],$b=Object.create(null),sRt=(t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=xRe?xRe.level:0;t.level=e.level===void 0?r:e.level};var oRt=t=>{let e=(...r)=>r.join(" ");return sRt(e,t),Object.setPrototypeOf(e,Lw.prototype),e};function Lw(t){return oRt(t)}Object.setPrototypeOf(Lw.prototype,Function.prototype);for(let[t,e]of Object.entries(pl))$b[t]={get(){let r=jM(this,HW(e.open,e.close,this[Gb]),this[Mw]);return Object.defineProperty(this,t,{value:r}),r}};$b.visible={get(){let t=jM(this,this[Gb],!0);return Object.defineProperty(this,"visible",{value:t}),t}};var jW=(t,e,r,...n)=>t==="rgb"?e==="ansi16m"?pl[r].ansi16m(...n):e==="ansi256"?pl[r].ansi256(pl.rgbToAnsi256(...n)):pl[r].ansi(pl.rgbToAnsi(...n)):t==="hex"?jW("rgb",e,r,...pl.hexToRgb(...n)):pl[r][t](...n),aRt=["rgb","hex","ansi256"];for(let t of aRt){$b[t]={get(){let{level:r}=this;return function(...n){let i=HW(jW(t,CRe[r],"color",...n),pl.color.close,this[Gb]);return jM(this,i,this[Mw])}}};let e="bg"+t[0].toUpperCase()+t.slice(1);$b[e]={get(){let{level:r}=this;return function(...n){let i=HW(jW(t,CRe[r],"bgColor",...n),pl.bgColor.close,this[Gb]);return jM(this,i,this[Mw])}}}}var cRt=Object.defineProperties(()=>{},{...$b,level:{enumerable:!0,get(){return this[qW].level},set(t){this[qW].level=t}}}),HW=(t,e,r)=>{let n,i;return r===void 0?(n=t,i=e):(n=r.openAll+t,i=e+r.closeAll),{open:t,close:e,openAll:n,closeAll:i,parent:r}},jM=(t,e,r)=>{let n=(...i)=>uRt(n,i.length===1?""+i[0]:i.join(" "));return Object.setPrototypeOf(n,cRt),n[qW]=t,n[Gb]=e,n[Mw]=r,n},uRt=(t,e)=>{if(t.level<=0||!e)return t[Mw]?"":e;let r=t[Gb];if(r===void 0)return e;let{openAll:n,closeAll:i}=r;if(e.includes("\x1B"))for(;r!==void 0;)e=TRe(e,r.close,r.open),r=r.parent;let s=e.indexOf(`
@@ -191,7 +191,7 @@ ${i.style.description(x.description)}`:"";return[[_,A,I].filter(Boolean).join("
191
191
  ${s.style.help("(Use arrow keys to reveal more choices)")}`:S=s.style.help("(Use arrow keys)"));let x=Fg({items:l,active:h,renderItem({item:N,isActive:C}){if(on.isSeparator(N))return` ${N.separator}`;if(N.disabled){let D=typeof N.disabled=="string"?N.disabled:"(disabled)";return s.style.disabled(`${N.name} ${D}`)}let M=C?s.style.highlight:D=>D,I=C?s.icon.cursor:" ";return M(`${I} ${N.name}`)},pageSize:n,loop:r});if(a==="done")return`${o} ${g} ${s.style.answer(_.short)}`;let A=_.description?`
192
192
  ${s.style.description(_.description)}`:"";return`${[o,g,S].filter(Boolean).join(" ")}
193
193
  ${x}${b}${A}${ENe.default.cursorHide}`});var J6e=he(require("node:readline"),1),oi=he(V6e(),1),qK=he(K6e(),1),X6e=he(yY(),1);var Z6e=he(ev(),1),Q6e={set:(t,e="",r)=>{let n=t;e.split(".").forEach((i,s,o)=>{i==="__proto__"||i==="constructor"||(s===o.length-1?n[i]=r:(!(i in n)||typeof n[i]!="object")&&(n[i]={}),n=n[i])})},get:(t,e="",r)=>{let n=s=>String.prototype.split.call(e,s).filter(Boolean).reduce((o,a)=>o!=null?o[a]:o,t),i=n(/[,[\]]+?/)||n(/[,.[\]]+?/);return i===void 0||i===t?r:i}};async function BK(t,e,r){let n=t[e];return typeof n=="function"?(0,qK.default)(n)(r):n}var UK=class extends Error{name="TTYError";isTtyError=!0};function vjt(t){t.skipTTYChecks=t.skipTTYChecks===void 0?!0:t.skipTTYChecks;let e=t.input||process.stdin;if(!t.skipTTYChecks&&!e.isTTY)throw new UK("Prompts can not be meaningfully rendered in non-TTY environments");let r=new X6e.default;return r.pipe(t.output||process.stdout),{terminal:!0,...t,input:e,output:r}}function Tjt(t){return Array.isArray(t)}function Ajt(t){return Object.values(t).every(e=>typeof e=="object"&&!Array.isArray(e)&&e!=null)}function xjt(t){return!!(t.prototype&&"run"in t.prototype&&typeof t.prototype.run=="function")}var Kv=class{prompts;answers={};process=oi.EMPTY;abortController=new AbortController;opt;rl;constructor(e,r={}){this.opt=r,this.prompts=e}async run(e,r){this.abortController=new AbortController,this.answers=typeof r=="object"?{...r}:{};let n;return Tjt(e)?n=(0,oi.from)(e):(0,oi.isObservable)(e)?n=e:Ajt(e)?n=(0,oi.from)(Object.entries(e).map(([i,s])=>Object.assign({},s,{name:i}))):n=(0,oi.from)([e]),this.process=n.pipe((0,oi.concatMap)(i=>(0,oi.of)(i).pipe((0,oi.concatMap)(s=>(0,oi.from)(this.shouldRun(s).then(o=>{if(o)return s})).pipe((0,oi.filter)(o=>o!=null))),(0,oi.concatMap)(s=>(0,oi.defer)(()=>(0,oi.from)(this.fetchAnswer(s))))))),(0,oi.lastValueFrom)(this.process.pipe((0,oi.reduce)((i,s)=>(Q6e.set(i,s.name,s.answer),i),this.answers))).then(()=>this.answers).finally(()=>this.close())}prepareQuestion=async e=>{let[r,n,i]=await Promise.all([BK(e,"message",this.answers),BK(e,"default",this.answers),BK(e,"choices",this.answers)]),s;return Array.isArray(i)&&(s=i.map(o=>typeof o=="string"||typeof o=="number"?{name:o,value:o}:typeof o=="object"&&o!=null&&!("value"in o)&&"name"in o?{...o,value:o.name}:o)),Object.assign({},e,{message:r,default:n,choices:s,type:e.type in this.prompts?e.type:"input"})};fetchAnswer=async e=>{let r=await this.prepareQuestion(e),n=this.prompts[r.type];if(n==null)throw new Error(`Prompt for type ${r.type} not found`);let i,s=xjt(n)?(u,{signal:l}={})=>new Promise((f,d)=>{let h=J6e.default.createInterface(vjt(this.opt));h.resume();let p=()=>{process.removeListener("exit",this.onForceClose),h.removeListener("SIGINT",this.onForceClose),h.setPrompt(""),h.output.unmute(),h.output.write(Z6e.default.cursorShow),h.output.end(),h.close()};this.rl=h,process.on("exit",this.onForceClose),h.on("SIGINT",this.onForceClose);let _=new n(u,h,this.answers),g=()=>{p(),this.rl=void 0,i?.()};if(l){let S=()=>{d(new zb({cause:l.reason})),g()};if(l.aborted){S();return}l.addEventListener("abort",S),i=()=>{l.removeEventListener("abort",S),i=void 0}}_.run().then(f,d).finally(g)}):n,{signal:o}=this.opt;if(o?.aborted)this.abortController.abort(o.reason);else if(o){let u=l=>this.abortController?.abort(l);o.addEventListener("abort",u),i=()=>{o.removeEventListener("abort",u)}}let{filter:a=u=>u}=r,{signal:c}=this.abortController;return s(r,{...this.opt,signal:c}).then(u=>({name:r.name,answer:a(u,this.answers)})).finally(()=>{i?.()})};onForceClose=()=>{this.close(),process.kill(process.pid,"SIGINT"),console.log("")};close=()=>{this.abortController?.abort()};shouldRun=async e=>{if(e.askAnswered!==!0&&Q6e.get(this.answers,e.name)!==void 0)return!1;let{when:r}=e;return typeof r=="function"?await(0,qK.default)(r)(this.answers)!==!1:r!==!1}};var eLe={input:pz,select:x6,list:x6,number:mz,confirm:hz,rawlist:yz,expand:gz,checkbox:TY,password:Sz,editor:dz,search:vz};function tLe(t){function e(r,n){let i=new Kv(e.prompts,t),s=i.run(r,n);return Object.assign(s,{ui:i})}return e.prompts={...eLe},e.registerPrompt=function(r,n){return e.prompts[r]=n,this},e.restoreDefaultPrompts=function(){e.prompts={...eLe}},e}var jK=tLe();function wjt(t,e){jK.registerPrompt(t,e)}function Cjt(){jK.restoreDefaultPrompts()}var Ijt={prompt:jK,ui:{Prompt:Kv},createPromptModule:tLe,registerPrompt:wjt,restoreDefaultPrompts:Cjt,Separator:on},yC=Ijt;var D3e=he(y_(),1),Kf=he(pJ(),1),R3e=he(I3e(),1);var vJ=he(require("path"),1),O3e=he(require("os"),1),N3e=(t={})=>{let{colorize:e=!0,timestamp:r=!0,format:n="simple"}=t;return Kf.default.format.combine(Kf.default.format.errors({stack:!0}),Kf.default.format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}),Kf.default.format.printf(i=>{let{level:s,message:o,timestamp:a,stack:c,...u}=i,l="";if(n==="json")return JSON.stringify({level:s,message:o,timestamp:a,...u});if(r&&a){let f=e?Jt.gray(`[${a}]`):`[${a}]`;l+=`${f} `}if(l+=o,Object.keys(u).length>0){let f=JSON.stringify(u);l+=e?Jt.gray(` ${f}`):` ${f}`}return c&&(l+=`
194
- ${c}`),l}))},PYt=t=>{let e=t.console||{};return new Kf.default.transports.Console({level:t.level==="silent"?"error":t.level||"info",format:N3e({colorize:e.colorize!==!1,timestamp:e.timestamp!==!1,format:e.format||"simple"})})},kYt=t=>{let e=t.file||{};return new R3e.default({level:t.level,filename:e.filename||"%DATE%.log",dirname:e.dirname||vJ.default.join(process.cwd(),"logs"),datePattern:e.datePattern||"YYYY-MM-DD",maxSize:e.maxSize||"20m",maxFiles:e.maxFiles||14,zippedArchive:e.zippedArchive||!1,format:N3e({colorize:!1,timestamp:!0,format:"detailed"})})},bJ=class{winston;config;constructor(e={}){this.config={...e},this.winston=this.createWinstonLogger()}createWinstonLogger(){let e=[],r=this.config.transports||"console",n=this.config.level==="silent"?"error":this.config.level||"info";(r==="console"||r==="both")&&e.push(PYt(this.config)),(r==="file"||r==="both")&&e.push(kYt(this.config));let i=BP(D3e.default,{levels:["error","warn"]});return e.push(new i({handleExceptions:!0,handleRejections:!0,format:Kf.default.format.combine(Kf.default.format.errors({stack:!0}))})),Kf.default.createLogger({level:n,transports:e,exitOnError:!1})}info(e,r){this.winston.info(e,r)}warn(e,r){this.winston.warn(e,r)}error(e,r){this.winston.error(e,r)}success(e,r){this.winston.levels.success!==void 0?this.winston.success(e,r):this.winston.info(e,{...r,level:"success"})}debug(e,r){this.winston.debug(e,r)}setLevel(e){this.config.level=e,this.winston.level=e==="silent"?"error":e,this.winston.transports.forEach(r=>{r.level=e==="silent"?"error":e,r instanceof Kf.default.transports.Console&&(r.silent=e==="silent")})}child(e){let r=this.winston.child(e),n=Object.create(this);return n.winston=r,n}async close(){return new Promise(e=>{this.winston.close(),e()})}},SJ=null,kB=(t={})=>new bJ(t);var P3e=(t={})=>{let e=kB({transports:"both",level:"info",console:{colorize:!0,timestamp:!1,format:"simple"},file:{dirname:vJ.default.join(O3e.default.homedir(),".lody","logs"),maxSize:"20m",maxFiles:14},...t});return bu=e,e},TJ=()=>(SJ||(SJ=kB({transports:"console",level:"info",console:{colorize:!0,timestamp:!1,format:"simple"}})),SJ),bu=TJ(),Uo=(t,e)=>!t&&!e?bu:bu.child({...t?{scope:t}:{},...e});var MYt=2e3,k3e=!1,LYt=t=>t instanceof Error?t:new Error(String(t)),Gs=async(t,e,r={})=>{let n=LYt(e);(r.logger??Uo(t)).error(r.message||n.message,{error:n,...r.extra}),await nRe(n,{component:t,extra:r.extra}),r.fatal&&await TW(MYt)},M3e=()=>{k3e||(k3e=!0,process.on("uncaughtException",t=>{Gs("uncaughtException",t,{message:"Uncaught exception in CLI",logger:bu,fatal:!0}).finally(()=>process.exit(1))}),process.on("unhandledRejection",t=>{Gs("unhandledRejection",t,{message:"Unhandled promise rejection in CLI",logger:bu,fatal:!0}).finally(()=>process.exit(1))}))};var qo=he(require("fs"),1),qa=he(require("path"),1),L3e=he(require("os"),1),F3e=require("child_process"),AJ=require("module"),H3e={},WC=qa.default.join(L3e.default.homedir(),".lody-agent"),YC=qa.default.join(WC,"serve.pid"),zC=qa.default.join(WC,"serve.json");function B3e(){qo.default.existsSync(WC)||qo.default.mkdirSync(WC,{recursive:!0})}function xJ(t,e){B3e(),qo.default.writeFileSync(YC,t.toString());let r={pid:t,...e};qo.default.writeFileSync(zC,JSON.stringify(r,null,2))}function U3e(t){xJ(process.pid,{...t,startTime:new Date().toISOString()})}function wJ(){try{if(!qo.default.existsSync(YC))return null;let t=parseInt(qo.default.readFileSync(YC,"utf-8").trim(),10);return isNaN(t)?null:t}catch{return null}}function FYt(){try{return qo.default.existsSync(zC)?JSON.parse(qo.default.readFileSync(zC,"utf-8")):null}catch{return null}}function MB(t){try{return process.kill(t,0),!0}catch{return!1}}function q3e(t){try{return process.kill(t,"SIGTERM"),setTimeout(()=>{if(MB(t))try{process.kill(t,"SIGKILL")}catch{}},2e3),!0}catch{return!1}}function CJ(){try{qo.default.existsSync(YC)&&qo.default.unlinkSync(YC),qo.default.existsSync(zC)&&qo.default.unlinkSync(zC)}catch{}}function IJ(){let t=wJ(),e=FYt();return!t||!e?{running:!1,info:null}:MB(t)?{running:!0,info:e}:(CJ(),{running:!1,info:null})}function BYt(t){let e=(0,AJ.createRequire)(H3e.url),r=qa.default.join(t,"node_modules",".bin","ts-node");if(qo.default.existsSync(r))return r;try{return e.resolve("ts-node/dist/bin.js",{paths:[t]})}catch{try{return e.resolve("ts-node",{paths:[t]})}catch{return null}}}function UYt(t){let e=(0,AJ.createRequire)(H3e.url),r=qa.default.join(t,"node_modules",".bin","tsx");if(qo.default.existsSync(r))return r;try{return e.resolve("tsx/dist/cli.mjs",{paths:[t]})}catch{try{return e.resolve("tsx",{paths:[t]})}catch{return null}}}function j3e(t,e,r){let n=qa.default.dirname(qa.default.dirname(t)),i=qa.default.join(n,"tsconfig.json"),s=t.endsWith(".ts"),o,a;if(s){let d=UYt(n),h=BYt(n);if(d){let p=d.includes(`${qa.default.sep}.bin${qa.default.sep}`);o=p?d:process.execPath,a=p?[t,...e]:[d,t,...e]}else if(h){let p=h.includes(`${qa.default.sep}.bin${qa.default.sep}`);o=p?h:process.execPath,a=[...p?[]:[h],"--esm","--project",i,"--experimentalSpecifierResolution","node",t,...e]}else throw new Error("Neither tsx nor ts-node is installed; cannot start background service")}else o=process.execPath,a=[t,...e];let c=s?n:process.cwd();B3e();let u=qa.default.join(WC,"background.log"),l=qo.default.openSync(u,"a");r?.info(`Starting background service: ${o} ${a.join(" ")}`),r?.info(`Working directory: ${c}`),r?.info(`Background logs: ${u}`);let f=(0,F3e.spawn)(o,a,{detached:!0,stdio:["ignore",l,l],cwd:c,env:{...process.env,LODY_AGENT_BACKGROUND:"1"}});return f.stdout?.on("data",d=>{let h=d.toString();r?.info("STDOUT",{output:h.trim()})}),f.stderr?.on("data",d=>{let h=d.toString();r?.error("STDERR",{error:h.trim()})}),f.on("error",d=>{r?.error("Process error",{error:d})}),f.on("close",(d,h)=>{r?.info("Process closed",{exitCode:d,signal:h||"none"}),r?.info("=== Agent Service Stopped ===")}),f.unref(),{child:f}}var G3e=require("child_process"),$3e=require("util"),DJ=(0,$3e.promisify)(G3e.exec);async function V3e(){try{await DJ("docker ps -q");let{stdout:t}=await DJ('docker version --format "{{.Server.Version}}"'),e=t.trim();return e?{installed:!0,running:!0,version:e}:{installed:!0,running:!1,error:"Docker is installed but not running"}}catch(t){let e=t instanceof Error?t.message.toLowerCase():"";if(e.includes("permission denied")||e.includes("got permission denied")||e.includes("connect: permission denied")||e.includes("dial unix /var/run/docker.sock"))try{let{stdout:r}=await DJ("groups");return r.includes("docker")?{installed:!0,running:!1,error:`Permission denied accessing Docker socket.
194
+ ${c}`),l}))},PYt=t=>{let e=t.console||{};return new Kf.default.transports.Console({level:t.level==="silent"?"error":t.level||"info",format:N3e({colorize:e.colorize!==!1,timestamp:e.timestamp!==!1,format:e.format||"simple"})})},kYt=t=>{let e=t.file||{};return new R3e.default({level:t.level,filename:e.filename||"%DATE%.log",dirname:e.dirname||vJ.default.join(process.cwd(),"logs"),datePattern:e.datePattern||"YYYY-MM-DD",maxSize:e.maxSize||"20m",maxFiles:e.maxFiles||14,zippedArchive:e.zippedArchive||!1,format:N3e({colorize:!1,timestamp:!0,format:"detailed"})})},bJ=class{winston;config;constructor(e={}){this.config={...e},this.winston=this.createWinstonLogger()}createWinstonLogger(){let e=[],r=this.config.transports||"console",n=this.config.level==="silent"?"error":this.config.level||"info";(r==="console"||r==="both")&&e.push(PYt(this.config)),(r==="file"||r==="both")&&e.push(kYt(this.config));let i=BP(D3e.default,{levels:["error","warn"]});return e.push(new i({handleExceptions:!0,handleRejections:!0,format:Kf.default.format.combine(Kf.default.format.errors({stack:!0}))})),Kf.default.createLogger({level:n,transports:e,exitOnError:!1})}info(e,r){this.winston.info(e,r)}warn(e,r){this.winston.warn(e,r)}error(e,r){this.winston.error(e,r)}success(e,r){this.winston.levels.success!==void 0?this.winston.success(e,r):this.winston.info(e,{...r,level:"success"})}debug(e,r){this.winston.debug(e,r)}setLevel(e){this.config.level=e,this.winston.level=e==="silent"?"error":e,this.winston.transports.forEach(r=>{r.level=e==="silent"?"error":e,r instanceof Kf.default.transports.Console&&(r.silent=e==="silent")})}child(e){let r=this.winston.child(e),n=Object.create(this);return n.winston=r,n}async close(){return new Promise(e=>{this.winston.close(),e()})}},SJ=null,kB=(t={})=>new bJ(t);var P3e=(t={})=>{let e=kB({transports:"both",level:"info",console:{colorize:!0,timestamp:!1,format:"simple"},file:{dirname:vJ.default.join(O3e.default.homedir(),".lody","logs"),maxSize:"20m",maxFiles:14},...t});return bu=e,e},TJ=()=>(SJ||(SJ=kB({transports:"console",level:"info",console:{colorize:!0,timestamp:!1,format:"simple"}})),SJ),bu=TJ(),Uo=(t,e)=>!t&&!e?bu:bu.child({...t?{scope:t}:{},...e});var MYt=2e3,k3e=!1,LYt=t=>t instanceof Error?t:new Error(String(t)),Gs=async(t,e,r={})=>{let n=LYt(e),i=r.logger??Uo(t);i.error(e),i.error(r.message||n.message,{error:n,...r.extra}),await nRe(n,{component:t,extra:r.extra}),r.fatal&&await TW(MYt)},M3e=()=>{k3e||(k3e=!0,process.on("uncaughtException",t=>{Gs("uncaughtException",t,{message:"Uncaught exception in CLI",logger:bu,fatal:!0}).finally(()=>process.exit(1))}),process.on("unhandledRejection",t=>{Gs("unhandledRejection",t,{message:"Unhandled promise rejection in CLI",logger:bu,fatal:!0}).finally(()=>process.exit(1))}))};var qo=he(require("fs"),1),qa=he(require("path"),1),L3e=he(require("os"),1),F3e=require("child_process"),AJ=require("module"),H3e={},WC=qa.default.join(L3e.default.homedir(),".lody-agent"),YC=qa.default.join(WC,"serve.pid"),zC=qa.default.join(WC,"serve.json");function B3e(){qo.default.existsSync(WC)||qo.default.mkdirSync(WC,{recursive:!0})}function xJ(t,e){B3e(),qo.default.writeFileSync(YC,t.toString());let r={pid:t,...e};qo.default.writeFileSync(zC,JSON.stringify(r,null,2))}function U3e(t){xJ(process.pid,{...t,startTime:new Date().toISOString()})}function wJ(){try{if(!qo.default.existsSync(YC))return null;let t=parseInt(qo.default.readFileSync(YC,"utf-8").trim(),10);return isNaN(t)?null:t}catch{return null}}function FYt(){try{return qo.default.existsSync(zC)?JSON.parse(qo.default.readFileSync(zC,"utf-8")):null}catch{return null}}function MB(t){try{return process.kill(t,0),!0}catch{return!1}}function q3e(t){try{return process.kill(t,"SIGTERM"),setTimeout(()=>{if(MB(t))try{process.kill(t,"SIGKILL")}catch{}},2e3),!0}catch{return!1}}function CJ(){try{qo.default.existsSync(YC)&&qo.default.unlinkSync(YC),qo.default.existsSync(zC)&&qo.default.unlinkSync(zC)}catch{}}function IJ(){let t=wJ(),e=FYt();return!t||!e?{running:!1,info:null}:MB(t)?{running:!0,info:e}:(CJ(),{running:!1,info:null})}function BYt(t){let e=(0,AJ.createRequire)(H3e.url),r=qa.default.join(t,"node_modules",".bin","ts-node");if(qo.default.existsSync(r))return r;try{return e.resolve("ts-node/dist/bin.js",{paths:[t]})}catch{try{return e.resolve("ts-node",{paths:[t]})}catch{return null}}}function UYt(t){let e=(0,AJ.createRequire)(H3e.url),r=qa.default.join(t,"node_modules",".bin","tsx");if(qo.default.existsSync(r))return r;try{return e.resolve("tsx/dist/cli.mjs",{paths:[t]})}catch{try{return e.resolve("tsx",{paths:[t]})}catch{return null}}}function j3e(t,e,r){let n=qa.default.dirname(qa.default.dirname(t)),i=qa.default.join(n,"tsconfig.json"),s=t.endsWith(".ts"),o,a;if(s){let d=UYt(n),h=BYt(n);if(d){let p=d.includes(`${qa.default.sep}.bin${qa.default.sep}`);o=p?d:process.execPath,a=p?[t,...e]:[d,t,...e]}else if(h){let p=h.includes(`${qa.default.sep}.bin${qa.default.sep}`);o=p?h:process.execPath,a=[...p?[]:[h],"--esm","--project",i,"--experimentalSpecifierResolution","node",t,...e]}else throw new Error("Neither tsx nor ts-node is installed; cannot start background service")}else o=process.execPath,a=[t,...e];let c=s?n:process.cwd();B3e();let u=qa.default.join(WC,"background.log"),l=qo.default.openSync(u,"a");r?.info(`Starting background service: ${o} ${a.join(" ")}`),r?.info(`Working directory: ${c}`),r?.info(`Background logs: ${u}`);let f=(0,F3e.spawn)(o,a,{detached:!0,stdio:["ignore",l,l],cwd:c,env:{...process.env,LODY_AGENT_BACKGROUND:"1"}});return f.stdout?.on("data",d=>{let h=d.toString();r?.info("STDOUT",{output:h.trim()})}),f.stderr?.on("data",d=>{let h=d.toString();r?.error("STDERR",{error:h.trim()})}),f.on("error",d=>{r?.error("Process error",{error:d})}),f.on("close",(d,h)=>{r?.info("Process closed",{exitCode:d,signal:h||"none"}),r?.info("=== Agent Service Stopped ===")}),f.unref(),{child:f}}var G3e=require("child_process"),$3e=require("util"),DJ=(0,$3e.promisify)(G3e.exec);async function V3e(){try{await DJ("docker ps -q");let{stdout:t}=await DJ('docker version --format "{{.Server.Version}}"'),e=t.trim();return e?{installed:!0,running:!0,version:e}:{installed:!0,running:!1,error:"Docker is installed but not running"}}catch(t){let e=t instanceof Error?t.message.toLowerCase():"";if(e.includes("permission denied")||e.includes("got permission denied")||e.includes("connect: permission denied")||e.includes("dial unix /var/run/docker.sock"))try{let{stdout:r}=await DJ("groups");return r.includes("docker")?{installed:!0,running:!1,error:`Permission denied accessing Docker socket.
195
195
  Try running: sudo chmod 666 /var/run/docker.sock
196
196
  Or restart the Docker service: sudo systemctl restart docker`}:{installed:!0,running:!1,error:`Permission denied. Your user is not in the docker group.
197
197
  To fix this, run: sudo usermod -aG docker $USER
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lody",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Lody Agent CLI tool for managing remote command execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",