@autter/runtime-node 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -45,10 +45,10 @@
45
45
 
46
46
 
47
47
 
48
- var _chunkUKYTXZOQcjs = require('./chunk-UKYTXZOQ.cjs');
48
+ var _chunkUXTIMS3Gcjs = require('./chunk-UXTIMS3G.cjs');
49
49
 
50
50
 
51
- var _chunkUGNPCOIWcjs = require('./chunk-UGNPCOIW.cjs');
51
+ var _chunk7OTD2YPTcjs = require('./chunk-7OTD2YPT.cjs');
52
52
 
53
53
 
54
54
 
@@ -69,7 +69,8 @@ var _chunkUGNPCOIWcjs = require('./chunk-UGNPCOIW.cjs');
69
69
 
70
70
 
71
71
 
72
- var _chunkARN26OK6cjs = require('./chunk-ARN26OK6.cjs');
72
+
73
+ var _chunk4MVWIRBIcjs = require('./chunk-4MVWIRBI.cjs');
73
74
 
74
75
  // src/relay.ts
75
76
  var IpWindow = (_class = class {
@@ -223,7 +224,7 @@ function relayContext(raw, redactor) {
223
224
  return Array.isArray(bounded) ? {} : { context: redactor(bounded) };
224
225
  }
225
226
  function relayBreadcrumbs(raw, redactor) {
226
- const breadcrumbs = _chunkUKYTXZOQcjs.sanitizeBreadcrumbs.call(void 0, raw, redactor);
227
+ const breadcrumbs = _chunkUXTIMS3Gcjs.sanitizeBreadcrumbs.call(void 0, raw, redactor);
227
228
  return breadcrumbs ? { breadcrumbs } : {};
228
229
  }
229
230
  var DEBUG_ID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
@@ -240,10 +241,10 @@ function relayDebugIds(raw, redactor) {
240
241
  return count ? { debugIds } : {};
241
242
  }
242
243
  function relayFingerprint(raw, redactor) {
243
- const values = _chunkUKYTXZOQcjs.fingerprintValues.call(void 0, raw, redactor.text);
244
+ const values = _chunkUXTIMS3Gcjs.fingerprintValues.call(void 0, raw, redactor.text);
244
245
  return values ? { fingerprint: Array.isArray(raw) ? values : values[0] } : {};
245
246
  }
246
- var defaultRelayRedactor = _chunkUKYTXZOQcjs.makeRedactor.call(void 0, true);
247
+ var defaultRelayRedactor = _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, true);
247
248
  function sanitizeBrowserPayload(raw, redactor = defaultRelayRedactor) {
248
249
  if (typeof raw !== "object" || raw === null) return null;
249
250
  const p = raw;
@@ -292,7 +293,7 @@ function forward(payload, opts) {
292
293
  const endpoint = (_nullishCoalesce(opts.endpoint, () => ( DEFAULT_ENDPOINT))).replace(/\/$/, "");
293
294
  const url = `${endpoint}/v1/browser`;
294
295
  const compat = opts.compatCheck !== false;
295
- if (compat) _chunkARN26OK6cjs.ensureCompatConfigured.call(void 0, endpoint);
296
+ if (compat) _chunk4MVWIRBIcjs.ensureCompatConfigured.call(void 0, endpoint);
296
297
  void fetch(url, {
297
298
  method: "POST",
298
299
  headers: {
@@ -306,12 +307,12 @@ function forward(payload, opts) {
306
307
  const types = new Set(
307
308
  (_nullishCoalesce(payload.events, () => ( []))).map((e) => String(e.type))
308
309
  );
309
- _chunkARN26OK6cjs.observeIngesterResponse.call(void 0, { status: response.status, headers: response.headers });
310
- for (const feature of _chunkARN26OK6cjs.featuresForBrowserEvents.call(void 0, types)) _chunkARN26OK6cjs.noteCompatFeature.call(void 0, feature);
310
+ _chunk4MVWIRBIcjs.observeIngesterResponse.call(void 0, { status: response.status, headers: response.headers });
311
+ for (const feature of _chunk4MVWIRBIcjs.featuresForBrowserEvents.call(void 0, types)) _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, feature);
311
312
  if ((_nullishCoalesce(payload.events, () => ( []))).some((e) => e.traceId)) {
312
- _chunkARN26OK6cjs.noteCompatFeature.call(void 0, "browser_trace_propagation");
313
+ _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "browser_trace_propagation");
313
314
  }
314
- _chunkARN26OK6cjs.noteRelayRejection.call(void 0, types, response.status, response.headers);
315
+ _chunk4MVWIRBIcjs.noteRelayRejection.call(void 0, types, response.status, response.headers);
315
316
  }).catch((err) => {
316
317
  (_nullishCoalesce(opts.onError, () => ( ((e) => console.warn("autter relay forward failed:", e)))))(
317
318
  err
@@ -320,7 +321,7 @@ function forward(payload, opts) {
320
321
  }
321
322
  function createBrowserRelayFetchHandler(opts) {
322
323
  const maxBody = _nullishCoalesce(opts.maxBodyBytes, () => ( DEFAULT_MAX_BODY));
323
- const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunkUKYTXZOQcjs.makeRedactor.call(void 0, opts.redact);
324
+ const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, opts.redact);
324
325
  const limiter = opts.perIpRateLimit === false ? null : new IpWindow(_nullishCoalesce(opts.perIpRateLimit, () => ( 120)));
325
326
  return async (request) => {
326
327
  if (request.method !== "POST") {
@@ -367,7 +368,7 @@ function createBrowserRelayFetchHandler(opts) {
367
368
  }
368
369
  function createBrowserRelayHandler(opts) {
369
370
  const maxBody = _nullishCoalesce(opts.maxBodyBytes, () => ( DEFAULT_MAX_BODY));
370
- const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunkUKYTXZOQcjs.makeRedactor.call(void 0, opts.redact);
371
+ const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, opts.redact);
371
372
  const limiter = opts.perIpRateLimit === false ? null : new IpWindow(_nullishCoalesce(opts.perIpRateLimit, () => ( 120)));
372
373
  function respond(res, status, body) {
373
374
  res.statusCode = status;
@@ -478,6 +479,89 @@ var _semanticconventions = require('@opentelemetry/semantic-conventions');
478
479
 
479
480
 
480
481
 
482
+
483
+ // src/url-query.ts
484
+ var URL_KEYS = ["http.target", "http.url", "url.full", "url.original", "url.path"];
485
+ var QUERY_KEY = "url.query";
486
+ var NAME_KEYS = ["next.span_name"];
487
+ var MASK = "[redacted]";
488
+ var SCHEME = /^[a-z][a-z0-9+.-]*:\/\//i;
489
+ function splitUrl(value) {
490
+ const from = SCHEME.test(value) ? value.indexOf("://") + 3 : 0;
491
+ const question = value.indexOf("?", from);
492
+ const hash = value.indexOf("#", from);
493
+ const at = question < 0 ? hash : hash < 0 ? question : Math.min(question, hash);
494
+ if (at < 0) return null;
495
+ const query = at === question ? value.slice(at + 1, hash > at ? hash : void 0) : null;
496
+ return { base: value.slice(0, at), query };
497
+ }
498
+ function decodeName(raw) {
499
+ try {
500
+ return decodeURIComponent(raw.replace(/\+/g, " "));
501
+ } catch (e12) {
502
+ return raw;
503
+ }
504
+ }
505
+ function makeUrlQueryPolicy(keepQueryParams = []) {
506
+ const keep = new Set(keepQueryParams.filter((name) => typeof name === "string"));
507
+ const maskQuery = (query) => {
508
+ const out = [];
509
+ for (const part of query.split("&")) {
510
+ if (!part) continue;
511
+ const eq = part.indexOf("=");
512
+ const name = eq < 0 ? part : part.slice(0, eq);
513
+ if (keep.size && keep.has(decodeName(name))) out.push(part);
514
+ else if (eq < 0) out.push(MASK);
515
+ else out.push(eq === part.length - 1 ? part : `${name}=${MASK}`);
516
+ }
517
+ return out.join("&");
518
+ };
519
+ const stripName = (name) => {
520
+ if (!name.includes("?") && !name.includes("#")) return name;
521
+ return name.split(" ").map((token) => {
522
+ if (!token.startsWith("/") && !SCHEME.test(token)) return token;
523
+ return _nullishCoalesce(_optionalChain([splitUrl, 'call', _3 => _3(token), 'optionalAccess', _4 => _4.base]), () => ( token));
524
+ }).join(" ");
525
+ };
526
+ return {
527
+ attributes(attributes) {
528
+ let out = null;
529
+ const set = (key, value) => {
530
+ out ??= { ...attributes };
531
+ out[key] = value;
532
+ };
533
+ let dropped = null;
534
+ for (const key of URL_KEYS) {
535
+ const value = attributes[key];
536
+ if (typeof value !== "string") continue;
537
+ const split = splitUrl(value);
538
+ if (!split) continue;
539
+ set(key, split.base);
540
+ if (split.query) dropped ??= split.query;
541
+ }
542
+ for (const key of NAME_KEYS) {
543
+ const value = attributes[key];
544
+ if (typeof value !== "string") continue;
545
+ const stripped = stripName(value);
546
+ if (stripped !== value) set(key, stripped);
547
+ }
548
+ const current = attributes[QUERY_KEY];
549
+ if (typeof current === "string") {
550
+ const masked = maskQuery(current.startsWith("?") ? current.slice(1) : current);
551
+ if (masked !== current) set(QUERY_KEY, masked);
552
+ } else if (current !== void 0) {
553
+ set(QUERY_KEY, MASK);
554
+ } else if (dropped !== null) {
555
+ const masked = maskQuery(dropped);
556
+ if (masked) set(QUERY_KEY, masked);
557
+ }
558
+ return _nullishCoalesce(out, () => ( attributes));
559
+ },
560
+ name: stripName
561
+ };
562
+ }
563
+
564
+ // src/redact-exporter.ts
481
565
  var scrubbedResources = /* @__PURE__ */ new WeakMap();
482
566
  function redactResource(resource, redactor) {
483
567
  const cached = scrubbedResources.get(resource);
@@ -486,17 +570,41 @@ function redactResource(resource, redactor) {
486
570
  scrubbedResources.set(resource, scrubbed);
487
571
  return scrubbed;
488
572
  }
489
- function redactSpan(span, redactor) {
490
- const status = span.status.message ? { ...span.status, message: redactor.text(span.status.message) } : span.status;
573
+ var DEFAULT_QUERY_POLICY = makeUrlQueryPolicy();
574
+ function stripQueries(span, query) {
575
+ const name = query.name(span.name);
576
+ const attributes = query.attributes(span.attributes);
577
+ if (name === span.name && attributes === span.attributes) return span;
578
+ return wrap(span, { name, attributes });
579
+ }
580
+ function wrap(span, fields) {
491
581
  return {
492
- name: redactor.text(span.name),
582
+ name: fields.name,
493
583
  kind: span.kind,
494
584
  spanContext: () => span.spanContext(),
495
585
  parentSpanId: span.parentSpanId,
496
586
  startTime: span.startTime,
497
587
  endTime: span.endTime,
588
+ status: _nullishCoalesce(fields.status, () => ( span.status)),
589
+ attributes: fields.attributes,
590
+ links: _nullishCoalesce(fields.links, () => ( span.links)),
591
+ events: _nullishCoalesce(fields.events, () => ( span.events)),
592
+ duration: span.duration,
593
+ ended: span.ended,
594
+ resource: _nullishCoalesce(fields.resource, () => ( span.resource)),
595
+ instrumentationLibrary: span.instrumentationLibrary,
596
+ droppedAttributesCount: span.droppedAttributesCount,
597
+ droppedEventsCount: span.droppedEventsCount,
598
+ droppedLinksCount: span.droppedLinksCount
599
+ };
600
+ }
601
+ function redactSpan(span, redactor, query = DEFAULT_QUERY_POLICY) {
602
+ if (!redactor.enabled) return stripQueries(span, query);
603
+ const status = span.status.message ? { ...span.status, message: redactor.text(span.status.message) } : span.status;
604
+ return wrap(span, {
605
+ name: query.name(redactor.text(span.name)),
498
606
  status,
499
- attributes: redactor.exported(span.attributes),
607
+ attributes: query.attributes(redactor.exported(span.attributes)),
500
608
  links: span.links.map(
501
609
  (link) => link.attributes ? { ...link, attributes: redactor.exported(link.attributes) } : link
502
610
  ),
@@ -505,34 +613,27 @@ function redactSpan(span, redactor) {
505
613
  name: redactor.text(event.name),
506
614
  ...event.attributes ? { attributes: redactor.exported(event.attributes) } : {}
507
615
  })),
508
- duration: span.duration,
509
- ended: span.ended,
510
- resource: redactResource(span.resource, redactor),
511
- instrumentationLibrary: span.instrumentationLibrary,
512
- droppedAttributesCount: span.droppedAttributesCount,
513
- droppedEventsCount: span.droppedEventsCount,
514
- droppedLinksCount: span.droppedLinksCount
515
- };
616
+ resource: redactResource(span.resource, redactor)
617
+ });
516
618
  }
517
619
  var RedactingSpanExporter = class {
518
- constructor(inner, redactor) {
620
+ constructor(inner, redactor, query = DEFAULT_QUERY_POLICY) {
519
621
  this.inner = inner;
520
622
  this.redactor = redactor;
623
+ this.query = query;
521
624
  }
522
625
 
523
626
 
627
+
524
628
  export(spans, resultCallback) {
525
629
  const redactor = this.redactor();
526
- let scrubbed = spans;
630
+ const scrubbed = [];
527
631
  let failed = 0;
528
- if (redactor.enabled) {
529
- scrubbed = [];
530
- for (const span of spans) {
531
- try {
532
- scrubbed.push(redactSpan(span, redactor));
533
- } catch (e12) {
534
- failed++;
535
- }
632
+ for (const span of spans) {
633
+ try {
634
+ scrubbed.push(redactSpan(span, redactor, this.query));
635
+ } catch (e13) {
636
+ failed++;
536
637
  }
537
638
  }
538
639
  if (!failed) {
@@ -554,7 +655,7 @@ var RedactingSpanExporter = class {
554
655
  return this.inner.shutdown();
555
656
  }
556
657
  forceFlush() {
557
- return _nullishCoalesce(_optionalChain([this, 'access', _3 => _3.inner, 'access', _4 => _4.forceFlush, 'optionalCall', _5 => _5()]), () => ( Promise.resolve()));
658
+ return _nullishCoalesce(_optionalChain([this, 'access', _5 => _5.inner, 'access', _6 => _6.forceFlush, 'optionalCall', _7 => _7()]), () => ( Promise.resolve()));
558
659
  }
559
660
  };
560
661
  var RedactingMetricExporter = class {
@@ -611,7 +712,7 @@ function startMemoryMetrics() {
611
712
  [heapUsed, (result) => result.observe(process.memoryUsage().heapUsed)],
612
713
  [heapLimit, (result) => result.observe(_v8.getHeapStatistics.call(void 0, ).heap_size_limit)],
613
714
  [containerLimit, (result) => {
614
- const constrained = _nullishCoalesce(_optionalChain([process, 'access', _6 => _6.constrainedMemory, 'optionalCall', _7 => _7()]), () => ( 0));
715
+ const constrained = _nullishCoalesce(_optionalChain([process, 'access', _8 => _8.constrainedMemory, 'optionalCall', _9 => _9()]), () => ( 0));
615
716
  if (constrained > 0) result.observe(constrained);
616
717
  }],
617
718
  [afterGc, (result) => {
@@ -641,7 +742,7 @@ var _async_hooks = require('async_hooks');
641
742
 
642
743
  var REQUEST_STATE = /* @__PURE__ */ Symbol.for("autter.runtime.request");
643
744
  var BOUND = /* @__PURE__ */ Symbol.for("autter.runtime.bound");
644
- var CAPTURED = /* @__PURE__ */ new WeakSet();
745
+ var CAPTURED = _chunk4MVWIRBIcjs.sharedSlot.call(void 0, "requests", () => ({ captured: /* @__PURE__ */ new WeakSet() })).captured;
645
746
  var capturer = () => {
646
747
  };
647
748
  function setRequestExceptionCapturer(fn) {
@@ -657,30 +758,30 @@ function markCaptured(error) {
657
758
  }
658
759
  function expressRouteOf(req) {
659
760
  const props = req;
660
- const path = _optionalChain([props, 'optionalAccess', _8 => _8.route, 'optionalAccess', _9 => _9.path]);
761
+ const path = _optionalChain([props, 'optionalAccess', _10 => _10.route, 'optionalAccess', _11 => _11.path]);
661
762
  if (typeof path !== "string" || path === "") return null;
662
- const base = typeof _optionalChain([props, 'optionalAccess', _10 => _10.baseUrl]) === "string" ? props.baseUrl : "";
763
+ const base = typeof _optionalChain([props, 'optionalAccess', _12 => _12.baseUrl]) === "string" ? props.baseUrl : "";
663
764
  const route = base + path;
664
765
  return route.startsWith("/") ? route : null;
665
766
  }
666
767
  function defaultShouldCapture(error) {
667
- return error instanceof _chunkUKYTXZOQcjs.RuntimeError || _chunkUKYTXZOQcjs.errorCodeOf.call(void 0, error) !== void 0 || _chunkUKYTXZOQcjs.responseStatusOf.call(void 0, error) >= 500;
768
+ return error instanceof _chunkUXTIMS3Gcjs.RuntimeError || _chunkUXTIMS3Gcjs.errorCodeOf.call(void 0, error) !== void 0 || _chunkUXTIMS3Gcjs.responseStatusOf.call(void 0, error) >= 500;
668
769
  }
669
770
  function onRequestSpan(fn) {
670
- const active2 = _api.context.active();
671
- const metadata = _core.getRPCMetadata.call(void 0, active2);
672
- const span = _optionalChain([metadata, 'optionalAccess', _11 => _11.type]) === _core.RPCType.HTTP ? metadata.span : void 0;
673
- if (!span || !span.isRecording() || _api.trace.getSpan(active2) === span) {
771
+ const active = _api.context.active();
772
+ const metadata = _core.getRPCMetadata.call(void 0, active);
773
+ const span = _optionalChain([metadata, 'optionalAccess', _13 => _13.type]) === _core.RPCType.HTTP ? metadata.span : void 0;
774
+ if (!span || !span.isRecording() || _api.trace.getSpan(active) === span) {
674
775
  fn();
675
776
  return;
676
777
  }
677
- _api.context.with(_api.trace.setSpan(active2, span), fn);
778
+ _api.context.with(_api.trace.setSpan(active, span), fn);
678
779
  }
679
780
  function captureAtBoundary(error, state, rule = void 0, attributes) {
680
781
  let wanted;
681
782
  try {
682
783
  wanted = typeof rule === "function" ? rule(error) : rule === void 0 ? defaultShouldCapture(error) : rule;
683
- } catch (e13) {
784
+ } catch (e14) {
684
785
  wanted = false;
685
786
  }
686
787
  if (!wanted) return;
@@ -688,9 +789,9 @@ function captureAtBoundary(error, state, rule = void 0, attributes) {
688
789
  markCaptured(error);
689
790
  try {
690
791
  const run = () => onRequestSpan(() => capturer(error, attributes));
691
- if (state && !state.sealed) _chunkUKYTXZOQcjs.local.run(state, run);
792
+ if (state && !state.sealed) _chunkUXTIMS3Gcjs.local.run(state, run);
692
793
  else run();
693
- } catch (e14) {
794
+ } catch (e15) {
694
795
  }
695
796
  }
696
797
  function requestStateOf(req) {
@@ -702,23 +803,23 @@ function captureRequestError(error, attributes) {
702
803
  if (!attributes) return;
703
804
  try {
704
805
  onRequestSpan(() => annotator(attributes));
705
- } catch (e15) {
806
+ } catch (e16) {
706
807
  }
707
808
  return;
708
809
  }
709
- captureAtBoundary(error, _chunkUKYTXZOQcjs.currentOperation.call(void 0, ), true, attributes);
810
+ captureAtBoundary(error, _chunkUXTIMS3Gcjs.currentOperation.call(void 0, ), true, attributes);
710
811
  }
711
812
  function bindEmitter(emitter, state) {
712
813
  const target = emitter;
713
814
  if (!target || typeof target !== "object" || target[BOUND]) return;
714
815
  target[BOUND] = true;
715
816
  const wrappers = /* @__PURE__ */ new WeakMap();
716
- const wrap = (listener) => {
817
+ const wrap2 = (listener) => {
717
818
  if (typeof listener !== "function") return listener;
718
819
  let wrapped = wrappers.get(listener);
719
820
  if (!wrapped) {
720
821
  wrapped = function(...args) {
721
- return _chunkUKYTXZOQcjs.local.run(
822
+ return _chunkUXTIMS3Gcjs.local.run(
722
823
  state,
723
824
  () => listener.apply(this, args)
724
825
  );
@@ -737,7 +838,7 @@ function bindEmitter(emitter, state) {
737
838
  const original = target[method];
738
839
  if (typeof original !== "function") continue;
739
840
  target[method] = function(event, listener) {
740
- return original.call(this, event, wrap(listener));
841
+ return original.call(this, event, wrap2(listener));
741
842
  };
742
843
  }
743
844
  for (const method of ["removeListener", "off"]) {
@@ -773,7 +874,7 @@ function exposeOnCors(res, header) {
773
874
  if (value && key && inline) inline[key] = value;
774
875
  else if (value) res.setHeader("access-control-expose-headers", value);
775
876
  }
776
- } catch (e16) {
877
+ } catch (e17) {
777
878
  }
778
879
  return original.apply(this, args);
779
880
  };
@@ -785,7 +886,7 @@ function pathOf(req) {
785
886
  function finishRequest(state, input) {
786
887
  if (state.sealed) return;
787
888
  state.name = (_nullishCoalesce(input.name, () => ( `${input.method} ${input.route}`))).slice(0, 200);
788
- state.outcome = _chunkUKYTXZOQcjs.requestOutcome.call(void 0, {
889
+ state.outcome = _chunkUXTIMS3Gcjs.requestOutcome.call(void 0, {
789
890
  ...state.explicitOutcome ? { explicit: state.outcome } : {},
790
891
  ...state.error !== void 0 ? { error: state.error } : {},
791
892
  ...state.errorThrown ? { thrown: true } : {},
@@ -793,15 +894,15 @@ function finishRequest(state, input) {
793
894
  aborted: input.aborted
794
895
  });
795
896
  const span = _api.trace.getActiveSpan();
796
- if (_optionalChain([span, 'optionalAccess', _12 => _12.isRecording, 'call', _13 => _13()])) span.setAttribute("autter.operation.outcome", state.outcome);
897
+ if (_optionalChain([span, 'optionalAccess', _14 => _14.isRecording, 'call', _15 => _15()])) span.setAttribute("autter.operation.outcome", state.outcome);
797
898
  if (input.span) {
798
899
  const remote = _api.trace.wrapSpanContext(input.span);
799
900
  _api.context.with(
800
901
  _api.trace.setSpan(_api.context.active(), remote),
801
- () => _chunkUKYTXZOQcjs.reportExplicitFailure.call(void 0, state)
902
+ () => _chunkUXTIMS3Gcjs.reportExplicitFailure.call(void 0, state)
802
903
  );
803
- } else _chunkUKYTXZOQcjs.reportExplicitFailure.call(void 0, state);
804
- _chunkUKYTXZOQcjs.emitSummary.call(void 0, state, {
904
+ } else _chunkUXTIMS3Gcjs.reportExplicitFailure.call(void 0, state);
905
+ _chunkUXTIMS3Gcjs.emitSummary.call(void 0, state, {
805
906
  http: {
806
907
  "http.request.method": input.method,
807
908
  "http.route": input.route,
@@ -812,14 +913,14 @@ function finishRequest(state, input) {
812
913
  });
813
914
  }
814
915
  function beginNodeRequest(req, res, options, route) {
815
- const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkUKYTXZOQcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
816
- const requestId = _chunkUKYTXZOQcjs.resolveRequestId.call(void 0,
916
+ const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkUXTIMS3Gcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
917
+ const requestId = _chunkUXTIMS3Gcjs.resolveRequestId.call(void 0,
817
918
  options.trustRequestId === false ? void 0 : req.headers[header]
818
919
  );
819
920
  const method = (_nullishCoalesce(req.method, () => ( "GET"))).toUpperCase();
820
921
  const path = pathOf(req);
821
- const state = _chunkUKYTXZOQcjs.createRequestState.call(void 0, {
822
- name: `${method} ${_chunkUKYTXZOQcjs.normalizeRoutePath.call(void 0, path)}`,
922
+ const state = _chunkUXTIMS3Gcjs.createRequestState.call(void 0, {
923
+ name: `${method} ${_chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, path)}`,
823
924
  requestId,
824
925
  req,
825
926
  res
@@ -828,22 +929,22 @@ function beginNodeRequest(req, res, options, route) {
828
929
  try {
829
930
  if (!res.headersSent) res.setHeader(header, requestId);
830
931
  exposeOnCors(res, header);
831
- } catch (e17) {
932
+ } catch (e18) {
832
933
  }
833
934
  const span = _api.trace.getActiveSpan();
834
- if (_optionalChain([span, 'optionalAccess', _14 => _14.isRecording, 'call', _15 => _15()]))
935
+ if (_optionalChain([span, 'optionalAccess', _16 => _16.isRecording, 'call', _17 => _17()]))
835
936
  span.setAttributes({
836
937
  "autter.request.id": requestId,
837
938
  "autter.operation.kind": "request"
838
939
  });
839
- const spanContext = _optionalChain([span, 'optionalAccess', _16 => _16.spanContext, 'call', _17 => _17()]);
940
+ const spanContext = _optionalChain([span, 'optionalAccess', _18 => _18.spanContext, 'call', _19 => _19()]);
840
941
  bindEmitter(req, state);
841
942
  bindEmitter(res, state);
842
943
  let finished = false;
843
944
  const done = () => {
844
945
  finishRequest(state, {
845
946
  method,
846
- route: _nullishCoalesce(_nullishCoalesce(_optionalChain([route, 'optionalCall', _18 => _18()]), () => ( expressRouteOf(req))), () => ( _chunkUKYTXZOQcjs.normalizeRoutePath.call(void 0, path))),
947
+ route: _nullishCoalesce(_nullishCoalesce(_optionalChain([route, 'optionalCall', _20 => _20()]), () => ( expressRouteOf(req))), () => ( _chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, path))),
847
948
  status: res.statusCode,
848
949
  aborted: !finished,
849
950
  ...spanContext ? { span: spanContext } : {}
@@ -857,50 +958,50 @@ function beginNodeRequest(req, res, options, route) {
857
958
  return state;
858
959
  }
859
960
  function autterRequests(options = {}) {
860
- const ignored = _chunkUKYTXZOQcjs.compileIgnore.call(void 0, options.ignore);
961
+ const ignored = _chunkUXTIMS3Gcjs.compileIgnore.call(void 0, options.ignore);
861
962
  return function autterRequestsMiddleware(req, res, next) {
862
963
  if (req[REQUEST_STATE] || ignored(pathOf(req))) {
863
964
  next();
864
965
  return;
865
966
  }
866
967
  const state = beginNodeRequest(req, res, options);
867
- _chunkUKYTXZOQcjs.local.run(state, () => next());
968
+ _chunkUXTIMS3Gcjs.local.run(state, () => next());
868
969
  };
869
970
  }
870
971
  function autterErrorResponse(options = {}) {
871
972
  return function autterErrorResponseMiddleware(error, req, res, next) {
872
973
  const state = req[REQUEST_STATE];
873
- if (state) _chunkUKYTXZOQcjs.noteOperationError.call(void 0, error, true, state);
974
+ if (state) _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error, true, state);
874
975
  captureAtBoundary(error, state, options.capture);
875
976
  if (res.headersSent) {
876
977
  next(error);
877
978
  return;
878
979
  }
879
- const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkUKYTXZOQcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
880
- const inbound = _optionalChain([req, 'access', _19 => _19.headers, 'optionalAccess', _20 => _20[header]]);
881
- const requestId = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _21 => _21.requestId]), () => ( (typeof inbound === "string" ? inbound.slice(0, 128) : void 0)));
882
- res.statusCode = _chunkUKYTXZOQcjs.responseStatusOf.call(void 0, error);
980
+ const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkUXTIMS3Gcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
981
+ const inbound = _optionalChain([req, 'access', _21 => _21.headers, 'optionalAccess', _22 => _22[header]]);
982
+ const requestId = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _23 => _23.requestId]), () => ( (typeof inbound === "string" ? inbound.slice(0, 128) : void 0)));
983
+ res.statusCode = _chunkUXTIMS3Gcjs.responseStatusOf.call(void 0, error);
883
984
  res.setHeader("content-type", "application/json; charset=utf-8");
884
- res.end(JSON.stringify(_chunkUKYTXZOQcjs.toClientError.call(void 0, error, requestId)));
985
+ res.end(JSON.stringify(_chunkUXTIMS3Gcjs.toClientError.call(void 0, error, requestId)));
885
986
  };
886
987
  }
887
988
  var RESOURCE = /* @__PURE__ */ Symbol.for("autter.runtime.resource");
888
989
  function autterFastify(fastify, options, done) {
889
990
  const opts = _nullishCoalesce(options, () => ( {}));
890
- const header = (_nullishCoalesce(opts.requestIdHeader, () => ( _chunkUKYTXZOQcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
891
- const ignored = _chunkUKYTXZOQcjs.compileIgnore.call(void 0, opts.ignore);
991
+ const header = (_nullishCoalesce(opts.requestIdHeader, () => ( _chunkUXTIMS3Gcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
992
+ const ignored = _chunkUXTIMS3Gcjs.compileIgnore.call(void 0, opts.ignore);
892
993
  const stateOf = (request) => request[REQUEST_STATE];
893
994
  fastify.addHook("onRequest", ((request, reply, next) => {
894
995
  if (ignored(request.url) || request.raw[REQUEST_STATE]) {
895
996
  next();
896
997
  return;
897
998
  }
898
- const requestId = _chunkUKYTXZOQcjs.resolveRequestId.call(void 0,
999
+ const requestId = _chunkUXTIMS3Gcjs.resolveRequestId.call(void 0,
899
1000
  opts.trustRequestId === false ? void 0 : request.headers[header]
900
1001
  );
901
1002
  const method = String(_nullishCoalesce(request.method, () => ( "GET"))).toUpperCase();
902
- const state = _chunkUKYTXZOQcjs.createRequestState.call(void 0, {
903
- name: `${method} ${_chunkUKYTXZOQcjs.normalizeRoutePath.call(void 0, request.url)}`,
1003
+ const state = _chunkUXTIMS3Gcjs.createRequestState.call(void 0, {
1004
+ name: `${method} ${_chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, request.url)}`,
904
1005
  requestId,
905
1006
  req: request.raw,
906
1007
  res: reply.raw
@@ -909,18 +1010,18 @@ function autterFastify(fastify, options, done) {
909
1010
  request.raw[REQUEST_STATE] = state;
910
1011
  reply.header(header, requestId);
911
1012
  const span = _api.trace.getActiveSpan();
912
- if (_optionalChain([span, 'optionalAccess', _22 => _22.isRecording, 'call', _23 => _23()]))
1013
+ if (_optionalChain([span, 'optionalAccess', _24 => _24.isRecording, 'call', _25 => _25()]))
913
1014
  span.setAttributes({
914
1015
  "autter.request.id": requestId,
915
1016
  "autter.operation.kind": "request"
916
1017
  });
917
- const spanContext = _optionalChain([span, 'optionalAccess', _24 => _24.spanContext, 'call', _25 => _25()]);
1018
+ const spanContext = _optionalChain([span, 'optionalAccess', _26 => _26.spanContext, 'call', _27 => _27()]);
918
1019
  bindEmitter(request.raw, state);
919
1020
  bindEmitter(reply.raw, state);
920
1021
  let finished = false;
921
1022
  const finish = (aborted) => finishRequest(state, {
922
1023
  method,
923
- route: _nullishCoalesce(_nullishCoalesce(_optionalChain([request, 'access', _26 => _26.routeOptions, 'optionalAccess', _27 => _27.url]), () => ( request.routerPath)), () => ( _chunkUKYTXZOQcjs.normalizeRoutePath.call(void 0, request.url))),
1024
+ route: _nullishCoalesce(_nullishCoalesce(_optionalChain([request, 'access', _28 => _28.routeOptions, 'optionalAccess', _29 => _29.url]), () => ( request.routerPath)), () => ( _chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, request.url))),
924
1025
  status: reply.raw.statusCode || reply.statusCode,
925
1026
  aborted,
926
1027
  ...spanContext ? { span: spanContext } : {}
@@ -930,7 +1031,7 @@ function autterFastify(fastify, options, done) {
930
1031
  finish(false);
931
1032
  });
932
1033
  reply.raw.once("close", () => finish(!finished));
933
- _chunkUKYTXZOQcjs.local.run(state, () => {
1034
+ _chunkUXTIMS3Gcjs.local.run(state, () => {
934
1035
  request[RESOURCE] = new (0, _async_hooks.AsyncResource)("autter-request");
935
1036
  next();
936
1037
  });
@@ -946,13 +1047,13 @@ function autterFastify(fastify, options, done) {
946
1047
  const value = exposeHeaderValue(reply.getHeader("access-control-expose-headers"), header);
947
1048
  if (value) reply.header("access-control-expose-headers", value);
948
1049
  }
949
- } catch (e18) {
1050
+ } catch (e19) {
950
1051
  }
951
1052
  next(null, payload);
952
1053
  }));
953
1054
  fastify.addHook("onError", ((request, _reply, error, next) => {
954
1055
  const state = stateOf(request);
955
- if (state) _chunkUKYTXZOQcjs.noteOperationError.call(void 0, error, true, state);
1056
+ if (state) _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error, true, state);
956
1057
  captureAtBoundary(error, state);
957
1058
  next();
958
1059
  }));
@@ -974,48 +1075,48 @@ function withHeaders(response, header, requestId) {
974
1075
  };
975
1076
  try {
976
1077
  return apply(response);
977
- } catch (e19) {
1078
+ } catch (e20) {
978
1079
  try {
979
1080
  return apply(new Response(response.body, response));
980
- } catch (e20) {
1081
+ } catch (e21) {
981
1082
  return response;
982
1083
  }
983
1084
  }
984
1085
  }
985
1086
  function withRuntimeRequest(handler, options = {}) {
986
- const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkUKYTXZOQcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
987
- const ignored = _chunkUKYTXZOQcjs.compileIgnore.call(void 0, options.ignore);
1087
+ const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkUXTIMS3Gcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
1088
+ const ignored = _chunkUXTIMS3Gcjs.compileIgnore.call(void 0, options.ignore);
988
1089
  return async (request, ...rest) => {
989
1090
  let pathname = "/";
990
1091
  try {
991
1092
  pathname = new URL(request.url, "http://localhost").pathname;
992
- } catch (e21) {
1093
+ } catch (e22) {
993
1094
  }
994
1095
  if (ignored(pathname)) return handler(request, ...rest);
995
- const requestId = _chunkUKYTXZOQcjs.resolveRequestId.call(void 0,
1096
+ const requestId = _chunkUXTIMS3Gcjs.resolveRequestId.call(void 0,
996
1097
  options.trustRequestId === false ? void 0 : request.headers.get(header)
997
1098
  );
998
1099
  const method = String(_nullishCoalesce(request.method, () => ( "GET"))).toUpperCase();
999
- const route = _nullishCoalesce(options.route, () => ( _chunkUKYTXZOQcjs.normalizeRoutePath.call(void 0, pathname)));
1000
- const state = _chunkUKYTXZOQcjs.createRequestState.call(void 0, {
1100
+ const route = _nullishCoalesce(options.route, () => ( _chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, pathname)));
1101
+ const state = _chunkUXTIMS3Gcjs.createRequestState.call(void 0, {
1001
1102
  name: `${method} ${_nullishCoalesce(options.name, () => ( route))}`,
1002
1103
  requestId,
1003
1104
  req: request
1004
1105
  });
1005
1106
  const span = _api.trace.getActiveSpan();
1006
- if (_optionalChain([span, 'optionalAccess', _28 => _28.isRecording, 'call', _29 => _29()]))
1107
+ if (_optionalChain([span, 'optionalAccess', _30 => _30.isRecording, 'call', _31 => _31()]))
1007
1108
  span.setAttributes({
1008
1109
  "autter.request.id": requestId,
1009
1110
  "autter.operation.kind": "request"
1010
1111
  });
1011
- const spanContext = _optionalChain([span, 'optionalAccess', _30 => _30.spanContext, 'call', _31 => _31()]);
1112
+ const spanContext = _optionalChain([span, 'optionalAccess', _32 => _32.spanContext, 'call', _33 => _33()]);
1012
1113
  let status = 500;
1013
1114
  try {
1014
- const response = await _chunkUKYTXZOQcjs.local.run(state, async () => {
1115
+ const response = await _chunkUXTIMS3Gcjs.local.run(state, async () => {
1015
1116
  try {
1016
1117
  return await handler(request, ...rest);
1017
1118
  } catch (error) {
1018
- _chunkUKYTXZOQcjs.noteOperationError.call(void 0, error, true, state);
1119
+ _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error, true, state);
1019
1120
  captureAtBoundary(error, state, true);
1020
1121
  throw error;
1021
1122
  }
@@ -1023,7 +1124,7 @@ function withRuntimeRequest(handler, options = {}) {
1023
1124
  status = response.status;
1024
1125
  return withHeaders(response, header, requestId);
1025
1126
  } finally {
1026
- const aborted = _optionalChain([request, 'access', _32 => _32.signal, 'optionalAccess', _33 => _33.aborted]) === true;
1127
+ const aborted = _optionalChain([request, 'access', _34 => _34.signal, 'optionalAccess', _35 => _35.aborted]) === true;
1027
1128
  finishRequest(state, {
1028
1129
  method,
1029
1130
  route,
@@ -1034,9 +1135,9 @@ function withRuntimeRequest(handler, options = {}) {
1034
1135
  });
1035
1136
  if (options.waitUntil) {
1036
1137
  try {
1037
- options.waitUntil(_chunkUKYTXZOQcjs.flushRuntimeLogs.call(void 0, ).catch(() => {
1138
+ options.waitUntil(_chunkUXTIMS3Gcjs.flushRuntimeLogs.call(void 0, ).catch(() => {
1038
1139
  }));
1039
- } catch (e22) {
1140
+ } catch (e23) {
1040
1141
  }
1041
1142
  }
1042
1143
  }
@@ -1046,7 +1147,7 @@ function startHookRequest(res) {
1046
1147
  const req = res.req;
1047
1148
  if (!req || req[REQUEST_STATE]) return;
1048
1149
  const state = beginNodeRequest(req, res, {});
1049
- _chunkUKYTXZOQcjs.local.enterWith(state);
1150
+ _chunkUXTIMS3Gcjs.local.enterWith(state);
1050
1151
  }
1051
1152
 
1052
1153
  // src/unhandled-rejections.ts
@@ -1072,7 +1173,7 @@ var recorded = /* @__PURE__ */ new WeakSet();
1072
1173
  function markRecorded(reason) {
1073
1174
  if (!reason || typeof reason !== "object") return;
1074
1175
  recorded.add(reason);
1075
- _optionalChain([setImmediate, 'call', _34 => _34(() => recorded.delete(reason)), 'access', _35 => _35.unref, 'optionalCall', _36 => _36()]);
1176
+ _optionalChain([setImmediate, 'call', _36 => _36(() => recorded.delete(reason)), 'access', _37 => _37.unref, 'optionalCall', _38 => _38()]);
1076
1177
  }
1077
1178
  function recordedAsRejection(error) {
1078
1179
  return !!error && typeof error === "object" && recorded.has(error);
@@ -1098,7 +1199,7 @@ function unhandledRejectionsMode(execArgv = process.execArgv, nodeOptions = proc
1098
1199
  function isErrorLike(value) {
1099
1200
  try {
1100
1201
  return typeof value === "object" && value !== null && Object.prototype.hasOwnProperty.call(value, "stack");
1101
- } catch (e23) {
1202
+ } catch (e24) {
1102
1203
  return false;
1103
1204
  }
1104
1205
  }
@@ -1106,16 +1207,16 @@ function describeReason(reason) {
1106
1207
  if (typeof reason !== "object" && typeof reason !== "function" || reason === null) {
1107
1208
  try {
1108
1209
  return String(reason);
1109
- } catch (e24) {
1210
+ } catch (e25) {
1110
1211
  return typeof reason;
1111
1212
  }
1112
1213
  }
1113
1214
  try {
1114
1215
  const proto = Object.getPrototypeOf(reason);
1115
- const ctor = _optionalChain([proto, 'optionalAccess', _37 => _37.constructor]);
1216
+ const ctor = _optionalChain([proto, 'optionalAccess', _39 => _39.constructor]);
1116
1217
  const name = typeof ctor === "function" ? ctor.name : "";
1117
1218
  return name ? `#<${name}>` : "[object Object]";
1118
- } catch (e25) {
1219
+ } catch (e26) {
1119
1220
  return "[object Object]";
1120
1221
  }
1121
1222
  }
@@ -1126,7 +1227,7 @@ function toUncaught(reason, from) {
1126
1227
  );
1127
1228
  error.name = "UnhandledPromiseRejection";
1128
1229
  error.code = "ERR_UNHANDLED_REJECTION";
1129
- _optionalChain([Error, 'access', _38 => _38.captureStackTrace, 'optionalCall', _39 => _39(error, from)]);
1230
+ _optionalChain([Error, 'access', _40 => _40.captureStackTrace, 'optionalCall', _41 => _41(error, from)]);
1130
1231
  return error;
1131
1232
  }
1132
1233
  var warningId = 0;
@@ -1138,7 +1239,7 @@ function emitNodeWarning(reason) {
1138
1239
  `Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag \`--unhandled-rejections=strict\` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: ${++warningId})`,
1139
1240
  "UnhandledPromiseRejectionWarning"
1140
1241
  );
1141
- } catch (e26) {
1242
+ } catch (e27) {
1142
1243
  }
1143
1244
  }
1144
1245
  function installUnhandledRejectionCapture(capture, mode = unhandledRejectionsMode()) {
@@ -1165,7 +1266,7 @@ function installUnhandledRejectionCapture(capture, mode = unhandledRejectionsMod
1165
1266
  }
1166
1267
  markRecorded(reason);
1167
1268
  capture(reason);
1168
- } catch (e27) {
1269
+ } catch (e28) {
1169
1270
  }
1170
1271
  };
1171
1272
  listener[LISTENER_MARK] = true;
@@ -1176,6 +1277,13 @@ function installUnhandledRejectionCapture(capture, mode = unhandledRejectionsMod
1176
1277
  }
1177
1278
 
1178
1279
  // src/server.ts
1280
+ var S = _chunk4MVWIRBIcjs.sharedSlot.call(void 0, "server", () => ({
1281
+ active: null,
1282
+ alwaysOnProvider: null,
1283
+ redactor: _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, true),
1284
+ loggerOnlyCapture: null,
1285
+ hookRequests: false
1286
+ }));
1179
1287
  var LLM_MARKER_ATTRIBUTES = [
1180
1288
  "gen_ai.operation.name",
1181
1289
  "gen_ai.system",
@@ -1272,7 +1380,7 @@ var ErrorTraceRetentionProcessor = (_class2 = class {
1272
1380
  this.retainErrors = retainErrors;
1273
1381
  this.slowThresholdMs = slowThresholdMs;
1274
1382
  this.sweeper = setInterval(() => this.sweep(), RETENTION_SWEEP_INTERVAL_MS);
1275
- _optionalChain([this, 'access', _40 => _40.sweeper, 'access', _41 => _41.unref, 'optionalCall', _42 => _42()]);
1383
+ _optionalChain([this, 'access', _42 => _42.sweeper, 'access', _43 => _43.unref, 'optionalCall', _44 => _44()]);
1276
1384
  }
1277
1385
 
1278
1386
 
@@ -1303,9 +1411,9 @@ var ErrorTraceRetentionProcessor = (_class2 = class {
1303
1411
  }
1304
1412
  /** Promote the active trace, if any — called on captured errors. */
1305
1413
  retainActiveTrace() {
1306
- const active2 = _optionalChain([_api.trace, 'access', _43 => _43.getActiveSpan, 'call', _44 => _44(), 'optionalAccess', _45 => _45.spanContext, 'call', _46 => _46()]);
1307
- if (!active2 || (active2.traceFlags & _api.TraceFlags.SAMPLED) !== 0) return;
1308
- const entry = this.entryFor(active2.traceId);
1414
+ const active = _optionalChain([_api.trace, 'access', _45 => _45.getActiveSpan, 'call', _46 => _46(), 'optionalAccess', _47 => _47.spanContext, 'call', _48 => _48()]);
1415
+ if (!active || (active.traceFlags & _api.TraceFlags.SAMPLED) !== 0) return;
1416
+ const entry = this.entryFor(active.traceId);
1309
1417
  if (entry.retained) return;
1310
1418
  entry.retained = true;
1311
1419
  this.flush(entry);
@@ -1372,7 +1480,7 @@ function llmBaseAttributes(info) {
1372
1480
  ...info.sessionId ? { "autter.session_id": info.sessionId } : {},
1373
1481
  // Caller-supplied extras go through redaction like every other
1374
1482
  // custom attribute family (prompts can contain emails/keys).
1375
- ...info.attributes ? activeRedactor(info.attributes) : {}
1483
+ ...info.attributes ? S.redactor(info.attributes) : {}
1376
1484
  };
1377
1485
  }
1378
1486
  function usageAttributes(usage) {
@@ -1413,7 +1521,7 @@ async function runLlmSpan(tracer, info, fn) {
1413
1521
  },
1414
1522
  setResponseModel,
1415
1523
  setModel: setResponseModel,
1416
- setAttributes: (attributes) => span.setAttributes(activeRedactor(attributes))
1524
+ setAttributes: (attributes) => span.setAttributes(S.redactor(attributes))
1417
1525
  };
1418
1526
  try {
1419
1527
  const result = await _api.context.with(
@@ -1424,15 +1532,15 @@ async function runLlmSpan(tracer, info, fn) {
1424
1532
  return result;
1425
1533
  } catch (err) {
1426
1534
  recordError(span, err);
1427
- if (_chunkUKYTXZOQcjs.isError.call(void 0, err)) span.setAttribute("error.type", err.name);
1535
+ if (_chunkUXTIMS3Gcjs.isError.call(void 0, err)) span.setAttribute("error.type", err.name);
1428
1536
  throw err;
1429
1537
  } finally {
1430
1538
  span.end();
1431
- _chunkUKYTXZOQcjs.recordOperationAiUsage.call(void 0, { ...usage, model: _nullishCoalesce(responseModel, () => ( info.model)) });
1539
+ _chunkUXTIMS3Gcjs.recordOperationAiUsage.call(void 0, { ...usage, model: _nullishCoalesce(responseModel, () => ( info.model)) });
1432
1540
  }
1433
1541
  }
1434
1542
  function recordLlmCall(tracer, call) {
1435
- _chunkUKYTXZOQcjs.recordOperationAiUsage.call(void 0, { ...call, model: call.model });
1543
+ _chunkUXTIMS3Gcjs.recordOperationAiUsage.call(void 0, { ...call, model: call.model });
1436
1544
  const durationMs = Math.max(0, _nullishCoalesce(call.durationMs, () => ( 0)));
1437
1545
  const endTime = /* @__PURE__ */ new Date();
1438
1546
  const startTime = new Date(endTime.getTime() - durationMs);
@@ -1446,7 +1554,7 @@ function recordLlmCall(tracer, call) {
1446
1554
  );
1447
1555
  if (call.error !== void 0 && call.error !== null) {
1448
1556
  recordError(span, call.error);
1449
- if (_chunkUKYTXZOQcjs.isError.call(void 0, call.error)) {
1557
+ if (_chunkUXTIMS3Gcjs.isError.call(void 0, call.error)) {
1450
1558
  span.setAttribute("error.type", call.error.name);
1451
1559
  }
1452
1560
  } else {
@@ -1457,7 +1565,7 @@ function recordLlmCall(tracer, call) {
1457
1565
  async function runWithSpan(tracer, name, fn, attributes, links) {
1458
1566
  const span = tracer.startSpan(name, {
1459
1567
  attributes,
1460
- ..._optionalChain([links, 'optionalAccess', _47 => _47.length]) ? { links } : {}
1568
+ ..._optionalChain([links, 'optionalAccess', _49 => _49.length]) ? { links } : {}
1461
1569
  });
1462
1570
  try {
1463
1571
  const result = await _api.context.with(
@@ -1474,25 +1582,25 @@ async function runWithSpan(tracer, name, fn, attributes, links) {
1474
1582
  }
1475
1583
  }
1476
1584
  function recordError(span, err) {
1477
- const isErr = _chunkUKYTXZOQcjs.isError.call(void 0, err);
1478
- const message = activeRedactor.text(isErr ? err.message : String(err));
1585
+ const isErr = _chunkUXTIMS3Gcjs.isError.call(void 0, err);
1586
+ const message = S.redactor.text(isErr ? err.message : String(err));
1479
1587
  if (isErr) {
1480
1588
  span.addEvent("exception", {
1481
1589
  "exception.type": err.name,
1482
1590
  "exception.message": message,
1483
- ...err.stack ? { "exception.stacktrace": activeRedactor.text(err.stack) } : {},
1484
- ..._chunkUKYTXZOQcjs.breadcrumbEventAttributes.call(void 0, activeRedactor.text, err)
1591
+ ...err.stack ? { "exception.stacktrace": S.redactor.text(err.stack) } : {},
1592
+ ..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text, err)
1485
1593
  });
1486
1594
  }
1487
1595
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message });
1488
1596
  }
1489
1597
  function redactWithActive(attributes) {
1490
- return activeRedactor(attributes);
1598
+ return S.redactor(attributes);
1491
1599
  }
1492
1600
  function captureExpressRoute(_span, response) {
1493
1601
  if (!(response instanceof _http.ServerResponse)) return;
1494
1602
  const rpcMetadata = _core.getRPCMetadata.call(void 0, _api.context.active());
1495
- if (_optionalChain([rpcMetadata, 'optionalAccess', _48 => _48.type]) !== _core.RPCType.HTTP) return;
1603
+ if (_optionalChain([rpcMetadata, 'optionalAccess', _50 => _50.type]) !== _core.RPCType.HTTP) return;
1496
1604
  const setRoute = () => {
1497
1605
  if (rpcMetadata.route) return;
1498
1606
  const route = expressRouteOf(response.req);
@@ -1500,44 +1608,43 @@ function captureExpressRoute(_span, response) {
1500
1608
  };
1501
1609
  response.prependListener("finish", setRoute);
1502
1610
  response.prependListener("close", setRoute);
1503
- if (hookRequests) startHookRequest(response);
1611
+ if (S.hookRequests) startHookRequest(response);
1504
1612
  }
1505
- var hookRequests = false;
1506
1613
  function structuredErrorAttributes(error) {
1507
- const attrs = { ..._chunkUKYTXZOQcjs.errorAttributes.call(void 0, error, { causes: false }) };
1508
- const internal = _chunkUKYTXZOQcjs.errorInternal.call(void 0, error);
1614
+ const attrs = { ..._chunkUXTIMS3Gcjs.errorAttributes.call(void 0, error, { causes: false }) };
1615
+ const internal = _chunkUXTIMS3Gcjs.errorInternal.call(void 0, error);
1509
1616
  if (internal) {
1510
1617
  try {
1511
1618
  attrs["autter.error.internal"] = JSON.stringify(
1512
- activeRedactor(internal)
1619
+ S.redactor(internal)
1513
1620
  ).slice(0, 4e3);
1514
- } catch (e28) {
1621
+ } catch (e29) {
1515
1622
  }
1516
1623
  }
1517
1624
  return attrs;
1518
1625
  }
1519
- var active = null;
1520
- var activeAlwaysOnProvider = null;
1521
- var activeRedactor = _chunkUKYTXZOQcjs.makeRedactor.call(void 0, true);
1522
1626
  function initAutterServer(options) {
1523
- if (active) return active;
1627
+ if (S.active) return S.active;
1524
1628
  const endpoint = (_nullishCoalesce(options.endpoint, () => ( "https://otlp.autter.dev"))).replace(
1525
1629
  /\/$/,
1526
1630
  ""
1527
1631
  );
1528
1632
  const headers = { authorization: `Bearer ${options.apiKey}` };
1529
- const traceExporter = () => new (0, _chunkARN26OK6cjs.CountingExporter)(
1633
+ const redactor = _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
1634
+ const queryPolicy = makeUrlQueryPolicy(options.keepQueryParams);
1635
+ const traceExporter = () => new (0, _chunk4MVWIRBIcjs.CountingExporter)(
1530
1636
  new RedactingSpanExporter(
1531
1637
  new (0, _exportertraceotlphttp.OTLPTraceExporter)({ url: `${endpoint}/v1/traces`, headers }),
1532
- () => activeRedactor
1638
+ () => redactor,
1639
+ queryPolicy
1533
1640
  )
1534
1641
  );
1535
1642
  const environment = _nullishCoalesce(_nullishCoalesce(options.environment, () => ( process.env.NODE_ENV)), () => ( "production"));
1536
- if (_chunkARN26OK6cjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunkARN26OK6cjs.setDebugMode.call(void 0, true);
1537
- _chunkARN26OK6cjs.debugLog.call(void 0, `initialising service=${options.service} endpoint=${endpoint}`);
1538
- activeRedactor = _chunkUKYTXZOQcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
1539
- const distro = _nullishCoalesce(options.distro, () => ( _chunkARN26OK6cjs.SDK_IDENTITY));
1540
- _chunkARN26OK6cjs.configureCompatCheck.call(void 0, { endpoint, enabled: options.compatCheck !== false, sdk: distro });
1643
+ if (_chunk4MVWIRBIcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunk4MVWIRBIcjs.setDebugMode.call(void 0, true);
1644
+ _chunk4MVWIRBIcjs.debugLog.call(void 0, `initialising service=${options.service} endpoint=${endpoint}`);
1645
+ S.redactor = redactor;
1646
+ const distro = _nullishCoalesce(options.distro, () => ( _chunk4MVWIRBIcjs.SDK_IDENTITY));
1647
+ _chunk4MVWIRBIcjs.configureCompatCheck.call(void 0, { endpoint, enabled: options.compatCheck !== false, sdk: distro });
1541
1648
  const resource = new (0, _resources.Resource)({
1542
1649
  [_semanticconventions.ATTR_SERVICE_NAME]: options.service,
1543
1650
  "service.instance.id": (options.instanceId || process.env.AUTTER_RUNTIME_INSTANCE_ID || _crypto.randomUUID.call(void 0, )).slice(0, 128),
@@ -1584,7 +1691,7 @@ function initAutterServer(options) {
1584
1691
  // 60 s export.
1585
1692
  temporalityPreference: _exportermetricsotlphttp.AggregationTemporalityPreference.DELTA
1586
1693
  }),
1587
- () => activeRedactor
1694
+ () => redactor
1588
1695
  ),
1589
1696
  exportIntervalMillis: _nullishCoalesce(options.metricIntervalMs, () => ( 6e4))
1590
1697
  });
@@ -1611,9 +1718,9 @@ function initAutterServer(options) {
1611
1718
  });
1612
1719
  sdk.start();
1613
1720
  const stopMemoryMetrics = options.memoryMetrics === false ? null : startMemoryMetrics();
1614
- _chunkARN26OK6cjs.noteCompatFeature.call(void 0, "endpoint_latency");
1615
- if (stopMemoryMetrics) _chunkARN26OK6cjs.noteCompatFeature.call(void 0, "memory_metrics");
1616
- if (options.llmTracing !== false) _chunkARN26OK6cjs.noteCompatFeature.call(void 0, "llm_calls");
1721
+ _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "endpoint_latency");
1722
+ if (stopMemoryMetrics) _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "memory_metrics");
1723
+ if (options.llmTracing !== false) _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "llm_calls");
1617
1724
  const alwaysOnProvider = new (0, _sdktracebase.BasicTracerProvider)({
1618
1725
  resource,
1619
1726
  sampler: new (0, _sdktracebase.AlwaysOnSampler)(),
@@ -1625,25 +1732,25 @@ function initAutterServer(options) {
1625
1732
  const processTracer = alwaysOnProvider.getTracer("autter-processes");
1626
1733
  const llmTracer = alwaysOnProvider.getTracer("autter-llm");
1627
1734
  function captureException2(error, attributes) {
1628
- _optionalChain([errorTraceBuffer, 'optionalAccess', _49 => _49.retainActiveTrace, 'call', _50 => _50()]);
1629
- _chunkARN26OK6cjs.telemetryStats.markCaptured();
1630
- const isErr = _chunkUKYTXZOQcjs.isError.call(void 0, error);
1631
- const message = activeRedactor.text(isErr ? error.message : String(error));
1632
- const stackText = isErr && error.stack ? activeRedactor.text(error.stack) : "";
1633
- const split = _chunkUKYTXZOQcjs.splitFingerprint.call(void 0, attributes);
1634
- const fingerprint = _chunkUKYTXZOQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, activeRedactor.text);
1635
- if (fingerprint["autter.fingerprint"]) _chunkARN26OK6cjs.noteCompatFeature.call(void 0, "fingerprint_override");
1636
- const redacted = activeRedactor(split.attributes);
1735
+ _optionalChain([errorTraceBuffer, 'optionalAccess', _51 => _51.retainActiveTrace, 'call', _52 => _52()]);
1736
+ _chunk4MVWIRBIcjs.telemetryStats.markCaptured();
1737
+ const isErr = _chunkUXTIMS3Gcjs.isError.call(void 0, error);
1738
+ const message = redactor.text(isErr ? error.message : String(error));
1739
+ const stackText = isErr && error.stack ? redactor.text(error.stack) : "";
1740
+ const split = _chunkUXTIMS3Gcjs.splitFingerprint.call(void 0, attributes);
1741
+ const fingerprint = _chunkUXTIMS3Gcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redactor.text);
1742
+ if (fingerprint["autter.fingerprint"]) _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "fingerprint_override");
1743
+ const redacted = redactor(split.attributes);
1637
1744
  const activeSpan = _api.trace.getActiveSpan();
1638
- const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _51 => _51.isRecording, 'call', _52 => _52()]) === true;
1745
+ const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _53 => _53.isRecording, 'call', _54 => _54()]) === true;
1639
1746
  const span = reuseActive ? activeSpan : errorTracer.startSpan(isErr ? error.name : "Error");
1640
1747
  const structured = structuredErrorAttributes(error);
1641
- const causes = _chunkUKYTXZOQcjs.errorAttributes.call(void 0, error);
1748
+ const causes = _chunkUXTIMS3Gcjs.errorAttributes.call(void 0, error);
1642
1749
  const declared = {
1643
1750
  ...Object.fromEntries(Object.entries(causes).filter(([key]) => key !== "autter.error.internal")),
1644
1751
  ...fingerprint
1645
1752
  };
1646
- const requestId = _optionalChain([_chunkUKYTXZOQcjs.currentOperation.call(void 0, ), 'optionalAccess', _53 => _53.requestId]);
1753
+ const requestId = _optionalChain([_chunkUXTIMS3Gcjs.currentOperation.call(void 0, ), 'optionalAccess', _55 => _55.requestId]);
1647
1754
  span.setAttributes({
1648
1755
  "autter.severity": "error",
1649
1756
  ...redacted,
@@ -1651,8 +1758,8 @@ function initAutterServer(options) {
1651
1758
  ...requestId ? { "autter.request.id": requestId } : {}
1652
1759
  });
1653
1760
  markCaptured(error);
1654
- _chunkUKYTXZOQcjs.noteOperationError.call(void 0, error);
1655
- _chunkUKYTXZOQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
1761
+ _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error);
1762
+ _chunkUXTIMS3Gcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
1656
1763
  if (isErr && stackText) {
1657
1764
  span.addEvent("exception", {
1658
1765
  "exception.type": error.name,
@@ -1660,17 +1767,17 @@ function initAutterServer(options) {
1660
1767
  "exception.stacktrace": stackText,
1661
1768
  ...redacted["autter.handled"] === true ? { "autter.handled": true, "autter.sampled": redacted["autter.sampled"] === true } : {},
1662
1769
  ...declared,
1663
- ..._chunkUKYTXZOQcjs.breadcrumbEventAttributes.call(void 0, activeRedactor.text, error)
1770
+ ..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
1664
1771
  });
1665
1772
  } else {
1666
- const stack = _optionalChain([new Error(), 'access', _54 => _54.stack, 'optionalAccess', _55 => _55.split, 'call', _56 => _56("\n"), 'access', _57 => _57.filter, 'call', _58 => _58((line, i) => i === 0 || !line.includes("captureException")), 'access', _59 => _59.join, 'call', _60 => _60("\n")]);
1773
+ const stack = _optionalChain([new Error(), 'access', _56 => _56.stack, 'optionalAccess', _57 => _57.split, 'call', _58 => _58("\n"), 'access', _59 => _59.filter, 'call', _60 => _60((line, i) => i === 0 || !line.includes("captureException")), 'access', _61 => _61.join, 'call', _62 => _62("\n")]);
1667
1774
  span.addEvent("exception", {
1668
1775
  "exception.type": isErr ? error.name : "Error",
1669
1776
  "exception.message": message,
1670
- ...stack ? { "exception.stacktrace": activeRedactor.text(stack) } : {},
1777
+ ...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
1671
1778
  ...redacted["autter.handled"] === true ? { "autter.handled": true, "autter.sampled": redacted["autter.sampled"] === true } : {},
1672
1779
  ...declared,
1673
- ..._chunkUKYTXZOQcjs.breadcrumbEventAttributes.call(void 0, activeRedactor.text, error)
1780
+ ..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
1674
1781
  });
1675
1782
  }
1676
1783
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message });
@@ -1678,35 +1785,35 @@ function initAutterServer(options) {
1678
1785
  }
1679
1786
  function captureMessage2(message, severity = "warning", attributes) {
1680
1787
  if (severity === "error" || severity === "fatal") {
1681
- _optionalChain([errorTraceBuffer, 'optionalAccess', _61 => _61.retainActiveTrace, 'call', _62 => _62()]);
1788
+ _optionalChain([errorTraceBuffer, 'optionalAccess', _63 => _63.retainActiveTrace, 'call', _64 => _64()]);
1682
1789
  }
1683
- _chunkARN26OK6cjs.telemetryStats.markCaptured();
1684
- const stack = _optionalChain([new Error(), 'access', _63 => _63.stack, 'optionalAccess', _64 => _64.split, 'call', _65 => _65("\n"), 'access', _66 => _66.filter, 'call', _67 => _67((line, i) => i === 0 || !line.includes("captureMessage")), 'access', _68 => _68.join, 'call', _69 => _69("\n")]);
1685
- const safeMessage = activeRedactor.text(message);
1790
+ _chunk4MVWIRBIcjs.telemetryStats.markCaptured();
1791
+ const stack = _optionalChain([new Error(), 'access', _65 => _65.stack, 'optionalAccess', _66 => _66.split, 'call', _67 => _67("\n"), 'access', _68 => _68.filter, 'call', _69 => _69((line, i) => i === 0 || !line.includes("captureMessage")), 'access', _70 => _70.join, 'call', _71 => _71("\n")]);
1792
+ const safeMessage = redactor.text(message);
1686
1793
  const span = errorTracer.startSpan("Message", {
1687
- attributes: { "autter.severity": severity, ...activeRedactor(attributes) }
1794
+ attributes: { "autter.severity": severity, ...redactor(attributes) }
1688
1795
  });
1689
1796
  span.addEvent("exception", {
1690
1797
  "exception.type": "Message",
1691
1798
  "exception.message": safeMessage,
1692
- ...stack ? { "exception.stacktrace": activeRedactor.text(stack) } : {},
1799
+ ...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
1693
1800
  "autter.severity": severity,
1694
- ..._chunkUKYTXZOQcjs.breadcrumbEventAttributes.call(void 0, activeRedactor.text)
1801
+ ..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, redactor.text)
1695
1802
  });
1696
1803
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
1697
1804
  span.end();
1698
1805
  }
1699
1806
  function reportOutcome2(name, message, attributes) {
1700
- _optionalChain([errorTraceBuffer, 'optionalAccess', _70 => _70.retainActiveTrace, 'call', _71 => _71()]);
1701
- _chunkARN26OK6cjs.telemetryStats.markCaptured();
1807
+ _optionalChain([errorTraceBuffer, 'optionalAccess', _72 => _72.retainActiveTrace, 'call', _73 => _73()]);
1808
+ _chunk4MVWIRBIcjs.telemetryStats.markCaptured();
1702
1809
  const activeSpan = _api.trace.getActiveSpan();
1703
- const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _72 => _72.isRecording, 'call', _73 => _73()]) === true;
1810
+ const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _74 => _74.isRecording, 'call', _75 => _75()]) === true;
1704
1811
  const span = reuseActive ? activeSpan : errorTracer.startSpan("OutcomeFailure");
1705
- const safeOutcome = activeRedactor({ "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
1812
+ const safeOutcome = redactor({ "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
1706
1813
  const safeName = String(_nullishCoalesce(safeOutcome["autter.outcome.name"], () => ( "operation")));
1707
1814
  const safeMessage = String(_nullishCoalesce(safeOutcome["autter.outcome.message"], () => ( "failed")));
1708
1815
  span.addEvent("autter.outcome", {
1709
- ...activeRedactor(attributes),
1816
+ ...redactor(attributes),
1710
1817
  "autter.outcome.status": "error",
1711
1818
  "autter.outcome.name": safeName,
1712
1819
  "autter.outcome.message": safeMessage
@@ -1714,7 +1821,7 @@ function initAutterServer(options) {
1714
1821
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
1715
1822
  if (!reuseActive) span.end();
1716
1823
  }
1717
- _chunkUKYTXZOQcjs.configureRuntimeLogger.call(void 0, {
1824
+ _chunkUXTIMS3Gcjs.configureRuntimeLogger.call(void 0, {
1718
1825
  endpoint,
1719
1826
  apiKey: options.apiKey,
1720
1827
  service: options.service,
@@ -1722,11 +1829,11 @@ function initAutterServer(options) {
1722
1829
  distro,
1723
1830
  release: options.release,
1724
1831
  options: options.logging,
1725
- redact: activeRedactor,
1726
- run: (name, fn, attributes, links) => runWithSpan(processTracer, name, fn, activeRedactor(attributes), links),
1832
+ redact: redactor,
1833
+ run: (name, fn, attributes, links) => runWithSpan(processTracer, name, fn, redactor(attributes), links),
1727
1834
  reportOutcome: reportOutcome2
1728
1835
  });
1729
- hookRequests = _optionalChain([options, 'access', _74 => _74.logging, 'optionalAccess', _75 => _75.requests]) === true;
1836
+ S.hookRequests = _optionalChain([options, 'access', _76 => _76.logging, 'optionalAccess', _77 => _77.requests]) === true;
1730
1837
  let onCrash = null;
1731
1838
  let uninstallRejections = null;
1732
1839
  if (options.captureGlobalErrors !== false) {
@@ -1746,7 +1853,7 @@ function initAutterServer(options) {
1746
1853
  const flushTarget = {
1747
1854
  forceFlush: async () => {
1748
1855
  const results = await Promise.allSettled([
1749
- _chunkUKYTXZOQcjs.flushRuntimeLogs.call(void 0, ),
1856
+ _chunkUXTIMS3Gcjs.flushRuntimeLogs.call(void 0, ),
1750
1857
  Promise.resolve().then(() => alwaysOnProvider.forceFlush()),
1751
1858
  Promise.resolve().then(() => mainSpanProcessor.forceFlush()),
1752
1859
  ...errorTraceBuffer ? [Promise.resolve().then(() => errorTraceBuffer.forceFlush())] : [],
@@ -1760,116 +1867,118 @@ function initAutterServer(options) {
1760
1867
  }
1761
1868
  }
1762
1869
  };
1763
- _chunkARN26OK6cjs.registerFlushTarget.call(void 0, "active-server", flushTarget);
1870
+ _chunk4MVWIRBIcjs.registerFlushTarget.call(void 0, "active-server", flushTarget);
1764
1871
  let autoFlushHandle = null;
1765
1872
  if (options.autoFlush !== false) {
1766
- autoFlushHandle = _chunkARN26OK6cjs.installAutterAutoFlush.call(void 0, );
1873
+ autoFlushHandle = _chunk4MVWIRBIcjs.installAutterAutoFlush.call(void 0, );
1767
1874
  }
1768
1875
  const server = {
1769
1876
  captureException: captureException2,
1770
1877
  captureMessage: captureMessage2,
1771
1878
  reportOutcome: reportOutcome2,
1772
- withProcessSpan: (name, fn, attributes) => runWithSpan(processTracer, name, fn, activeRedactor(attributes)),
1879
+ withProcessSpan: (name, fn, attributes) => runWithSpan(processTracer, name, fn, redactor(attributes)),
1773
1880
  withLlmCall: (info, fn) => runLlmSpan(llmTracer, info, fn),
1774
1881
  trackLlmCall: (call) => recordLlmCall(llmTracer, call),
1775
1882
  shutdown: async () => {
1776
- const logShutdown = await Promise.allSettled([_chunkUKYTXZOQcjs.shutdownRuntimeLogger.call(void 0, )]);
1777
- hookRequests = false;
1883
+ const logShutdown = await Promise.allSettled([_chunkUXTIMS3Gcjs.shutdownRuntimeLogger.call(void 0, )]);
1778
1884
  if (onCrash) process.off("uncaughtExceptionMonitor", onCrash);
1779
- _optionalChain([uninstallRejections, 'optionalCall', _76 => _76()]);
1780
- _optionalChain([stopMemoryMetrics, 'optionalCall', _77 => _77()]);
1781
- active = null;
1782
- activeAlwaysOnProvider = null;
1783
- _optionalChain([autoFlushHandle, 'optionalAccess', _78 => _78.dispose, 'call', _79 => _79()]);
1885
+ _optionalChain([uninstallRejections, 'optionalCall', _78 => _78()]);
1886
+ _optionalChain([stopMemoryMetrics, 'optionalCall', _79 => _79()]);
1887
+ if (S.active === server) {
1888
+ S.active = null;
1889
+ S.alwaysOnProvider = null;
1890
+ S.hookRequests = false;
1891
+ S.redactor = _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, true);
1892
+ }
1893
+ _optionalChain([autoFlushHandle, 'optionalAccess', _80 => _80.dispose, 'call', _81 => _81()]);
1784
1894
  autoFlushHandle = null;
1785
- _chunkARN26OK6cjs.unregisterFlushTargets.call(void 0, );
1786
- _chunkARN26OK6cjs.telemetryStats.markAllFlushed();
1895
+ _chunk4MVWIRBIcjs.unregisterFlushTargets.call(void 0, );
1896
+ _chunk4MVWIRBIcjs.telemetryStats.markAllFlushed();
1787
1897
  await Promise.allSettled([alwaysOnProvider.shutdown(), sdk.shutdown()]);
1788
- if (_optionalChain([logShutdown, 'access', _80 => _80[0], 'optionalAccess', _81 => _81.status]) === "rejected") throw logShutdown[0].reason;
1898
+ if (_optionalChain([logShutdown, 'access', _82 => _82[0], 'optionalAccess', _83 => _83.status]) === "rejected") throw logShutdown[0].reason;
1789
1899
  }
1790
1900
  };
1791
- active = server;
1792
- activeAlwaysOnProvider = alwaysOnProvider;
1901
+ S.active = server;
1902
+ S.alwaysOnProvider = alwaysOnProvider;
1793
1903
  return server;
1794
1904
  }
1795
1905
  function captureException(error, attributes) {
1796
- if (active) {
1797
- active.captureException(error, attributes);
1906
+ if (S.active) {
1907
+ S.active.captureException(error, attributes);
1798
1908
  return;
1799
1909
  }
1800
- if (loggerOnlyCapture) {
1801
- loggerOnlyCapture(error, attributes);
1910
+ if (S.loggerOnlyCapture) {
1911
+ S.loggerOnlyCapture(error, attributes);
1802
1912
  return;
1803
1913
  }
1804
1914
  markCaptured(error);
1805
- _chunkUKYTXZOQcjs.noteOperationError.call(void 0, error);
1806
- const split = _chunkUKYTXZOQcjs.splitFingerprint.call(void 0, attributes);
1807
- const fingerprint = _chunkUKYTXZOQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, activeRedactor.text);
1808
- _chunkUKYTXZOQcjs.notifyException.call(void 0, error, { ...split.attributes, ...fingerprint });
1809
- const span = _api.trace.getTracer("autter-errors").startSpan(_chunkUKYTXZOQcjs.isError.call(void 0, error) ? error.name : "Error", {
1810
- attributes: { ...activeRedactor(split.attributes), ...fingerprint }
1915
+ _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error);
1916
+ const split = _chunkUXTIMS3Gcjs.splitFingerprint.call(void 0, attributes);
1917
+ const fingerprint = _chunkUXTIMS3Gcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, S.redactor.text);
1918
+ _chunkUXTIMS3Gcjs.notifyException.call(void 0, error, { ...split.attributes, ...fingerprint });
1919
+ const span = _api.trace.getTracer("autter-errors").startSpan(_chunkUXTIMS3Gcjs.isError.call(void 0, error) ? error.name : "Error", {
1920
+ attributes: { ...S.redactor(split.attributes), ...fingerprint }
1811
1921
  });
1812
1922
  recordError(span, error);
1813
1923
  span.end();
1814
1924
  }
1815
- var loggerOnlyCapture = null;
1816
1925
  function setLoggerOnlyCapture(fn) {
1817
- loggerOnlyCapture = fn;
1926
+ S.loggerOnlyCapture = fn;
1818
1927
  }
1819
1928
  function serverActive() {
1820
- return active !== null;
1929
+ return S.active !== null;
1821
1930
  }
1822
1931
  setRequestExceptionCapturer((error, attributes) => captureException(error, attributes));
1823
1932
  setRequestSpanAnnotator((attributes) => {
1824
1933
  const span = _api.trace.getActiveSpan();
1825
- if (_optionalChain([span, 'optionalAccess', _82 => _82.isRecording, 'call', _83 => _83()])) span.setAttributes(activeRedactor(_chunkUKYTXZOQcjs.splitFingerprint.call(void 0, attributes).attributes));
1934
+ if (_optionalChain([span, 'optionalAccess', _84 => _84.isRecording, 'call', _85 => _85()])) span.setAttributes(S.redactor(_chunkUXTIMS3Gcjs.splitFingerprint.call(void 0, attributes).attributes));
1826
1935
  });
1827
1936
  function withProcessSpan(name, fn, attributes) {
1828
- if (active) return active.withProcessSpan(name, fn, attributes);
1937
+ if (S.active) return S.active.withProcessSpan(name, fn, attributes);
1829
1938
  return runWithSpan(
1830
1939
  _api.trace.getTracer("autter-processes"),
1831
1940
  name,
1832
1941
  fn,
1833
- activeRedactor(attributes)
1942
+ S.redactor(attributes)
1834
1943
  );
1835
1944
  }
1836
1945
  function withLlmCall(info, fn) {
1837
- if (active) return active.withLlmCall(info, fn);
1946
+ if (S.active) return S.active.withLlmCall(info, fn);
1838
1947
  return runLlmSpan(_api.trace.getTracer("autter-llm"), info, fn);
1839
1948
  }
1840
1949
  function trackLlmCall(call) {
1841
- if (active) {
1842
- active.trackLlmCall(call);
1950
+ if (S.active) {
1951
+ S.active.trackLlmCall(call);
1843
1952
  return;
1844
1953
  }
1845
1954
  recordLlmCall(_api.trace.getTracer("autter-llm"), call);
1846
1955
  }
1847
1956
  function captureMessage(message, severity = "warning", attributes) {
1848
- if (active) {
1849
- active.captureMessage(message, severity, attributes);
1957
+ if (S.active) {
1958
+ S.active.captureMessage(message, severity, attributes);
1850
1959
  return;
1851
1960
  }
1852
- const safeMessage = activeRedactor.text(message);
1961
+ const safeMessage = S.redactor.text(message);
1853
1962
  const span = _api.trace.getTracer("autter-errors").startSpan("Message", {
1854
- attributes: { "autter.severity": severity, ...activeRedactor(attributes) }
1963
+ attributes: { "autter.severity": severity, ...S.redactor(attributes) }
1855
1964
  });
1856
1965
  span.addEvent("exception", {
1857
1966
  "exception.type": "Message",
1858
1967
  "exception.message": safeMessage,
1859
1968
  "autter.severity": severity,
1860
- ..._chunkUKYTXZOQcjs.breadcrumbEventAttributes.call(void 0, activeRedactor.text)
1969
+ ..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text)
1861
1970
  });
1862
1971
  span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
1863
1972
  span.end();
1864
1973
  }
1865
1974
  function reportOutcome(name, message, attributes) {
1866
- if (active) return active.reportOutcome(name, message, attributes);
1975
+ if (S.active) return S.active.reportOutcome(name, message, attributes);
1867
1976
  const span = _api.trace.getTracer("autter-outcomes").startSpan("OutcomeFailure");
1868
- const safeOutcome = _chunkUKYTXZOQcjs.redactAttributes.call(void 0, { "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
1977
+ const safeOutcome = _chunkUXTIMS3Gcjs.redactAttributes.call(void 0, { "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
1869
1978
  const safeName = String(_nullishCoalesce(safeOutcome["autter.outcome.name"], () => ( "operation")));
1870
1979
  const safeMessage = String(_nullishCoalesce(safeOutcome["autter.outcome.message"], () => ( "failed")));
1871
1980
  span.addEvent("autter.outcome", {
1872
- ..._chunkUKYTXZOQcjs.redactAttributes.call(void 0, attributes),
1981
+ ..._chunkUXTIMS3Gcjs.redactAttributes.call(void 0, attributes),
1873
1982
  "autter.outcome.status": "error",
1874
1983
  "autter.outcome.name": safeName,
1875
1984
  "autter.outcome.message": safeMessage
@@ -1878,20 +1987,20 @@ function reportOutcome(name, message, attributes) {
1878
1987
  span.end();
1879
1988
  }
1880
1989
  function makeSafeCapture(options) {
1881
- const clean = (attributes) => attributes ? { ..._chunkUKYTXZOQcjs.redactAttributes.call(void 0, attributes, options) } : void 0;
1990
+ const clean = (attributes) => attributes ? { ..._chunkUXTIMS3Gcjs.redactAttributes.call(void 0, attributes, options) } : void 0;
1882
1991
  return {
1883
1992
  captureException: (error, attributes) => captureException(error, clean(attributes)),
1884
1993
  captureMessage: (message, severity, attributes) => captureMessage(message, _nullishCoalesce(severity, () => ( "warning")), clean(attributes))
1885
1994
  };
1886
1995
  }
1887
1996
  function alwaysOnTracer(name) {
1888
- return activeAlwaysOnProvider ? activeAlwaysOnProvider.getTracer(name) : _api.trace.getTracer(name);
1997
+ return S.alwaysOnProvider ? S.alwaysOnProvider.getTracer(name) : _api.trace.getTracer(name);
1889
1998
  }
1890
1999
  function autterLlmTracer() {
1891
2000
  return alwaysOnTracer("autter-llm");
1892
2001
  }
1893
2002
  async function emitLlmSelftestTrace() {
1894
- const provider = activeAlwaysOnProvider;
2003
+ const provider = S.alwaysOnProvider;
1895
2004
  if (!provider) {
1896
2005
  throw new Error(
1897
2006
  "emitLlmSelftestTrace() requires initAutterServer() to have been called"
@@ -1905,7 +2014,7 @@ async function emitLlmSelftestTrace() {
1905
2014
  attributes: { "autter.selftest": true }
1906
2015
  },
1907
2016
  (llm) => {
1908
- traceId = _nullishCoalesce(_optionalChain([_api.trace, 'access', _84 => _84.getActiveSpan, 'call', _85 => _85(), 'optionalAccess', _86 => _86.spanContext, 'call', _87 => _87(), 'access', _88 => _88.traceId]), () => ( ""));
2017
+ traceId = _nullishCoalesce(_optionalChain([_api.trace, 'access', _86 => _86.getActiveSpan, 'call', _87 => _87(), 'optionalAccess', _88 => _88.spanContext, 'call', _89 => _89(), 'access', _90 => _90.traceId]), () => ( ""));
1909
2018
  llm.setUsage({ inputTokens: 1, outputTokens: 1 });
1910
2019
  llm.setCost(0);
1911
2020
  }
@@ -1933,7 +2042,7 @@ var CALL_METHODS = /* @__PURE__ */ new Set([
1933
2042
  // openai beta structured outputs
1934
2043
  ]);
1935
2044
  function detectProvider(client) {
1936
- const name = _nullishCoalesce(_optionalChain([client, 'access', _89 => _89.constructor, 'optionalAccess', _90 => _90.name, 'optionalAccess', _91 => _91.toLowerCase, 'call', _92 => _92()]), () => ( ""));
2045
+ const name = _nullishCoalesce(_optionalChain([client, 'access', _91 => _91.constructor, 'optionalAccess', _92 => _92.name, 'optionalAccess', _93 => _93.toLowerCase, 'call', _94 => _94()]), () => ( ""));
1937
2046
  for (const known of ["openai", "anthropic", "mistral", "groq", "cohere"]) {
1938
2047
  if (name.includes(known)) return known;
1939
2048
  }
@@ -1941,7 +2050,7 @@ function detectProvider(client) {
1941
2050
  const baseUrl = String(
1942
2051
  _nullishCoalesce(_nullishCoalesce(client.baseURL, () => ( client.baseUrl)), () => ( ""))
1943
2052
  );
1944
- const host = _nullishCoalesce(_optionalChain([baseUrl, 'access', _93 => _93.match, 'call', _94 => _94(/https?:\/\/([^/]+)/), 'optionalAccess', _95 => _95[1]]), () => ( ""));
2053
+ const host = _nullishCoalesce(_optionalChain([baseUrl, 'access', _95 => _95.match, 'call', _96 => _96(/https?:\/\/([^/]+)/), 'optionalAccess', _97 => _97[1]]), () => ( ""));
1945
2054
  if (host.includes("openai")) return "openai";
1946
2055
  if (host.includes("anthropic")) return "anthropic";
1947
2056
  if (host.includes("googleapis")) return "google";
@@ -1951,13 +2060,13 @@ function detectProvider(client) {
1951
2060
  }
1952
2061
  function extractUsage(result) {
1953
2062
  const r = result;
1954
- const usage = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _96 => _96.usage]), () => ( _optionalChain([r, 'optionalAccess', _97 => _97.message, 'optionalAccess', _98 => _98.usage])));
1955
- const meta = _optionalChain([r, 'optionalAccess', _99 => _99.usageMetadata]);
1956
- const details = _optionalChain([usage, 'optionalAccess', _100 => _100.prompt_tokens_details]);
1957
- const cached = _nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _101 => _101.cache_read_input_tokens]), () => ( (typeof _optionalChain([details, 'optionalAccess', _102 => _102.cached_tokens]) === "number" ? details.cached_tokens : void 0))), () => ( _optionalChain([meta, 'optionalAccess', _103 => _103.cachedContentTokenCount])));
1958
- const input = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _104 => _104.prompt_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _105 => _105.input_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _106 => _106.promptTokenCount]))), () => ( void 0));
1959
- const output = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _107 => _107.completion_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _108 => _108.output_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _109 => _109.candidatesTokenCount]))), () => ( void 0));
1960
- const responseModel = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _110 => _110.model]), () => ( _optionalChain([r, 'optionalAccess', _111 => _111.modelVersion])));
2063
+ const usage = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _98 => _98.usage]), () => ( _optionalChain([r, 'optionalAccess', _99 => _99.message, 'optionalAccess', _100 => _100.usage])));
2064
+ const meta = _optionalChain([r, 'optionalAccess', _101 => _101.usageMetadata]);
2065
+ const details = _optionalChain([usage, 'optionalAccess', _102 => _102.prompt_tokens_details]);
2066
+ const cached = _nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _103 => _103.cache_read_input_tokens]), () => ( (typeof _optionalChain([details, 'optionalAccess', _104 => _104.cached_tokens]) === "number" ? details.cached_tokens : void 0))), () => ( _optionalChain([meta, 'optionalAccess', _105 => _105.cachedContentTokenCount])));
2067
+ const input = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _106 => _106.prompt_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _107 => _107.input_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _108 => _108.promptTokenCount]))), () => ( void 0));
2068
+ const output = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _109 => _109.completion_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _110 => _110.output_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _111 => _111.candidatesTokenCount]))), () => ( void 0));
2069
+ const responseModel = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _112 => _112.model]), () => ( _optionalChain([r, 'optionalAccess', _113 => _113.modelVersion])));
1961
2070
  return {
1962
2071
  inputTokens: typeof input === "number" ? input : void 0,
1963
2072
  outputTokens: typeof output === "number" ? output : void 0,
@@ -1966,7 +2075,7 @@ function extractUsage(result) {
1966
2075
  };
1967
2076
  }
1968
2077
  function rollUp(model, usage) {
1969
- _chunkUKYTXZOQcjs.recordOperationAiUsage.call(void 0, {
2078
+ _chunkUXTIMS3Gcjs.recordOperationAiUsage.call(void 0, {
1970
2079
  model: _nullishCoalesce(usage.responseModel, () => ( model)),
1971
2080
  ...usage.inputTokens !== void 0 ? { inputTokens: usage.inputTokens } : {},
1972
2081
  ...usage.outputTokens !== void 0 ? { outputTokens: usage.outputTokens } : {},
@@ -2050,10 +2159,10 @@ function wrapStream(stream, span, model) {
2050
2159
  });
2051
2160
  }
2052
2161
  function instrumentLlmClient(client, options) {
2053
- const provider = (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _112 => _112.provider]), () => ( detectProvider(client)))).toLowerCase();
2162
+ const provider = (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _114 => _114.provider]), () => ( detectProvider(client)))).toLowerCase();
2054
2163
  const proxied = /* @__PURE__ */ new WeakMap();
2055
2164
  function resolveUserId() {
2056
- return typeof _optionalChain([options, 'optionalAccess', _113 => _113.userId]) === "function" ? options.userId() : _optionalChain([options, 'optionalAccess', _114 => _114.userId]);
2165
+ return typeof _optionalChain([options, 'optionalAccess', _115 => _115.userId]) === "function" ? options.userId() : _optionalChain([options, 'optionalAccess', _116 => _116.userId]);
2057
2166
  }
2058
2167
  function traceCall(fn, self, callPath, args) {
2059
2168
  const request = args[0];
@@ -2067,7 +2176,7 @@ function instrumentLlmClient(client, options) {
2067
2176
  "gen_ai.system": provider,
2068
2177
  "gen_ai.request.model": request.model,
2069
2178
  ...userId ? { "autter.user_id": userId } : {},
2070
- ...redactWithActive(_optionalChain([options, 'optionalAccess', _115 => _115.attributes]))
2179
+ ...redactWithActive(_optionalChain([options, 'optionalAccess', _117 => _117.attributes]))
2071
2180
  }
2072
2181
  });
2073
2182
  let result;
@@ -2149,14 +2258,14 @@ function startCaughtExceptionSampler(options = {}) {
2149
2258
  const rate = Math.max(0, Math.min(1, _nullishCoalesce(options.sampleRate, () => ( 0.01))));
2150
2259
  const cap = Math.max(1, Math.min(100, _nullishCoalesce(options.maxPerMinute, () => ( 10))));
2151
2260
  const session = new _inspector2.default.Session();
2152
- let active2 = true;
2261
+ let active = true;
2153
2262
  let minute = 0;
2154
2263
  let sent = 0;
2155
2264
  session.connect();
2156
2265
  session.on("Debugger.paused", (message) => {
2157
2266
  session.post("Debugger.resume", () => {
2158
2267
  });
2159
- if (!active2 || message.params.reason !== "exception") return;
2268
+ if (!active || message.params.reason !== "exception") return;
2160
2269
  const nowMinute = Math.floor(Date.now() / 6e4);
2161
2270
  if (nowMinute !== minute) {
2162
2271
  minute = nowMinute;
@@ -2171,16 +2280,16 @@ function startCaughtExceptionSampler(options = {}) {
2171
2280
  error.stack = `${error.name}: ${error.message}
2172
2281
  ${frames.join("\n")}`;
2173
2282
  queueMicrotask(() => {
2174
- if (active2) captureException(error, { "autter.handled": true, "autter.sampled": true });
2283
+ if (active) captureException(error, { "autter.handled": true, "autter.sampled": true });
2175
2284
  });
2176
2285
  });
2177
2286
  session.post("Debugger.enable", (error) => {
2178
- if (!error && active2) session.post("Debugger.setPauseOnExceptions", { state: "all" }, () => {
2287
+ if (!error && active) session.post("Debugger.setPauseOnExceptions", { state: "all" }, () => {
2179
2288
  });
2180
2289
  });
2181
2290
  return { stop() {
2182
- if (!active2) return;
2183
- active2 = false;
2291
+ if (!active) return;
2292
+ active = false;
2184
2293
  session.post("Debugger.setPauseOnExceptions", { state: "none" }, () => {
2185
2294
  session.post("Debugger.disable", () => session.disconnect());
2186
2295
  });
@@ -2191,9 +2300,9 @@ ${frames.join("\n")}`;
2191
2300
  function recordBoundaryError(error, req, rule) {
2192
2301
  try {
2193
2302
  const state = requestStateOf(req);
2194
- if (state) _chunkUKYTXZOQcjs.noteOperationError.call(void 0, error, false, state);
2303
+ if (state) _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error, false, state);
2195
2304
  captureAtBoundary(error, state, rule);
2196
- } catch (e29) {
2305
+ } catch (e30) {
2197
2306
  }
2198
2307
  }
2199
2308
  function autterErrorHandler(options = {}) {
@@ -2203,12 +2312,12 @@ function autterErrorHandler(options = {}) {
2203
2312
  };
2204
2313
  }
2205
2314
  function autterFastifyErrors(fastify, options, done) {
2206
- const rule = _optionalChain([options, 'optionalAccess', _116 => _116.capture]);
2315
+ const rule = _optionalChain([options, 'optionalAccess', _118 => _118.capture]);
2207
2316
  fastify.addHook("onError", ((request, _reply, error, next) => {
2208
- recordBoundaryError(error, _optionalChain([request, 'optionalAccess', _117 => _117.raw]), rule);
2317
+ recordBoundaryError(error, _optionalChain([request, 'optionalAccess', _119 => _119.raw]), rule);
2209
2318
  next();
2210
2319
  }));
2211
- _optionalChain([done, 'optionalCall', _118 => _118()]);
2320
+ _optionalChain([done, 'optionalCall', _120 => _120()]);
2212
2321
  }
2213
2322
  autterFastifyErrors[/* @__PURE__ */ Symbol.for("skip-override")] = true;
2214
2323
  autterFastifyErrors[/* @__PURE__ */ Symbol.for("fastify.display-name")] = "autter-runtime-errors";
@@ -2217,7 +2326,7 @@ function autterKoa(options = {}) {
2217
2326
  try {
2218
2327
  await next();
2219
2328
  } catch (error) {
2220
- recordBoundaryError(error, _optionalChain([ctx, 'optionalAccess', _119 => _119.req]), options.capture);
2329
+ recordBoundaryError(error, _optionalChain([ctx, 'optionalAccess', _121 => _121.req]), options.capture);
2221
2330
  throw error;
2222
2331
  }
2223
2332
  };
@@ -2228,38 +2337,38 @@ function autterKoa(options = {}) {
2228
2337
 
2229
2338
 
2230
2339
 
2231
- var activeLogging = null;
2340
+ var L = _chunk4MVWIRBIcjs.sharedSlot.call(void 0, "logging", () => ({ active: null }));
2232
2341
  function initAutterLogging(options) {
2233
- if (activeLogging) return activeLogging;
2342
+ if (L.active) return L.active;
2234
2343
  if (serverActive()) {
2235
2344
  console.warn(
2236
2345
  "[autter-runtime] initAutterLogging() ignored: initAutterServer() is already active and includes logging"
2237
2346
  );
2238
2347
  return {
2239
2348
  captureException,
2240
- flush: _chunkUKYTXZOQcjs.flushRuntimeLogs,
2349
+ flush: _chunkUXTIMS3Gcjs.flushRuntimeLogs,
2241
2350
  shutdown: async () => {
2242
2351
  }
2243
2352
  };
2244
2353
  }
2245
- if (_chunkARN26OK6cjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunkARN26OK6cjs.setDebugMode.call(void 0, true);
2354
+ if (_chunk4MVWIRBIcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunk4MVWIRBIcjs.setDebugMode.call(void 0, true);
2246
2355
  const endpoint = (_nullishCoalesce(options.endpoint, () => ( "https://otlp.autter.dev"))).replace(/\/$/, "");
2247
2356
  const environment = _nullishCoalesce(_nullishCoalesce(options.environment, () => ( process.env.NODE_ENV)), () => ( "production"));
2248
- const redact = _chunkUKYTXZOQcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
2357
+ const redact = _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
2249
2358
  const mode = _nullishCoalesce(options.exceptions, () => ( "auto"));
2250
- _chunkARN26OK6cjs.debugLog.call(void 0, `initialising logger-only service=${options.service} endpoint=${endpoint}`);
2359
+ _chunk4MVWIRBIcjs.debugLog.call(void 0, `initialising logger-only service=${options.service} endpoint=${endpoint}`);
2251
2360
  function captureException2(error, attributes) {
2252
2361
  markCaptured(error);
2253
- const split = _chunkUKYTXZOQcjs.splitFingerprint.call(void 0, attributes);
2254
- const fingerprint = _chunkUKYTXZOQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redact.text);
2362
+ const split = _chunkUXTIMS3Gcjs.splitFingerprint.call(void 0, attributes);
2363
+ const fingerprint = _chunkUXTIMS3Gcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redact.text);
2255
2364
  const redacted = redact(split.attributes);
2256
2365
  const span = _api.trace.getActiveSpan();
2257
- if (mode === "auto" && _optionalChain([span, 'optionalAccess', _120 => _120.isRecording, 'call', _121 => _121()])) {
2258
- _chunkUKYTXZOQcjs.noteOperationError.call(void 0, error);
2259
- _chunkUKYTXZOQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
2366
+ if (mode === "auto" && _optionalChain([span, 'optionalAccess', _122 => _122.isRecording, 'call', _123 => _123()])) {
2367
+ _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error);
2368
+ _chunkUXTIMS3Gcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
2260
2369
  span.setAttributes({ "autter.severity": "error", ...redacted, ...structuredErrorAttributes(error) });
2261
- const declared = { ..._chunkUKYTXZOQcjs.errorAttributes.call(void 0, error), ...fingerprint };
2262
- if (_chunkUKYTXZOQcjs.isError.call(void 0, error)) {
2370
+ const declared = { ..._chunkUXTIMS3Gcjs.errorAttributes.call(void 0, error), ...fingerprint };
2371
+ if (_chunkUXTIMS3Gcjs.isError.call(void 0, error)) {
2263
2372
  span.addEvent("exception", {
2264
2373
  "exception.type": error.name,
2265
2374
  "exception.message": error.message,
@@ -2275,15 +2384,15 @@ function initAutterLogging(options) {
2275
2384
  }
2276
2385
  span.setStatus({
2277
2386
  code: _api.SpanStatusCode.ERROR,
2278
- message: _chunkUKYTXZOQcjs.isError.call(void 0, error) ? error.message : String(error)
2387
+ message: _chunkUXTIMS3Gcjs.isError.call(void 0, error) ? error.message : String(error)
2279
2388
  });
2280
2389
  return;
2281
2390
  }
2282
- _chunkUKYTXZOQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
2283
- _chunkUKYTXZOQcjs.captureExceptionAsLog.call(void 0, error, { ...redacted, ...fingerprint });
2391
+ _chunkUXTIMS3Gcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
2392
+ _chunkUXTIMS3Gcjs.captureExceptionAsLog.call(void 0, error, { ...redacted, ...fingerprint });
2284
2393
  }
2285
2394
  const captured = /* @__PURE__ */ new WeakSet();
2286
- _chunkUKYTXZOQcjs.configureRuntimeLogger.call(void 0, {
2395
+ _chunkUXTIMS3Gcjs.configureRuntimeLogger.call(void 0, {
2287
2396
  endpoint,
2288
2397
  apiKey: _nullishCoalesce(options.apiKey, () => ( "")),
2289
2398
  service: options.service,
@@ -2292,7 +2401,7 @@ function initAutterLogging(options) {
2292
2401
  ...options.logging ? { options: options.logging } : {},
2293
2402
  redact,
2294
2403
  reportOutcome: (name, message, attributes) => {
2295
- _chunkUKYTXZOQcjs.runtimeLogger.error(message, {
2404
+ _chunkUXTIMS3Gcjs.runtimeLogger.error(message, {
2296
2405
  ...attributes,
2297
2406
  "autter.outcome.name": name.slice(0, 200),
2298
2407
  "autter.outcome.message": message.slice(0, 1e3)
@@ -2319,30 +2428,30 @@ function initAutterLogging(options) {
2319
2428
  (reason) => captureException2(reason, { "autter.unhandled_rejection": true })
2320
2429
  );
2321
2430
  }
2322
- _chunkARN26OK6cjs.registerFlushTarget.call(void 0, "logging", { forceFlush: () => _chunkUKYTXZOQcjs.flushRuntimeLogs.call(void 0, ) });
2323
- let autoFlushHandle = options.autoFlush === false ? null : _chunkARN26OK6cjs.installAutterAutoFlush.call(void 0, );
2431
+ _chunk4MVWIRBIcjs.registerFlushTarget.call(void 0, "logging", { forceFlush: () => _chunkUXTIMS3Gcjs.flushRuntimeLogs.call(void 0, ) });
2432
+ let autoFlushHandle = options.autoFlush === false ? null : _chunk4MVWIRBIcjs.installAutterAutoFlush.call(void 0, );
2324
2433
  const handle = {
2325
2434
  captureException: captureException2,
2326
- flush: _chunkUKYTXZOQcjs.flushRuntimeLogs,
2435
+ flush: _chunkUXTIMS3Gcjs.flushRuntimeLogs,
2327
2436
  shutdown: async () => {
2328
2437
  process.off("uncaughtExceptionMonitor", onCrash);
2329
- _optionalChain([uninstallRejections, 'optionalCall', _122 => _122()]);
2438
+ _optionalChain([uninstallRejections, 'optionalCall', _124 => _124()]);
2330
2439
  uninstallRejections = null;
2331
2440
  setLoggerOnlyCapture(null);
2332
- _optionalChain([autoFlushHandle, 'optionalAccess', _123 => _123.dispose, 'call', _124 => _124()]);
2441
+ _optionalChain([autoFlushHandle, 'optionalAccess', _125 => _125.dispose, 'call', _126 => _126()]);
2333
2442
  autoFlushHandle = null;
2334
- _chunkARN26OK6cjs.unregisterFlushTargets.call(void 0, );
2335
- activeLogging = null;
2336
- await _chunkUKYTXZOQcjs.shutdownRuntimeLogger.call(void 0, );
2443
+ _chunk4MVWIRBIcjs.unregisterFlushTargets.call(void 0, );
2444
+ if (L.active === handle) L.active = null;
2445
+ await _chunkUXTIMS3Gcjs.shutdownRuntimeLogger.call(void 0, );
2337
2446
  }
2338
2447
  };
2339
- activeLogging = handle;
2448
+ L.active = handle;
2340
2449
  return handle;
2341
2450
  }
2342
2451
 
2343
2452
  // src/enrichers.ts
2344
2453
  function headerOf(req, name) {
2345
- const headers = _optionalChain([req, 'optionalAccess', _125 => _125.headers]);
2454
+ const headers = _optionalChain([req, 'optionalAccess', _127 => _127.headers]);
2346
2455
  if (!headers) return void 0;
2347
2456
  if (typeof headers.get === "function") {
2348
2457
  return _nullishCoalesce(headers.get(name), () => ( void 0));
@@ -2355,7 +2464,7 @@ function enrichUserAgent() {
2355
2464
  return (event, { req }) => {
2356
2465
  const ua = headerOf(req, "user-agent");
2357
2466
  if (!ua) return;
2358
- const info = _chunkUKYTXZOQcjs.parseUserAgent.call(void 0, ua);
2467
+ const info = _chunkUXTIMS3Gcjs.parseUserAgent.call(void 0, ua);
2359
2468
  if (info.browser) event.attributes["user_agent.browser"] = info.browser;
2360
2469
  if (info.os) event.attributes["user_agent.os"] = info.os;
2361
2470
  event.attributes["user_agent.device"] = info.device;
@@ -2367,7 +2476,7 @@ function enrichRequestSize() {
2367
2476
  const request = Number(headerOf(req, "content-length"));
2368
2477
  if (Number.isFinite(request) && request >= 0)
2369
2478
  event.attributes["http.request.body.size"] = request;
2370
- const raw = _optionalChain([res, 'optionalAccess', _126 => _126.getHeader, 'optionalCall', _127 => _127(
2479
+ const raw = _optionalChain([res, 'optionalAccess', _128 => _128.getHeader, 'optionalCall', _129 => _129(
2371
2480
  "content-length"
2372
2481
  )]);
2373
2482
  const response = Number(raw);
@@ -2385,7 +2494,7 @@ var COUNTRY_HEADERS = [
2385
2494
  function enrichEdgeGeo() {
2386
2495
  return (event, { req }) => {
2387
2496
  for (const name of COUNTRY_HEADERS) {
2388
- const value = _optionalChain([headerOf, 'call', _128 => _128(req, name), 'optionalAccess', _129 => _129.trim, 'call', _130 => _130(), 'access', _131 => _131.toUpperCase, 'call', _132 => _132()]);
2497
+ const value = _optionalChain([headerOf, 'call', _130 => _130(req, name), 'optionalAccess', _131 => _131.trim, 'call', _132 => _132(), 'access', _133 => _133.toUpperCase, 'call', _134 => _134()]);
2389
2498
  if (value && /^[A-Z]{2}$/.test(value) && value !== "XX" && value !== "T1") {
2390
2499
  event.attributes["geo.country.iso_code"] = value;
2391
2500
  return;
@@ -2419,9 +2528,9 @@ var COMMIT_VARS = [
2419
2528
  "SOURCE_VERSION"
2420
2529
  ];
2421
2530
  function enrichDeployment(env = process.env) {
2422
- const pick = (names) => names.map((name) => _optionalChain([env, 'access', _133 => _133[name], 'optionalAccess', _134 => _134.trim, 'call', _135 => _135()])).find((value) => value);
2423
- const region = _optionalChain([pick, 'call', _136 => _136(REGION_VARS), 'optionalAccess', _137 => _137.slice, 'call', _138 => _138(0, 64)]);
2424
- const commit = _optionalChain([pick, 'call', _139 => _139(COMMIT_VARS), 'optionalAccess', _140 => _140.slice, 'call', _141 => _141(0, 64)]);
2531
+ const pick = (names) => names.map((name) => _optionalChain([env, 'access', _135 => _135[name], 'optionalAccess', _136 => _136.trim, 'call', _137 => _137()])).find((value) => value);
2532
+ const region = _optionalChain([pick, 'call', _138 => _138(REGION_VARS), 'optionalAccess', _139 => _139.slice, 'call', _140 => _140(0, 64)]);
2533
+ const commit = _optionalChain([pick, 'call', _141 => _141(COMMIT_VARS), 'optionalAccess', _142 => _142.slice, 'call', _143 => _143(0, 64)]);
2425
2534
  return (event) => {
2426
2535
  if (region) event.attributes["deployment.region"] = region;
2427
2536
  if (commit) event.attributes["deployment.commit"] = commit;
@@ -2482,4 +2591,4 @@ function enrichDeployment(env = process.env) {
2482
2591
 
2483
2592
 
2484
2593
 
2485
- exports.CODE_PATTERN = _chunkUKYTXZOQcjs.CODE_PATTERN; exports.COMPAT_MANIFEST = _chunkARN26OK6cjs.COMPAT_MANIFEST; exports.INGESTER_VERSION_HEADER = _chunkARN26OK6cjs.INGESTER_VERSION_HEADER; exports.RuntimeError = _chunkUKYTXZOQcjs.RuntimeError; exports.SDK_IDENTITY = _chunkARN26OK6cjs.SDK_IDENTITY; exports.addBreadcrumb = _chunkUKYTXZOQcjs.addBreadcrumb; exports.autterErrorHandler = autterErrorHandler; exports.autterErrorResponse = autterErrorResponse; exports.autterFastify = autterFastify; exports.autterFastifyErrors = autterFastifyErrors; exports.autterKoa = autterKoa; exports.autterRequests = autterRequests; exports.captureException = captureException; exports.captureMessage = captureMessage; exports.captureRequestError = captureRequestError; exports.consoleSink = _chunkUKYTXZOQcjs.consoleSink; exports.createBrowserRelayFetchHandler = createBrowserRelayFetchHandler; exports.createBrowserRelayHandler = createBrowserRelayHandler; exports.createRuntimeLogger = _chunkUKYTXZOQcjs.createRuntimeLogger; exports.defineRuntimeErrors = _chunkUKYTXZOQcjs.defineRuntimeErrors; exports.emitLlmSelftestTrace = emitLlmSelftestTrace; exports.enrichDeployment = enrichDeployment; exports.enrichEdgeGeo = enrichEdgeGeo; exports.enrichRequestSize = enrichRequestSize; exports.enrichUserAgent = enrichUserAgent; exports.errorAttributes = _chunkUKYTXZOQcjs.errorAttributes; exports.evaluateCompat = _chunkARN26OK6cjs.evaluateCompat; exports.fetchIngesterCompat = _chunkARN26OK6cjs.fetchIngesterCompat; exports.fileSink = _chunkUKYTXZOQcjs.fileSink; exports.flushRuntimeLogs = _chunkUKYTXZOQcjs.flushRuntimeLogs; exports.initAutterLogging = initAutterLogging; exports.initAutterServer = initAutterServer; exports.installAutterAutoFlush = _chunkARN26OK6cjs.installAutterAutoFlush; exports.instrumentLlmClient = instrumentLlmClient; exports.isRuntimeErrorLike = _chunkUKYTXZOQcjs.isRuntimeErrorLike; exports.makeSafeCapture = makeSafeCapture; exports.otlpSink = _chunkUKYTXZOQcjs.otlpSink; exports.redactAttributes = _chunkUKYTXZOQcjs.redactAttributes; exports.redactText = _chunkUKYTXZOQcjs.redactText; exports.reportOutcome = reportOutcome; exports.runDoctor = _chunkUGNPCOIWcjs.runDoctor; exports.runInBackground = _chunkUKYTXZOQcjs.runInBackground; exports.runtimeContext = _chunkUKYTXZOQcjs.runtimeContext; exports.runtimeLogStats = _chunkUKYTXZOQcjs.runtimeLogStats; exports.runtimeLogger = _chunkUKYTXZOQcjs.runtimeLogger; exports.sanitizeBrowserPayload = sanitizeBrowserPayload; exports.startCaughtExceptionSampler = startCaughtExceptionSampler; exports.toClientError = _chunkUKYTXZOQcjs.toClientError; exports.trackLlmCall = trackLlmCall; exports.unhandledRejectionsMode = unhandledRejectionsMode; exports.withLlmCall = withLlmCall; exports.withProcessSpan = withProcessSpan; exports.withRuntimeOperation = _chunkUKYTXZOQcjs.withRuntimeOperation; exports.withRuntimeRequest = withRuntimeRequest;
2594
+ exports.CODE_PATTERN = _chunkUXTIMS3Gcjs.CODE_PATTERN; exports.COMPAT_MANIFEST = _chunk4MVWIRBIcjs.COMPAT_MANIFEST; exports.INGESTER_VERSION_HEADER = _chunk4MVWIRBIcjs.INGESTER_VERSION_HEADER; exports.RuntimeError = _chunkUXTIMS3Gcjs.RuntimeError; exports.SDK_IDENTITY = _chunk4MVWIRBIcjs.SDK_IDENTITY; exports.addBreadcrumb = _chunkUXTIMS3Gcjs.addBreadcrumb; exports.autterErrorHandler = autterErrorHandler; exports.autterErrorResponse = autterErrorResponse; exports.autterFastify = autterFastify; exports.autterFastifyErrors = autterFastifyErrors; exports.autterKoa = autterKoa; exports.autterRequests = autterRequests; exports.captureException = captureException; exports.captureMessage = captureMessage; exports.captureRequestError = captureRequestError; exports.consoleSink = _chunkUXTIMS3Gcjs.consoleSink; exports.createBrowserRelayFetchHandler = createBrowserRelayFetchHandler; exports.createBrowserRelayHandler = createBrowserRelayHandler; exports.createRuntimeLogger = _chunkUXTIMS3Gcjs.createRuntimeLogger; exports.defineRuntimeErrors = _chunkUXTIMS3Gcjs.defineRuntimeErrors; exports.emitLlmSelftestTrace = emitLlmSelftestTrace; exports.enrichDeployment = enrichDeployment; exports.enrichEdgeGeo = enrichEdgeGeo; exports.enrichRequestSize = enrichRequestSize; exports.enrichUserAgent = enrichUserAgent; exports.errorAttributes = _chunkUXTIMS3Gcjs.errorAttributes; exports.evaluateCompat = _chunk4MVWIRBIcjs.evaluateCompat; exports.fetchIngesterCompat = _chunk4MVWIRBIcjs.fetchIngesterCompat; exports.fileSink = _chunkUXTIMS3Gcjs.fileSink; exports.flushRuntimeLogs = _chunkUXTIMS3Gcjs.flushRuntimeLogs; exports.initAutterLogging = initAutterLogging; exports.initAutterServer = initAutterServer; exports.installAutterAutoFlush = _chunk4MVWIRBIcjs.installAutterAutoFlush; exports.instrumentLlmClient = instrumentLlmClient; exports.isRuntimeErrorLike = _chunkUXTIMS3Gcjs.isRuntimeErrorLike; exports.makeSafeCapture = makeSafeCapture; exports.otlpSink = _chunkUXTIMS3Gcjs.otlpSink; exports.redactAttributes = _chunkUXTIMS3Gcjs.redactAttributes; exports.redactText = _chunkUXTIMS3Gcjs.redactText; exports.reportOutcome = reportOutcome; exports.runDoctor = _chunk7OTD2YPTcjs.runDoctor; exports.runInBackground = _chunkUXTIMS3Gcjs.runInBackground; exports.runtimeContext = _chunkUXTIMS3Gcjs.runtimeContext; exports.runtimeLogStats = _chunkUXTIMS3Gcjs.runtimeLogStats; exports.runtimeLogger = _chunkUXTIMS3Gcjs.runtimeLogger; exports.sanitizeBrowserPayload = sanitizeBrowserPayload; exports.startCaughtExceptionSampler = startCaughtExceptionSampler; exports.toClientError = _chunkUXTIMS3Gcjs.toClientError; exports.trackLlmCall = trackLlmCall; exports.unhandledRejectionsMode = unhandledRejectionsMode; exports.withLlmCall = withLlmCall; exports.withProcessSpan = withProcessSpan; exports.withRuntimeOperation = _chunkUXTIMS3Gcjs.withRuntimeOperation; exports.withRuntimeRequest = withRuntimeRequest;