@brizz/sdk 0.1.37 → 0.1.40

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 (102) hide show
  1. package/README.md +28 -125
  2. package/dist/{chunk-OR3YPY4I.js → chunk-BGLKBQ6N.js} +1 -1
  3. package/dist/{chunk-2DSTZTDA.cjs → chunk-RNU3DOSR.cjs} +1 -1
  4. package/dist/index.cjs +2263 -13
  5. package/dist/index.js +2298 -48
  6. package/dist/{mcp-NC5OXRT4.cjs → mcp-64ZNSCIR.cjs} +53 -25
  7. package/dist/{mcp-7Y3O5QSS.js → mcp-HBOMHU67.js} +33 -5
  8. package/dist/types/cjs/eve.d.ts +2 -0
  9. package/dist/types/cjs/google-genai.d.ts +1 -0
  10. package/dist/types/cjs/index.d.ts +15 -0
  11. package/dist/types/cjs/internal/config.d.ts +19 -0
  12. package/dist/types/cjs/internal/constants.d.ts +3 -0
  13. package/dist/types/cjs/internal/dsn.d.ts +13 -0
  14. package/dist/types/cjs/internal/instrumentation/auto-init.d.ts +8 -0
  15. package/dist/types/cjs/internal/instrumentation/google-genai.d.ts +13 -0
  16. package/dist/types/cjs/internal/instrumentation/index.d.ts +2 -0
  17. package/dist/types/cjs/internal/instrumentation/mcp/index.d.ts +2 -0
  18. package/dist/types/cjs/internal/instrumentation/mcp/instrumentation.d.ts +15 -0
  19. package/dist/types/cjs/internal/instrumentation/mcp/patches/attributes.d.ts +9 -0
  20. package/dist/types/cjs/internal/instrumentation/mcp/patches/protocol.d.ts +2 -0
  21. package/dist/types/cjs/internal/instrumentation/mcp/schemas.d.ts +2 -0
  22. package/dist/types/cjs/internal/instrumentation/mcp/semantic-conventions.d.ts +37 -0
  23. package/dist/types/cjs/internal/instrumentation/mcp/session.d.ts +7 -0
  24. package/dist/types/cjs/internal/instrumentation/mcp/types.d.ts +47 -0
  25. package/dist/types/cjs/internal/instrumentation/mcp/version.d.ts +2 -0
  26. package/dist/types/cjs/internal/instrumentation/registry.d.ts +29 -0
  27. package/dist/types/cjs/internal/instrumentation/vercel-ai/interrupt.d.ts +11 -0
  28. package/dist/types/cjs/internal/log/index.d.ts +1 -0
  29. package/dist/types/cjs/internal/log/logging.d.ts +21 -0
  30. package/dist/types/cjs/internal/log/processors/log-processor.d.ts +16 -0
  31. package/dist/types/cjs/internal/logger.d.ts +23 -0
  32. package/dist/types/cjs/internal/masking/index.d.ts +3 -0
  33. package/dist/types/cjs/internal/masking/patterns.d.ts +2 -0
  34. package/dist/types/cjs/internal/masking/types.d.ts +32 -0
  35. package/dist/types/cjs/internal/masking/utils.d.ts +5 -0
  36. package/dist/types/cjs/internal/metric/index.d.ts +1 -0
  37. package/dist/types/cjs/internal/metric/metrics.d.ts +17 -0
  38. package/dist/types/cjs/internal/sdk.d.ts +42 -0
  39. package/dist/types/cjs/internal/semantic-conventions.d.ts +54 -0
  40. package/dist/types/cjs/internal/trace/exporters/eve-trace-exporter.d.ts +18 -0
  41. package/dist/types/cjs/internal/trace/exporters/span-exporter.d.ts +12 -0
  42. package/dist/types/cjs/internal/trace/index.d.ts +4 -0
  43. package/dist/types/cjs/internal/trace/processors/eve-session-processor.d.ts +2 -0
  44. package/dist/types/cjs/internal/trace/processors/span-processor.d.ts +18 -0
  45. package/dist/types/cjs/internal/trace/session.d.ts +136 -0
  46. package/dist/types/cjs/internal/trace/tracing.d.ts +17 -0
  47. package/dist/types/cjs/internal/version.d.ts +1 -0
  48. package/dist/types/cjs/package.json +3 -0
  49. package/dist/types/esm/eve.d.ts +2 -0
  50. package/dist/types/esm/google-genai.d.ts +1 -0
  51. package/dist/types/esm/index.d.ts +15 -0
  52. package/dist/types/esm/internal/config.d.ts +19 -0
  53. package/dist/types/esm/internal/constants.d.ts +3 -0
  54. package/dist/types/esm/internal/dsn.d.ts +13 -0
  55. package/dist/types/esm/internal/instrumentation/auto-init.d.ts +8 -0
  56. package/dist/types/esm/internal/instrumentation/google-genai.d.ts +13 -0
  57. package/dist/types/esm/internal/instrumentation/index.d.ts +2 -0
  58. package/dist/types/esm/internal/instrumentation/mcp/index.d.ts +2 -0
  59. package/dist/types/esm/internal/instrumentation/mcp/instrumentation.d.ts +15 -0
  60. package/dist/types/esm/internal/instrumentation/mcp/patches/attributes.d.ts +9 -0
  61. package/dist/types/esm/internal/instrumentation/mcp/patches/protocol.d.ts +2 -0
  62. package/dist/types/esm/internal/instrumentation/mcp/schemas.d.ts +2 -0
  63. package/dist/types/esm/internal/instrumentation/mcp/semantic-conventions.d.ts +37 -0
  64. package/dist/types/esm/internal/instrumentation/mcp/session.d.ts +7 -0
  65. package/dist/types/esm/internal/instrumentation/mcp/types.d.ts +47 -0
  66. package/dist/types/esm/internal/instrumentation/mcp/version.d.ts +2 -0
  67. package/dist/types/esm/internal/instrumentation/registry.d.ts +29 -0
  68. package/dist/types/esm/internal/instrumentation/vercel-ai/interrupt.d.ts +11 -0
  69. package/dist/types/esm/internal/log/index.d.ts +1 -0
  70. package/dist/types/esm/internal/log/logging.d.ts +21 -0
  71. package/dist/types/esm/internal/log/processors/log-processor.d.ts +16 -0
  72. package/dist/types/esm/internal/logger.d.ts +23 -0
  73. package/dist/types/esm/internal/masking/index.d.ts +3 -0
  74. package/dist/types/esm/internal/masking/patterns.d.ts +2 -0
  75. package/dist/types/esm/internal/masking/types.d.ts +32 -0
  76. package/dist/types/esm/internal/masking/utils.d.ts +5 -0
  77. package/dist/types/esm/internal/metric/index.d.ts +1 -0
  78. package/dist/types/esm/internal/metric/metrics.d.ts +17 -0
  79. package/dist/types/esm/internal/sdk.d.ts +42 -0
  80. package/dist/types/esm/internal/semantic-conventions.d.ts +54 -0
  81. package/dist/types/esm/internal/trace/exporters/eve-trace-exporter.d.ts +18 -0
  82. package/dist/types/esm/internal/trace/exporters/span-exporter.d.ts +12 -0
  83. package/dist/types/esm/internal/trace/index.d.ts +4 -0
  84. package/dist/types/esm/internal/trace/processors/eve-session-processor.d.ts +2 -0
  85. package/dist/types/esm/internal/trace/processors/span-processor.d.ts +18 -0
  86. package/dist/types/esm/internal/trace/session.d.ts +136 -0
  87. package/dist/types/esm/internal/trace/tracing.d.ts +17 -0
  88. package/dist/types/esm/internal/version.d.ts +1 -0
  89. package/package.json +57 -57
  90. package/dist/chunk-4Q2CRWI6.js +0 -2377
  91. package/dist/chunk-O5DVPC42.cjs +0 -2377
  92. package/dist/eve.d.cts +0 -19
  93. package/dist/eve.d.ts +0 -19
  94. package/dist/google-genai.d.cts +0 -7
  95. package/dist/google-genai.d.ts +0 -7
  96. package/dist/index.d.cts +0 -291
  97. package/dist/index.d.ts +0 -291
  98. package/dist/loader.mjs +0 -85
  99. package/dist/preload.cjs +0 -119
  100. package/dist/preload.d.cts +0 -2
  101. package/dist/preload.d.ts +0 -2
  102. package/dist/preload.js +0 -119
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunk2DSTZTDAcjs = require('./chunk-2DSTZTDA.cjs');
3
+ var _chunkRNU3DOSRcjs = require('./chunk-RNU3DOSR.cjs');
4
4
 
