@brizz/sdk 0.1.35 → 0.1.36
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 +6 -1
- package/dist/{chunk-GSKXPOLQ.js → chunk-6OGRVH77.js} +1 -1
- package/dist/{chunk-NEF2O7HF.cjs → chunk-77UGZGMP.cjs} +3 -1
- package/dist/{chunk-D27LNW3M.cjs → chunk-CQDWK43A.cjs} +145 -130
- package/dist/{chunk-24CEDVD2.js → chunk-EC3MYSRM.js} +1 -1
- package/dist/{chunk-M3UGFLH7.cjs → chunk-EVRCHF74.cjs} +4 -4
- package/dist/{chunk-HZOBDXDS.cjs → chunk-PXIW2K27.cjs} +1 -1
- package/dist/{chunk-QY4VADPP.js → chunk-WII4R5RE.js} +2 -0
- package/dist/{chunk-KP3KG66W.js → chunk-YNCBWOHM.js} +20 -5
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -6
- package/dist/interrupt-DM3AWSBX.cjs +12 -0
- package/dist/{interrupt-KADNA6WK.js → interrupt-YJVZK4VC.js} +2 -2
- package/dist/{mcp-KAYXU4AU.cjs → mcp-HAUJ3G4Q.cjs} +7 -7
- package/dist/{mcp-EJNZYON6.js → mcp-ZCRMQV5L.js} +2 -2
- package/dist/preload.cjs +7 -7
- package/dist/preload.js +4 -4
- package/package.json +10 -10
- package/dist/interrupt-7MWQCOY3.cjs +0 -12
package/README.md
CHANGED
|
@@ -672,7 +672,7 @@ warnings, and is less prone to `this` binding issues.
|
|
|
672
672
|
|
|
673
673
|
## Mute Messages
|
|
674
674
|
|
|
675
|
-
Keep internal or unrelated LLM calls — summarization, title generation, classification, guardrail checks — out of the captured conversation. The call still runs and its telemetry (latency, tokens, cost) is recorded; only the
|
|
675
|
+
Keep internal or unrelated LLM calls — summarization, title generation, classification, guardrail checks — out of the captured conversation. The call still runs and its telemetry (latency, tokens, cost) is recorded; only the content is left out — the prompt, the reply, and the tool calls.
|
|
676
676
|
|
|
677
677
|
```typescript
|
|
678
678
|
import { callWithMute, withMute } from '@brizz/sdk';
|
|
@@ -683,10 +683,15 @@ await callWithMute({}, () => agent.run('Summarize this conversation for internal
|
|
|
683
683
|
// Keep the assistant reply, drop the prompt
|
|
684
684
|
await callWithMute({ output: false }, () => agent.run('…a long internal prompt…'));
|
|
685
685
|
|
|
686
|
+
// Keep the tool calls, drop the prompt and the reply
|
|
687
|
+
await callWithMute({ tools: false }, () => agent.run('…a long internal prompt…'));
|
|
688
|
+
|
|
686
689
|
// Pre-wrap a function to reuse the same muting
|
|
687
690
|
const muteTitle = withMute({}, agent.run, agent);
|
|
688
691
|
```
|
|
689
692
|
|
|
693
|
+
`tools` covers tool calls and their results. Leave it out and it follows `output`.
|
|
694
|
+
|
|
690
695
|
## Deployment Environment
|
|
691
696
|
|
|
692
697
|
Optionally specify the deployment environment for better filtering and organization:
|
|
@@ -12,6 +12,7 @@ var SESSION_OUTPUT_CONTEXT = "brizz.session.output.context";
|
|
|
12
12
|
var SESSION_SPAN_NAME = "brizz.start_session";
|
|
13
13
|
var MUTE_INPUT = "mute.input";
|
|
14
14
|
var MUTE_OUTPUT = "mute.output";
|
|
15
|
+
var MUTE_TOOLS = "mute.tools";
|
|
15
16
|
var USER_ID = "user.id";
|
|
16
17
|
var USER_EMAIL = "user.email";
|
|
17
18
|
var USER_NAME = "user.name";
|
|
@@ -114,4 +115,5 @@ var METRIC_POLARITY_NEGATIVE = "negative";
|
|
|
114
115
|
|
|
115
116
|
|
|
116
117
|
|
|
117
|
-
|
|
118
|
+
|
|
119
|
+
exports.BRIZZ = BRIZZ; exports.SESSION_ID = SESSION_ID; exports.PROPERTIES_CONTEXT_KEY = PROPERTIES_CONTEXT_KEY; exports.SESSION_OBJECT_CONTEXT_KEY = SESSION_OBJECT_CONTEXT_KEY; exports.SESSION_INPUT = SESSION_INPUT; exports.SESSION_OUTPUT = SESSION_OUTPUT; exports.SESSION_INPUT_CONTEXT = SESSION_INPUT_CONTEXT; exports.SESSION_OUTPUT_CONTEXT = SESSION_OUTPUT_CONTEXT; exports.SESSION_SPAN_NAME = SESSION_SPAN_NAME; exports.MUTE_INPUT = MUTE_INPUT; exports.MUTE_OUTPUT = MUTE_OUTPUT; exports.MUTE_TOOLS = MUTE_TOOLS; exports.USER_ID = USER_ID; exports.USER_EMAIL = USER_EMAIL; exports.USER_NAME = USER_NAME; exports.USER_ROLE = USER_ROLE; exports.USER_PLAN = USER_PLAN; exports.ORGANIZATION_ID = ORGANIZATION_ID; exports.ORGANIZATION_NAME = ORGANIZATION_NAME; exports.ORGANIZATION_PLAN = ORGANIZATION_PLAN; exports.ORGANIZATION_DOMAIN = ORGANIZATION_DOMAIN; exports.MESSAGE_ID = MESSAGE_ID; exports.SESSION_TITLE_SPAN_NAME = SESSION_TITLE_SPAN_NAME; exports.SESSION_TITLE_GENERATION = SESSION_TITLE_GENERATION; exports.SESSION_TITLE = SESSION_TITLE; exports.INTERRUPT_TOOLS = INTERRUPT_TOOLS; exports.INTERNAL_EVENT_PREFIX = INTERNAL_EVENT_PREFIX; exports.EXTERNAL_LINK_EVENT_NAME = EXTERNAL_LINK_EVENT_NAME; exports.EXTERNAL_LINK_URL = EXTERNAL_LINK_URL; exports.EXTERNAL_LINK_TITLE = EXTERNAL_LINK_TITLE; exports.EXTERNAL_LINK_TYPE = EXTERNAL_LINK_TYPE; exports.FEEDBACK_EVENT_NAME = FEEDBACK_EVENT_NAME; exports.FEEDBACK_TYPE = FEEDBACK_TYPE; exports.FEEDBACK_SCORE = FEEDBACK_SCORE; exports.FEEDBACK_REASON = FEEDBACK_REASON; exports.FEEDBACK_COMMENT = FEEDBACK_COMMENT; exports.FEEDBACK_SOURCE = FEEDBACK_SOURCE; exports.FEEDBACK_ATTR_PREFIX = FEEDBACK_ATTR_PREFIX; exports.METRIC_EVENT_NAME = METRIC_EVENT_NAME; exports.METRIC_NAME = METRIC_NAME; exports.METRIC_VALUE = METRIC_VALUE; exports.METRIC_UNIT = METRIC_UNIT; exports.METRIC_COMMENT = METRIC_COMMENT; exports.METRIC_POLARITY = METRIC_POLARITY; exports.METRIC_MIN = METRIC_MIN; exports.METRIC_MAX = METRIC_MAX; exports.METRIC_TIMESTAMP = METRIC_TIMESTAMP; exports.METRIC_ATTRIBUTE_PREFIX = METRIC_ATTRIBUTE_PREFIX; exports.RESERVED_METRIC_NAMES = RESERVED_METRIC_NAMES; exports.METRIC_POLARITY_POSITIVE = METRIC_POLARITY_POSITIVE; exports.METRIC_POLARITY_NEGATIVE = METRIC_POLARITY_NEGATIVE;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkPXIW2K27cjs = require('./chunk-PXIW2K27.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ var _chunkHZOBDXDScjs = require('./chunk-HZOBDXDS.cjs');
|
|
|
13
13
|
var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkEVRCHF74cjs = require('./chunk-EVRCHF74.cjs');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
@@ -64,7 +64,8 @@ var _chunkM3UGFLH7cjs = require('./chunk-M3UGFLH7.cjs');
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
|
|
68
|
+
var _chunk77UGZGMPcjs = require('./chunk-77UGZGMP.cjs');
|
|
68
69
|
|
|
69
70
|
|
|
70
71
|
var _chunkOBGZSXTJcjs = require('./chunk-OBGZSXTJ.cjs');
|
|
@@ -189,7 +190,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
189
190
|
const mcpModules = this.manualModules.mcp;
|
|
190
191
|
void (async () => {
|
|
191
192
|
try {
|
|
192
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
193
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-HAUJ3G4Q.cjs")));
|
|
193
194
|
const instrumentation = new MCPInstrumentation({ exceptionLogger });
|
|
194
195
|
instrumentation.manuallyInstrument(mcpModules);
|
|
195
196
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
|
|
@@ -680,10 +681,10 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
|
|
|
680
681
|
if (maskingConfig) {
|
|
681
682
|
maskLog(logRecord, maskingConfig);
|
|
682
683
|
}
|
|
683
|
-
const associationProperties = _api.context.active().getValue(
|
|
684
|
+
const associationProperties = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
684
685
|
if (associationProperties) {
|
|
685
686
|
for (const [key, value] of Object.entries(associationProperties)) {
|
|
686
|
-
logRecord.setAttribute(`${
|
|
687
|
+
logRecord.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
|
|
687
688
|
}
|
|
688
689
|
}
|
|
689
690
|
super.onEmit(logRecord);
|
|
@@ -700,10 +701,10 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
|
|
|
700
701
|
if (maskingConfig) {
|
|
701
702
|
maskLog(logRecord, maskingConfig);
|
|
702
703
|
}
|
|
703
|
-
const associationProperties = _api.context.active().getValue(
|
|
704
|
+
const associationProperties = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
704
705
|
if (associationProperties) {
|
|
705
706
|
for (const [key, value] of Object.entries(associationProperties)) {
|
|
706
|
-
logRecord.setAttribute(`${
|
|
707
|
+
logRecord.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
|
|
707
708
|
}
|
|
708
709
|
}
|
|
709
710
|
super.onEmit(logRecord);
|
|
@@ -730,7 +731,7 @@ function maskLog(logRecord, config) {
|
|
|
730
731
|
newAttributes[key] = value;
|
|
731
732
|
}
|
|
732
733
|
for (const [key, value] of Object.entries(logRecord.attributes)) {
|
|
733
|
-
if (key.startsWith(
|
|
734
|
+
if (key.startsWith(_chunk77UGZGMPcjs.INTERNAL_EVENT_PREFIX)) {
|
|
734
735
|
newAttributes[key] = value;
|
|
735
736
|
}
|
|
736
737
|
}
|
|
@@ -821,7 +822,7 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
|
|
|
821
822
|
const resourceAttributes = {
|
|
822
823
|
...config.resourceAttributes,
|
|
823
824
|
"service.name": config.appName,
|
|
824
|
-
[BRIZZ_SDK_VERSION]:
|
|
825
|
+
[BRIZZ_SDK_VERSION]: _chunkPXIW2K27cjs.getSDKVersion.call(void 0, ),
|
|
825
826
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
826
827
|
};
|
|
827
828
|
if (config.environment) {
|
|
@@ -937,16 +938,16 @@ function setCurrentSpanCustomProperties(properties) {
|
|
|
937
938
|
}
|
|
938
939
|
for (const [key, value] of Object.entries(properties)) {
|
|
939
940
|
try {
|
|
940
|
-
current.setAttribute(`${
|
|
941
|
+
current.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
|
|
941
942
|
} catch (e) {
|
|
942
943
|
}
|
|
943
944
|
}
|
|
944
945
|
}
|
|
945
946
|
function callWithProperties(properties, fn, thisArg, ...args) {
|
|
946
947
|
const base = _api.context.active();
|
|
947
|
-
const prev = base.getValue(
|
|
948
|
+
const prev = base.getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
948
949
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
949
|
-
const next = base.setValue(
|
|
950
|
+
const next = base.setValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY, merged);
|
|
950
951
|
return _api.context.with(next, fn, thisArg, ...args);
|
|
951
952
|
}
|
|
952
953
|
function withProperties(properties, fn, thisArg) {
|
|
@@ -968,25 +969,25 @@ function propagatePropertiesImperatively(properties) {
|
|
|
968
969
|
return;
|
|
969
970
|
}
|
|
970
971
|
const base = _api.context.active();
|
|
971
|
-
const prev = base.getValue(
|
|
972
|
+
const prev = base.getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
972
973
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
973
|
-
store.enterWith(base.setValue(
|
|
974
|
+
store.enterWith(base.setValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY, merged));
|
|
974
975
|
} catch (e2) {
|
|
975
976
|
}
|
|
976
977
|
}
|
|
977
978
|
function setUser(user) {
|
|
978
|
-
const properties = { [
|
|
979
|
+
const properties = { [_chunk77UGZGMPcjs.USER_ID]: user.id };
|
|
979
980
|
if (user.email !== void 0) {
|
|
980
|
-
properties[
|
|
981
|
+
properties[_chunk77UGZGMPcjs.USER_EMAIL] = user.email;
|
|
981
982
|
}
|
|
982
983
|
if (user.name !== void 0) {
|
|
983
|
-
properties[
|
|
984
|
+
properties[_chunk77UGZGMPcjs.USER_NAME] = user.name;
|
|
984
985
|
}
|
|
985
986
|
if (user.role !== void 0) {
|
|
986
|
-
properties[
|
|
987
|
+
properties[_chunk77UGZGMPcjs.USER_ROLE] = user.role;
|
|
987
988
|
}
|
|
988
989
|
if (user.plan !== void 0) {
|
|
989
|
-
properties[
|
|
990
|
+
properties[_chunk77UGZGMPcjs.USER_PLAN] = user.plan;
|
|
990
991
|
}
|
|
991
992
|
if (user.traits) {
|
|
992
993
|
for (const [key, value] of Object.entries(user.traits)) {
|
|
@@ -1000,15 +1001,15 @@ function setUser(user) {
|
|
|
1000
1001
|
propagatePropertiesImperatively(properties);
|
|
1001
1002
|
}
|
|
1002
1003
|
function setOrganization(org) {
|
|
1003
|
-
const properties = { [
|
|
1004
|
+
const properties = { [_chunk77UGZGMPcjs.ORGANIZATION_ID]: org.id };
|
|
1004
1005
|
if (org.name !== void 0) {
|
|
1005
|
-
properties[
|
|
1006
|
+
properties[_chunk77UGZGMPcjs.ORGANIZATION_NAME] = org.name;
|
|
1006
1007
|
}
|
|
1007
1008
|
if (org.plan !== void 0) {
|
|
1008
|
-
properties[
|
|
1009
|
+
properties[_chunk77UGZGMPcjs.ORGANIZATION_PLAN] = org.plan;
|
|
1009
1010
|
}
|
|
1010
1011
|
if (org.domain !== void 0) {
|
|
1011
|
-
properties[
|
|
1012
|
+
properties[_chunk77UGZGMPcjs.ORGANIZATION_DOMAIN] = org.domain;
|
|
1012
1013
|
}
|
|
1013
1014
|
if (org.traits) {
|
|
1014
1015
|
for (const [key, value] of Object.entries(org.traits)) {
|
|
@@ -1022,23 +1023,23 @@ function setOrganization(org) {
|
|
|
1022
1023
|
propagatePropertiesImperatively(properties);
|
|
1023
1024
|
}
|
|
1024
1025
|
function setMessageId(id) {
|
|
1025
|
-
const properties = { [
|
|
1026
|
+
const properties = { [_chunk77UGZGMPcjs.MESSAGE_ID]: id };
|
|
1026
1027
|
setCurrentSpanCustomProperties(properties);
|
|
1027
1028
|
propagatePropertiesImperatively(properties);
|
|
1028
1029
|
}
|
|
1029
1030
|
function userProperties(user) {
|
|
1030
|
-
const properties = { [
|
|
1031
|
+
const properties = { [_chunk77UGZGMPcjs.USER_ID]: user.id };
|
|
1031
1032
|
if (user.email !== void 0) {
|
|
1032
|
-
properties[
|
|
1033
|
+
properties[_chunk77UGZGMPcjs.USER_EMAIL] = user.email;
|
|
1033
1034
|
}
|
|
1034
1035
|
if (user.name !== void 0) {
|
|
1035
|
-
properties[
|
|
1036
|
+
properties[_chunk77UGZGMPcjs.USER_NAME] = user.name;
|
|
1036
1037
|
}
|
|
1037
1038
|
if (user.role !== void 0) {
|
|
1038
|
-
properties[
|
|
1039
|
+
properties[_chunk77UGZGMPcjs.USER_ROLE] = user.role;
|
|
1039
1040
|
}
|
|
1040
1041
|
if (user.plan !== void 0) {
|
|
1041
|
-
properties[
|
|
1042
|
+
properties[_chunk77UGZGMPcjs.USER_PLAN] = user.plan;
|
|
1042
1043
|
}
|
|
1043
1044
|
if (user.traits) {
|
|
1044
1045
|
for (const [key, value] of Object.entries(user.traits)) {
|
|
@@ -1051,15 +1052,15 @@ function userProperties(user) {
|
|
|
1051
1052
|
return properties;
|
|
1052
1053
|
}
|
|
1053
1054
|
function organizationProperties(org) {
|
|
1054
|
-
const properties = { [
|
|
1055
|
+
const properties = { [_chunk77UGZGMPcjs.ORGANIZATION_ID]: org.id };
|
|
1055
1056
|
if (org.name !== void 0) {
|
|
1056
|
-
properties[
|
|
1057
|
+
properties[_chunk77UGZGMPcjs.ORGANIZATION_NAME] = org.name;
|
|
1057
1058
|
}
|
|
1058
1059
|
if (org.plan !== void 0) {
|
|
1059
|
-
properties[
|
|
1060
|
+
properties[_chunk77UGZGMPcjs.ORGANIZATION_PLAN] = org.plan;
|
|
1060
1061
|
}
|
|
1061
1062
|
if (org.domain !== void 0) {
|
|
1062
|
-
properties[
|
|
1063
|
+
properties[_chunk77UGZGMPcjs.ORGANIZATION_DOMAIN] = org.domain;
|
|
1063
1064
|
}
|
|
1064
1065
|
if (org.traits) {
|
|
1065
1066
|
for (const [key, value] of Object.entries(org.traits)) {
|
|
@@ -1084,19 +1085,33 @@ function withOrganization(org, fn, thisArg) {
|
|
|
1084
1085
|
return withProperties(organizationProperties(org), fn, thisArg);
|
|
1085
1086
|
}
|
|
1086
1087
|
function callWithMessageId(id, fn, thisArg, ...args) {
|
|
1087
|
-
return callWithProperties({ [
|
|
1088
|
+
return callWithProperties({ [_chunk77UGZGMPcjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
|
|
1088
1089
|
}
|
|
1089
1090
|
function withMessageId(id, fn, thisArg) {
|
|
1090
|
-
return withProperties({ [
|
|
1091
|
+
return withProperties({ [_chunk77UGZGMPcjs.MESSAGE_ID]: id }, fn, thisArg);
|
|
1092
|
+
}
|
|
1093
|
+
function inheritedMuteTools() {
|
|
1094
|
+
const properties = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
1095
|
+
return _optionalChain([properties, 'optionalAccess', _40 => _40[_chunk77UGZGMPcjs.MUTE_TOOLS]]);
|
|
1091
1096
|
}
|
|
1092
1097
|
function muteProperties(options) {
|
|
1093
|
-
const { input = true, output = true } = options;
|
|
1098
|
+
const { input = true, output = true, tools = output } = options;
|
|
1094
1099
|
const properties = {};
|
|
1095
1100
|
if (input) {
|
|
1096
|
-
properties[
|
|
1101
|
+
properties[_chunk77UGZGMPcjs.MUTE_INPUT] = "true";
|
|
1097
1102
|
}
|
|
1098
1103
|
if (output) {
|
|
1099
|
-
properties[
|
|
1104
|
+
properties[_chunk77UGZGMPcjs.MUTE_OUTPUT] = "true";
|
|
1105
|
+
}
|
|
1106
|
+
if (tools !== output) {
|
|
1107
|
+
properties[_chunk77UGZGMPcjs.MUTE_TOOLS] = String(tools);
|
|
1108
|
+
} else {
|
|
1109
|
+
const inherited = inheritedMuteTools();
|
|
1110
|
+
if (tools && inherited === "false") {
|
|
1111
|
+
properties[_chunk77UGZGMPcjs.MUTE_TOOLS] = "true";
|
|
1112
|
+
} else if (options.tools === false && inherited === "true") {
|
|
1113
|
+
properties[_chunk77UGZGMPcjs.MUTE_TOOLS] = "false";
|
|
1114
|
+
}
|
|
1100
1115
|
}
|
|
1101
1116
|
return properties;
|
|
1102
1117
|
}
|
|
@@ -1107,11 +1122,11 @@ function withMute(options, fn, thisArg) {
|
|
|
1107
1122
|
return withProperties(muteProperties(options), fn, thisArg);
|
|
1108
1123
|
}
|
|
1109
1124
|
function withSessionId(sessionId, fn, thisArg, extraProperties) {
|
|
1110
|
-
const properties = { [
|
|
1125
|
+
const properties = { [_chunk77UGZGMPcjs.SESSION_ID]: sessionId, ...extraProperties };
|
|
1111
1126
|
return withProperties(properties, fn, thisArg);
|
|
1112
1127
|
}
|
|
1113
1128
|
function callWithSessionId(sessionId, fn, thisArg, ...args) {
|
|
1114
|
-
return callWithProperties({ [
|
|
1129
|
+
return callWithProperties({ [_chunk77UGZGMPcjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
|
|
1115
1130
|
}
|
|
1116
1131
|
var Session = (_class3 = class {
|
|
1117
1132
|
|
|
@@ -1139,8 +1154,8 @@ var Session = (_class3 = class {
|
|
|
1139
1154
|
setInput(text, context4) {
|
|
1140
1155
|
this.inputs.push(text);
|
|
1141
1156
|
this.inputContexts.push(_nullishCoalesce(context4, () => ( {})));
|
|
1142
|
-
this.span.setAttribute(
|
|
1143
|
-
this.span.setAttribute(
|
|
1157
|
+
this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_INPUT, JSON.stringify(this.inputs));
|
|
1158
|
+
this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
|
|
1144
1159
|
}
|
|
1145
1160
|
/**
|
|
1146
1161
|
* Append an assistant turn to session output tracking.
|
|
@@ -1155,8 +1170,8 @@ var Session = (_class3 = class {
|
|
|
1155
1170
|
setOutput(text, context4) {
|
|
1156
1171
|
this.outputs.push(text);
|
|
1157
1172
|
this.outputContexts.push(_nullishCoalesce(context4, () => ( {})));
|
|
1158
|
-
this.span.setAttribute(
|
|
1159
|
-
this.span.setAttribute(
|
|
1173
|
+
this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
|
|
1174
|
+
this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
|
|
1160
1175
|
}
|
|
1161
1176
|
/**
|
|
1162
1177
|
* Set the session title on the span.
|
|
@@ -1164,7 +1179,7 @@ var Session = (_class3 = class {
|
|
|
1164
1179
|
* @param title - The generated title string
|
|
1165
1180
|
*/
|
|
1166
1181
|
setTitle(title) {
|
|
1167
|
-
this.span.setAttribute(
|
|
1182
|
+
this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_TITLE, title);
|
|
1168
1183
|
}
|
|
1169
1184
|
/**
|
|
1170
1185
|
* Update custom properties on the session span.
|
|
@@ -1174,7 +1189,7 @@ var Session = (_class3 = class {
|
|
|
1174
1189
|
*/
|
|
1175
1190
|
updateProperties(properties) {
|
|
1176
1191
|
for (const [key, value] of Object.entries(properties)) {
|
|
1177
|
-
this.span.setAttribute(`${
|
|
1192
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
|
|
1178
1193
|
}
|
|
1179
1194
|
}
|
|
1180
1195
|
/**
|
|
@@ -1186,21 +1201,21 @@ var Session = (_class3 = class {
|
|
|
1186
1201
|
setUser(user) {
|
|
1187
1202
|
if (user.traits) {
|
|
1188
1203
|
for (const [key, value] of Object.entries(user.traits)) {
|
|
1189
|
-
this.span.setAttribute(`${
|
|
1204
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.user.${key}`, value);
|
|
1190
1205
|
}
|
|
1191
1206
|
}
|
|
1192
|
-
this.span.setAttribute(`${
|
|
1207
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_ID}`, user.id);
|
|
1193
1208
|
if (user.email !== void 0) {
|
|
1194
|
-
this.span.setAttribute(`${
|
|
1209
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_EMAIL}`, user.email);
|
|
1195
1210
|
}
|
|
1196
1211
|
if (user.name !== void 0) {
|
|
1197
|
-
this.span.setAttribute(`${
|
|
1212
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_NAME}`, user.name);
|
|
1198
1213
|
}
|
|
1199
1214
|
if (user.role !== void 0) {
|
|
1200
|
-
this.span.setAttribute(`${
|
|
1215
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_ROLE}`, user.role);
|
|
1201
1216
|
}
|
|
1202
1217
|
if (user.plan !== void 0) {
|
|
1203
|
-
this.span.setAttribute(`${
|
|
1218
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.USER_PLAN}`, user.plan);
|
|
1204
1219
|
}
|
|
1205
1220
|
}
|
|
1206
1221
|
/**
|
|
@@ -1212,18 +1227,18 @@ var Session = (_class3 = class {
|
|
|
1212
1227
|
setOrganization(org) {
|
|
1213
1228
|
if (org.traits) {
|
|
1214
1229
|
for (const [key, value] of Object.entries(org.traits)) {
|
|
1215
|
-
this.span.setAttribute(`${
|
|
1230
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.organization.${key}`, value);
|
|
1216
1231
|
}
|
|
1217
1232
|
}
|
|
1218
|
-
this.span.setAttribute(`${
|
|
1233
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.ORGANIZATION_ID}`, org.id);
|
|
1219
1234
|
if (org.name !== void 0) {
|
|
1220
|
-
this.span.setAttribute(`${
|
|
1235
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.ORGANIZATION_NAME}`, org.name);
|
|
1221
1236
|
}
|
|
1222
1237
|
if (org.plan !== void 0) {
|
|
1223
|
-
this.span.setAttribute(`${
|
|
1238
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.ORGANIZATION_PLAN}`, org.plan);
|
|
1224
1239
|
}
|
|
1225
1240
|
if (org.domain !== void 0) {
|
|
1226
|
-
this.span.setAttribute(`${
|
|
1241
|
+
this.span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.ORGANIZATION_DOMAIN}`, org.domain);
|
|
1227
1242
|
}
|
|
1228
1243
|
}
|
|
1229
1244
|
/**
|
|
@@ -1239,7 +1254,7 @@ var Session = (_class3 = class {
|
|
|
1239
1254
|
* (free-form category, defaults to `'generic'`)
|
|
1240
1255
|
*/
|
|
1241
1256
|
addExternalLink(url, options) {
|
|
1242
|
-
emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess',
|
|
1257
|
+
emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess', _41 => _41.title]), _optionalChain([options, 'optionalAccess', _42 => _42.linkType]));
|
|
1243
1258
|
}
|
|
1244
1259
|
}, _class3);
|
|
1245
1260
|
var SessionTitle = class {
|
|
@@ -1253,69 +1268,69 @@ var SessionTitle = class {
|
|
|
1253
1268
|
* @param title - The generated title string
|
|
1254
1269
|
*/
|
|
1255
1270
|
setTitle(title) {
|
|
1256
|
-
this.span.setAttribute(
|
|
1271
|
+
this.span.setAttribute(_chunk77UGZGMPcjs.SESSION_TITLE, title);
|
|
1257
1272
|
}
|
|
1258
1273
|
};
|
|
1259
1274
|
function getActiveSession() {
|
|
1260
|
-
return _api.context.active().getValue(
|
|
1275
|
+
return _api.context.active().getValue(_chunk77UGZGMPcjs.SESSION_OBJECT_CONTEXT_KEY);
|
|
1261
1276
|
}
|
|
1262
1277
|
function resolveSessionIdFromContext() {
|
|
1263
1278
|
const active = getActiveSession();
|
|
1264
1279
|
if (active) {
|
|
1265
1280
|
return active.sessionId;
|
|
1266
1281
|
}
|
|
1267
|
-
const props = _api.context.active().getValue(
|
|
1268
|
-
return _optionalChain([props, 'optionalAccess',
|
|
1282
|
+
const props = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
1283
|
+
return _optionalChain([props, 'optionalAccess', _43 => _43[_chunk77UGZGMPcjs.SESSION_ID]]);
|
|
1269
1284
|
}
|
|
1270
1285
|
function resolveMessageIdFromContext() {
|
|
1271
|
-
const props = _api.context.active().getValue(
|
|
1272
|
-
return _optionalChain([props, 'optionalAccess',
|
|
1286
|
+
const props = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
1287
|
+
return _optionalChain([props, 'optionalAccess', _44 => _44[_chunk77UGZGMPcjs.MESSAGE_ID]]);
|
|
1273
1288
|
}
|
|
1274
1289
|
function emitExternalLink(sessionId, url, title, linkType) {
|
|
1275
1290
|
try {
|
|
1276
|
-
emitEventWithSessionId(sessionId,
|
|
1277
|
-
[
|
|
1278
|
-
[
|
|
1279
|
-
[
|
|
1291
|
+
emitEventWithSessionId(sessionId, _chunk77UGZGMPcjs.EXTERNAL_LINK_EVENT_NAME, {
|
|
1292
|
+
[_chunk77UGZGMPcjs.EXTERNAL_LINK_URL]: url,
|
|
1293
|
+
[_chunk77UGZGMPcjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
|
|
1294
|
+
[_chunk77UGZGMPcjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
|
|
1280
1295
|
});
|
|
1281
1296
|
} catch (error) {
|
|
1282
1297
|
_chunkWC573FCIcjs.logger.warn("addExternalLink: failed to emit external link", error);
|
|
1283
1298
|
}
|
|
1284
1299
|
}
|
|
1285
1300
|
function addExternalLink(url, options) {
|
|
1286
|
-
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1301
|
+
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.sessionId]), () => ( resolveSessionIdFromContext()));
|
|
1287
1302
|
if (!sessionId) {
|
|
1288
1303
|
_chunkWC573FCIcjs.logger.warn(
|
|
1289
1304
|
"addExternalLink called without a resolvable session id; link dropped. Pass options.sessionId or call inside a startSession/callWithSessionId scope."
|
|
1290
1305
|
);
|
|
1291
1306
|
return;
|
|
1292
1307
|
}
|
|
1293
|
-
emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess',
|
|
1308
|
+
emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _46 => _46.title]), _optionalChain([options, 'optionalAccess', _47 => _47.linkType]));
|
|
1294
1309
|
}
|
|
1295
1310
|
function recordFeedback(type, options) {
|
|
1296
|
-
const eventAttributes = { [
|
|
1297
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1298
|
-
eventAttributes[
|
|
1311
|
+
const eventAttributes = { [_chunk77UGZGMPcjs.FEEDBACK_TYPE]: type };
|
|
1312
|
+
if (_optionalChain([options, 'optionalAccess', _48 => _48.score]) !== void 0) {
|
|
1313
|
+
eventAttributes[_chunk77UGZGMPcjs.FEEDBACK_SCORE] = options.score;
|
|
1299
1314
|
}
|
|
1300
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1301
|
-
eventAttributes[
|
|
1315
|
+
if (_optionalChain([options, 'optionalAccess', _49 => _49.reason]) !== void 0) {
|
|
1316
|
+
eventAttributes[_chunk77UGZGMPcjs.FEEDBACK_REASON] = options.reason;
|
|
1302
1317
|
}
|
|
1303
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1304
|
-
eventAttributes[
|
|
1318
|
+
if (_optionalChain([options, 'optionalAccess', _50 => _50.comment]) !== void 0) {
|
|
1319
|
+
eventAttributes[_chunk77UGZGMPcjs.FEEDBACK_COMMENT] = options.comment;
|
|
1305
1320
|
}
|
|
1306
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1307
|
-
eventAttributes[
|
|
1321
|
+
if (_optionalChain([options, 'optionalAccess', _51 => _51.source]) !== void 0) {
|
|
1322
|
+
eventAttributes[_chunk77UGZGMPcjs.FEEDBACK_SOURCE] = options.source;
|
|
1308
1323
|
}
|
|
1309
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1324
|
+
if (_optionalChain([options, 'optionalAccess', _52 => _52.attributes])) {
|
|
1310
1325
|
for (const [key, value] of Object.entries(options.attributes)) {
|
|
1311
|
-
const k = `${
|
|
1326
|
+
const k = `${_chunk77UGZGMPcjs.FEEDBACK_ATTR_PREFIX}${key}`;
|
|
1312
1327
|
if (eventAttributes[k] === void 0) {
|
|
1313
1328
|
eventAttributes[k] = value;
|
|
1314
1329
|
}
|
|
1315
1330
|
}
|
|
1316
1331
|
}
|
|
1317
|
-
const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1318
|
-
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1332
|
+
const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _53 => _53.messageId]), () => ( resolveMessageIdFromContext()));
|
|
1333
|
+
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _54 => _54.sessionId]), () => ( resolveSessionIdFromContext()));
|
|
1319
1334
|
if (messageId === void 0 && sessionId === void 0) {
|
|
1320
1335
|
_chunkWC573FCIcjs.logger.warn(
|
|
1321
1336
|
"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."
|
|
@@ -1323,16 +1338,16 @@ function recordFeedback(type, options) {
|
|
|
1323
1338
|
}
|
|
1324
1339
|
const anchor = {};
|
|
1325
1340
|
if (messageId !== void 0) {
|
|
1326
|
-
anchor[
|
|
1341
|
+
anchor[_chunk77UGZGMPcjs.MESSAGE_ID] = messageId;
|
|
1327
1342
|
}
|
|
1328
1343
|
if (sessionId !== void 0) {
|
|
1329
|
-
anchor[
|
|
1344
|
+
anchor[_chunk77UGZGMPcjs.SESSION_ID] = sessionId;
|
|
1330
1345
|
}
|
|
1331
1346
|
try {
|
|
1332
1347
|
if (Object.keys(anchor).length === 0) {
|
|
1333
|
-
emitEvent(
|
|
1348
|
+
emitEvent(_chunk77UGZGMPcjs.FEEDBACK_EVENT_NAME, eventAttributes);
|
|
1334
1349
|
} else {
|
|
1335
|
-
callWithProperties(anchor, () => emitEvent(
|
|
1350
|
+
callWithProperties(anchor, () => emitEvent(_chunk77UGZGMPcjs.FEEDBACK_EVENT_NAME, eventAttributes));
|
|
1336
1351
|
}
|
|
1337
1352
|
} catch (error) {
|
|
1338
1353
|
_chunkWC573FCIcjs.logger.warn("recordFeedback: failed to emit feedback event", error);
|
|
@@ -1346,7 +1361,7 @@ function recordMetric(options) {
|
|
|
1346
1361
|
try {
|
|
1347
1362
|
recordMetricImpl(options);
|
|
1348
1363
|
} catch (error) {
|
|
1349
|
-
_chunkWC573FCIcjs.logger.warn(`recordMetric(${JSON.stringify(_optionalChain([options, 'optionalAccess',
|
|
1364
|
+
_chunkWC573FCIcjs.logger.warn(`recordMetric(${JSON.stringify(_optionalChain([options, 'optionalAccess', _55 => _55.name]))}) failed; metric dropped.`, error);
|
|
1350
1365
|
}
|
|
1351
1366
|
}
|
|
1352
1367
|
function recordMetricImpl(options) {
|
|
@@ -1357,7 +1372,7 @@ function recordMetricImpl(options) {
|
|
|
1357
1372
|
);
|
|
1358
1373
|
return;
|
|
1359
1374
|
}
|
|
1360
|
-
if (
|
|
1375
|
+
if (_chunk77UGZGMPcjs.RESERVED_METRIC_NAMES.has(name)) {
|
|
1361
1376
|
_chunkWC573FCIcjs.logger.warn(
|
|
1362
1377
|
`recordMetric called with the reserved name ${JSON.stringify(name)}; metric dropped. Brizz computes this metric itself \u2014 pick a different name.`
|
|
1363
1378
|
);
|
|
@@ -1376,17 +1391,17 @@ function recordMetricImpl(options) {
|
|
|
1376
1391
|
return;
|
|
1377
1392
|
}
|
|
1378
1393
|
const eventAttributes = {
|
|
1379
|
-
[
|
|
1380
|
-
[
|
|
1394
|
+
[_chunk77UGZGMPcjs.METRIC_NAME]: name,
|
|
1395
|
+
[_chunk77UGZGMPcjs.METRIC_VALUE]: numericValue
|
|
1381
1396
|
};
|
|
1382
1397
|
if (options.unit !== void 0) {
|
|
1383
|
-
eventAttributes[
|
|
1398
|
+
eventAttributes[_chunk77UGZGMPcjs.METRIC_UNIT] = options.unit;
|
|
1384
1399
|
}
|
|
1385
1400
|
if (options.minValue !== void 0) {
|
|
1386
|
-
eventAttributes[
|
|
1401
|
+
eventAttributes[_chunk77UGZGMPcjs.METRIC_MIN] = options.minValue;
|
|
1387
1402
|
}
|
|
1388
1403
|
if (options.maxValue !== void 0) {
|
|
1389
|
-
eventAttributes[
|
|
1404
|
+
eventAttributes[_chunk77UGZGMPcjs.METRIC_MAX] = options.maxValue;
|
|
1390
1405
|
}
|
|
1391
1406
|
if (options.comment !== void 0) {
|
|
1392
1407
|
let comment = options.comment;
|
|
@@ -1396,21 +1411,21 @@ function recordMetricImpl(options) {
|
|
|
1396
1411
|
);
|
|
1397
1412
|
comment = comment.slice(0, METRIC_COMMENT_MAX_LEN);
|
|
1398
1413
|
}
|
|
1399
|
-
eventAttributes[
|
|
1414
|
+
eventAttributes[_chunk77UGZGMPcjs.METRIC_COMMENT] = comment;
|
|
1400
1415
|
}
|
|
1401
1416
|
if (options.polarity !== void 0) {
|
|
1402
1417
|
const polarity = options.polarity;
|
|
1403
|
-
if (polarity ===
|
|
1404
|
-
eventAttributes[
|
|
1418
|
+
if (polarity === _chunk77UGZGMPcjs.METRIC_POLARITY_POSITIVE || polarity === _chunk77UGZGMPcjs.METRIC_POLARITY_NEGATIVE) {
|
|
1419
|
+
eventAttributes[_chunk77UGZGMPcjs.METRIC_POLARITY] = polarity;
|
|
1405
1420
|
} else {
|
|
1406
1421
|
_chunkWC573FCIcjs.logger.warn(
|
|
1407
|
-
`recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${
|
|
1422
|
+
`recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${_chunk77UGZGMPcjs.METRIC_POLARITY_POSITIVE}' or '${_chunk77UGZGMPcjs.METRIC_POLARITY_NEGATIVE}'. Emitting the metric without it.`
|
|
1408
1423
|
);
|
|
1409
1424
|
}
|
|
1410
1425
|
}
|
|
1411
1426
|
if (options.timestamp !== void 0) {
|
|
1412
1427
|
if (Number.isFinite(options.timestamp.getTime())) {
|
|
1413
|
-
eventAttributes[
|
|
1428
|
+
eventAttributes[_chunk77UGZGMPcjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
|
|
1414
1429
|
} else {
|
|
1415
1430
|
_chunkWC573FCIcjs.logger.warn(
|
|
1416
1431
|
`recordMetric(${name}) called with an invalid timestamp; emitting the metric without it.`
|
|
@@ -1440,7 +1455,7 @@ function recordMetricImpl(options) {
|
|
|
1440
1455
|
);
|
|
1441
1456
|
text = text.slice(0, METRIC_ATTRIBUTE_VALUE_MAX_LEN);
|
|
1442
1457
|
}
|
|
1443
|
-
eventAttributes[`${
|
|
1458
|
+
eventAttributes[`${_chunk77UGZGMPcjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
|
|
1444
1459
|
accepted += 1;
|
|
1445
1460
|
}
|
|
1446
1461
|
}
|
|
@@ -1453,28 +1468,28 @@ function recordMetricImpl(options) {
|
|
|
1453
1468
|
}
|
|
1454
1469
|
try {
|
|
1455
1470
|
callWithProperties(
|
|
1456
|
-
{ [
|
|
1457
|
-
() => emitEvent(
|
|
1471
|
+
{ [_chunk77UGZGMPcjs.SESSION_ID]: sessionId },
|
|
1472
|
+
() => emitEvent(_chunk77UGZGMPcjs.METRIC_EVENT_NAME, eventAttributes)
|
|
1458
1473
|
);
|
|
1459
1474
|
} catch (error) {
|
|
1460
1475
|
_chunkWC573FCIcjs.logger.warn("recordMetric: failed to emit metric event", error);
|
|
1461
1476
|
}
|
|
1462
1477
|
}
|
|
1463
1478
|
function startSession(sessionId, callback, extraProperties, options) {
|
|
1464
|
-
const isTitle = _optionalChain([options, 'optionalAccess',
|
|
1465
|
-
const spanName = isTitle ?
|
|
1479
|
+
const isTitle = _optionalChain([options, 'optionalAccess', _56 => _56.mode]) === "title";
|
|
1480
|
+
const spanName = isTitle ? _chunk77UGZGMPcjs.SESSION_TITLE_SPAN_NAME : _chunk77UGZGMPcjs.SESSION_SPAN_NAME;
|
|
1466
1481
|
const tracer = _api.trace.getTracer("@brizz/sdk");
|
|
1467
1482
|
return tracer.startActiveSpan(spanName, (span) => {
|
|
1468
|
-
span.setAttribute(`${
|
|
1483
|
+
span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.SESSION_ID}`, sessionId);
|
|
1469
1484
|
if (extraProperties) {
|
|
1470
1485
|
for (const [key, value] of Object.entries(extraProperties)) {
|
|
1471
|
-
span.setAttribute(`${
|
|
1486
|
+
span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
|
|
1472
1487
|
}
|
|
1473
1488
|
}
|
|
1474
1489
|
const session = new Session(sessionId, span);
|
|
1475
|
-
const contextProperties = { [
|
|
1490
|
+
const contextProperties = { [_chunk77UGZGMPcjs.SESSION_ID]: sessionId };
|
|
1476
1491
|
if (isTitle) {
|
|
1477
|
-
contextProperties[
|
|
1492
|
+
contextProperties[_chunk77UGZGMPcjs.SESSION_TITLE_GENERATION] = "true";
|
|
1478
1493
|
}
|
|
1479
1494
|
if (extraProperties) {
|
|
1480
1495
|
for (const [key, value] of Object.entries(extraProperties)) {
|
|
@@ -1482,7 +1497,7 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
1482
1497
|
}
|
|
1483
1498
|
}
|
|
1484
1499
|
return callWithProperties(contextProperties, () => {
|
|
1485
|
-
const sessionCtx = _api.context.active().setValue(
|
|
1500
|
+
const sessionCtx = _api.context.active().setValue(_chunk77UGZGMPcjs.SESSION_OBJECT_CONTEXT_KEY, session);
|
|
1486
1501
|
return _api.context.with(sessionCtx, () => {
|
|
1487
1502
|
try {
|
|
1488
1503
|
const result = callback(session);
|
|
@@ -1510,16 +1525,16 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
1510
1525
|
});
|
|
1511
1526
|
}
|
|
1512
1527
|
function startSessionTitle(callback, options) {
|
|
1513
|
-
const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1528
|
+
const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _57 => _57.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _58 => _58(), 'optionalAccess', _59 => _59.sessionId])));
|
|
1514
1529
|
const tracer = _api.trace.getTracer("@brizz/sdk");
|
|
1515
|
-
return tracer.startActiveSpan(
|
|
1530
|
+
return tracer.startActiveSpan(_chunk77UGZGMPcjs.SESSION_TITLE_SPAN_NAME, (span) => {
|
|
1516
1531
|
if (resolvedSessionId) {
|
|
1517
|
-
span.setAttribute(`${
|
|
1532
|
+
span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.SESSION_ID}`, resolvedSessionId);
|
|
1518
1533
|
}
|
|
1519
1534
|
const sessionTitle = new SessionTitle(span);
|
|
1520
|
-
const properties = { [
|
|
1535
|
+
const properties = { [_chunk77UGZGMPcjs.SESSION_TITLE_GENERATION]: "true" };
|
|
1521
1536
|
if (resolvedSessionId) {
|
|
1522
|
-
properties[
|
|
1537
|
+
properties[_chunk77UGZGMPcjs.SESSION_ID] = resolvedSessionId;
|
|
1523
1538
|
}
|
|
1524
1539
|
return callWithProperties(properties, () => {
|
|
1525
1540
|
try {
|
|
@@ -1664,7 +1679,7 @@ var BrizzSpanExporter = class {
|
|
|
1664
1679
|
const resourceAttrs = {
|
|
1665
1680
|
...config.resourceAttributes,
|
|
1666
1681
|
"service.name": config.appName,
|
|
1667
|
-
[BRIZZ_SDK_VERSION]:
|
|
1682
|
+
[BRIZZ_SDK_VERSION]: _chunkPXIW2K27cjs.getSDKVersion.call(void 0, ),
|
|
1668
1683
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
1669
1684
|
};
|
|
1670
1685
|
if (config.environment) {
|
|
@@ -1716,7 +1731,7 @@ var BrizzSpanExporter = class {
|
|
|
1716
1731
|
return this._delegate.shutdown();
|
|
1717
1732
|
}
|
|
1718
1733
|
async forceFlush() {
|
|
1719
|
-
return _optionalChain([this, 'access',
|
|
1734
|
+
return _optionalChain([this, 'access', _60 => _60._delegate, 'access', _61 => _61.forceFlush, 'optionalCall', _62 => _62()]);
|
|
1720
1735
|
}
|
|
1721
1736
|
};
|
|
1722
1737
|
|
|
@@ -1727,10 +1742,10 @@ var BrizzSpanExporter = class {
|
|
|
1727
1742
|
|
|
1728
1743
|
var _sdktracebase = require('@opentelemetry/sdk-trace-base');
|
|
1729
1744
|
function applyContextAttributes(span) {
|
|
1730
|
-
const sessionProperties = _api.context.active().getValue(
|
|
1745
|
+
const sessionProperties = _api.context.active().getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
1731
1746
|
if (sessionProperties) {
|
|
1732
1747
|
for (const [key, value] of Object.entries(sessionProperties)) {
|
|
1733
|
-
span.setAttribute(`${
|
|
1748
|
+
span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${key}`, value);
|
|
1734
1749
|
}
|
|
1735
1750
|
}
|
|
1736
1751
|
}
|
|
@@ -1751,7 +1766,7 @@ var BrizzSimpleSpanProcessor = class extends _sdktracebase.SimpleSpanProcessor {
|
|
|
1751
1766
|
super.onStart(span, parentContext);
|
|
1752
1767
|
}
|
|
1753
1768
|
onEnd(span) {
|
|
1754
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
1769
|
+
const maskingConfig = _optionalChain([this, 'access', _63 => _63.config, 'access', _64 => _64.masking, 'optionalAccess', _65 => _65.spanMasking]);
|
|
1755
1770
|
if (maskingConfig) {
|
|
1756
1771
|
maskReadableSpan(span, maskingConfig);
|
|
1757
1772
|
}
|
|
@@ -1769,7 +1784,7 @@ var BrizzBatchSpanProcessor = class extends _sdktracebase.BatchSpanProcessor {
|
|
|
1769
1784
|
super.onStart(span, parentContext);
|
|
1770
1785
|
}
|
|
1771
1786
|
onEnd(span) {
|
|
1772
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
1787
|
+
const maskingConfig = _optionalChain([this, 'access', _66 => _66.config, 'access', _67 => _67.masking, 'optionalAccess', _68 => _68.spanMasking]);
|
|
1773
1788
|
if (maskingConfig) {
|
|
1774
1789
|
maskReadableSpan(span, maskingConfig);
|
|
1775
1790
|
}
|
|
@@ -1849,7 +1864,7 @@ var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.pro
|
|
|
1849
1864
|
}
|
|
1850
1865
|
_chunkWC573FCIcjs.logger.debug("Initializing span processor", {
|
|
1851
1866
|
disableBatch: config.disableBatch,
|
|
1852
|
-
hasMasking: !!_optionalChain([config, 'access',
|
|
1867
|
+
hasMasking: !!_optionalChain([config, 'access', _69 => _69.masking, 'optionalAccess', _70 => _70.spanMasking])
|
|
1853
1868
|
});
|
|
1854
1869
|
const spanProcessor = config.disableBatch ? new BrizzSimpleSpanProcessor(this.spanExporter, config) : new BrizzBatchSpanProcessor(this.spanExporter, config);
|
|
1855
1870
|
_chunkWC573FCIcjs.logger.debug("Span processor initialized successfully");
|
|
@@ -1929,7 +1944,7 @@ var _sdktracenode = require('@opentelemetry/sdk-trace-node');
|
|
|
1929
1944
|
|
|
1930
1945
|
// src/internal/config.ts
|
|
1931
1946
|
function resolveConfig(options) {
|
|
1932
|
-
const envLogLevel = process.env["BRIZZ_LOG_LEVEL"] || _optionalChain([options, 'access',
|
|
1947
|
+
const envLogLevel = process.env["BRIZZ_LOG_LEVEL"] || _optionalChain([options, 'access', _71 => _71.logLevel, 'optionalAccess', _72 => _72.toString, 'call', _73 => _73()]) || _chunkWC573FCIcjs.DEFAULT_LOG_LEVEL.toString();
|
|
1933
1948
|
let resolvedLogLevel;
|
|
1934
1949
|
if (envLogLevel) {
|
|
1935
1950
|
resolvedLogLevel = _chunkWC573FCIcjs.parseLogLevel.call(void 0, envLogLevel);
|
|
@@ -2100,7 +2115,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2100
2115
|
const resourceAttributes = {
|
|
2101
2116
|
...resolvedConfig.resourceAttributes,
|
|
2102
2117
|
"service.name": resolvedConfig.appName,
|
|
2103
|
-
[BRIZZ_SDK_VERSION]:
|
|
2118
|
+
[BRIZZ_SDK_VERSION]: _chunkPXIW2K27cjs.getSDKVersion.call(void 0, ),
|
|
2104
2119
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2105
2120
|
};
|
|
2106
2121
|
if (resolvedConfig.environment) {
|
|
@@ -2112,7 +2127,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2112
2127
|
const resource = _resources.defaultResource.call(void 0, ).merge(_resources.detectResources.call(void 0, { detectors: [_resources.envDetector, _resources.hostDetector, _resources.processDetector] })).merge(_resources.resourceFromAttributes.call(void 0, resourceAttributes));
|
|
2113
2128
|
this._tracerProvider = new (0, _sdktracenode.NodeTracerProvider)({
|
|
2114
2129
|
resource,
|
|
2115
|
-
spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0,
|
|
2130
|
+
spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkEVRCHF74cjs.InterruptPropagator)(), getSpanProcessor()]
|
|
2116
2131
|
});
|
|
2117
2132
|
this._tracerProvider.register();
|
|
2118
2133
|
this._meterProvider = new (0, _sdkmetrics.MeterProvider)({ resource, readers: [getMetricsReader()] });
|
|
@@ -2248,10 +2263,10 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2248
2263
|
}
|
|
2249
2264
|
try {
|
|
2250
2265
|
await this.shutdownModules();
|
|
2251
|
-
await _optionalChain([this, 'access',
|
|
2252
|
-
await _optionalChain([this, 'access',
|
|
2253
|
-
await _optionalChain([this, 'access',
|
|
2254
|
-
await _optionalChain([this, 'access',
|
|
2266
|
+
await _optionalChain([this, 'access', _74 => _74._tracerProvider, 'optionalAccess', _75 => _75.forceFlush, 'call', _76 => _76()]);
|
|
2267
|
+
await _optionalChain([this, 'access', _77 => _77._tracerProvider, 'optionalAccess', _78 => _78.shutdown, 'call', _79 => _79()]);
|
|
2268
|
+
await _optionalChain([this, 'access', _80 => _80._meterProvider, 'optionalAccess', _81 => _81.forceFlush, 'call', _82 => _82()]);
|
|
2269
|
+
await _optionalChain([this, 'access', _83 => _83._meterProvider, 'optionalAccess', _84 => _84.shutdown, 'call', _85 => _85()]);
|
|
2255
2270
|
this._initialized = false;
|
|
2256
2271
|
this._tracerProvider = null;
|
|
2257
2272
|
this._meterProvider = null;
|
|
@@ -2280,7 +2295,7 @@ function detectRuntime() {
|
|
|
2280
2295
|
const supportsLoaderAPI = (_nullishCoalesce(major, () => ( 0))) >= 21 || (_nullishCoalesce(major, () => ( 0))) === 20 && (_nullishCoalesce(minor, () => ( 0))) >= 6 || (_nullishCoalesce(major, () => ( 0))) === 18 && (_nullishCoalesce(minor, () => ( 0))) >= 19;
|
|
2281
2296
|
const supportsRegister = (
|
|
2282
2297
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2283
|
-
!!_optionalChain([process, 'access',
|
|
2298
|
+
!!_optionalChain([process, 'access', _86 => _86.features, 'optionalAccess', _87 => _87.typescript]) || !!_optionalChain([globalThis, 'access', _88 => _88.module, 'optionalAccess', _89 => _89.register])
|
|
2284
2299
|
);
|
|
2285
2300
|
_chunkWC573FCIcjs.logger.debug("Runtime detection results:", {
|
|
2286
2301
|
nodeVersion: `${_nullishCoalesce(major, () => ( 0))}.${_nullishCoalesce(minor, () => ( 0))}`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
|
|
3
|
+
var _chunk77UGZGMPcjs = require('./chunk-77UGZGMP.cjs');
|
|
4
4
|
|
|
5
5
|
// src/internal/instrumentation/vercel-ai/interrupt.ts
|
|
6
6
|
var _api = require('@opentelemetry/api');
|
|
@@ -78,7 +78,7 @@ function createInterruptIntegration() {
|
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
const value = JSON.stringify(names);
|
|
81
|
-
span.setAttribute(
|
|
81
|
+
span.setAttribute(_chunk77UGZGMPcjs.INTERRUPT_TOOLS, value);
|
|
82
82
|
setPending(span.spanContext().spanId, value);
|
|
83
83
|
};
|
|
84
84
|
return {
|
|
@@ -94,7 +94,7 @@ var InterruptPropagator = class {
|
|
|
94
94
|
const parentSpanId = _optionalChain([span, 'access', _ => _.parentSpanContext, 'optionalAccess', _2 => _2.spanId]);
|
|
95
95
|
const stashed = parentSpanId && pendingByParentSpanId.get(parentSpanId);
|
|
96
96
|
if (stashed) {
|
|
97
|
-
span.setAttribute(
|
|
97
|
+
span.setAttribute(_chunk77UGZGMPcjs.INTERRUPT_TOOLS, stashed);
|
|
98
98
|
pendingByParentSpanId.delete(parentSpanId);
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
@@ -104,7 +104,7 @@ var InterruptPropagator = class {
|
|
|
104
104
|
const scoped = parsePromptToolNames(span.attributes["ai.prompt.tools"]);
|
|
105
105
|
const names = scoped === null ? [...needsApprovalToolNames] : scoped.filter((n) => needsApprovalToolNames.has(n));
|
|
106
106
|
if (names.length > 0) {
|
|
107
|
-
span.setAttribute(
|
|
107
|
+
span.setAttribute(_chunk77UGZGMPcjs.INTERRUPT_TOOLS, JSON.stringify(names));
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
onEnd() {
|
|
@@ -12,6 +12,7 @@ var SESSION_OUTPUT_CONTEXT = "brizz.session.output.context";
|
|
|
12
12
|
var SESSION_SPAN_NAME = "brizz.start_session";
|
|
13
13
|
var MUTE_INPUT = "mute.input";
|
|
14
14
|
var MUTE_OUTPUT = "mute.output";
|
|
15
|
+
var MUTE_TOOLS = "mute.tools";
|
|
15
16
|
var USER_ID = "user.id";
|
|
16
17
|
var USER_EMAIL = "user.email";
|
|
17
18
|
var USER_NAME = "user.name";
|
|
@@ -75,6 +76,7 @@ export {
|
|
|
75
76
|
SESSION_SPAN_NAME,
|
|
76
77
|
MUTE_INPUT,
|
|
77
78
|
MUTE_OUTPUT,
|
|
79
|
+
MUTE_TOOLS,
|
|
78
80
|
USER_ID,
|
|
79
81
|
USER_EMAIL,
|
|
80
82
|
USER_NAME,
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-7SUF4VVI.js";
|
|
5
5
|
import {
|
|
6
6
|
getSDKVersion
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-6OGRVH77.js";
|
|
8
8
|
import {
|
|
9
9
|
DEFAULT_LOG_LEVEL,
|
|
10
10
|
logger,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "./chunk-Y4HNUX3Q.js";
|
|
14
14
|
import {
|
|
15
15
|
InterruptPropagator
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-EC3MYSRM.js";
|
|
17
17
|
import {
|
|
18
18
|
BRIZZ,
|
|
19
19
|
EXTERNAL_LINK_EVENT_NAME,
|
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
METRIC_VALUE,
|
|
44
44
|
MUTE_INPUT,
|
|
45
45
|
MUTE_OUTPUT,
|
|
46
|
+
MUTE_TOOLS,
|
|
46
47
|
ORGANIZATION_DOMAIN,
|
|
47
48
|
ORGANIZATION_ID,
|
|
48
49
|
ORGANIZATION_NAME,
|
|
@@ -64,7 +65,7 @@ import {
|
|
|
64
65
|
USER_NAME,
|
|
65
66
|
USER_PLAN,
|
|
66
67
|
USER_ROLE
|
|
67
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-WII4R5RE.js";
|
|
68
69
|
import {
|
|
69
70
|
__require
|
|
70
71
|
} from "./chunk-3RG5ZIWI.js";
|
|
@@ -189,7 +190,7 @@ var InstrumentationRegistry = class _InstrumentationRegistry {
|
|
|
189
190
|
const mcpModules = this.manualModules.mcp;
|
|
190
191
|
void (async () => {
|
|
191
192
|
try {
|
|
192
|
-
const { MCPInstrumentation } = await import("./mcp-
|
|
193
|
+
const { MCPInstrumentation } = await import("./mcp-ZCRMQV5L.js");
|
|
193
194
|
const instrumentation = new MCPInstrumentation({ exceptionLogger });
|
|
194
195
|
instrumentation.manuallyInstrument(mcpModules);
|
|
195
196
|
logger.debug("Manual instrumentation enabled for MCP");
|
|
@@ -1089,8 +1090,12 @@ function callWithMessageId(id, fn, thisArg, ...args) {
|
|
|
1089
1090
|
function withMessageId(id, fn, thisArg) {
|
|
1090
1091
|
return withProperties({ [MESSAGE_ID]: id }, fn, thisArg);
|
|
1091
1092
|
}
|
|
1093
|
+
function inheritedMuteTools() {
|
|
1094
|
+
const properties = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
|
|
1095
|
+
return properties?.[MUTE_TOOLS];
|
|
1096
|
+
}
|
|
1092
1097
|
function muteProperties(options) {
|
|
1093
|
-
const { input = true, output = true } = options;
|
|
1098
|
+
const { input = true, output = true, tools = output } = options;
|
|
1094
1099
|
const properties = {};
|
|
1095
1100
|
if (input) {
|
|
1096
1101
|
properties[MUTE_INPUT] = "true";
|
|
@@ -1098,6 +1103,16 @@ function muteProperties(options) {
|
|
|
1098
1103
|
if (output) {
|
|
1099
1104
|
properties[MUTE_OUTPUT] = "true";
|
|
1100
1105
|
}
|
|
1106
|
+
if (tools !== output) {
|
|
1107
|
+
properties[MUTE_TOOLS] = String(tools);
|
|
1108
|
+
} else {
|
|
1109
|
+
const inherited = inheritedMuteTools();
|
|
1110
|
+
if (tools && inherited === "false") {
|
|
1111
|
+
properties[MUTE_TOOLS] = "true";
|
|
1112
|
+
} else if (options.tools === false && inherited === "true") {
|
|
1113
|
+
properties[MUTE_TOOLS] = "false";
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1101
1116
|
return properties;
|
|
1102
1117
|
}
|
|
1103
1118
|
function callWithMute(options, fn, thisArg, ...args) {
|
package/dist/index.cjs
CHANGED
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
var
|
|
37
|
+
var _chunkCQDWK43Acjs = require('./chunk-CQDWK43A.cjs');
|
|
38
38
|
require('./chunk-UNLNNKZ7.cjs');
|
|
39
|
-
require('./chunk-
|
|
39
|
+
require('./chunk-PXIW2K27.cjs');
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
|
|
46
|
-
require('./chunk-
|
|
47
|
-
require('./chunk-
|
|
46
|
+
require('./chunk-EVRCHF74.cjs');
|
|
47
|
+
require('./chunk-77UGZGMP.cjs');
|
|
48
48
|
require('./chunk-OBGZSXTJ.cjs');
|
|
49
49
|
|
|
50
50
|
// src/internal/instrumentation/auto-init.ts
|
|
@@ -94,7 +94,7 @@ function loadGenAIInstrumentations() {
|
|
|
94
94
|
function loadMCPInstrumentation() {
|
|
95
95
|
void (async () => {
|
|
96
96
|
try {
|
|
97
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
97
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-HAUJ3G4Q.cjs")));
|
|
98
98
|
const mcp = new MCPInstrumentation({ exceptionLogger });
|
|
99
99
|
_instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp] });
|
|
100
100
|
_chunkWC573FCIcjs.logger.debug("Auto-loaded MCP instrumentation");
|
|
@@ -150,7 +150,7 @@ function loadVercelAITelemetry() {
|
|
|
150
150
|
}
|
|
151
151
|
const isV7 = typeof ai.registerTelemetry === "function";
|
|
152
152
|
const integrations = [];
|
|
153
|
-
const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-
|
|
153
|
+
const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-DM3AWSBX.cjs")));
|
|
154
154
|
integrations.push(createInterruptIntegration());
|
|
155
155
|
let otelCollectorLoaded = false;
|
|
156
156
|
try {
|
|
@@ -243,4 +243,4 @@ var init_exports = {};
|
|
|
243
243
|
|
|
244
244
|
|
|
245
245
|
|
|
246
|
-
exports.Brizz =
|
|
246
|
+
exports.Brizz = _chunkCQDWK43Acjs.Brizz; exports.DEFAULT_PII_PATTERNS = _chunkCQDWK43Acjs.DEFAULT_PII_PATTERNS; exports.LogLevel = _chunkWC573FCIcjs.LogLevel; exports.Session = _chunkCQDWK43Acjs.Session; exports.SessionTitle = _chunkCQDWK43Acjs.SessionTitle; exports.SeverityNumber = _apilogs.SeverityNumber; exports.addExternalLink = _chunkCQDWK43Acjs.addExternalLink; exports.callWithMessageId = _chunkCQDWK43Acjs.callWithMessageId; exports.callWithMute = _chunkCQDWK43Acjs.callWithMute; exports.callWithOrganization = _chunkCQDWK43Acjs.callWithOrganization; exports.callWithProperties = _chunkCQDWK43Acjs.callWithProperties; exports.callWithSessionId = _chunkCQDWK43Acjs.callWithSessionId; exports.callWithUser = _chunkCQDWK43Acjs.callWithUser; exports.detectRuntime = _chunkCQDWK43Acjs.detectRuntime; exports.emitEvent = _chunkCQDWK43Acjs.emitEvent; exports.emitEventWithSessionId = _chunkCQDWK43Acjs.emitEventWithSessionId; exports.getActiveSession = _chunkCQDWK43Acjs.getActiveSession; exports.getLogLevel = _chunkWC573FCIcjs.getLogLevel; exports.getMetricsExporter = _chunkCQDWK43Acjs.getMetricsExporter; exports.getMetricsReader = _chunkCQDWK43Acjs.getMetricsReader; exports.getSpanExporter = _chunkCQDWK43Acjs.getSpanExporter; exports.getSpanProcessor = _chunkCQDWK43Acjs.getSpanProcessor; exports.init = init_exports; exports.logger = _chunkWC573FCIcjs.logger; exports.maskAttributes = _chunkCQDWK43Acjs.maskAttributes; exports.maskValue = _chunkCQDWK43Acjs.maskValue; exports.recordFeedback = _chunkCQDWK43Acjs.recordFeedback; exports.recordMetric = _chunkCQDWK43Acjs.recordMetric; exports.setCurrentSpanCustomProperties = _chunkCQDWK43Acjs.setCurrentSpanCustomProperties; exports.setLogLevel = _chunkWC573FCIcjs.setLogLevel; exports.setMessageId = _chunkCQDWK43Acjs.setMessageId; exports.setOrganization = _chunkCQDWK43Acjs.setOrganization; exports.setUser = _chunkCQDWK43Acjs.setUser; exports.startSession = _chunkCQDWK43Acjs.startSession; exports.startSessionTitle = _chunkCQDWK43Acjs.startSessionTitle; exports.withMessageId = _chunkCQDWK43Acjs.withMessageId; exports.withMute = _chunkCQDWK43Acjs.withMute; exports.withOrganization = _chunkCQDWK43Acjs.withOrganization; exports.withProperties = _chunkCQDWK43Acjs.withProperties; exports.withSessionId = _chunkCQDWK43Acjs.withSessionId; exports.withUser = _chunkCQDWK43Acjs.withUser;
|
package/dist/index.d.cts
CHANGED
|
@@ -195,6 +195,7 @@ declare function withMessageId<F extends (this: any, ...args: any[]) => any>(id:
|
|
|
195
195
|
interface IMuteOptions {
|
|
196
196
|
input?: boolean;
|
|
197
197
|
output?: boolean;
|
|
198
|
+
tools?: boolean;
|
|
198
199
|
}
|
|
199
200
|
declare function callWithMute<A extends unknown[], F extends (...args: A) => ReturnType<F>>(options: IMuteOptions, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
|
|
200
201
|
declare function withMute<F extends (this: any, ...args: any[]) => any>(options: IMuteOptions, fn: F, thisArg?: ThisParameterType<F>): F;
|
package/dist/index.d.ts
CHANGED
|
@@ -195,6 +195,7 @@ declare function withMessageId<F extends (this: any, ...args: any[]) => any>(id:
|
|
|
195
195
|
interface IMuteOptions {
|
|
196
196
|
input?: boolean;
|
|
197
197
|
output?: boolean;
|
|
198
|
+
tools?: boolean;
|
|
198
199
|
}
|
|
199
200
|
declare function callWithMute<A extends unknown[], F extends (...args: A) => ReturnType<F>>(options: IMuteOptions, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
|
|
200
201
|
declare function withMute<F extends (this: any, ...args: any[]) => any>(options: IMuteOptions, fn: F, thisArg?: ThisParameterType<F>): F;
|
package/dist/index.js
CHANGED
|
@@ -34,17 +34,17 @@ import {
|
|
|
34
34
|
withProperties,
|
|
35
35
|
withSessionId,
|
|
36
36
|
withUser
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-YNCBWOHM.js";
|
|
38
38
|
import "./chunk-7SUF4VVI.js";
|
|
39
|
-
import "./chunk-
|
|
39
|
+
import "./chunk-6OGRVH77.js";
|
|
40
40
|
import {
|
|
41
41
|
LogLevel,
|
|
42
42
|
getLogLevel,
|
|
43
43
|
logger,
|
|
44
44
|
setLogLevel
|
|
45
45
|
} from "./chunk-Y4HNUX3Q.js";
|
|
46
|
-
import "./chunk-
|
|
47
|
-
import "./chunk-
|
|
46
|
+
import "./chunk-EC3MYSRM.js";
|
|
47
|
+
import "./chunk-WII4R5RE.js";
|
|
48
48
|
import "./chunk-3RG5ZIWI.js";
|
|
49
49
|
|
|
50
50
|
// src/internal/instrumentation/auto-init.ts
|
|
@@ -94,7 +94,7 @@ function loadGenAIInstrumentations() {
|
|
|
94
94
|
function loadMCPInstrumentation() {
|
|
95
95
|
void (async () => {
|
|
96
96
|
try {
|
|
97
|
-
const { MCPInstrumentation } = await import("./mcp-
|
|
97
|
+
const { MCPInstrumentation } = await import("./mcp-ZCRMQV5L.js");
|
|
98
98
|
const mcp = new MCPInstrumentation({ exceptionLogger });
|
|
99
99
|
registerInstrumentations({ instrumentations: [mcp] });
|
|
100
100
|
logger.debug("Auto-loaded MCP instrumentation");
|
|
@@ -150,7 +150,7 @@ function loadVercelAITelemetry() {
|
|
|
150
150
|
}
|
|
151
151
|
const isV7 = typeof ai.registerTelemetry === "function";
|
|
152
152
|
const integrations = [];
|
|
153
|
-
const { createInterruptIntegration } = await import("./interrupt-
|
|
153
|
+
const { createInterruptIntegration } = await import("./interrupt-YJVZK4VC.js");
|
|
154
154
|
integrations.push(createInterruptIntegration());
|
|
155
155
|
let otelCollectorLoaded = false;
|
|
156
156
|
try {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkEVRCHF74cjs = require('./chunk-EVRCHF74.cjs');
|
|
6
|
+
require('./chunk-77UGZGMP.cjs');
|
|
7
|
+
require('./chunk-OBGZSXTJ.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.InterruptPropagator = _chunkEVRCHF74cjs.InterruptPropagator; exports._resetInterruptState = _chunkEVRCHF74cjs._resetInterruptState; exports.createInterruptIntegration = _chunkEVRCHF74cjs.createInterruptIntegration;
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
InterruptPropagator,
|
|
3
3
|
_resetInterruptState,
|
|
4
4
|
createInterruptIntegration
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-EC3MYSRM.js";
|
|
6
|
+
import "./chunk-WII4R5RE.js";
|
|
7
7
|
import "./chunk-3RG5ZIWI.js";
|
|
8
8
|
export {
|
|
9
9
|
InterruptPropagator,
|
|
@@ -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
|
|
3
|
+
var _chunkPXIW2K27cjs = require('./chunk-PXIW2K27.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
|
|
@@ -8,7 +8,7 @@ var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk77UGZGMPcjs = require('./chunk-77UGZGMP.cjs');
|
|
12
12
|
require('./chunk-OBGZSXTJ.cjs');
|
|
13
13
|
|
|
14
14
|
// src/internal/instrumentation/mcp/instrumentation.ts
|
|
@@ -139,7 +139,7 @@ function stampAndPropagateSession(span, sessionId, baseContext = _api.context.ac
|
|
|
139
139
|
}
|
|
140
140
|
if (span.isRecording()) {
|
|
141
141
|
try {
|
|
142
|
-
span.setAttribute(`${
|
|
142
|
+
span.setAttribute(`${_chunk77UGZGMPcjs.BRIZZ}.${_chunk77UGZGMPcjs.SESSION_ID}`, sessionId);
|
|
143
143
|
} catch (error) {
|
|
144
144
|
_chunkWC573FCIcjs.logger.warn(
|
|
145
145
|
`Brizz MCP: failed to stamp session id on span: ${String(error)}`
|
|
@@ -147,10 +147,10 @@ function stampAndPropagateSession(span, sessionId, baseContext = _api.context.ac
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
try {
|
|
150
|
-
const prev = baseContext.getValue(
|
|
151
|
-
const merged = prev ? { ...prev, [
|
|
150
|
+
const prev = baseContext.getValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY);
|
|
151
|
+
const merged = prev ? { ...prev, [_chunk77UGZGMPcjs.SESSION_ID]: sessionId } : { [_chunk77UGZGMPcjs.SESSION_ID]: sessionId };
|
|
152
152
|
return {
|
|
153
|
-
context: baseContext.setValue(
|
|
153
|
+
context: baseContext.setValue(_chunk77UGZGMPcjs.PROPERTIES_CONTEXT_KEY, merged),
|
|
154
154
|
sessionId
|
|
155
155
|
};
|
|
156
156
|
} catch (error) {
|
|
@@ -570,7 +570,7 @@ function safeEnd(span) {
|
|
|
570
570
|
|
|
571
571
|
// src/internal/instrumentation/mcp/version.ts
|
|
572
572
|
var INSTRUMENTATION_NAME = "@brizz/sdk/mcp";
|
|
573
|
-
var INSTRUMENTATION_VERSION =
|
|
573
|
+
var INSTRUMENTATION_VERSION = _chunkPXIW2K27cjs.getSDKVersion.call(void 0, );
|
|
574
574
|
|
|
575
575
|
// src/internal/instrumentation/mcp/instrumentation.ts
|
|
576
576
|
var PROTOCOL_MODULE_NAME = "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSDKVersion
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6OGRVH77.js";
|
|
4
4
|
import {
|
|
5
5
|
logger
|
|
6
6
|
} from "./chunk-Y4HNUX3Q.js";
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
BRIZZ,
|
|
9
9
|
PROPERTIES_CONTEXT_KEY,
|
|
10
10
|
SESSION_ID
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-WII4R5RE.js";
|
|
12
12
|
import "./chunk-3RG5ZIWI.js";
|
|
13
13
|
|
|
14
14
|
// src/internal/instrumentation/mcp/instrumentation.ts
|
package/dist/preload.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkCQDWK43Acjs = require('./chunk-CQDWK43A.cjs');
|
|
5
5
|
require('./chunk-UNLNNKZ7.cjs');
|
|
6
|
-
require('./chunk-
|
|
6
|
+
require('./chunk-PXIW2K27.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
|
|
11
|
-
require('./chunk-
|
|
12
|
-
require('./chunk-
|
|
11
|
+
require('./chunk-EVRCHF74.cjs');
|
|
12
|
+
require('./chunk-77UGZGMP.cjs');
|
|
13
13
|
require('./chunk-OBGZSXTJ.cjs');
|
|
14
14
|
|
|
15
15
|
// src/node/loader.ts
|
|
@@ -96,16 +96,16 @@ if (globalThis[LOADER_REGISTERED_KEY] !== true) {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// src/preload.ts
|
|
99
|
-
var runtime =
|
|
99
|
+
var runtime = _chunkCQDWK43Acjs.detectRuntime.call(void 0, );
|
|
100
100
|
if (runtime.isESM && runtime.supportsLoaderAPI) {
|
|
101
101
|
maybeRegisterESMLoader();
|
|
102
102
|
}
|
|
103
103
|
try {
|
|
104
104
|
const logLevel = process.env["BRIZZ_LOG_LEVEL"] || _chunkWC573FCIcjs.DEFAULT_LOG_LEVEL.toString();
|
|
105
105
|
if (process.env["BRIZZ_DSN"]) {
|
|
106
|
-
|
|
106
|
+
_chunkCQDWK43Acjs.Brizz.initialize({ logLevel, disableNodeSdk: false });
|
|
107
107
|
} else {
|
|
108
|
-
|
|
108
|
+
_chunkCQDWK43Acjs.Brizz.initialize({
|
|
109
109
|
apiKey: process.env["BRIZZ_API_KEY"],
|
|
110
110
|
baseUrl: process.env["BRIZZ_BASE_URL"],
|
|
111
111
|
appName: process.env["BRIZZ_APP_NAME"] || process.env["OTEL_SERVICE_NAME"],
|
package/dist/preload.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Brizz,
|
|
3
3
|
detectRuntime
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YNCBWOHM.js";
|
|
5
5
|
import "./chunk-7SUF4VVI.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-6OGRVH77.js";
|
|
7
7
|
import {
|
|
8
8
|
DEFAULT_LOG_LEVEL,
|
|
9
9
|
logger
|
|
10
10
|
} from "./chunk-Y4HNUX3Q.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-EC3MYSRM.js";
|
|
12
|
+
import "./chunk-WII4R5RE.js";
|
|
13
13
|
import "./chunk-3RG5ZIWI.js";
|
|
14
14
|
|
|
15
15
|
// src/node/loader.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brizz/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.36",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenTelemetry-based observability SDK for AI applications",
|
|
6
6
|
"keywords": [
|
|
@@ -106,22 +106,22 @@
|
|
|
106
106
|
"registry": "https://registry.npmjs.org/"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@ai-sdk/anthropic": "^4.0.
|
|
110
|
-
"@ai-sdk/openai": "^4.0.
|
|
111
|
-
"@ai-sdk/otel": "^1.0.
|
|
109
|
+
"@ai-sdk/anthropic": "^4.0.16",
|
|
110
|
+
"@ai-sdk/openai": "^4.0.16",
|
|
111
|
+
"@ai-sdk/otel": "^1.0.31",
|
|
112
112
|
"@arizeai/openinference-instrumentation-mcp": "^0.2.20",
|
|
113
113
|
"@changesets/changelog-github": "^0.7.0",
|
|
114
|
-
"@changesets/cli": "^2.
|
|
114
|
+
"@changesets/cli": "^2.31.1",
|
|
115
115
|
"@eslint/js": "^10.0.1",
|
|
116
|
-
"@google/genai": "^2.
|
|
116
|
+
"@google/genai": "^2.12.0",
|
|
117
117
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
118
118
|
"@traceloop/instrumentation-google-generativeai": "^0.27.0",
|
|
119
119
|
"@traceloop/instrumentation-vertexai": "^0.27.0",
|
|
120
120
|
"@types/jest": "^30.0.0",
|
|
121
121
|
"@types/node": "^26.1.1",
|
|
122
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
123
|
-
"@typescript-eslint/parser": "^8.
|
|
124
|
-
"ai": "^7.0.
|
|
122
|
+
"@typescript-eslint/eslint-plugin": "^8.64.0",
|
|
123
|
+
"@typescript-eslint/parser": "^8.64.0",
|
|
124
|
+
"ai": "^7.0.31",
|
|
125
125
|
"eslint": "^10.7.0",
|
|
126
126
|
"eslint-config-prettier": "^10.1.8",
|
|
127
127
|
"eslint-plugin-import": "^2.32.0",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"eslint-plugin-unicorn": "^71.1.0",
|
|
130
130
|
"jest": "^30.4.2",
|
|
131
131
|
"jest-environment-jsdom": "^30.4.1",
|
|
132
|
-
"openai": "^6.
|
|
132
|
+
"openai": "^6.48.0",
|
|
133
133
|
"prettier": "^3.9.5",
|
|
134
134
|
"ts-jest": "^29.4.11",
|
|
135
135
|
"tsup": "^8.5.1",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _chunkM3UGFLH7cjs = require('./chunk-M3UGFLH7.cjs');
|
|
6
|
-
require('./chunk-NEF2O7HF.cjs');
|
|
7
|
-
require('./chunk-OBGZSXTJ.cjs');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.InterruptPropagator = _chunkM3UGFLH7cjs.InterruptPropagator; exports._resetInterruptState = _chunkM3UGFLH7cjs._resetInterruptState; exports.createInterruptIntegration = _chunkM3UGFLH7cjs.createInterruptIntegration;
|