@sailfish-ai/sf-veritas 0.2.19 → 0.2.20

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.
@@ -0,0 +1 @@
1
+ "use strict";const A=require("async_hooks"),U=require("child_process"),h=require("fs"),P=require("fs/promises"),m=require("os");function D(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const M=D(P),R=D(m),o=[];for(let s=0;s<256;++s)o.push((s+256).toString(16).slice(1));let C;const b=new Uint8Array(16),O={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function g(s,e,t){if(O.randomUUID&&!s)return O.randomUUID();const r=(s=s||{}).random??s.rng?.()??(function(){if(!C){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");C=crypto.getRandomValues.bind(crypto)}return C(b)})();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,(function(n,i=0){return(o[n[i+0]]+o[n[i+1]]+o[n[i+2]]+o[n[i+3]]+"-"+o[n[i+4]]+o[n[i+5]]+"-"+o[n[i+6]]+o[n[i+7]]+"-"+o[n[i+8]]+o[n[i+9]]+"-"+o[n[i+10]]+o[n[i+11]]+o[n[i+12]]+o[n[i+13]]+o[n[i+14]]+o[n[i+15]]).toLowerCase()})(r)}class x{apiKey;apiGraphqlEndpoint;sfDebug;serviceIdentifier;serviceVersion;serviceUUID;serviceAdditionalMetadata;profilingModeEnabled;profilingMaxDepth;profilingMaxVariableSizeKb;domainsToNotPropagateHeadersTo;nodeModulesToCollectLocalVariablesOn;printConfigurationStatuses;logLevel;stackDepthLocals;stackDepthCodeTraceDepth;packageLibraryType;version;gitSha;gitOrg;gitRepo;gitProvider;serviceDisplayName;infrastructureType;infrastructureDetails;setupInterceptorsFile;setupInterceptorsLine;logIgnoreRegex;captureRequestHeaders;captureResponseHeaders;captureRequestBody;captureResponseBody;requestBodyLimitBytes;responseBodyLimitBytes;_serviceIdentificationReceived=!1;constructor(e){this.apiKey=e.apiKey,this.apiGraphqlEndpoint=e?.apiGraphqlEndpoint||process.env.SAILFISH_GRAPHQL_ENDPOINT||"https://api-service.sailfishqa.com/graphql/",this.sfDebug=e?.debug===!0||process.env.SF_DEBUG==="true",this.serviceIdentifier=e?.serviceIdentifier||process.env.SERVICE_IDENTIFIER,this.serviceUUID=g(),this.serviceVersion=e?.serviceVersion||process.env.SERVICE_VERSION,this.gitSha=e?.gitSha||process.env.GIT_SHA||process.env.GITHUB_SHA||process.env.CI_COMMIT_SHA||process.env.BITBUCKET_COMMIT||process.env.VERCEL_GIT_COMMIT_SHA||process.env.CIRCLE_SHA1||process.env.HEROKU_SLUG_COMMIT||process.env.RENDER_GIT_COMMIT||process.env.RAILWAY_GIT_COMMIT_SHA||process.env.CODEBUILD_RESOLVED_SOURCE_VERSION;const t=process.env.GITHUB_REPOSITORY?.split("/");this.gitOrg=e?.gitOrg||process.env.GIT_ORG||(t&&t.length>=2?t[0]:void 0)||process.env.CI_PROJECT_NAMESPACE||process.env.BITBUCKET_REPO_OWNER||process.env.VERCEL_GIT_REPO_OWNER||process.env.CIRCLE_PROJECT_USERNAME,this.gitRepo=e?.gitRepo||process.env.GIT_REPO||(t&&t.length>=2?t.slice(1).join("/"):void 0)||process.env.CI_PROJECT_NAME||process.env.BITBUCKET_REPO_SLUG||process.env.VERCEL_GIT_REPO_SLUG||process.env.CIRCLE_PROJECT_REPONAME,this.gitProvider=e?.gitProvider||process.env.GIT_PROVIDER||(process.env.GITHUB_ACTIONS?"github":void 0)||(process.env.GITLAB_CI?"gitlab":void 0)||(process.env.BITBUCKET_PIPELINE_UUID?"bitbucket":void 0)||(process.env.CIRCLECI?"circleci":void 0),this.serviceDisplayName=e?.serviceDisplayName||process.env.SERVICE_DISPLAY_NAME,this.serviceAdditionalMetadata=e?.serviceAdditionalMetadata||{},this.profilingModeEnabled=e?.profilingModeEnabled??!1,this.profilingMaxDepth=e?.profilingMaxDepth??5,this.profilingMaxVariableSizeKb=e?.profilingMaxVariableSizeKb??25,this.domainsToNotPropagateHeadersTo=e?.domainsToNotPropagateHeadersTo||[],this.nodeModulesToCollectLocalVariablesOn=e?.nodeModulesToCollectLocalVariablesOn||["_all_"],this.printConfigurationStatuses=process.env.PRINT_CONFIGURATION_STATUSES||"true",this.logLevel=process.env.LOG_LEVEL||"INFO",this.stackDepthLocals=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS,10):5,isNaN(this.stackDepthLocals)&&(this.stackDepthLocals=-1),this.stackDepthCodeTraceDepth=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH,10):-1,isNaN(this.stackDepthCodeTraceDepth)&&(this.stackDepthCodeTraceDepth=-1),this.packageLibraryType="JS/TS BACKEND",this.version=this.getPackageVersion();const r=(function(){return process.env.KUBERNETES_SERVICE_HOST||h.existsSync("/var/run/secrets/kubernetes.io/serviceaccount/token")?{type:"Kubernetes",details:{namespace:process.env.POD_NAMESPACE||"",podName:process.env.HOSTNAME||"",nodeName:process.env.NODE_NAME||""}}:process.env.AWS_LAMBDA_FUNCTION_NAME?{type:"AWS Lambda",details:{functionName:process.env.AWS_LAMBDA_FUNCTION_NAME||"",region:process.env.AWS_REGION||"",runtime:process.env.AWS_EXECUTION_ENV||""}}:process.env.AWS_EXECUTION_ENV?{type:"AWS",details:{executionEnv:process.env.AWS_EXECUTION_ENV||"",region:process.env.AWS_REGION||""}}:process.env.GOOGLE_CLOUD_PROJECT?{type:"Google Cloud",details:{project:process.env.GOOGLE_CLOUD_PROJECT||""}}:process.env.AZURE_FUNCTIONS_ENVIRONMENT?{type:"Azure Functions",details:{environment:process.env.AZURE_FUNCTIONS_ENVIRONMENT||""}}:process.env.VERCEL?{type:"Vercel",details:{env:process.env.VERCEL_ENV||"",region:process.env.VERCEL_REGION||""}}:process.env.NETLIFY?{type:"Netlify",details:{}}:process.env.FLY_APP_NAME?{type:"Fly.io",details:{appName:process.env.FLY_APP_NAME||"",region:process.env.FLY_REGION||""}}:process.env.RENDER_SERVICE_ID?{type:"Render",details:{serviceId:process.env.RENDER_SERVICE_ID||""}}:process.env.RAILWAY_ENVIRONMENT?{type:"Railway",details:{environment:process.env.RAILWAY_ENVIRONMENT||""}}:h.existsSync("/.dockerenv")?{type:"Docker",details:{}}:{type:"Unknown",details:{os:R.platform(),arch:R.arch(),nodeVersion:process.version}}})();this.infrastructureType=r.type,this.infrastructureDetails=r.details;const n=process.env.SF_LOG_IGNORE_REGEX;if(n)try{this.logIgnoreRegex=new RegExp(n)}catch{}this.captureRequestHeaders=process.env.SF_NETWORKHOP_CAPTURE_REQUEST_HEADERS==="true",this.captureResponseHeaders=process.env.SF_NETWORKHOP_CAPTURE_RESPONSE_HEADERS==="true",this.captureRequestBody=process.env.SF_NETWORKHOP_CAPTURE_REQUEST_BODY==="true",this.captureResponseBody=process.env.SF_NETWORKHOP_CAPTURE_RESPONSE_BODY==="true";const i=parseInt(process.env.SF_NETWORKHOP_REQUEST_LIMIT_MB||"1",10);this.requestBodyLimitBytes=1024*(isNaN(i)?1:i)*1024;const c=parseInt(process.env.SF_NETWORKHOP_RESPONSE_LIMIT_MB||"1",10);this.responseBodyLimitBytes=1024*(isNaN(c)?1:c)*1024}getPackageVersion(){return"0.2.14"}get serviceIdentificationReceived(){return this._serviceIdentificationReceived}setServiceIdentificationReceived(e){this._serviceIdentificationReceived=e}}const L=Symbol.for("sailfish.sf_config");function S(){return globalThis[L]}function _(){const s=S();if(!s)throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");return s}const T=Symbol.for("sf.ctx.storeAls"),a=globalThis,v=a[T]??(a[T]=new A.AsyncLocalStorage),y=["identitytoolkit.googleapis.com","t.co","*.twitter.com","*.gravatar.com","*.googleapis.com","*.amazonaws.com","*.smooch.io","*.zendesk.com"],f=Symbol.for("sf.ctx.als"),E=a[f]??(a[f]=new A.AsyncLocalStorage),N=Symbol.for("sf.ctx.sessionRegistry"),d=a[N]??(a[N]=new Map),l={handledExceptions:new Set,reentrancyGuardLoggingActive:!1,reentrancyGuardLoggingPreActive:!1,reentrancyGuardPrintActive:!1,reentrancyGuardPrintPreActive:!1,reentrancyGuardExceptionActive:!1,reentrancyGuardExceptionPreActive:!1,excludedDomains:new Set(y),supportedDomains:new Set};class p{static GLOBAL_MANAGER_SYMBOL=Symbol.for("sf.ctx.manager");constructor(){}current(){return v.getStore()}ensureStore(){const e=this.current();if(e)return e;const t=new Map;return v.enterWith(t),t}runWith(e,t){const r=this.current()??new Map,n=new Map(r);for(const[i,c]of Object.entries(e))n.set(i,c);return v.run(n,t)}static getInstance(){return a[p.GLOBAL_MANAGER_SYMBOL]||(a[p.GLOBAL_MANAGER_SYMBOL]=new p),a[p.GLOBAL_MANAGER_SYMBOL]}getCurrentContext(){return E.getStore()||l}setCurrentContext(e){const t=E.getStore()||l;E.enterWith({...t,...e})}ensureSession(e){let t=d.get(e);return t||(t={...l},d.set(e,t)),t}getContextFor(e){return d.get(e)??l}updateContextFor(e,t){const r=this.ensureSession(e);d.set(e,{...r,...t})}runWithSession(e,t){const r={...this.ensureSession(e)};return E.run(r,t)}deleteSession(e){d.delete(e)}getTraceId(){return this.getCurrentContext().traceId}getPageVisitUUID(){return this.getCurrentContext().pageVisitUUID}setTraceId(e){this.setCurrentContext({traceId:e})}setPageVisitUUID(e){this.setCurrentContext({pageVisitUUID:e})}getCurrentFunctionSpanId(){return this.getCurrentContext().currentFunctionSpanId}setCurrentFunctionSpanId(e){this.setCurrentContext({currentFunctionSpanId:e})}clearCurrentFunctionSpanId(){this.setCurrentContext({currentFunctionSpanId:void 0})}getOrSetSfTraceId(e,t=!1){let r=this.getTraceId();return r||(r=e||(t?g():`nonsession-applogs-v3/${_().apiKey}/${g()}`),this.setTraceId(r),_().sfDebug&&console.log(" Created new trace ID:",r),r)}getOrSetPageVisitUUID(){let e=this.getPageVisitUUID();return e||(e=g(),this.setPageVisitUUID(e),_().sfDebug&&console.log(" Created new page visit UUID:",e),e)}getHandledExceptions(){return this.getCurrentContext().handledExceptions}markExceptionHandled(e){const t=this.getHandledExceptions();t.add(e),this.setCurrentContext({handledExceptions:t})}hasHandledException(e){return this.getHandledExceptions().has(e)}resetHandledExceptions(){this.setCurrentContext({handledExceptions:new Set})}getExcludedDomains(){return this.getCurrentContext().excludedDomains}getSupportedDomains(){return this.getCurrentContext().supportedDomains}addSupportedDomains(e){this.getCurrentContext().supportedDomains.add(e.toLowerCase().trim())}setTraceIdFor(e,t){this.updateContextFor(e,{traceId:t})}setPageVisitUUIDFor(e,t){this.updateContextFor(e,{pageVisitUUID:t})}}exports.ContextManager=p,exports.DEFAULT_DOMAINS_TO_EXCLUDE=y,exports.backfillGitInfoAsync=async function(s){if(!(s.gitOrg&&s.gitRepo&&s.gitProvider))try{const e=await(async function(){let t="";try{t=await new Promise((r,n)=>{U.execFile("git",["remote","get-url","origin"],{timeout:3e3},(i,c)=>{i?n(i):r((c||"").trim())})})}catch{try{const r=(await M.readFile(".git/config","utf-8")).match(/\[remote "origin"\][^[]*url\s*=\s*(.+)/m);r&&(t=r[1].trim())}catch{}}return t?(function(r){let n,i,c;if(r.includes("github.com")?n="github":r.includes("gitlab.com")?n="gitlab":r.includes("bitbucket.org")&&(n="bitbucket"),r.startsWith("https://")||r.startsWith("http://")){const u=r.split("/");u.length>=5&&(i=u[3],c=u[4].replace(/\.git$/,""))}else{const u=r.indexOf(":");if(u>0){const I=r.substring(u+1).replace(/\.git$/,"").split("/");I.length>=2&&(i=I[0],c=I[1])}}return{org:i,repo:c,provider:n}})(t):{}})();s.gitOrg||(s.gitOrg=e.org),s.gitRepo||(s.gitRepo=e.repo),s.gitProvider||(s.gitProvider=e.provider)}catch{}},exports.getConfig=_,exports.getCurrentFunctionSpanId=function(){return p.getInstance().getCurrentFunctionSpanId()},exports.getGlobalConfigUnsafe=S,exports.getOrCreateConfig=function(s){const e=S();if(e)return{config:e};const t=new x(s);return(function(r){globalThis[L]=r})(t),t.sfDebug&&console.log("[[getOrCreateConfig]] Created global config:",t),{config:t}},exports.runWithContext=function(s){const e={...p.getInstance().getCurrentContext()};E.run(e,()=>{s()})},exports.v4=g;
@@ -1,30 +1,30 @@
1
- var L = Object.defineProperty;
2
- var P = (n, e, t) => e in n ? L(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var s = (n, e, t) => P(n, typeof e != "symbol" ? e + "" : e, t);
1
+ var y = Object.defineProperty;
2
+ var U = (n, e, t) => e in n ? y(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var s = (n, e, t) => U(n, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { AsyncLocalStorage as D } from "async_hooks";
5
- import { execFile as U } from "child_process";
6
- import { existsSync as f } from "fs";
7
- import * as x from "fs/promises";
8
- import * as R from "os";
9
- const a = [];
10
- for (let n = 0; n < 256; ++n) a.push((n + 256).toString(16).slice(1));
11
- let S;
12
- const b = new Uint8Array(16), N = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
13
- function h(n, e, t) {
14
- if (N.randomUUID && !n) return N.randomUUID();
5
+ import { execFile as P } from "child_process";
6
+ import { existsSync as R } from "fs";
7
+ import * as M from "fs/promises";
8
+ import * as T from "os";
9
+ const c = [];
10
+ for (let n = 0; n < 256; ++n) c.push((n + 256).toString(16).slice(1));
11
+ let v;
12
+ const b = new Uint8Array(16), O = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
13
+ function I(n, e, t) {
14
+ if (O.randomUUID && !n) return O.randomUUID();
15
15
  const r = (n = n || {}).random ?? n.rng?.() ?? (function() {
16
- if (!S) {
16
+ if (!v) {
17
17
  if (typeof crypto > "u" || !crypto.getRandomValues) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
18
- S = crypto.getRandomValues.bind(crypto);
18
+ v = crypto.getRandomValues.bind(crypto);
19
19
  }
20
- return S(b);
20
+ return v(b);
21
21
  })();
22
22
  if (r.length < 16) throw new Error("Random bytes length must be >= 16");
23
23
  return r[6] = 15 & r[6] | 64, r[8] = 63 & r[8] | 128, (function(i, o = 0) {
24
- return (a[i[o + 0]] + a[i[o + 1]] + a[i[o + 2]] + a[i[o + 3]] + "-" + a[i[o + 4]] + a[i[o + 5]] + "-" + a[i[o + 6]] + a[i[o + 7]] + "-" + a[i[o + 8]] + a[i[o + 9]] + "-" + a[i[o + 10]] + a[i[o + 11]] + a[i[o + 12]] + a[i[o + 13]] + a[i[o + 14]] + a[i[o + 15]]).toLowerCase();
24
+ return (c[i[o + 0]] + c[i[o + 1]] + c[i[o + 2]] + c[i[o + 3]] + "-" + c[i[o + 4]] + c[i[o + 5]] + "-" + c[i[o + 6]] + c[i[o + 7]] + "-" + c[i[o + 8]] + c[i[o + 9]] + "-" + c[i[o + 10]] + c[i[o + 11]] + c[i[o + 12]] + c[i[o + 13]] + c[i[o + 14]] + c[i[o + 15]]).toLowerCase();
25
25
  })(r);
26
26
  }
27
- class V {
27
+ class x {
28
28
  constructor(e) {
29
29
  s(this, "apiKey");
30
30
  s(this, "apiGraphqlEndpoint");
@@ -61,21 +61,23 @@ class V {
61
61
  s(this, "requestBodyLimitBytes");
62
62
  s(this, "responseBodyLimitBytes");
63
63
  s(this, "_serviceIdentificationReceived", !1);
64
- this.apiKey = e.apiKey, this.apiGraphqlEndpoint = e?.apiGraphqlEndpoint || process.env.SAILFISH_GRAPHQL_ENDPOINT || "https://api-service.sailfishqa.com/graphql/", this.sfDebug = e?.debug === !0 || process.env.SF_DEBUG === "true", this.serviceIdentifier = e?.serviceIdentifier || process.env.SERVICE_IDENTIFIER, this.serviceUUID = h(), this.serviceVersion = e?.serviceVersion || process.env.SERVICE_VERSION, this.gitSha = e?.gitSha || process.env.GIT_SHA || process.env.VERCEL_GIT_COMMIT_SHA, this.gitOrg = e?.gitOrg || process.env.GIT_ORG || process.env.VERCEL_GIT_REPO_OWNER, this.gitRepo = e?.gitRepo || process.env.GIT_REPO || process.env.VERCEL_GIT_REPO_SLUG, this.gitProvider = e?.gitProvider || process.env.GIT_PROVIDER, this.serviceDisplayName = e?.serviceDisplayName || process.env.SERVICE_DISPLAY_NAME, this.serviceAdditionalMetadata = e?.serviceAdditionalMetadata || {}, this.profilingModeEnabled = e?.profilingModeEnabled ?? !1, this.profilingMaxDepth = e?.profilingMaxDepth ?? 5, this.profilingMaxVariableSizeKb = e?.profilingMaxVariableSizeKb ?? 25, this.domainsToNotPropagateHeadersTo = e?.domainsToNotPropagateHeadersTo || [], this.nodeModulesToCollectLocalVariablesOn = e?.nodeModulesToCollectLocalVariablesOn || ["_all_"], this.printConfigurationStatuses = process.env.PRINT_CONFIGURATION_STATUSES || "true", this.logLevel = process.env.LOG_LEVEL || "INFO", this.stackDepthLocals = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS, 10) : 5, isNaN(this.stackDepthLocals) && (this.stackDepthLocals = -1), this.stackDepthCodeTraceDepth = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH, 10) : -1, isNaN(this.stackDepthCodeTraceDepth) && (this.stackDepthCodeTraceDepth = -1), this.packageLibraryType = "JS/TS BACKEND", this.version = this.getPackageVersion();
65
- const t = (function() {
66
- return process.env.KUBERNETES_SERVICE_HOST || f("/var/run/secrets/kubernetes.io/serviceaccount/token") ? { type: "Kubernetes", details: { namespace: process.env.POD_NAMESPACE || "", podName: process.env.HOSTNAME || "", nodeName: process.env.NODE_NAME || "" } } : process.env.AWS_LAMBDA_FUNCTION_NAME ? { type: "AWS Lambda", details: { functionName: process.env.AWS_LAMBDA_FUNCTION_NAME || "", region: process.env.AWS_REGION || "", runtime: process.env.AWS_EXECUTION_ENV || "" } } : process.env.AWS_EXECUTION_ENV ? { type: "AWS", details: { executionEnv: process.env.AWS_EXECUTION_ENV || "", region: process.env.AWS_REGION || "" } } : process.env.GOOGLE_CLOUD_PROJECT ? { type: "Google Cloud", details: { project: process.env.GOOGLE_CLOUD_PROJECT || "" } } : process.env.AZURE_FUNCTIONS_ENVIRONMENT ? { type: "Azure Functions", details: { environment: process.env.AZURE_FUNCTIONS_ENVIRONMENT || "" } } : process.env.VERCEL ? { type: "Vercel", details: { env: process.env.VERCEL_ENV || "", region: process.env.VERCEL_REGION || "" } } : process.env.NETLIFY ? { type: "Netlify", details: {} } : process.env.FLY_APP_NAME ? { type: "Fly.io", details: { appName: process.env.FLY_APP_NAME || "", region: process.env.FLY_REGION || "" } } : process.env.RENDER_SERVICE_ID ? { type: "Render", details: { serviceId: process.env.RENDER_SERVICE_ID || "" } } : process.env.RAILWAY_ENVIRONMENT ? { type: "Railway", details: { environment: process.env.RAILWAY_ENVIRONMENT || "" } } : f("/.dockerenv") ? { type: "Docker", details: {} } : { type: "Unknown", details: { os: R.platform(), arch: R.arch(), nodeVersion: process.version } };
64
+ this.apiKey = e.apiKey, this.apiGraphqlEndpoint = e?.apiGraphqlEndpoint || process.env.SAILFISH_GRAPHQL_ENDPOINT || "https://api-service.sailfishqa.com/graphql/", this.sfDebug = e?.debug === !0 || process.env.SF_DEBUG === "true", this.serviceIdentifier = e?.serviceIdentifier || process.env.SERVICE_IDENTIFIER, this.serviceUUID = I(), this.serviceVersion = e?.serviceVersion || process.env.SERVICE_VERSION, this.gitSha = e?.gitSha || process.env.GIT_SHA || process.env.GITHUB_SHA || process.env.CI_COMMIT_SHA || process.env.BITBUCKET_COMMIT || process.env.VERCEL_GIT_COMMIT_SHA || process.env.CIRCLE_SHA1 || process.env.HEROKU_SLUG_COMMIT || process.env.RENDER_GIT_COMMIT || process.env.RAILWAY_GIT_COMMIT_SHA || process.env.CODEBUILD_RESOLVED_SOURCE_VERSION;
65
+ const t = process.env.GITHUB_REPOSITORY?.split("/");
66
+ this.gitOrg = e?.gitOrg || process.env.GIT_ORG || (t && t.length >= 2 ? t[0] : void 0) || process.env.CI_PROJECT_NAMESPACE || process.env.BITBUCKET_REPO_OWNER || process.env.VERCEL_GIT_REPO_OWNER || process.env.CIRCLE_PROJECT_USERNAME, this.gitRepo = e?.gitRepo || process.env.GIT_REPO || (t && t.length >= 2 ? t.slice(1).join("/") : void 0) || process.env.CI_PROJECT_NAME || process.env.BITBUCKET_REPO_SLUG || process.env.VERCEL_GIT_REPO_SLUG || process.env.CIRCLE_PROJECT_REPONAME, this.gitProvider = e?.gitProvider || process.env.GIT_PROVIDER || (process.env.GITHUB_ACTIONS ? "github" : void 0) || (process.env.GITLAB_CI ? "gitlab" : void 0) || (process.env.BITBUCKET_PIPELINE_UUID ? "bitbucket" : void 0) || (process.env.CIRCLECI ? "circleci" : void 0), this.serviceDisplayName = e?.serviceDisplayName || process.env.SERVICE_DISPLAY_NAME, this.serviceAdditionalMetadata = e?.serviceAdditionalMetadata || {}, this.profilingModeEnabled = e?.profilingModeEnabled ?? !1, this.profilingMaxDepth = e?.profilingMaxDepth ?? 5, this.profilingMaxVariableSizeKb = e?.profilingMaxVariableSizeKb ?? 25, this.domainsToNotPropagateHeadersTo = e?.domainsToNotPropagateHeadersTo || [], this.nodeModulesToCollectLocalVariablesOn = e?.nodeModulesToCollectLocalVariablesOn || ["_all_"], this.printConfigurationStatuses = process.env.PRINT_CONFIGURATION_STATUSES || "true", this.logLevel = process.env.LOG_LEVEL || "INFO", this.stackDepthLocals = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS, 10) : 5, isNaN(this.stackDepthLocals) && (this.stackDepthLocals = -1), this.stackDepthCodeTraceDepth = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH, 10) : -1, isNaN(this.stackDepthCodeTraceDepth) && (this.stackDepthCodeTraceDepth = -1), this.packageLibraryType = "JS/TS BACKEND", this.version = this.getPackageVersion();
67
+ const r = (function() {
68
+ return process.env.KUBERNETES_SERVICE_HOST || R("/var/run/secrets/kubernetes.io/serviceaccount/token") ? { type: "Kubernetes", details: { namespace: process.env.POD_NAMESPACE || "", podName: process.env.HOSTNAME || "", nodeName: process.env.NODE_NAME || "" } } : process.env.AWS_LAMBDA_FUNCTION_NAME ? { type: "AWS Lambda", details: { functionName: process.env.AWS_LAMBDA_FUNCTION_NAME || "", region: process.env.AWS_REGION || "", runtime: process.env.AWS_EXECUTION_ENV || "" } } : process.env.AWS_EXECUTION_ENV ? { type: "AWS", details: { executionEnv: process.env.AWS_EXECUTION_ENV || "", region: process.env.AWS_REGION || "" } } : process.env.GOOGLE_CLOUD_PROJECT ? { type: "Google Cloud", details: { project: process.env.GOOGLE_CLOUD_PROJECT || "" } } : process.env.AZURE_FUNCTIONS_ENVIRONMENT ? { type: "Azure Functions", details: { environment: process.env.AZURE_FUNCTIONS_ENVIRONMENT || "" } } : process.env.VERCEL ? { type: "Vercel", details: { env: process.env.VERCEL_ENV || "", region: process.env.VERCEL_REGION || "" } } : process.env.NETLIFY ? { type: "Netlify", details: {} } : process.env.FLY_APP_NAME ? { type: "Fly.io", details: { appName: process.env.FLY_APP_NAME || "", region: process.env.FLY_REGION || "" } } : process.env.RENDER_SERVICE_ID ? { type: "Render", details: { serviceId: process.env.RENDER_SERVICE_ID || "" } } : process.env.RAILWAY_ENVIRONMENT ? { type: "Railway", details: { environment: process.env.RAILWAY_ENVIRONMENT || "" } } : R("/.dockerenv") ? { type: "Docker", details: {} } : { type: "Unknown", details: { os: T.platform(), arch: T.arch(), nodeVersion: process.version } };
67
69
  })();
68
- this.infrastructureType = t.type, this.infrastructureDetails = t.details;
69
- const r = process.env.SF_LOG_IGNORE_REGEX;
70
- if (r) try {
71
- this.logIgnoreRegex = new RegExp(r);
70
+ this.infrastructureType = r.type, this.infrastructureDetails = r.details;
71
+ const i = process.env.SF_LOG_IGNORE_REGEX;
72
+ if (i) try {
73
+ this.logIgnoreRegex = new RegExp(i);
72
74
  } catch {
73
75
  }
74
76
  this.captureRequestHeaders = process.env.SF_NETWORKHOP_CAPTURE_REQUEST_HEADERS === "true", this.captureResponseHeaders = process.env.SF_NETWORKHOP_CAPTURE_RESPONSE_HEADERS === "true", this.captureRequestBody = process.env.SF_NETWORKHOP_CAPTURE_REQUEST_BODY === "true", this.captureResponseBody = process.env.SF_NETWORKHOP_CAPTURE_RESPONSE_BODY === "true";
75
- const i = parseInt(process.env.SF_NETWORKHOP_REQUEST_LIMIT_MB || "1", 10);
76
- this.requestBodyLimitBytes = 1024 * (isNaN(i) ? 1 : i) * 1024;
77
- const o = parseInt(process.env.SF_NETWORKHOP_RESPONSE_LIMIT_MB || "1", 10);
78
- this.responseBodyLimitBytes = 1024 * (isNaN(o) ? 1 : o) * 1024;
77
+ const o = parseInt(process.env.SF_NETWORKHOP_REQUEST_LIMIT_MB || "1", 10);
78
+ this.requestBodyLimitBytes = 1024 * (isNaN(o) ? 1 : o) * 1024;
79
+ const a = parseInt(process.env.SF_NETWORKHOP_RESPONSE_LIMIT_MB || "1", 10);
80
+ this.responseBodyLimitBytes = 1024 * (isNaN(a) ? 1 : a) * 1024;
79
81
  }
80
82
  getPackageVersion() {
81
83
  return "0.2.14";
@@ -87,103 +89,103 @@ class V {
87
89
  this._serviceIdentificationReceived = e;
88
90
  }
89
91
  }
90
- async function B(n) {
92
+ async function w(n) {
91
93
  if (!(n.gitOrg && n.gitRepo && n.gitProvider)) try {
92
94
  const e = await (async function() {
93
95
  let t = "";
94
96
  try {
95
97
  t = await new Promise((r, i) => {
96
- U("git", ["remote", "get-url", "origin"], { timeout: 3e3 }, (o, p) => {
97
- o ? i(o) : r((p || "").trim());
98
+ P("git", ["remote", "get-url", "origin"], { timeout: 3e3 }, (o, a) => {
99
+ o ? i(o) : r((a || "").trim());
98
100
  });
99
101
  });
100
102
  } catch {
101
103
  try {
102
- const r = (await x.readFile(".git/config", "utf-8")).match(/\[remote "origin"\][^[]*url\s*=\s*(.+)/m);
104
+ const r = (await M.readFile(".git/config", "utf-8")).match(/\[remote "origin"\][^[]*url\s*=\s*(.+)/m);
103
105
  r && (t = r[1].trim());
104
106
  } catch {
105
107
  }
106
108
  }
107
109
  return t ? (function(r) {
108
- let i, o, p;
110
+ let i, o, a;
109
111
  if (r.includes("github.com") ? i = "github" : r.includes("gitlab.com") ? i = "gitlab" : r.includes("bitbucket.org") && (i = "bitbucket"), r.startsWith("https://") || r.startsWith("http://")) {
110
112
  const d = r.split("/");
111
- d.length >= 5 && (o = d[3], p = d[4].replace(/\.git$/, ""));
113
+ d.length >= 5 && (o = d[3], a = d[4].replace(/\.git$/, ""));
112
114
  } else {
113
115
  const d = r.indexOf(":");
114
116
  if (d > 0) {
115
- const _ = r.substring(d + 1).replace(/\.git$/, "").split("/");
116
- _.length >= 2 && (o = _[0], p = _[1]);
117
+ const C = r.substring(d + 1).replace(/\.git$/, "").split("/");
118
+ C.length >= 2 && (o = C[0], a = C[1]);
117
119
  }
118
120
  }
119
- return { org: o, repo: p, provider: i };
121
+ return { org: o, repo: a, provider: i };
120
122
  })(t) : {};
121
123
  })();
122
124
  n.gitOrg || (n.gitOrg = e.org), n.gitRepo || (n.gitRepo = e.repo), n.gitProvider || (n.gitProvider = e.provider);
123
125
  } catch {
124
126
  }
125
127
  }
126
- const m = Symbol.for("sailfish.sf_config");
127
- function y() {
128
- return globalThis[m];
128
+ const L = Symbol.for("sailfish.sf_config");
129
+ function m() {
130
+ return globalThis[L];
129
131
  }
130
132
  function W(n) {
131
- const e = y();
133
+ const e = m();
132
134
  if (e) return { config: e };
133
- const t = new V(n);
135
+ const t = new x(n);
134
136
  return (function(r) {
135
- globalThis[m] = r;
137
+ globalThis[L] = r;
136
138
  })(t), t.sfDebug && console.log("[[getOrCreateConfig]] Created global config:", t), { config: t };
137
139
  }
138
- function v() {
139
- const n = y();
140
+ function h() {
141
+ const n = m();
140
142
  if (!n) throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");
141
143
  return n;
142
144
  }
143
- const O = Symbol.for("sf.ctx.storeAls"), c = globalThis, C = c[O] ?? (c[O] = new D()), M = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], T = Symbol.for("sf.ctx.als"), E = c[T] ?? (c[T] = new D()), A = Symbol.for("sf.ctx.sessionRegistry"), g = c[A] ?? (c[A] = /* @__PURE__ */ new Map()), l = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(M), supportedDomains: /* @__PURE__ */ new Set() }, u = class u {
145
+ const f = Symbol.for("sf.ctx.storeAls"), p = globalThis, S = p[f] ?? (p[f] = new D()), G = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], N = Symbol.for("sf.ctx.als"), g = p[N] ?? (p[N] = new D()), A = Symbol.for("sf.ctx.sessionRegistry"), E = p[A] ?? (p[A] = /* @__PURE__ */ new Map()), l = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(G), supportedDomains: /* @__PURE__ */ new Set() }, u = class u {
144
146
  constructor() {
145
147
  }
146
148
  current() {
147
- return C.getStore();
149
+ return S.getStore();
148
150
  }
149
151
  ensureStore() {
150
152
  const e = this.current();
151
153
  if (e) return e;
152
154
  const t = /* @__PURE__ */ new Map();
153
- return C.enterWith(t), t;
155
+ return S.enterWith(t), t;
154
156
  }
155
157
  runWith(e, t) {
156
158
  const r = this.current() ?? /* @__PURE__ */ new Map(), i = new Map(r);
157
- for (const [o, p] of Object.entries(e)) i.set(o, p);
158
- return C.run(i, t);
159
+ for (const [o, a] of Object.entries(e)) i.set(o, a);
160
+ return S.run(i, t);
159
161
  }
160
162
  static getInstance() {
161
- return c[u.GLOBAL_MANAGER_SYMBOL] || (c[u.GLOBAL_MANAGER_SYMBOL] = new u()), c[u.GLOBAL_MANAGER_SYMBOL];
163
+ return p[u.GLOBAL_MANAGER_SYMBOL] || (p[u.GLOBAL_MANAGER_SYMBOL] = new u()), p[u.GLOBAL_MANAGER_SYMBOL];
162
164
  }
163
165
  getCurrentContext() {
164
- return E.getStore() || l;
166
+ return g.getStore() || l;
165
167
  }
166
168
  setCurrentContext(e) {
167
- const t = E.getStore() || l;
168
- E.enterWith({ ...t, ...e });
169
+ const t = g.getStore() || l;
170
+ g.enterWith({ ...t, ...e });
169
171
  }
170
172
  ensureSession(e) {
171
- let t = g.get(e);
172
- return t || (t = { ...l }, g.set(e, t)), t;
173
+ let t = E.get(e);
174
+ return t || (t = { ...l }, E.set(e, t)), t;
173
175
  }
174
176
  getContextFor(e) {
175
- return g.get(e) ?? l;
177
+ return E.get(e) ?? l;
176
178
  }
177
179
  updateContextFor(e, t) {
178
180
  const r = this.ensureSession(e);
179
- g.set(e, { ...r, ...t });
181
+ E.set(e, { ...r, ...t });
180
182
  }
181
183
  runWithSession(e, t) {
182
184
  const r = { ...this.ensureSession(e) };
183
- return E.run(r, t);
185
+ return g.run(r, t);
184
186
  }
185
187
  deleteSession(e) {
186
- g.delete(e);
188
+ E.delete(e);
187
189
  }
188
190
  getTraceId() {
189
191
  return this.getCurrentContext().traceId;
@@ -208,11 +210,11 @@ const O = Symbol.for("sf.ctx.storeAls"), c = globalThis, C = c[O] ?? (c[O] = new
208
210
  }
209
211
  getOrSetSfTraceId(e, t = !1) {
210
212
  let r = this.getTraceId();
211
- return r || (r = e || (t ? h() : `nonsession-applogs-v3/${v().apiKey}/${h()}`), this.setTraceId(r), v().sfDebug && console.log(" Created new trace ID:", r), r);
213
+ return r || (r = e || (t ? I() : `nonsession-applogs-v3/${h().apiKey}/${I()}`), this.setTraceId(r), h().sfDebug && console.log(" Created new trace ID:", r), r);
212
214
  }
213
215
  getOrSetPageVisitUUID() {
214
216
  let e = this.getPageVisitUUID();
215
- return e || (e = h(), this.setPageVisitUUID(e), v().sfDebug && console.log(" Created new page visit UUID:", e), e);
217
+ return e || (e = I(), this.setPageVisitUUID(e), h().sfDebug && console.log(" Created new page visit UUID:", e), e);
216
218
  }
217
219
  getHandledExceptions() {
218
220
  return this.getCurrentContext().handledExceptions;
@@ -244,24 +246,24 @@ const O = Symbol.for("sf.ctx.storeAls"), c = globalThis, C = c[O] ?? (c[O] = new
244
246
  }
245
247
  };
246
248
  s(u, "GLOBAL_MANAGER_SYMBOL", Symbol.for("sf.ctx.manager"));
247
- let I = u;
248
- function k(n) {
249
- const e = { ...I.getInstance().getCurrentContext() };
250
- E.run(e, () => {
249
+ let _ = u;
250
+ function K(n) {
251
+ const e = { ..._.getInstance().getCurrentContext() };
252
+ g.run(e, () => {
251
253
  n();
252
254
  });
253
255
  }
254
- function K() {
255
- return I.getInstance().getCurrentFunctionSpanId();
256
+ function k() {
257
+ return _.getInstance().getCurrentFunctionSpanId();
256
258
  }
257
259
  export {
258
- I as C,
259
- M as D,
260
- y as a,
261
- K as b,
260
+ _ as C,
261
+ G as D,
262
+ m as a,
263
+ k as b,
262
264
  W as c,
263
- B as d,
264
- v as g,
265
- k as r,
266
- h as v
265
+ w as d,
266
+ h as g,
267
+ K as r,
268
+ I as v
267
269
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("fs"),r=require("../funcSpanTransformer-D0W2t41q.cjs"),c=require("../runtimeConfig-paQOMT6f.cjs");function l(o={}){try{if(c.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Esbuild Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-esbuild-disabled",setup(){}}}catch{}const{enabled:a=!0,includeNodeModules:i=[],debug:t=!1}=o;return{name:"sailfish-funcspan-esbuild",setup(u){a&&(u.onLoad({filter:/\.(js|ts|jsx|tsx)$/},async e=>{if(e.path.includes("node_modules")&&!i.some(n=>e.path.includes(`node_modules/${n}`))||e.path.includes("@sailfish-ai/sf-veritas")||e.path.includes("jsts-backend/dist"))return null;try{const n=d.readFileSync(e.path,"utf-8"),s=await r.transformFunctionSpans(n,e.path,{projectRoot:process.cwd(),includeNodeModules:i,debug:t});if(s.modified)return{contents:s.code,loader:e.path.endsWith(".ts")||e.path.endsWith(".tsx")?"ts":"js"}}catch(n){t&&console.error(`[FuncSpan Esbuild] Error transforming ${e.path}:`,n)}return null}),t&&console.log("[FuncSpan Esbuild] Plugin initialized"))}}}exports.default=l,exports.funcspanEsbuildPlugin=l;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("fs"),r=require("../funcSpanTransformer-D0W2t41q.cjs"),c=require("../runtimeConfig-DmD4lUhG.cjs");function l(o={}){try{if(c.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Esbuild Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-esbuild-disabled",setup(){}}}catch{}const{enabled:a=!0,includeNodeModules:i=[],debug:t=!1}=o;return{name:"sailfish-funcspan-esbuild",setup(u){a&&(u.onLoad({filter:/\.(js|ts|jsx|tsx)$/},async e=>{if(e.path.includes("node_modules")&&!i.some(n=>e.path.includes(`node_modules/${n}`))||e.path.includes("@sailfish-ai/sf-veritas")||e.path.includes("jsts-backend/dist"))return null;try{const n=d.readFileSync(e.path,"utf-8"),s=await r.transformFunctionSpans(n,e.path,{projectRoot:process.cwd(),includeNodeModules:i,debug:t});if(s.modified)return{contents:s.code,loader:e.path.endsWith(".ts")||e.path.endsWith(".tsx")?"ts":"js"}}catch(n){t&&console.error(`[FuncSpan Esbuild] Error transforming ${e.path}:`,n)}return null}),t&&console.log("[FuncSpan Esbuild] Plugin initialized"))}}}exports.default=l,exports.funcspanEsbuildPlugin=l;
@@ -1,6 +1,6 @@
1
1
  import { readFileSync as l } from "fs";
2
2
  import { t as d } from "../funcSpanTransformer-S_WeAt_m.js";
3
- import { s as r } from "../runtimeConfig--MlBo3_L.js";
3
+ import { s as r } from "../runtimeConfig-Bfqf33tO.js";
4
4
  function h(o = {}) {
5
5
  try {
6
6
  if (r()) return console.warn("[FuncSpan Esbuild Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-esbuild-disabled", setup() {
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../funcSpanTransformer-D0W2t41q.cjs"),a=require("../runtimeConfig-paQOMT6f.cjs");function s(o={}){try{if(a.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Rollup Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-rollup-disabled"}}catch{}const{enabled:t=!0,includeNodeModules:l=[],debug:u=!1}=o;return{name:"sailfish-funcspan-rollup",async transform(r,e){if(!t||!e.match(/\.(js|ts|jsx|tsx)$/)||e.includes("node_modules")&&!l.some(n=>e.includes(`node_modules/${n}`))||e.includes("@sailfish-ai/sf-veritas")||e.includes("jsts-backend/dist"))return null;try{const n=await i.transformFunctionSpans(r,e,{projectRoot:process.cwd(),includeNodeModules:l,debug:u});if(n.modified)return{code:n.code,map:n.map||null}}catch(n){u&&console.error(`[FuncSpan Rollup] Error transforming ${e}:`,n)}return null}}}exports.default=s,exports.funcspanRollupPlugin=s;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../funcSpanTransformer-D0W2t41q.cjs"),a=require("../runtimeConfig-DmD4lUhG.cjs");function s(o={}){try{if(a.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Rollup Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-rollup-disabled"}}catch{}const{enabled:t=!0,includeNodeModules:l=[],debug:u=!1}=o;return{name:"sailfish-funcspan-rollup",async transform(r,e){if(!t||!e.match(/\.(js|ts|jsx|tsx)$/)||e.includes("node_modules")&&!l.some(n=>e.includes(`node_modules/${n}`))||e.includes("@sailfish-ai/sf-veritas")||e.includes("jsts-backend/dist"))return null;try{const n=await i.transformFunctionSpans(r,e,{projectRoot:process.cwd(),includeNodeModules:l,debug:u});if(n.modified)return{code:n.code,map:n.map||null}}catch(n){u&&console.error(`[FuncSpan Rollup] Error transforming ${e}:`,n)}return null}}}exports.default=s,exports.funcspanRollupPlugin=s;
@@ -1,5 +1,5 @@
1
1
  import { t as i } from "../funcSpanTransformer-S_WeAt_m.js";
2
- import { s as r } from "../runtimeConfig--MlBo3_L.js";
2
+ import { s as r } from "../runtimeConfig-Bfqf33tO.js";
3
3
  function c(o = {}) {
4
4
  try {
5
5
  if (r()) return console.warn("[FuncSpan Rollup Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-rollup-disabled" };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("fs"),_=require("glob"),N=require("path"),m=require("../funcSpanTransformer-D0W2t41q.cjs"),T=require("../runtimeConfig-paQOMT6f.cjs");async function S(n={}){try{if(T.shouldEnableRuntimeHooks())return void console.warn("[FuncSpan TSC Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation")}catch{}const{outDir:f="dist",include:F=["**/*.js"],exclude:g=["**/*.test.js","**/*.spec.js","**/__tests__/**"],projectRoot:c=process.cwd(),includeNodeModules:C=[],debug:s=!1}=n,u=N.resolve(c,f);console.log("[FuncSpan TSC] Starting post-build function instrumentation..."),console.log(`[FuncSpan TSC] Output directory: ${u}`),console.log(`[FuncSpan TSC] Project root: ${c}`);const r=[];for(const e of F){const t=_.sync(e,{cwd:u,absolute:!0,ignore:g});r.push(...t)}console.log(`[FuncSpan TSC] Found ${r.length} JavaScript files to process`);let l=0,a=0;for(const e of r)try{const t=i.readFileSync(e,"utf-8"),o=await m.transformFunctionSpans(t,e,{projectRoot:c,includeNodeModules:C,debug:s});if(o.modified){if(i.writeFileSync(e,o.code,"utf-8"),o.map){const p=`${e}.map`;i.writeFileSync(p,JSON.stringify(o.map),"utf-8"),s&&console.log(`[FuncSpan TSC] Generated source map: ${p}`)}l++,a+=o.functionsWrapped,s&&console.log(`[FuncSpan TSC] Modified: ${e} (${o.functionsWrapped} functions)`)}}catch(t){console.error(`[FuncSpan TSC] Error processing ${e}:`,t)}console.log(`[FuncSpan TSC] ✅ Completed: Modified ${l} files, wrapped ${a} functions`)}async function d(){const n={outDir:process.env.SF_FUNCSPAN_OUT_DIR||"dist",debug:process.env.SF_FUNCSPAN_DEBUG==="true",includeNodeModules:process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES?process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES.split(","):[]};await S(n)}require.main===module&&d().catch(n=>{console.error("[FuncSpan TSC] Fatal error:",n),process.exit(1)}),exports.cli=d,exports.processTscFiles=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("fs"),_=require("glob"),N=require("path"),m=require("../funcSpanTransformer-D0W2t41q.cjs"),T=require("../runtimeConfig-DmD4lUhG.cjs");async function S(n={}){try{if(T.shouldEnableRuntimeHooks())return void console.warn("[FuncSpan TSC Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation")}catch{}const{outDir:f="dist",include:F=["**/*.js"],exclude:g=["**/*.test.js","**/*.spec.js","**/__tests__/**"],projectRoot:c=process.cwd(),includeNodeModules:C=[],debug:s=!1}=n,u=N.resolve(c,f);console.log("[FuncSpan TSC] Starting post-build function instrumentation..."),console.log(`[FuncSpan TSC] Output directory: ${u}`),console.log(`[FuncSpan TSC] Project root: ${c}`);const r=[];for(const e of F){const t=_.sync(e,{cwd:u,absolute:!0,ignore:g});r.push(...t)}console.log(`[FuncSpan TSC] Found ${r.length} JavaScript files to process`);let l=0,a=0;for(const e of r)try{const t=i.readFileSync(e,"utf-8"),o=await m.transformFunctionSpans(t,e,{projectRoot:c,includeNodeModules:C,debug:s});if(o.modified){if(i.writeFileSync(e,o.code,"utf-8"),o.map){const p=`${e}.map`;i.writeFileSync(p,JSON.stringify(o.map),"utf-8"),s&&console.log(`[FuncSpan TSC] Generated source map: ${p}`)}l++,a+=o.functionsWrapped,s&&console.log(`[FuncSpan TSC] Modified: ${e} (${o.functionsWrapped} functions)`)}}catch(t){console.error(`[FuncSpan TSC] Error processing ${e}:`,t)}console.log(`[FuncSpan TSC] ✅ Completed: Modified ${l} files, wrapped ${a} functions`)}async function d(){const n={outDir:process.env.SF_FUNCSPAN_OUT_DIR||"dist",debug:process.env.SF_FUNCSPAN_DEBUG==="true",includeNodeModules:process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES?process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES.split(","):[]};await S(n)}require.main===module&&d().catch(n=>{console.error("[FuncSpan TSC] Fatal error:",n),process.exit(1)}),exports.cli=d,exports.processTscFiles=S;
@@ -2,7 +2,7 @@ import { readFileSync as m, writeFileSync as l } from "fs";
2
2
  import { sync as g } from "glob";
3
3
  import { resolve as C } from "path";
4
4
  import { t as _ } from "../funcSpanTransformer-S_WeAt_m.js";
5
- import { s as N } from "../runtimeConfig--MlBo3_L.js";
5
+ import { s as N } from "../runtimeConfig-Bfqf33tO.js";
6
6
  async function D(n = {}) {
7
7
  try {
8
8
  if (N()) return void console.warn("[FuncSpan TSC Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation");
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../funcSpanTransformer-D0W2t41q.cjs"),l=require("../runtimeConfig-paQOMT6f.cjs");exports.funcspanVitePlugin=function(s={}){try{if(l.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Vite Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-vite-disabled"}}catch{}const{enabled:o=!0,includeNodeModules:t=[],debug:i=!1}=s;return{name:"sailfish-funcspan-vite",enforce:"pre",async transform(u,e){if(!o||!e.match(/\.(js|ts|jsx|tsx)$/)||e.startsWith("\0")||e.includes("node_modules")&&!t.some(n=>e.includes(`node_modules/${n}`))||e.includes("@sailfish-ai/sf-veritas")||e.includes("jsts-backend/dist"))return null;try{const n=await r.transformFunctionSpans(u,e,{projectRoot:process.cwd(),includeNodeModules:t,debug:i});if(n.modified)return{code:n.code,map:null}}catch(n){i&&console.error(`[FuncSpan Vite] Error transforming ${e}:`,n)}return null}}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../funcSpanTransformer-D0W2t41q.cjs"),l=require("../runtimeConfig-DmD4lUhG.cjs");exports.funcspanVitePlugin=function(s={}){try{if(l.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Vite Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-vite-disabled"}}catch{}const{enabled:o=!0,includeNodeModules:t=[],debug:i=!1}=s;return{name:"sailfish-funcspan-vite",enforce:"pre",async transform(u,e){if(!o||!e.match(/\.(js|ts|jsx|tsx)$/)||e.startsWith("\0")||e.includes("node_modules")&&!t.some(n=>e.includes(`node_modules/${n}`))||e.includes("@sailfish-ai/sf-veritas")||e.includes("jsts-backend/dist"))return null;try{const n=await r.transformFunctionSpans(u,e,{projectRoot:process.cwd(),includeNodeModules:t,debug:i});if(n.modified)return{code:n.code,map:null}}catch(n){i&&console.error(`[FuncSpan Vite] Error transforming ${e}:`,n)}return null}}};
@@ -1,5 +1,5 @@
1
1
  import { t as o } from "../funcSpanTransformer-S_WeAt_m.js";
2
- import { s as l } from "../runtimeConfig--MlBo3_L.js";
2
+ import { s as l } from "../runtimeConfig-Bfqf33tO.js";
3
3
  function d(u = {}) {
4
4
  try {
5
5
  if (l()) return console.warn("[FuncSpan Vite Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-vite-disabled" };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("../runtimeConfig-paQOMT6f.cjs"),a=require("path"),P=require("url");function m(r){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const n in r)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(o,n,t.get?t:{enumerable:!0,get:()=>r[n]})}}return o.default=r,Object.freeze(o)}const f=m(a);class u{options;constructor(o={}){this.options={enabled:!0,includeNodeModules:[],debug:!1,enableWorkerPoolTracking:!1,workerPoolTrackDns:!1,workerPoolTrackFs:!1,workerPoolTrackCrypto:!1,workerPoolTrackZlib:!1,...o}}apply(o){try{if(b.shouldEnableRuntimeHooks())return void console.warn("[FuncSpan Webpack Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation")}catch{}const{enabled:n,includeNodeModules:t,debug:c}=this.options;if(!n)return;const l="FuncspanWebpackPlugin";o.hooks.compilation.tap(l,s=>{s.hooks.buildModule.tap(l,i=>{i.resource&&i.resource.match(/\.(js|ts|jsx|tsx)$/)&&(!i.resource.includes("node_modules")||t?.some(e=>i.resource.includes(`node_modules/${e}`)))}),o.webpack.NormalModule.getCompilationHooks(s).loader.tap(l,(i,e)=>{if(!e.resource||!e.resource.match(/\.(js|ts|jsx|tsx)$/)||e.resource.includes("node_modules")&&!t?.some(p=>e.resource.includes(`node_modules/${p}`)))return;const d=typeof __dirname<"u"?__dirname:a.dirname(P.fileURLToPath(require("node:url").pathToFileURL(__filename).href)),k=f.join(d,"funcspanWebpackLoader.cjs");e.loaders.push({loader:k,options:{projectRoot:o.context,includeNodeModules:t,debug:c,enableWorkerPoolTracking:this.options.enableWorkerPoolTracking,workerPoolTrackDns:this.options.workerPoolTrackDns,workerPoolTrackFs:this.options.workerPoolTrackFs,workerPoolTrackCrypto:this.options.workerPoolTrackCrypto,workerPoolTrackZlib:this.options.workerPoolTrackZlib}})})}),c&&console.log("[FuncSpan Webpack] Plugin initialized")}}exports.FuncspanWebpackPlugin=u,exports.default=u;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("../runtimeConfig-DmD4lUhG.cjs"),a=require("path"),P=require("url");function m(r){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const n in r)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(o,n,t.get?t:{enumerable:!0,get:()=>r[n]})}}return o.default=r,Object.freeze(o)}const f=m(a);class u{options;constructor(o={}){this.options={enabled:!0,includeNodeModules:[],debug:!1,enableWorkerPoolTracking:!1,workerPoolTrackDns:!1,workerPoolTrackFs:!1,workerPoolTrackCrypto:!1,workerPoolTrackZlib:!1,...o}}apply(o){try{if(b.shouldEnableRuntimeHooks())return void console.warn("[FuncSpan Webpack Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation")}catch{}const{enabled:n,includeNodeModules:t,debug:c}=this.options;if(!n)return;const l="FuncspanWebpackPlugin";o.hooks.compilation.tap(l,s=>{s.hooks.buildModule.tap(l,i=>{i.resource&&i.resource.match(/\.(js|ts|jsx|tsx)$/)&&(!i.resource.includes("node_modules")||t?.some(e=>i.resource.includes(`node_modules/${e}`)))}),o.webpack.NormalModule.getCompilationHooks(s).loader.tap(l,(i,e)=>{if(!e.resource||!e.resource.match(/\.(js|ts|jsx|tsx)$/)||e.resource.includes("node_modules")&&!t?.some(p=>e.resource.includes(`node_modules/${p}`)))return;const d=typeof __dirname<"u"?__dirname:a.dirname(P.fileURLToPath(require("node:url").pathToFileURL(__filename).href)),k=f.join(d,"funcspanWebpackLoader.cjs");e.loaders.push({loader:k,options:{projectRoot:o.context,includeNodeModules:t,debug:c,enableWorkerPoolTracking:this.options.enableWorkerPoolTracking,workerPoolTrackDns:this.options.workerPoolTrackDns,workerPoolTrackFs:this.options.workerPoolTrackFs,workerPoolTrackCrypto:this.options.workerPoolTrackCrypto,workerPoolTrackZlib:this.options.workerPoolTrackZlib}})})}),c&&console.log("[FuncSpan Webpack] Plugin initialized")}}exports.FuncspanWebpackPlugin=u,exports.default=u;
@@ -1,7 +1,7 @@
1
1
  var k = Object.defineProperty;
2
2
  var m = (r, o, s) => o in r ? k(r, o, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[o] = s;
3
3
  var c = (r, o, s) => m(r, typeof o != "symbol" ? o + "" : o, s);
4
- import { s as b } from "../runtimeConfig--MlBo3_L.js";
4
+ import { s as b } from "../runtimeConfig-Bfqf33tO.js";
5
5
  import * as P from "path";
6
6
  import { dirname as T } from "path";
7
7
  import { fileURLToPath as f } from "url";
@@ -5,7 +5,7 @@ import * as oI from "fs/promises";
5
5
  import sI from "os";
6
6
  import { s as AI } from "./source-map-Cr6YkjTd.js";
7
7
  import { Worker as rI } from "worker_threads";
8
- import { g as m, a as bI, C as D } from "./contextManager-C-sqFxpi.js";
8
+ import { g as m, a as bI, C as D } from "./contextManager-Dw7Yot7r.js";
9
9
  import { resolve as uI } from "path";
10
10
  function x(I) {
11
11
  return typeof I == "string" ? I : I == null ? "" : Array.isArray(I) ? I.map((g) => String(g)).join(`
@@ -1,4 +1,4 @@
1
- "use strict";const on=require("fs/promises"),sn=require("os"),An=require("./source-map-rHHEdpre.cjs"),rn=require("worker_threads"),a=require("./contextManager-wMuxqwl9.cjs"),bn=require("path");function un(n){const I=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const g in n)if(g!=="default"){const e=Object.getOwnPropertyDescriptor(n,g);Object.defineProperty(I,g,e.get?e:{enumerable:!0,get:()=>n[g]})}}return I.default=n,Object.freeze(I)}const an=un(on);function k(n){return typeof n=="string"?n:n==null?"":Array.isArray(n)?n.map(I=>String(I)).join(`
1
+ "use strict";const on=require("fs/promises"),sn=require("os"),An=require("./source-map-rHHEdpre.cjs"),rn=require("worker_threads"),a=require("./contextManager-DQMeQfS_.cjs"),bn=require("path");function un(n){const I=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const g in n)if(g!=="default"){const e=Object.getOwnPropertyDescriptor(n,g);Object.defineProperty(I,g,e.get?e:{enumerable:!0,get:()=>n[g]})}}return I.default=n,Object.freeze(I)}const an=un(on);function k(n){return typeof n=="string"?n:n==null?"":Array.isArray(n)?n.map(I=>String(I)).join(`
2
2
  `):String(n)}function dn(n){try{return JSON.stringify(n),!0}catch{return!1}}const nn={};class v{file;line;function;code;locals;offender;column;constructor({file:I,line:g,function:e,code:C,locals:t={},offender:l=!1,column:s}){this.file=I,this.line=g,this.function=e,this.code=C,this.locals=t,this.offender=l,this.column=s}toDict(){const I={file:this.file,line:this.line,function:this.function,code:this.code,locals:Object.fromEntries(Object.entries(this.locals).map(([g,e])=>[g,String(e)]))};return this.offender&&(I.offender=this.offender),this.column!==void 0&&(I.column=this.column),I}toJson(){return JSON.stringify(this.toDict())}}class L{static encode(I){return I instanceof v?I.toDict():Array.isArray(I)?I.map(g=>L.encode(g)):typeof I=="object"&&I!==null?JSON.stringify(I):I}static stringify(I){return JSON.stringify(L.encode(I),(g,e)=>e instanceof v?e.toDict():e)}}const mn=["/sf-veritas/","/@sailfish-ai/","/node_modules/","/dist/","/<","/internal/","node:"],N=new Map;function Zn(n){return mn.some(I=>n.includes(I))}function fn(n){let I=n;I.startsWith("file://")&&(I=I.substring(7)),process.platform==="win32"&&I.startsWith("/")&&I.length>2&&I[2]===":"&&(I=I.substring(1));try{return bn.resolve(I)}catch{return n}}function Wn(n=0){const I=new Error().stack;if(!I)return[null,null];const g=k(I),e=(function(c,i){const A=2+i;return c.split(`
3
3
  `).slice(A,A+5).join(`
4
4
  `)})(g,n),C=N.get(e);if(C)return C;const t=(function(c){if(!c)return[];const i=c.split(`
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./contextManager-wMuxqwl9.cjs"),u=require("./workerPoolSpanCapture-B3yge78T.cjs"),g=require("./runtimeConfig-paQOMT6f.cjs"),ae=require("node:module"),H=require("fs"),ce=require("./source-map-rHHEdpre.cjs"),de=require("fs/promises"),le=require("path"),ue=require("glob"),E=require("worker_threads"),O=require("./funcSpanTransformer-D0W2t41q.cjs");function x(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const pe=x(H),W=x(de),F=x(le);class P extends u.BaseTransmitter{constructor(){super(),this.setOperationName("IdentifyServiceDetails")}async doSend(e){if(!c.getConfig().serviceIdentificationReceived)try{this.send()}catch(t){c.getConfig().sfDebug&&console.error(" Error during service identification:",t)}}async send(){const e=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./contextManager-DQMeQfS_.cjs"),u=require("./workerPoolSpanCapture-CAM2z9Jx.cjs"),g=require("./runtimeConfig-DmD4lUhG.cjs"),ae=require("node:module"),H=require("fs"),ce=require("./source-map-rHHEdpre.cjs"),de=require("fs/promises"),le=require("path"),ue=require("glob"),E=require("worker_threads"),O=require("./funcSpanTransformer-D0W2t41q.cjs");function x(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const pe=x(H),W=x(de),F=x(le);class P extends u.BaseTransmitter{constructor(){super(),this.setOperationName("IdentifyServiceDetails")}async doSend(e){if(!c.getConfig().serviceIdentificationReceived)try{this.send()}catch(t){c.getConfig().sfDebug&&console.error(" Error during service identification:",t)}}async send(){const e=`
2
2
  ${this.queryType} ${this.operationName}(
3
3
  $apiKey: String!,
4
4
  $timestampMs: String!,
@@ -1,12 +1,12 @@
1
1
  var he = Object.defineProperty;
2
2
  var me = (r, t, e) => t in r ? he(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
3
  var y = (r, t, e) => me(r, typeof t != "symbol" ? t + "" : t, e);
4
- import { g as u, C as j, D as ye, v as oe, b as q, c as Se, d as Ie, a as ae } from "./contextManager-C-sqFxpi.js";
5
- import { r as St } from "./contextManager-C-sqFxpi.js";
6
- import { B as T, n as P, f as ve, g as ce, p as de, a as ue, b as $e, m as U, c as A, i as Q, d as _e, e as R, t as H, F as be } from "./workerPoolSpanCapture-DqBbNQLv.js";
7
- import { h as vt, s as $t } from "./workerPoolSpanCapture-DqBbNQLv.js";
8
- import { a as Fe, C as Ne, i as _, b as De, c as le, h as w, d as we, e as Pe } from "./runtimeConfig--MlBo3_L.js";
9
- import { f as bt, g as Ft, s as Nt } from "./runtimeConfig--MlBo3_L.js";
4
+ import { g as u, C as j, D as ye, v as oe, b as q, c as Se, d as Ie, a as ae } from "./contextManager-Dw7Yot7r.js";
5
+ import { r as St } from "./contextManager-Dw7Yot7r.js";
6
+ import { B as T, n as P, f as ve, g as ce, p as de, a as ue, b as $e, m as U, c as A, i as Q, d as _e, e as R, t as H, F as be } from "./workerPoolSpanCapture-Dm4Reseo.js";
7
+ import { h as vt, s as $t } from "./workerPoolSpanCapture-Dm4Reseo.js";
8
+ import { a as Fe, C as Ne, i as _, b as De, c as le, h as w, d as we, e as Pe } from "./runtimeConfig-Bfqf33tO.js";
9
+ import { f as bt, g as Ft, s as Nt } from "./runtimeConfig-Bfqf33tO.js";
10
10
  import { createRequire as Ee } from "node:module";
11
11
  import * as Te from "fs";
12
12
  import { readFileSync as Ce, appendFileSync as Ue } from "fs";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./workerPoolSpanCapture-B3yge78T.cjs");exports.captureWorkerPoolOperation=e.captureWorkerPoolOperation;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./workerPoolSpanCapture-CAM2z9Jx.cjs");exports.captureWorkerPoolOperation=e.captureWorkerPoolOperation;
@@ -1,4 +1,4 @@
1
- import { c as e } from "./workerPoolSpanCapture-DqBbNQLv.js";
1
+ import { c as e } from "./workerPoolSpanCapture-Dm4Reseo.js";
2
2
  export {
3
3
  e as captureWorkerPoolOperation
4
4
  };
@@ -1,4 +1,4 @@
1
- "use strict";const w=require("async_hooks"),B=require("fs"),v=require("worker_threads"),l=require("./contextManager-wMuxqwl9.cjs");class M{apiKey;endpoint;queryType="mutation";operationName="";serviceUUID=l.getConfig().serviceUUID;contextManager;constructor(){this.apiKey=l.getConfig().apiKey,this.endpoint=l.getConfig().apiGraphqlEndpoint,this.contextManager=l.ContextManager.getInstance()}get queryName(){return this.operationName?this.operationName.charAt(0).toLowerCase()+this.operationName.slice(1):""}getDefaultVariables(){const t=Date.now().toString(),o=this.contextManager.getOrSetSfTraceId(),s=this.contextManager.getCurrentFunctionSpanId();return{apiKey:this.apiKey,serviceUuid:this.serviceUUID,sessionId:o,timestampMs:t,parentSpanId:s}}getVariables(t={}){return{...this.getDefaultVariables(),...t}}setOperationName(t){this.operationName=t}setEndpoint(t){this.endpoint=t}setServiceUUID(t){this.serviceUUID=t}}const K=fetch;let _=!1;async function P(n,t,o,s){try{const a=l.getConfig();let i;try{i=JSON.stringify({query:o,variables:s,operationName:t})}catch{i=JSON.stringify({query:o,operationName:t})}_=!0,K(n,{method:"POST",headers:{"Content-Type":"application/json"},body:i}).then(async e=>{if(_=!1,!e.ok)return void(a.sfDebug&&console.error(`GraphQL request failed with status ${e.status} for ${t}`));const r=await e.json();r.errors?.length?(function(u,g,c){const d=u&&typeof u=="object"&&!Array.isArray(u)?Object.keys(u)[0]:void 0;console.error(d==="identifyServiceDetails"?`IdentifyServiceDetails NOT sent successfully for service: UUID=${c.serviceUUID}`:`GraphQL request failed with errors: ${JSON.stringify(g)} for operation key ${d}`)})(r.data,r.errors,a):a.sfDebug&&(function(u,g,c){const d=u&&typeof u=="object"&&!Array.isArray(u)?Object.keys(u)[0]:void 0,p=u[d]||!1;d==="identifyServiceDetails"&&(c.setServiceIdentificationReceived(p),l.getConfig().sfDebug&&console.log(`IdentifyServiceDetails sent successfully for service: UUID=${c.serviceUUID}; serviceIdentificationReceived=${d==="identifyServiceDetails"?p:"N/A"}`))})(r.data,0,a)}).catch(e=>{_=!1,a.sfDebug&&(console.error(`[RequestUtils] Fetch error for ${t} to ${n}:`,e),e.cause&&console.error("[RequestUtils] Error cause:",e.cause))})}catch(a){_=!1,l.getConfig().sfDebug&&console.error("Error sending data to GraphQL server:",a)}}function N(n,t){if(!n)return t;const o=n.toLowerCase();return o==="true"||o==="1"||o==="yes"}const O="__sf_funcspanOverrideStorage";globalThis[O]||(globalThis[O]=new w.AsyncLocalStorage);const I=globalThis[O];function C(n,t){try{const o=JSON.stringify(n).length/1048576;return o<=t?n:{_truncated:!0,_originalSizeMB:o.toFixed(2),_limitMB:t,_preview:JSON.stringify(n).substring(0,500)+"..."}}catch{return{_error:"Failed to serialize data",_type:typeof n}}}function S(n,t){const o=process.env[n];return o===void 0?t:o==="true"||o==="1"}function E(n,t){const o=process.env[n];if(o===void 0)return t;const s=parseFloat(o);return isNaN(s)?t:s}function T(){return{enabled:S("SF_WORKER_POOL_ENABLED",!0),trackFs:S("SF_WORKER_POOL_TRACK_FS",!1),trackDns:S("SF_WORKER_POOL_TRACK_DNS",!1),trackCrypto:S("SF_WORKER_POOL_TRACK_CRYPTO",!1),trackZlib:S("SF_WORKER_POOL_TRACK_ZLIB",!1),captureArguments:S("SF_WORKER_POOL_CAPTURE_ARGUMENTS",!0),captureReturnValue:S("SF_WORKER_POOL_CAPTURE_RETURN_VALUE",!0),argLimitMb:E("SF_WORKER_POOL_ARG_LIMIT_MB",1),returnLimitMb:E("SF_WORKER_POOL_RETURN_LIMIT_MB",1)}}function D(n,t,o,s){let a;try{switch(n){case"fs":a=(function(i,e){const r={};switch(i){case"readFile":case"writeFile":case"appendFile":r.path=String(e[0]||""),e[1]&&typeof e[1]=="object"?(r.encoding=e[1].encoding||null,r.flag=e[1].flag||null):typeof e[1]=="string"&&(r.encoding=e[1]),i!=="writeFile"&&i!=="appendFile"||(Buffer.isBuffer(e[1])?(r.dataType="Buffer",r.dataSize=e[1].length):typeof e[1]=="string"&&(r.dataType="string",r.dataSize=e[1].length));break;case"readdir":case"stat":case"lstat":case"access":case"chmod":case"mkdir":case"rmdir":case"unlink":r.path=String(e[0]||""),e[1]&&typeof e[1]=="object"&&(r.options={...e[1]},delete r.options.callback);break;case"rename":r.oldPath=String(e[0]||""),r.newPath=String(e[1]||"");break;case"open":r.path=String(e[0]||""),r.flags=e[1],r.mode=e[2];break;case"close":case"fstat":r.fd=e[0];break;case"read":case"write":r.fd=e[0],Buffer.isBuffer(e[1])&&(r.bufferSize=e[1].length),r.offset=e[2],r.length=e[3],r.position=e[4];break;default:r.argsCount=e.length-1}return r})(t,o);break;case"dns":a=(function(i,e){const r={};switch(i){case"lookup":r.hostname=String(e[0]||""),typeof e[1]=="object"?(r.family=e[1].family,r.all=e[1].all):typeof e[1]=="number"&&(r.family=e[1]);break;case"resolve":case"resolve4":case"resolve6":case"resolveAny":case"resolveMx":case"resolveNs":case"resolveTxt":r.hostname=String(e[0]||"");break;case"reverse":r.ip=String(e[0]||"");break;default:r.argsCount=e.length-1}return r})(t,o);break;case"crypto":a=(function(i,e){const r={};switch(i){case"pbkdf2":r.passwordType=typeof e[0],r.saltType=typeof e[1],r.iterations=e[2],r.keylen=e[3],r.digest=e[4];break;case"scrypt":r.passwordType=typeof e[0],r.saltType=typeof e[1],r.keylen=e[2],typeof e[3]=="object"&&(r.N=e[3].N,r.r=e[3].r,r.p=e[3].p);break;case"randomBytes":r.size=e[0];break;case"generateKeyPair":r.type=e[0],typeof e[1]=="object"&&(r.modulusLength=e[1].modulusLength,r.namedCurve=e[1].namedCurve);break;default:r.argsCount=e.length-1}return r})(t,o);break;case"zlib":a=(function(i,e){const r={};return Buffer.isBuffer(e[0])?(r.inputType="Buffer",r.inputSize=e[0].length):typeof e[0]=="string"?(r.inputType="string",r.inputSize=e[0].length):r.inputType=typeof e[0],e[1]&&typeof e[1]=="object"&&typeof e[1]!="function"&&(r.options={...e[1]}),r})(0,o);break;default:return null}return s>0?C(a,s):a}catch{return{error:"Failed to capture arguments",argsCount:o.length-1}}}function L(n,t,o,s){let a;try{switch(n){case"fs":a=(function(i,e){if(!e)return null;switch(i){case"readFile":return Buffer.isBuffer(e)?{type:"Buffer",size:e.length}:typeof e=="string"?{type:"string",size:e.length}:{type:typeof e};case"readdir":return{count:Array.isArray(e)?e.length:0,items:e};case"stat":case"lstat":case"fstat":return{size:e.size,mode:e.mode,isFile:e.isFile(),isDirectory:e.isDirectory()};case"open":return{fd:e};case"read":return{bytesRead:e};case"write":return{bytesWritten:e};default:return e}})(t,o);break;case"dns":a=(function(i,e){if(!e)return null;switch(i){case"lookup":return Array.isArray(e)?{count:e.length,addresses:e}:e;case"resolve":case"resolve4":case"resolve6":case"resolveAny":case"resolveMx":case"resolveNs":case"resolveTxt":return{count:Array.isArray(e)?e.length:0,records:e};case"reverse":return{hostnames:e};default:return e}})(t,o);break;case"crypto":a=(function(i,e){if(!e)return null;switch(i){case"pbkdf2":case"scrypt":case"randomBytes":return Buffer.isBuffer(e)?{type:"Buffer",size:e.length}:{type:typeof e};case"generateKeyPair":return{hasPublicKey:!!e?.publicKey,hasPrivateKey:!!e?.privateKey};default:return e}})(t,o);break;case"zlib":a=(function(i,e){return e?Buffer.isBuffer(e)?{type:"Buffer",size:e.length}:typeof e=="string"?{type:"string",size:e.length}:{type:typeof e}:null})(0,o);break;default:return null}return s>0?C(a,s):a}catch{return{error:"Failed to capture result",type:typeof o}}}function V(n){return n.operationType==="worker_pool"}class W extends M{constructor(){super(),this.operationName="CollectFunctionSpans"}send(t){const o=l.getConfig().sfDebug;o&&console.log(`[FunctionSpanTransmitter] Preparing to send ${t.length} function span(s)`);for(const s of t)try{if(V(s)){this.sendWorkerPoolSpan(s,o);continue}const a=s;let i;if(a.result!==void 0&&a.result!==null){const r=typeof a.result;i=JSON.stringify({type:r,has_value:!0,value:a.result})}else i=a.result===null?JSON.stringify({type:"null",has_value:!0,value:null}):JSON.stringify({type:"undefined",has_value:!1,value:null});const e=this.getVariables({library:"JS/TS BACKEND",version:l.getConfig().version,spanId:a.spanId,parentSpanId:a.parentSpanId,filePath:a.filePath,lineNumber:a.metadata.line,columnNumber:a.metadata.column,functionName:a.functionName,arguments:JSON.stringify(a.args||{}),returnValue:i,startTimeNs:(1e6*Date.now()-1e6*a.duration).toString(),durationNs:(1e6*a.duration).toString()});o&&(console.log(`[FunctionSpanTransmitter] Sending GraphQL mutation to ${this.endpoint}`),console.log("[FunctionSpanTransmitter] Variables:",JSON.stringify(e,null,2))),P(this.endpoint,this.operationName,this.getQuery(),e),o&&console.log(`[FunctionSpanTransmitter] Queued function span for ${a.functionName}`)}catch(a){console.error(`[FunctionSpanTransmitter] Error preparing function span for ${s.functionName}:`,a)}}sendWorkerPoolSpan(t,o){try{let s;if(t.result!==void 0&&t.result!==null){const i=typeof t.result;s=JSON.stringify({type:i,has_value:!0,value:t.result})}else s=t.result===null?JSON.stringify({type:"null",has_value:!0,value:null}):JSON.stringify({type:"undefined",has_value:!1,value:null});const a=this.getVariables({library:"JS/TS BACKEND",version:l.getConfig().version,spanId:t.spanId,operationName:t.operationName,moduleName:t.moduleName,methodName:t.methodName,startTimeNs:t.startTimeNs,durationNs:t.durationNs,arguments:JSON.stringify(t.args||{}),returnValue:s,error:t.error,pid:t.pid,threadId:t.threadId});o&&(console.log(`[FunctionSpanTransmitter] Sending worker pool span: ${t.operationName}`),console.log("[FunctionSpanTransmitter] Variables:",JSON.stringify(a,null,2))),P(this.endpoint,"CollectWorkerPoolSpans",this.getWorkerPoolQuery(),a),o&&console.log(`[FunctionSpanTransmitter] Queued worker pool span for ${t.operationName}`)}catch(s){console.error(`[FunctionSpanTransmitter] Error preparing worker pool span for ${t.operationName}:`,s)}}getWorkerPoolQuery(){return`
1
+ "use strict";const w=require("async_hooks"),B=require("fs"),v=require("worker_threads"),l=require("./contextManager-DQMeQfS_.cjs");class M{apiKey;endpoint;queryType="mutation";operationName="";serviceUUID=l.getConfig().serviceUUID;contextManager;constructor(){this.apiKey=l.getConfig().apiKey,this.endpoint=l.getConfig().apiGraphqlEndpoint,this.contextManager=l.ContextManager.getInstance()}get queryName(){return this.operationName?this.operationName.charAt(0).toLowerCase()+this.operationName.slice(1):""}getDefaultVariables(){const t=Date.now().toString(),o=this.contextManager.getOrSetSfTraceId(),s=this.contextManager.getCurrentFunctionSpanId();return{apiKey:this.apiKey,serviceUuid:this.serviceUUID,sessionId:o,timestampMs:t,parentSpanId:s}}getVariables(t={}){return{...this.getDefaultVariables(),...t}}setOperationName(t){this.operationName=t}setEndpoint(t){this.endpoint=t}setServiceUUID(t){this.serviceUUID=t}}const K=fetch;let _=!1;async function P(n,t,o,s){try{const a=l.getConfig();let i;try{i=JSON.stringify({query:o,variables:s,operationName:t})}catch{i=JSON.stringify({query:o,operationName:t})}_=!0,K(n,{method:"POST",headers:{"Content-Type":"application/json"},body:i}).then(async e=>{if(_=!1,!e.ok)return void(a.sfDebug&&console.error(`GraphQL request failed with status ${e.status} for ${t}`));const r=await e.json();r.errors?.length?(function(u,g,c){const d=u&&typeof u=="object"&&!Array.isArray(u)?Object.keys(u)[0]:void 0;console.error(d==="identifyServiceDetails"?`IdentifyServiceDetails NOT sent successfully for service: UUID=${c.serviceUUID}`:`GraphQL request failed with errors: ${JSON.stringify(g)} for operation key ${d}`)})(r.data,r.errors,a):a.sfDebug&&(function(u,g,c){const d=u&&typeof u=="object"&&!Array.isArray(u)?Object.keys(u)[0]:void 0,p=u[d]||!1;d==="identifyServiceDetails"&&(c.setServiceIdentificationReceived(p),l.getConfig().sfDebug&&console.log(`IdentifyServiceDetails sent successfully for service: UUID=${c.serviceUUID}; serviceIdentificationReceived=${d==="identifyServiceDetails"?p:"N/A"}`))})(r.data,0,a)}).catch(e=>{_=!1,a.sfDebug&&(console.error(`[RequestUtils] Fetch error for ${t} to ${n}:`,e),e.cause&&console.error("[RequestUtils] Error cause:",e.cause))})}catch(a){_=!1,l.getConfig().sfDebug&&console.error("Error sending data to GraphQL server:",a)}}function N(n,t){if(!n)return t;const o=n.toLowerCase();return o==="true"||o==="1"||o==="yes"}const O="__sf_funcspanOverrideStorage";globalThis[O]||(globalThis[O]=new w.AsyncLocalStorage);const I=globalThis[O];function C(n,t){try{const o=JSON.stringify(n).length/1048576;return o<=t?n:{_truncated:!0,_originalSizeMB:o.toFixed(2),_limitMB:t,_preview:JSON.stringify(n).substring(0,500)+"..."}}catch{return{_error:"Failed to serialize data",_type:typeof n}}}function S(n,t){const o=process.env[n];return o===void 0?t:o==="true"||o==="1"}function E(n,t){const o=process.env[n];if(o===void 0)return t;const s=parseFloat(o);return isNaN(s)?t:s}function T(){return{enabled:S("SF_WORKER_POOL_ENABLED",!0),trackFs:S("SF_WORKER_POOL_TRACK_FS",!1),trackDns:S("SF_WORKER_POOL_TRACK_DNS",!1),trackCrypto:S("SF_WORKER_POOL_TRACK_CRYPTO",!1),trackZlib:S("SF_WORKER_POOL_TRACK_ZLIB",!1),captureArguments:S("SF_WORKER_POOL_CAPTURE_ARGUMENTS",!0),captureReturnValue:S("SF_WORKER_POOL_CAPTURE_RETURN_VALUE",!0),argLimitMb:E("SF_WORKER_POOL_ARG_LIMIT_MB",1),returnLimitMb:E("SF_WORKER_POOL_RETURN_LIMIT_MB",1)}}function D(n,t,o,s){let a;try{switch(n){case"fs":a=(function(i,e){const r={};switch(i){case"readFile":case"writeFile":case"appendFile":r.path=String(e[0]||""),e[1]&&typeof e[1]=="object"?(r.encoding=e[1].encoding||null,r.flag=e[1].flag||null):typeof e[1]=="string"&&(r.encoding=e[1]),i!=="writeFile"&&i!=="appendFile"||(Buffer.isBuffer(e[1])?(r.dataType="Buffer",r.dataSize=e[1].length):typeof e[1]=="string"&&(r.dataType="string",r.dataSize=e[1].length));break;case"readdir":case"stat":case"lstat":case"access":case"chmod":case"mkdir":case"rmdir":case"unlink":r.path=String(e[0]||""),e[1]&&typeof e[1]=="object"&&(r.options={...e[1]},delete r.options.callback);break;case"rename":r.oldPath=String(e[0]||""),r.newPath=String(e[1]||"");break;case"open":r.path=String(e[0]||""),r.flags=e[1],r.mode=e[2];break;case"close":case"fstat":r.fd=e[0];break;case"read":case"write":r.fd=e[0],Buffer.isBuffer(e[1])&&(r.bufferSize=e[1].length),r.offset=e[2],r.length=e[3],r.position=e[4];break;default:r.argsCount=e.length-1}return r})(t,o);break;case"dns":a=(function(i,e){const r={};switch(i){case"lookup":r.hostname=String(e[0]||""),typeof e[1]=="object"?(r.family=e[1].family,r.all=e[1].all):typeof e[1]=="number"&&(r.family=e[1]);break;case"resolve":case"resolve4":case"resolve6":case"resolveAny":case"resolveMx":case"resolveNs":case"resolveTxt":r.hostname=String(e[0]||"");break;case"reverse":r.ip=String(e[0]||"");break;default:r.argsCount=e.length-1}return r})(t,o);break;case"crypto":a=(function(i,e){const r={};switch(i){case"pbkdf2":r.passwordType=typeof e[0],r.saltType=typeof e[1],r.iterations=e[2],r.keylen=e[3],r.digest=e[4];break;case"scrypt":r.passwordType=typeof e[0],r.saltType=typeof e[1],r.keylen=e[2],typeof e[3]=="object"&&(r.N=e[3].N,r.r=e[3].r,r.p=e[3].p);break;case"randomBytes":r.size=e[0];break;case"generateKeyPair":r.type=e[0],typeof e[1]=="object"&&(r.modulusLength=e[1].modulusLength,r.namedCurve=e[1].namedCurve);break;default:r.argsCount=e.length-1}return r})(t,o);break;case"zlib":a=(function(i,e){const r={};return Buffer.isBuffer(e[0])?(r.inputType="Buffer",r.inputSize=e[0].length):typeof e[0]=="string"?(r.inputType="string",r.inputSize=e[0].length):r.inputType=typeof e[0],e[1]&&typeof e[1]=="object"&&typeof e[1]!="function"&&(r.options={...e[1]}),r})(0,o);break;default:return null}return s>0?C(a,s):a}catch{return{error:"Failed to capture arguments",argsCount:o.length-1}}}function L(n,t,o,s){let a;try{switch(n){case"fs":a=(function(i,e){if(!e)return null;switch(i){case"readFile":return Buffer.isBuffer(e)?{type:"Buffer",size:e.length}:typeof e=="string"?{type:"string",size:e.length}:{type:typeof e};case"readdir":return{count:Array.isArray(e)?e.length:0,items:e};case"stat":case"lstat":case"fstat":return{size:e.size,mode:e.mode,isFile:e.isFile(),isDirectory:e.isDirectory()};case"open":return{fd:e};case"read":return{bytesRead:e};case"write":return{bytesWritten:e};default:return e}})(t,o);break;case"dns":a=(function(i,e){if(!e)return null;switch(i){case"lookup":return Array.isArray(e)?{count:e.length,addresses:e}:e;case"resolve":case"resolve4":case"resolve6":case"resolveAny":case"resolveMx":case"resolveNs":case"resolveTxt":return{count:Array.isArray(e)?e.length:0,records:e};case"reverse":return{hostnames:e};default:return e}})(t,o);break;case"crypto":a=(function(i,e){if(!e)return null;switch(i){case"pbkdf2":case"scrypt":case"randomBytes":return Buffer.isBuffer(e)?{type:"Buffer",size:e.length}:{type:typeof e};case"generateKeyPair":return{hasPublicKey:!!e?.publicKey,hasPrivateKey:!!e?.privateKey};default:return e}})(t,o);break;case"zlib":a=(function(i,e){return e?Buffer.isBuffer(e)?{type:"Buffer",size:e.length}:typeof e=="string"?{type:"string",size:e.length}:{type:typeof e}:null})(0,o);break;default:return null}return s>0?C(a,s):a}catch{return{error:"Failed to capture result",type:typeof o}}}function V(n){return n.operationType==="worker_pool"}class W extends M{constructor(){super(),this.operationName="CollectFunctionSpans"}send(t){const o=l.getConfig().sfDebug;o&&console.log(`[FunctionSpanTransmitter] Preparing to send ${t.length} function span(s)`);for(const s of t)try{if(V(s)){this.sendWorkerPoolSpan(s,o);continue}const a=s;let i;if(a.result!==void 0&&a.result!==null){const r=typeof a.result;i=JSON.stringify({type:r,has_value:!0,value:a.result})}else i=a.result===null?JSON.stringify({type:"null",has_value:!0,value:null}):JSON.stringify({type:"undefined",has_value:!1,value:null});const e=this.getVariables({library:"JS/TS BACKEND",version:l.getConfig().version,spanId:a.spanId,parentSpanId:a.parentSpanId,filePath:a.filePath,lineNumber:a.metadata.line,columnNumber:a.metadata.column,functionName:a.functionName,arguments:JSON.stringify(a.args||{}),returnValue:i,startTimeNs:(1e6*Date.now()-1e6*a.duration).toString(),durationNs:(1e6*a.duration).toString()});o&&(console.log(`[FunctionSpanTransmitter] Sending GraphQL mutation to ${this.endpoint}`),console.log("[FunctionSpanTransmitter] Variables:",JSON.stringify(e,null,2))),P(this.endpoint,this.operationName,this.getQuery(),e),o&&console.log(`[FunctionSpanTransmitter] Queued function span for ${a.functionName}`)}catch(a){console.error(`[FunctionSpanTransmitter] Error preparing function span for ${s.functionName}:`,a)}}sendWorkerPoolSpan(t,o){try{let s;if(t.result!==void 0&&t.result!==null){const i=typeof t.result;s=JSON.stringify({type:i,has_value:!0,value:t.result})}else s=t.result===null?JSON.stringify({type:"null",has_value:!0,value:null}):JSON.stringify({type:"undefined",has_value:!1,value:null});const a=this.getVariables({library:"JS/TS BACKEND",version:l.getConfig().version,spanId:t.spanId,operationName:t.operationName,moduleName:t.moduleName,methodName:t.methodName,startTimeNs:t.startTimeNs,durationNs:t.durationNs,arguments:JSON.stringify(t.args||{}),returnValue:s,error:t.error,pid:t.pid,threadId:t.threadId});o&&(console.log(`[FunctionSpanTransmitter] Sending worker pool span: ${t.operationName}`),console.log("[FunctionSpanTransmitter] Variables:",JSON.stringify(a,null,2))),P(this.endpoint,"CollectWorkerPoolSpans",this.getWorkerPoolQuery(),a),o&&console.log(`[FunctionSpanTransmitter] Queued worker pool span for ${t.operationName}`)}catch(s){console.error(`[FunctionSpanTransmitter] Error preparing worker pool span for ${t.operationName}:`,s)}}getWorkerPoolQuery(){return`
2
2
  mutation CollectWorkerPoolSpans(
3
3
  $apiKey: String!,
4
4
  $serviceUuid: String!,
@@ -4,7 +4,7 @@ var S = (n, t, a) => V(n, typeof t != "symbol" ? t + "" : t, a);
4
4
  import { AsyncLocalStorage as J, AsyncResource as z } from "async_hooks";
5
5
  import { appendFileSync as x } from "fs";
6
6
  import { threadId as T } from "worker_threads";
7
- import { g as f, C as P, v as L, a as O } from "./contextManager-C-sqFxpi.js";
7
+ import { g as f, C as P, v as L, a as O } from "./contextManager-Dw7Yot7r.js";
8
8
  class j {
9
9
  constructor() {
10
10
  S(this, "apiKey");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailfish-ai/sf-veritas",
3
- "version": "0.2.19",
3
+ "version": "0.2.20",
4
4
  "publishPublicly": true,
5
5
  "description": "A versatile Edge Runtime-compatible package for JavaScript and TypeScript backend systems and scripts.",
6
6
  "main": "./dist/sf-veritas.cjs",
@@ -1 +0,0 @@
1
- "use strict";const D=require("async_hooks"),m=require("child_process"),v=require("fs"),P=require("fs/promises"),U=require("os");function A(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const b=A(P),f=A(U),o=[];for(let n=0;n<256;++n)o.push((n+256).toString(16).slice(1));let I;const x=new Uint8Array(16),O={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function l(n,e,t){if(O.randomUUID&&!n)return O.randomUUID();const r=(n=n||{}).random??n.rng?.()??(function(){if(!I){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");I=crypto.getRandomValues.bind(crypto)}return I(x)})();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,(function(s,i=0){return(o[s[i+0]]+o[s[i+1]]+o[s[i+2]]+o[s[i+3]]+"-"+o[s[i+4]]+o[s[i+5]]+"-"+o[s[i+6]]+o[s[i+7]]+"-"+o[s[i+8]]+o[s[i+9]]+"-"+o[s[i+10]]+o[s[i+11]]+o[s[i+12]]+o[s[i+13]]+o[s[i+14]]+o[s[i+15]]).toLowerCase()})(r)}class M{apiKey;apiGraphqlEndpoint;sfDebug;serviceIdentifier;serviceVersion;serviceUUID;serviceAdditionalMetadata;profilingModeEnabled;profilingMaxDepth;profilingMaxVariableSizeKb;domainsToNotPropagateHeadersTo;nodeModulesToCollectLocalVariablesOn;printConfigurationStatuses;logLevel;stackDepthLocals;stackDepthCodeTraceDepth;packageLibraryType;version;gitSha;gitOrg;gitRepo;gitProvider;serviceDisplayName;infrastructureType;infrastructureDetails;setupInterceptorsFile;setupInterceptorsLine;logIgnoreRegex;captureRequestHeaders;captureResponseHeaders;captureRequestBody;captureResponseBody;requestBodyLimitBytes;responseBodyLimitBytes;_serviceIdentificationReceived=!1;constructor(e){this.apiKey=e.apiKey,this.apiGraphqlEndpoint=e?.apiGraphqlEndpoint||process.env.SAILFISH_GRAPHQL_ENDPOINT||"https://api-service.sailfishqa.com/graphql/",this.sfDebug=e?.debug===!0||process.env.SF_DEBUG==="true",this.serviceIdentifier=e?.serviceIdentifier||process.env.SERVICE_IDENTIFIER,this.serviceUUID=l(),this.serviceVersion=e?.serviceVersion||process.env.SERVICE_VERSION,this.gitSha=e?.gitSha||process.env.GIT_SHA||process.env.VERCEL_GIT_COMMIT_SHA,this.gitOrg=e?.gitOrg||process.env.GIT_ORG||process.env.VERCEL_GIT_REPO_OWNER,this.gitRepo=e?.gitRepo||process.env.GIT_REPO||process.env.VERCEL_GIT_REPO_SLUG,this.gitProvider=e?.gitProvider||process.env.GIT_PROVIDER,this.serviceDisplayName=e?.serviceDisplayName||process.env.SERVICE_DISPLAY_NAME,this.serviceAdditionalMetadata=e?.serviceAdditionalMetadata||{},this.profilingModeEnabled=e?.profilingModeEnabled??!1,this.profilingMaxDepth=e?.profilingMaxDepth??5,this.profilingMaxVariableSizeKb=e?.profilingMaxVariableSizeKb??25,this.domainsToNotPropagateHeadersTo=e?.domainsToNotPropagateHeadersTo||[],this.nodeModulesToCollectLocalVariablesOn=e?.nodeModulesToCollectLocalVariablesOn||["_all_"],this.printConfigurationStatuses=process.env.PRINT_CONFIGURATION_STATUSES||"true",this.logLevel=process.env.LOG_LEVEL||"INFO",this.stackDepthLocals=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS,10):5,isNaN(this.stackDepthLocals)&&(this.stackDepthLocals=-1),this.stackDepthCodeTraceDepth=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH,10):-1,isNaN(this.stackDepthCodeTraceDepth)&&(this.stackDepthCodeTraceDepth=-1),this.packageLibraryType="JS/TS BACKEND",this.version=this.getPackageVersion();const t=(function(){return process.env.KUBERNETES_SERVICE_HOST||v.existsSync("/var/run/secrets/kubernetes.io/serviceaccount/token")?{type:"Kubernetes",details:{namespace:process.env.POD_NAMESPACE||"",podName:process.env.HOSTNAME||"",nodeName:process.env.NODE_NAME||""}}:process.env.AWS_LAMBDA_FUNCTION_NAME?{type:"AWS Lambda",details:{functionName:process.env.AWS_LAMBDA_FUNCTION_NAME||"",region:process.env.AWS_REGION||"",runtime:process.env.AWS_EXECUTION_ENV||""}}:process.env.AWS_EXECUTION_ENV?{type:"AWS",details:{executionEnv:process.env.AWS_EXECUTION_ENV||"",region:process.env.AWS_REGION||""}}:process.env.GOOGLE_CLOUD_PROJECT?{type:"Google Cloud",details:{project:process.env.GOOGLE_CLOUD_PROJECT||""}}:process.env.AZURE_FUNCTIONS_ENVIRONMENT?{type:"Azure Functions",details:{environment:process.env.AZURE_FUNCTIONS_ENVIRONMENT||""}}:process.env.VERCEL?{type:"Vercel",details:{env:process.env.VERCEL_ENV||"",region:process.env.VERCEL_REGION||""}}:process.env.NETLIFY?{type:"Netlify",details:{}}:process.env.FLY_APP_NAME?{type:"Fly.io",details:{appName:process.env.FLY_APP_NAME||"",region:process.env.FLY_REGION||""}}:process.env.RENDER_SERVICE_ID?{type:"Render",details:{serviceId:process.env.RENDER_SERVICE_ID||""}}:process.env.RAILWAY_ENVIRONMENT?{type:"Railway",details:{environment:process.env.RAILWAY_ENVIRONMENT||""}}:v.existsSync("/.dockerenv")?{type:"Docker",details:{}}:{type:"Unknown",details:{os:f.platform(),arch:f.arch(),nodeVersion:process.version}}})();this.infrastructureType=t.type,this.infrastructureDetails=t.details;const r=process.env.SF_LOG_IGNORE_REGEX;if(r)try{this.logIgnoreRegex=new RegExp(r)}catch{}this.captureRequestHeaders=process.env.SF_NETWORKHOP_CAPTURE_REQUEST_HEADERS==="true",this.captureResponseHeaders=process.env.SF_NETWORKHOP_CAPTURE_RESPONSE_HEADERS==="true",this.captureRequestBody=process.env.SF_NETWORKHOP_CAPTURE_REQUEST_BODY==="true",this.captureResponseBody=process.env.SF_NETWORKHOP_CAPTURE_RESPONSE_BODY==="true";const s=parseInt(process.env.SF_NETWORKHOP_REQUEST_LIMIT_MB||"1",10);this.requestBodyLimitBytes=1024*(isNaN(s)?1:s)*1024;const i=parseInt(process.env.SF_NETWORKHOP_RESPONSE_LIMIT_MB||"1",10);this.responseBodyLimitBytes=1024*(isNaN(i)?1:i)*1024}getPackageVersion(){return"0.2.14"}get serviceIdentificationReceived(){return this._serviceIdentificationReceived}setServiceIdentificationReceived(e){this._serviceIdentificationReceived=e}}const y=Symbol.for("sailfish.sf_config");function C(){return globalThis[y]}function h(){const n=C();if(!n)throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");return n}const R=Symbol.for("sf.ctx.storeAls"),a=globalThis,S=a[R]??(a[R]=new D.AsyncLocalStorage),L=["identitytoolkit.googleapis.com","t.co","*.twitter.com","*.gravatar.com","*.googleapis.com","*.amazonaws.com","*.smooch.io","*.zendesk.com"],N=Symbol.for("sf.ctx.als"),g=a[N]??(a[N]=new D.AsyncLocalStorage),T=Symbol.for("sf.ctx.sessionRegistry"),d=a[T]??(a[T]=new Map),E={handledExceptions:new Set,reentrancyGuardLoggingActive:!1,reentrancyGuardLoggingPreActive:!1,reentrancyGuardPrintActive:!1,reentrancyGuardPrintPreActive:!1,reentrancyGuardExceptionActive:!1,reentrancyGuardExceptionPreActive:!1,excludedDomains:new Set(L),supportedDomains:new Set};class c{static GLOBAL_MANAGER_SYMBOL=Symbol.for("sf.ctx.manager");constructor(){}current(){return S.getStore()}ensureStore(){const e=this.current();if(e)return e;const t=new Map;return S.enterWith(t),t}runWith(e,t){const r=this.current()??new Map,s=new Map(r);for(const[i,p]of Object.entries(e))s.set(i,p);return S.run(s,t)}static getInstance(){return a[c.GLOBAL_MANAGER_SYMBOL]||(a[c.GLOBAL_MANAGER_SYMBOL]=new c),a[c.GLOBAL_MANAGER_SYMBOL]}getCurrentContext(){return g.getStore()||E}setCurrentContext(e){const t=g.getStore()||E;g.enterWith({...t,...e})}ensureSession(e){let t=d.get(e);return t||(t={...E},d.set(e,t)),t}getContextFor(e){return d.get(e)??E}updateContextFor(e,t){const r=this.ensureSession(e);d.set(e,{...r,...t})}runWithSession(e,t){const r={...this.ensureSession(e)};return g.run(r,t)}deleteSession(e){d.delete(e)}getTraceId(){return this.getCurrentContext().traceId}getPageVisitUUID(){return this.getCurrentContext().pageVisitUUID}setTraceId(e){this.setCurrentContext({traceId:e})}setPageVisitUUID(e){this.setCurrentContext({pageVisitUUID:e})}getCurrentFunctionSpanId(){return this.getCurrentContext().currentFunctionSpanId}setCurrentFunctionSpanId(e){this.setCurrentContext({currentFunctionSpanId:e})}clearCurrentFunctionSpanId(){this.setCurrentContext({currentFunctionSpanId:void 0})}getOrSetSfTraceId(e,t=!1){let r=this.getTraceId();return r||(r=e||(t?l():`nonsession-applogs-v3/${h().apiKey}/${l()}`),this.setTraceId(r),h().sfDebug&&console.log(" Created new trace ID:",r),r)}getOrSetPageVisitUUID(){let e=this.getPageVisitUUID();return e||(e=l(),this.setPageVisitUUID(e),h().sfDebug&&console.log(" Created new page visit UUID:",e),e)}getHandledExceptions(){return this.getCurrentContext().handledExceptions}markExceptionHandled(e){const t=this.getHandledExceptions();t.add(e),this.setCurrentContext({handledExceptions:t})}hasHandledException(e){return this.getHandledExceptions().has(e)}resetHandledExceptions(){this.setCurrentContext({handledExceptions:new Set})}getExcludedDomains(){return this.getCurrentContext().excludedDomains}getSupportedDomains(){return this.getCurrentContext().supportedDomains}addSupportedDomains(e){this.getCurrentContext().supportedDomains.add(e.toLowerCase().trim())}setTraceIdFor(e,t){this.updateContextFor(e,{traceId:t})}setPageVisitUUIDFor(e,t){this.updateContextFor(e,{pageVisitUUID:t})}}exports.ContextManager=c,exports.DEFAULT_DOMAINS_TO_EXCLUDE=L,exports.backfillGitInfoAsync=async function(n){if(!(n.gitOrg&&n.gitRepo&&n.gitProvider))try{const e=await(async function(){let t="";try{t=await new Promise((r,s)=>{m.execFile("git",["remote","get-url","origin"],{timeout:3e3},(i,p)=>{i?s(i):r((p||"").trim())})})}catch{try{const r=(await b.readFile(".git/config","utf-8")).match(/\[remote "origin"\][^[]*url\s*=\s*(.+)/m);r&&(t=r[1].trim())}catch{}}return t?(function(r){let s,i,p;if(r.includes("github.com")?s="github":r.includes("gitlab.com")?s="gitlab":r.includes("bitbucket.org")&&(s="bitbucket"),r.startsWith("https://")||r.startsWith("http://")){const u=r.split("/");u.length>=5&&(i=u[3],p=u[4].replace(/\.git$/,""))}else{const u=r.indexOf(":");if(u>0){const _=r.substring(u+1).replace(/\.git$/,"").split("/");_.length>=2&&(i=_[0],p=_[1])}}return{org:i,repo:p,provider:s}})(t):{}})();n.gitOrg||(n.gitOrg=e.org),n.gitRepo||(n.gitRepo=e.repo),n.gitProvider||(n.gitProvider=e.provider)}catch{}},exports.getConfig=h,exports.getCurrentFunctionSpanId=function(){return c.getInstance().getCurrentFunctionSpanId()},exports.getGlobalConfigUnsafe=C,exports.getOrCreateConfig=function(n){const e=C();if(e)return{config:e};const t=new M(n);return(function(r){globalThis[y]=r})(t),t.sfDebug&&console.log("[[getOrCreateConfig]] Created global config:",t),{config:t}},exports.runWithContext=function(n){const e={...c.getInstance().getCurrentContext()};g.run(e,()=>{n()})},exports.v4=l;