@sailfish-ai/sf-veritas 0.2.14 → 0.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,21 @@
1
- var pe = Object.defineProperty;
2
- var ge = (r, t, e) => t in r ? pe(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var y = (r, t, e) => ge(r, typeof t != "symbol" ? t + "" : t, e);
4
- import { g as u, C as V, D as fe, v as oe, b as H, c as he, a as ae } from "./contextManager-Cx03mw7l.js";
5
- import { r as gt } from "./contextManager-Cx03mw7l.js";
6
- import { B as T, n as E, f as me, g as ce, p as de, a as ue, b as ye, m as R, c as k, d as Se, i as O, t as M, F as Ie } from "./workerPoolSpanCapture-DWS_V0Mn.js";
7
- import { e as ht, s as mt } from "./workerPoolSpanCapture-DWS_V0Mn.js";
8
- import { C as ve, i as _, a as $e, h as w, b as _e, c as be } from "./runtimeConfig-DndXTWki.js";
9
- import { d as St, e as It, s as vt } from "./runtimeConfig-DndXTWki.js";
10
- import { createRequire as Ne } from "node:module";
11
- import * as x from "fs";
12
- import { readFileSync as Fe, appendFileSync as De } from "fs";
1
+ var fe = Object.defineProperty;
2
+ var he = (r, t, e) => t in r ? fe(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var y = (r, t, e) => he(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import { g as u, C as j, D as me, v as oe, b as q, c as ye, a as ae } from "./contextManager-Cx03mw7l.js";
5
+ import { r as ht } from "./contextManager-Cx03mw7l.js";
6
+ import { B as T, n as E, f as Se, g as ce, p as de, a as ue, b as Ie, m as U, c as A, i as X, d as ve, e as R, t as H, F as $e } from "./workerPoolSpanCapture-DEW40aIL.js";
7
+ import { h as yt, s as St } from "./workerPoolSpanCapture-DEW40aIL.js";
8
+ import { C as _e, i as _, a as be, h as P, b as Fe, c as Ne } from "./runtimeConfig-DndXTWki.js";
9
+ import { d as vt, e as $t, s as _t } from "./runtimeConfig-DndXTWki.js";
10
+ import { createRequire as De } from "node:module";
11
+ import * as M from "fs";
12
+ import { readFileSync as Pe, appendFileSync as Ee } from "fs";
13
13
  import { s as we } from "./source-map-Cr6YkjTd.js";
14
- import * as F from "path";
15
- import { glob as Ee } from "glob";
16
- import { threadId as L } from "worker_threads";
17
- import { s as _t, t as bt, a as Nt } from "./funcSpanTransformer-Byqzu4B1.js";
18
- class U extends T {
14
+ import * as N from "path";
15
+ import { glob as Te } from "glob";
16
+ import { threadId as O } from "worker_threads";
17
+ import { s as Ft, t as Nt, a as Dt } from "./funcSpanTransformer-Byqzu4B1.js";
18
+ class C extends T {
19
19
  constructor() {
20
20
  super(), this.setOperationName("IdentifyServiceDetails");
21
21
  }
@@ -63,17 +63,17 @@ class U extends T {
63
63
  E(this.endpoint, this.operationName, t, e);
64
64
  }
65
65
  }
66
- function Pe(r) {
66
+ function Ce(r) {
67
67
  try {
68
68
  return JSON.stringify(r), !0;
69
69
  } catch {
70
70
  return !1;
71
71
  }
72
72
  }
73
- class Te extends T {
73
+ class Ue extends T {
74
74
  constructor() {
75
75
  super();
76
- y(this, "serviceIdentifier", new U());
76
+ y(this, "serviceIdentifier", new C());
77
77
  this.setOperationName("CollectMetadata");
78
78
  }
79
79
  async sendAppIdentifier() {
@@ -88,7 +88,7 @@ class Te extends T {
88
88
  if (!o) {
89
89
  const c = (function(a) {
90
90
  const l = {}, g = [];
91
- if (a) for (const [f, h] of Object.entries(a)) Pe(h) ? l[f] = h : g.push(f);
91
+ if (a) for (const [f, h] of Object.entries(a)) Ce(h) ? l[f] = h : g.push(f);
92
92
  return { traitsJson: JSON.stringify(l), excludedFields: g };
93
93
  })(i);
94
94
  o = c.traitsJson, d = c.excludedFields;
@@ -107,7 +107,7 @@ class Te extends T {
107
107
  class le {
108
108
  constructor(t) {
109
109
  y(this, "metadataTransmitter");
110
- this.apiKey = t, this.metadataTransmitter = new Te();
110
+ this.apiKey = t, this.metadataTransmitter = new Ue();
111
111
  }
112
112
  identify(t, e, i, n = !1) {
113
113
  e || i ? this.addOrUpdateMetadata(t, e, i, n) : this.addOrUpdateMetadata(t, {}, void 0, n);
@@ -117,10 +117,10 @@ class le {
117
117
  u().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), u().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", t, e, i), this.metadataTransmitter.doSend(t, e, n, i);
118
118
  }
119
119
  }
120
- class Q extends T {
120
+ class V extends T {
121
121
  constructor() {
122
122
  super();
123
- y(this, "serviceIdentifier", new U());
123
+ y(this, "serviceIdentifier", new C());
124
124
  }
125
125
  async sendAppIdentifier() {
126
126
  this.serviceIdentifier.doSend({});
@@ -164,10 +164,10 @@ class Q extends T {
164
164
  `;
165
165
  }
166
166
  }
167
- class Ce extends T {
167
+ class Re extends T {
168
168
  constructor() {
169
169
  super();
170
- y(this, "serviceIdentifier", new U());
170
+ y(this, "serviceIdentifier", new C());
171
171
  y(this, "supplementalFields", {});
172
172
  this.setOperationName("CollectExceptions");
173
173
  }
@@ -186,7 +186,7 @@ class Ce extends T {
186
186
  }
187
187
  async send(e, i) {
188
188
  u().sfDebug && console.log(" SENDING EXCEPTION...");
189
- const n = JSON.stringify(ve.encode(i)), o = this.normalizedSupplementalForGraphQL(), d = this.getVariables({ exceptionMessage: e, traceJson: n, reentrancyGuardPreactive: !1, library: u().packageLibraryType, version: u().version, ...o });
189
+ const n = JSON.stringify(_e.encode(i)), o = this.normalizedSupplementalForGraphQL(), d = this.getVariables({ exceptionMessage: e, traceJson: n, reentrancyGuardPreactive: !1, library: u().packageLibraryType, version: u().version, ...o });
190
190
  E(this.endpoint, this.operationName, this.getQuery(), d);
191
191
  }
192
192
  getQuery() {
@@ -222,18 +222,18 @@ class Ce extends T {
222
222
  }
223
223
  }
224
224
  const Y = "getting request source code";
225
- var q = ((r) => (r.UNKNOWN = "unknown", r.ANONYMOUS = "anonymous", r.NOT_CAPTURED = "not captured", r))(q || {});
226
- const G = "http:", K = "https:", Ue = Ne(import.meta.url);
225
+ var k = ((r) => (r.UNKNOWN = "unknown", r.ANONYMOUS = "anonymous", r.NOT_CAPTURED = "not captured", r))(k || {});
226
+ const x = "http:", G = "https:", Oe = De(import.meta.url);
227
227
  let Z = !1;
228
- function Re() {
228
+ function Le() {
229
229
  const r = u().sfDebug;
230
230
  if (Z) return void (r && _("[patchNodeHttpInbound] Already installed, skipping."));
231
231
  let t;
232
232
  Z = !0;
233
233
  try {
234
- t = Ue("node:http"), r && _("[patchNodeHttpInbound] node:http required successfully.");
234
+ t = Oe("node:http"), r && _("[patchNodeHttpInbound] node:http required successfully.");
235
235
  } catch (n) {
236
- return void $e("Failed to require node:http:", n);
236
+ return void be("Failed to require node:http:", n);
237
237
  }
238
238
  if (!t?.Server?.prototype) return void (r && _("[patchNodeHttpInbound] http.Server.prototype not found."));
239
239
  const e = t.Server.prototype, i = e.emit;
@@ -246,7 +246,7 @@ function Re() {
246
246
  return m;
247
247
  })(d?.headers), a = c["x-sf3-rid"], l = c["x-sf3-functionspancaptureoverride"];
248
248
  r && (_("[patchNodeHttpInbound] Intercepted request event."), _("[patchNodeHttpInbound] Inbound headers:", c), _("[patchNodeHttpInbound] Trace header:", a), _("[patchNodeHttpInbound] FuncSpan override header:", l));
249
- const g = V.getInstance();
249
+ const g = j.getInstance();
250
250
  g.setTraceId(a);
251
251
  const f = g.getTraceId();
252
252
  r && _("[patchNodeHttpInbound] Context traceId set:", f);
@@ -259,13 +259,13 @@ function Re() {
259
259
  });
260
260
  if (!l) return h();
261
261
  try {
262
- return me.run(l, () => h());
262
+ return Se.run(l, () => h());
263
263
  } catch {
264
264
  return h();
265
265
  }
266
266
  }) : r && _("[patchNodeHttpInbound] Already patched, skipping.");
267
267
  }
268
- class Oe extends Q {
268
+ class Ae extends V {
269
269
  constructor() {
270
270
  super(), this.setOperationName("DomainsToNotPassHeaderTo");
271
271
  }
@@ -289,10 +289,10 @@ class Oe extends Q {
289
289
  E(this.endpoint, this.operationName, e, i);
290
290
  }
291
291
  }
292
- class Le extends T {
292
+ class ke extends T {
293
293
  constructor() {
294
294
  super();
295
- y(this, "serviceIdentifier", new U());
295
+ y(this, "serviceIdentifier", new C());
296
296
  this.setOperationName("CollectNetworkHops");
297
297
  }
298
298
  async sendAppIdentifier() {
@@ -333,10 +333,10 @@ class Le extends T {
333
333
  `;
334
334
  }
335
335
  }
336
- class Ae extends T {
336
+ class qe extends T {
337
337
  constructor() {
338
338
  super();
339
- y(this, "serviceIdentifier", new U());
339
+ y(this, "serviceIdentifier", new C());
340
340
  this.setOperationName("CollectNetworkRequest");
341
341
  }
342
342
  async sendAppIdentifier() {
@@ -360,15 +360,15 @@ class Ae extends T {
360
360
  await E(this.endpoint, this.operationName, this.getQuery(), i);
361
361
  }
362
362
  }
363
- const W = [400, 403];
364
- class ke {
363
+ const K = [400, 403];
364
+ class He {
365
365
  constructor(t = []) {
366
366
  y(this, "HEADER_TRACING", "X-Sf3-Rid");
367
367
  y(this, "HEADER_LOG_GUARD", "reentrancy_guard_logging_preactive");
368
368
  y(this, "HEADER_PRINT_GUARD", "reentrancy_guard_print_preactive");
369
369
  y(this, "HEADER_EXCEPTION_GUARD", "reentrancy_guard_exception_preactive");
370
370
  y(this, "contextManager");
371
- this.contextManager = V.getInstance(), t?.forEach((e) => {
371
+ this.contextManager = j.getInstance(), t?.forEach((e) => {
372
372
  typeof e == "string" && e.trim() && this.contextManager.getExcludedDomains().add(e);
373
373
  }), u().sfDebug && console.log("[RequestInterceptor] Initialized with static excluded domains.");
374
374
  }
@@ -394,9 +394,10 @@ class ke {
394
394
  }
395
395
  async getOriginalPosition(t, e, i) {
396
396
  let n = { source: t, line: e, column: i, name: null };
397
+ if (t.includes("://")) return { originalPos: n };
397
398
  const o = t + ".map";
398
399
  try {
399
- const d = JSON.parse(Fe(o, "utf-8"));
400
+ const d = JSON.parse(Pe(o, "utf-8"));
400
401
  let s = (await new we.SourceMapConsumer(d)).originalPositionFor({ line: e, column: i });
401
402
  s.source && (n = s);
402
403
  } catch (d) {
@@ -421,7 +422,7 @@ class ke {
421
422
  const { originalPos: f } = await this.getOriginalPosition(g.filePath, g.line, g.column);
422
423
  if (f) {
423
424
  u().sfDebug && console.log("[RequestInterceptor] First user code line:", f);
424
- const h = { line: f.line?.toString() || q.UNKNOWN, column: f.column?.toString() || q.NOT_CAPTURED, name: f.name || q.NOT_CAPTURED, entrypoint: f.source, retryWithoutTraceId: i };
425
+ const h = { line: f.line?.toString() || k.UNKNOWN, column: f.column?.toString() || k.NOT_CAPTURED, name: f.name || k.NOT_CAPTURED, entrypoint: f.source, retryWithoutTraceId: i };
425
426
  t.doSend(h);
426
427
  }
427
428
  })() : u().sfDebug && console.error("Could not parse stack line:", l);
@@ -431,7 +432,7 @@ class ke {
431
432
  t.set(this.HEADER_LOG_GUARD, "true"), t.set(this.HEADER_PRINT_GUARD, "true"), t.set(this.HEADER_EXCEPTION_GUARD, "true");
432
433
  }
433
434
  shouldPropagateHeaders(t) {
434
- return !fe.some((e) => new RegExp(`^${e.replace(/\*/g, ".*")}$`).test(t));
435
+ return !me.some((e) => new RegExp(`^${e.replace(/\*/g, ".*")}$`).test(t));
435
436
  }
436
437
  addTracingHeaders(t, e) {
437
438
  const i = new URL(e).hostname, n = this.shouldPropagateHeaders(i);
@@ -461,20 +462,20 @@ class ke {
461
462
  let h;
462
463
  try {
463
464
  let p = !1;
464
- this.addTracingHeaders(l, c), h = await i(c, f), g && W.includes(h.status) ? (h = await i(c, { ...o, headers: l }), p = !0, this.captureFirstUserLines(t, 10, p)) : this.contextManager.addSupportedDomains(a);
465
+ this.addTracingHeaders(l, c), h = await i(c, f), g && K.includes(h.status) ? (h = await i(c, { ...o, headers: l }), p = !0, this.captureFirstUserLines(t, 10, p)) : this.contextManager.addSupportedDomains(a);
465
466
  const m = Date.now();
466
467
  u().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${c}, Status: ${h.status}, Duration: ${m - s}ms`);
467
- const { sessionId: I, pageVisitId: v, requestId: D } = this.extractIdsFromTraceHeader(d), $ = u(), b = { apiKey: $.apiKey, requestId: D, pageVisitId: v, recordingSessionId: I, serviceUuid: $.serviceUUID, timestampStart: s.toString(), timestampEnd: m.toString(), responseCode: h.status, success: !0, error: null, url: c, method: f.method || "GET", retryWithoutTraceId: p, parentSpanId: H() };
468
+ const { sessionId: I, pageVisitId: v, requestId: D } = this.extractIdsFromTraceHeader(d), $ = u(), b = { apiKey: $.apiKey, requestId: D, pageVisitId: v, recordingSessionId: I, serviceUuid: $.serviceUUID, timestampStart: s.toString(), timestampEnd: m.toString(), responseCode: h.status, success: !0, error: null, url: c, method: f.method || "GET", retryWithoutTraceId: p, parentSpanId: q() };
468
469
  if ($.captureRequestHeaders) {
469
470
  const S = {};
470
- d.forEach((N, P) => {
471
- S[P] = N;
471
+ d.forEach((F, w) => {
472
+ S[w] = F;
472
473
  }), b.requestHeaders = S;
473
474
  }
474
475
  if ($.captureResponseHeaders) {
475
476
  const S = {};
476
- h.headers.forEach((N, P) => {
477
- S[P] = N;
477
+ h.headers.forEach((F, w) => {
478
+ S[w] = F;
478
479
  }), b.responseHeaders = S;
479
480
  }
480
481
  if ($.captureRequestBody && o?.body) try {
@@ -483,8 +484,8 @@ class ke {
483
484
  } catch {
484
485
  }
485
486
  if ($.captureResponseBody) try {
486
- const S = h.clone(), N = await S.text();
487
- b.responseBody = N.length > $.responseBodyLimitBytes ? N.substring(0, $.responseBodyLimitBytes) + "...[truncated]" : N;
487
+ const S = h.clone(), F = await S.text();
488
+ b.responseBody = F.length > $.responseBodyLimitBytes ? F.substring(0, $.responseBodyLimitBytes) + "...[truncated]" : F;
488
489
  } catch {
489
490
  }
490
491
  return e.doSend(b), h;
@@ -495,15 +496,15 @@ class ke {
495
496
  } : u().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
496
497
  }
497
498
  patchHttp(t, e) {
498
- if (u().sfDebug && console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."), !w || typeof w.request != "function") return void (u().sfDebug && console.log("[RequestInterceptor] HTTP/HTTPS not available."));
499
- const i = w.request.bind(w), n = w.request.bind(w);
500
- w.request = function(o, d) {
499
+ if (u().sfDebug && console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."), !P || typeof P.request != "function") return void (u().sfDebug && console.log("[RequestInterceptor] HTTP/HTTPS not available."));
500
+ const i = P.request.bind(P), n = P.request.bind(P);
501
+ P.request = function(o, d) {
501
502
  let s;
502
503
  try {
503
504
  if (typeof o == "string") {
504
505
  const a = new URL(o);
505
- s = { protocol: a.protocol || G, hostname: a.hostname, path: a.pathname + a.search, headers: {} };
506
- } else o instanceof URL ? s = { protocol: o.protocol || G, hostname: o.hostname, path: o.pathname + o.search, headers: {} } : (s = { ...o }, s.protocol || (s.protocol = G));
506
+ s = { protocol: a.protocol || x, hostname: a.hostname, path: a.pathname + a.search, headers: {} };
507
+ } else o instanceof URL ? s = { protocol: o.protocol || x, hostname: o.hostname, path: o.pathname + o.search, headers: {} } : (s = { ...o }, s.protocol || (s.protocol = x));
507
508
  if (s.headers) {
508
509
  const a = `${s.protocol}//${s.hostname}`;
509
510
  this.addTracingHeaders(s.headers, a), this.captureFirstUserLines(t);
@@ -514,21 +515,21 @@ class ke {
514
515
  let c = !1;
515
516
  return i(s, (a) => {
516
517
  const l = `${s.protocol}//${s.hostname}`;
517
- if (s.headers && this.shouldPropagateHeaders(new URL(l).hostname) && W.includes(a.statusCode || 0)) {
518
+ if (s.headers && this.shouldPropagateHeaders(new URL(l).hostname) && K.includes(a.statusCode || 0)) {
518
519
  s.hostname;
519
520
  const p = { ...s, headers: { ...s.headers } };
520
521
  delete p.headers[this.HEADER_TRACING], i(p, d), c = !0, this.captureFirstUserLines(t, 10, c);
521
522
  }
522
523
  const { sessionId: g, pageVisitId: f, requestId: h } = this.extractIdsFromTraceHeader(s.headers);
523
- e.doSend({ apiKey: u().apiKey, requestId: h, pageVisitId: f, recordingSessionId: g, serviceUuid: u().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: a.statusCode || 0, success: !!a.statusCode && a.statusCode < 400, error: null, url: l, method: s.method || "GET", retryWithoutTraceId: c, parentSpanId: H() }), d?.(a);
524
+ e.doSend({ apiKey: u().apiKey, requestId: h, pageVisitId: f, recordingSessionId: g, serviceUuid: u().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: a.statusCode || 0, success: !!a.statusCode && a.statusCode < 400, error: null, url: l, method: s.method || "GET", retryWithoutTraceId: c, parentSpanId: q() }), d?.(a);
524
525
  });
525
- }, w.request = function(o, d) {
526
+ }, P.request = function(o, d) {
526
527
  let s;
527
528
  try {
528
529
  if (typeof o == "string") {
529
530
  const a = new URL(o);
530
- s = { protocol: a.protocol || K, hostname: a.hostname, path: a.pathname + a.search, headers: {} };
531
- } else o instanceof URL ? s = { protocol: o.protocol || K, hostname: o.hostname, path: o.pathname + o.search, headers: {} } : (s = { ...o }, s.protocol || (s.protocol = K));
531
+ s = { protocol: a.protocol || G, hostname: a.hostname, path: a.pathname + a.search, headers: {} };
532
+ } else o instanceof URL ? s = { protocol: o.protocol || G, hostname: o.hostname, path: o.pathname + o.search, headers: {} } : (s = { ...o }, s.protocol || (s.protocol = G));
532
533
  if (s.headers) {
533
534
  const a = `${s.protocol}//${s.hostname}`;
534
535
  this.addTracingHeaders(s.headers, a);
@@ -539,12 +540,12 @@ class ke {
539
540
  let c = !1;
540
541
  return n(s, (a) => {
541
542
  const l = `${s.protocol}//${s.hostname}`;
542
- if (s.headers && this.shouldPropagateHeaders(new URL(l).hostname) && W.includes(a.statusCode || 0)) {
543
+ if (s.headers && this.shouldPropagateHeaders(new URL(l).hostname) && K.includes(a.statusCode || 0)) {
543
544
  const p = { ...s, headers: { ...s.headers } };
544
545
  delete p.headers[this.HEADER_TRACING], n(p, d), c = !0, this.captureFirstUserLines(t, 10, c);
545
546
  }
546
547
  const { sessionId: g, pageVisitId: f, requestId: h } = this.extractIdsFromTraceHeader(s.headers);
547
- e.doSend({ apiKey: u().apiKey, requestId: h, pageVisitId: f, recordingSessionId: g, serviceUuid: u().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: a.statusCode || 0, success: !!a.statusCode && a.statusCode < 400, error: null, url: l, method: s.method || "GET", retryWithoutTraceId: c, parentSpanId: H() }), d?.(a);
548
+ e.doSend({ apiKey: u().apiKey, requestId: h, pageVisitId: f, recordingSessionId: g, serviceUuid: u().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: a.statusCode || 0, success: !!a.statusCode && a.statusCode < 400, error: null, url: l, method: s.method || "GET", retryWithoutTraceId: c, parentSpanId: q() }), d?.(a);
548
549
  });
549
550
  }, u().sfDebug && console.log("✅ HTTP and HTTPS request methods patched globally.");
550
551
  }
@@ -558,7 +559,7 @@ class ke {
558
559
  return [...this.contextManager.getExcludedDomains()];
559
560
  }
560
561
  }
561
- class qe extends Q {
562
+ class Me extends V {
562
563
  constructor() {
563
564
  super(), this.setOperationName("UpdateServiceDetails");
564
565
  }
@@ -606,7 +607,7 @@ class qe extends Q {
606
607
  E(this.endpoint, this.operationName, t, i);
607
608
  }
608
609
  }
609
- class He {
610
+ class xe {
610
611
  constructor(t = [process.cwd()], e = !1) {
611
612
  y(this, "rootPaths");
612
613
  y(this, "fileConfigs", /* @__PURE__ */ new Map());
@@ -620,28 +621,28 @@ class He {
620
621
  async loadAllConfigs() {
621
622
  this.debug && console.log("[FuncSpan ConfigLoader] Scanning for .sailfish files in:", this.rootPaths);
622
623
  const t = [];
623
- for (const e of this.rootPaths) x.existsSync(e) ? await this._walkDirectory(e, t) : this.debug && console.log(`[FuncSpan ConfigLoader] Root path does not exist: ${e}`);
624
+ for (const e of this.rootPaths) M.existsSync(e) ? await this._walkDirectory(e, t) : this.debug && console.log(`[FuncSpan ConfigLoader] Root path does not exist: ${e}`);
624
625
  t.length > 0 ? (this.hasSailfishFiles = !0, this.debug && (console.log(`[FuncSpan ConfigLoader] Found ${t.length} .sailfish files:`), t.forEach((e) => console.log(`[FuncSpan ConfigLoader] - ${e}`)))) : this.debug && console.log("[FuncSpan ConfigLoader] No .sailfish files found - function spans disabled by default");
625
626
  for (const e of t) await this._loadConfigFile(e);
626
627
  await this._resolveInheritance(), this.debug && console.log(`[FuncSpan ConfigLoader] Loaded ${this.fileConfigs.size} file configs, ${this.functionConfigs.size} function configs`);
627
628
  }
628
629
  getConfig(t, e) {
629
- const i = this.hasSailfishFiles ? ue() : ye(), n = this._getDirectoryConfig(t), o = F.normalize(t), d = this.fileConfigs.get(o) || {};
630
+ const i = this.hasSailfishFiles ? Ie() : ue(), n = this._getDirectoryConfig(t), o = N.normalize(t), d = this.fileConfigs.get(o) || {};
630
631
  let s = {};
631
632
  if (e) {
632
633
  const c = this.functionConfigs.get(o);
633
634
  c && (s = c.get(e) || {});
634
635
  }
635
- return R(i, n, d, s);
636
+ return U(i, n, d, s);
636
637
  }
637
638
  hasRuntimeMode() {
638
639
  return this.runtimeModeEnabled;
639
640
  }
640
641
  async _walkDirectory(t, e) {
641
642
  try {
642
- const i = x.readdirSync(t, { withFileTypes: !0 });
643
+ const i = M.readdirSync(t, { withFileTypes: !0 });
643
644
  for (const n of i) {
644
- const o = F.join(t, n.name);
645
+ const o = N.join(t, n.name);
645
646
  n.isFile() && n.name === ".sailfish" ? e.push(o) : n.name === "node_modules" || n.isDirectory() && n.name.startsWith(".") && n.name !== ".sailfish" || n.isDirectory() && await this._walkDirectory(o, e);
646
647
  }
647
648
  } catch (i) {
@@ -650,7 +651,7 @@ class He {
650
651
  }
651
652
  async _loadConfigFile(t) {
652
653
  try {
653
- const e = x.readFileSync(t, "utf-8"), i = F.dirname(t);
654
+ const e = M.readFileSync(t, "utf-8"), i = N.dirname(t);
654
655
  let n = null;
655
656
  try {
656
657
  n = JSON.parse(e);
@@ -673,10 +674,10 @@ class He {
673
674
  }
674
675
  async _expandFileGlobs(t, e, i) {
675
676
  for (const [n, o] of Object.entries(e)) try {
676
- const d = F.join(t, n), s = await Ee(d, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
677
+ const d = N.join(t, n), s = await Te(d, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
677
678
  this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${n}' matched ${s.length} files`);
678
679
  for (const c of s) {
679
- const a = F.normalize(c), l = R(i, o);
680
+ const a = N.normalize(c), l = U(i, o);
680
681
  this.fileConfigs.set(a, l), this.debug && s.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${c}`);
681
682
  }
682
683
  } catch (d) {
@@ -690,37 +691,44 @@ class He {
690
691
  this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${n}' (expected format: 'file.ts::functionName')`);
691
692
  continue;
692
693
  }
693
- const [s, c] = d, a = F.normalize(F.join(t, s));
694
+ const [s, c] = d, a = N.normalize(N.join(t, s));
694
695
  this.functionConfigs.has(a) || this.functionConfigs.set(a, /* @__PURE__ */ new Map());
695
- const l = this.functionConfigs.get(a), g = R(i, o);
696
+ const l = this.functionConfigs.get(a), g = U(i, o);
696
697
  l.set(c, g), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${a}::${c}`);
697
698
  }
698
699
  }
699
700
  async _resolveInheritance() {
700
701
  }
701
702
  _getDirectoryConfig(t) {
702
- let e = F.dirname(F.normalize(t));
703
+ let e = N.dirname(N.normalize(t));
703
704
  const i = [];
704
- for (; e && e !== F.dirname(e); ) {
705
+ for (; e && e !== N.dirname(e); ) {
705
706
  const n = this.directoryConfigs.get(e);
706
- n && i.unshift(n), e = F.dirname(e);
707
+ n && i.unshift(n), e = N.dirname(e);
707
708
  }
708
- return i.reduce((n, o) => R(n, o), {});
709
+ return i.reduce((n, o) => U(n, o), {});
709
710
  }
710
711
  }
711
- let C = null;
712
- async function Me(r, t) {
713
- C = new He(r, t), await C.loadAllConfigs();
712
+ const pe = "__sf_globalConfigLoader";
713
+ function ge() {
714
+ return globalThis[pe] ?? null;
715
+ }
716
+ async function Ge(r, t) {
717
+ const e = new xe(r, t);
718
+ (function(i) {
719
+ globalThis[pe] = i;
720
+ })(e), await e.loadAllConfigs();
714
721
  }
715
- function xe(r, t) {
716
- return C ? C.getConfig(r, t) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using env config for worker process"), ue());
722
+ function Ke(r, t) {
723
+ const e = ge();
724
+ return e ? e.getConfig(r, t) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using default config (disabled)"), ue());
717
725
  }
718
- function Ge() {
719
- return C !== null;
726
+ function We() {
727
+ return ge() !== null;
720
728
  }
721
- const Ke = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "fstat", "access", "open", "close", "read", "write", "chmod", "mkdir", "rmdir", "unlink", "rename"], ee = ["lookup", "resolve", "resolve4", "resolve6", "resolveAny", "resolveMx", "resolveNs", "resolveTxt", "reverse"], We = ["pbkdf2", "randomBytes", "scrypt", "generateKeyPair"], Be = ["gzip", "gunzip", "deflate", "inflate", "deflateRaw", "inflateRaw", "brotliCompress", "brotliDecompress"];
729
+ const Be = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "fstat", "access", "open", "close", "read", "write", "chmod", "mkdir", "rmdir", "unlink", "rename"], ee = ["lookup", "resolve", "resolve4", "resolve6", "resolveAny", "resolveMx", "resolveNs", "resolveTxt", "reverse"], ze = ["pbkdf2", "randomBytes", "scrypt", "generateKeyPair"], Je = ["gzip", "gunzip", "deflate", "inflate", "deflateRaw", "inflateRaw", "brotliCompress", "brotliDecompress"];
722
730
  let te = !1;
723
- function ze(r) {
731
+ function je(r) {
724
732
  if (typeof r != "string") return !1;
725
733
  const t = process.env.SF_FUNCSPAN_JSONL_FILE;
726
734
  if (t && r.includes(t)) return !0;
@@ -739,7 +747,7 @@ function re(r) {
739
747
  }
740
748
  return !1;
741
749
  }
742
- function Je() {
750
+ function Ve() {
743
751
  if (!ne) try {
744
752
  let r;
745
753
  if (typeof require > "u") return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] Skipping dns patching in pure ESM environment (require unavailable)"));
@@ -753,7 +761,7 @@ function Je() {
753
761
  for (const t of ee) if (typeof r[t] == "function") {
754
762
  const e = r[t];
755
763
  r[t] = function(...i) {
756
- return re(i[0]) ? e.apply(this, i) : typeof i[i.length - 1] == "function" ? k("dns", t, e, i, this) : e.apply(this, i);
764
+ return X() ? e.apply(this, i) : re(i[0]) ? e.apply(this, i) : typeof i[i.length - 1] == "function" ? A("dns", t, e, i, this) : e.apply(this, i);
757
765
  }, Object.defineProperty(r[t], "name", { value: t, writable: !1 });
758
766
  }
759
767
  (function(t) {
@@ -763,7 +771,7 @@ function Je() {
763
771
  for (const e of ee) if (typeof t.promises[e] == "function") {
764
772
  const i = t.promises[e];
765
773
  t.promises[e] = function(...n) {
766
- return re(n[0]) ? i.apply(this, n) : Se("dns", e, i, n, this);
774
+ return X() ? i.apply(this, n) : re(n[0]) ? i.apply(this, n) : ve("dns", e, i, n, this);
767
775
  }, Object.defineProperty(t.promises[e], "name", { value: e, writable: !1 });
768
776
  }
769
777
  process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises module patched successfully");
@@ -773,65 +781,65 @@ function Je() {
773
781
  console.error("[WorkerPool] Error patching dns module:", r);
774
782
  }
775
783
  }
776
- let ie = !1, se = !1, J = !1;
777
- function je() {
778
- if (J) return;
784
+ let ie = !1, se = !1, z = !1;
785
+ function Qe() {
786
+ if (z) return;
779
787
  const r = process.env.SF_DEBUG === "true";
780
- r && console.log("[WorkerPool] Initializing worker pool patching..."), O("fs") && (r && console.log("[WorkerPool] Patching fs module..."), (function() {
788
+ r && console.log("[WorkerPool] Initializing worker pool patching..."), R("fs") && (r && console.log("[WorkerPool] Patching fs module..."), (function() {
781
789
  if (!te) try {
782
790
  const t = require("node:fs");
783
791
  if (t.__sf_worker_pool_patched__) return;
784
792
  Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
785
- for (const e of Ke) if (typeof t[e] == "function") {
793
+ for (const e of Be) if (typeof t[e] == "function") {
786
794
  const i = t[e];
787
795
  t[e] = function(...n) {
788
- return ze(n[0]) ? i.apply(this, n) : typeof n[n.length - 1] == "function" ? k("fs", e, i, n, this) : i.apply(this, n);
796
+ return je(n[0]) ? i.apply(this, n) : typeof n[n.length - 1] == "function" ? A("fs", e, i, n, this) : i.apply(this, n);
789
797
  }, Object.defineProperty(t[e], "name", { value: e, writable: !1 });
790
798
  }
791
799
  te = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] fs module patched successfully");
792
800
  } catch (t) {
793
801
  console.error("[WorkerPool] Error patching fs module:", t);
794
802
  }
795
- })()), O("dns") && (r && console.log("[WorkerPool] Patching dns module..."), Je()), O("crypto") && (r && console.log("[WorkerPool] Patching crypto module..."), (function() {
803
+ })()), R("dns") && (r && console.log("[WorkerPool] Patching dns module..."), Ve()), R("crypto") && (r && console.log("[WorkerPool] Patching crypto module..."), (function() {
796
804
  if (!ie) try {
797
805
  const t = require("node:crypto");
798
806
  if (t.__sf_worker_pool_patched__) return;
799
807
  Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
800
- for (const e of We) if (typeof t[e] == "function") {
808
+ for (const e of ze) if (typeof t[e] == "function") {
801
809
  const i = t[e];
802
810
  t[e] = function(...n) {
803
- return typeof n[n.length - 1] == "function" ? k("crypto", e, i, n, this) : i.apply(this, n);
811
+ return typeof n[n.length - 1] == "function" ? A("crypto", e, i, n, this) : i.apply(this, n);
804
812
  }, Object.defineProperty(t[e], "name", { value: e, writable: !1 });
805
813
  }
806
814
  ie = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] crypto module patched successfully");
807
815
  } catch (t) {
808
816
  console.error("[WorkerPool] Error patching crypto module:", t);
809
817
  }
810
- })()), O("zlib") && (r && console.log("[WorkerPool] Patching zlib module..."), (function() {
818
+ })()), R("zlib") && (r && console.log("[WorkerPool] Patching zlib module..."), (function() {
811
819
  if (!se) try {
812
820
  const t = require("node:zlib");
813
821
  if (t.__sf_worker_pool_patched__) return;
814
822
  Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
815
- for (const e of Be) if (typeof t[e] == "function") {
823
+ for (const e of Je) if (typeof t[e] == "function") {
816
824
  const i = t[e];
817
825
  t[e] = function(...n) {
818
- return typeof n[n.length - 1] == "function" ? k("zlib", e, i, n, this) : i.apply(this, n);
826
+ return typeof n[n.length - 1] == "function" ? A("zlib", e, i, n, this) : i.apply(this, n);
819
827
  }, Object.defineProperty(t[e], "name", { value: e, writable: !1 });
820
828
  }
821
829
  se = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] zlib module patched successfully");
822
830
  } catch (t) {
823
831
  console.error("[WorkerPool] Error patching zlib module:", t);
824
832
  }
825
- })()), J = !0, r && console.log("[WorkerPool] Worker pool patching initialized");
833
+ })()), z = !0, r && console.log("[WorkerPool] Worker pool patching initialized");
826
834
  }
827
- function Ve() {
828
- return J;
835
+ function Xe() {
836
+ return z;
829
837
  }
830
- let j = !1, B = !1;
831
- function st(r) {
832
- if (B) console.warn("[setupInterceptors] ⚠️ Recursive call detected and blocked!");
833
- else if (!j) {
834
- B = !0;
838
+ let J = !1, W = !1;
839
+ function at(r) {
840
+ if (W) console.warn("[setupInterceptors] ⚠️ Recursive call detected and blocked!");
841
+ else if (!J) {
842
+ W = !0;
835
843
  try {
836
844
  let t, e;
837
845
  const i = new Error().stack;
@@ -844,41 +852,41 @@ function st(r) {
844
852
  const s = `The required API Key is not provided: ${JSON.stringify(r)}`;
845
853
  console.error(s);
846
854
  }
847
- const { config: n } = he(r);
855
+ const { config: n } = ye(r);
848
856
  if (t && (n.setupInterceptorsFile = t), e && (n.setupInterceptorsLine = e), n.sfDebug && console.log("Updated configuration after applying options:", n), !n.apiKey || !n.apiGraphqlEndpoint) {
849
857
  const s = `The required config is not provided: ${JSON.stringify(n)}`;
850
858
  throw console.error(s), new Error(s);
851
859
  }
852
- Ge() || Me(void 0, n.sfDebug).catch((s) => {
860
+ We() || Ge(void 0, n.sfDebug).catch((s) => {
853
861
  n.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:", s);
854
- }), process.env.SF_WORKER_POOL_DISABLED === "true" ? n.sfDebug && console.log("[setupInterceptors] Worker pool patching DISABLED (SF_WORKER_POOL_DISABLED=true)") : Ve() || (je(), n.sfDebug && console.log("[setupInterceptors] Worker pool patching initialized (DNS tracking enabled)"));
855
- const o = new Q();
856
- o.setServiceUUID(n.serviceUUID), _e(o), (function(s = []) {
857
- const c = new ke(s);
858
- new Oe().doSend(c.getExcludedDomains());
859
- const a = new Le(), l = new Ae();
862
+ }), process.env.SF_WORKER_POOL_DISABLED === "true" ? n.sfDebug && console.log("[setupInterceptors] Worker pool patching DISABLED (SF_WORKER_POOL_DISABLED=true)") : Xe() || (Qe(), n.sfDebug && console.log("[setupInterceptors] Worker pool patching initialized (DNS tracking enabled)"));
863
+ const o = new V();
864
+ o.setServiceUUID(n.serviceUUID), Fe(o), (function(s = []) {
865
+ const c = new He(s);
866
+ new Ae().doSend(c.getExcludedDomains());
867
+ const a = new ke(), l = new qe();
860
868
  c.patchFetch(a, l), c.patchHttp(a, l);
861
869
  })(n.domainsToNotPropagateHeadersTo);
862
- const d = new Ce();
863
- d.setServiceUUID(n.serviceUUID), be(d), Re(), new qe().send(), j = !0, n.sfDebug && console.log("[setupInterceptors] ✅ Initialization complete");
870
+ const d = new Re();
871
+ d.setServiceUUID(n.serviceUUID), Ne(d), Le(), new Me().send(), J = !0, n.sfDebug && console.log("[setupInterceptors] ✅ Initialization complete");
864
872
  } finally {
865
- B = !1;
873
+ W = !1;
866
874
  }
867
875
  }
868
876
  }
869
- function ot() {
870
- return j;
877
+ function ct() {
878
+ return J;
871
879
  }
872
- function at(r, t, e, i = !1) {
880
+ function dt(r, t, e, i = !1) {
873
881
  const n = u();
874
882
  new le(n.apiKey).identify(r, t, e, i);
875
883
  }
876
- function ct(r, t = {}, e, i = !1) {
884
+ function ut(r, t = {}, e, i = !1) {
877
885
  const n = u();
878
886
  new le(n.apiKey).addOrUpdateMetadata(r, t, e, i);
879
887
  }
880
- let z = null;
881
- function dt(r, t, e, i) {
888
+ let B = null;
889
+ function lt(r, t, e, i) {
882
890
  const n = function(...o) {
883
891
  const d = ae(), s = d?.sfDebug || !1;
884
892
  s && console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${e}::${t}`);
@@ -889,7 +897,7 @@ function dt(r, t, e, i) {
889
897
  if (D) return process.env.SF_DEBUG === "true" && console.log(`[FuncSpan] Using HTTP header override for ${m}::${I}`), D;
890
898
  }
891
899
  try {
892
- return xe(m, I);
900
+ return Ke(m, I);
893
901
  } catch {
894
902
  return { sample_rate: process.env.SF_FUNCSPAN_SAMPLE_RATE ? parseFloat(process.env.SF_FUNCSPAN_SAMPLE_RATE) : 1, capture_arguments: !0, capture_return_value: !0, arg_limit_mb: 1, return_limit_mb: 1, enable_sampling: !1, autocapture_all_child_functions: !1, capture_sf_veritas: !1, parse_json_strings: !1 };
895
903
  }
@@ -897,36 +905,36 @@ function dt(r, t, e, i) {
897
905
  if (s && console.log(`[FuncSpan] Config for ${e}::${t}:`, c), c.enable_sampling && c.sample_rate < 1 && Math.random() > c.sample_rate) return s && console.log(`[FuncSpan] Skipping ${t} due to sampling`), r.apply(this, o);
898
906
  if (c.sample_rate === 0) return s && console.log(`[FuncSpan] Skipping ${t} - sample_rate is 0.0`), r.apply(this, o);
899
907
  s && console.log(`[FuncSpan] Capturing function span for ${t}`);
900
- const a = V.getInstance(), l = a.getCurrentFunctionSpanId(), g = oe();
908
+ const a = j.getInstance(), l = a.getCurrentFunctionSpanId(), g = oe();
901
909
  a.setCurrentFunctionSpanId(g);
902
910
  const f = process.hrtime.bigint(), h = Date.now();
903
911
  let p = null;
904
912
  c.capture_arguments && (p = {}, i.paramNames.forEach((m, I) => {
905
913
  I < o.length && (p[m] = o[I]);
906
- }), p && c.arg_limit_mb > 0 && (p = M(p, c.arg_limit_mb)));
914
+ }), p && c.arg_limit_mb > 0 && (p = H(p, c.arg_limit_mb)));
907
915
  try {
908
916
  const m = r.apply(this, o);
909
917
  if (m && typeof m.then == "function") return l ? a.setCurrentFunctionSpanId(l) : a.clearCurrentFunctionSpanId(), m.then((b) => {
910
- const S = process.hrtime.bigint(), N = Date.now(), P = Number(S - f);
911
- let X = null;
912
- return c.capture_return_value && c.return_limit_mb > 0 && (X = M(b, c.return_limit_mb)), A({ functionName: t, filePath: e, metadata: i, args: p, result: X, error: null, duration: N - h, durationNs: P, startTimeNs: f.toString(), async: !0, spanId: g, parentSpanId: l, pid: process.pid, threadId: L }), b;
918
+ const S = process.hrtime.bigint(), F = Date.now(), w = Number(S - f);
919
+ let Q = null;
920
+ return c.capture_return_value && c.return_limit_mb > 0 && (Q = H(b, c.return_limit_mb)), L({ functionName: t, filePath: e, metadata: i, args: p, result: Q, error: null, duration: F - h, durationNs: w, startTimeNs: f.toString(), async: !0, spanId: g, parentSpanId: l, pid: process.pid, threadId: O }), b;
913
921
  }, (b) => {
914
- const S = process.hrtime.bigint(), N = Date.now(), P = Number(S - f);
915
- throw A({ functionName: t, filePath: e, metadata: i, args: p, result: null, error: b?.message || String(b), duration: N - h, durationNs: P, startTimeNs: f.toString(), async: !0, spanId: g, parentSpanId: l, pid: process.pid, threadId: L }), b;
922
+ const S = process.hrtime.bigint(), F = Date.now(), w = Number(S - f);
923
+ throw L({ functionName: t, filePath: e, metadata: i, args: p, result: null, error: b?.message || String(b), duration: F - h, durationNs: w, startTimeNs: f.toString(), async: !0, spanId: g, parentSpanId: l, pid: process.pid, threadId: O }), b;
916
924
  });
917
925
  const I = process.hrtime.bigint(), v = Date.now(), D = Number(I - f);
918
926
  let $ = null;
919
- return c.capture_return_value && c.return_limit_mb > 0 && ($ = M(m, c.return_limit_mb)), A({ functionName: t, filePath: e, metadata: i, args: p, result: $, error: null, duration: v - h, durationNs: D, startTimeNs: f.toString(), async: !1, spanId: g, parentSpanId: l, pid: process.pid, threadId: L }), l ? a.setCurrentFunctionSpanId(l) : a.clearCurrentFunctionSpanId(), m;
927
+ return c.capture_return_value && c.return_limit_mb > 0 && ($ = H(m, c.return_limit_mb)), L({ functionName: t, filePath: e, metadata: i, args: p, result: $, error: null, duration: v - h, durationNs: D, startTimeNs: f.toString(), async: !1, spanId: g, parentSpanId: l, pid: process.pid, threadId: O }), l ? a.setCurrentFunctionSpanId(l) : a.clearCurrentFunctionSpanId(), m;
920
928
  } catch (m) {
921
929
  const I = process.hrtime.bigint(), v = Date.now(), D = Number(I - f);
922
- throw A({ functionName: t, filePath: e, metadata: i, args: p, result: null, error: m?.message || String(m), duration: v - h, durationNs: D, startTimeNs: f.toString(), async: !1, spanId: g, parentSpanId: l, pid: process.pid, threadId: L }), l ? a.setCurrentFunctionSpanId(l) : a.clearCurrentFunctionSpanId(), m;
930
+ throw L({ functionName: t, filePath: e, metadata: i, args: p, result: null, error: m?.message || String(m), duration: v - h, durationNs: D, startTimeNs: f.toString(), async: !1, spanId: g, parentSpanId: l, pid: process.pid, threadId: O }), l ? a.setCurrentFunctionSpanId(l) : a.clearCurrentFunctionSpanId(), m;
923
931
  }
924
932
  };
925
933
  Object.defineProperty(n, "name", { value: t, writable: !1 });
926
934
  for (const o in r) r.hasOwnProperty(o) && (n[o] = r[o]);
927
935
  return n;
928
936
  }
929
- function A(r) {
937
+ function L(r) {
930
938
  const t = ae(), e = t?.sfDebug || !1;
931
939
  e && console.log("[FuncSpan] captureSpanData called for:", { function: r.functionName, file: r.filePath, duration: `${r.duration}ms`, async: r.async, error: r.error, spanId: r.spanId });
932
940
  const i = { functionName: r.functionName, filePath: r.filePath, metadata: r.metadata, args: r.args, result: r.result, error: r.error, duration: r.duration, durationNs: r.durationNs, async: r.async, spanId: r.spanId, parentSpanId: r.parentSpanId };
@@ -936,44 +944,44 @@ function A(r) {
936
944
  if (n) try {
937
945
  const o = n === "true" || n === "1" ? "funcspans.jsonl" : n, d = Date.now(), s = process.hrtime.bigint(), c = BigInt(r.startTimeNs), a = Number(s - c) / 1e6, l = new Date(d - a).toISOString(), g = JSON.stringify({ timestamp: l, functionName: r.functionName, filePath: r.filePath, line: r.metadata.line, column: r.metadata.column, duration: r.duration, durationNs: r.durationNs, startTimeNs: r.startTimeNs, arguments: r.args, returnValue: r.error ? { error: String(r.error) } : r.result, spanId: r.spanId, parentSpanId: r.parentSpanId, async: r.async, pid: r.pid, threadId: r.threadId }) + `
938
946
  `;
939
- De(o, g, "utf-8");
947
+ Ee(o, g, "utf-8");
940
948
  } catch (o) {
941
949
  console.error("[FuncSpan] Error writing to JSONL file:", o);
942
950
  }
943
951
  if (e && console.log("[FuncSpan] Sending function span to transmitter:", i), process.env.SF_FUNCSPAN_SKIP_BACKEND !== "true") try {
944
- (z || (z = new Ie()), z).send([i]), e && console.log("[FuncSpan] Function span sent successfully");
952
+ (B || (B = new $e()), B).send([i]), e && console.log("[FuncSpan] Function span sent successfully");
945
953
  } catch (o) {
946
954
  e && console.error("[FuncSpan] Error sending function span:", o);
947
955
  }
948
956
  }
949
- function ut(r) {
957
+ function pt(r) {
950
958
  return !!r.includes("captureFunctionSpan(") || !!r.includes("@sailfish-ai/sf-veritas") || !(!r.includes("/* @sailfish-instrumented */") && !r.includes("// @sailfish-instrumented"));
951
959
  }
952
960
  export {
953
- V as ContextManager,
954
- ct as addOrUpdateMetadata,
955
- dt as captureFunctionSpan,
956
- ht as clearFuncspanOverride,
957
- H as getCurrentFunctionSpanId,
958
- ye as getDefaultConfig,
959
- ue as getEnvConfig,
961
+ j as ContextManager,
962
+ ut as addOrUpdateMetadata,
963
+ lt as captureFunctionSpan,
964
+ yt as clearFuncspanOverride,
965
+ q as getCurrentFunctionSpanId,
966
+ ue as getDefaultConfig,
967
+ Ie as getEnvConfig,
960
968
  ce as getFuncspanOverride,
961
- xe as getGlobalConfig,
962
- at as identify,
963
- Me as initializeConfigLoader,
964
- je as initializeWorkerPoolPatching,
965
- ut as isAlreadyInstrumented,
966
- Ge as isConfigLoaderInitialized,
967
- St as isProductionEnvironment,
968
- It as isRuntimeModeEnabled,
969
- ot as isSetupInterceptorsInitialized,
970
- Ve as isWorkerPoolInitialized,
969
+ Ke as getGlobalConfig,
970
+ dt as identify,
971
+ Ge as initializeConfigLoader,
972
+ Qe as initializeWorkerPoolPatching,
973
+ pt as isAlreadyInstrumented,
974
+ We as isConfigLoaderInitialized,
975
+ vt as isProductionEnvironment,
976
+ $t as isRuntimeModeEnabled,
977
+ ct as isSetupInterceptorsInitialized,
978
+ Xe as isWorkerPoolInitialized,
971
979
  de as parseHeaderOverride,
972
- gt as runWithContext,
973
- mt as setFuncspanOverride,
974
- _t as setSkipTypeScriptPlugin,
975
- st as setupInterceptors,
976
- vt as shouldEnableRuntimeHooks,
977
- bt as transformFunctionSpans,
978
- Nt as transformFunctionSpansSync
980
+ ht as runWithContext,
981
+ St as setFuncspanOverride,
982
+ Ft as setSkipTypeScriptPlugin,
983
+ at as setupInterceptors,
984
+ _t as shouldEnableRuntimeHooks,
985
+ Nt as transformFunctionSpans,
986
+ Dt as transformFunctionSpansSync
979
987
  };