5
5
 
6
6
  var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
@@ -133,6 +133,34 @@ function extractTools(result) {
133
133
 
134
134
  // src/internal/instrumentation/mcp/session.ts
135
135
 
136
+ var FALLBACK_SESSION_ID = /* @__PURE__ */ Symbol("brizz.mcp.fallback-session-id");
137
+ var FALLBACK_SESSION_ID_BYTES = 16;
138
+ function generateSessionId() {
139
+ let id = "";
140
+ for (let i = 0; i < FALLBACK_SESSION_ID_BYTES; i++) {
141
+ id += Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
142
+ }
143
+ return id;
144
+ }
145
+ function resolveSessionId(protocol, baseContext) {
146
+ if (typeof protocol !== "object" || protocol === null) {
147
+ return void 0;
148
+ }
149
+ const carrier = protocol;
150
+ const fromTransport = _nullishCoalesce(carrier.sessionId, () => ( _optionalChain([carrier, 'access', _ => _._transport, 'optionalAccess', _2 => _2.sessionId])));
151
+ if (fromTransport) {
152
+ return fromTransport;
153
+ }
154
+ try {
155
+ const bound = baseContext.getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
156
+ if (_optionalChain([bound, 'optionalAccess', _3 => _3[_chunk77UGZGMPcjs.SESSION_ID]])) {
157
+ return void 0;
158
+ }
159
+ } catch (e2) {
160
+ }
161
+ carrier[FALLBACK_SESSION_ID] ??= generateSessionId();
162
+ return carrier[FALLBACK_SESSION_ID];
163
+ }
136
164
  function stampAndPropagateSession(span, sessionId, baseContext = _api.context.active()) {
137
165
  if (!sessionId) {
138
166
  return { context: baseContext, sessionId: null };
@@ -164,19 +192,19 @@ function stampAndPropagateSession(span, sessionId, baseContext = _api.context.ac
164
192
  function deriveSpanName(method, params) {
165
193
  try {
166
194
  if (method === METHOD_TOOLS_CALL) {
167
- const name = typeof _optionalChain([params, 'optionalAccess', _ => _["name"]]) === "string" ? params["name"] : "";
195
+ const name = typeof _optionalChain([params, 'optionalAccess', _4 => _4["name"]]) === "string" ? params["name"] : "";
168
196
  return name ? `${SPAN_NAME_TOOLS_CALL} ${name}` : SPAN_NAME_TOOLS_CALL;
169
197
  }
170
198
  if (method === METHOD_RESOURCES_READ) {
171
- const uri = typeof _optionalChain([params, 'optionalAccess', _2 => _2["uri"]]) === "string" ? params["uri"] : "";
199
+ const uri = typeof _optionalChain([params, 'optionalAccess', _5 => _5["uri"]]) === "string" ? params["uri"] : "";
172
200
  return uri ? `${METHOD_RESOURCES_READ} ${uri}` : METHOD_RESOURCES_READ;
173
201
  }
174
202
  if (method === METHOD_PROMPTS_GET) {
175
- const name = typeof _optionalChain([params, 'optionalAccess', _3 => _3["name"]]) === "string" ? params["name"] : "";
203
+ const name = typeof _optionalChain([params, 'optionalAccess', _6 => _6["name"]]) === "string" ? params["name"] : "";
176
204
  return name ? `${METHOD_PROMPTS_GET} ${name}` : METHOD_PROMPTS_GET;
177
205
  }
178
206
  return method;
179
- } catch (e2) {
207
+ } catch (e3) {
180
208
  return method || "mcp";
181
209
  }
182
210
  }
@@ -205,12 +233,12 @@ function applyServerRequestAttributes(span, request, protocol) {
205
233
  applyBaseAttributes(span, request);
206
234
  applyMethodSpecificRequestAttributes(span, request);
207
235
  if (request.method === METHOD_TOOLS_CALL) {
208
- const args = _optionalChain([request, 'access', _4 => _4.params, 'optionalAccess', _5 => _5["arguments"]]);
236
+ const args = _optionalChain([request, 'access', _7 => _7.params, 'optionalAccess', _8 => _8["arguments"]]);
209
237
  if (args !== void 0) {
210
238
  span.setAttribute(MCP_TOOL_ARGUMENTS, serializeForAttribute(args));
211
239
  }
212
240
  }
213
- const sessionId = _nullishCoalesce(protocol.sessionId, () => ( _optionalChain([protocol, 'access', _6 => _6._transport, 'optionalAccess', _7 => _7.sessionId])));
241
+ const sessionId = _nullishCoalesce(protocol.sessionId, () => ( _optionalChain([protocol, 'access', _9 => _9._transport, 'optionalAccess', _10 => _10.sessionId])));
214
242
  if (sessionId) {
215
243
  span.setAttribute(MCP_SESSION_ID, sessionId);
216
244
  }
@@ -258,7 +286,7 @@ function applyResultAttributes(span, method, result) {
258
286
  return;
259
287
  }
260
288
  const obj = result && typeof result === "object" ? result : null;
261
- const content = _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _8 => _8["content"]]), () => ( result));
289
+ const content = _nullishCoalesce(_optionalChain([obj, 'optionalAccess', _11 => _11["content"]]), () => ( result));
262
290
  span.setAttribute(MCP_TOOL_RESULT, serializeForAttribute(content));
263
291
  if (obj && obj["isError"] === true) {
264
292
  span.setAttribute(ERROR_TYPE, ERROR_TYPE_TOOL);
@@ -268,24 +296,24 @@ function applyResultAttributes(span, method, result) {
268
296
  }
269
297
  function applyErrorAttributes(span, err) {
270
298
  const error = err;
271
- const code = _optionalChain([error, 'optionalAccess', _9 => _9.code]);
299
+ const code = _optionalChain([error, 'optionalAccess', _12 => _12.code]);
272
300
  if (typeof code === "number") {
273
301
  span.setAttribute(RPC_RESPONSE_STATUS_CODE, code);
274
302
  span.setAttribute(ERROR_TYPE, String(code));
275
- } else if (_optionalChain([error, 'optionalAccess', _10 => _10.name]) === "AbortError") {
303
+ } else if (_optionalChain([error, 'optionalAccess', _13 => _13.name]) === "AbortError") {
276
304
  span.setAttribute(ERROR_TYPE, "cancelled");
277
- } else if (_optionalChain([error, 'optionalAccess', _11 => _11.name]) === "TimeoutError") {
305
+ } else if (_optionalChain([error, 'optionalAccess', _14 => _14.name]) === "TimeoutError") {
278
306
  span.setAttribute(ERROR_TYPE, "timeout");
279
307
  } else {
280
- span.setAttribute(ERROR_TYPE, _optionalChain([error, 'optionalAccess', _12 => _12.constructor, 'optionalAccess', _13 => _13.name]) || _optionalChain([error, 'optionalAccess', _14 => _14.name]) || "Error");
308
+ span.setAttribute(ERROR_TYPE, _optionalChain([error, 'optionalAccess', _15 => _15.constructor, 'optionalAccess', _16 => _16.name]) || _optionalChain([error, 'optionalAccess', _17 => _17.name]) || "Error");
281
309
  }
282
310
  try {
283
311
  span.recordException(error);
284
- } catch (e3) {
312
+ } catch (e4) {
285
313
  }
286
314
  span.setStatus({
287
315
  code: _api.SpanStatusCode.ERROR,
288
- message: typeof _optionalChain([error, 'optionalAccess', _15 => _15.message]) === "string" ? error.message : void 0
316
+ message: typeof _optionalChain([error, 'optionalAccess', _18 => _18.message]) === "string" ? error.message : void 0
289
317
  });
290
318
  }
291
319
  function serializeForAttribute(value) {
@@ -304,7 +332,7 @@ function rawSerialize(value) {
304
332
  }
305
333
  try {
306
334
  return JSON.stringify(value);
307
- } catch (e4) {
335
+ } catch (e5) {
308
336
  try {
309
337
  if (value === null || value === void 0) {
310
338
  return "";
@@ -314,7 +342,7 @@ function rawSerialize(value) {
314
342
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
315
343
  String(value)
316
344
  ) : tag;
317
- } catch (e5) {
345
+ } catch (e6) {
318
346
  return "";
319
347
  }
320
348
  }
@@ -421,7 +449,7 @@ function wrapOnRequest(original, tracer) {
421
449
  return original.apply(this, args);
422
450
  }
423
451
  const { span, spanCtx } = started;
424
- const transportSessionId = _nullishCoalesce(this.sessionId, () => ( _optionalChain([this, 'access', _16 => _16._transport, 'optionalAccess', _17 => _17.sessionId])));
452
+ const transportSessionId = _nullishCoalesce(started.sessionId, () => ( void 0));
425
453
  const postResult = method === METHOD_TOOLS_LIST ? (result) => {
426
454
  try {
427
455
  emitSchemaSpansFromListResponse(result, transportSessionId, tracer);
@@ -500,7 +528,7 @@ function safeStartClientSpan(tracer, request, protocol) {
500
528
  applyClientRequestAttributes(
501
529
  span,
502
530
  request,
503
- _optionalChain([protocol, 'access', _18 => _18._transport, 'optionalAccess', _19 => _19.constructor, 'optionalAccess', _20 => _20.name])
531
+ _optionalChain([protocol, 'access', _19 => _19._transport, 'optionalAccess', _20 => _20.constructor, 'optionalAccess', _21 => _21.name])
504
532
  );
505
533
  return span;
506
534
  } catch (error) {
@@ -518,9 +546,9 @@ function safeStartServerSpan(tracer, request, protocol) {
518
546
  parentCtx
519
547
  );
520
548
  applyServerRequestAttributes(span, request, protocol);
521
- const sessionId = _nullishCoalesce(protocol.sessionId, () => ( _optionalChain([protocol, 'access', _21 => _21._transport, 'optionalAccess', _22 => _22.sessionId])));
522
- const { context: sessCtx } = stampAndPropagateSession(span, sessionId, parentCtx);
523
- return { span, spanCtx: _api.trace.setSpan(sessCtx, span) };
549
+ const resolved = resolveSessionId(protocol, parentCtx);
550
+ const { context: sessCtx, sessionId } = stampAndPropagateSession(span, resolved, parentCtx);
551
+ return { span, spanCtx: _api.trace.setSpan(sessCtx, span), sessionId };
524
552
  } catch (error) {
525
553
  _chunkWC573FCIcjs.logger.debug(`Brizz MCP: failed to open SERVER span: ${String(error)}`);
526
554
  return null;
@@ -528,7 +556,7 @@ function safeStartServerSpan(tracer, request, protocol) {
528
556
  }
529
557
  function extractParentContext(request) {
530
558
  try {
531
- const meta = _optionalChain([request, 'access', _23 => _23.params, 'optionalAccess', _24 => _24._meta]);
559
+ const meta = _optionalChain([request, 'access', _22 => _22.params, 'optionalAccess', _23 => _23._meta]);
532
560
  if (meta && typeof meta === "object") {
533
561
  return _api.propagation.extract(_api.context.active(), meta);
534
562
  }
@@ -570,7 +598,7 @@ function safeEnd(span) {
570
598
 
571
599
  // src/internal/instrumentation/mcp/version.ts
572
600
  var INSTRUMENTATION_NAME = "@brizz/sdk/mcp";
573
- var INSTRUMENTATION_VERSION = _chunk2DSTZTDAcjs.getSDKVersion.call(void 0, );
601
+ var INSTRUMENTATION_VERSION = _chunkRNU3DOSRcjs.getSDKVersion.call(void 0, );
574
602
 
575
603
  // src/internal/instrumentation/mcp/instrumentation.ts
576
604
  var PROTOCOL_MODULE_NAME = "@modelcontextprotocol/sdk/shared/protocol.js";
@@ -588,7 +616,7 @@ var MCPInstrumentation = class extends _openinferenceinstrumentationmcp.MCPInstr
588
616
  */
589
617
 
590
618
  constructor(_config) {
591
- super({ instrumentationConfig: _optionalChain([_config, 'optionalAccess', _25 => _25.instrumentationConfig]) });
619
+ super({ instrumentationConfig: _optionalChain([_config, 'optionalAccess', _24 => _24.instrumentationConfig]) });
592
620
  this.brizzTracer = _api.trace.getTracer(INSTRUMENTATION_NAME, INSTRUMENTATION_VERSION);
593
621
  }
594
622
  /**
@@ -598,7 +626,7 @@ var MCPInstrumentation = class extends _openinferenceinstrumentationmcp.MCPInstr
598
626
  * calls `patchProtocolPrototype`.
599
627
  */
600
628
  patchProtocolModule(module) {
601
- const proto = _optionalChain([module, 'optionalAccess', _26 => _26.Protocol, 'optionalAccess', _27 => _27.prototype]);
629
+ const proto = _optionalChain([module, 'optionalAccess', _25 => _25.Protocol, 'optionalAccess', _26 => _26.prototype]);
602
630
  if (!proto) {
603
631
  _chunkWC573FCIcjs.logger.debug(
604
632
  "Brizz MCP: module does not expose Protocol.prototype \u2014 skipping protocol patches"
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getSDKVersion
3
- } from "./chunk-OR3YPY4I.js";
3
+ } from "./chunk-BGLKBQ6N.js";
4
4
  import {
5
5
  logger
6
6
  } from "./chunk-Y4HNUX3Q.js";
@@ -133,6 +133,34 @@ function extractTools(result) {
133
133
 
134
134
  // src/internal/instrumentation/mcp/session.ts
135
135
  import { context } from "@opentelemetry/api";
136
+ var FALLBACK_SESSION_ID = /* @__PURE__ */ Symbol("brizz.mcp.fallback-session-id");
137
+ var FALLBACK_SESSION_ID_BYTES = 16;
138
+ function generateSessionId() {
139
+ let id = "";
140
+ for (let i = 0; i < FALLBACK_SESSION_ID_BYTES; i++) {
141
+ id += Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
142
+ }
143
+ return id;
144
+ }
145
+ function resolveSessionId(protocol, baseContext) {
146
+ if (typeof protocol !== "object" || protocol === null) {
147
+ return void 0;
148
+ }
149
+ const carrier = protocol;
150
+ const fromTransport = carrier.sessionId ?? carrier._transport?.sessionId;
151
+ if (fromTransport) {
152
+ return fromTransport;
153
+ }
154
+ try {
155
+ const bound = baseContext.getValue(PROPERTIES_CONTEXT_KEY);
156
+ if (bound?.[SESSION_ID]) {
157
+ return void 0;
158
+ }
159
+ } catch {
160
+ }
161
+ carrier[FALLBACK_SESSION_ID] ??= generateSessionId();
162
+ return carrier[FALLBACK_SESSION_ID];
163
+ }
136
164
  function stampAndPropagateSession(span, sessionId, baseContext = context.active()) {
137
165
  if (!sessionId) {
138
166
  return { context: baseContext, sessionId: null };
@@ -421,7 +449,7 @@ function wrapOnRequest(original, tracer) {
421
449
  return original.apply(this, args);
422
450
  }
423
451
  const { span, spanCtx } = started;
424
- const transportSessionId = this.sessionId ?? this._transport?.sessionId;
452
+ const transportSessionId = started.sessionId ?? void 0;
425
453
  const postResult = method === METHOD_TOOLS_LIST ? (result) => {
426
454
  try {
427
455
  emitSchemaSpansFromListResponse(result, transportSessionId, tracer);
@@ -518,9 +546,9 @@ function safeStartServerSpan(tracer, request, protocol) {
518
546
  parentCtx
519
547
  );
520
548
  applyServerRequestAttributes(span, request, protocol);
521
- const sessionId = protocol.sessionId ?? protocol._transport?.sessionId;
522
- const { context: sessCtx } = stampAndPropagateSession(span, sessionId, parentCtx);
523
- return { span, spanCtx: trace.setSpan(sessCtx, span) };
549
+ const resolved = resolveSessionId(protocol, parentCtx);
550
+ const { context: sessCtx, sessionId } = stampAndPropagateSession(span, resolved, parentCtx);
551
+ return { span, spanCtx: trace.setSpan(sessCtx, span), sessionId };
524
552
  } catch (error) {
525
553
  logger.debug(`Brizz MCP: failed to open SERVER span: ${String(error)}`);
526
554
  return null;
@@ -0,0 +1,2 @@
1
+ export { createEveSessionProcessor } from './internal/trace/processors/eve-session-processor.js';
2
+ export { createEveTraceExporter, createEveOtelConfig, } from './internal/trace/exporters/eve-trace-exporter.js';
@@ -0,0 +1 @@
1
+ export { instrumentGoogleGenAI } from './internal/instrumentation/google-genai.js';
@@ -0,0 +1,15 @@
1
+ import './internal/instrumentation/auto-init.js';
2
+ export { Brizz, type IBrizzInitializeOptions } from './internal/sdk.js';
3
+ export { type IInstrumentModules, type IMCPManualModules, } from './internal/instrumentation/index.js';
4
+ export { emitEvent, emitEventWithSessionId } from './internal/log/index.js';
5
+ export { getSpanExporter, getSpanProcessor, withSessionId, callWithSessionId, withProperties, callWithProperties, withMute, callWithMute, setCurrentSpanCustomProperties, setUser, setOrganization, setMessageId, setSessionId, withUser, callWithUser, withOrganization, callWithOrganization, withMessageId, callWithMessageId, Session, SessionTitle, startSession, startSessionTitle, getActiveSession, addExternalLink, recordFeedback, recordMetric, } from './internal/trace/index.js';
6
+ export type { IMuteOptions } from './internal/trace/index.js';
7
+ export { getMetricsExporter, getMetricsReader } from './internal/metric/index.js';
8
+ export type { IMaskingConfig, ISpanMaskingConfig, ILogMaskingConfig, IEventMaskingConfig, IEventMaskingRule, MaskingMode, IAttributesMaskingRule, } from './internal/masking/index.js';
9
+ export { DEFAULT_PII_PATTERNS } from './internal/masking/patterns.js';
10
+ export { maskValue, maskAttributes } from './internal/masking/utils.js';
11
+ export { LogLevel, logger, setLogLevel, getLogLevel } from './internal/logger.js';
12
+ export type { ILogger } from './internal/logger.js';
13
+ export { SeverityNumber } from '@opentelemetry/api-logs';
14
+ export type { AttributeValue } from '@opentelemetry/api';
15
+ export type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
@@ -0,0 +1,19 @@
1
+ import type { AttributeValue } from '@opentelemetry/api';
2
+ import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
3
+ import type { IBrizzInitializeOptions } from '../index.js';
4
+ import type { LogLevel } from './logger.js';
5
+ import type { IMaskingConfig } from './masking/index.js';
6
+ export interface IResolvedBrizzConfig extends Omit<IBrizzInitializeOptions, 'masking'> {
7
+ appName: string;
8
+ baseUrl: string;
9
+ headers: Record<string, string>;
10
+ disableBatch: boolean;
11
+ environment?: string;
12
+ apiKey?: string;
13
+ logLevel: LogLevel;
14
+ masking?: IMaskingConfig;
15
+ resourceAttributes?: Record<string, AttributeValue>;
16
+ beforeSendSpan?: (span: ReadableSpan) => boolean | Promise<boolean>;
17
+ }
18
+ export declare function resolveConfig(options: IBrizzInitializeOptions): IResolvedBrizzConfig;
19
+ export declare function processEnvironmentConfig(options: IBrizzInitializeOptions): IResolvedBrizzConfig;
@@ -0,0 +1,3 @@
1
+ export declare const BRIZZ_SDK_VERSION = "brizz.sdk.version";
2
+ export declare const BRIZZ_SDK_LANGUAGE = "brizz.sdk.language";
3
+ export declare const SDK_LANGUAGE = "typescript";
@@ -0,0 +1,13 @@
1
+ export declare const PLACEHOLDER_SERVICE = "<service-name>";
2
+ export declare const SERVICE_NAME_HEADER = "X-Brizz-Service-Name";
3
+ export interface IParsedDSN {
4
+ scheme: 'http' | 'https';
5
+ host: string;
6
+ bearer: string;
7
+ service: string;
8
+ baseUrl: string;
9
+ }
10
+ export interface IParseDSNOptions {
11
+ allowPlaceholderService?: boolean;
12
+ }
13
+ export declare function parseDSN(dsn: string, options?: IParseDSNOptions): IParsedDSN | null;
@@ -0,0 +1,8 @@
1
+ type TelemetryRegister = (...integrations: unknown[]) => void;
2
+ interface AISdkTelemetryModule {
3
+ registerTelemetry?: TelemetryRegister;
4
+ registerTelemetryIntegration?: TelemetryRegister;
5
+ }
6
+ export declare function selectTelemetryRegister(ai: AISdkTelemetryModule): TelemetryRegister | undefined;
7
+ export declare const autoInstrumentationsLoaded: boolean;
8
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { Instrumentation } from '@opentelemetry/instrumentation';
2
+ interface GoogleGenAIModule {
3
+ GoogleGenAI: new (...args: never[]) => object;
4
+ }
5
+ interface GoogleGenAIInstrumentationConfig {
6
+ exceptionLogger?: (error: Error) => void;
7
+ }
8
+ interface GoogleGenAIInstrumentationLike extends Instrumentation {
9
+ manuallyInstrument(module: GoogleGenAIModule): void;
10
+ }
11
+ export declare const GoogleGenAIInstrumentation: new (config?: GoogleGenAIInstrumentationConfig) => GoogleGenAIInstrumentationLike;
12
+ export declare function instrumentGoogleGenAI<T extends GoogleGenAIModule>(module: T): T['GoogleGenAI'];
13
+ export {};
@@ -0,0 +1,2 @@
1
+ export { InstrumentationRegistry, type IInstrumentModules } from './registry.js';
2
+ export type { IMCPManualModules } from './mcp/types.js';
@@ -0,0 +1,2 @@
1
+ export { MCPInstrumentation, isMCPInstrumentation } from './instrumentation.js';
2
+ export type { IMCPManualModules, IMCPInstrumentationConfig } from './types.js';
@@ -0,0 +1,15 @@
1
+ import { MCPInstrumentation as BaseMCPInstrumentation } from '@arizeai/openinference-instrumentation-mcp';
2
+ import type { Instrumentation, InstrumentationConfig } from '@opentelemetry/instrumentation';
3
+ import type { IMCPManualModules } from './types.js';
4
+ export declare class MCPInstrumentation extends BaseMCPInstrumentation {
5
+ private readonly brizzTracer;
6
+ constructor(_config?: {
7
+ exceptionLogger?: (error: Error) => void;
8
+ instrumentationConfig?: InstrumentationConfig;
9
+ });
10
+ private patchProtocolModule;
11
+ private unpatchProtocolModule;
12
+ protected init(): ReturnType<BaseMCPInstrumentation['init']>;
13
+ manuallyInstrument(modules: IMCPManualModules): void;
14
+ }
15
+ export declare function isMCPInstrumentation(value: unknown): value is Instrumentation;
@@ -0,0 +1,9 @@
1
+ import type { Span } from '@opentelemetry/api';
2
+ import type { IJsonRpcRequest, IProtocolLike } from '../types.js';
3
+ export declare function deriveSpanName(method: string, params?: Record<string, unknown>): string;
4
+ export declare function applyBaseAttributes(span: Span, request: IJsonRpcRequest): void;
5
+ export declare function applyClientRequestAttributes(span: Span, request: IJsonRpcRequest, transportName?: string): void;
6
+ export declare function applyServerRequestAttributes(span: Span, request: IJsonRpcRequest, protocol: IProtocolLike): void;
7
+ export declare function applyResultAttributes(span: Span, method: string, result: unknown): void;
8
+ export declare function applyErrorAttributes(span: Span, err: unknown): void;
9
+ export declare function serializeForAttribute(value: unknown): string;
@@ -0,0 +1,2 @@
1
+ import type { Tracer } from '@opentelemetry/api';
2
+ export declare function patchProtocolPrototype(prototype: unknown, tracer: Tracer): boolean;
@@ -0,0 +1,2 @@
1
+ import type { Tracer } from '@opentelemetry/api';
2
+ export declare function emitSchemaSpansFromListResponse(result: unknown, transportSessionId: string | null | undefined, tracer: Tracer): void;
@@ -0,0 +1,37 @@
1
+ export declare const MCP_TOOL_NAME = "mcp.tool.name";
2
+ export declare const MCP_TOOL_ARGUMENTS = "mcp.tool.arguments";
3
+ export declare const MCP_TOOL_RESULT = "mcp.tool.result";
4
+ export declare const MCP_COMPONENT_TYPE = "mcp.component.type";
5
+ export declare const MCP_COMPONENT_TOOL = "tool";
6
+ export declare const MCP_COMPONENT_TOOL_SCHEMA = "tool_schema";
7
+ export declare const MCP_TOOL_SCHEMA_PARAMETERS = "mcp.tool.schema.parameters";
8
+ export declare const MCP_TOOL_SCHEMA_OUTPUT = "mcp.tool.schema.output";
9
+ export declare const MCP_TOOL_DESCRIPTION = "mcp.tool.description";
10
+ export declare const SPAN_NAME_TOOL_REGISTER = "mcp.tool.register";
11
+ export declare const MCP_METHOD_NAME = "mcp.method.name";
12
+ export declare const MCP_REQUEST_ID = "mcp.request.id";
13
+ export declare const MCP_SESSION_ID = "mcp.session.id";
14
+ export declare const MCP_PROTOCOL_VERSION = "mcp.protocol.version";
15
+ export declare const MCP_RESOURCE_URI = "mcp.resource.uri";
16
+ export declare const MCP_NOTIFICATION_METHOD = "mcp.notification.method";
17
+ export declare const RPC_SYSTEM = "rpc.system";
18
+ export declare const RPC_SYSTEM_MCP = "mcp";
19
+ export declare const RPC_RESPONSE_STATUS_CODE = "rpc.response.status_code";
20
+ export declare const GEN_AI_TOOL_NAME = "gen_ai.tool.name";
21
+ export declare const GEN_AI_PROMPT_NAME = "gen_ai.prompt.name";
22
+ export declare const GEN_AI_OPERATION_NAME = "gen_ai.operation.name";
23
+ export declare const GEN_AI_OPERATION_EXECUTE_TOOL = "execute_tool";
24
+ export declare const NETWORK_TRANSPORT = "network.transport";
25
+ export declare const ERROR_TYPE = "error.type";
26
+ export declare const ERROR_TYPE_TOOL = "tool_error";
27
+ export declare const ERROR_TYPE_TIMEOUT = "timeout";
28
+ export declare const ERROR_TYPE_CANCELLED = "cancelled";
29
+ export declare const JSONRPC_REQUEST_ID = "jsonrpc.request.id";
30
+ export declare const SPAN_NAME_TOOLS_CALL = "tools/call";
31
+ export declare const MAX_ATTRIBUTE_LENGTH: number;
32
+ export declare const TRUNCATION_SUFFIX = "\u2026(truncated)";
33
+ export declare const METHOD_TOOLS_CALL = "tools/call";
34
+ export declare const METHOD_TOOLS_LIST = "tools/list";
35
+ export declare const METHOD_RESOURCES_READ = "resources/read";
36
+ export declare const METHOD_PROMPTS_GET = "prompts/get";
37
+ export declare const METHOD_INITIALIZE = "initialize";
@@ -0,0 +1,7 @@
1
+ import type { Context, Span } from '@opentelemetry/api';
2
+ export interface ISessionAttachResult {
3
+ context: Context;
4
+ sessionId: string | null;
5
+ }
6
+ export declare function resolveSessionId(protocol: unknown, baseContext: Context): string | undefined;
7
+ export declare function stampAndPropagateSession(span: Span, sessionId: string | null | undefined, baseContext?: Context): ISessionAttachResult;
@@ -0,0 +1,47 @@
1
+ export interface IJsonRpcRequest {
2
+ method: string;
3
+ params?: IMessageParams;
4
+ id?: string | number;
5
+ }
6
+ export interface IMessageParams {
7
+ _meta?: IMessageMeta;
8
+ [key: string]: unknown;
9
+ }
10
+ export interface IMessageMeta {
11
+ [key: string]: unknown;
12
+ }
13
+ export interface IJsonRpcResponse {
14
+ jsonrpc: '2.0';
15
+ id?: string | number;
16
+ result?: unknown;
17
+ error?: {
18
+ code?: number;
19
+ message?: string;
20
+ data?: unknown;
21
+ };
22
+ }
23
+ export interface IProtocolLike {
24
+ sessionId?: string;
25
+ _transport?: ITransportLike;
26
+ _requestHandlers?: Map<string, RequestHandler>;
27
+ fallbackRequestHandler?: RequestHandler;
28
+ }
29
+ export interface ITransportLike {
30
+ sessionId?: string;
31
+ constructor?: {
32
+ name?: string;
33
+ };
34
+ }
35
+ export type RequestHandler = (request: unknown, extra: unknown) => unknown;
36
+ export interface IMCPManualModules {
37
+ clientSSEModule?: unknown;
38
+ serverSSEModule?: unknown;
39
+ clientStdioModule?: unknown;
40
+ serverStdioModule?: unknown;
41
+ clientStreamableHTTPModule?: unknown;
42
+ serverStreamableHTTPModule?: unknown;
43
+ protocolModule?: unknown;
44
+ }
45
+ export interface IMCPInstrumentationConfig {
46
+ captureNotifications?: boolean;
47
+ }
@@ -0,0 +1,2 @@
1
+ export declare const INSTRUMENTATION_NAME = "@brizz/sdk/mcp";
2
+ export declare const INSTRUMENTATION_VERSION: string;
@@ -0,0 +1,29 @@
1
+ import type { Instrumentation } from '@opentelemetry/instrumentation';
2
+ import type { IMCPManualModules } from './mcp/types.js';
3
+ export interface IInstrumentModules {
4
+ openAI?: unknown;
5
+ anthropic?: unknown;
6
+ cohere?: unknown;
7
+ google_vertexai?: unknown;
8
+ google_genai?: unknown;
9
+ bedrock?: unknown;
10
+ pinecone?: unknown;
11
+ langchain?: {
12
+ callbackManagerModule?: unknown;
13
+ };
14
+ llamaindex?: unknown;
15
+ chromadb?: unknown;
16
+ qdrant?: unknown;
17
+ together?: unknown;
18
+ mcp?: IMCPManualModules;
19
+ }
20
+ export type { IMCPManualModules } from './mcp/types.js';
21
+ export declare class InstrumentationRegistry {
22
+ private static instance;
23
+ static getInstance(): InstrumentationRegistry;
24
+ private manualModules;
25
+ private loadInstrumentation;
26
+ private loadManualInstrumentations;
27
+ setManualModules(modules: IInstrumentModules): void;
28
+ getManualInstrumentations(): Instrumentation[];
29
+ }
@@ -0,0 +1,11 @@
1
+ import { type Context } from '@opentelemetry/api';
2
+ import type { Span as SdkSpan, SpanProcessor } from '@opentelemetry/sdk-trace-base';
3
+ import type { Telemetry } from 'ai';
4
+ export declare function createInterruptIntegration(): Telemetry;
5
+ export declare class InterruptPropagator implements SpanProcessor {
6
+ onStart(span: SdkSpan, _parentContext: Context): void;
7
+ onEnd(): void;
8
+ shutdown(): Promise<void>;
9
+ forceFlush(): Promise<void>;
10
+ }
11
+ export declare function _resetInterruptState(): void;
@@ -0,0 +1 @@
1
+ export { LoggingModule, emitEvent, emitEventWithSessionId } from './logging.js';
@@ -0,0 +1,21 @@
1
+ import type { LogBody } from '@opentelemetry/api-logs';
2
+ import { SeverityNumber } from '@opentelemetry/api-logs';
3
+ import { LoggerProvider } from '@opentelemetry/sdk-logs';
4
+ import type { IResolvedBrizzConfig } from '../config.js';
5
+ export declare class LoggingModule {
6
+ private static instance;
7
+ static getInstance(): LoggingModule;
8
+ private logExporter;
9
+ private logProcessor;
10
+ private loggerProvider;
11
+ private initLogExporter;
12
+ private initLogProcessor;
13
+ private initLoggerProvider;
14
+ setup(config: IResolvedBrizzConfig): void;
15
+ emitEvent(name: string, attributes?: Record<string, string | number | boolean>, body?: LogBody, severityNumber?: SeverityNumber): void;
16
+ isInitialized(): boolean;
17
+ getLoggerProvider(): LoggerProvider | null;
18
+ shutdown(): Promise<void>;
19
+ }
20
+ export declare function emitEvent(name: string, attributes?: Record<string, string | number | boolean>, body?: LogBody, severityNumber?: SeverityNumber): void;
21
+ export declare function emitEventWithSessionId(sessionId: string, name: string, attributes?: Record<string, string | number | boolean>, body?: LogBody, severityNumber?: SeverityNumber): void;
@@ -0,0 +1,16 @@
1
+ import type { LogRecordExporter, SdkLogRecord } from '@opentelemetry/sdk-logs';
2
+ import { BatchLogRecordProcessor, SimpleLogRecordProcessor } from '@opentelemetry/sdk-logs';
3
+ import type { IResolvedBrizzConfig } from '../../config.js';
4
+ import type { IAttributesMaskingRule, ILogMaskingConfig } from '../../masking/types.js';
5
+ export declare const DEFAULT_LOG_MASKING_RULES: IAttributesMaskingRule[];
6
+ export declare class BrizzSimpleLogRecordProcessor extends SimpleLogRecordProcessor {
7
+ readonly config: IResolvedBrizzConfig;
8
+ constructor(exporter: LogRecordExporter, config: IResolvedBrizzConfig);
9
+ onEmit(logRecord: SdkLogRecord): void;
10
+ }
11
+ export declare class BrizzBatchLogRecordProcessor extends BatchLogRecordProcessor {
12
+ readonly config: IResolvedBrizzConfig;
13
+ constructor(exporter: LogRecordExporter, config: IResolvedBrizzConfig);
14
+ onEmit(logRecord: SdkLogRecord): void;
15
+ }
16
+ export declare function maskLog(logRecord: SdkLogRecord, config: ILogMaskingConfig): SdkLogRecord;
@@ -0,0 +1,23 @@
1
+ import { DiagLogLevel } from '@opentelemetry/api';
2
+ export declare enum LogLevel {
3
+ NONE = 0,
4
+ ERROR = 1,
5
+ WARN = 2,
6
+ INFO = 3,
7
+ DEBUG = 4
8
+ }
9
+ export declare const DEFAULT_LOG_LEVEL = LogLevel.WARN;
10
+ export interface ILogger {
11
+ debug: (msg: string, ...meta: unknown[]) => void;
12
+ info: (msg: string, ...meta: unknown[]) => void;
13
+ warn: (msg: string, ...meta: unknown[]) => void;
14
+ error: (msg: string, ...meta: unknown[]) => void;
15
+ setLevel: (level: LogLevel) => void;
16
+ getLevel: () => LogLevel;
17
+ }
18
+ export declare const noopLogger: ILogger;
19
+ export declare function parseLogLevel(level?: string): LogLevel;
20
+ export declare const logger: ILogger;
21
+ export declare function setLogLevel(level: LogLevel | string): void;
22
+ export declare function getLogLevel(): LogLevel;
23
+ export declare function mapLogLevelToDiagLevel(logLevel: LogLevel): DiagLogLevel;
@@ -0,0 +1,3 @@
1
+ export type { IPatternEntry, MaskingMode, IPatternBasedMaskingRule, ISpanMaskingConfig, IEventMaskingConfig, ILogMaskingConfig, MaskableValue, IMaskingConfig, IEventMaskingRule, IAttributesMaskingRule, } from './types.js';
2
+ export { DEFAULT_PII_PATTERNS } from './patterns.js';
3
+ export { maskValue, maskAttributes } from './utils.js';
@@ -0,0 +1,2 @@
1
+ import type { IPatternEntry } from './types.js';
2
+ export declare const DEFAULT_PII_PATTERNS: IPatternEntry[];