@brizz/sdk 0.1.43 → 0.1.44

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
@@ -5,7 +5,7 @@ var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
5
5
 
6
6
 
7
7
 
8
- var _chunkWTQTF57Jcjs = require('./chunk-WTQTF57J.cjs');
8
+ var _chunkA3HH5OULcjs = require('./chunk-A3HH5OUL.cjs');
9
9
 
10
10
 
11
11
 
@@ -16,7 +16,7 @@ var _chunkWTQTF57Jcjs = require('./chunk-WTQTF57J.cjs');
16
16
  var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
17
17
 
18
18
 
19
- var _chunkQUV5HYJ2cjs = require('./chunk-QUV5HYJ2.cjs');
19
+ var _chunk3IGBYXLRcjs = require('./chunk-3IGBYXLR.cjs');
20
20
 
21
21
 
22
22
 
@@ -70,7 +70,10 @@ var _chunkQUV5HYJ2cjs = require('./chunk-QUV5HYJ2.cjs');
70
70
 
71
71
 
72
72
 
73
- var _chunkFORVS4QWcjs = require('./chunk-FORVS4QW.cjs');
73
+
74
+
75
+
76
+ var _chunk5WBPX342cjs = require('./chunk-5WBPX342.cjs');
74
77
 
75
78
 
76
79
  var _chunkOBGZSXTJcjs = require('./chunk-OBGZSXTJ.cjs');
