@brizz/sdk 0.1.50 → 0.1.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-VH5N6E54.cjs → chunk-2T7OEV33.cjs} +1 -1
- package/dist/{chunk-STM7QUQP.js → chunk-W7VSQ4KQ.js} +1 -1
- package/dist/index.cjs +124 -73
- package/dist/index.js +64 -13
- package/dist/{mcp-3URJU7OY.cjs → mcp-MVZSP5NE.cjs} +11 -11
- package/dist/{mcp-AOBKXJND.js → mcp-TOZFTC5Y.js} +1 -1
- package/package.json +35 -35
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk2T7OEV33cjs = require('./chunk-2T7OEV33.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -104,7 +104,7 @@ var _api = require('@opentelemetry/api');
|
|
|
104
104
|
|
|
105
105
|
// src/internal/instrumentation/langgraph/attributes.ts
|
|
106
106
|
var INSTRUMENTATION_NAME = "@brizz/sdk/langgraph";
|
|
107
|
-
var INSTRUMENTATION_VERSION =
|
|
107
|
+
var INSTRUMENTATION_VERSION = _chunk2T7OEV33cjs.getSDKVersion.call(void 0, );
|
|
108
108
|
var MODULE_NAME = "@langchain/langgraph";
|
|
109
109
|
var SUPPORTED_VERSIONS = [">=0.2.0 <2"];
|
|
110
110
|
function isSupportedVersion(version) {
|
|
@@ -468,7 +468,7 @@ function loadGenAIInstrumentations() {
|
|
|
468
468
|
function loadMCPInstrumentation() {
|
|
469
469
|
void (async () => {
|
|
470
470
|
try {
|
|
471
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
471
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-MVZSP5NE.cjs")));
|
|
472
472
|
const mcp = new MCPInstrumentation({ exceptionLogger });
|
|
473
473
|
_instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp] });
|
|
474
474
|
_chunkWC573FCIcjs.logger.debug("Auto-loaded MCP instrumentation");
|
|
@@ -753,6 +753,9 @@ var OMITTED_KEYS = /* @__PURE__ */ new Set([
|
|
|
753
753
|
_chunkRV7JIIDGcjs.ORGANIZATION_NAME,
|
|
754
754
|
_chunkRV7JIIDGcjs.ORGANIZATION_DOMAIN
|
|
755
755
|
]);
|
|
756
|
+
var TOOL_CALL_ID_METADATA_KEY = "brizz_tool_call_id";
|
|
757
|
+
var TOOL_ID = "tool.id";
|
|
758
|
+
var TOOL_CALL_ID_ARG = 7;
|
|
756
759
|
function runMetadataFromContext() {
|
|
757
760
|
const bag = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
|
|
758
761
|
if (!bag) {
|
|
@@ -792,9 +795,32 @@ function patchCallbackManagerModule(module2) {
|
|
|
792
795
|
}
|
|
793
796
|
return manager;
|
|
794
797
|
};
|
|
798
|
+
patchToolStart(statics["prototype"]);
|
|
795
799
|
statics[PATCHED_MARKER] = true;
|
|
796
800
|
return true;
|
|
797
801
|
}
|
|
802
|
+
function patchToolStart(prototype) {
|
|
803
|
+
const proto = prototype;
|
|
804
|
+
const original = _optionalChain([proto, 'optionalAccess', _23 => _23["handleToolStart"]]);
|
|
805
|
+
if (!proto || typeof original !== "function") {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
const handleToolStart = original;
|
|
809
|
+
proto["handleToolStart"] = function(...args) {
|
|
810
|
+
try {
|
|
811
|
+
const toolCallId = args[TOOL_CALL_ID_ARG];
|
|
812
|
+
if (typeof toolCallId === "string" && toolCallId !== "") {
|
|
813
|
+
this.addMetadata({ [TOOL_CALL_ID_METADATA_KEY]: toolCallId }, false);
|
|
814
|
+
} else if (this.metadata && TOOL_CALL_ID_METADATA_KEY in this.metadata) {
|
|
815
|
+
const rest = { ...this.metadata };
|
|
816
|
+
delete rest[TOOL_CALL_ID_METADATA_KEY];
|
|
817
|
+
this.metadata = rest;
|
|
818
|
+
}
|
|
819
|
+
} catch (e3) {
|
|
820
|
+
}
|
|
821
|
+
return handleToolStart.apply(this, args);
|
|
822
|
+
};
|
|
823
|
+
}
|
|
798
824
|
function patchInstalledCallbackManager() {
|
|
799
825
|
void (async () => {
|
|
800
826
|
try {
|
|
@@ -813,23 +839,28 @@ function patchInstalledCallbackManager() {
|
|
|
813
839
|
function restampLangChainSpan(span) {
|
|
814
840
|
try {
|
|
815
841
|
const scope = span.instrumentationScope;
|
|
816
|
-
if (_optionalChain([scope, 'optionalAccess',
|
|
842
|
+
if (_optionalChain([scope, 'optionalAccess', _24 => _24.name]) !== SCOPE_NAME) {
|
|
817
843
|
return;
|
|
818
844
|
}
|
|
819
845
|
const attrs = span.attributes;
|
|
820
846
|
const metadata = attrs["metadata"];
|
|
821
|
-
if (typeof metadata !== "string" || !metadata.includes(`"${_chunkRV7JIIDGcjs.BRIZZ}.`)) {
|
|
847
|
+
if (typeof metadata !== "string" || !metadata.includes(`"${_chunkRV7JIIDGcjs.BRIZZ}.`) && !metadata.includes(`"${TOOL_CALL_ID_METADATA_KEY}"`)) {
|
|
822
848
|
return;
|
|
823
849
|
}
|
|
824
850
|
const parsed = JSON.parse(metadata);
|
|
825
851
|
if (typeof parsed !== "object" || parsed === null) {
|
|
826
852
|
return;
|
|
827
853
|
}
|
|
828
|
-
|
|
854
|
+
const entries = parsed;
|
|
855
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
829
856
|
if (key.startsWith(`${_chunkRV7JIIDGcjs.BRIZZ}.`) && value !== null && value !== void 0) {
|
|
830
857
|
attrs[key] = String(value);
|
|
831
858
|
}
|
|
832
859
|
}
|
|
860
|
+
const toolCallId = entries[TOOL_CALL_ID_METADATA_KEY];
|
|
861
|
+
if (typeof toolCallId === "string" && toolCallId !== "" && attrs[TOOL_ID] === void 0) {
|
|
862
|
+
attrs[TOOL_ID] = toolCallId;
|
|
863
|
+
}
|
|
833
864
|
} catch (error) {
|
|
834
865
|
_chunkWC573FCIcjs.logger.debug("Skipped LangChain span re-stamp", { err: error });
|
|
835
866
|
}
|
|
@@ -868,7 +899,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
868
899
|
* @private
|
|
869
900
|
*/
|
|
870
901
|
loadManualInstrumentations(instrumentations, exceptionLogger2) {
|
|
871
|
-
if (_optionalChain([this, 'access',
|
|
902
|
+
if (_optionalChain([this, 'access', _25 => _25.manualModules, 'optionalAccess', _26 => _26.openAI])) {
|
|
872
903
|
try {
|
|
873
904
|
const openAIInst = new (0, _openinferenceinstrumentationopenai.OpenAIInstrumentation)();
|
|
874
905
|
openAIInst.manuallyInstrument(this.manualModules.openAI);
|
|
@@ -879,18 +910,18 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
879
910
|
}
|
|
880
911
|
}
|
|
881
912
|
const instrumentationConfigs = [
|
|
882
|
-
{ class: _instrumentationanthropic.AnthropicInstrumentation, name: "Anthropic", module: _optionalChain([this, 'access',
|
|
883
|
-
{ class: _instrumentationcohere.CohereInstrumentation, name: "Cohere", module: _optionalChain([this, 'access',
|
|
884
|
-
{ class: _instrumentationbedrock.BedrockInstrumentation, name: "Bedrock", module: _optionalChain([this, 'access',
|
|
885
|
-
{ class: _instrumentationpinecone.PineconeInstrumentation, name: "Pinecone", module: _optionalChain([this, 'access',
|
|
913
|
+
{ class: _instrumentationanthropic.AnthropicInstrumentation, name: "Anthropic", module: _optionalChain([this, 'access', _27 => _27.manualModules, 'optionalAccess', _28 => _28.anthropic]) },
|
|
914
|
+
{ class: _instrumentationcohere.CohereInstrumentation, name: "Cohere", module: _optionalChain([this, 'access', _29 => _29.manualModules, 'optionalAccess', _30 => _30.cohere]) },
|
|
915
|
+
{ class: _instrumentationbedrock.BedrockInstrumentation, name: "Bedrock", module: _optionalChain([this, 'access', _31 => _31.manualModules, 'optionalAccess', _32 => _32.bedrock]) },
|
|
916
|
+
{ class: _instrumentationpinecone.PineconeInstrumentation, name: "Pinecone", module: _optionalChain([this, 'access', _33 => _33.manualModules, 'optionalAccess', _34 => _34.pinecone]) },
|
|
886
917
|
{
|
|
887
918
|
class: _instrumentationllamaindex.LlamaIndexInstrumentation,
|
|
888
919
|
name: "LlamaIndex",
|
|
889
|
-
module: _optionalChain([this, 'access',
|
|
920
|
+
module: _optionalChain([this, 'access', _35 => _35.manualModules, 'optionalAccess', _36 => _36.llamaindex])
|
|
890
921
|
},
|
|
891
|
-
{ class: _instrumentationchromadb.ChromaDBInstrumentation, name: "ChromaDB", module: _optionalChain([this, 'access',
|
|
892
|
-
{ class: _instrumentationqdrant.QdrantInstrumentation, name: "Qdrant", module: _optionalChain([this, 'access',
|
|
893
|
-
{ class: _instrumentationtogether.TogetherInstrumentation, name: "Together", module: _optionalChain([this, 'access',
|
|
922
|
+
{ class: _instrumentationchromadb.ChromaDBInstrumentation, name: "ChromaDB", module: _optionalChain([this, 'access', _37 => _37.manualModules, 'optionalAccess', _38 => _38.chromadb]) },
|
|
923
|
+
{ class: _instrumentationqdrant.QdrantInstrumentation, name: "Qdrant", module: _optionalChain([this, 'access', _39 => _39.manualModules, 'optionalAccess', _40 => _40.qdrant]) },
|
|
924
|
+
{ class: _instrumentationtogether.TogetherInstrumentation, name: "Together", module: _optionalChain([this, 'access', _41 => _41.manualModules, 'optionalAccess', _42 => _42.together]) }
|
|
894
925
|
];
|
|
895
926
|
for (const config of instrumentationConfigs) {
|
|
896
927
|
if (!config.module) {
|
|
@@ -906,7 +937,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
906
937
|
instrumentations.push(instrumentation);
|
|
907
938
|
}
|
|
908
939
|
}
|
|
909
|
-
if (_optionalChain([this, 'access',
|
|
940
|
+
if (_optionalChain([this, 'access', _43 => _43.manualModules, 'optionalAccess', _44 => _44.langchain, 'optionalAccess', _45 => _45.callbackManagerModule])) {
|
|
910
941
|
const callbackManagerModule = this.manualModules.langchain.callbackManagerModule;
|
|
911
942
|
void (async () => {
|
|
912
943
|
try {
|
|
@@ -922,7 +953,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
922
953
|
}
|
|
923
954
|
})();
|
|
924
955
|
}
|
|
925
|
-
if (_optionalChain([this, 'access',
|
|
956
|
+
if (_optionalChain([this, 'access', _46 => _46.manualModules, 'optionalAccess', _47 => _47.langgraph])) {
|
|
926
957
|
try {
|
|
927
958
|
new LangGraphInstrumentation().manuallyInstrument(this.manualModules.langgraph);
|
|
928
959
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for LangGraph");
|
|
@@ -930,7 +961,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
930
961
|
_chunkWC573FCIcjs.logger.error(`Failed to apply LangGraph instrumentation: ${String(error)}`);
|
|
931
962
|
}
|
|
932
963
|
}
|
|
933
|
-
if (_optionalChain([this, 'access',
|
|
964
|
+
if (_optionalChain([this, 'access', _48 => _48.manualModules, 'optionalAccess', _49 => _49.google_vertexai])) {
|
|
934
965
|
const vertexModule = this.manualModules.google_vertexai;
|
|
935
966
|
void (async () => {
|
|
936
967
|
try {
|
|
@@ -945,7 +976,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
945
976
|
}
|
|
946
977
|
})();
|
|
947
978
|
}
|
|
948
|
-
if (_optionalChain([this, 'access',
|
|
979
|
+
if (_optionalChain([this, 'access', _50 => _50.manualModules, 'optionalAccess', _51 => _51.google_genai])) {
|
|
949
980
|
const genaiModule = this.manualModules.google_genai;
|
|
950
981
|
void (async () => {
|
|
951
982
|
try {
|
|
@@ -960,11 +991,11 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
960
991
|
}
|
|
961
992
|
})();
|
|
962
993
|
}
|
|
963
|
-
if (_optionalChain([this, 'access',
|
|
994
|
+
if (_optionalChain([this, 'access', _52 => _52.manualModules, 'optionalAccess', _53 => _53.mcp])) {
|
|
964
995
|
const mcpModules = this.manualModules.mcp;
|
|
965
996
|
void (async () => {
|
|
966
997
|
try {
|
|
967
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
998
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-MVZSP5NE.cjs")));
|
|
968
999
|
const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
|
|
969
1000
|
instrumentation.manuallyInstrument(mcpModules);
|
|
970
1001
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
|
|
@@ -1016,7 +1047,7 @@ function setCurrentSpanCustomProperties(properties) {
|
|
|
1016
1047
|
for (const [key, value] of Object.entries(properties)) {
|
|
1017
1048
|
try {
|
|
1018
1049
|
current.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${key}`, value);
|
|
1019
|
-
} catch (
|
|
1050
|
+
} catch (e4) {
|
|
1020
1051
|
}
|
|
1021
1052
|
}
|
|
1022
1053
|
}
|
|
@@ -1040,15 +1071,15 @@ function withProperties(properties, fn, thisArg) {
|
|
|
1040
1071
|
function propagatePropertiesImperatively(properties, base = _api.context.active()) {
|
|
1041
1072
|
try {
|
|
1042
1073
|
const manager = _api.context;
|
|
1043
|
-
const mgr = _optionalChain([manager, 'access',
|
|
1044
|
-
const store = _optionalChain([mgr, 'optionalAccess',
|
|
1074
|
+
const mgr = _optionalChain([manager, 'access', _54 => _54._getContextManager, 'optionalCall', _55 => _55()]);
|
|
1075
|
+
const store = _optionalChain([mgr, 'optionalAccess', _56 => _56._asyncLocalStorage]);
|
|
1045
1076
|
if (!store || typeof store.enterWith !== "function") {
|
|
1046
1077
|
return;
|
|
1047
1078
|
}
|
|
1048
1079
|
const prev = base.getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
|
|
1049
1080
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
1050
1081
|
store.enterWith(base.setValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY, merged));
|
|
1051
|
-
} catch (
|
|
1082
|
+
} catch (e5) {
|
|
1052
1083
|
}
|
|
1053
1084
|
}
|
|
1054
1085
|
function setUser(user) {
|
|
@@ -1143,7 +1174,7 @@ function withServiceName(name, fn, thisArg) {
|
|
|
1143
1174
|
}
|
|
1144
1175
|
function resolveServiceNameFromContext() {
|
|
1145
1176
|
const props = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
|
|
1146
|
-
return _optionalChain([props, 'optionalAccess',
|
|
1177
|
+
return _optionalChain([props, 'optionalAccess', _57 => _57[_chunkRV7JIIDGcjs.SERVICE_NAME]]);
|
|
1147
1178
|
}
|
|
1148
1179
|
function userProperties(user) {
|
|
1149
1180
|
const properties = { [_chunkRV7JIIDGcjs.USER_ID]: user.id };
|
|
@@ -1210,7 +1241,7 @@ function withMessageId(id, fn, thisArg) {
|
|
|
1210
1241
|
}
|
|
1211
1242
|
function inheritedMuteTools() {
|
|
1212
1243
|
const properties = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
|
|
1213
|
-
return _optionalChain([properties, 'optionalAccess',
|
|
1244
|
+
return _optionalChain([properties, 'optionalAccess', _58 => _58[_chunkRV7JIIDGcjs.MUTE_TOOLS]]);
|
|
1214
1245
|
}
|
|
1215
1246
|
function muteProperties(options) {
|
|
1216
1247
|
const { input = true, output = true, tools = output } = options;
|
|
@@ -1372,7 +1403,7 @@ var Session = (_class2 = class {
|
|
|
1372
1403
|
* (free-form category, defaults to `'generic'`)
|
|
1373
1404
|
*/
|
|
1374
1405
|
addExternalLink(url, options) {
|
|
1375
|
-
emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess',
|
|
1406
|
+
emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess', _59 => _59.title]), _optionalChain([options, 'optionalAccess', _60 => _60.linkType]));
|
|
1376
1407
|
}
|
|
1377
1408
|
}, _class2);
|
|
1378
1409
|
var SessionTitle = class {
|
|
@@ -1398,11 +1429,11 @@ function resolveSessionIdFromContext() {
|
|
|
1398
1429
|
return active.sessionId;
|
|
1399
1430
|
}
|
|
1400
1431
|
const props = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
|
|
1401
|
-
return _optionalChain([props, 'optionalAccess',
|
|
1432
|
+
return _optionalChain([props, 'optionalAccess', _61 => _61[_chunkRV7JIIDGcjs.SESSION_ID]]);
|
|
1402
1433
|
}
|
|
1403
1434
|
function resolveMessageIdFromContext() {
|
|
1404
1435
|
const props = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
|
|
1405
|
-
return _optionalChain([props, 'optionalAccess',
|
|
1436
|
+
return _optionalChain([props, 'optionalAccess', _62 => _62[_chunkRV7JIIDGcjs.MESSAGE_ID]]);
|
|
1406
1437
|
}
|
|
1407
1438
|
function emitExternalLink(sessionId, url, title, linkType) {
|
|
1408
1439
|
try {
|
|
@@ -1416,30 +1447,30 @@ function emitExternalLink(sessionId, url, title, linkType) {
|
|
|
1416
1447
|
}
|
|
1417
1448
|
}
|
|
1418
1449
|
function addExternalLink(url, options) {
|
|
1419
|
-
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1450
|
+
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _63 => _63.sessionId]), () => ( resolveSessionIdFromContext()));
|
|
1420
1451
|
if (!sessionId) {
|
|
1421
1452
|
_chunkWC573FCIcjs.logger.warn(
|
|
1422
1453
|
"addExternalLink called without a resolvable session id; link dropped. Pass options.sessionId or call inside a startSession/callWithSessionId scope."
|
|
1423
1454
|
);
|
|
1424
1455
|
return;
|
|
1425
1456
|
}
|
|
1426
|
-
emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess',
|
|
1457
|
+
emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _64 => _64.title]), _optionalChain([options, 'optionalAccess', _65 => _65.linkType]));
|
|
1427
1458
|
}
|
|
1428
1459
|
function recordFeedback(type, options) {
|
|
1429
1460
|
const eventAttributes = { [_chunkRV7JIIDGcjs.FEEDBACK_TYPE]: type };
|
|
1430
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1461
|
+
if (_optionalChain([options, 'optionalAccess', _66 => _66.score]) !== void 0) {
|
|
1431
1462
|
eventAttributes[_chunkRV7JIIDGcjs.FEEDBACK_SCORE] = options.score;
|
|
1432
1463
|
}
|
|
1433
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1464
|
+
if (_optionalChain([options, 'optionalAccess', _67 => _67.reason]) !== void 0) {
|
|
1434
1465
|
eventAttributes[_chunkRV7JIIDGcjs.FEEDBACK_REASON] = options.reason;
|
|
1435
1466
|
}
|
|
1436
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1467
|
+
if (_optionalChain([options, 'optionalAccess', _68 => _68.comment]) !== void 0) {
|
|
1437
1468
|
eventAttributes[_chunkRV7JIIDGcjs.FEEDBACK_COMMENT] = options.comment;
|
|
1438
1469
|
}
|
|
1439
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1470
|
+
if (_optionalChain([options, 'optionalAccess', _69 => _69.source]) !== void 0) {
|
|
1440
1471
|
eventAttributes[_chunkRV7JIIDGcjs.FEEDBACK_SOURCE] = options.source;
|
|
1441
1472
|
}
|
|
1442
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1473
|
+
if (_optionalChain([options, 'optionalAccess', _70 => _70.attributes])) {
|
|
1443
1474
|
for (const [key, value] of Object.entries(options.attributes)) {
|
|
1444
1475
|
const k = `${_chunkRV7JIIDGcjs.FEEDBACK_ATTR_PREFIX}${key}`;
|
|
1445
1476
|
if (eventAttributes[k] === void 0) {
|
|
@@ -1447,8 +1478,8 @@ function recordFeedback(type, options) {
|
|
|
1447
1478
|
}
|
|
1448
1479
|
}
|
|
1449
1480
|
}
|
|
1450
|
-
const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1451
|
-
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1481
|
+
const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _71 => _71.messageId]), () => ( resolveMessageIdFromContext()));
|
|
1482
|
+
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _72 => _72.sessionId]), () => ( resolveSessionIdFromContext()));
|
|
1452
1483
|
if (messageId === void 0 && sessionId === void 0) {
|
|
1453
1484
|
_chunkWC573FCIcjs.logger.warn(
|
|
1454
1485
|
"recordFeedback called with no resolvable message id or session id; the feedback cannot be attributed to a message or conversation. Pass options.messageId / options.sessionId or call inside a startSession/callWithMessageId scope."
|
|
@@ -1479,7 +1510,7 @@ function recordMetric(options) {
|
|
|
1479
1510
|
try {
|
|
1480
1511
|
recordMetricImpl(options);
|
|
1481
1512
|
} catch (error) {
|
|
1482
|
-
_chunkWC573FCIcjs.logger.warn(`recordMetric(${JSON.stringify(_optionalChain([options, 'optionalAccess',
|
|
1513
|
+
_chunkWC573FCIcjs.logger.warn(`recordMetric(${JSON.stringify(_optionalChain([options, 'optionalAccess', _73 => _73.name]))}) failed; metric dropped.`, error);
|
|
1483
1514
|
}
|
|
1484
1515
|
}
|
|
1485
1516
|
function recordMetricImpl(options) {
|
|
@@ -1599,7 +1630,7 @@ function recordMetricImpl(options) {
|
|
|
1599
1630
|
eventAttributes[_chunkRV7JIIDGcjs.METRIC_TRACE_ID] = traceId;
|
|
1600
1631
|
}
|
|
1601
1632
|
if (scope === _chunkRV7JIIDGcjs.METRIC_SCOPE_TRACE && traceId === void 0) {
|
|
1602
|
-
const spanContext = _optionalChain([_api.trace, 'access',
|
|
1633
|
+
const spanContext = _optionalChain([_api.trace, 'access', _74 => _74.getActiveSpan, 'call', _75 => _75(), 'optionalAccess', _76 => _76.spanContext, 'call', _77 => _77()]);
|
|
1603
1634
|
if (!spanContext || !_api.isSpanContextValid.call(void 0, spanContext)) {
|
|
1604
1635
|
_chunkWC573FCIcjs.logger.warn(
|
|
1605
1636
|
`recordMetric(${name}) called with scope 'trace' but no trace; metric dropped. Pass options.traceId, or call inside the span of the trace being scored.`
|
|
@@ -1637,7 +1668,7 @@ function recordMetricImpl(options) {
|
|
|
1637
1668
|
}
|
|
1638
1669
|
}
|
|
1639
1670
|
function startSession(sessionId, callback, extraProperties, options) {
|
|
1640
|
-
const isTitle = _optionalChain([options, 'optionalAccess',
|
|
1671
|
+
const isTitle = _optionalChain([options, 'optionalAccess', _78 => _78.mode]) === "title";
|
|
1641
1672
|
const spanName = isTitle ? _chunkRV7JIIDGcjs.SESSION_TITLE_SPAN_NAME : _chunkRV7JIIDGcjs.SESSION_SPAN_NAME;
|
|
1642
1673
|
const tracer = _api.trace.getTracer("@brizz/sdk");
|
|
1643
1674
|
return tracer.startActiveSpan(spanName, (span) => {
|
|
@@ -1686,7 +1717,7 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
1686
1717
|
});
|
|
1687
1718
|
}
|
|
1688
1719
|
function startSessionTitle(callback, options) {
|
|
1689
|
-
const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1720
|
+
const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _79 => _79.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _80 => _80(), 'optionalAccess', _81 => _81.sessionId])));
|
|
1690
1721
|
const tracer = _api.trace.getTracer("@brizz/sdk");
|
|
1691
1722
|
return tracer.startActiveSpan(_chunkRV7JIIDGcjs.SESSION_TITLE_SPAN_NAME, (span) => {
|
|
1692
1723
|
if (resolvedSessionId) {
|
|
@@ -2158,7 +2189,7 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
|
|
|
2158
2189
|
this.config = config;
|
|
2159
2190
|
}
|
|
2160
2191
|
onEmit(logRecord) {
|
|
2161
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
2192
|
+
const maskingConfig = _optionalChain([this, 'access', _82 => _82.config, 'access', _83 => _83.masking, 'optionalAccess', _84 => _84.eventMasking]);
|
|
2162
2193
|
if (maskingConfig) {
|
|
2163
2194
|
maskLog(logRecord, maskingConfig);
|
|
2164
2195
|
}
|
|
@@ -2178,7 +2209,7 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
|
|
|
2178
2209
|
this.config = config;
|
|
2179
2210
|
}
|
|
2180
2211
|
onEmit(logRecord) {
|
|
2181
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
2212
|
+
const maskingConfig = _optionalChain([this, 'access', _85 => _85.config, 'access', _86 => _86.masking, 'optionalAccess', _87 => _87.eventMasking]);
|
|
2182
2213
|
if (maskingConfig) {
|
|
2183
2214
|
maskLog(logRecord, maskingConfig);
|
|
2184
2215
|
}
|
|
@@ -2279,14 +2310,14 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
|
|
|
2279
2310
|
_chunkWC573FCIcjs.logger.debug("Creating logger provider", {
|
|
2280
2311
|
serviceName,
|
|
2281
2312
|
disableBatch: config.disableBatch,
|
|
2282
|
-
hasMasking: !!_optionalChain([config, 'access',
|
|
2313
|
+
hasMasking: !!_optionalChain([config, 'access', _88 => _88.masking, 'optionalAccess', _89 => _89.eventMasking])
|
|
2283
2314
|
});
|
|
2284
2315
|
const exporter = this.createLogExporter(config, serviceName);
|
|
2285
2316
|
const processor = config.disableBatch ? new BrizzSimpleLogRecordProcessor(exporter, config) : new BrizzBatchLogRecordProcessor(exporter, config);
|
|
2286
2317
|
const resourceAttributes = {
|
|
2287
2318
|
...config.resourceAttributes,
|
|
2288
2319
|
"service.name": serviceName,
|
|
2289
|
-
[BRIZZ_SDK_VERSION]:
|
|
2320
|
+
[BRIZZ_SDK_VERSION]: _chunk2T7OEV33cjs.getSDKVersion.call(void 0, ),
|
|
2290
2321
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2291
2322
|
};
|
|
2292
2323
|
if (config.environment) {
|
|
@@ -2535,7 +2566,7 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2535
2566
|
const resourceAttrs = {
|
|
2536
2567
|
...config.resourceAttributes,
|
|
2537
2568
|
"service.name": config.appName,
|
|
2538
|
-
[BRIZZ_SDK_VERSION]:
|
|
2569
|
+
[BRIZZ_SDK_VERSION]: _chunk2T7OEV33cjs.getSDKVersion.call(void 0, ),
|
|
2539
2570
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2540
2571
|
};
|
|
2541
2572
|
if (config.environment) {
|
|
@@ -2662,8 +2693,8 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2662
2693
|
}
|
|
2663
2694
|
async forceFlush() {
|
|
2664
2695
|
await Promise.all([
|
|
2665
|
-
_optionalChain([this, 'access',
|
|
2666
|
-
...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access',
|
|
2696
|
+
_optionalChain([this, 'access', _90 => _90._delegate, 'access', _91 => _91.forceFlush, 'optionalCall', _92 => _92()]),
|
|
2697
|
+
...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access', _93 => _93.forceFlush, 'optionalCall', _94 => _94()]))
|
|
2667
2698
|
]);
|
|
2668
2699
|
}
|
|
2669
2700
|
}, _class5);
|
|
@@ -2682,9 +2713,27 @@ function applyContextAttributes(span) {
|
|
|
2682
2713
|
}
|
|
2683
2714
|
}
|
|
2684
2715
|
}
|
|
2716
|
+
var LIBRARY_ID_ATTRIBUTES = [
|
|
2717
|
+
"mcp.request.id",
|
|
2718
|
+
"mcp.session.id",
|
|
2719
|
+
"jsonrpc.request.id",
|
|
2720
|
+
"gen_ai.response.id",
|
|
2721
|
+
"ai.response.id",
|
|
2722
|
+
// Session-id aliases the streamer copies into brizz.session.id (sessionIDAliases).
|
|
2723
|
+
"session.id",
|
|
2724
|
+
"langfuse.trace.metadata.session.id",
|
|
2725
|
+
"langfuse.trace.metadata.brizz.session.id",
|
|
2726
|
+
"langsmith.metadata.thread_id",
|
|
2727
|
+
"langsmith.metadata.session_id",
|
|
2728
|
+
"langsmith.metadata.conversation_id",
|
|
2729
|
+
"langsmith.trace.session_id"
|
|
2730
|
+
];
|
|
2731
|
+
var DEFAULT_RULE_ATTRIBUTES = String.raw`^(?!brizz\.(?!session\.(?:input|output)(?:\.context)?$|session\.title$|internal\.intent$)` + `|(?:${LIBRARY_ID_ATTRIBUTES.map((key) => key.replaceAll(".", String.raw`\.`)).join("|")})$)`;
|
|
2732
|
+
var isText = (value) => typeof value === "string" || Array.isArray(value) && value.some((item) => typeof item === "string");
|
|
2685
2733
|
var DEFAULT_MASKING_RULES = [
|
|
2686
2734
|
{
|
|
2687
2735
|
mode: "partial",
|
|
2736
|
+
attributePattern: DEFAULT_RULE_ATTRIBUTES,
|
|
2688
2737
|
patterns: DEFAULT_PII_PATTERNS
|
|
2689
2738
|
}
|
|
2690
2739
|
];
|
|
@@ -2700,7 +2749,7 @@ var BrizzSimpleSpanProcessor = class extends _sdktracebase.SimpleSpanProcessor {
|
|
|
2700
2749
|
}
|
|
2701
2750
|
onEnd(span) {
|
|
2702
2751
|
restampLangChainSpan(span);
|
|
2703
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
2752
|
+
const maskingConfig = _optionalChain([this, 'access', _95 => _95.config, 'access', _96 => _96.masking, 'optionalAccess', _97 => _97.spanMasking]);
|
|
2704
2753
|
if (maskingConfig) {
|
|
2705
2754
|
maskReadableSpan(span, maskingConfig);
|
|
2706
2755
|
}
|
|
@@ -2719,7 +2768,7 @@ var BrizzBatchSpanProcessor = class extends _sdktracebase.BatchSpanProcessor {
|
|
|
2719
2768
|
}
|
|
2720
2769
|
onEnd(span) {
|
|
2721
2770
|
restampLangChainSpan(span);
|
|
2722
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
2771
|
+
const maskingConfig = _optionalChain([this, 'access', _98 => _98.config, 'access', _99 => _99.masking, 'optionalAccess', _100 => _100.spanMasking]);
|
|
2723
2772
|
if (maskingConfig) {
|
|
2724
2773
|
maskReadableSpan(span, maskingConfig);
|
|
2725
2774
|
}
|
|
@@ -2731,17 +2780,19 @@ function maskReadableSpan(span, config) {
|
|
|
2731
2780
|
if (!attrs || Object.keys(attrs).length === 0) {
|
|
2732
2781
|
return;
|
|
2733
2782
|
}
|
|
2734
|
-
let rules = config.rules ? [...config.rules] : [];
|
|
2735
|
-
if (!config.disableDefaultRules) {
|
|
2736
|
-
rules = [...rules, ...DEFAULT_MASKING_RULES];
|
|
2737
|
-
}
|
|
2738
2783
|
try {
|
|
2739
|
-
|
|
2784
|
+
let masked = {};
|
|
2740
2785
|
for (const [k, v] of Object.entries(attrs)) {
|
|
2741
|
-
|
|
2786
|
+
masked[k] = v;
|
|
2787
|
+
}
|
|
2788
|
+
if (_optionalChain([config, 'access', _101 => _101.rules, 'optionalAccess', _102 => _102.length])) {
|
|
2789
|
+
masked = maskAttributes(masked, config.rules);
|
|
2790
|
+
}
|
|
2791
|
+
if (!config.disableDefaultRules) {
|
|
2792
|
+
const text = Object.fromEntries(Object.entries(masked).filter(([k]) => isText(attrs[k])));
|
|
2793
|
+
Object.assign(masked, maskAttributes(text, DEFAULT_MASKING_RULES));
|
|
2742
2794
|
}
|
|
2743
|
-
const
|
|
2744
|
-
const maskedEntries = Object.entries(_nullishCoalesce(masked, () => ( {})));
|
|
2795
|
+
const maskedEntries = Object.entries(masked);
|
|
2745
2796
|
for (const [k, v] of maskedEntries) {
|
|
2746
2797
|
if (attrs[k] !== v) {
|
|
2747
2798
|
attrs[k] = v;
|
|
@@ -2806,7 +2857,7 @@ var TracingModule = (_class6 = class _TracingModule {constructor() { _class6.pro
|
|
|
2806
2857
|
}
|
|
2807
2858
|
_chunkWC573FCIcjs.logger.debug("Initializing span processor", {
|
|
2808
2859
|
disableBatch: config.disableBatch,
|
|
2809
|
-
hasMasking: !!_optionalChain([config, 'access',
|
|
2860
|
+
hasMasking: !!_optionalChain([config, 'access', _103 => _103.masking, 'optionalAccess', _104 => _104.spanMasking])
|
|
2810
2861
|
});
|
|
2811
2862
|
const spanProcessor = config.disableBatch ? new BrizzSimpleSpanProcessor(this.spanExporter, config) : new BrizzBatchSpanProcessor(this.spanExporter, config);
|
|
2812
2863
|
_chunkWC573FCIcjs.logger.debug("Span processor initialized successfully");
|
|
@@ -2893,7 +2944,7 @@ function currentTraceparent() {
|
|
|
2893
2944
|
const carrier = {};
|
|
2894
2945
|
try {
|
|
2895
2946
|
_api.propagation.inject(_api.context.active(), carrier);
|
|
2896
|
-
} catch (
|
|
2947
|
+
} catch (e6) {
|
|
2897
2948
|
}
|
|
2898
2949
|
return _nullishCoalesce(carrier["traceparent"], () => ( ""));
|
|
2899
2950
|
}
|
|
@@ -2916,7 +2967,7 @@ function decodeToken(token) {
|
|
|
2916
2967
|
try {
|
|
2917
2968
|
const payload = JSON.parse(Buffer.from(token, "base64url").toString("utf8"));
|
|
2918
2969
|
return payload.id ? payload : void 0;
|
|
2919
|
-
} catch (
|
|
2970
|
+
} catch (e7) {
|
|
2920
2971
|
return void 0;
|
|
2921
2972
|
}
|
|
2922
2973
|
}
|
|
@@ -2954,7 +3005,7 @@ function resolveAgent(agent) {
|
|
|
2954
3005
|
if (decoded.traceparent) {
|
|
2955
3006
|
try {
|
|
2956
3007
|
parentContext = _api.propagation.extract(parentContext, { traceparent: decoded.traceparent });
|
|
2957
|
-
} catch (
|
|
3008
|
+
} catch (e8) {
|
|
2958
3009
|
}
|
|
2959
3010
|
}
|
|
2960
3011
|
}
|
|
@@ -3026,7 +3077,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3026
3077
|
*/
|
|
3027
3078
|
setupInstrumentation(options) {
|
|
3028
3079
|
const registry = InstrumentationRegistry.getInstance();
|
|
3029
|
-
|
|
3080
|
+
_chunk2T7OEV33cjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
|
|
3030
3081
|
patchInstalledCallbackManager();
|
|
3031
3082
|
patchInstalledLangGraph();
|
|
3032
3083
|
if (options.instrumentModules && Object.keys(options.instrumentModules).length > 0) {
|
|
@@ -3051,7 +3102,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3051
3102
|
const resourceAttributes = {
|
|
3052
3103
|
...resolvedConfig.resourceAttributes,
|
|
3053
3104
|
"service.name": resolvedConfig.appName,
|
|
3054
|
-
[BRIZZ_SDK_VERSION]:
|
|
3105
|
+
[BRIZZ_SDK_VERSION]: _chunk2T7OEV33cjs.getSDKVersion.call(void 0, ),
|
|
3055
3106
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
3056
3107
|
};
|
|
3057
3108
|
if (resolvedConfig.environment) {
|
|
@@ -3121,19 +3172,19 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3121
3172
|
try {
|
|
3122
3173
|
const tracingModule = TracingModule.getInstance();
|
|
3123
3174
|
await tracingModule.shutdown();
|
|
3124
|
-
} catch (
|
|
3175
|
+
} catch (e9) {
|
|
3125
3176
|
_chunkWC573FCIcjs.logger.debug("Tracing module already shut down or not initialized");
|
|
3126
3177
|
}
|
|
3127
3178
|
try {
|
|
3128
3179
|
const metricsModule = MetricsModule.getInstance();
|
|
3129
3180
|
metricsModule.shutdown();
|
|
3130
|
-
} catch (
|
|
3181
|
+
} catch (e10) {
|
|
3131
3182
|
_chunkWC573FCIcjs.logger.debug("Metrics module already shut down or not initialized");
|
|
3132
3183
|
}
|
|
3133
3184
|
try {
|
|
3134
3185
|
const loggingModule = LoggingModule.getInstance();
|
|
3135
3186
|
await loggingModule.shutdown();
|
|
3136
|
-
} catch (
|
|
3187
|
+
} catch (e11) {
|
|
3137
3188
|
_chunkWC573FCIcjs.logger.debug("Logging module already shut down or not initialized");
|
|
3138
3189
|
}
|
|
3139
3190
|
_chunkWC573FCIcjs.logger.info("All telemetry modules shut down successfully");
|
|
@@ -3199,10 +3250,10 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3199
3250
|
}
|
|
3200
3251
|
try {
|
|
3201
3252
|
await this.shutdownModules();
|
|
3202
|
-
await _optionalChain([this, 'access',
|
|
3203
|
-
await _optionalChain([this, 'access',
|
|
3204
|
-
await _optionalChain([this, 'access',
|
|
3205
|
-
await _optionalChain([this, 'access',
|
|
3253
|
+
await _optionalChain([this, 'access', _105 => _105._tracerProvider, 'optionalAccess', _106 => _106.forceFlush, 'call', _107 => _107()]);
|
|
3254
|
+
await _optionalChain([this, 'access', _108 => _108._tracerProvider, 'optionalAccess', _109 => _109.shutdown, 'call', _110 => _110()]);
|
|
3255
|
+
await _optionalChain([this, 'access', _111 => _111._meterProvider, 'optionalAccess', _112 => _112.forceFlush, 'call', _113 => _113()]);
|
|
3256
|
+
await _optionalChain([this, 'access', _114 => _114._meterProvider, 'optionalAccess', _115 => _115.shutdown, 'call', _116 => _116()]);
|
|
3206
3257
|
this._initialized = false;
|
|
3207
3258
|
this._tracerProvider = null;
|
|
3208
3259
|
this._meterProvider = null;
|
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-W7VSQ4KQ.js";
|
|
9
9
|
import {
|
|
10
10
|
DEFAULT_LOG_LEVEL,
|
|
11
11
|
LogLevel,
|
|
@@ -468,7 +468,7 @@ function loadGenAIInstrumentations() {
|
|
|
468
468
|
function loadMCPInstrumentation() {
|
|
469
469
|
void (async () => {
|
|
470
470
|
try {
|
|
471
|
-
const { MCPInstrumentation } = await import("./mcp-
|
|
471
|
+
const { MCPInstrumentation } = await import("./mcp-TOZFTC5Y.js");
|
|
472
472
|
const mcp = new MCPInstrumentation({ exceptionLogger });
|
|
473
473
|
registerInstrumentations({ instrumentations: [mcp] });
|
|
474
474
|
logger.debug("Auto-loaded MCP instrumentation");
|
|
@@ -753,6 +753,9 @@ var OMITTED_KEYS = /* @__PURE__ */ new Set([
|
|
|
753
753
|
ORGANIZATION_NAME,
|
|
754
754
|
ORGANIZATION_DOMAIN
|
|
755
755
|
]);
|
|
756
|
+
var TOOL_CALL_ID_METADATA_KEY = "brizz_tool_call_id";
|
|
757
|
+
var TOOL_ID = "tool.id";
|
|
758
|
+
var TOOL_CALL_ID_ARG = 7;
|
|
756
759
|
function runMetadataFromContext() {
|
|
757
760
|
const bag = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
|
|
758
761
|
if (!bag) {
|
|
@@ -792,9 +795,32 @@ function patchCallbackManagerModule(module2) {
|
|
|
792
795
|
}
|
|
793
796
|
return manager;
|
|
794
797
|
};
|
|
798
|
+
patchToolStart(statics["prototype"]);
|
|
795
799
|
statics[PATCHED_MARKER] = true;
|
|
796
800
|
return true;
|
|
797
801
|
}
|
|
802
|
+
function patchToolStart(prototype) {
|
|
803
|
+
const proto = prototype;
|
|
804
|
+
const original = proto?.["handleToolStart"];
|
|
805
|
+
if (!proto || typeof original !== "function") {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
const handleToolStart = original;
|
|
809
|
+
proto["handleToolStart"] = function(...args) {
|
|
810
|
+
try {
|
|
811
|
+
const toolCallId = args[TOOL_CALL_ID_ARG];
|
|
812
|
+
if (typeof toolCallId === "string" && toolCallId !== "") {
|
|
813
|
+
this.addMetadata({ [TOOL_CALL_ID_METADATA_KEY]: toolCallId }, false);
|
|
814
|
+
} else if (this.metadata && TOOL_CALL_ID_METADATA_KEY in this.metadata) {
|
|
815
|
+
const rest = { ...this.metadata };
|
|
816
|
+
delete rest[TOOL_CALL_ID_METADATA_KEY];
|
|
817
|
+
this.metadata = rest;
|
|
818
|
+
}
|
|
819
|
+
} catch {
|
|
820
|
+
}
|
|
821
|
+
return handleToolStart.apply(this, args);
|
|
822
|
+
};
|
|
823
|
+
}
|
|
798
824
|
function patchInstalledCallbackManager() {
|
|
799
825
|
void (async () => {
|
|
800
826
|
try {
|
|
@@ -818,18 +844,23 @@ function restampLangChainSpan(span) {
|
|
|
818
844
|
}
|
|
819
845
|
const attrs = span.attributes;
|
|
820
846
|
const metadata = attrs["metadata"];
|
|
821
|
-
if (typeof metadata !== "string" || !metadata.includes(`"${BRIZZ}.`)) {
|
|
847
|
+
if (typeof metadata !== "string" || !metadata.includes(`"${BRIZZ}.`) && !metadata.includes(`"${TOOL_CALL_ID_METADATA_KEY}"`)) {
|
|
822
848
|
return;
|
|
823
849
|
}
|
|
824
850
|
const parsed = JSON.parse(metadata);
|
|
825
851
|
if (typeof parsed !== "object" || parsed === null) {
|
|
826
852
|
return;
|
|
827
853
|
}
|
|
828
|
-
|
|
854
|
+
const entries = parsed;
|
|
855
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
829
856
|
if (key.startsWith(`${BRIZZ}.`) && value !== null && value !== void 0) {
|
|
830
857
|
attrs[key] = String(value);
|
|
831
858
|
}
|
|
832
859
|
}
|
|
860
|
+
const toolCallId = entries[TOOL_CALL_ID_METADATA_KEY];
|
|
861
|
+
if (typeof toolCallId === "string" && toolCallId !== "" && attrs[TOOL_ID] === void 0) {
|
|
862
|
+
attrs[TOOL_ID] = toolCallId;
|
|
863
|
+
}
|
|
833
864
|
} catch (error) {
|
|
834
865
|
logger.debug("Skipped LangChain span re-stamp", { err: error });
|
|
835
866
|
}
|
|
@@ -964,7 +995,7 @@ var InstrumentationRegistry = class _InstrumentationRegistry {
|
|
|
964
995
|
const mcpModules = this.manualModules.mcp;
|
|
965
996
|
void (async () => {
|
|
966
997
|
try {
|
|
967
|
-
const { MCPInstrumentation } = await import("./mcp-
|
|
998
|
+
const { MCPInstrumentation } = await import("./mcp-TOZFTC5Y.js");
|
|
968
999
|
const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
|
|
969
1000
|
instrumentation.manuallyInstrument(mcpModules);
|
|
970
1001
|
logger.debug("Manual instrumentation enabled for MCP");
|
|
@@ -2682,9 +2713,27 @@ function applyContextAttributes(span) {
|
|
|
2682
2713
|
}
|
|
2683
2714
|
}
|
|
2684
2715
|
}
|
|
2716
|
+
var LIBRARY_ID_ATTRIBUTES = [
|
|
2717
|
+
"mcp.request.id",
|
|
2718
|
+
"mcp.session.id",
|
|
2719
|
+
"jsonrpc.request.id",
|
|
2720
|
+
"gen_ai.response.id",
|
|
2721
|
+
"ai.response.id",
|
|
2722
|
+
// Session-id aliases the streamer copies into brizz.session.id (sessionIDAliases).
|
|
2723
|
+
"session.id",
|
|
2724
|
+
"langfuse.trace.metadata.session.id",
|
|
2725
|
+
"langfuse.trace.metadata.brizz.session.id",
|
|
2726
|
+
"langsmith.metadata.thread_id",
|
|
2727
|
+
"langsmith.metadata.session_id",
|
|
2728
|
+
"langsmith.metadata.conversation_id",
|
|
2729
|
+
"langsmith.trace.session_id"
|
|
2730
|
+
];
|
|
2731
|
+
var DEFAULT_RULE_ATTRIBUTES = String.raw`^(?!brizz\.(?!session\.(?:input|output)(?:\.context)?$|session\.title$|internal\.intent$)` + `|(?:${LIBRARY_ID_ATTRIBUTES.map((key) => key.replaceAll(".", String.raw`\.`)).join("|")})$)`;
|
|
2732
|
+
var isText = (value) => typeof value === "string" || Array.isArray(value) && value.some((item) => typeof item === "string");
|
|
2685
2733
|
var DEFAULT_MASKING_RULES = [
|
|
2686
2734
|
{
|
|
2687
2735
|
mode: "partial",
|
|
2736
|
+
attributePattern: DEFAULT_RULE_ATTRIBUTES,
|
|
2688
2737
|
patterns: DEFAULT_PII_PATTERNS
|
|
2689
2738
|
}
|
|
2690
2739
|
];
|
|
@@ -2731,17 +2780,19 @@ function maskReadableSpan(span, config) {
|
|
|
2731
2780
|
if (!attrs || Object.keys(attrs).length === 0) {
|
|
2732
2781
|
return;
|
|
2733
2782
|
}
|
|
2734
|
-
let rules = config.rules ? [...config.rules] : [];
|
|
2735
|
-
if (!config.disableDefaultRules) {
|
|
2736
|
-
rules = [...rules, ...DEFAULT_MASKING_RULES];
|
|
2737
|
-
}
|
|
2738
2783
|
try {
|
|
2739
|
-
|
|
2784
|
+
let masked = {};
|
|
2740
2785
|
for (const [k, v] of Object.entries(attrs)) {
|
|
2741
|
-
|
|
2786
|
+
masked[k] = v;
|
|
2787
|
+
}
|
|
2788
|
+
if (config.rules?.length) {
|
|
2789
|
+
masked = maskAttributes(masked, config.rules);
|
|
2790
|
+
}
|
|
2791
|
+
if (!config.disableDefaultRules) {
|
|
2792
|
+
const text = Object.fromEntries(Object.entries(masked).filter(([k]) => isText(attrs[k])));
|
|
2793
|
+
Object.assign(masked, maskAttributes(text, DEFAULT_MASKING_RULES));
|
|
2742
2794
|
}
|
|
2743
|
-
const
|
|
2744
|
-
const maskedEntries = Object.entries(masked ?? {});
|
|
2795
|
+
const maskedEntries = Object.entries(masked);
|
|
2745
2796
|
for (const [k, v] of maskedEntries) {
|
|
2746
2797
|
if (attrs[k] !== v) {
|
|
2747
2798
|
attrs[k] = v;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk2T7OEV33cjs = require('./chunk-2T7OEV33.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
|
|
@@ -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 && _chunk2T7OEV33cjs.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 = _chunk2T7OEV33cjs.isEnabled.call(void 0, ) && method === METHOD_TOOLS_CALL ? _chunk2T7OEV33cjs.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 (_chunk2T7OEV33cjs.isEnabled.call(void 0, )) {
|
|
408
408
|
try {
|
|
409
|
-
advertised =
|
|
409
|
+
advertised = _chunk2T7OEV33cjs.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
|
+
_chunk2T7OEV33cjs.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
|
+
_chunk2T7OEV33cjs.stampAndPropagateSession.call(void 0, span, _chunk2T7OEV33cjs.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 } = _chunk2T7OEV33cjs.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, () => ( _chunk2T7OEV33cjs.resolveSessionId.call(void 0, protocol, parentCtx))) : void 0;
|
|
558
|
+
const { context: sessCtx } = _chunk2T7OEV33cjs.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 = _chunk2T7OEV33cjs.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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brizz/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenTelemetry-based observability SDK for AI applications",
|
|
6
6
|
"keywords": [
|
|
@@ -103,35 +103,35 @@
|
|
|
103
103
|
"registry": "https://registry.npmjs.org/"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
|
-
"@ai-sdk/anthropic": "^4.0.
|
|
107
|
-
"@ai-sdk/openai": "^4.0.
|
|
108
|
-
"@ai-sdk/otel": "^1.0.
|
|
106
|
+
"@ai-sdk/anthropic": "^4.0.78",
|
|
107
|
+
"@ai-sdk/openai": "^4.0.91",
|
|
108
|
+
"@ai-sdk/otel": "^1.0.137",
|
|
109
109
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
110
|
-
"@arizeai/openinference-instrumentation-mcp": "^0.2.
|
|
111
|
-
"@babel/core": "^8.0.
|
|
112
|
-
"@babel/preset-env": "^8.0.
|
|
113
|
-
"@babel/preset-typescript": "^8.0.
|
|
110
|
+
"@arizeai/openinference-instrumentation-mcp": "^0.2.36",
|
|
111
|
+
"@babel/core": "^8.0.7",
|
|
112
|
+
"@babel/preset-env": "^8.0.7",
|
|
113
|
+
"@babel/preset-typescript": "^8.0.7",
|
|
114
114
|
"@changesets/changelog-github": "^1.0.1",
|
|
115
115
|
"@changesets/cli": "^3.0.3",
|
|
116
|
-
"@google/genai": "^2.
|
|
117
|
-
"@langchain/core": "^1.2.
|
|
118
|
-
"@langchain/langgraph": "^1.4.
|
|
119
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
116
|
+
"@google/genai": "^2.28.0",
|
|
117
|
+
"@langchain/core": "^1.2.17",
|
|
118
|
+
"@langchain/langgraph": "^1.4.21",
|
|
119
|
+
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
120
120
|
"@traceloop/instrumentation-google-generativeai": "^0.27.0",
|
|
121
121
|
"@traceloop/instrumentation-vertexai": "^0.27.0",
|
|
122
122
|
"@types/jest": "^30.0.0",
|
|
123
|
-
"@types/node": "^26.6.
|
|
124
|
-
"ai": "^7.0.
|
|
123
|
+
"@types/node": "^26.6.5",
|
|
124
|
+
"ai": "^7.0.137",
|
|
125
125
|
"babel-jest": "^30.5.2",
|
|
126
126
|
"babel-plugin-transform-import-meta": "^3.0.0",
|
|
127
127
|
"jest": "^30.5.2",
|
|
128
128
|
"jest-environment-jsdom": "^30.5.2",
|
|
129
|
-
"openai": "^7.
|
|
130
|
-
"oxlint": "^1.
|
|
131
|
-
"prettier": "^3.9.
|
|
129
|
+
"openai": "^7.32.0",
|
|
130
|
+
"oxlint": "^1.87.0",
|
|
131
|
+
"prettier": "^3.9.10",
|
|
132
132
|
"tsup": "^8.5.1",
|
|
133
133
|
"typescript": "^7.0.2",
|
|
134
|
-
"vitest": "^5.0.
|
|
134
|
+
"vitest": "^5.0.3",
|
|
135
135
|
"zod": "^4.6.5"
|
|
136
136
|
},
|
|
137
137
|
"peerDependencies": {
|
|
@@ -175,21 +175,21 @@
|
|
|
175
175
|
}
|
|
176
176
|
},
|
|
177
177
|
"dependencies": {
|
|
178
|
-
"@arizeai/openinference-instrumentation-langchain": "^4.1.
|
|
178
|
+
"@arizeai/openinference-instrumentation-langchain": "^4.1.4",
|
|
179
179
|
"@arizeai/openinference-instrumentation-openai": "^2.3.1",
|
|
180
180
|
"@opentelemetry/api": "^1.9.0",
|
|
181
|
-
"@opentelemetry/api-logs": "^0.
|
|
182
|
-
"@opentelemetry/core": "^2.
|
|
183
|
-
"@opentelemetry/exporter-logs-otlp-http": "^0.
|
|
184
|
-
"@opentelemetry/exporter-metrics-otlp-http": "^0.
|
|
185
|
-
"@opentelemetry/exporter-trace-otlp-http": "^0.
|
|
186
|
-
"@opentelemetry/exporter-trace-otlp-proto": "^0.
|
|
187
|
-
"@opentelemetry/instrumentation": "^0.
|
|
188
|
-
"@opentelemetry/resources": "^2.
|
|
189
|
-
"@opentelemetry/sdk-logs": "^0.
|
|
190
|
-
"@opentelemetry/sdk-metrics": "^2.
|
|
191
|
-
"@opentelemetry/sdk-trace-base": "^2.
|
|
192
|
-
"@opentelemetry/sdk-trace-node": "^2.
|
|
181
|
+
"@opentelemetry/api-logs": "^0.223.0",
|
|
182
|
+
"@opentelemetry/core": "^2.12.0",
|
|
183
|
+
"@opentelemetry/exporter-logs-otlp-http": "^0.223.0",
|
|
184
|
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.223.0",
|
|
185
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.223.0",
|
|
186
|
+
"@opentelemetry/exporter-trace-otlp-proto": "^0.223.0",
|
|
187
|
+
"@opentelemetry/instrumentation": "^0.223.0",
|
|
188
|
+
"@opentelemetry/resources": "^2.12.0",
|
|
189
|
+
"@opentelemetry/sdk-logs": "^0.223.0",
|
|
190
|
+
"@opentelemetry/sdk-metrics": "^2.12.0",
|
|
191
|
+
"@opentelemetry/sdk-trace-base": "^2.12.0",
|
|
192
|
+
"@opentelemetry/sdk-trace-node": "^2.12.0",
|
|
193
193
|
"@opentelemetry/semantic-conventions": "^1.43.0",
|
|
194
194
|
"@traceloop/ai-semantic-conventions": "^0.27.0",
|
|
195
195
|
"@traceloop/instrumentation-anthropic": "^0.27.0",
|
|
@@ -200,15 +200,15 @@
|
|
|
200
200
|
"@traceloop/instrumentation-pinecone": "^0.27.0",
|
|
201
201
|
"@traceloop/instrumentation-qdrant": "^0.27.0",
|
|
202
202
|
"@traceloop/instrumentation-together": "^0.27.0",
|
|
203
|
-
"pino": "^10.
|
|
204
|
-
"pino-pretty": "^13.
|
|
203
|
+
"pino": "^10.4.0",
|
|
204
|
+
"pino-pretty": "^13.2.0",
|
|
205
205
|
"tslib": "^2.8.1"
|
|
206
206
|
},
|
|
207
207
|
"packageManager": "pnpm@10.17.0+sha512.fce8a3dd29a4ed2ec566fb53efbb04d8c44a0f05bc6f24a73046910fb9c3ce7afa35a0980500668fa3573345bd644644fa98338fa168235c80f4aa17aa17fbef",
|
|
208
208
|
"pnpm": {
|
|
209
209
|
"overrides": {
|
|
210
|
-
"@babel/core": "^8.0.
|
|
211
|
-
"@opentelemetry/core": "^2.
|
|
210
|
+
"@babel/core": "^8.0.7",
|
|
211
|
+
"@opentelemetry/core": "^2.12.0"
|
|
212
212
|
},
|
|
213
213
|
"updateConfig": {
|
|
214
214
|
"ignoreDependencies": [
|