@sailfish-ai/sf-veritas 0.2.19 → 0.2.21

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,30 +1,32 @@
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, C as V, D as ye, v as W, b as H, c as Se, d as ve, a as de } from "./contextManager-RxrMXs5c.js";
5
+ import { r as It } from "./contextManager-RxrMXs5c.js";
6
+ import { B as T, n as w, f as Ie, g as B, p as j, a as le, b as $e, m as R, c as A, i as Y, d as _e, e as U, t as M, F as be } from "./workerPoolSpanCapture-DVYmzgbN.js";
7
+ import { h as _t, s as bt } from "./workerPoolSpanCapture-DVYmzgbN.js";
8
+ import { a as Fe, C as Ne, i as b, b as De, c as ue, d as we, e as Pe } from "./runtimeConfig-CB57auSb.js";
9
+ import { f as Nt, g as Dt, s as wt } from "./runtimeConfig-CB57auSb.js";
10
10
  import { createRequire as Ee } from "node:module";
11
11
  import * as Te from "fs";
12
- import { readFileSync as Ce, appendFileSync as Ue } from "fs";
13
- import { s as Re } from "./source-map-Cr6YkjTd.js";
14
- import * as X from "fs/promises";
15
- import * as N from "path";
16
- import { glob as Le } from "glob";
17
- import { threadId as L } from "worker_threads";
18
- import { s as wt, t as Pt, a as Et } from "./funcSpanTransformer-S_WeAt_m.js";
12
+ import { readFileSync as Ce, appendFileSync as Re } from "fs";
13
+ import E from "http";
14
+ import O from "https";
15
+ import { s as Ue } from "./source-map-Cr6YkjTd.js";
16
+ import * as Z from "fs/promises";
17
+ import * as D from "path";
18
+ import { glob as Oe } from "glob";
19
+ import { threadId as k } from "worker_threads";
20
+ import { s as Et, t as Tt, a as Ct } from "./funcSpanTransformer-S_WeAt_m.js";
19
21
  class C extends T {
20
22
  constructor() {
21
23
  super(), this.setOperationName("IdentifyServiceDetails");
22
24
  }
23
25
  async doSend(t) {
24
- if (!u().serviceIdentificationReceived) try {
26
+ if (!g().serviceIdentificationReceived) try {
25
27
  this.send();
26
28
  } catch (e) {
27
- u().sfDebug && console.error(" Error during service identification:", e);
29
+ g().sfDebug && console.error(" Error during service identification:", e);
28
30
  }
29
31
  }
30
32
  async send() {
@@ -43,6 +45,9 @@ class C extends T {
43
45
  $gitRepo: String,
44
46
  $gitProvider: String,
45
47
  $serviceDisplayName: String,
48
+ $framework: String,
49
+ $additionalFrameworks: JSON,
50
+ $serviceRole: String,
46
51
  ) {
47
52
  ${this.queryName}(
48
53
  apiKey: $apiKey,
@@ -58,13 +63,16 @@ class C extends T {
58
63
  gitRepo: $gitRepo,
59
64
  gitProvider: $gitProvider,
60
65
  serviceDisplayName: $serviceDisplayName,
66
+ framework: $framework,
67
+ additionalFrameworks: $additionalFrameworks,
68
+ serviceRole: $serviceRole,
61
69
  )
62
70
  }
63
- `, e = this.getVariables({ serviceIdentifier: u().serviceIdentifier, serviceVersion: u().serviceVersion, library: u().packageLibraryType, version: u().version, serviceAdditionalMetadata: u().serviceAdditionalMetadata, gitSha: u().gitSha || "", gitOrg: u().gitOrg || void 0, gitRepo: u().gitRepo || void 0, gitProvider: u().gitProvider || void 0, serviceDisplayName: u().serviceDisplayName || void 0 });
64
- P(this.endpoint, this.operationName, t, e);
71
+ `, e = g(), i = this.getVariables({ serviceIdentifier: e.serviceIdentifier, serviceVersion: e.serviceVersion, library: e.packageLibraryType, version: e.version, serviceAdditionalMetadata: e.serviceAdditionalMetadata, gitSha: e.gitSha || "", gitOrg: e.gitOrg || void 0, gitRepo: e.gitRepo || void 0, gitProvider: e.gitProvider || void 0, serviceDisplayName: e.serviceDisplayName || void 0, framework: e.framework || void 0, additionalFrameworks: e.additionalFrameworks.length > 0 ? e.additionalFrameworks : void 0, serviceRole: e.serviceRole || void 0 });
72
+ w(this.endpoint, this.operationName, t, i);
65
73
  }
66
74
  }
67
- class Oe extends T {
75
+ class ke extends T {
68
76
  constructor() {
69
77
  super();
70
78
  y(this, "serviceIdentifier", new C());
@@ -73,18 +81,18 @@ class Oe extends T {
73
81
  async sendAppIdentifier() {
74
82
  this.serviceIdentifier.doSend({});
75
83
  }
76
- async doSend(e, i, n, o) {
77
- this.sendAppIdentifier(), this.send(e, i, n, o);
84
+ async doSend(e, i, n, s) {
85
+ this.sendAppIdentifier(), this.send(e, i, n, s);
78
86
  }
79
- async send(e, i, n, o) {
80
- if (!i && !o) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
81
- let d = [];
82
- if (!o) {
83
- const a = Fe(i);
84
- o = a.traitsJson, d = a.excludedFields;
87
+ async send(e, i, n, s) {
88
+ if (!i && !s) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
89
+ let l = [];
90
+ if (!s) {
91
+ const o = Fe(i);
92
+ s = o.traitsJson, l = o.excludedFields;
85
93
  }
86
- const s = this.getVariables({ userId: e, traitsJson: o, excludedFields: d, override: n, library: u().packageLibraryType, version: u().version });
87
- P(this.endpoint, this.operationName, this.getQuery(), s);
94
+ const a = this.getVariables({ userId: e, traitsJson: s, excludedFields: l, override: n, library: g().packageLibraryType, version: g().version });
95
+ w(this.endpoint, this.operationName, this.getQuery(), a);
88
96
  }
89
97
  getQuery() {
90
98
  return `
@@ -97,17 +105,17 @@ class Oe extends T {
97
105
  class pe {
98
106
  constructor(t) {
99
107
  y(this, "metadataTransmitter");
100
- this.apiKey = t, this.metadataTransmitter = new Oe();
108
+ this.apiKey = t, this.metadataTransmitter = new ke();
101
109
  }
102
110
  identify(t, e, i, n = !1) {
103
111
  e || i ? this.addOrUpdateMetadata(t, e, i, n) : this.addOrUpdateMetadata(t, {}, void 0, n);
104
112
  }
105
113
  addOrUpdateMetadata(t, e = {}, i, n = !1) {
106
114
  if (!e && !i) throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');
107
- 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);
115
+ g().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), g().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", t, e, i), this.metadataTransmitter.doSend(t, e, n, i);
108
116
  }
109
117
  }
110
- class J extends T {
118
+ class Q extends T {
111
119
  constructor() {
112
120
  super();
113
121
  y(this, "serviceIdentifier", new C());
@@ -121,9 +129,9 @@ class J extends T {
121
129
  async send(e) {
122
130
  try {
123
131
  const i = Array.isArray(e) ? e : [e, "default", null, null], n = this.getVariables({ contents: i[0], level: i[1], sourceFile: i[2] || void 0, sourceLine: i[3] || void 0 });
124
- P(this.endpoint, this.operationName, this.getQuery(), n);
132
+ w(this.endpoint, this.operationName, this.getQuery(), n);
125
133
  } catch (i) {
126
- u().sfDebug && console.error("🚨 Error in send():", i);
134
+ g().sfDebug && console.error("🚨 Error in send():", i);
127
135
  }
128
136
  }
129
137
  getQuery() {
@@ -154,7 +162,7 @@ class J extends T {
154
162
  `;
155
163
  }
156
164
  }
157
- class Ae extends T {
165
+ class Le extends T {
158
166
  constructor() {
159
167
  super();
160
168
  y(this, "serviceIdentifier", new C());
@@ -175,9 +183,9 @@ class Ae extends T {
175
183
  this.sendAppIdentifier(), this.send(e, i);
176
184
  }
177
185
  async send(e, i) {
178
- u().sfDebug && console.log(" SENDING EXCEPTION...");
179
- const n = JSON.stringify(Ne.encode(i)), o = this.normalizedSupplementalForGraphQL(), d = this.getVariables({ exceptionMessage: e, traceJson: n, reentrancyGuardPreactive: !1, library: u().packageLibraryType, version: u().version, ...o });
180
- P(this.endpoint, this.operationName, this.getQuery(), d);
186
+ g().sfDebug && console.log(" SENDING EXCEPTION...");
187
+ const n = JSON.stringify(Ne.encode(i)), s = this.normalizedSupplementalForGraphQL(), l = this.getVariables({ exceptionMessage: e, traceJson: n, reentrancyGuardPreactive: !1, library: g().packageLibraryType, version: g().version, ...s });
188
+ w(this.endpoint, this.operationName, this.getQuery(), l);
181
189
  }
182
190
  getQuery() {
183
191
  return `
@@ -211,51 +219,51 @@ class Ae extends T {
211
219
  `;
212
220
  }
213
221
  }
214
- const Y = "getting request source code";
215
- var k = ((r) => (r.UNKNOWN = "unknown", r.ANONYMOUS = "anonymous", r.NOT_CAPTURED = "not captured", r))(k || {});
216
- const M = "http:", x = "https:", ke = Ee(import.meta.url);
217
- let Z = !1;
222
+ const ee = "getting request source code";
223
+ var q = ((r) => (r.UNKNOWN = "unknown", r.ANONYMOUS = "anonymous", r.NOT_CAPTURED = "not captured", r))(q || {});
224
+ const te = "http:", Ae = Ee(import.meta.url);
225
+ let ne = !1;
218
226
  function qe() {
219
- const r = u().sfDebug;
220
- if (Z) return void (r && _("[patchNodeHttpInbound] Already installed, skipping."));
227
+ const r = g().sfDebug;
228
+ if (ne) return void (r && b("[patchNodeHttpInbound] Already installed, skipping."));
221
229
  let t;
222
- Z = !0;
230
+ ne = !0;
223
231
  try {
224
- t = ke("node:http"), r && _("[patchNodeHttpInbound] node:http required successfully.");
232
+ t = Ae("node:http"), r && b("[patchNodeHttpInbound] node:http required successfully.");
225
233
  } catch (n) {
226
234
  return void De("Failed to require node:http:", n);
227
235
  }
228
- if (!t?.Server?.prototype) return void (r && _("[patchNodeHttpInbound] http.Server.prototype not found."));
236
+ if (!t?.Server?.prototype) return void (r && b("[patchNodeHttpInbound] http.Server.prototype not found."));
229
237
  const e = t.Server.prototype, i = e.emit;
230
- i && !e.__sf_inbound_patched__ ? (Object.defineProperty(e, "__sf_inbound_patched__", { value: !0, enumerable: !1, configurable: !1, writable: !1 }), r && _("[patchNodeHttpInbound] Patching http.Server.prototype.emit."), e.emit = function(n, ...o) {
231
- if (n !== "request") return r && _(`[patchNodeHttpInbound] Passing through event: ${n}`), i.call(this, n, ...o);
232
- const d = o[0], s = o[1], a = (function(p) {
233
- const f = {};
234
- if (!p) return f;
235
- for (const [I, v] of Object.entries(p)) v != null && (Array.isArray(v) ? f[I.toLowerCase()] = v.join(", ") : f[I.toLowerCase()] = String(v));
236
- return f;
237
- })(d?.headers), c = a["x-sf3-rid"], l = a["x-sf3-functionspancaptureoverride"];
238
- r && (_("[patchNodeHttpInbound] Intercepted request event."), _("[patchNodeHttpInbound] Inbound headers:", a), _("[patchNodeHttpInbound] Trace header:", c), _("[patchNodeHttpInbound] FuncSpan override header:", l));
239
- const g = j.getInstance();
240
- g.setTraceId(c);
241
- const h = g.getTraceId();
242
- r && _("[patchNodeHttpInbound] Context traceId set:", h);
243
- const m = () => g.runWith({ inboundHeaders: a, ...c ? { traceId: c } : {} }, () => {
244
- c && g.setTraceId(c), r && _("[patchNodeHttpInbound] Running request handler in context.");
245
- const p = () => {
246
- r && _("[patchNodeHttpInbound] Response finished/closed for traceId:", g.getTraceId());
238
+ i && !e.__sf_inbound_patched__ ? (Object.defineProperty(e, "__sf_inbound_patched__", { value: !0, enumerable: !1, configurable: !1, writable: !1 }), r && b("[patchNodeHttpInbound] Patching http.Server.prototype.emit."), e.emit = function(n, ...s) {
239
+ if (n !== "request") return r && b(`[patchNodeHttpInbound] Passing through event: ${n}`), i.call(this, n, ...s);
240
+ const l = s[0], a = s[1], o = (function(u) {
241
+ const h = {};
242
+ if (!u) return h;
243
+ for (const [v, I] of Object.entries(u)) I != null && (Array.isArray(I) ? h[v.toLowerCase()] = I.join(", ") : h[v.toLowerCase()] = String(I));
244
+ return h;
245
+ })(l?.headers), d = o["x-sf3-rid"], p = o["x-sf3-functionspancaptureoverride"];
246
+ r && (b("[patchNodeHttpInbound] Intercepted request event."), b("[patchNodeHttpInbound] Inbound headers:", o), b("[patchNodeHttpInbound] Trace header:", d), b("[patchNodeHttpInbound] FuncSpan override header:", p));
247
+ const c = V.getInstance();
248
+ c.setTraceId(d);
249
+ const f = c.getTraceId();
250
+ r && b("[patchNodeHttpInbound] Context traceId set:", f);
251
+ const m = () => c.runWith({ inboundHeaders: o, ...d ? { traceId: d } : {} }, () => {
252
+ d && c.setTraceId(d), r && b("[patchNodeHttpInbound] Running request handler in context.");
253
+ const u = () => {
254
+ r && b("[patchNodeHttpInbound] Response finished/closed for traceId:", c.getTraceId());
247
255
  };
248
- return s.on("finish", p), s.on("close", p), i.call(this, n, d, s);
256
+ return a.on("finish", u), a.on("close", u), i.call(this, n, l, a);
249
257
  });
250
- if (!l) return m();
258
+ if (!p) return m();
251
259
  try {
252
- return ve.run(l, () => m());
260
+ return Ie.run(p, () => m());
253
261
  } catch {
254
262
  return m();
255
263
  }
256
- }) : r && _("[patchNodeHttpInbound] Already patched, skipping.");
264
+ }) : r && b("[patchNodeHttpInbound] Already patched, skipping.");
257
265
  }
258
- class He extends J {
266
+ class He extends Q {
259
267
  constructor() {
260
268
  super(), this.setOperationName("DomainsToNotPassHeaderTo");
261
269
  }
@@ -276,7 +284,7 @@ class He extends J {
276
284
  )
277
285
  }
278
286
  `, i = { apiKey: this.apiKey, serviceUuid: this.serviceUUID, domains: t };
279
- P(this.endpoint, this.operationName, e, i);
287
+ w(this.endpoint, this.operationName, e, i);
280
288
  }
281
289
  }
282
290
  class Me extends T {
@@ -292,8 +300,8 @@ class Me extends T {
292
300
  this.sendAppIdentifier(), this.send(e);
293
301
  }
294
302
  async send(e) {
295
- const { name: i, column: n, line: o, entrypoint: d, retryWithoutTraceId: s } = e, a = this.getVariables({ name: i, column: n, line: o, entrypoint: d, retryWithoutTraceId: s });
296
- P(this.endpoint, this.operationName, this.getQuery(), a);
303
+ const { name: i, column: n, line: s, entrypoint: l, retryWithoutTraceId: a } = e, o = this.getVariables({ name: i, column: n, line: s, entrypoint: l, retryWithoutTraceId: a });
304
+ w(this.endpoint, this.operationName, this.getQuery(), o);
297
305
  }
298
306
  getQuery() {
299
307
  return `
@@ -347,10 +355,10 @@ class xe extends T {
347
355
  }
348
356
  async send(e) {
349
357
  const i = { data: { ...e } };
350
- await P(this.endpoint, this.operationName, this.getQuery(), i);
358
+ await w(this.endpoint, this.operationName, this.getQuery(), i);
351
359
  }
352
360
  }
353
- const G = [400, 403];
361
+ const x = [400, 403];
354
362
  class Ge {
355
363
  constructor(t = []) {
356
364
  y(this, "HEADER_TRACING", "X-Sf3-Rid");
@@ -358,17 +366,17 @@ class Ge {
358
366
  y(this, "HEADER_PRINT_GUARD", "reentrancy_guard_print_preactive");
359
367
  y(this, "HEADER_EXCEPTION_GUARD", "reentrancy_guard_exception_preactive");
360
368
  y(this, "contextManager");
361
- this.contextManager = j.getInstance(), t?.forEach((e) => {
369
+ this.contextManager = V.getInstance(), t?.forEach((e) => {
362
370
  typeof e == "string" && e.trim() && this.contextManager.getExcludedDomains().add(e);
363
- }), u().sfDebug && console.log("[RequestInterceptor] Initialized with static excluded domains.");
371
+ }), g().sfDebug && console.log("[RequestInterceptor] Initialized with static excluded domains.");
364
372
  }
365
373
  extractIdsFromTraceHeader(t, e = this.HEADER_TRACING) {
366
374
  let i;
367
375
  if (t instanceof Headers) i = t.get(e) ?? void 0;
368
376
  else {
369
- const o = e.toLowerCase();
370
- for (const [d, s] of Object.entries(t)) if (d.toLowerCase() === o) {
371
- i = s;
377
+ const s = e.toLowerCase();
378
+ for (const [l, a] of Object.entries(t)) if (l.toLowerCase() === s) {
379
+ i = a;
372
380
  break;
373
381
  }
374
382
  }
@@ -379,43 +387,43 @@ class Ge {
379
387
  parseStackFrame(t) {
380
388
  const e = /\((.*):(\d+):(\d+)\)$/.exec(t.trim());
381
389
  if (!e) return null;
382
- const [, i, n, o] = e;
383
- return { filePath: i, line: parseInt(n, 10), column: parseInt(o, 10) };
390
+ const [, i, n, s] = e;
391
+ return { filePath: i, line: parseInt(n, 10), column: parseInt(s, 10) };
384
392
  }
385
393
  async getOriginalPosition(t, e, i) {
386
394
  let n = { source: t, line: e, column: i, name: null };
387
395
  if (t.includes("://")) return { originalPos: n };
388
- const o = t + ".map";
396
+ const s = t + ".map";
389
397
  try {
390
- const d = JSON.parse(Ce(o, "utf-8"));
391
- let s = (await new Re.SourceMapConsumer(d)).originalPositionFor({ line: e, column: i });
392
- s.source && (n = s);
393
- } catch (d) {
394
- u().sfDebug && console.error(`Could not read/parse map file at ${o}:`, d);
398
+ const l = JSON.parse(Ce(s, "utf-8"));
399
+ let a = (await new Ue.SourceMapConsumer(l)).originalPositionFor({ line: e, column: i });
400
+ a.source && (n = a);
401
+ } catch (l) {
402
+ g().sfDebug && console.error(`Could not read/parse map file at ${s}:`, l);
395
403
  }
396
404
  return { originalPos: n };
397
405
  }
398
406
  captureFirstUserLines(t, e = 10, i = !1) {
399
- const n = u().sfDebug ? 10 : e, o = Error.stackTraceLimit;
400
- Error.stackTraceLimit = Math.max(o, n);
401
- const d = new Error(Y);
402
- Y in Error && Error.captureStackTrace(d, this.captureFirstUserLines);
403
- const s = le(d.stack);
404
- Error.stackTraceLimit = o;
405
- const a = s.split(`
406
- `).slice(1), c = [];
407
- for (const l of a)
408
- if (!(l.includes("node:internal") || l.includes("internal/modules") || l.includes("internal/process") || l.includes("node_modules") || l.includes(".next/server/chunks") || l.includes("RequestInterceptor") || l.includes("contextManager") || l.includes("setupConfig")) && (c.push(l.trim()), c.length >= e)) break;
409
- for (const l of c) {
410
- const g = this.parseStackFrame(l);
411
- g ? (async () => {
412
- const { originalPos: h } = await this.getOriginalPosition(g.filePath, g.line, g.column);
413
- if (h) {
414
- u().sfDebug && console.log("[RequestInterceptor] First user code line:", h);
415
- const m = { line: h.line?.toString() || k.UNKNOWN, column: h.column?.toString() || k.NOT_CAPTURED, name: h.name || k.NOT_CAPTURED, entrypoint: h.source, retryWithoutTraceId: i };
407
+ const n = g().sfDebug ? 10 : e, s = Error.stackTraceLimit;
408
+ Error.stackTraceLimit = Math.max(s, n);
409
+ const l = new Error(ee);
410
+ ee in Error && Error.captureStackTrace(l, this.captureFirstUserLines);
411
+ const a = ue(l.stack);
412
+ Error.stackTraceLimit = s;
413
+ const o = a.split(`
414
+ `).slice(1), d = [];
415
+ for (const p of o)
416
+ if (!(p.includes("node:internal") || p.includes("internal/modules") || p.includes("internal/process") || p.includes("node_modules") || p.includes(".next/server/chunks") || p.includes("RequestInterceptor") || p.includes("contextManager") || p.includes("setupConfig")) && (d.push(p.trim()), d.length >= e)) break;
417
+ for (const p of d) {
418
+ const c = this.parseStackFrame(p);
419
+ c ? (async () => {
420
+ const { originalPos: f } = await this.getOriginalPosition(c.filePath, c.line, c.column);
421
+ if (f) {
422
+ g().sfDebug && console.log("[RequestInterceptor] First user code line:", f);
423
+ const m = { line: f.line?.toString() || q.UNKNOWN, column: f.column?.toString() || q.NOT_CAPTURED, name: f.name || q.NOT_CAPTURED, entrypoint: f.source, retryWithoutTraceId: i };
416
424
  t.doSend(m);
417
425
  }
418
- })() : u().sfDebug && console.error("Could not parse stack line:", l);
426
+ })() : g().sfDebug && console.error("Could not parse stack line:", p);
419
427
  }
420
428
  }
421
429
  addReentrancyGuardHeaders(t) {
@@ -426,118 +434,134 @@ class Ge {
426
434
  }
427
435
  addTracingHeaders(t, e) {
428
436
  const i = new URL(e).hostname, n = this.shouldPropagateHeaders(i);
429
- return n ? this.addTracingHeader(t, e) : u().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${i}`), n;
437
+ return n ? this.addTracingHeader(t, e) : g().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${i}`), n;
430
438
  }
431
439
  addTracingHeader(t, e) {
432
- const i = ce();
440
+ const i = B();
433
441
  if (i) {
434
- const s = de(i);
435
- if (s && s.sample_rate === 0) return void (u().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${e}`));
442
+ const a = j(i);
443
+ if (a && a.sample_rate === 0) return void (g().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${e}`));
436
444
  }
437
- const n = this.contextManager.getOrSetSfTraceId(), o = this.contextManager.getOrSetPageVisitUUID(), d = oe();
438
- t.set(this.HEADER_TRACING, `${n}/${o}/${d}`), u().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${e}`);
445
+ const n = this.contextManager.getOrSetSfTraceId(), s = this.contextManager.getOrSetPageVisitUUID(), l = W();
446
+ t.set(this.HEADER_TRACING, `${n}/${s}/${l}`), g().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${e}`);
439
447
  }
440
448
  patchFetch(t, e) {
441
449
  const i = globalThis.fetch;
442
- typeof i == "function" ? globalThis.fetch = async (n, o) => {
443
- const d = new Headers(o?.headers);
444
- if (d.get(this.HEADER_LOG_GUARD) === "true" || d.get(this.HEADER_PRINT_GUARD) === "true" || d.get(this.HEADER_EXCEPTION_GUARD) === "true") return i(n, o);
450
+ typeof i == "function" ? globalThis.fetch = async (n, s) => {
451
+ const l = new Headers(s?.headers);
452
+ if (l.get(this.HEADER_LOG_GUARD) === "true" || l.get(this.HEADER_PRINT_GUARD) === "true" || l.get(this.HEADER_EXCEPTION_GUARD) === "true") return i(n, s);
445
453
  this.captureFirstUserLines(t);
446
- const s = Date.now();
447
- let a;
448
- typeof n == "string" || n instanceof URL ? a = n.toString() : n instanceof Request ? (a = n.url, n.headers.forEach((p, f) => {
449
- d.set(f, p);
450
- })) : u().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), u().sfDebug && console.log("[RequestInterceptor] Fetching request to:", a);
451
- const c = new URL(a).hostname, l = new Headers(d), g = this.addTracingHeaders(d, a), h = { ...o, headers: d };
454
+ const a = Date.now();
455
+ let o;
456
+ typeof n == "string" || n instanceof URL ? o = n.toString() : n instanceof Request ? (o = n.url, n.headers.forEach((u, h) => {
457
+ l.set(h, u);
458
+ })) : g().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), g().sfDebug && console.log("[RequestInterceptor] Fetching request to:", o);
459
+ const d = new URL(o).hostname, p = new Headers(l), c = this.addTracingHeaders(l, o), f = { ...s, headers: l };
452
460
  let m;
453
461
  try {
454
- let p = !1;
455
- this.addTracingHeaders(l, a), m = await i(a, h), g && G.includes(m.status) ? (m = await i(a, { ...o, headers: l }), p = !0, this.captureFirstUserLines(t, 10, p)) : this.contextManager.addSupportedDomains(c);
456
- const f = Date.now();
457
- u().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${a}, Status: ${m.status}, Duration: ${f - s}ms`);
458
- 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: f.toString(), responseCode: m.status, success: !0, error: null, url: a, method: h.method || "GET", retryWithoutTraceId: p, parentSpanId: q() };
459
- if ($.captureRequestHeaders) {
460
- const S = {};
461
- d.forEach((F, E) => {
462
- S[E] = F;
463
- }), b.requestHeaders = S;
462
+ let u = !1;
463
+ this.addTracingHeaders(p, o), m = await i(o, f), c && x.includes(m.status) ? (m = await i(o, { ...s, headers: p }), u = !0, this.captureFirstUserLines(t, 10, u)) : this.contextManager.addSupportedDomains(d);
464
+ const h = Date.now();
465
+ g().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${o}, Status: ${m.status}, Duration: ${h - a}ms`);
466
+ const { sessionId: v, pageVisitId: I, requestId: _ } = this.extractIdsFromTraceHeader(l), S = g(), F = { apiKey: S.apiKey, requestId: _, pageVisitId: I, recordingSessionId: v, serviceUuid: S.serviceUUID, timestampStart: a.toString(), timestampEnd: h.toString(), responseCode: m.status, success: !0, error: null, url: o, method: f.method || "GET", retryWithoutTraceId: u, parentSpanId: H() };
467
+ if (S.captureRequestHeaders) {
468
+ const $ = {};
469
+ l.forEach((N, P) => {
470
+ $[P] = N;
471
+ }), F.requestHeaders = $;
464
472
  }
465
- if ($.captureResponseHeaders) {
466
- const S = {};
467
- m.headers.forEach((F, E) => {
468
- S[E] = F;
469
- }), b.responseHeaders = S;
473
+ if (S.captureResponseHeaders) {
474
+ const $ = {};
475
+ m.headers.forEach((N, P) => {
476
+ $[P] = N;
477
+ }), F.responseHeaders = $;
470
478
  }
471
- if ($.captureRequestBody && o?.body) try {
472
- const S = typeof o.body == "string" ? o.body : JSON.stringify(o.body);
473
- b.requestBody = S.length > $.requestBodyLimitBytes ? S.substring(0, $.requestBodyLimitBytes) + "...[truncated]" : S;
479
+ if (S.captureRequestBody && s?.body) try {
480
+ const $ = typeof s.body == "string" ? s.body : JSON.stringify(s.body);
481
+ F.requestBody = $.length > S.requestBodyLimitBytes ? $.substring(0, S.requestBodyLimitBytes) + "...[truncated]" : $;
474
482
  } catch {
475
483
  }
476
- if ($.captureResponseBody) try {
477
- const S = m.clone(), F = await S.text();
478
- b.responseBody = F.length > $.responseBodyLimitBytes ? F.substring(0, $.responseBodyLimitBytes) + "...[truncated]" : F;
484
+ if (S.captureResponseBody) try {
485
+ const $ = m.clone(), N = await $.text();
486
+ F.responseBody = N.length > S.responseBodyLimitBytes ? N.substring(0, S.responseBodyLimitBytes) + "...[truncated]" : N;
479
487
  } catch {
480
488
  }
481
- return e.doSend(b), m;
482
- } catch (p) {
483
- const f = Date.now();
484
- u().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${a}, Error: ${p}, Duration: ${f - s}ms`);
489
+ return e.doSend(F), m;
490
+ } catch (u) {
491
+ const h = Date.now();
492
+ g().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${o}, Error: ${u}, Duration: ${h - a}ms`);
493
+ }
494
+ } : g().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
495
+ }
496
+ setHeader(t, e, i) {
497
+ t instanceof Headers ? t.set(e, i) : t[e] = i;
498
+ }
499
+ addTracingHeadersToPlainObject(t, e) {
500
+ const i = new URL(e).hostname, n = this.shouldPropagateHeaders(i);
501
+ if (n) {
502
+ const s = B();
503
+ if (s) {
504
+ const d = j(s);
505
+ if (d && d.sample_rate === 0) return g().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${e}`), !1;
485
506
  }
486
- } : u().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
507
+ const l = this.contextManager.getOrSetSfTraceId(), a = this.contextManager.getOrSetPageVisitUUID(), o = W();
508
+ t[this.HEADER_TRACING] = `${l}/${a}/${o}`, g().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${e}`);
509
+ } else g().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${i}`);
510
+ return n;
487
511
  }
488
512
  patchHttp(t, e) {
489
- 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."));
490
- const i = w.request.bind(w), n = w.request.bind(w);
491
- w.request = function(o, d) {
492
- let s;
513
+ if (g().sfDebug && console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."), !E || typeof E.request != "function") return void (g().sfDebug && console.log("[RequestInterceptor] HTTP/HTTPS not available."));
514
+ const i = E.request.bind(E), n = O.request.bind(O), s = (o, d, p, c = te) => {
515
+ let f, m;
516
+ if (typeof o == "string" || o instanceof URL) {
517
+ const u = typeof o == "string" ? new URL(o) : o;
518
+ f = { ...typeof d == "object" && d !== null ? d : {}, protocol: u.protocol || c, hostname: u.hostname, port: u.port || void 0, path: u.pathname + u.search }, m = typeof d == "function" ? d : p;
519
+ } else f = { ...o }, f.protocol || (f.protocol = c), m = typeof d == "function" ? d : void 0;
520
+ return f.headers || (f.headers = {}), [f, m];
521
+ }, l = (o, d, p) => {
522
+ const [c, f] = s(o, d, p, te);
493
523
  try {
494
- if (typeof o == "string") {
495
- const c = new URL(o);
496
- s = { protocol: c.protocol || M, hostname: c.hostname, path: c.pathname + c.search, headers: {} };
497
- } else o instanceof URL ? s = { protocol: o.protocol || M, hostname: o.hostname, path: o.pathname + o.search, headers: {} } : (s = { ...o }, s.protocol || (s.protocol = M));
498
- if (s.headers) {
499
- const c = `${s.protocol}//${s.hostname}`;
500
- this.addTracingHeaders(s.headers, c), this.captureFirstUserLines(t);
501
- } else u().sfDebug && console.warn("[RequestInterceptor] No headers found in HTTP request options. Skipping header addition.");
502
- } catch (c) {
503
- throw u().sfDebug && console.error("[RequestInterceptor] Error while processing HTTP request options:", c), c;
524
+ const u = `${c.protocol}//${c.hostname}`;
525
+ this.addTracingHeadersToPlainObject(c.headers, u), this.captureFirstUserLines(t);
526
+ } catch (u) {
527
+ g().sfDebug && console.error("[RequestInterceptor] Error while processing HTTP request options:", u);
504
528
  }
505
- let a = !1;
506
- return i(s, (c) => {
507
- const l = `${s.protocol}//${s.hostname}`;
508
- if (s.headers && this.shouldPropagateHeaders(new URL(l).hostname) && G.includes(c.statusCode || 0)) {
509
- s.hostname;
510
- const p = { ...s, headers: { ...s.headers } };
511
- delete p.headers[this.HEADER_TRACING], i(p, d), a = !0, this.captureFirstUserLines(t, 10, a);
529
+ let m = !1;
530
+ return i(c, (u) => {
531
+ const h = `${c.protocol}//${c.hostname}`;
532
+ if (this.shouldPropagateHeaders(new URL(h).hostname) && x.includes(u.statusCode || 0)) {
533
+ const S = { ...c, headers: { ...c.headers } };
534
+ delete S.headers[this.HEADER_TRACING], i(S, f), m = !0, this.captureFirstUserLines(t, 10, m);
512
535
  }
513
- const { sessionId: g, pageVisitId: h, requestId: m } = this.extractIdsFromTraceHeader(s.headers);
514
- e.doSend({ apiKey: u().apiKey, requestId: m, pageVisitId: h, recordingSessionId: g, serviceUuid: u().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: c.statusCode || 0, success: !!c.statusCode && c.statusCode < 400, error: null, url: l, method: s.method || "GET", retryWithoutTraceId: a, parentSpanId: q() }), d?.(c);
536
+ const { sessionId: v, pageVisitId: I, requestId: _ } = this.extractIdsFromTraceHeader(c.headers);
537
+ e.doSend({ apiKey: g().apiKey, requestId: _, pageVisitId: I, recordingSessionId: v, serviceUuid: g().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: u.statusCode || 0, success: !!u.statusCode && u.statusCode < 400, error: null, url: h, method: c.method || "GET", retryWithoutTraceId: m, parentSpanId: H() }), f?.(u);
515
538
  });
516
- }, w.request = function(o, d) {
517
- let s;
539
+ }, a = (o, d, p) => {
540
+ const [c, f] = s(o, d, p, "https:");
518
541
  try {
519
- if (typeof o == "string") {
520
- const c = new URL(o);
521
- s = { protocol: c.protocol || x, hostname: c.hostname, path: c.pathname + c.search, headers: {} };
522
- } 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));
523
- if (s.headers) {
524
- const c = `${s.protocol}//${s.hostname}`;
525
- this.addTracingHeaders(s.headers, c);
526
- } else u().sfDebug && console.warn("[RequestInterceptor] No headers found in HTTPS request options. Skipping header addition.");
527
- } catch (c) {
528
- throw u().sfDebug && console.error("[RequestInterceptor] Error while processing HTTPS request options:", c), c;
542
+ const u = `${c.protocol}//${c.hostname}`;
543
+ this.addTracingHeadersToPlainObject(c.headers, u), this.captureFirstUserLines(t);
544
+ } catch (u) {
545
+ g().sfDebug && console.error("[RequestInterceptor] Error while processing HTTPS request options:", u);
529
546
  }
530
- let a = !1;
531
- return n(s, (c) => {
532
- const l = `${s.protocol}//${s.hostname}`;
533
- if (s.headers && this.shouldPropagateHeaders(new URL(l).hostname) && G.includes(c.statusCode || 0)) {
534
- const p = { ...s, headers: { ...s.headers } };
535
- delete p.headers[this.HEADER_TRACING], n(p, d), a = !0, this.captureFirstUserLines(t, 10, a);
547
+ let m = !1;
548
+ return n(c, (u) => {
549
+ const h = `${c.protocol}//${c.hostname}`;
550
+ if (this.shouldPropagateHeaders(new URL(h).hostname) && x.includes(u.statusCode || 0)) {
551
+ const S = { ...c, headers: { ...c.headers } };
552
+ delete S.headers[this.HEADER_TRACING], n(S, f), m = !0, this.captureFirstUserLines(t, 10, m);
536
553
  }
537
- const { sessionId: g, pageVisitId: h, requestId: m } = this.extractIdsFromTraceHeader(s.headers);
538
- e.doSend({ apiKey: u().apiKey, requestId: m, pageVisitId: h, recordingSessionId: g, serviceUuid: u().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: c.statusCode || 0, success: !!c.statusCode && c.statusCode < 400, error: null, url: l, method: s.method || "GET", retryWithoutTraceId: a, parentSpanId: q() }), d?.(c);
554
+ const { sessionId: v, pageVisitId: I, requestId: _ } = this.extractIdsFromTraceHeader(c.headers);
555
+ e.doSend({ apiKey: g().apiKey, requestId: _, pageVisitId: I, recordingSessionId: v, serviceUuid: g().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: u.statusCode || 0, success: !!u.statusCode && u.statusCode < 400, error: null, url: h, method: c.method || "GET", retryWithoutTraceId: m, parentSpanId: H() }), f?.(u);
539
556
  });
540
- }, u().sfDebug && console.log("✅ HTTP and HTTPS request methods patched globally.");
557
+ };
558
+ E.request = l, O.request = a, E.get = (o, d, p) => {
559
+ const c = l(o, d, p);
560
+ return c.end(), c;
561
+ }, O.get = (o, d, p) => {
562
+ const c = a(o, d, p);
563
+ return c.end(), c;
564
+ }, g().sfDebug && console.log("✅ HTTP and HTTPS request/get methods patched globally.");
541
565
  }
542
566
  tryPatch(t, e) {
543
567
  try {
@@ -549,7 +573,7 @@ class Ge {
549
573
  return [...this.contextManager.getExcludedDomains()];
550
574
  }
551
575
  }
552
- class Ke extends J {
576
+ class Ke extends Q {
553
577
  constructor() {
554
578
  super(), this.setOperationName("UpdateServiceDetails");
555
579
  }
@@ -574,6 +598,9 @@ class Ke extends J {
574
598
  $infrastructureDetails: JSON,
575
599
  $setupInterceptorsFile: String,
576
600
  $setupInterceptorsLine: Int,
601
+ $framework: String,
602
+ $additionalFrameworks: JSON,
603
+ $serviceRole: String,
577
604
  ) {
578
605
  ${this.queryName}(
579
606
  apiKey: $apiKey,
@@ -591,10 +618,13 @@ class Ke extends J {
591
618
  infrastructureDetails: $infrastructureDetails,
592
619
  setupInterceptorsFile: $setupInterceptorsFile,
593
620
  setupInterceptorsLine: $setupInterceptorsLine,
621
+ framework: $framework,
622
+ additionalFrameworks: $additionalFrameworks,
623
+ serviceRole: $serviceRole,
594
624
  )
595
625
  }
596
- `, e = u(), i = this.getVariables({ serviceIdentifier: e.serviceIdentifier, serviceVersion: e.serviceVersion, serviceAdditionalMetadata: e.serviceAdditionalMetadata, gitSha: e.gitSha || "", gitOrg: e.gitOrg || void 0, gitRepo: e.gitRepo || void 0, gitProvider: e.gitProvider || void 0, serviceDisplayName: e.serviceDisplayName || void 0, infrastructureType: e.infrastructureType || void 0, infrastructureDetails: e.infrastructureDetails || void 0, setupInterceptorsFile: e.setupInterceptorsFile || void 0, setupInterceptorsLine: e.setupInterceptorsLine || void 0 });
597
- P(this.endpoint, this.operationName, t, i);
626
+ `, e = g(), i = this.getVariables({ serviceIdentifier: e.serviceIdentifier, serviceVersion: e.serviceVersion, serviceAdditionalMetadata: e.serviceAdditionalMetadata, gitSha: e.gitSha || "", gitOrg: e.gitOrg || void 0, gitRepo: e.gitRepo || void 0, gitProvider: e.gitProvider || void 0, serviceDisplayName: e.serviceDisplayName || void 0, infrastructureType: e.infrastructureType || void 0, infrastructureDetails: e.infrastructureDetails || void 0, setupInterceptorsFile: e.setupInterceptorsFile || void 0, setupInterceptorsLine: e.setupInterceptorsLine || void 0, framework: e.framework || void 0, additionalFrameworks: e.additionalFrameworks?.length > 0 ? e.additionalFrameworks : void 0, serviceRole: e.serviceRole || void 0 });
627
+ w(this.endpoint, this.operationName, t, i);
598
628
  }
599
629
  }
600
630
  class We {
@@ -617,23 +647,23 @@ class We {
617
647
  await this._resolveInheritance(), this.debug && console.log(`[FuncSpan ConfigLoader] Loaded ${this.fileConfigs.size} file configs, ${this.functionConfigs.size} function configs`);
618
648
  }
619
649
  getConfig(t, e) {
620
- const i = this.hasSailfishFiles ? $e() : ue(), n = this._getDirectoryConfig(t), o = N.normalize(t), d = this.fileConfigs.get(o) || {};
621
- let s = {};
650
+ const i = this.hasSailfishFiles ? $e() : le(), n = this._getDirectoryConfig(t), s = D.normalize(t), l = this.fileConfigs.get(s) || {};
651
+ let a = {};
622
652
  if (e) {
623
- const a = this.functionConfigs.get(o);
624
- a && (s = a.get(e) || {});
653
+ const o = this.functionConfigs.get(s);
654
+ o && (a = o.get(e) || {});
625
655
  }
626
- return U(i, n, d, s);
656
+ return R(i, n, l, a);
627
657
  }
628
658
  hasRuntimeMode() {
629
659
  return this.runtimeModeEnabled;
630
660
  }
631
661
  async _walkDirectory(t, e) {
632
662
  try {
633
- const i = await X.readdir(t, { withFileTypes: !0 });
663
+ const i = await Z.readdir(t, { withFileTypes: !0 });
634
664
  for (const n of i) {
635
- const o = N.join(t, n.name);
636
- 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);
665
+ const s = D.join(t, n.name);
666
+ n.isFile() && n.name === ".sailfish" ? e.push(s) : n.name === "node_modules" || n.isDirectory() && n.name.startsWith(".") && n.name !== ".sailfish" || n.isDirectory() && await this._walkDirectory(s, e);
637
667
  }
638
668
  } catch (i) {
639
669
  this.debug && console.error(`[FuncSpan ConfigLoader] Error walking directory ${t}:`, i);
@@ -641,7 +671,7 @@ class We {
641
671
  }
642
672
  async _loadConfigFile(t) {
643
673
  try {
644
- const e = await X.readFile(t, "utf-8"), i = N.dirname(t);
674
+ const e = await Z.readFile(t, "utf-8"), i = D.dirname(t);
645
675
  let n = null;
646
676
  try {
647
677
  n = JSON.parse(e);
@@ -651,8 +681,8 @@ class We {
651
681
  } catch {
652
682
  try {
653
683
  n = require("js-yaml").load(e);
654
- } catch (o) {
655
- return void (this.debug && console.error(`[FuncSpan ConfigLoader] Failed to parse ${t} as JSON, TOML, or YAML:`, o));
684
+ } catch (s) {
685
+ return void (this.debug && console.error(`[FuncSpan ConfigLoader] Failed to parse ${t} as JSON, TOML, or YAML:`, s));
656
686
  }
657
687
  }
658
688
  }
@@ -663,40 +693,40 @@ class We {
663
693
  }
664
694
  }
665
695
  async _expandFileGlobs(t, e, i) {
666
- for (const [n, o] of Object.entries(e)) try {
667
- const d = N.join(t, n), s = await Le(d, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
668
- this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${n}' matched ${s.length} files`);
669
- for (const a of s) {
670
- const c = N.normalize(a), l = U(i, o);
671
- this.fileConfigs.set(c, l), this.debug && s.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${a}`);
696
+ for (const [n, s] of Object.entries(e)) try {
697
+ const l = D.join(t, n), a = await Oe(l, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
698
+ this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${n}' matched ${a.length} files`);
699
+ for (const o of a) {
700
+ const d = D.normalize(o), p = R(i, s);
701
+ this.fileConfigs.set(d, p), this.debug && a.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${o}`);
672
702
  }
673
- } catch (d) {
674
- this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${n}':`, d);
703
+ } catch (l) {
704
+ this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${n}':`, l);
675
705
  }
676
706
  }
677
707
  _storeFunctionConfigs(t, e, i) {
678
- for (const [n, o] of Object.entries(e)) {
679
- const d = n.split("::");
680
- if (d.length !== 2) {
708
+ for (const [n, s] of Object.entries(e)) {
709
+ const l = n.split("::");
710
+ if (l.length !== 2) {
681
711
  this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${n}' (expected format: 'file.ts::functionName')`);
682
712
  continue;
683
713
  }
684
- const [s, a] = d, c = N.normalize(N.join(t, s));
685
- this.functionConfigs.has(c) || this.functionConfigs.set(c, /* @__PURE__ */ new Map());
686
- const l = this.functionConfigs.get(c), g = U(i, o);
687
- l.set(a, g), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${c}::${a}`);
714
+ const [a, o] = l, d = D.normalize(D.join(t, a));
715
+ this.functionConfigs.has(d) || this.functionConfigs.set(d, /* @__PURE__ */ new Map());
716
+ const p = this.functionConfigs.get(d), c = R(i, s);
717
+ p.set(o, c), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${d}::${o}`);
688
718
  }
689
719
  }
690
720
  async _resolveInheritance() {
691
721
  }
692
722
  _getDirectoryConfig(t) {
693
- let e = N.dirname(N.normalize(t));
723
+ let e = D.dirname(D.normalize(t));
694
724
  const i = [];
695
- for (; e && e !== N.dirname(e); ) {
725
+ for (; e && e !== D.dirname(e); ) {
696
726
  const n = this.directoryConfigs.get(e);
697
- n && i.unshift(n), e = N.dirname(e);
727
+ n && i.unshift(n), e = D.dirname(e);
698
728
  }
699
- return i.reduce((n, o) => U(n, o), {});
729
+ return i.reduce((n, s) => R(n, s), {});
700
730
  }
701
731
  }
702
732
  const ge = "__sf_globalConfigLoader";
@@ -709,15 +739,15 @@ async function Be(r, t) {
709
739
  globalThis[ge] = i;
710
740
  })(e), await e.loadAllConfigs();
711
741
  }
712
- function ze(r, t) {
742
+ function je(r, t) {
713
743
  const e = fe();
714
- return e ? e.getConfig(r, t) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using default config (disabled)"), ue());
744
+ return e ? e.getConfig(r, t) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using default config (disabled)"), le());
715
745
  }
716
- function je() {
746
+ function ze() {
717
747
  return fe() !== null;
718
748
  }
719
- const Je = ["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"], Ve = ["pbkdf2", "randomBytes", "scrypt", "generateKeyPair"], Qe = ["gzip", "gunzip", "deflate", "inflate", "deflateRaw", "inflateRaw", "brotliCompress", "brotliDecompress"];
720
- let te = !1;
749
+ const Je = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "fstat", "access", "open", "close", "read", "write", "chmod", "mkdir", "rmdir", "unlink", "rename"], re = ["lookup", "resolve", "resolve4", "resolve6", "resolveAny", "resolveMx", "resolveNs", "resolveTxt", "reverse"], Ve = ["pbkdf2", "randomBytes", "scrypt", "generateKeyPair"], Qe = ["gzip", "gunzip", "deflate", "inflate", "deflateRaw", "inflateRaw", "brotliCompress", "brotliDecompress"];
750
+ let ie = !1;
721
751
  function Xe(r) {
722
752
  if (typeof r != "string") return !1;
723
753
  const t = process.env.SF_FUNCSPAN_JSONL_FILE;
@@ -725,8 +755,8 @@ function Xe(r) {
725
755
  const e = process.env.SF_WORKER_POOL_JSONL_FILE;
726
756
  return !(!e || !r.includes(e));
727
757
  }
728
- let ne = !1;
729
- function re(r) {
758
+ let se = !1;
759
+ function oe(r) {
730
760
  if (typeof r != "string") return !1;
731
761
  if (r === "localhost" || r === "127.0.0.1" || r === "::1") return !0;
732
762
  try {
@@ -738,7 +768,7 @@ function re(r) {
738
768
  return !1;
739
769
  }
740
770
  function Ye() {
741
- if (!ne) try {
771
+ if (!se) try {
742
772
  let r;
743
773
  if (typeof require > "u") return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] Skipping dns patching in pure ESM environment (require unavailable)"));
744
774
  try {
@@ -748,35 +778,35 @@ function Ye() {
748
778
  }
749
779
  if (r.__sf_worker_pool_patched__) return;
750
780
  Object.defineProperty(r, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
751
- for (const t of ee) if (typeof r[t] == "function") {
781
+ for (const t of re) if (typeof r[t] == "function") {
752
782
  const e = r[t];
753
783
  r[t] = function(...i) {
754
- return Q() ? 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);
784
+ return Y() ? e.apply(this, i) : oe(i[0]) ? e.apply(this, i) : typeof i[i.length - 1] == "function" ? A("dns", t, e, i, this) : e.apply(this, i);
755
785
  }, Object.defineProperty(r[t], "name", { value: t, writable: !1 });
756
786
  }
757
787
  (function(t) {
758
788
  if (!t.promises) return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises not available, skipping"));
759
789
  if (!t.promises.__sf_worker_pool_patched__) {
760
790
  Object.defineProperty(t.promises, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
761
- for (const e of ee) if (typeof t.promises[e] == "function") {
791
+ for (const e of re) if (typeof t.promises[e] == "function") {
762
792
  const i = t.promises[e];
763
793
  t.promises[e] = function(...n) {
764
- return Q() ? i.apply(this, n) : re(n[0]) ? i.apply(this, n) : _e("dns", e, i, n, this);
794
+ return Y() ? i.apply(this, n) : oe(n[0]) ? i.apply(this, n) : _e("dns", e, i, n, this);
765
795
  }, Object.defineProperty(t.promises[e], "name", { value: e, writable: !1 });
766
796
  }
767
797
  process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises module patched successfully");
768
798
  }
769
- })(r), ne = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns module patched successfully");
799
+ })(r), se = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns module patched successfully");
770
800
  } catch (r) {
771
801
  console.error("[WorkerPool] Error patching dns module:", r);
772
802
  }
773
803
  }
774
- let ie = !1, se = !1, B = !1;
804
+ let ae = !1, ce = !1, z = !1;
775
805
  function Ze() {
776
- if (B) return;
806
+ if (z) return;
777
807
  const r = process.env.SF_DEBUG === "true";
778
- r && console.log("[WorkerPool] Initializing worker pool patching..."), R("fs") && (r && console.log("[WorkerPool] Patching fs module..."), (function() {
779
- if (!te) try {
808
+ r && console.log("[WorkerPool] Initializing worker pool patching..."), U("fs") && (r && console.log("[WorkerPool] Patching fs module..."), (function() {
809
+ if (!ie) try {
780
810
  const t = require("node:fs");
781
811
  if (t.__sf_worker_pool_patched__) return;
782
812
  Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
@@ -786,12 +816,12 @@ function Ze() {
786
816
  return Xe(n[0]) ? i.apply(this, n) : typeof n[n.length - 1] == "function" ? A("fs", e, i, n, this) : i.apply(this, n);
787
817
  }, Object.defineProperty(t[e], "name", { value: e, writable: !1 });
788
818
  }
789
- te = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] fs module patched successfully");
819
+ ie = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] fs module patched successfully");
790
820
  } catch (t) {
791
821
  console.error("[WorkerPool] Error patching fs module:", t);
792
822
  }
793
- })()), R("dns") && (r && console.log("[WorkerPool] Patching dns module..."), Ye()), R("crypto") && (r && console.log("[WorkerPool] Patching crypto module..."), (function() {
794
- if (!ie) try {
823
+ })()), U("dns") && (r && console.log("[WorkerPool] Patching dns module..."), Ye()), U("crypto") && (r && console.log("[WorkerPool] Patching crypto module..."), (function() {
824
+ if (!ae) try {
795
825
  const t = require("node:crypto");
796
826
  if (t.__sf_worker_pool_patched__) return;
797
827
  Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
@@ -801,12 +831,12 @@ function Ze() {
801
831
  return typeof n[n.length - 1] == "function" ? A("crypto", e, i, n, this) : i.apply(this, n);
802
832
  }, Object.defineProperty(t[e], "name", { value: e, writable: !1 });
803
833
  }
804
- ie = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] crypto module patched successfully");
834
+ ae = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] crypto module patched successfully");
805
835
  } catch (t) {
806
836
  console.error("[WorkerPool] Error patching crypto module:", t);
807
837
  }
808
- })()), R("zlib") && (r && console.log("[WorkerPool] Patching zlib module..."), (function() {
809
- if (!se) try {
838
+ })()), U("zlib") && (r && console.log("[WorkerPool] Patching zlib module..."), (function() {
839
+ if (!ce) try {
810
840
  const t = require("node:zlib");
811
841
  if (t.__sf_worker_pool_patched__) return;
812
842
  Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
@@ -816,163 +846,163 @@ function Ze() {
816
846
  return typeof n[n.length - 1] == "function" ? A("zlib", e, i, n, this) : i.apply(this, n);
817
847
  }, Object.defineProperty(t[e], "name", { value: e, writable: !1 });
818
848
  }
819
- se = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] zlib module patched successfully");
849
+ ce = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] zlib module patched successfully");
820
850
  } catch (t) {
821
851
  console.error("[WorkerPool] Error patching zlib module:", t);
822
852
  }
823
- })()), B = !0, r && console.log("[WorkerPool] Worker pool patching initialized");
853
+ })()), z = !0, r && console.log("[WorkerPool] Worker pool patching initialized");
824
854
  }
825
855
  function et() {
826
- return B;
856
+ return z;
827
857
  }
828
- let z = !1, K = !1;
829
- function ut(r) {
830
- if (K) console.warn("[setupInterceptors] ⚠️ Recursive call detected and blocked!");
831
- else if (!z) {
832
- K = !0;
858
+ let J = !1, G = !1;
859
+ function pt(r) {
860
+ if (G) console.warn("[setupInterceptors] ⚠️ Recursive call detected and blocked!");
861
+ else if (!J) {
862
+ G = !0;
833
863
  try {
834
864
  let t, e;
835
- const i = le(new Error().stack);
865
+ const i = ue(new Error().stack);
836
866
  if (i) {
837
- const s = i.split(`
838
- `)[2] || "", a = s.match(/\((.+):(\d+):\d+\)/) || s.match(/at (.+):(\d+):\d+/);
839
- a && (t = a[1], e = parseInt(a[2], 10));
867
+ const a = i.split(`
868
+ `)[2] || "", o = a.match(/\((.+):(\d+):\d+\)/) || a.match(/at (.+):(\d+):\d+/);
869
+ o && (t = o[1], e = parseInt(o[2], 10));
840
870
  }
841
871
  if (!r || !r.apiKey) {
842
- const s = `The required API Key is not provided: ${JSON.stringify(r)}`;
843
- console.error(s);
872
+ const a = `The required API Key is not provided: ${JSON.stringify(r)}`;
873
+ console.error(a);
844
874
  }
845
875
  const { config: n } = Se(r);
846
- if (Ie(n).catch(() => {
876
+ if (ve(n).catch(() => {
847
877
  }), t && (n.setupInterceptorsFile = t), e && (n.setupInterceptorsLine = e), n.sfDebug && console.log("Updated configuration after applying options:", n), !n.apiKey || !n.apiGraphqlEndpoint) {
848
- const s = `The required config is not provided: ${JSON.stringify(n)}`;
849
- throw console.error(s), new Error(s);
878
+ const a = `The required config is not provided: ${JSON.stringify(n)}`;
879
+ throw console.error(a), new Error(a);
850
880
  }
851
- je() || Be(void 0, n.sfDebug).catch((s) => {
852
- n.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:", s);
881
+ ze() || Be(void 0, n.sfDebug).catch((a) => {
882
+ n.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:", a);
853
883
  }), process.env.SF_WORKER_POOL_DISABLED === "true" ? n.sfDebug && console.log("[setupInterceptors] Worker pool patching DISABLED (SF_WORKER_POOL_DISABLED=true)") : et() || (Ze(), n.sfDebug && console.log("[setupInterceptors] Worker pool patching initialized (DNS tracking enabled)"));
854
- const o = new J();
855
- o.setServiceUUID(n.serviceUUID), we(o), (function(s = []) {
856
- const a = new Ge(s);
857
- new He().doSend(a.getExcludedDomains());
858
- const c = new Me(), l = new xe();
859
- a.patchFetch(c, l), a.patchHttp(c, l);
884
+ const s = new Q();
885
+ s.setServiceUUID(n.serviceUUID), we(s), (function(a = []) {
886
+ const o = new Ge(a);
887
+ new He().doSend(o.getExcludedDomains());
888
+ const d = new Me(), p = new xe();
889
+ o.patchFetch(d, p), o.patchHttp(d, p);
860
890
  })(n.domainsToNotPropagateHeadersTo);
861
- const d = new Ae();
862
- d.setServiceUUID(n.serviceUUID), Pe(d), qe(), new Ke().send(), z = !0, n.sfDebug && console.log("[setupInterceptors] ✅ Initialization complete");
891
+ const l = new Le();
892
+ l.setServiceUUID(n.serviceUUID), Pe(l), qe(), new Ke().send(), J = !0, n.sfDebug && console.log("[setupInterceptors] ✅ Initialization complete");
863
893
  } finally {
864
- K = !1;
894
+ G = !1;
865
895
  }
866
896
  }
867
897
  }
868
- function lt() {
869
- return z;
898
+ function gt() {
899
+ return J;
870
900
  }
871
- function pt(r, t, e, i = !1) {
872
- const n = u();
901
+ function ft(r, t, e, i = !1) {
902
+ const n = g();
873
903
  new pe(n.apiKey).identify(r, t, e, i);
874
904
  }
875
- function gt(r, t = {}, e, i = !1) {
876
- const n = u();
905
+ function ht(r, t = {}, e, i = !1) {
906
+ const n = g();
877
907
  new pe(n.apiKey).addOrUpdateMetadata(r, t, e, i);
878
908
  }
879
- let W = null;
880
- function ft(r, t, e, i) {
881
- const n = function(...o) {
882
- const d = ae(), s = d?.sfDebug || !1;
883
- s && console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${e}::${t}`);
884
- const a = (function(f, I) {
885
- const v = ce();
886
- if (v) {
887
- const D = de(v);
888
- if (D) return process.env.SF_DEBUG === "true" && console.log(`[FuncSpan] Using HTTP header override for ${f}::${I}`), D;
909
+ let K = null;
910
+ function mt(r, t, e, i) {
911
+ const n = function(...s) {
912
+ const l = de(), a = l?.sfDebug || !1;
913
+ a && console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${e}::${t}`);
914
+ const o = (function(h, v) {
915
+ const I = B();
916
+ if (I) {
917
+ const _ = j(I);
918
+ if (_) return process.env.SF_DEBUG === "true" && console.log(`[FuncSpan] Using HTTP header override for ${h}::${v}`), _;
889
919
  }
890
920
  try {
891
- return ze(f, I);
921
+ return je(h, v);
892
922
  } catch {
893
923
  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 };
894
924
  }
895
925
  })(e, t);
896
- if (s && console.log(`[FuncSpan] Config for ${e}::${t}:`, a), a.enable_sampling && a.sample_rate < 1 && Math.random() > a.sample_rate) return s && console.log(`[FuncSpan] Skipping ${t} due to sampling`), r.apply(this, o);
897
- if (a.sample_rate === 0) return s && console.log(`[FuncSpan] Skipping ${t} - sample_rate is 0.0`), r.apply(this, o);
898
- s && console.log(`[FuncSpan] Capturing function span for ${t}`);
899
- const c = j.getInstance(), l = c.getCurrentFunctionSpanId(), g = oe();
900
- c.setCurrentFunctionSpanId(g);
901
- const h = process.hrtime.bigint(), m = Date.now();
902
- let p = null;
903
- a.capture_arguments && (p = {}, i.paramNames.forEach((f, I) => {
904
- I < o.length && (p[f] = o[I]);
905
- }), p && a.arg_limit_mb > 0 && (p = H(p, a.arg_limit_mb)));
926
+ if (a && console.log(`[FuncSpan] Config for ${e}::${t}:`, o), o.enable_sampling && o.sample_rate < 1 && Math.random() > o.sample_rate) return a && console.log(`[FuncSpan] Skipping ${t} due to sampling`), r.apply(this, s);
927
+ if (o.sample_rate === 0) return a && console.log(`[FuncSpan] Skipping ${t} - sample_rate is 0.0`), r.apply(this, s);
928
+ a && console.log(`[FuncSpan] Capturing function span for ${t}`);
929
+ const d = V.getInstance(), p = d.getCurrentFunctionSpanId(), c = W();
930
+ d.setCurrentFunctionSpanId(c);
931
+ const f = process.hrtime.bigint(), m = Date.now();
932
+ let u = null;
933
+ o.capture_arguments && (u = {}, i.paramNames.forEach((h, v) => {
934
+ v < s.length && (u[h] = s[v]);
935
+ }), u && o.arg_limit_mb > 0 && (u = M(u, o.arg_limit_mb)));
906
936
  try {
907
- const f = r.apply(this, o);
908
- if (f && typeof f.then == "function") return l ? c.setCurrentFunctionSpanId(l) : c.clearCurrentFunctionSpanId(), f.then((b) => {
909
- const S = process.hrtime.bigint(), F = Date.now(), E = Number(S - h);
910
- let V = null;
911
- return a.capture_return_value && a.return_limit_mb > 0 && (V = H(b, a.return_limit_mb)), O({ functionName: t, filePath: e, metadata: i, args: p, result: V, error: null, duration: F - m, durationNs: E, startTimeNs: h.toString(), async: !0, spanId: g, parentSpanId: l, pid: process.pid, threadId: L }), b;
912
- }, (b) => {
913
- const S = process.hrtime.bigint(), F = Date.now(), E = Number(S - h);
914
- throw O({ functionName: t, filePath: e, metadata: i, args: p, result: null, error: b?.message || String(b), duration: F - m, durationNs: E, startTimeNs: h.toString(), async: !0, spanId: g, parentSpanId: l, pid: process.pid, threadId: L }), b;
937
+ const h = r.apply(this, s);
938
+ if (h && typeof h.then == "function") return p ? d.setCurrentFunctionSpanId(p) : d.clearCurrentFunctionSpanId(), h.then((F) => {
939
+ const $ = process.hrtime.bigint(), N = Date.now(), P = Number($ - f);
940
+ let X = null;
941
+ return o.capture_return_value && o.return_limit_mb > 0 && (X = M(F, o.return_limit_mb)), L({ functionName: t, filePath: e, metadata: i, args: u, result: X, error: null, duration: N - m, durationNs: P, startTimeNs: f.toString(), async: !0, spanId: c, parentSpanId: p, pid: process.pid, threadId: k }), F;
942
+ }, (F) => {
943
+ const $ = process.hrtime.bigint(), N = Date.now(), P = Number($ - f);
944
+ throw L({ functionName: t, filePath: e, metadata: i, args: u, result: null, error: F?.message || String(F), duration: N - m, durationNs: P, startTimeNs: f.toString(), async: !0, spanId: c, parentSpanId: p, pid: process.pid, threadId: k }), F;
915
945
  });
916
- const I = process.hrtime.bigint(), v = Date.now(), D = Number(I - h);
917
- let $ = null;
918
- return a.capture_return_value && a.return_limit_mb > 0 && ($ = H(f, a.return_limit_mb)), O({ functionName: t, filePath: e, metadata: i, args: p, result: $, error: null, duration: v - m, durationNs: D, startTimeNs: h.toString(), async: !1, spanId: g, parentSpanId: l, pid: process.pid, threadId: L }), l ? c.setCurrentFunctionSpanId(l) : c.clearCurrentFunctionSpanId(), f;
919
- } catch (f) {
920
- const I = process.hrtime.bigint(), v = Date.now(), D = Number(I - h);
921
- throw O({ functionName: t, filePath: e, metadata: i, args: p, result: null, error: f?.message || String(f), duration: v - m, durationNs: D, startTimeNs: h.toString(), async: !1, spanId: g, parentSpanId: l, pid: process.pid, threadId: L }), l ? c.setCurrentFunctionSpanId(l) : c.clearCurrentFunctionSpanId(), f;
946
+ const v = process.hrtime.bigint(), I = Date.now(), _ = Number(v - f);
947
+ let S = null;
948
+ return o.capture_return_value && o.return_limit_mb > 0 && (S = M(h, o.return_limit_mb)), L({ functionName: t, filePath: e, metadata: i, args: u, result: S, error: null, duration: I - m, durationNs: _, startTimeNs: f.toString(), async: !1, spanId: c, parentSpanId: p, pid: process.pid, threadId: k }), p ? d.setCurrentFunctionSpanId(p) : d.clearCurrentFunctionSpanId(), h;
949
+ } catch (h) {
950
+ const v = process.hrtime.bigint(), I = Date.now(), _ = Number(v - f);
951
+ throw L({ functionName: t, filePath: e, metadata: i, args: u, result: null, error: h?.message || String(h), duration: I - m, durationNs: _, startTimeNs: f.toString(), async: !1, spanId: c, parentSpanId: p, pid: process.pid, threadId: k }), p ? d.setCurrentFunctionSpanId(p) : d.clearCurrentFunctionSpanId(), h;
922
952
  }
923
953
  };
924
954
  Object.defineProperty(n, "name", { value: t, writable: !1 });
925
- for (const o in r) r.hasOwnProperty(o) && (n[o] = r[o]);
955
+ for (const s in r) r.hasOwnProperty(s) && (n[s] = r[s]);
926
956
  return n;
927
957
  }
928
- function O(r) {
929
- const t = ae(), e = t?.sfDebug || !1;
958
+ function L(r) {
959
+ const t = de(), e = t?.sfDebug || !1;
930
960
  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 });
931
961
  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 };
932
962
  process.env.SF_FUNCSPAN_CONSOLE_OUTPUT === "true" && console.log(`
933
963
  📊 Function Span:`, { function: `${r.functionName} (${r.filePath}:${r.metadata.line}:${r.metadata.column})`, duration: `${r.duration.toFixed(2)}ms`, arguments: r.args, result: r.error ? `Error: ${r.error}` : r.result, spanId: r.spanId, parentSpanId: r.parentSpanId || "none" });
934
964
  const n = process.env.SF_FUNCSPAN_JSONL_FILE;
935
965
  if (n) try {
936
- const o = n === "true" || n === "1" ? "funcspans.jsonl" : n, d = Date.now(), s = process.hrtime.bigint(), a = BigInt(r.startTimeNs), c = Number(s - a) / 1e6, l = new Date(d - c).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 }) + `
966
+ const s = n === "true" || n === "1" ? "funcspans.jsonl" : n, l = Date.now(), a = process.hrtime.bigint(), o = BigInt(r.startTimeNs), d = Number(a - o) / 1e6, p = new Date(l - d).toISOString(), c = JSON.stringify({ timestamp: p, 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 }) + `
937
967
  `;
938
- Ue(o, g, "utf-8");
939
- } catch (o) {
940
- console.error("[FuncSpan] Error writing to JSONL file:", o);
968
+ Re(s, c, "utf-8");
969
+ } catch (s) {
970
+ console.error("[FuncSpan] Error writing to JSONL file:", s);
941
971
  }
942
972
  if (e && console.log("[FuncSpan] Sending function span to transmitter:", i), process.env.SF_FUNCSPAN_SKIP_BACKEND !== "true") try {
943
- (W || (W = new be()), W).send([i]), e && console.log("[FuncSpan] Function span sent successfully");
944
- } catch (o) {
945
- e && console.error("[FuncSpan] Error sending function span:", o);
973
+ (K || (K = new be()), K).send([i]), e && console.log("[FuncSpan] Function span sent successfully");
974
+ } catch (s) {
975
+ e && console.error("[FuncSpan] Error sending function span:", s);
946
976
  }
947
977
  }
948
- function ht(r) {
978
+ function yt(r) {
949
979
  return !!r.includes("captureFunctionSpan(") || !!r.includes("@sailfish-ai/sf-veritas") || !(!r.includes("/* @sailfish-instrumented */") && !r.includes("// @sailfish-instrumented"));
950
980
  }
951
981
  export {
952
- j as ContextManager,
953
- gt as addOrUpdateMetadata,
954
- ft as captureFunctionSpan,
955
- vt as clearFuncspanOverride,
956
- q as getCurrentFunctionSpanId,
957
- ue as getDefaultConfig,
982
+ V as ContextManager,
983
+ ht as addOrUpdateMetadata,
984
+ mt as captureFunctionSpan,
985
+ _t as clearFuncspanOverride,
986
+ H as getCurrentFunctionSpanId,
987
+ le as getDefaultConfig,
958
988
  $e as getEnvConfig,
959
- ce as getFuncspanOverride,
960
- ze as getGlobalConfig,
961
- pt as identify,
989
+ B as getFuncspanOverride,
990
+ je as getGlobalConfig,
991
+ ft as identify,
962
992
  Be as initializeConfigLoader,
963
993
  Ze as initializeWorkerPoolPatching,
964
- ht as isAlreadyInstrumented,
965
- je as isConfigLoaderInitialized,
966
- bt as isProductionEnvironment,
967
- Ft as isRuntimeModeEnabled,
968
- lt as isSetupInterceptorsInitialized,
994
+ yt as isAlreadyInstrumented,
995
+ ze as isConfigLoaderInitialized,
996
+ Nt as isProductionEnvironment,
997
+ Dt as isRuntimeModeEnabled,
998
+ gt as isSetupInterceptorsInitialized,
969
999
  et as isWorkerPoolInitialized,
970
- de as parseHeaderOverride,
971
- St as runWithContext,
972
- $t as setFuncspanOverride,
973
- wt as setSkipTypeScriptPlugin,
974
- ut as setupInterceptors,
975
- Nt as shouldEnableRuntimeHooks,
976
- Pt as transformFunctionSpans,
977
- Et as transformFunctionSpansSync
1000
+ j as parseHeaderOverride,
1001
+ It as runWithContext,
1002
+ bt as setFuncspanOverride,
1003
+ Et as setSkipTypeScriptPlugin,
1004
+ pt as setupInterceptors,
1005
+ wt as shouldEnableRuntimeHooks,
1006
+ Tt as transformFunctionSpans,
1007
+ Ct as transformFunctionSpansSync
978
1008
  };