@@ -127,7 +130,7 @@ function loadGenAIInstrumentations() {
127
130
  function loadMCPInstrumentation() {
128
131
  void (async () => {
129
132
  try {
130
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-UJD6KF7G.cjs")));
133
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-5FSUXYHM.cjs")));
131
134
  const mcp = new MCPInstrumentation({ exceptionLogger });
132
135
  _instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp] });
133
136
  _chunkWC573FCIcjs.logger.debug("Auto-loaded MCP instrumentation");
@@ -183,7 +186,7 @@ function loadVercelAITelemetry() {
183
186
  }
184
187
  const isV7 = typeof ai.registerTelemetry === "function";
185
188
  const integrations = [];
186
- const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-3NXOTY4N.cjs")));
189
+ const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-IKOUBQGN.cjs")));
187
190
  integrations.push(createInterruptIntegration());
188
191
  let otelCollectorLoaded = false;
189
192
  try {
@@ -510,7 +513,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
510
513
  const mcpModules = this.manualModules.mcp;
511
514
  void (async () => {
512
515
  try {
513
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-UJD6KF7G.cjs")));
516
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-5FSUXYHM.cjs")));
514
517
  const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
515
518
  instrumentation.manuallyInstrument(mcpModules);
516
519
  _chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
@@ -561,16 +564,16 @@ function setCurrentSpanCustomProperties(properties) {
561
564
  }
562
565
  for (const [key, value] of Object.entries(properties)) {
563
566
  try {
564
- current.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${key}`, value);
567
+ current.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
565
568
  } catch (e2) {
566
569
  }
567
570
  }
568
571
  }
569
572
  function callWithProperties(properties, fn, thisArg, ...args) {
570
573
  const base = _api.context.active();
571
- const prev = base.getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
574
+ const prev = base.getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
572
575
  const merged = prev ? { ...prev, ...properties } : properties;
573
- const next = base.setValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY, merged);
576
+ const next = base.setValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY, merged);
574
577
  return _api.context.with(next, fn, thisArg, ...args);
575
578
  }
576
579
  function withProperties(properties, fn, thisArg) {
@@ -583,7 +586,7 @@ function withProperties(properties, fn, thisArg) {
583
586
  );
584
587
  };
585
588
  }
586
- function propagatePropertiesImperatively(properties) {
589
+ function propagatePropertiesImperatively(properties, base = _api.context.active()) {
587
590
  try {
588
591
  const manager = _api.context;
589
592
  const mgr = _optionalChain([manager, 'access', _32 => _32._getContextManager, 'optionalCall', _33 => _33()]);
@@ -591,26 +594,25 @@ function propagatePropertiesImperatively(properties) {
591
594
  if (!store || typeof store.enterWith !== "function") {
592
595
  return;
593
596
  }
594
- const base = _api.context.active();
595
- const prev = base.getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
597
+ const prev = base.getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
596
598
  const merged = prev ? { ...prev, ...properties } : properties;
597
- store.enterWith(base.setValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY, merged));
599
+ store.enterWith(base.setValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY, merged));
598
600
  } catch (e3) {
599
601
  }
600
602
  }
601
603
  function setUser(user) {
602
- const properties = { [_chunkFORVS4QWcjs.USER_ID]: user.id };
604
+ const properties = { [_chunk5WBPX342cjs.USER_ID]: user.id };
603
605
  if (user.email !== void 0) {
604
- properties[_chunkFORVS4QWcjs.USER_EMAIL] = user.email;
606
+ properties[_chunk5WBPX342cjs.USER_EMAIL] = user.email;
605
607
  }
606
608
  if (user.name !== void 0) {
607
- properties[_chunkFORVS4QWcjs.USER_NAME] = user.name;
609
+ properties[_chunk5WBPX342cjs.USER_NAME] = user.name;
608
610
  }
609
611
  if (user.role !== void 0) {
610
- properties[_chunkFORVS4QWcjs.USER_ROLE] = user.role;
612
+ properties[_chunk5WBPX342cjs.USER_ROLE] = user.role;
611
613
  }
612
614
  if (user.plan !== void 0) {
613
- properties[_chunkFORVS4QWcjs.USER_PLAN] = user.plan;
615
+ properties[_chunk5WBPX342cjs.USER_PLAN] = user.plan;
614
616
  }
615
617
  if (user.traits) {
616
618
  for (const [key, value] of Object.entries(user.traits)) {
@@ -624,15 +626,15 @@ function setUser(user) {
624
626
  propagatePropertiesImperatively(properties);
625
627
  }
626
628
  function setOrganization(org) {
627
- const properties = { [_chunkFORVS4QWcjs.ORGANIZATION_ID]: org.id };
629
+ const properties = { [_chunk5WBPX342cjs.ORGANIZATION_ID]: org.id };
628
630
  if (org.name !== void 0) {
629
- properties[_chunkFORVS4QWcjs.ORGANIZATION_NAME] = org.name;
631
+ properties[_chunk5WBPX342cjs.ORGANIZATION_NAME] = org.name;
630
632
  }
631
633
  if (org.plan !== void 0) {
632
- properties[_chunkFORVS4QWcjs.ORGANIZATION_PLAN] = org.plan;
634
+ properties[_chunk5WBPX342cjs.ORGANIZATION_PLAN] = org.plan;
633
635
  }
634
636
  if (org.domain !== void 0) {
635
- properties[_chunkFORVS4QWcjs.ORGANIZATION_DOMAIN] = org.domain;
637
+ properties[_chunk5WBPX342cjs.ORGANIZATION_DOMAIN] = org.domain;
636
638
  }
637
639
  if (org.traits) {
638
640
  for (const [key, value] of Object.entries(org.traits)) {
@@ -646,12 +648,12 @@ function setOrganization(org) {
646
648
  propagatePropertiesImperatively(properties);
647
649
  }
648
650
  function setMessageId(id) {
649
- const properties = { [_chunkFORVS4QWcjs.MESSAGE_ID]: id };
651
+ const properties = { [_chunk5WBPX342cjs.MESSAGE_ID]: id };
650
652
  setCurrentSpanCustomProperties(properties);
651
653
  propagatePropertiesImperatively(properties);
652
654
  }
653
655
  function setSessionId(id) {
654
- const properties = { [_chunkFORVS4QWcjs.SESSION_ID]: id };
656
+ const properties = { [_chunk5WBPX342cjs.SESSION_ID]: id };
655
657
  setCurrentSpanCustomProperties(properties);
656
658
  propagatePropertiesImperatively(properties);
657
659
  }
@@ -674,7 +676,7 @@ function serviceNameProperties(name) {
674
676
  );
675
677
  return {};
676
678
  }
677
- return { [_chunkFORVS4QWcjs.SERVICE_NAME]: name };
679
+ return { [_chunk5WBPX342cjs.SERVICE_NAME]: name };
678
680
  }
679
681
  function setServiceName(name) {
680
682
  const properties = serviceNameProperties(name);
@@ -688,22 +690,22 @@ function withServiceName(name, fn, thisArg) {
688
690
  return withProperties(serviceNameProperties(name), fn, thisArg);
689
691
  }
690
692
  function resolveServiceNameFromContext() {
691
- const props = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
692
- return _optionalChain([props, 'optionalAccess', _35 => _35[_chunkFORVS4QWcjs.SERVICE_NAME]]);
693
+ const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
694
+ return _optionalChain([props, 'optionalAccess', _35 => _35[_chunk5WBPX342cjs.SERVICE_NAME]]);
693
695
  }
694
696
  function userProperties(user) {
695
- const properties = { [_chunkFORVS4QWcjs.USER_ID]: user.id };
697
+ const properties = { [_chunk5WBPX342cjs.USER_ID]: user.id };
696
698
  if (user.email !== void 0) {
697
- properties[_chunkFORVS4QWcjs.USER_EMAIL] = user.email;
699
+ properties[_chunk5WBPX342cjs.USER_EMAIL] = user.email;
698
700
  }
699
701
  if (user.name !== void 0) {
700
- properties[_chunkFORVS4QWcjs.USER_NAME] = user.name;
702
+ properties[_chunk5WBPX342cjs.USER_NAME] = user.name;
701
703
  }
702
704
  if (user.role !== void 0) {
703
- properties[_chunkFORVS4QWcjs.USER_ROLE] = user.role;
705
+ properties[_chunk5WBPX342cjs.USER_ROLE] = user.role;
704
706
  }
705
707
  if (user.plan !== void 0) {
706
- properties[_chunkFORVS4QWcjs.USER_PLAN] = user.plan;
708
+ properties[_chunk5WBPX342cjs.USER_PLAN] = user.plan;
707
709
  }
708
710
  if (user.traits) {
709
711
  for (const [key, value] of Object.entries(user.traits)) {
@@ -716,15 +718,15 @@ function userProperties(user) {
716
718
  return properties;
717
719
  }
718
720
  function organizationProperties(org) {
719
- const properties = { [_chunkFORVS4QWcjs.ORGANIZATION_ID]: org.id };
721
+ const properties = { [_chunk5WBPX342cjs.ORGANIZATION_ID]: org.id };
720
722
  if (org.name !== void 0) {
721
- properties[_chunkFORVS4QWcjs.ORGANIZATION_NAME] = org.name;
723
+ properties[_chunk5WBPX342cjs.ORGANIZATION_NAME] = org.name;
722
724
  }
723
725
  if (org.plan !== void 0) {
724
- properties[_chunkFORVS4QWcjs.ORGANIZATION_PLAN] = org.plan;
726
+ properties[_chunk5WBPX342cjs.ORGANIZATION_PLAN] = org.plan;
725
727
  }
726
728
  if (org.domain !== void 0) {
727
- properties[_chunkFORVS4QWcjs.ORGANIZATION_DOMAIN] = org.domain;
729
+ properties[_chunk5WBPX342cjs.ORGANIZATION_DOMAIN] = org.domain;
728
730
  }
729
731
  if (org.traits) {
730
732
  for (const [key, value] of Object.entries(org.traits)) {
@@ -749,32 +751,32 @@ function withOrganization(org, fn, thisArg) {
749
751
  return withProperties(organizationProperties(org), fn, thisArg);
750
752
  }
751
753
  function callWithMessageId(id, fn, thisArg, ...args) {
752
- return callWithProperties({ [_chunkFORVS4QWcjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
754
+ return callWithProperties({ [_chunk5WBPX342cjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
753
755
  }
754
756
  function withMessageId(id, fn, thisArg) {
755
- return withProperties({ [_chunkFORVS4QWcjs.MESSAGE_ID]: id }, fn, thisArg);
757
+ return withProperties({ [_chunk5WBPX342cjs.MESSAGE_ID]: id }, fn, thisArg);
756
758
  }
757
759
  function inheritedMuteTools() {
758
- const properties = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
759
- return _optionalChain([properties, 'optionalAccess', _36 => _36[_chunkFORVS4QWcjs.MUTE_TOOLS]]);
760
+ const properties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
761
+ return _optionalChain([properties, 'optionalAccess', _36 => _36[_chunk5WBPX342cjs.MUTE_TOOLS]]);
760
762
  }
761
763
  function muteProperties(options) {
762
764
  const { input = true, output = true, tools = output } = options;
763
765
  const properties = {};
764
766
  if (input) {
765
- properties[_chunkFORVS4QWcjs.MUTE_INPUT] = "true";
767
+ properties[_chunk5WBPX342cjs.MUTE_INPUT] = "true";
766
768
  }
767
769
  if (output) {
768
- properties[_chunkFORVS4QWcjs.MUTE_OUTPUT] = "true";
770
+ properties[_chunk5WBPX342cjs.MUTE_OUTPUT] = "true";
769
771
  }
770
772
  if (tools !== output) {
771
- properties[_chunkFORVS4QWcjs.MUTE_TOOLS] = String(tools);
773
+ properties[_chunk5WBPX342cjs.MUTE_TOOLS] = String(tools);
772
774
  } else {
773
775
  const inherited = inheritedMuteTools();
774
776
  if (tools && inherited === "false") {
775
- properties[_chunkFORVS4QWcjs.MUTE_TOOLS] = "true";
777
+ properties[_chunk5WBPX342cjs.MUTE_TOOLS] = "true";
776
778
  } else if (options.tools === false && inherited === "true") {
777
- properties[_chunkFORVS4QWcjs.MUTE_TOOLS] = "false";
779
+ properties[_chunk5WBPX342cjs.MUTE_TOOLS] = "false";
778
780
  }
779
781
  }
780
782
  return properties;
@@ -786,11 +788,11 @@ function withMute(options, fn, thisArg) {
786
788
  return withProperties(muteProperties(options), fn, thisArg);
787
789
  }
788
790
  function withSessionId(sessionId, fn, thisArg, extraProperties) {
789
- const properties = { [_chunkFORVS4QWcjs.SESSION_ID]: sessionId, ...extraProperties };
791
+ const properties = { [_chunk5WBPX342cjs.SESSION_ID]: sessionId, ...extraProperties };
790
792
  return withProperties(properties, fn, thisArg);
791
793
  }
792
794
  function callWithSessionId(sessionId, fn, thisArg, ...args) {
793
- return callWithProperties({ [_chunkFORVS4QWcjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
795
+ return callWithProperties({ [_chunk5WBPX342cjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
794
796
  }
795
797
  var Session = (_class2 = class {
796
798
 
@@ -815,11 +817,11 @@ var Session = (_class2 = class {
815
817
  * @param text - Text to append (null becomes a null/"hide marker")
816
818
  * @param context - Optional per-turn context bag to attach to this turn
817
819
  */
818
- setInput(text, context4) {
820
+ setInput(text, context5) {
819
821
  this.inputs.push(text);
820
- this.inputContexts.push(_nullishCoalesce(context4, () => ( {})));
821
- this.span.setAttribute(_chunkFORVS4QWcjs.SESSION_INPUT, JSON.stringify(this.inputs));
822
- this.span.setAttribute(_chunkFORVS4QWcjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
822
+ this.inputContexts.push(_nullishCoalesce(context5, () => ( {})));
823
+ this.span.setAttribute(_chunk5WBPX342cjs.SESSION_INPUT, JSON.stringify(this.inputs));
824
+ this.span.setAttribute(_chunk5WBPX342cjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
823
825
  }
824
826
  /**
825
827
  * Append an assistant turn to session output tracking.
@@ -831,11 +833,11 @@ var Session = (_class2 = class {
831
833
  * @param text - Text to append (null becomes a null/"hide marker")
832
834
  * @param context - Optional per-turn context bag to attach to this turn
833
835
  */
834
- setOutput(text, context4) {
836
+ setOutput(text, context5) {
835
837
  this.outputs.push(text);
836
- this.outputContexts.push(_nullishCoalesce(context4, () => ( {})));
837
- this.span.setAttribute(_chunkFORVS4QWcjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
838
- this.span.setAttribute(_chunkFORVS4QWcjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
838
+ this.outputContexts.push(_nullishCoalesce(context5, () => ( {})));
839
+ this.span.setAttribute(_chunk5WBPX342cjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
840
+ this.span.setAttribute(_chunk5WBPX342cjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
839
841
  }
840
842
  /**
841
843
  * Set the session title on the span.
@@ -843,7 +845,7 @@ var Session = (_class2 = class {
843
845
  * @param title - The generated title string
844
846
  */
845
847
  setTitle(title) {
846
- this.span.setAttribute(_chunkFORVS4QWcjs.SESSION_TITLE, title);
848
+ this.span.setAttribute(_chunk5WBPX342cjs.SESSION_TITLE, title);
847
849
  }
848
850
  /**
849
851
  * Update custom properties on the session span.
@@ -853,7 +855,7 @@ var Session = (_class2 = class {
853
855
  */
854
856
  updateProperties(properties) {
855
857
  for (const [key, value] of Object.entries(properties)) {
856
- this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${key}`, value);
858
+ this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
857
859
  }
858
860
  }
859
861
  /**
@@ -865,21 +867,21 @@ var Session = (_class2 = class {
865
867
  setUser(user) {
866
868
  if (user.traits) {
867
869
  for (const [key, value] of Object.entries(user.traits)) {
868
- this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.user.${key}`, value);
870
+ this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.user.${key}`, value);
869
871
  }
870
872
  }
871
- this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.USER_ID}`, user.id);
873
+ this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_ID}`, user.id);
872
874
  if (user.email !== void 0) {
873
- this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.USER_EMAIL}`, user.email);
875
+ this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_EMAIL}`, user.email);
874
876
  }
875
877
  if (user.name !== void 0) {
876
- this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.USER_NAME}`, user.name);
878
+ this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_NAME}`, user.name);
877
879
  }
878
880
  if (user.role !== void 0) {
879
- this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.USER_ROLE}`, user.role);
881
+ this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_ROLE}`, user.role);
880
882
  }
881
883
  if (user.plan !== void 0) {
882
- this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.USER_PLAN}`, user.plan);
884
+ this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_PLAN}`, user.plan);
883
885
  }
884
886
  }
885
887
  /**
@@ -891,18 +893,18 @@ var Session = (_class2 = class {
891
893
  setOrganization(org) {
892
894
  if (org.traits) {
893
895
  for (const [key, value] of Object.entries(org.traits)) {
894
- this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.organization.${key}`, value);
896
+ this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.organization.${key}`, value);
895
897
  }
896
898
  }
897
- this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.ORGANIZATION_ID}`, org.id);
899
+ this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_ID}`, org.id);
898
900
  if (org.name !== void 0) {
899
- this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.ORGANIZATION_NAME}`, org.name);
901
+ this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_NAME}`, org.name);
900
902
  }
901
903
  if (org.plan !== void 0) {
902
- this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.ORGANIZATION_PLAN}`, org.plan);
904
+ this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_PLAN}`, org.plan);
903
905
  }
904
906
  if (org.domain !== void 0) {
905
- this.span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.ORGANIZATION_DOMAIN}`, org.domain);
907
+ this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_DOMAIN}`, org.domain);
906
908
  }
907
909
  }
908
910
  /**
@@ -932,30 +934,30 @@ var SessionTitle = class {
932
934
  * @param title - The generated title string
933
935
  */
934
936
  setTitle(title) {
935
- this.span.setAttribute(_chunkFORVS4QWcjs.SESSION_TITLE, title);
937
+ this.span.setAttribute(_chunk5WBPX342cjs.SESSION_TITLE, title);
936
938
  }
937
939
  };
938
940
  function getActiveSession() {
939
- return _api.context.active().getValue(_chunkFORVS4QWcjs.SESSION_OBJECT_CONTEXT_KEY);
941
+ return _api.context.active().getValue(_chunk5WBPX342cjs.SESSION_OBJECT_CONTEXT_KEY);
940
942
  }
941
943
  function resolveSessionIdFromContext() {
942
944
  const active = getActiveSession();
943
945
  if (active) {
944
946
  return active.sessionId;
945
947
  }
946
- const props = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
947
- return _optionalChain([props, 'optionalAccess', _39 => _39[_chunkFORVS4QWcjs.SESSION_ID]]);
948
+ const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
949
+ return _optionalChain([props, 'optionalAccess', _39 => _39[_chunk5WBPX342cjs.SESSION_ID]]);
948
950
  }
949
951
  function resolveMessageIdFromContext() {
950
- const props = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
951
- return _optionalChain([props, 'optionalAccess', _40 => _40[_chunkFORVS4QWcjs.MESSAGE_ID]]);
952
+ const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
953
+ return _optionalChain([props, 'optionalAccess', _40 => _40[_chunk5WBPX342cjs.MESSAGE_ID]]);
952
954
  }
953
955
  function emitExternalLink(sessionId, url, title, linkType) {
954
956
  try {
955
- emitEventWithSessionId(sessionId, _chunkFORVS4QWcjs.EXTERNAL_LINK_EVENT_NAME, {
956
- [_chunkFORVS4QWcjs.EXTERNAL_LINK_URL]: url,
957
- [_chunkFORVS4QWcjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
958
- [_chunkFORVS4QWcjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
957
+ emitEventWithSessionId(sessionId, _chunk5WBPX342cjs.EXTERNAL_LINK_EVENT_NAME, {
958
+ [_chunk5WBPX342cjs.EXTERNAL_LINK_URL]: url,
959
+ [_chunk5WBPX342cjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
960
+ [_chunk5WBPX342cjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
959
961
  });
960
962
  } catch (error) {
961
963
  _chunkWC573FCIcjs.logger.warn("addExternalLink: failed to emit external link", error);
@@ -972,22 +974,22 @@ function addExternalLink(url, options) {
972
974
  emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _42 => _42.title]), _optionalChain([options, 'optionalAccess', _43 => _43.linkType]));
973
975
  }
974
976
  function recordFeedback(type, options) {
975
- const eventAttributes = { [_chunkFORVS4QWcjs.FEEDBACK_TYPE]: type };
977
+ const eventAttributes = { [_chunk5WBPX342cjs.FEEDBACK_TYPE]: type };
976
978
  if (_optionalChain([options, 'optionalAccess', _44 => _44.score]) !== void 0) {
977
- eventAttributes[_chunkFORVS4QWcjs.FEEDBACK_SCORE] = options.score;
979
+ eventAttributes[_chunk5WBPX342cjs.FEEDBACK_SCORE] = options.score;
978
980
  }
979
981
  if (_optionalChain([options, 'optionalAccess', _45 => _45.reason]) !== void 0) {
980
- eventAttributes[_chunkFORVS4QWcjs.FEEDBACK_REASON] = options.reason;
982
+ eventAttributes[_chunk5WBPX342cjs.FEEDBACK_REASON] = options.reason;
981
983
  }
982
984
  if (_optionalChain([options, 'optionalAccess', _46 => _46.comment]) !== void 0) {
983
- eventAttributes[_chunkFORVS4QWcjs.FEEDBACK_COMMENT] = options.comment;
985
+ eventAttributes[_chunk5WBPX342cjs.FEEDBACK_COMMENT] = options.comment;
984
986
  }
985
987
  if (_optionalChain([options, 'optionalAccess', _47 => _47.source]) !== void 0) {
986
- eventAttributes[_chunkFORVS4QWcjs.FEEDBACK_SOURCE] = options.source;
988
+ eventAttributes[_chunk5WBPX342cjs.FEEDBACK_SOURCE] = options.source;
987
989
  }
988
990
  if (_optionalChain([options, 'optionalAccess', _48 => _48.attributes])) {
989
991
  for (const [key, value] of Object.entries(options.attributes)) {
990
- const k = `${_chunkFORVS4QWcjs.FEEDBACK_ATTR_PREFIX}${key}`;
992
+ const k = `${_chunk5WBPX342cjs.FEEDBACK_ATTR_PREFIX}${key}`;
991
993
  if (eventAttributes[k] === void 0) {
992
994
  eventAttributes[k] = value;
993
995
  }
@@ -1002,16 +1004,16 @@ function recordFeedback(type, options) {
1002
1004
  }
1003
1005
  const anchor = {};
1004
1006
  if (messageId !== void 0) {
1005
- anchor[_chunkFORVS4QWcjs.MESSAGE_ID] = messageId;
1007
+ anchor[_chunk5WBPX342cjs.MESSAGE_ID] = messageId;
1006
1008
  }
1007
1009
  if (sessionId !== void 0) {
1008
- anchor[_chunkFORVS4QWcjs.SESSION_ID] = sessionId;
1010
+ anchor[_chunk5WBPX342cjs.SESSION_ID] = sessionId;
1009
1011
  }
1010
1012
  try {
1011
1013
  if (Object.keys(anchor).length === 0) {
1012
- emitEvent(_chunkFORVS4QWcjs.FEEDBACK_EVENT_NAME, eventAttributes);
1014
+ emitEvent(_chunk5WBPX342cjs.FEEDBACK_EVENT_NAME, eventAttributes);
1013
1015
  } else {
1014
- callWithProperties(anchor, () => emitEvent(_chunkFORVS4QWcjs.FEEDBACK_EVENT_NAME, eventAttributes));
1016
+ callWithProperties(anchor, () => emitEvent(_chunk5WBPX342cjs.FEEDBACK_EVENT_NAME, eventAttributes));
1015
1017
  }
1016
1018
  } catch (error) {
1017
1019
  _chunkWC573FCIcjs.logger.warn("recordFeedback: failed to emit feedback event", error);
@@ -1036,7 +1038,7 @@ function recordMetricImpl(options) {
1036
1038
  );
1037
1039
  return;
1038
1040
  }
1039
- if (_chunkFORVS4QWcjs.RESERVED_METRIC_NAMES.has(name)) {
1041
+ if (_chunk5WBPX342cjs.RESERVED_METRIC_NAMES.has(name)) {
1040
1042
  _chunkWC573FCIcjs.logger.warn(
1041
1043
  `recordMetric called with the reserved name ${JSON.stringify(name)}; metric dropped. Brizz computes this metric itself \u2014 pick a different name.`
1042
1044
  );
@@ -1055,17 +1057,17 @@ function recordMetricImpl(options) {
1055
1057
  return;
1056
1058
  }
1057
1059
  const eventAttributes = {
1058
- [_chunkFORVS4QWcjs.METRIC_NAME]: name,
1059
- [_chunkFORVS4QWcjs.METRIC_VALUE]: numericValue
1060
+ [_chunk5WBPX342cjs.METRIC_NAME]: name,
1061
+ [_chunk5WBPX342cjs.METRIC_VALUE]: numericValue
1060
1062
  };
1061
1063
  if (options.unit !== void 0) {
1062
- eventAttributes[_chunkFORVS4QWcjs.METRIC_UNIT] = options.unit;
1064
+ eventAttributes[_chunk5WBPX342cjs.METRIC_UNIT] = options.unit;
1063
1065
  }
1064
1066
  if (options.minValue !== void 0) {
1065
- eventAttributes[_chunkFORVS4QWcjs.METRIC_MIN] = options.minValue;
1067
+ eventAttributes[_chunk5WBPX342cjs.METRIC_MIN] = options.minValue;
1066
1068
  }
1067
1069
  if (options.maxValue !== void 0) {
1068
- eventAttributes[_chunkFORVS4QWcjs.METRIC_MAX] = options.maxValue;
1070
+ eventAttributes[_chunk5WBPX342cjs.METRIC_MAX] = options.maxValue;
1069
1071
  }
1070
1072
  if (options.comment !== void 0) {
1071
1073
  let comment = options.comment;
@@ -1075,21 +1077,21 @@ function recordMetricImpl(options) {
1075
1077
  );
1076
1078
  comment = comment.slice(0, METRIC_COMMENT_MAX_LEN);
1077
1079
  }
1078
- eventAttributes[_chunkFORVS4QWcjs.METRIC_COMMENT] = comment;
1080
+ eventAttributes[_chunk5WBPX342cjs.METRIC_COMMENT] = comment;
1079
1081
  }
1080
1082
  if (options.polarity !== void 0) {
1081
1083
  const polarity = options.polarity;
1082
- if (polarity === _chunkFORVS4QWcjs.METRIC_POLARITY_POSITIVE || polarity === _chunkFORVS4QWcjs.METRIC_POLARITY_NEGATIVE) {
1083
- eventAttributes[_chunkFORVS4QWcjs.METRIC_POLARITY] = polarity;
1084
+ if (polarity === _chunk5WBPX342cjs.METRIC_POLARITY_POSITIVE || polarity === _chunk5WBPX342cjs.METRIC_POLARITY_NEGATIVE) {
1085
+ eventAttributes[_chunk5WBPX342cjs.METRIC_POLARITY] = polarity;
1084
1086
  } else {
1085
1087
  _chunkWC573FCIcjs.logger.warn(
1086
- `recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${_chunkFORVS4QWcjs.METRIC_POLARITY_POSITIVE}' or '${_chunkFORVS4QWcjs.METRIC_POLARITY_NEGATIVE}'. Emitting the metric without it.`
1088
+ `recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${_chunk5WBPX342cjs.METRIC_POLARITY_POSITIVE}' or '${_chunk5WBPX342cjs.METRIC_POLARITY_NEGATIVE}'. Emitting the metric without it.`
1087
1089
  );
1088
1090
  }
1089
1091
  }
1090
1092
  if (options.timestamp !== void 0) {
1091
1093
  if (Number.isFinite(options.timestamp.getTime())) {
1092
- eventAttributes[_chunkFORVS4QWcjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
1094
+ eventAttributes[_chunk5WBPX342cjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
1093
1095
  } else {
1094
1096
  _chunkWC573FCIcjs.logger.warn(
1095
1097
  `recordMetric(${name}) called with an invalid timestamp; emitting the metric without it.`
@@ -1119,7 +1121,7 @@ function recordMetricImpl(options) {
1119
1121
  );
1120
1122
  text = text.slice(0, METRIC_ATTRIBUTE_VALUE_MAX_LEN);
1121
1123
  }
1122
- eventAttributes[`${_chunkFORVS4QWcjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
1124
+ eventAttributes[`${_chunk5WBPX342cjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
1123
1125
  accepted += 1;
1124
1126
  }
1125
1127
  }
@@ -1132,8 +1134,8 @@ function recordMetricImpl(options) {
1132
1134
  }
1133
1135
  try {
1134
1136
  callWithProperties(
1135
- { [_chunkFORVS4QWcjs.SESSION_ID]: sessionId },
1136
- () => emitEvent(_chunkFORVS4QWcjs.METRIC_EVENT_NAME, eventAttributes)
1137
+ { [_chunk5WBPX342cjs.SESSION_ID]: sessionId },
1138
+ () => emitEvent(_chunk5WBPX342cjs.METRIC_EVENT_NAME, eventAttributes)
1137
1139
  );
1138
1140
  } catch (error) {
1139
1141
  _chunkWC573FCIcjs.logger.warn("recordMetric: failed to emit metric event", error);
@@ -1141,19 +1143,19 @@ function recordMetricImpl(options) {
1141
1143
  }
1142
1144
  function startSession(sessionId, callback, extraProperties, options) {
1143
1145
  const isTitle = _optionalChain([options, 'optionalAccess', _52 => _52.mode]) === "title";
1144
- const spanName = isTitle ? _chunkFORVS4QWcjs.SESSION_TITLE_SPAN_NAME : _chunkFORVS4QWcjs.SESSION_SPAN_NAME;
1146
+ const spanName = isTitle ? _chunk5WBPX342cjs.SESSION_TITLE_SPAN_NAME : _chunk5WBPX342cjs.SESSION_SPAN_NAME;
1145
1147
  const tracer = _api.trace.getTracer("@brizz/sdk");
1146
1148
  return tracer.startActiveSpan(spanName, (span) => {
1147
- span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.SESSION_ID}`, sessionId);
1149
+ span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.SESSION_ID}`, sessionId);
1148
1150
  if (extraProperties) {
1149
1151
  for (const [key, value] of Object.entries(extraProperties)) {
1150
- span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${key}`, value);
1152
+ span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
1151
1153
  }
1152
1154
  }
1153
1155
  const session = new Session(sessionId, span);
1154
- const contextProperties = { [_chunkFORVS4QWcjs.SESSION_ID]: sessionId };
1156
+ const contextProperties = { [_chunk5WBPX342cjs.SESSION_ID]: sessionId };
1155
1157
  if (isTitle) {
1156
- contextProperties[_chunkFORVS4QWcjs.SESSION_TITLE_GENERATION] = "true";
1158
+ contextProperties[_chunk5WBPX342cjs.SESSION_TITLE_GENERATION] = "true";
1157
1159
  }
1158
1160
  if (extraProperties) {
1159
1161
  for (const [key, value] of Object.entries(extraProperties)) {
@@ -1161,7 +1163,7 @@ function startSession(sessionId, callback, extraProperties, options) {
1161
1163
  }
1162
1164
  }
1163
1165
  return callWithProperties(contextProperties, () => {
1164
- const sessionCtx = _api.context.active().setValue(_chunkFORVS4QWcjs.SESSION_OBJECT_CONTEXT_KEY, session);
1166
+ const sessionCtx = _api.context.active().setValue(_chunk5WBPX342cjs.SESSION_OBJECT_CONTEXT_KEY, session);
1165
1167
  return _api.context.with(sessionCtx, () => {
1166
1168
  try {
1167
1169
  const result = callback(session);
@@ -1191,14 +1193,14 @@ function startSession(sessionId, callback, extraProperties, options) {
1191
1193
  function startSessionTitle(callback, options) {
1192
1194
  const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _53 => _53.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _54 => _54(), 'optionalAccess', _55 => _55.sessionId])));
1193
1195
  const tracer = _api.trace.getTracer("@brizz/sdk");
1194
- return tracer.startActiveSpan(_chunkFORVS4QWcjs.SESSION_TITLE_SPAN_NAME, (span) => {
1196
+ return tracer.startActiveSpan(_chunk5WBPX342cjs.SESSION_TITLE_SPAN_NAME, (span) => {
1195
1197
  if (resolvedSessionId) {
1196
- span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${_chunkFORVS4QWcjs.SESSION_ID}`, resolvedSessionId);
1198
+ span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.SESSION_ID}`, resolvedSessionId);
1197
1199
  }
1198
1200
  const sessionTitle = new SessionTitle(span);
1199
- const properties = { [_chunkFORVS4QWcjs.SESSION_TITLE_GENERATION]: "true" };
1201
+ const properties = { [_chunk5WBPX342cjs.SESSION_TITLE_GENERATION]: "true" };
1200
1202
  if (resolvedSessionId) {
1201
- properties[_chunkFORVS4QWcjs.SESSION_ID] = resolvedSessionId;
1203
+ properties[_chunk5WBPX342cjs.SESSION_ID] = resolvedSessionId;
1202
1204
  }
1203
1205
  return callWithProperties(properties, () => {
1204
1206
  try {
@@ -1665,10 +1667,10 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
1665
1667
  if (maskingConfig) {
1666
1668
  maskLog(logRecord, maskingConfig);
1667
1669
  }
1668
- const associationProperties = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
1670
+ const associationProperties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
1669
1671
  if (associationProperties) {
1670
1672
  for (const [key, value] of Object.entries(associationProperties)) {
1671
- logRecord.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${key}`, value);
1673
+ logRecord.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
1672
1674
  }
1673
1675
  }
1674
1676
  super.onEmit(logRecord);
@@ -1685,10 +1687,10 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
1685
1687
  if (maskingConfig) {
1686
1688
  maskLog(logRecord, maskingConfig);
1687
1689
  }
1688
- const associationProperties = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
1690
+ const associationProperties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
1689
1691
  if (associationProperties) {
1690
1692
  for (const [key, value] of Object.entries(associationProperties)) {
1691
- logRecord.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${key}`, value);
1693
+ logRecord.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
1692
1694
  }
1693
1695
  }
1694
1696
  super.onEmit(logRecord);
@@ -1715,7 +1717,7 @@ function maskLog(logRecord, config) {
1715
1717
  newAttributes[key] = value;
1716
1718
  }
1717
1719
  for (const [key, value] of Object.entries(logRecord.attributes)) {
1718
- if (key.startsWith(_chunkFORVS4QWcjs.INTERNAL_EVENT_PREFIX)) {
1720
+ if (key.startsWith(_chunk5WBPX342cjs.INTERNAL_EVENT_PREFIX)) {
1719
1721
  newAttributes[key] = value;
1720
1722
  }
1721
1723
  }
@@ -1780,7 +1782,7 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
1780
1782
  const resourceAttributes = {
1781
1783
  ...config.resourceAttributes,
1782
1784
  "service.name": serviceName,
1783
- [BRIZZ_SDK_VERSION]: _chunkWTQTF57Jcjs.getSDKVersion.call(void 0, ),
1785
+ [BRIZZ_SDK_VERSION]: _chunkA3HH5OULcjs.getSDKVersion.call(void 0, ),
1784
1786
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
1785
1787
  };
1786
1788
  if (config.environment) {
@@ -2029,7 +2031,7 @@ var BrizzSpanExporter = (_class5 = class {
2029
2031
  const resourceAttrs = {
2030
2032
  ...config.resourceAttributes,
2031
2033
  "service.name": config.appName,
2032
- [BRIZZ_SDK_VERSION]: _chunkWTQTF57Jcjs.getSDKVersion.call(void 0, ),
2034
+ [BRIZZ_SDK_VERSION]: _chunkA3HH5OULcjs.getSDKVersion.call(void 0, ),
2033
2035
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2034
2036
  };
2035
2037
  if (config.environment) {
@@ -2043,7 +2045,7 @@ var BrizzSpanExporter = (_class5 = class {
2043
2045
  }
2044
2046
  /** The service a span reports under: its scoped override, else the configured appName. */
2045
2047
  _serviceNameOf(span) {
2046
- const value = span.attributes[_chunkFORVS4QWcjs.SERVICE_NAME_ATTRIBUTE];
2048
+ const value = span.attributes[_chunk5WBPX342cjs.SERVICE_NAME_ATTRIBUTE];
2047
2049
  return typeof value === "string" && value !== "" ? value : this._defaultServiceName;
2048
2050
  }
2049
2051
  _resourceFor(serviceName) {
@@ -2169,10 +2171,10 @@ var BrizzSpanExporter = (_class5 = class {
2169
2171
 
2170
2172
  var _sdktracebase = require('@opentelemetry/sdk-trace-base');
2171
2173
  function applyContextAttributes(span) {
2172
- const sessionProperties = _api.context.active().getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
2174
+ const sessionProperties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
2173
2175
  if (sessionProperties) {
2174
2176
  for (const [key, value] of Object.entries(sessionProperties)) {
2175
- span.setAttribute(`${_chunkFORVS4QWcjs.BRIZZ}.${key}`, value);
2177
+ span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
2176
2178
  }
2177
2179
  }
2178
2180
  }
@@ -2362,6 +2364,133 @@ function getSpanProcessor() {
2362
2364
  return TracingModule.getInstance().getSpanProcessor();
2363
2365
  }
2364
2366
 
2367
+ // src/internal/trace/agent.ts
2368
+ var _crypto = require('crypto');
2369
+
2370
+ function newInstanceId() {
2371
+ return _crypto.randomUUID.call(void 0, ).replaceAll("-", "").slice(0, 8);
2372
+ }
2373
+ function activeProperties() {
2374
+ return _nullishCoalesce(_api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY), () => ( {}));
2375
+ }
2376
+ function encodeToken(agent) {
2377
+ const payload = {
2378
+ id: agent.id,
2379
+ parentId: agent.parentId,
2380
+ name: agent.name,
2381
+ traceparent: agent.traceparent,
2382
+ sessionId: agent.sessionId
2383
+ };
2384
+ return Buffer.from(JSON.stringify(payload), "utf8").toString("base64url");
2385
+ }
2386
+ function currentTraceparent() {
2387
+ const carrier = {};
2388
+ try {
2389
+ _api.propagation.inject(_api.context.active(), carrier);
2390
+ } catch (e4) {
2391
+ }
2392
+ return _nullishCoalesce(carrier["traceparent"], () => ( ""));
2393
+ }
2394
+ function agentHandle(id, parentId, name) {
2395
+ const opened = {
2396
+ id,
2397
+ parentId,
2398
+ name,
2399
+ traceparent: currentTraceparent(),
2400
+ sessionId: _nullishCoalesce(activeProperties()[_chunk5WBPX342cjs.SESSION_ID], () => ( ""))
2401
+ };
2402
+ return {
2403
+ ...opened,
2404
+ get token() {
2405
+ return encodeToken(opened);
2406
+ }
2407
+ };
2408
+ }
2409
+ function decodeToken(token) {
2410
+ try {
2411
+ const payload = JSON.parse(Buffer.from(token, "base64url").toString("utf8"));
2412
+ return payload.id ? payload : void 0;
2413
+ } catch (e5) {
2414
+ return void 0;
2415
+ }
2416
+ }
2417
+ function unreadableAgent(agent) {
2418
+ return {
2419
+ id: "",
2420
+ parentId: "",
2421
+ name: "",
2422
+ traceparent: "",
2423
+ sessionId: "",
2424
+ token: typeof agent === "string" ? "" : _nullishCoalesce(agent.token, () => ( ""))
2425
+ };
2426
+ }
2427
+ function resolveAgent(agent) {
2428
+ const options = typeof agent === "string" ? { name: agent } : agent;
2429
+ let id;
2430
+ let parentId;
2431
+ let name;
2432
+ let sessionId = "";
2433
+ let parentContext = _api.context.active();
2434
+ if (options.token === void 0) {
2435
+ id = options.id || newInstanceId();
2436
+ parentId = options.parentId || activeProperties()[_chunk5WBPX342cjs.AGENT_ID] || "";
2437
+ name = _nullishCoalesce(options.name, () => ( ""));
2438
+ } else {
2439
+ const decoded = decodeToken(options.token);
2440
+ if (!decoded) {
2441
+ _chunkWC573FCIcjs.logger.warn("Brizz: ignoring an unreadable agent token");
2442
+ return void 0;
2443
+ }
2444
+ id = decoded.id;
2445
+ parentId = decoded.parentId;
2446
+ name = decoded.name;
2447
+ sessionId = decoded.sessionId;
2448
+ if (decoded.traceparent) {
2449
+ try {
2450
+ parentContext = _api.propagation.extract(parentContext, { traceparent: decoded.traceparent });
2451
+ } catch (e6) {
2452
+ }
2453
+ }
2454
+ }
2455
+ const properties = { [_chunk5WBPX342cjs.AGENT_ID]: id, [_chunk5WBPX342cjs.AGENT_NAME]: name };
2456
+ if (parentId) {
2457
+ properties[_chunk5WBPX342cjs.AGENT_PARENT_ID] = parentId;
2458
+ }
2459
+ if (sessionId) {
2460
+ properties[_chunk5WBPX342cjs.SESSION_ID] = sessionId;
2461
+ }
2462
+ return { id, parentId, name, properties, parentContext };
2463
+ }
2464
+ function startAgent(agent, callback) {
2465
+ const resolved = resolveAgent(agent);
2466
+ if (!resolved) {
2467
+ return callback(unreadableAgent(agent));
2468
+ }
2469
+ const { id, parentId, name, properties, parentContext } = resolved;
2470
+ return _api.context.with(
2471
+ parentContext,
2472
+ () => callWithProperties(properties, () => callback(agentHandle(id, parentId, name)))
2473
+ );
2474
+ }
2475
+ function withAgent(agent, fn, thisArg) {
2476
+ return function wrapped(...args) {
2477
+ return startAgent(
2478
+ agent,
2479
+ () => fn.apply(thisArg !== void 0 ? thisArg : this, args)
2480
+ );
2481
+ };
2482
+ }
2483
+ function setAgent(agent) {
2484
+ const resolved = resolveAgent(agent);
2485
+ if (!resolved) {
2486
+ return unreadableAgent(agent);
2487
+ }
2488
+ const { id, parentId, name, properties, parentContext } = resolved;
2489
+ setCurrentSpanCustomProperties(properties);
2490
+ propagatePropertiesImperatively(properties, parentContext);
2491
+ return agentHandle(id, parentId, name);
2492
+ }
2493
+
2365
2494
  // src/internal/sdk.ts
2366
2495
  function resolveMcpSessionTracking(configured) {
2367
2496
  const fromEnv = process.env["BRIZZ_MCP_SESSION_TRACKING"];
@@ -2391,7 +2520,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2391
2520
  */
2392
2521
  setupInstrumentation(options) {
2393
2522
  const registry = InstrumentationRegistry.getInstance();
2394
- _chunkWTQTF57Jcjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
2523
+ _chunkA3HH5OULcjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
2395
2524
  if (options.instrumentModules && Object.keys(options.instrumentModules).length > 0) {
2396
2525
  registry.setManualModules(options.instrumentModules);
2397
2526
  }
@@ -2414,7 +2543,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2414
2543
  const resourceAttributes = {
2415
2544
  ...resolvedConfig.resourceAttributes,
2416
2545
  "service.name": resolvedConfig.appName,
2417
- [BRIZZ_SDK_VERSION]: _chunkWTQTF57Jcjs.getSDKVersion.call(void 0, ),
2546
+ [BRIZZ_SDK_VERSION]: _chunkA3HH5OULcjs.getSDKVersion.call(void 0, ),
2418
2547
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2419
2548
  };
2420
2549
  if (resolvedConfig.environment) {
@@ -2426,7 +2555,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2426
2555
  const resource = _resources2.defaultResource.call(void 0, ).merge(_resources2.detectResources.call(void 0, { detectors: [_resources2.envDetector, _resources2.hostDetector, _resources2.processDetector] })).merge(_resources2.resourceFromAttributes.call(void 0, resourceAttributes));
2427
2556
  this._tracerProvider = new (0, _sdktracenode.NodeTracerProvider)({
2428
2557
  resource,
2429
- spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkQUV5HYJ2cjs.InterruptPropagator)(), getSpanProcessor()]
2558
+ spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunk3IGBYXLRcjs.InterruptPropagator)(), getSpanProcessor()]
2430
2559
  });
2431
2560
  this._tracerProvider.register();
2432
2561
  this._meterProvider = new (0, _sdkmetrics.MeterProvider)({ resource, readers: [getMetricsReader()] });
@@ -2484,19 +2613,19 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2484
2613
  try {
2485
2614
  const tracingModule = TracingModule.getInstance();
2486
2615
  await tracingModule.shutdown();
2487
- } catch (e4) {
2616
+ } catch (e7) {
2488
2617
  _chunkWC573FCIcjs.logger.debug("Tracing module already shut down or not initialized");
2489
2618
  }
2490
2619
  try {
2491
2620
  const metricsModule = MetricsModule.getInstance();
2492
2621
  metricsModule.shutdown();
2493
- } catch (e5) {
2622
+ } catch (e8) {
2494
2623
  _chunkWC573FCIcjs.logger.debug("Metrics module already shut down or not initialized");
2495
2624
  }
2496
2625
  try {
2497
2626
  const loggingModule = LoggingModule.getInstance();
2498
2627
  await loggingModule.shutdown();
2499
- } catch (e6) {
2628
+ } catch (e9) {
2500
2629
  _chunkWC573FCIcjs.logger.debug("Logging module already shut down or not initialized");
2501
2630
  }
2502
2631
  _chunkWC573FCIcjs.logger.info("All telemetry modules shut down successfully");
@@ -2629,4 +2758,7 @@ var Brizz = new _Brizz();
2629
2758
 
2630
2759
 
2631
2760
 
2632
- exports.Brizz = Brizz; exports.DEFAULT_PII_PATTERNS = DEFAULT_PII_PATTERNS; exports.LogLevel = _chunkWC573FCIcjs.LogLevel; exports.Session = Session; exports.SessionTitle = SessionTitle; exports.SeverityNumber = _apilogs.SeverityNumber; exports.addExternalLink = addExternalLink; exports.callWithMessageId = callWithMessageId; exports.callWithMute = callWithMute; exports.callWithOrganization = callWithOrganization; exports.callWithProperties = callWithProperties; exports.callWithServiceName = callWithServiceName; exports.callWithSessionId = callWithSessionId; exports.callWithUser = callWithUser; exports.emitEvent = emitEvent; exports.emitEventWithSessionId = emitEventWithSessionId; exports.getActiveSession = getActiveSession; exports.getLogLevel = _chunkWC573FCIcjs.getLogLevel; exports.getMetricsExporter = getMetricsExporter; exports.getMetricsReader = getMetricsReader; exports.getSpanExporter = getSpanExporter; exports.getSpanProcessor = getSpanProcessor; exports.logger = _chunkWC573FCIcjs.logger; exports.maskAttributes = maskAttributes; exports.maskValue = maskValue; exports.recordFeedback = recordFeedback; exports.recordMetric = recordMetric; exports.setCurrentSpanCustomProperties = setCurrentSpanCustomProperties; exports.setLogLevel = _chunkWC573FCIcjs.setLogLevel; exports.setMessageId = setMessageId; exports.setOrganization = setOrganization; exports.setServiceName = setServiceName; exports.setSessionId = setSessionId; exports.setUser = setUser; exports.startSession = startSession; exports.startSessionTitle = startSessionTitle; exports.withMessageId = withMessageId; exports.withMute = withMute; exports.withOrganization = withOrganization; exports.withProperties = withProperties; exports.withServiceName = withServiceName; exports.withSessionId = withSessionId; exports.withUser = withUser;
2761
+
2762
+
2763
+
2764
+ exports.Brizz = Brizz; exports.DEFAULT_PII_PATTERNS = DEFAULT_PII_PATTERNS; exports.LogLevel = _chunkWC573FCIcjs.LogLevel; exports.Session = Session; exports.SessionTitle = SessionTitle; exports.SeverityNumber = _apilogs.SeverityNumber; exports.addExternalLink = addExternalLink; exports.callWithMessageId = callWithMessageId; exports.callWithMute = callWithMute; exports.callWithOrganization = callWithOrganization; exports.callWithProperties = callWithProperties; exports.callWithServiceName = callWithServiceName; exports.callWithSessionId = callWithSessionId; exports.callWithUser = callWithUser; exports.emitEvent = emitEvent; exports.emitEventWithSessionId = emitEventWithSessionId; exports.getActiveSession = getActiveSession; exports.getLogLevel = _chunkWC573FCIcjs.getLogLevel; exports.getMetricsExporter = getMetricsExporter; exports.getMetricsReader = getMetricsReader; exports.getSpanExporter = getSpanExporter; exports.getSpanProcessor = getSpanProcessor; exports.logger = _chunkWC573FCIcjs.logger; exports.maskAttributes = maskAttributes; exports.maskValue = maskValue; exports.recordFeedback = recordFeedback; exports.recordMetric = recordMetric; exports.setAgent = setAgent; exports.setCurrentSpanCustomProperties = setCurrentSpanCustomProperties; exports.setLogLevel = _chunkWC573FCIcjs.setLogLevel; exports.setMessageId = setMessageId; exports.setOrganization = setOrganization; exports.setServiceName = setServiceName; exports.setSessionId = setSessionId; exports.setUser = setUser; exports.startAgent = startAgent; exports.startSession = startSession; exports.startSessionTitle = startSessionTitle; exports.withAgent = withAgent; exports.withMessageId = withMessageId; exports.withMute = withMute; exports.withOrganization = withOrganization; exports.withProperties = withProperties; exports.withServiceName = withServiceName; exports.withSessionId = withSessionId; exports.withUser = withUser;