@brizz/sdk 0.1.47 → 0.1.49

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.
Files changed (25) hide show
  1. package/README.md +15 -0
  2. package/dist/{chunk-APOYOP7D.js → chunk-3OMB2F7B.js} +1 -1
  3. package/dist/{chunk-3IGBYXLR.cjs → chunk-ELLCNMLI.cjs} +4 -4
  4. package/dist/{chunk-AOT5NJDV.js → chunk-FVVRWMPV.js} +2 -0
  5. package/dist/{chunk-5WBPX342.cjs → chunk-GMZQ6N77.cjs} +3 -1
  6. package/dist/{chunk-V727EJE5.js → chunk-HTFR2LKY.js} +2 -2
  7. package/dist/{chunk-EWT4TUB7.cjs → chunk-VAUO47L3.cjs} +8 -8
  8. package/dist/index.cjs +234 -153
  9. package/dist/index.js +108 -27
  10. package/dist/{interrupt-A6O7N72X.js → interrupt-YO3ID433.js} +2 -2
  11. package/dist/interrupt-YQHEXVES.cjs +12 -0
  12. package/dist/{mcp-3FOEDOF2.cjs → mcp-FWGIYACB.cjs} +12 -12
  13. package/dist/{mcp-GANFYW4J.js → mcp-LIAXZGBN.js} +2 -2
  14. package/dist/types/cjs/internal/instrumentation/langgraph/attributes.d.ts +1 -0
  15. package/dist/types/cjs/internal/instrumentation/langgraph/index.d.ts +1 -1
  16. package/dist/types/cjs/internal/instrumentation/langgraph/instrumentation.d.ts +1 -0
  17. package/dist/types/cjs/internal/semantic-conventions.d.ts +1 -0
  18. package/dist/types/cjs/internal/trace/session.d.ts +2 -0
  19. package/dist/types/esm/internal/instrumentation/langgraph/attributes.d.ts +1 -0
  20. package/dist/types/esm/internal/instrumentation/langgraph/index.d.ts +1 -1
  21. package/dist/types/esm/internal/instrumentation/langgraph/instrumentation.d.ts +1 -0
  22. package/dist/types/esm/internal/semantic-conventions.d.ts +1 -0
  23. package/dist/types/esm/internal/trace/session.d.ts +2 -0
  24. package/package.json +3 -2
  25. package/dist/interrupt-IKOUBQGN.cjs +0 -12
package/dist/index.cjs CHANGED
@@ -5,7 +5,7 @@ var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
5
5
 
6
6
 
7
7
 
8
- var _chunkEWT4TUB7cjs = require('./chunk-EWT4TUB7.cjs');
8
+ var _chunkVAUO47L3cjs = require('./chunk-VAUO47L3.cjs');
9
9
 
10
10
 
11
11
 
@@ -16,7 +16,7 @@ var _chunkEWT4TUB7cjs = require('./chunk-EWT4TUB7.cjs');
16
16
  var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
17
17
 
18
18
 
19
- var _chunk3IGBYXLRcjs = require('./chunk-3IGBYXLR.cjs');
19
+ var _chunkELLCNMLIcjs = require('./chunk-ELLCNMLI.cjs');
20
20
 
21
21
 
22
22
 
@@ -73,7 +73,8 @@ var _chunk3IGBYXLRcjs = require('./chunk-3IGBYXLR.cjs');
73
73
 
74
74
 
75
75
 
76
- var _chunk5WBPX342cjs = require('./chunk-5WBPX342.cjs');
76
+
77
+ var _chunkGMZQ6N77cjs = require('./chunk-GMZQ6N77.cjs');
77
78
 
78
79
 
79
80
  var _chunkOBGZSXTJcjs = require('./chunk-OBGZSXTJ.cjs');
@@ -91,6 +92,7 @@ var _instrumentationqdrant = require('@traceloop/instrumentation-qdrant');
91
92
  var _instrumentationtogether = require('@traceloop/instrumentation-together');
92
93
 
93
94
  // src/internal/instrumentation/langgraph/instrumentation.ts
95
+ var _module = require('module');
94
96
  var _api = require('@opentelemetry/api');
95
97
 
96
98
 
@@ -99,9 +101,16 @@ var _api = require('@opentelemetry/api');
99
101
 
100
102
  // src/internal/instrumentation/langgraph/attributes.ts
101
103
  var INSTRUMENTATION_NAME = "@brizz/sdk/langgraph";
102
- var INSTRUMENTATION_VERSION = _chunkEWT4TUB7cjs.getSDKVersion.call(void 0, );
104
+ var INSTRUMENTATION_VERSION = _chunkVAUO47L3cjs.getSDKVersion.call(void 0, );
103
105
  var MODULE_NAME = "@langchain/langgraph";
104
106
  var SUPPORTED_VERSIONS = [">=0.2.0 <2"];
107
+ function isSupportedVersion(version) {
108
+ const [major, minor] = version.split(".").map(Number);
109
+ if (major === void 0 || minor === void 0 || Number.isNaN(major) || Number.isNaN(minor)) {
110
+ return false;
111
+ }
112
+ return major === 1 || major === 0 && minor >= 2;
113
+ }
105
114
  var CHECKPOINT_SPAN_NAME = "brizz.langgraph.checkpoint";
106
115
  var ATTR_CHECKPOINT_PARENT_ID = "brizz.checkpoint_parent_id";
107
116
  var ATTR_CHECKPOINT_ID = "brizz.checkpoint_id";
@@ -180,7 +189,8 @@ var LangGraphInstrumentation = class extends _instrumentation.InstrumentationBas
180
189
  * Patch a LangGraph module the caller already imported.
181
190
  *
182
191
  * The module-load hook above only fires for CommonJS requires, so an ESM or
183
- * bundled consumer reaches the instrumentation through here — via
192
+ * bundled consumer reaches the instrumentation through here — from
193
+ * `patchInstalledLangGraph`, or from
184
194
  * `Brizz.initialize({ instrumentModules: { langgraph } })`. Accepts either
185
195
  * the package root or its `pregel` subpath.
186
196
  */
@@ -198,6 +208,43 @@ var LangGraphInstrumentation = class extends _instrumentation.InstrumentationBas
198
208
  }
199
209
  }
200
210
  };
