@brizz/sdk 0.1.49 → 0.1.50
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/README.md +9 -0
- package/dist/{chunk-3OMB2F7B.js → chunk-7PRTTYWM.js} +1 -1
- package/dist/{chunk-FVVRWMPV.js → chunk-GUKWVI53.js} +7 -1
- package/dist/{chunk-ELLCNMLI.cjs → chunk-O2IBZJOJ.cjs} +4 -4
- package/dist/{chunk-GMZQ6N77.cjs → chunk-RV7JIIDG.cjs} +7 -1
- package/dist/{chunk-HTFR2LKY.js → chunk-STM7QUQP.js} +2 -2
- package/dist/{chunk-VAUO47L3.cjs → chunk-VH5N6E54.cjs} +8 -8
- package/dist/index.cjs +177 -154
- package/dist/index.js +30 -7
- package/dist/interrupt-BYLSBXTV.cjs +12 -0
- package/dist/{interrupt-YO3ID433.js → interrupt-UKJK5WOA.js} +2 -2
- package/dist/{mcp-FWGIYACB.cjs → mcp-3URJU7OY.cjs} +12 -12
- package/dist/{mcp-LIAXZGBN.js → mcp-AOBKXJND.js} +2 -2
- package/dist/types/cjs/internal/semantic-conventions.d.ts +3 -0
- package/dist/types/cjs/internal/trace/session.d.ts +1 -0
- package/dist/types/esm/internal/semantic-conventions.d.ts +3 -0
- package/dist/types/esm/internal/trace/session.d.ts +1 -0
- package/package.json +1 -1
- package/dist/interrupt-YQHEXVES.cjs +0 -12
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
configure,
|
|
7
7
|
getSDKVersion
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-STM7QUQP.js";
|
|
9
9
|
import {
|
|
10
10
|
DEFAULT_LOG_LEVEL,
|
|
11
11
|
LogLevel,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./chunk-Y4HNUX3Q.js";
|
|
17
17
|
import {
|
|
18
18
|
InterruptPropagator
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-7PRTTYWM.js";
|
|
20
20
|
import {
|
|
21
21
|
AGENT_ID,
|
|
22
22
|
AGENT_NAME,
|
|
@@ -44,6 +44,9 @@ import {
|
|
|
44
44
|
METRIC_POLARITY,
|
|
45
45
|
METRIC_POLARITY_NEGATIVE,
|
|
46
46
|
METRIC_POLARITY_POSITIVE,
|
|
47
|
+
METRIC_SCOPE,
|
|
48
|
+
METRIC_SCOPE_SESSION,
|
|
49
|
+
METRIC_SCOPE_TRACE,
|
|
47
50
|
METRIC_TIMESTAMP,
|
|
48
51
|
METRIC_TRACE_ID,
|
|
49
52
|
METRIC_UNIT,
|
|
@@ -74,7 +77,7 @@ import {
|
|
|
74
77
|
USER_NAME,
|
|
75
78
|
USER_PLAN,
|
|
76
79
|
USER_ROLE
|
|
77
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-GUKWVI53.js";
|
|
78
81
|
import {
|
|
79
82
|
__require
|
|
80
83
|
} from "./chunk-3RG5ZIWI.js";
|
|
@@ -465,7 +468,7 @@ function loadGenAIInstrumentations() {
|
|
|
465
468
|
function loadMCPInstrumentation() {
|
|
466
469
|
void (async () => {
|
|
467
470
|
try {
|
|
468
|
-
const { MCPInstrumentation } = await import("./mcp-
|
|
471
|
+
const { MCPInstrumentation } = await import("./mcp-AOBKXJND.js");
|
|
469
472
|
const mcp = new MCPInstrumentation({ exceptionLogger });
|
|
470
473
|
registerInstrumentations({ instrumentations: [mcp] });
|
|
471
474
|
logger.debug("Auto-loaded MCP instrumentation");
|
|
@@ -529,7 +532,7 @@ function loadVercelAITelemetry() {
|
|
|
529
532
|
}
|
|
530
533
|
const isV7 = typeof ai.registerTelemetry === "function";
|
|
531
534
|
const integrations = [];
|
|
532
|
-
const { createInterruptIntegration } = await import("./interrupt-
|
|
535
|
+
const { createInterruptIntegration } = await import("./interrupt-UKJK5WOA.js");
|
|
533
536
|
integrations.push(createInterruptIntegration());
|
|
534
537
|
let otelCollectorLoaded = false;
|
|
535
538
|
try {
|
|
@@ -961,7 +964,7 @@ var InstrumentationRegistry = class _InstrumentationRegistry {
|
|
|
961
964
|
const mcpModules = this.manualModules.mcp;
|
|
962
965
|
void (async () => {
|
|
963
966
|
try {
|
|
964
|
-
const { MCPInstrumentation } = await import("./mcp-
|
|
967
|
+
const { MCPInstrumentation } = await import("./mcp-AOBKXJND.js");
|
|
965
968
|
const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
|
|
966
969
|
instrumentation.manuallyInstrument(mcpModules);
|
|
967
970
|
logger.debug("Manual instrumentation enabled for MCP");
|
|
@@ -1004,7 +1007,7 @@ import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
|
1004
1007
|
import { LoggerProvider } from "@opentelemetry/sdk-logs";
|
|
1005
1008
|
|
|
1006
1009
|
// src/internal/trace/session.ts
|
|
1007
|
-
import { context as context3, trace as trace2, SpanStatusCode as SpanStatusCode2 } from "@opentelemetry/api";
|
|
1010
|
+
import { context as context3, isSpanContextValid, trace as trace2, SpanStatusCode as SpanStatusCode2 } from "@opentelemetry/api";
|
|
1008
1011
|
function setCurrentSpanCustomProperties(properties) {
|
|
1009
1012
|
const current = trace2.getActiveSpan();
|
|
1010
1013
|
if (!current || !current.isRecording()) {
|
|
@@ -1512,10 +1515,20 @@ function recordMetricImpl(options) {
|
|
|
1512
1515
|
return;
|
|
1513
1516
|
}
|
|
1514
1517
|
}
|
|
1518
|
+
const scope = options.scope ?? METRIC_SCOPE_SESSION;
|
|
1519
|
+
if (scope !== METRIC_SCOPE_SESSION && scope !== METRIC_SCOPE_TRACE) {
|
|
1520
|
+
logger.warn(
|
|
1521
|
+
`recordMetric(${name}) called with an invalid scope ${JSON.stringify(scope)}; expected '${METRIC_SCOPE_SESSION}' or '${METRIC_SCOPE_TRACE}'. Metric dropped.`
|
|
1522
|
+
);
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1515
1525
|
const eventAttributes = {
|
|
1516
1526
|
[METRIC_NAME]: name,
|
|
1517
1527
|
[METRIC_VALUE]: numericValue
|
|
1518
1528
|
};
|
|
1529
|
+
if (options.scope !== void 0) {
|
|
1530
|
+
eventAttributes[METRIC_SCOPE] = scope;
|
|
1531
|
+
}
|
|
1519
1532
|
if (options.unit !== void 0) {
|
|
1520
1533
|
eventAttributes[METRIC_UNIT] = options.unit;
|
|
1521
1534
|
}
|
|
@@ -1585,6 +1598,16 @@ function recordMetricImpl(options) {
|
|
|
1585
1598
|
if (traceId !== void 0) {
|
|
1586
1599
|
eventAttributes[METRIC_TRACE_ID] = traceId;
|
|
1587
1600
|
}
|
|
1601
|
+
if (scope === METRIC_SCOPE_TRACE && traceId === void 0) {
|
|
1602
|
+
const spanContext = trace2.getActiveSpan()?.spanContext();
|
|
1603
|
+
if (!spanContext || !isSpanContextValid(spanContext)) {
|
|
1604
|
+
logger.warn(
|
|
1605
|
+
`recordMetric(${name}) called with scope 'trace' but no trace; metric dropped. Pass options.traceId, or call inside the span of the trace being scored.`
|
|
1606
|
+
);
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1609
|
+
eventAttributes[METRIC_TRACE_ID] = spanContext.traceId;
|
|
1610
|
+
}
|
|
1588
1611
|
const sessionId = options.sessionId ?? (traceId === void 0 ? resolveSessionIdFromContext() : void 0);
|
|
1589
1612
|
if (sessionId === void 0 && traceId === void 0) {
|
|
1590
1613
|
logger.warn(
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkO2IBZJOJcjs = require('./chunk-O2IBZJOJ.cjs');
|
|
6
|
+
require('./chunk-RV7JIIDG.cjs');
|
|
7
|
+
require('./chunk-OBGZSXTJ.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.InterruptPropagator = _chunkO2IBZJOJcjs.InterruptPropagator; exports._resetInterruptState = _chunkO2IBZJOJcjs._resetInterruptState; exports.createInterruptIntegration = _chunkO2IBZJOJcjs.createInterruptIntegration;
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
InterruptPropagator,
|
|
3
3
|
_resetInterruptState,
|
|
4
4
|
createInterruptIntegration
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-7PRTTYWM.js";
|
|
6
|
+
import "./chunk-GUKWVI53.js";
|
|
7
7
|
import "./chunk-3RG5ZIWI.js";
|
|
8
8
|
export {
|
|
9
9
|
InterruptPropagator,
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkVH5N6E54cjs = require('./chunk-VH5N6E54.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
|
|
15
|
-
require('./chunk-
|
|
15
|
+
require('./chunk-RV7JIIDG.cjs');
|
|
16
16
|
require('./chunk-OBGZSXTJ.cjs');
|
|
17
17
|
|
|
18
18
|
// src/internal/instrumentation/mcp/instrumentation.ts
|
|
@@ -387,14 +387,14 @@ function wrapOnRequest(original, tracer) {
|
|
|
387
387
|
return original.apply(this, args);
|
|
388
388
|
}
|
|
389
389
|
const method = request.method;
|
|
390
|
-
if (method === METHOD_TOOLS_CALL &&
|
|
390
|
+
if (method === METHOD_TOOLS_CALL && _chunkVH5N6E54cjs.isSessionToolCall.call(void 0, request)) {
|
|
391
391
|
return answerSessionToolCall(this, request, tracer, args, original);
|
|
392
392
|
}
|
|
393
393
|
const handler = _nullishCoalesce(handlers.get(method), () => ( this.fallbackRequestHandler));
|
|
394
394
|
if (!handler) {
|
|
395
395
|
return original.apply(this, args);
|
|
396
396
|
}
|
|
397
|
-
const tracking =
|
|
397
|
+
const tracking = _chunkVH5N6E54cjs.isEnabled.call(void 0, ) && method === METHOD_TOOLS_CALL ? _chunkVH5N6E54cjs.popTrackingArguments.call(void 0, request) : {};
|
|
398
398
|
const started = safeStartServerSpan(tracer, request, this, tracking);
|
|
399
399
|
if (!started) {
|
|
400
400
|
return original.apply(this, args);
|
|
@@ -404,9 +404,9 @@ function wrapOnRequest(original, tracer) {
|
|
|
404
404
|
if (method === METHOD_TOOLS_LIST) {
|
|
405
405
|
hooks.onResult = (result) => {
|
|
406
406
|
let advertised = result;
|
|
407
|
-
if (
|
|
407
|
+
if (_chunkVH5N6E54cjs.isEnabled.call(void 0, )) {
|
|
408
408
|
try {
|
|
409
|
-
advertised =
|
|
409
|
+
advertised = _chunkVH5N6E54cjs.patchListToolsResult.call(void 0, result);
|
|
410
410
|
} catch (error) {
|
|
411
411
|
_chunkWC573FCIcjs.logger.warn(
|
|
412
412
|
`Brizz MCP: failed to patch tools/list schemas: ${String(error)}`
|
|
@@ -417,7 +417,7 @@ function wrapOnRequest(original, tracer) {
|
|
|
417
417
|
try {
|
|
418
418
|
emitSchemaSpansFromListResponse(
|
|
419
419
|
advertised,
|
|
420
|
-
|
|
420
|
+
_chunkVH5N6E54cjs.resolveTransportSessionId.call(void 0, this),
|
|
421
421
|
tracer
|
|
422
422
|
);
|
|
423
423
|
} catch (error) {
|
|
@@ -430,7 +430,7 @@ function wrapOnRequest(original, tracer) {
|
|
|
430
430
|
}
|
|
431
431
|
if (method !== METHOD_TOOLS_CALL) {
|
|
432
432
|
hooks.onError = () => {
|
|
433
|
-
|
|
433
|
+
_chunkVH5N6E54cjs.stampAndPropagateSession.call(void 0, span, _chunkVH5N6E54cjs.resolveSessionId.call(void 0, this, spanCtx), spanCtx);
|
|
434
434
|
};
|
|
435
435
|
}
|
|
436
436
|
const wrappedHandler = (req, extra) => _api.context.with(
|
|
@@ -464,7 +464,7 @@ function answerSessionToolCall(protocol, request, tracer, args, original) {
|
|
|
464
464
|
if (!handlers) {
|
|
465
465
|
return original.apply(protocol, args);
|
|
466
466
|
}
|
|
467
|
-
const { id, result } =
|
|
467
|
+
const { id, result } = _chunkVH5N6E54cjs.sessionToolResult.call(void 0, );
|
|
468
468
|
const started = safeStartServerSpan(tracer, request, protocol, { sessionId: id });
|
|
469
469
|
const handler = () => started ? _api.context.with(started.spanCtx, () => result) : result;
|
|
470
470
|
const hadEntry = handlers.has(METHOD_TOOLS_CALL);
|
|
@@ -554,8 +554,8 @@ function safeStartServerSpan(tracer, request, protocol, tracking = {}) {
|
|
|
554
554
|
parentCtx
|
|
555
555
|
);
|
|
556
556
|
applyServerRequestAttributes(span, request, protocol);
|
|
557
|
-
const resolved = request.method === METHOD_TOOLS_CALL ? _nullishCoalesce(tracking.sessionId, () => (
|
|
558
|
-
const { context: sessCtx } =
|
|
557
|
+
const resolved = request.method === METHOD_TOOLS_CALL ? _nullishCoalesce(tracking.sessionId, () => ( _chunkVH5N6E54cjs.resolveSessionId.call(void 0, protocol, parentCtx))) : void 0;
|
|
558
|
+
const { context: sessCtx } = _chunkVH5N6E54cjs.stampAndPropagateSession.call(void 0,
|
|
559
559
|
span,
|
|
560
560
|
resolved,
|
|
561
561
|
parentCtx,
|
|
@@ -611,7 +611,7 @@ function safeEnd(span) {
|
|
|
611
611
|
|
|
612
612
|
// src/internal/instrumentation/mcp/version.ts
|
|
613
613
|
var INSTRUMENTATION_NAME = "@brizz/sdk/mcp";
|
|
614
|
-
var INSTRUMENTATION_VERSION =
|
|
614
|
+
var INSTRUMENTATION_VERSION = _chunkVH5N6E54cjs.getSDKVersion.call(void 0, );
|
|
615
615
|
|
|
616
616
|
// src/internal/instrumentation/mcp/instrumentation.ts
|
|
617
617
|
var PROTOCOL_MODULE_NAME = "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
resolveTransportSessionId,
|
|
9
9
|
sessionToolResult,
|
|
10
10
|
stampAndPropagateSession
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-STM7QUQP.js";
|
|
12
12
|
import {
|
|
13
13
|
logger
|
|
14
14
|
} from "./chunk-Y4HNUX3Q.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-GUKWVI53.js";
|
|
16
16
|
import "./chunk-3RG5ZIWI.js";
|
|
17
17
|
|
|
18
18
|
// src/internal/instrumentation/mcp/instrumentation.ts
|
|
@@ -54,7 +54,10 @@ export declare const METRIC_MIN = "brizz.internal.metric.min";
|
|
|
54
54
|
export declare const METRIC_MAX = "brizz.internal.metric.max";
|
|
55
55
|
export declare const METRIC_TIMESTAMP = "brizz.internal.metric.timestamp";
|
|
56
56
|
export declare const METRIC_TRACE_ID = "brizz.internal.metric.trace_id";
|
|
57
|
+
export declare const METRIC_SCOPE = "brizz.internal.metric.scope";
|
|
57
58
|
export declare const METRIC_ATTRIBUTE_PREFIX = "brizz.internal.metric.attribute.";
|
|
58
59
|
export declare const RESERVED_METRIC_NAMES: Set<string>;
|
|
59
60
|
export declare const METRIC_POLARITY_POSITIVE = "positive";
|
|
60
61
|
export declare const METRIC_POLARITY_NEGATIVE = "negative";
|
|
62
|
+
export declare const METRIC_SCOPE_SESSION = "session";
|
|
63
|
+
export declare const METRIC_SCOPE_TRACE = "trace";
|
|
@@ -134,6 +134,7 @@ export declare function recordMetric(options: {
|
|
|
134
134
|
sessionId?: string;
|
|
135
135
|
traceId?: string;
|
|
136
136
|
serviceName?: string;
|
|
137
|
+
scope?: 'session' | 'trace';
|
|
137
138
|
}): void;
|
|
138
139
|
export declare function startSession<T>(sessionId: string, callback: (session: Session) => T, extraProperties?: Record<string, AttributeValue>, options?: {
|
|
139
140
|
mode?: 'default' | 'title';
|
|
@@ -54,7 +54,10 @@ export declare const METRIC_MIN = "brizz.internal.metric.min";
|
|
|
54
54
|
export declare const METRIC_MAX = "brizz.internal.metric.max";
|
|
55
55
|
export declare const METRIC_TIMESTAMP = "brizz.internal.metric.timestamp";
|
|
56
56
|
export declare const METRIC_TRACE_ID = "brizz.internal.metric.trace_id";
|
|
57
|
+
export declare const METRIC_SCOPE = "brizz.internal.metric.scope";
|
|
57
58
|
export declare const METRIC_ATTRIBUTE_PREFIX = "brizz.internal.metric.attribute.";
|
|
58
59
|
export declare const RESERVED_METRIC_NAMES: Set<string>;
|
|
59
60
|
export declare const METRIC_POLARITY_POSITIVE = "positive";
|
|
60
61
|
export declare const METRIC_POLARITY_NEGATIVE = "negative";
|
|
62
|
+
export declare const METRIC_SCOPE_SESSION = "session";
|
|
63
|
+
export declare const METRIC_SCOPE_TRACE = "trace";
|
|
@@ -134,6 +134,7 @@ export declare function recordMetric(options: {
|
|
|
134
134
|
sessionId?: string;
|
|
135
135
|
traceId?: string;
|
|
136
136
|
serviceName?: string;
|
|
137
|
+
scope?: 'session' | 'trace';
|
|
137
138
|
}): void;
|
|
138
139
|
export declare function startSession<T>(sessionId: string, callback: (session: Session) => T, extraProperties?: Record<string, AttributeValue>, options?: {
|
|
139
140
|
mode?: 'default' | 'title';
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _chunkELLCNMLIcjs = require('./chunk-ELLCNMLI.cjs');
|
|
6
|
-
require('./chunk-GMZQ6N77.cjs');
|
|
7
|
-
require('./chunk-OBGZSXTJ.cjs');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.InterruptPropagator = _chunkELLCNMLIcjs.InterruptPropagator; exports._resetInterruptState = _chunkELLCNMLIcjs._resetInterruptState; exports.createInterruptIntegration = _chunkELLCNMLIcjs.createInterruptIntegration;
|