211
+ function patchInstalledLangGraph() {
212
+ let requireFromSdk;
213
+ let version;
214
+ try {
215
+ requireFromSdk = _module.createRequire.call(void 0, __filename);
216
+ version = requireFromSdk(`${MODULE_NAME}/package.json`).version;
217
+ } catch (error) {
218
+ _chunkWC573FCIcjs.logger.debug(`LangGraph not resolved, not patched: ${String(error)}`);
219
+ return;
220
+ }
221
+ if (!isSupportedVersion(version)) {
222
+ _chunkWC573FCIcjs.logger.debug(`LangGraph ${version} is outside ${SUPPORTED_VERSIONS.join(" ")}, not patched`);
223
+ return;
224
+ }
225
+ let instrumentation;
226
+ try {
227
+ instrumentation = new LangGraphInstrumentation({ enabled: false });
228
+ } catch (error) {
229
+ _chunkWC573FCIcjs.logger.debug(`LangGraph instrumentation not constructed: ${String(error)}`);
230
+ return;
231
+ }
232
+ try {
233
+ const loaded = requireFromSdk.cache[requireFromSdk.resolve(MODULE_NAME)];
234
+ if (loaded) {
235
+ instrumentation.manuallyInstrument(loaded.exports);
236
+ }
237
+ } catch (error) {
238
+ _chunkWC573FCIcjs.logger.debug(`LangGraph CJS build not patched: ${String(error)}`);
239
+ }
240
+ void (async () => {
241
+ try {
242
+ instrumentation.manuallyInstrument(await Promise.resolve().then(() => _interopRequireWildcard(require("@langchain/langgraph"))));
243
+ } catch (error) {
244
+ _chunkWC573FCIcjs.logger.debug(`LangGraph not patched: ${String(error)}`);
245
+ }
246
+ })();
247
+ }
201
248
  function patchPregelStream(proto, getTracer) {
202
249
  const target = proto;
203
250
  if (target[PATCHED_FLAG]) {
@@ -418,7 +465,7 @@ function loadGenAIInstrumentations() {
418
465
  function loadMCPInstrumentation() {
419
466
  void (async () => {
420
467
  try {
421
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-3FOEDOF2.cjs")));
468
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-FWGIYACB.cjs")));
422
469
  const mcp = new MCPInstrumentation({ exceptionLogger });
423
470
  _instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp] });
424
471
  _chunkWC573FCIcjs.logger.debug("Auto-loaded MCP instrumentation");
@@ -482,7 +529,7 @@ function loadVercelAITelemetry() {
482
529
  }
483
530
  const isV7 = typeof ai.registerTelemetry === "function";
484
531
  const integrations = [];
485
- const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-IKOUBQGN.cjs")));
532
+ const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-YQHEXVES.cjs")));
486
533
  integrations.push(createInterruptIntegration());
487
534
  let otelCollectorLoaded = false;
488
535
  try {
@@ -693,25 +740,25 @@ var SDK_LANGUAGE = "typescript";
693
740
 
694
741
 
695
742
  // src/internal/instrumentation/langchain.ts
696
- var _module = require('module');
743
+
697
744
 
698
745
  var SCOPE_NAME = "@arizeai/openinference-instrumentation-langchain";
699
746
  var PATCHED_MARKER = /* @__PURE__ */ Symbol.for("brizz.langchain.callbackManagerPatched");
700
747
  var OMITTED_KEYS = /* @__PURE__ */ new Set([
701
- _chunk5WBPX342cjs.USER_EMAIL,
702
- _chunk5WBPX342cjs.USER_NAME,
703
- _chunk5WBPX342cjs.ORGANIZATION_NAME,
704
- _chunk5WBPX342cjs.ORGANIZATION_DOMAIN
748
+ _chunkGMZQ6N77cjs.USER_EMAIL,
749
+ _chunkGMZQ6N77cjs.USER_NAME,
750
+ _chunkGMZQ6N77cjs.ORGANIZATION_NAME,
751
+ _chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN
705
752
  ]);
706
753
  function runMetadataFromContext() {
707
- const bag = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
754
+ const bag = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
708
755
  if (!bag) {
709
756
  return void 0;
710
757
  }
711
758
  const metadata = {};
712
759
  for (const [name, value] of Object.entries(bag)) {
713
760
  if (!OMITTED_KEYS.has(name)) {
714
- metadata[`${_chunk5WBPX342cjs.BRIZZ}.${name}`] = String(value);
761
+ metadata[`${_chunkGMZQ6N77cjs.BRIZZ}.${name}`] = String(value);
715
762
  }
716
763
  }
717
764
  return Object.keys(metadata).length > 0 ? metadata : void 0;
@@ -768,7 +815,7 @@ function restampLangChainSpan(span) {
768
815
  }
769
816
  const attrs = span.attributes;
770
817
  const metadata = attrs["metadata"];
771
- if (typeof metadata !== "string" || !metadata.includes(`"${_chunk5WBPX342cjs.BRIZZ}.`)) {
818
+ if (typeof metadata !== "string" || !metadata.includes(`"${_chunkGMZQ6N77cjs.BRIZZ}.`)) {
772
819
  return;
773
820
  }
774
821
  const parsed = JSON.parse(metadata);
@@ -776,7 +823,7 @@ function restampLangChainSpan(span) {
776
823
  return;
777
824
  }
778
825
  for (const [key, value] of Object.entries(parsed)) {
779
- if (key.startsWith(`${_chunk5WBPX342cjs.BRIZZ}.`) && value !== null && value !== void 0) {
826
+ if (key.startsWith(`${_chunkGMZQ6N77cjs.BRIZZ}.`) && value !== null && value !== void 0) {
780
827
  attrs[key] = String(value);
781
828
  }
782
829
  }
@@ -914,7 +961,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
914
961
  const mcpModules = this.manualModules.mcp;
915
962
  void (async () => {
916
963
  try {
917
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-3FOEDOF2.cjs")));
964
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-FWGIYACB.cjs")));
918
965
  const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
919
966
  instrumentation.manuallyInstrument(mcpModules);
920
967
  _chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
@@ -965,16 +1012,16 @@ function setCurrentSpanCustomProperties(properties) {
965
1012
  }
966
1013
  for (const [key, value] of Object.entries(properties)) {
967
1014
  try {
968
- current.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
1015
+ current.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
969
1016
  } catch (e3) {
970
1017
  }
971
1018
  }
972
1019
  }
973
1020
  function callWithProperties(properties, fn, thisArg, ...args) {
974
1021
  const base = _api.context.active();
975
- const prev = base.getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
1022
+ const prev = base.getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
976
1023
  const merged = prev ? { ...prev, ...properties } : properties;
977
- const next = base.setValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY, merged);
1024
+ const next = base.setValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY, merged);
978
1025
  return _api.context.with(next, fn, thisArg, ...args);
979
1026
  }
980
1027
  function withProperties(properties, fn, thisArg) {
@@ -995,25 +1042,25 @@ function propagatePropertiesImperatively(properties, base = _api.context.active(
995
1042
  if (!store || typeof store.enterWith !== "function") {
996
1043
  return;
997
1044
  }
998
- const prev = base.getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
1045
+ const prev = base.getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
999
1046
  const merged = prev ? { ...prev, ...properties } : properties;
1000
- store.enterWith(base.setValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY, merged));
1047
+ store.enterWith(base.setValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY, merged));
1001
1048
  } catch (e4) {
1002
1049
  }
1003
1050
  }
1004
1051
  function setUser(user) {
1005
- const properties = { [_chunk5WBPX342cjs.USER_ID]: user.id };
1052
+ const properties = { [_chunkGMZQ6N77cjs.USER_ID]: user.id };
1006
1053
  if (user.email !== void 0) {
1007
- properties[_chunk5WBPX342cjs.USER_EMAIL] = user.email;
1054
+ properties[_chunkGMZQ6N77cjs.USER_EMAIL] = user.email;
1008
1055
  }
1009
1056
  if (user.name !== void 0) {
1010
- properties[_chunk5WBPX342cjs.USER_NAME] = user.name;
1057
+ properties[_chunkGMZQ6N77cjs.USER_NAME] = user.name;
1011
1058
  }
1012
1059
  if (user.role !== void 0) {
1013
- properties[_chunk5WBPX342cjs.USER_ROLE] = user.role;
1060
+ properties[_chunkGMZQ6N77cjs.USER_ROLE] = user.role;
1014
1061
  }
1015
1062
  if (user.plan !== void 0) {
1016
- properties[_chunk5WBPX342cjs.USER_PLAN] = user.plan;
1063
+ properties[_chunkGMZQ6N77cjs.USER_PLAN] = user.plan;
1017
1064
  }
1018
1065
  if (user.traits) {
1019
1066
  for (const [key, value] of Object.entries(user.traits)) {
@@ -1027,15 +1074,15 @@ function setUser(user) {
1027
1074
  propagatePropertiesImperatively(properties);
1028
1075
  }
1029
1076
  function setOrganization(org) {
1030
- const properties = { [_chunk5WBPX342cjs.ORGANIZATION_ID]: org.id };
1077
+ const properties = { [_chunkGMZQ6N77cjs.ORGANIZATION_ID]: org.id };
1031
1078
  if (org.name !== void 0) {
1032
- properties[_chunk5WBPX342cjs.ORGANIZATION_NAME] = org.name;
1079
+ properties[_chunkGMZQ6N77cjs.ORGANIZATION_NAME] = org.name;
1033
1080
  }
1034
1081
  if (org.plan !== void 0) {
1035
- properties[_chunk5WBPX342cjs.ORGANIZATION_PLAN] = org.plan;
1082
+ properties[_chunkGMZQ6N77cjs.ORGANIZATION_PLAN] = org.plan;
1036
1083
  }
1037
1084
  if (org.domain !== void 0) {
1038
- properties[_chunk5WBPX342cjs.ORGANIZATION_DOMAIN] = org.domain;
1085
+ properties[_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN] = org.domain;
1039
1086
  }
1040
1087
  if (org.traits) {
1041
1088
  for (const [key, value] of Object.entries(org.traits)) {
@@ -1049,35 +1096,36 @@ function setOrganization(org) {
1049
1096
  propagatePropertiesImperatively(properties);
1050
1097
  }
1051
1098
  function setMessageId(id) {
1052
- const properties = { [_chunk5WBPX342cjs.MESSAGE_ID]: id };
1099
+ const properties = { [_chunkGMZQ6N77cjs.MESSAGE_ID]: id };
1053
1100
  setCurrentSpanCustomProperties(properties);
1054
1101
  propagatePropertiesImperatively(properties);
1055
1102
  }
1056
1103
  function setSessionId(id) {
1057
- const properties = { [_chunk5WBPX342cjs.SESSION_ID]: id };
1104
+ const properties = { [_chunkGMZQ6N77cjs.SESSION_ID]: id };
1058
1105
  setCurrentSpanCustomProperties(properties);
1059
1106
  propagatePropertiesImperatively(properties);
1060
1107
  }
1061
1108
  var SERVICE_NAME_MAX_BYTES = 256;
1062
- function serviceNameProperties(name) {
1109
+ function serviceNameProblem(name) {
1063
1110
  if (typeof name !== "string" || name === "") {
1064
- _chunkWC573FCIcjs.logger.warn("Service name must be a non-empty string; keeping the configured appName.");
1065
- return {};
1111
+ return "must be a non-empty string";
1066
1112
  }
1067
1113
  if (/[\r\n\0]/.test(name)) {
1068
- _chunkWC573FCIcjs.logger.warn(
1069
- `Service name ${JSON.stringify(name)} contains CR, LF, or NUL; keeping the configured appName.`
1070
- );
1071
- return {};
1114
+ return `${JSON.stringify(name)} contains CR, LF, or NUL`;
1072
1115
  }
1073
1116
  const byteLength = new globalThis.TextEncoder().encode(name).length;
1074
1117
  if (byteLength > SERVICE_NAME_MAX_BYTES) {
1075
- _chunkWC573FCIcjs.logger.warn(
1076
- `Service name is ${byteLength} bytes, over the ${SERVICE_NAME_MAX_BYTES}-byte limit; keeping the configured appName.`
1077
- );
1118
+ return `is ${byteLength} bytes, over the ${SERVICE_NAME_MAX_BYTES}-byte limit`;
1119
+ }
1120
+ return void 0;
1121
+ }
1122
+ function serviceNameProperties(name) {
1123
+ const problem = serviceNameProblem(name);
1124
+ if (problem !== void 0) {
1125
+ _chunkWC573FCIcjs.logger.warn(`Service name ${problem}; keeping the configured appName.`);
1078
1126
  return {};
1079
1127
  }
1080
- return { [_chunk5WBPX342cjs.SERVICE_NAME]: name };
1128
+ return { [_chunkGMZQ6N77cjs.SERVICE_NAME]: name };
1081
1129
  }
1082
1130
  function setServiceName(name) {
1083
1131
  const properties = serviceNameProperties(name);
@@ -1091,22 +1139,22 @@ function withServiceName(name, fn, thisArg) {
1091
1139
  return withProperties(serviceNameProperties(name), fn, thisArg);
1092
1140
  }
1093
1141
  function resolveServiceNameFromContext() {
1094
- const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
1095
- return _optionalChain([props, 'optionalAccess', _56 => _56[_chunk5WBPX342cjs.SERVICE_NAME]]);
1142
+ const props = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1143
+ return _optionalChain([props, 'optionalAccess', _56 => _56[_chunkGMZQ6N77cjs.SERVICE_NAME]]);
1096
1144
  }
1097
1145
  function userProperties(user) {
1098
- const properties = { [_chunk5WBPX342cjs.USER_ID]: user.id };
1146
+ const properties = { [_chunkGMZQ6N77cjs.USER_ID]: user.id };
1099
1147
  if (user.email !== void 0) {
1100
- properties[_chunk5WBPX342cjs.USER_EMAIL] = user.email;
1148
+ properties[_chunkGMZQ6N77cjs.USER_EMAIL] = user.email;
1101
1149
  }
1102
1150
  if (user.name !== void 0) {
1103
- properties[_chunk5WBPX342cjs.USER_NAME] = user.name;
1151
+ properties[_chunkGMZQ6N77cjs.USER_NAME] = user.name;
1104
1152
  }
1105
1153
  if (user.role !== void 0) {
1106
- properties[_chunk5WBPX342cjs.USER_ROLE] = user.role;
1154
+ properties[_chunkGMZQ6N77cjs.USER_ROLE] = user.role;
1107
1155
  }
1108
1156
  if (user.plan !== void 0) {
1109
- properties[_chunk5WBPX342cjs.USER_PLAN] = user.plan;
1157
+ properties[_chunkGMZQ6N77cjs.USER_PLAN] = user.plan;
1110
1158
  }
1111
1159
  if (user.traits) {
1112
1160
  for (const [key, value] of Object.entries(user.traits)) {
@@ -1119,15 +1167,15 @@ function userProperties(user) {
1119
1167
  return properties;
1120
1168
  }
1121
1169
  function organizationProperties(org) {
1122
- const properties = { [_chunk5WBPX342cjs.ORGANIZATION_ID]: org.id };
1170
+ const properties = { [_chunkGMZQ6N77cjs.ORGANIZATION_ID]: org.id };
1123
1171
  if (org.name !== void 0) {
1124
- properties[_chunk5WBPX342cjs.ORGANIZATION_NAME] = org.name;
1172
+ properties[_chunkGMZQ6N77cjs.ORGANIZATION_NAME] = org.name;
1125
1173
  }
1126
1174
  if (org.plan !== void 0) {
1127
- properties[_chunk5WBPX342cjs.ORGANIZATION_PLAN] = org.plan;
1175
+ properties[_chunkGMZQ6N77cjs.ORGANIZATION_PLAN] = org.plan;
1128
1176
  }
1129
1177
  if (org.domain !== void 0) {
1130
- properties[_chunk5WBPX342cjs.ORGANIZATION_DOMAIN] = org.domain;
1178
+ properties[_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN] = org.domain;
1131
1179
  }
1132
1180
  if (org.traits) {
1133
1181
  for (const [key, value] of Object.entries(org.traits)) {
@@ -1152,32 +1200,32 @@ function withOrganization(org, fn, thisArg) {
1152
1200
  return withProperties(organizationProperties(org), fn, thisArg);
1153
1201
  }
1154
1202
  function callWithMessageId(id, fn, thisArg, ...args) {
1155
- return callWithProperties({ [_chunk5WBPX342cjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
1203
+ return callWithProperties({ [_chunkGMZQ6N77cjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
1156
1204
  }
1157
1205
  function withMessageId(id, fn, thisArg) {
1158
- return withProperties({ [_chunk5WBPX342cjs.MESSAGE_ID]: id }, fn, thisArg);
1206
+ return withProperties({ [_chunkGMZQ6N77cjs.MESSAGE_ID]: id }, fn, thisArg);
1159
1207
  }
1160
1208
  function inheritedMuteTools() {
1161
- const properties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
1162
- return _optionalChain([properties, 'optionalAccess', _57 => _57[_chunk5WBPX342cjs.MUTE_TOOLS]]);
1209
+ const properties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1210
+ return _optionalChain([properties, 'optionalAccess', _57 => _57[_chunkGMZQ6N77cjs.MUTE_TOOLS]]);
1163
1211
  }
1164
1212
  function muteProperties(options) {
1165
1213
  const { input = true, output = true, tools = output } = options;
1166
1214
  const properties = {};
1167
1215
  if (input) {
1168
- properties[_chunk5WBPX342cjs.MUTE_INPUT] = "true";
1216
+ properties[_chunkGMZQ6N77cjs.MUTE_INPUT] = "true";
1169
1217
  }
1170
1218
  if (output) {
1171
- properties[_chunk5WBPX342cjs.MUTE_OUTPUT] = "true";
1219
+ properties[_chunkGMZQ6N77cjs.MUTE_OUTPUT] = "true";
1172
1220
  }
1173
1221
  if (tools !== output) {
1174
- properties[_chunk5WBPX342cjs.MUTE_TOOLS] = String(tools);
1222
+ properties[_chunkGMZQ6N77cjs.MUTE_TOOLS] = String(tools);
1175
1223
  } else {
1176
1224
  const inherited = inheritedMuteTools();
1177
1225
  if (tools && inherited === "false") {
1178
- properties[_chunk5WBPX342cjs.MUTE_TOOLS] = "true";
1226
+ properties[_chunkGMZQ6N77cjs.MUTE_TOOLS] = "true";
1179
1227
  } else if (options.tools === false && inherited === "true") {
1180
- properties[_chunk5WBPX342cjs.MUTE_TOOLS] = "false";
1228
+ properties[_chunkGMZQ6N77cjs.MUTE_TOOLS] = "false";
1181
1229
  }
1182
1230
  }
1183
1231
  return properties;
@@ -1189,11 +1237,11 @@ function withMute(options, fn, thisArg) {
1189
1237
  return withProperties(muteProperties(options), fn, thisArg);
1190
1238
  }
1191
1239
  function withSessionId(sessionId, fn, thisArg, extraProperties) {
1192
- const properties = { [_chunk5WBPX342cjs.SESSION_ID]: sessionId, ...extraProperties };
1240
+ const properties = { [_chunkGMZQ6N77cjs.SESSION_ID]: sessionId, ...extraProperties };
1193
1241
  return withProperties(properties, fn, thisArg);
1194
1242
  }
1195
1243
  function callWithSessionId(sessionId, fn, thisArg, ...args) {
1196
- return callWithProperties({ [_chunk5WBPX342cjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
1244
+ return callWithProperties({ [_chunkGMZQ6N77cjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
1197
1245
  }
1198
1246
  var Session = (_class2 = class {
1199
1247
 
@@ -1221,8 +1269,8 @@ var Session = (_class2 = class {
1221
1269
  setInput(text, context7) {
1222
1270
  this.inputs.push(text);
1223
1271
  this.inputContexts.push(_nullishCoalesce(context7, () => ( {})));
1224
- this.span.setAttribute(_chunk5WBPX342cjs.SESSION_INPUT, JSON.stringify(this.inputs));
1225
- this.span.setAttribute(_chunk5WBPX342cjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
1272
+ this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_INPUT, JSON.stringify(this.inputs));
1273
+ this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
1226
1274
  }
1227
1275
  /**
1228
1276
  * Append an assistant turn to session output tracking.
@@ -1237,8 +1285,8 @@ var Session = (_class2 = class {
1237
1285
  setOutput(text, context7) {
1238
1286
  this.outputs.push(text);
1239
1287
  this.outputContexts.push(_nullishCoalesce(context7, () => ( {})));
1240
- this.span.setAttribute(_chunk5WBPX342cjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
1241
- this.span.setAttribute(_chunk5WBPX342cjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
1288
+ this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
1289
+ this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
1242
1290
  }
1243
1291
  /**
1244
1292
  * Set the session title on the span.
@@ -1246,7 +1294,7 @@ var Session = (_class2 = class {
1246
1294
  * @param title - The generated title string
1247
1295
  */
1248
1296
  setTitle(title) {
1249
- this.span.setAttribute(_chunk5WBPX342cjs.SESSION_TITLE, title);
1297
+ this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_TITLE, title);
1250
1298
  }
1251
1299
  /**
1252
1300
  * Update custom properties on the session span.
@@ -1256,7 +1304,7 @@ var Session = (_class2 = class {
1256
1304
  */
1257
1305
  updateProperties(properties) {
1258
1306
  for (const [key, value] of Object.entries(properties)) {
1259
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
1307
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
1260
1308
  }
1261
1309
  }
1262
1310
  /**
@@ -1268,21 +1316,21 @@ var Session = (_class2 = class {
1268
1316
  setUser(user) {
1269
1317
  if (user.traits) {
1270
1318
  for (const [key, value] of Object.entries(user.traits)) {
1271
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.user.${key}`, value);
1319
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.user.${key}`, value);
1272
1320
  }
1273
1321
  }
1274
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_ID}`, user.id);
1322
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_ID}`, user.id);
1275
1323
  if (user.email !== void 0) {
1276
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_EMAIL}`, user.email);
1324
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_EMAIL}`, user.email);
1277
1325
  }
1278
1326
  if (user.name !== void 0) {
1279
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_NAME}`, user.name);
1327
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_NAME}`, user.name);
1280
1328
  }
1281
1329
  if (user.role !== void 0) {
1282
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_ROLE}`, user.role);
1330
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_ROLE}`, user.role);
1283
1331
  }
1284
1332
  if (user.plan !== void 0) {
1285
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_PLAN}`, user.plan);
1333
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_PLAN}`, user.plan);
1286
1334
  }
1287
1335
  }
1288
1336
  /**
@@ -1294,18 +1342,18 @@ var Session = (_class2 = class {
1294
1342
  setOrganization(org) {
1295
1343
  if (org.traits) {
1296
1344
  for (const [key, value] of Object.entries(org.traits)) {
1297
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.organization.${key}`, value);
1345
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.organization.${key}`, value);
1298
1346
  }
1299
1347
  }
1300
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_ID}`, org.id);
1348
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_ID}`, org.id);
1301
1349
  if (org.name !== void 0) {
1302
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_NAME}`, org.name);
1350
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_NAME}`, org.name);
1303
1351
  }
1304
1352
  if (org.plan !== void 0) {
1305
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_PLAN}`, org.plan);
1353
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_PLAN}`, org.plan);
1306
1354
  }
1307
1355
  if (org.domain !== void 0) {
1308
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_DOMAIN}`, org.domain);
1356
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN}`, org.domain);
1309
1357
  }
1310
1358
  }
1311
1359
  /**
@@ -1335,30 +1383,30 @@ var SessionTitle = class {
1335
1383
  * @param title - The generated title string
1336
1384
  */
1337
1385
  setTitle(title) {
1338
- this.span.setAttribute(_chunk5WBPX342cjs.SESSION_TITLE, title);
1386
+ this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_TITLE, title);
1339
1387
  }
1340
1388
  };
1341
1389
  function getActiveSession() {
1342
- return _api.context.active().getValue(_chunk5WBPX342cjs.SESSION_OBJECT_CONTEXT_KEY);
1390
+ return _api.context.active().getValue(_chunkGMZQ6N77cjs.SESSION_OBJECT_CONTEXT_KEY);
1343
1391
  }
1344
1392
  function resolveSessionIdFromContext() {
1345
1393
  const active = getActiveSession();
1346
1394
  if (active) {
1347
1395
  return active.sessionId;
1348
1396
  }
1349
- const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
1350
- return _optionalChain([props, 'optionalAccess', _60 => _60[_chunk5WBPX342cjs.SESSION_ID]]);
1397
+ const props = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1398
+ return _optionalChain([props, 'optionalAccess', _60 => _60[_chunkGMZQ6N77cjs.SESSION_ID]]);
1351
1399
  }
1352
1400
  function resolveMessageIdFromContext() {
1353
- const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
1354
- return _optionalChain([props, 'optionalAccess', _61 => _61[_chunk5WBPX342cjs.MESSAGE_ID]]);
1401
+ const props = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1402
+ return _optionalChain([props, 'optionalAccess', _61 => _61[_chunkGMZQ6N77cjs.MESSAGE_ID]]);
1355
1403
  }
1356
1404
  function emitExternalLink(sessionId, url, title, linkType) {
1357
1405
  try {
1358
- emitEventWithSessionId(sessionId, _chunk5WBPX342cjs.EXTERNAL_LINK_EVENT_NAME, {
1359
- [_chunk5WBPX342cjs.EXTERNAL_LINK_URL]: url,
1360
- [_chunk5WBPX342cjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
1361
- [_chunk5WBPX342cjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
1406
+ emitEventWithSessionId(sessionId, _chunkGMZQ6N77cjs.EXTERNAL_LINK_EVENT_NAME, {
1407
+ [_chunkGMZQ6N77cjs.EXTERNAL_LINK_URL]: url,
1408
+ [_chunkGMZQ6N77cjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
1409
+ [_chunkGMZQ6N77cjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
1362
1410
  });
1363
1411
  } catch (error) {
1364
1412
  _chunkWC573FCIcjs.logger.warn("addExternalLink: failed to emit external link", error);
@@ -1375,22 +1423,22 @@ function addExternalLink(url, options) {
1375
1423
  emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _63 => _63.title]), _optionalChain([options, 'optionalAccess', _64 => _64.linkType]));
1376
1424
  }
1377
1425
  function recordFeedback(type, options) {
1378
- const eventAttributes = { [_chunk5WBPX342cjs.FEEDBACK_TYPE]: type };
1426
+ const eventAttributes = { [_chunkGMZQ6N77cjs.FEEDBACK_TYPE]: type };
1379
1427
  if (_optionalChain([options, 'optionalAccess', _65 => _65.score]) !== void 0) {
1380
- eventAttributes[_chunk5WBPX342cjs.FEEDBACK_SCORE] = options.score;
1428
+ eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_SCORE] = options.score;
1381
1429
  }
1382
1430
  if (_optionalChain([options, 'optionalAccess', _66 => _66.reason]) !== void 0) {
1383
- eventAttributes[_chunk5WBPX342cjs.FEEDBACK_REASON] = options.reason;
1431
+ eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_REASON] = options.reason;
1384
1432
  }
1385
1433
  if (_optionalChain([options, 'optionalAccess', _67 => _67.comment]) !== void 0) {
1386
- eventAttributes[_chunk5WBPX342cjs.FEEDBACK_COMMENT] = options.comment;
1434
+ eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_COMMENT] = options.comment;
1387
1435
  }
1388
1436
  if (_optionalChain([options, 'optionalAccess', _68 => _68.source]) !== void 0) {
1389
- eventAttributes[_chunk5WBPX342cjs.FEEDBACK_SOURCE] = options.source;
1437
+ eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_SOURCE] = options.source;
1390
1438
  }
1391
1439
  if (_optionalChain([options, 'optionalAccess', _69 => _69.attributes])) {
1392
1440
  for (const [key, value] of Object.entries(options.attributes)) {
1393
- const k = `${_chunk5WBPX342cjs.FEEDBACK_ATTR_PREFIX}${key}`;
1441
+ const k = `${_chunkGMZQ6N77cjs.FEEDBACK_ATTR_PREFIX}${key}`;
1394
1442
  if (eventAttributes[k] === void 0) {
1395
1443
  eventAttributes[k] = value;
1396
1444
  }
@@ -1405,16 +1453,16 @@ function recordFeedback(type, options) {
1405
1453
  }
1406
1454
  const anchor = {};
1407
1455
  if (messageId !== void 0) {
1408
- anchor[_chunk5WBPX342cjs.MESSAGE_ID] = messageId;
1456
+ anchor[_chunkGMZQ6N77cjs.MESSAGE_ID] = messageId;
1409
1457
  }
1410
1458
  if (sessionId !== void 0) {
1411
- anchor[_chunk5WBPX342cjs.SESSION_ID] = sessionId;
1459
+ anchor[_chunkGMZQ6N77cjs.SESSION_ID] = sessionId;
1412
1460
  }
1413
1461
  try {
1414
1462
  if (Object.keys(anchor).length === 0) {
1415
- emitEvent(_chunk5WBPX342cjs.FEEDBACK_EVENT_NAME, eventAttributes);
1463
+ emitEvent(_chunkGMZQ6N77cjs.FEEDBACK_EVENT_NAME, eventAttributes);
1416
1464
  } else {
1417
- callWithProperties(anchor, () => emitEvent(_chunk5WBPX342cjs.FEEDBACK_EVENT_NAME, eventAttributes));
1465
+ callWithProperties(anchor, () => emitEvent(_chunkGMZQ6N77cjs.FEEDBACK_EVENT_NAME, eventAttributes));
1418
1466
  }
1419
1467
  } catch (error) {
1420
1468
  _chunkWC573FCIcjs.logger.warn("recordFeedback: failed to emit feedback event", error);
@@ -1439,7 +1487,7 @@ function recordMetricImpl(options) {
1439
1487
  );
1440
1488
  return;
1441
1489
  }
1442
- if (_chunk5WBPX342cjs.RESERVED_METRIC_NAMES.has(name)) {
1490
+ if (_chunkGMZQ6N77cjs.RESERVED_METRIC_NAMES.has(name)) {
1443
1491
  _chunkWC573FCIcjs.logger.warn(
1444
1492
  `recordMetric called with the reserved name ${JSON.stringify(name)}; metric dropped. Brizz computes this metric itself \u2014 pick a different name.`
1445
1493
  );
@@ -1457,18 +1505,25 @@ function recordMetricImpl(options) {
1457
1505
  );
1458
1506
  return;
1459
1507
  }
1508
+ if (options.serviceName !== void 0) {
1509
+ const problem = serviceNameProblem(options.serviceName);
1510
+ if (problem !== void 0) {
1511
+ _chunkWC573FCIcjs.logger.warn(`recordMetric(${name}) service name ${problem}; metric dropped.`);
1512
+ return;
1513
+ }
1514
+ }
1460
1515
  const eventAttributes = {
1461
- [_chunk5WBPX342cjs.METRIC_NAME]: name,
1462
- [_chunk5WBPX342cjs.METRIC_VALUE]: numericValue
1516
+ [_chunkGMZQ6N77cjs.METRIC_NAME]: name,
1517
+ [_chunkGMZQ6N77cjs.METRIC_VALUE]: numericValue
1463
1518
  };
1464
1519
  if (options.unit !== void 0) {
1465
- eventAttributes[_chunk5WBPX342cjs.METRIC_UNIT] = options.unit;
1520
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_UNIT] = options.unit;
1466
1521
  }
1467
1522
  if (options.minValue !== void 0) {
1468
- eventAttributes[_chunk5WBPX342cjs.METRIC_MIN] = options.minValue;
1523
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_MIN] = options.minValue;
1469
1524
  }
1470
1525
  if (options.maxValue !== void 0) {
1471
- eventAttributes[_chunk5WBPX342cjs.METRIC_MAX] = options.maxValue;
1526
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_MAX] = options.maxValue;
1472
1527
  }
1473
1528
  if (options.comment !== void 0) {
1474
1529
  let comment = options.comment;
@@ -1478,21 +1533,21 @@ function recordMetricImpl(options) {
1478
1533
  );
1479
1534
  comment = comment.slice(0, METRIC_COMMENT_MAX_LEN);
1480
1535
  }
1481
- eventAttributes[_chunk5WBPX342cjs.METRIC_COMMENT] = comment;
1536
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_COMMENT] = comment;
1482
1537
  }
1483
1538
  if (options.polarity !== void 0) {
1484
1539
  const polarity = options.polarity;
1485
- if (polarity === _chunk5WBPX342cjs.METRIC_POLARITY_POSITIVE || polarity === _chunk5WBPX342cjs.METRIC_POLARITY_NEGATIVE) {
1486
- eventAttributes[_chunk5WBPX342cjs.METRIC_POLARITY] = polarity;
1540
+ if (polarity === _chunkGMZQ6N77cjs.METRIC_POLARITY_POSITIVE || polarity === _chunkGMZQ6N77cjs.METRIC_POLARITY_NEGATIVE) {
1541
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_POLARITY] = polarity;
1487
1542
  } else {
1488
1543
  _chunkWC573FCIcjs.logger.warn(
1489
- `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.`
1544
+ `recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${_chunkGMZQ6N77cjs.METRIC_POLARITY_POSITIVE}' or '${_chunkGMZQ6N77cjs.METRIC_POLARITY_NEGATIVE}'. Emitting the metric without it.`
1490
1545
  );
1491
1546
  }
1492
1547
  }
1493
1548
  if (options.timestamp !== void 0) {
1494
1549
  if (Number.isFinite(options.timestamp.getTime())) {
1495
- eventAttributes[_chunk5WBPX342cjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
1550
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
1496
1551
  } else {
1497
1552
  _chunkWC573FCIcjs.logger.warn(
1498
1553
  `recordMetric(${name}) called with an invalid timestamp; emitting the metric without it.`
@@ -1522,21 +1577,37 @@ function recordMetricImpl(options) {
1522
1577
  );
1523
1578
  text = text.slice(0, METRIC_ATTRIBUTE_VALUE_MAX_LEN);
1524
1579
  }
1525
- eventAttributes[`${_chunk5WBPX342cjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
1580
+ eventAttributes[`${_chunkGMZQ6N77cjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
1526
1581
  accepted += 1;
1527
1582
  }
1528
1583
  }
1529
- const sessionId = _nullishCoalesce(options.sessionId, () => ( resolveSessionIdFromContext()));
1530
- if (sessionId === void 0) {
1584
+ const traceId = typeof options.traceId === "string" && options.traceId !== "" ? options.traceId : void 0;
1585
+ if (traceId !== void 0) {
1586
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_TRACE_ID] = traceId;
1587
+ }
1588
+ const sessionId = _nullishCoalesce(options.sessionId, () => ( (traceId === void 0 ? resolveSessionIdFromContext() : void 0)));
1589
+ if (sessionId === void 0 && traceId === void 0) {
1531
1590
  _chunkWC573FCIcjs.logger.warn(
1532
- `recordMetric(${name}) called with no resolvable session id; the metric cannot be attributed to a conversation and is dropped. Pass options.sessionId or call inside a startSession/callWithSessionId scope.`
1591
+ `recordMetric(${name}) called with no resolvable session id or trace id; the metric cannot be attributed to a conversation and is dropped. Pass options.sessionId or options.traceId, or call inside a startSession/callWithSessionId scope.`
1533
1592
  );
1534
1593
  return;
1535
1594
  }
1595
+ const base = _api.context.active();
1596
+ const ambient = base.getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1597
+ const properties = { ...ambient };
1598
+ if (sessionId === void 0) {
1599
+ delete properties[_chunkGMZQ6N77cjs.SESSION_ID];
1600
+ delete properties[_chunkGMZQ6N77cjs.MESSAGE_ID];
1601
+ } else {
1602
+ properties[_chunkGMZQ6N77cjs.SESSION_ID] = sessionId;
1603
+ }
1604
+ if (options.serviceName !== void 0) {
1605
+ properties[_chunkGMZQ6N77cjs.SERVICE_NAME] = options.serviceName;
1606
+ }
1536
1607
  try {
1537
- callWithProperties(
1538
- { [_chunk5WBPX342cjs.SESSION_ID]: sessionId },
1539
- () => emitEvent(_chunk5WBPX342cjs.METRIC_EVENT_NAME, eventAttributes)
1608
+ _api.context.with(
1609
+ base.setValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY, properties),
1610
+ () => emitEvent(_chunkGMZQ6N77cjs.METRIC_EVENT_NAME, eventAttributes)
1540
1611
  );
1541
1612
  } catch (error) {
1542
1613
  _chunkWC573FCIcjs.logger.warn("recordMetric: failed to emit metric event", error);
@@ -1544,19 +1615,19 @@ function recordMetricImpl(options) {
1544
1615
  }
1545
1616
  function startSession(sessionId, callback, extraProperties, options) {
1546
1617
  const isTitle = _optionalChain([options, 'optionalAccess', _73 => _73.mode]) === "title";
1547
- const spanName = isTitle ? _chunk5WBPX342cjs.SESSION_TITLE_SPAN_NAME : _chunk5WBPX342cjs.SESSION_SPAN_NAME;
1618
+ const spanName = isTitle ? _chunkGMZQ6N77cjs.SESSION_TITLE_SPAN_NAME : _chunkGMZQ6N77cjs.SESSION_SPAN_NAME;
1548
1619
  const tracer = _api.trace.getTracer("@brizz/sdk");
1549
1620
  return tracer.startActiveSpan(spanName, (span) => {
1550
- span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.SESSION_ID}`, sessionId);
1621
+ span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.SESSION_ID}`, sessionId);
1551
1622
  if (extraProperties) {
1552
1623
  for (const [key, value] of Object.entries(extraProperties)) {
1553
- span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
1624
+ span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
1554
1625
  }
1555
1626
  }
1556
1627
  const session = new Session(sessionId, span);
1557
- const contextProperties = { [_chunk5WBPX342cjs.SESSION_ID]: sessionId };
1628
+ const contextProperties = { [_chunkGMZQ6N77cjs.SESSION_ID]: sessionId };
1558
1629
  if (isTitle) {
1559
- contextProperties[_chunk5WBPX342cjs.SESSION_TITLE_GENERATION] = "true";
1630
+ contextProperties[_chunkGMZQ6N77cjs.SESSION_TITLE_GENERATION] = "true";
1560
1631
  }
1561
1632
  if (extraProperties) {
1562
1633
  for (const [key, value] of Object.entries(extraProperties)) {
@@ -1564,7 +1635,7 @@ function startSession(sessionId, callback, extraProperties, options) {
1564
1635
  }
1565
1636
  }
1566
1637
  return callWithProperties(contextProperties, () => {
1567
- const sessionCtx = _api.context.active().setValue(_chunk5WBPX342cjs.SESSION_OBJECT_CONTEXT_KEY, session);
1638
+ const sessionCtx = _api.context.active().setValue(_chunkGMZQ6N77cjs.SESSION_OBJECT_CONTEXT_KEY, session);
1568
1639
  return _api.context.with(sessionCtx, () => {
1569
1640
  try {
1570
1641
  const result = callback(session);
@@ -1594,14 +1665,14 @@ function startSession(sessionId, callback, extraProperties, options) {
1594
1665
  function startSessionTitle(callback, options) {
1595
1666
  const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _74 => _74.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _75 => _75(), 'optionalAccess', _76 => _76.sessionId])));
1596
1667
  const tracer = _api.trace.getTracer("@brizz/sdk");
1597
- return tracer.startActiveSpan(_chunk5WBPX342cjs.SESSION_TITLE_SPAN_NAME, (span) => {
1668
+ return tracer.startActiveSpan(_chunkGMZQ6N77cjs.SESSION_TITLE_SPAN_NAME, (span) => {
1598
1669
  if (resolvedSessionId) {
1599
- span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.SESSION_ID}`, resolvedSessionId);
1670
+ span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.SESSION_ID}`, resolvedSessionId);
1600
1671
  }
1601
1672
  const sessionTitle = new SessionTitle(span);
1602
- const properties = { [_chunk5WBPX342cjs.SESSION_TITLE_GENERATION]: "true" };
1673
+ const properties = { [_chunkGMZQ6N77cjs.SESSION_TITLE_GENERATION]: "true" };
1603
1674
  if (resolvedSessionId) {
1604
- properties[_chunk5WBPX342cjs.SESSION_ID] = resolvedSessionId;
1675
+ properties[_chunkGMZQ6N77cjs.SESSION_ID] = resolvedSessionId;
1605
1676
  }
1606
1677
  return callWithProperties(properties, () => {
1607
1678
  try {
@@ -2068,10 +2139,10 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
2068
2139
  if (maskingConfig) {
2069
2140
  maskLog(logRecord, maskingConfig);
2070
2141
  }
2071
- const associationProperties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
2142
+ const associationProperties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
2072
2143
  if (associationProperties) {
2073
2144
  for (const [key, value] of Object.entries(associationProperties)) {
2074
- logRecord.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
2145
+ logRecord.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
2075
2146
  }
2076
2147
  }
2077
2148
  super.onEmit(logRecord);
@@ -2088,10 +2159,10 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
2088
2159
  if (maskingConfig) {
2089
2160
  maskLog(logRecord, maskingConfig);
2090
2161
  }
2091
- const associationProperties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
2162
+ const associationProperties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
2092
2163
  if (associationProperties) {
2093
2164
  for (const [key, value] of Object.entries(associationProperties)) {
2094
- logRecord.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
2165
+ logRecord.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
2095
2166
  }
2096
2167
  }
2097
2168
  super.onEmit(logRecord);
@@ -2118,7 +2189,7 @@ function maskLog(logRecord, config) {
2118
2189
  newAttributes[key] = value;
2119
2190
  }
2120
2191
  for (const [key, value] of Object.entries(logRecord.attributes)) {
2121
- if (key.startsWith(_chunk5WBPX342cjs.INTERNAL_EVENT_PREFIX)) {
2192
+ if (key.startsWith(_chunkGMZQ6N77cjs.INTERNAL_EVENT_PREFIX)) {
2122
2193
  newAttributes[key] = value;
2123
2194
  }
2124
2195
  }
@@ -2161,7 +2232,16 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
2161
2232
  createLogExporter(config, serviceName) {
2162
2233
  if (config.customLogExporter) {
2163
2234
  _chunkWC573FCIcjs.logger.debug("Using custom log exporter");
2164
- return config.customLogExporter;
2235
+ if (serviceName === config.appName) {
2236
+ return config.customLogExporter;
2237
+ }
2238
+ const shared = config.customLogExporter;
2239
+ return {
2240
+ export: (logs, resultCallback) => shared.export(logs, resultCallback),
2241
+ forceFlush: async () => shared.forceFlush(),
2242
+ shutdown: async () => {
2243
+ }
2244
+ };
2165
2245
  }
2166
2246
  const logsUrl = config.baseUrl.replace(/\/$/, "") + "/v1/logs";
2167
2247
  _chunkWC573FCIcjs.logger.debug("Initializing default OTLP log exporter", { url: logsUrl, serviceName });
@@ -2183,7 +2263,7 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
2183
2263
  const resourceAttributes = {
2184
2264
  ...config.resourceAttributes,
2185
2265
  "service.name": serviceName,
2186
- [BRIZZ_SDK_VERSION]: _chunkEWT4TUB7cjs.getSDKVersion.call(void 0, ),
2266
+ [BRIZZ_SDK_VERSION]: _chunkVAUO47L3cjs.getSDKVersion.call(void 0, ),
2187
2267
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2188
2268
  };
2189
2269
  if (config.environment) {
@@ -2287,12 +2367,12 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
2287
2367
  */
2288
2368
  async shutdown() {
2289
2369
  _chunkWC573FCIcjs.logger.debug("Shutting down logging module");
2370
+ await Promise.all([...this.scopedProviders.values()].map(async (p) => p.shutdown()));
2371
+ this.scopedProviders.clear();
2290
2372
  if (this.loggerProvider) {
2291
2373
  await this.loggerProvider.shutdown();
2292
2374
  this.loggerProvider = null;
2293
2375
  }
2294
- await Promise.all([...this.scopedProviders.values()].map(async (p) => p.shutdown()));
2295
- this.scopedProviders.clear();
2296
2376
  this.config = null;
2297
2377
  if (_LoggingModule.instance === this) {
2298
2378
  _LoggingModule.instance = null;
@@ -2432,7 +2512,7 @@ var BrizzSpanExporter = (_class5 = class {
2432
2512
  const resourceAttrs = {
2433
2513
  ...config.resourceAttributes,
2434
2514
  "service.name": config.appName,
2435
- [BRIZZ_SDK_VERSION]: _chunkEWT4TUB7cjs.getSDKVersion.call(void 0, ),
2515
+ [BRIZZ_SDK_VERSION]: _chunkVAUO47L3cjs.getSDKVersion.call(void 0, ),
2436
2516
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2437
2517
  };
2438
2518
  if (config.environment) {
@@ -2446,7 +2526,7 @@ var BrizzSpanExporter = (_class5 = class {
2446
2526
  }
2447
2527
  /** The service a span reports under: its scoped override, else the configured appName. */
2448
2528
  _serviceNameOf(span) {
2449
- const value = span.attributes[_chunk5WBPX342cjs.SERVICE_NAME_ATTRIBUTE];
2529
+ const value = span.attributes[_chunkGMZQ6N77cjs.SERVICE_NAME_ATTRIBUTE];
2450
2530
  return typeof value === "string" && value !== "" ? value : this._defaultServiceName;
2451
2531
  }
2452
2532
  _resourceFor(serviceName) {
@@ -2572,10 +2652,10 @@ var BrizzSpanExporter = (_class5 = class {
2572
2652
 
2573
2653
  var _sdktracebase = require('@opentelemetry/sdk-trace-base');
2574
2654
  function applyContextAttributes(span) {
2575
- const sessionProperties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
2655
+ const sessionProperties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
2576
2656
  if (sessionProperties) {
2577
2657
  for (const [key, value] of Object.entries(sessionProperties)) {
2578
- span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
2658
+ span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
2579
2659
  }
2580
2660
  }
2581
2661
  }
@@ -2774,7 +2854,7 @@ function newInstanceId() {
2774
2854
  return _crypto.randomUUID.call(void 0, ).replaceAll("-", "").slice(0, 8);
2775
2855
  }
2776
2856
  function activeProperties() {
2777
- return _nullishCoalesce(_api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY), () => ( {}));
2857
+ return _nullishCoalesce(_api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY), () => ( {}));
2778
2858
  }
2779
2859
  function encodeToken(agent) {
2780
2860
  const payload = {
@@ -2800,7 +2880,7 @@ function agentHandle(id, parentId, name) {
2800
2880
  parentId,
2801
2881
  name,
2802
2882
  traceparent: currentTraceparent(),
2803
- sessionId: _nullishCoalesce(activeProperties()[_chunk5WBPX342cjs.SESSION_ID], () => ( ""))
2883
+ sessionId: _nullishCoalesce(activeProperties()[_chunkGMZQ6N77cjs.SESSION_ID], () => ( ""))
2804
2884
  };
2805
2885
  return {
2806
2886
  ...opened,
@@ -2836,7 +2916,7 @@ function resolveAgent(agent) {
2836
2916
  let parentContext = _api.context.active();
2837
2917
  if (options.token === void 0) {
2838
2918
  id = options.id || newInstanceId();
2839
- parentId = options.parentId || activeProperties()[_chunk5WBPX342cjs.AGENT_ID] || "";
2919
+ parentId = options.parentId || activeProperties()[_chunkGMZQ6N77cjs.AGENT_ID] || "";
2840
2920
  name = _nullishCoalesce(options.name, () => ( ""));
2841
2921
  } else {
2842
2922
  const decoded = decodeToken(options.token);
@@ -2855,12 +2935,12 @@ function resolveAgent(agent) {
2855
2935
  }
2856
2936
  }
2857
2937
  }
2858
- const properties = { [_chunk5WBPX342cjs.AGENT_ID]: id, [_chunk5WBPX342cjs.AGENT_NAME]: name };
2938
+ const properties = { [_chunkGMZQ6N77cjs.AGENT_ID]: id, [_chunkGMZQ6N77cjs.AGENT_NAME]: name };
2859
2939
  if (parentId) {
2860
- properties[_chunk5WBPX342cjs.AGENT_PARENT_ID] = parentId;
2940
+ properties[_chunkGMZQ6N77cjs.AGENT_PARENT_ID] = parentId;
2861
2941
  }
2862
2942
  if (sessionId) {
2863
- properties[_chunk5WBPX342cjs.SESSION_ID] = sessionId;
2943
+ properties[_chunkGMZQ6N77cjs.SESSION_ID] = sessionId;
2864
2944
  }
2865
2945
  return { id, parentId, name, properties, parentContext };
2866
2946
  }
@@ -2923,8 +3003,9 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2923
3003
  */
2924
3004
  setupInstrumentation(options) {
2925
3005
  const registry = InstrumentationRegistry.getInstance();
2926
- _chunkEWT4TUB7cjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
3006
+ _chunkVAUO47L3cjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
2927
3007
  patchInstalledCallbackManager();
3008
+ patchInstalledLangGraph();
2928
3009
  if (options.instrumentModules && Object.keys(options.instrumentModules).length > 0) {
2929
3010
  registry.setManualModules(options.instrumentModules);
2930
3011
  }
@@ -2947,7 +3028,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2947
3028
  const resourceAttributes = {
2948
3029
  ...resolvedConfig.resourceAttributes,
2949
3030
  "service.name": resolvedConfig.appName,
2950
- [BRIZZ_SDK_VERSION]: _chunkEWT4TUB7cjs.getSDKVersion.call(void 0, ),
3031
+ [BRIZZ_SDK_VERSION]: _chunkVAUO47L3cjs.getSDKVersion.call(void 0, ),
2951
3032
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2952
3033
  };
2953
3034
  if (resolvedConfig.environment) {
@@ -2959,7 +3040,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2959
3040
  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));
2960
3041
  this._tracerProvider = new (0, _sdktracenode.NodeTracerProvider)({
2961
3042
  resource,
2962
- spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunk3IGBYXLRcjs.InterruptPropagator)(), getSpanProcessor()]
3043
+ spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkELLCNMLIcjs.InterruptPropagator)(), getSpanProcessor()]
2963
3044
  });
2964
3045
  this._tracerProvider.register();
2965
3046
  this._meterProvider = new (0, _sdkmetrics.MeterProvider)({ resource, readers: [getMetricsReader()] });