@brizz/sdk 0.1.32 → 0.1.34

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.
@@ -1,6 +1,6 @@
1
1
  // src/internal/version.ts
2
2
  function getSDKVersion() {
3
- return "0.1.32";
3
+ return "0.1.34";
4
4
  }
5
5
 
6
6
  export {
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-7SUF4VVI.js";
5
5
  import {
6
6
  getSDKVersion
7
- } from "./chunk-6M3CBP2N.js";
7
+ } from "./chunk-64STNQKL.js";
8
8
  import {
9
9
  DEFAULT_LOG_LEVEL,
10
10
  logger,
@@ -13,17 +13,42 @@ import {
13
13
  } from "./chunk-Y4HNUX3Q.js";
14
14
  import {
15
15
  InterruptPropagator
16
- } from "./chunk-LTLONC6I.js";
16
+ } from "./chunk-24CEDVD2.js";
17
17
  import {
18
18
  BRIZZ,
19
19
  EXTERNAL_LINK_EVENT_NAME,
20
20
  EXTERNAL_LINK_TITLE,
21
21
  EXTERNAL_LINK_TYPE,
22
22
  EXTERNAL_LINK_URL,
23
+ FEEDBACK_ATTR_PREFIX,
24
+ FEEDBACK_COMMENT,
25
+ FEEDBACK_EVENT_NAME,
26
+ FEEDBACK_REASON,
27
+ FEEDBACK_SCORE,
28
+ FEEDBACK_SOURCE,
29
+ FEEDBACK_TYPE,
23
30
  INTERNAL_EVENT_PREFIX,
31
+ MESSAGE_ID,
32
+ METRIC_ATTRIBUTE_PREFIX,
33
+ METRIC_COMMENT,
34
+ METRIC_EVENT_NAME,
35
+ METRIC_MAX,
36
+ METRIC_MIN,
37
+ METRIC_NAME,
38
+ METRIC_POLARITY,
39
+ METRIC_POLARITY_NEGATIVE,
40
+ METRIC_POLARITY_POSITIVE,
41
+ METRIC_TIMESTAMP,
42
+ METRIC_UNIT,
43
+ METRIC_VALUE,
24
44
  MUTE_INPUT,
25
45
  MUTE_OUTPUT,
46
+ ORGANIZATION_DOMAIN,
47
+ ORGANIZATION_ID,
48
+ ORGANIZATION_NAME,
49
+ ORGANIZATION_PLAN,
26
50
  PROPERTIES_CONTEXT_KEY,
51
+ RESERVED_METRIC_NAMES,
27
52
  SESSION_ID,
28
53
  SESSION_INPUT,
29
54
  SESSION_INPUT_CONTEXT,
@@ -33,8 +58,13 @@ import {
33
58
  SESSION_SPAN_NAME,
34
59
  SESSION_TITLE,
35
60
  SESSION_TITLE_GENERATION,
36
- SESSION_TITLE_SPAN_NAME
37
- } from "./chunk-VGMJ3KUM.js";
61
+ SESSION_TITLE_SPAN_NAME,
62
+ USER_EMAIL,
63
+ USER_ID,
64
+ USER_NAME,
65
+ USER_PLAN,
66
+ USER_ROLE
67
+ } from "./chunk-QY4VADPP.js";
38
68
  import {
39
69
  __require
40
70
  } from "./chunk-3RG5ZIWI.js";
@@ -144,7 +174,7 @@ var InstrumentationRegistry = class _InstrumentationRegistry {
144
174
  const mcpModules = this.manualModules.mcp;
145
175
  void (async () => {
146
176
  try {
147
- const { MCPInstrumentation } = await import("./mcp-3YERODPL.js");
177
+ const { MCPInstrumentation } = await import("./mcp-ZP6AY3FE.js");
148
178
  const instrumentation = new MCPInstrumentation({ exceptionLogger });
149
179
  instrumentation.manuallyInstrument(mcpModules);
150
180
  logger.debug("Manual instrumentation enabled for MCP");
@@ -914,6 +944,136 @@ function withProperties(properties, fn, thisArg) {
914
944
  );
915
945
  };
916
946
  }
947
+ function propagatePropertiesImperatively(properties) {
948
+ try {
949
+ const manager = context2;
950
+ const mgr = manager._getContextManager?.();
951
+ const store = mgr?._asyncLocalStorage;
952
+ if (!store || typeof store.enterWith !== "function") {
953
+ return;
954
+ }
955
+ const base = context2.active();
956
+ const prev = base.getValue(PROPERTIES_CONTEXT_KEY);
957
+ const merged = prev ? { ...prev, ...properties } : properties;
958
+ store.enterWith(base.setValue(PROPERTIES_CONTEXT_KEY, merged));
959
+ } catch {
960
+ }
961
+ }
962
+ function setUser(user) {
963
+ const properties = { [USER_ID]: user.id };
964
+ if (user.email !== void 0) {
965
+ properties[USER_EMAIL] = user.email;
966
+ }
967
+ if (user.name !== void 0) {
968
+ properties[USER_NAME] = user.name;
969
+ }
970
+ if (user.role !== void 0) {
971
+ properties[USER_ROLE] = user.role;
972
+ }
973
+ if (user.plan !== void 0) {
974
+ properties[USER_PLAN] = user.plan;
975
+ }
976
+ if (user.traits) {
977
+ for (const [key, value] of Object.entries(user.traits)) {
978
+ const k = `user.${key}`;
979
+ if (properties[k] === void 0) {
980
+ properties[k] = value;
981
+ }
982
+ }
983
+ }
984
+ setCurrentSpanCustomProperties(properties);
985
+ propagatePropertiesImperatively(properties);
986
+ }
987
+ function setOrganization(org) {
988
+ const properties = { [ORGANIZATION_ID]: org.id };
989
+ if (org.name !== void 0) {
990
+ properties[ORGANIZATION_NAME] = org.name;
991
+ }
992
+ if (org.plan !== void 0) {
993
+ properties[ORGANIZATION_PLAN] = org.plan;
994
+ }
995
+ if (org.domain !== void 0) {
996
+ properties[ORGANIZATION_DOMAIN] = org.domain;
997
+ }
998
+ if (org.traits) {
999
+ for (const [key, value] of Object.entries(org.traits)) {
1000
+ const k = `organization.${key}`;
1001
+ if (properties[k] === void 0) {
1002
+ properties[k] = value;
1003
+ }
1004
+ }
1005
+ }
1006
+ setCurrentSpanCustomProperties(properties);
1007
+ propagatePropertiesImperatively(properties);
1008
+ }
1009
+ function setMessageId(id) {
1010
+ const properties = { [MESSAGE_ID]: id };
1011
+ setCurrentSpanCustomProperties(properties);
1012
+ propagatePropertiesImperatively(properties);
1013
+ }
1014
+ function userProperties(user) {
1015
+ const properties = { [USER_ID]: user.id };
1016
+ if (user.email !== void 0) {
1017
+ properties[USER_EMAIL] = user.email;
1018
+ }
1019
+ if (user.name !== void 0) {
1020
+ properties[USER_NAME] = user.name;
1021
+ }
1022
+ if (user.role !== void 0) {
1023
+ properties[USER_ROLE] = user.role;
1024
+ }
1025
+ if (user.plan !== void 0) {
1026
+ properties[USER_PLAN] = user.plan;
1027
+ }
1028
+ if (user.traits) {
1029
+ for (const [key, value] of Object.entries(user.traits)) {
1030
+ const k = `user.${key}`;
1031
+ if (properties[k] === void 0) {
1032
+ properties[k] = value;
1033
+ }
1034
+ }
1035
+ }
1036
+ return properties;
1037
+ }
1038
+ function organizationProperties(org) {
1039
+ const properties = { [ORGANIZATION_ID]: org.id };
1040
+ if (org.name !== void 0) {
1041
+ properties[ORGANIZATION_NAME] = org.name;
1042
+ }
1043
+ if (org.plan !== void 0) {
1044
+ properties[ORGANIZATION_PLAN] = org.plan;
1045
+ }
1046
+ if (org.domain !== void 0) {
1047
+ properties[ORGANIZATION_DOMAIN] = org.domain;
1048
+ }
1049
+ if (org.traits) {
1050
+ for (const [key, value] of Object.entries(org.traits)) {
1051
+ const k = `organization.${key}`;
1052
+ if (properties[k] === void 0) {
1053
+ properties[k] = value;
1054
+ }
1055
+ }
1056
+ }
1057
+ return properties;
1058
+ }
1059
+ function callWithUser(user, fn, thisArg, ...args) {
1060
+ return callWithProperties(userProperties(user), fn, thisArg, ...args);
1061
+ }
1062
+ function withUser(user, fn, thisArg) {
1063
+ return withProperties(userProperties(user), fn, thisArg);
1064
+ }
1065
+ function callWithOrganization(org, fn, thisArg, ...args) {
1066
+ return callWithProperties(organizationProperties(org), fn, thisArg, ...args);
1067
+ }
1068
+ function withOrganization(org, fn, thisArg) {
1069
+ return withProperties(organizationProperties(org), fn, thisArg);
1070
+ }
1071
+ function callWithMessageId(id, fn, thisArg, ...args) {
1072
+ return callWithProperties({ [MESSAGE_ID]: id }, fn, thisArg, ...args);
1073
+ }
1074
+ function withMessageId(id, fn, thisArg) {
1075
+ return withProperties({ [MESSAGE_ID]: id }, fn, thisArg);
1076
+ }
917
1077
  function muteProperties(options) {
918
1078
  const { input = true, output = true } = options;
919
1079
  const properties = {};
@@ -1002,6 +1162,55 @@ var Session = class {
1002
1162
  this.span.setAttribute(`${BRIZZ}.${key}`, value);
1003
1163
  }
1004
1164
  }
1165
+ /**
1166
+ * Set end-user identity on the session span: `brizz.user.id` and, when
1167
+ * provided, `brizz.user.email` / `brizz.user.name`. Undefined fields are omitted.
1168
+ *
1169
+ * @param user - User identity (`id` required; `email` / `name` optional)
1170
+ */
1171
+ setUser(user) {
1172
+ if (user.traits) {
1173
+ for (const [key, value] of Object.entries(user.traits)) {
1174
+ this.span.setAttribute(`${BRIZZ}.user.${key}`, value);
1175
+ }
1176
+ }
1177
+ this.span.setAttribute(`${BRIZZ}.${USER_ID}`, user.id);
1178
+ if (user.email !== void 0) {
1179
+ this.span.setAttribute(`${BRIZZ}.${USER_EMAIL}`, user.email);
1180
+ }
1181
+ if (user.name !== void 0) {
1182
+ this.span.setAttribute(`${BRIZZ}.${USER_NAME}`, user.name);
1183
+ }
1184
+ if (user.role !== void 0) {
1185
+ this.span.setAttribute(`${BRIZZ}.${USER_ROLE}`, user.role);
1186
+ }
1187
+ if (user.plan !== void 0) {
1188
+ this.span.setAttribute(`${BRIZZ}.${USER_PLAN}`, user.plan);
1189
+ }
1190
+ }
1191
+ /**
1192
+ * Set organization identity on the session span: `brizz.organization.id` and,
1193
+ * when provided, `brizz.organization.name`. Undefined fields are omitted.
1194
+ *
1195
+ * @param org - Organization identity (`id` required; `name` optional)
1196
+ */
1197
+ setOrganization(org) {
1198
+ if (org.traits) {
1199
+ for (const [key, value] of Object.entries(org.traits)) {
1200
+ this.span.setAttribute(`${BRIZZ}.organization.${key}`, value);
1201
+ }
1202
+ }
1203
+ this.span.setAttribute(`${BRIZZ}.${ORGANIZATION_ID}`, org.id);
1204
+ if (org.name !== void 0) {
1205
+ this.span.setAttribute(`${BRIZZ}.${ORGANIZATION_NAME}`, org.name);
1206
+ }
1207
+ if (org.plan !== void 0) {
1208
+ this.span.setAttribute(`${BRIZZ}.${ORGANIZATION_PLAN}`, org.plan);
1209
+ }
1210
+ if (org.domain !== void 0) {
1211
+ this.span.setAttribute(`${BRIZZ}.${ORGANIZATION_DOMAIN}`, org.domain);
1212
+ }
1213
+ }
1005
1214
  /**
1006
1215
  * Attach an external link (URL) to this session.
1007
1216
  *
@@ -1043,6 +1252,10 @@ function resolveSessionIdFromContext() {
1043
1252
  const props = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
1044
1253
  return props?.[SESSION_ID];
1045
1254
  }
1255
+ function resolveMessageIdFromContext() {
1256
+ const props = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
1257
+ return props?.[MESSAGE_ID];
1258
+ }
1046
1259
  function emitExternalLink(sessionId, url, title, linkType) {
1047
1260
  try {
1048
1261
  emitEventWithSessionId(sessionId, EXTERNAL_LINK_EVENT_NAME, {
@@ -1064,6 +1277,174 @@ function addExternalLink(url, options) {
1064
1277
  }
1065
1278
  emitExternalLink(sessionId, url, options?.title, options?.linkType);
1066
1279
  }
1280
+ function recordFeedback(type, options) {
1281
+ const eventAttributes = { [FEEDBACK_TYPE]: type };
1282
+ if (options?.score !== void 0) {
1283
+ eventAttributes[FEEDBACK_SCORE] = options.score;
1284
+ }
1285
+ if (options?.reason !== void 0) {
1286
+ eventAttributes[FEEDBACK_REASON] = options.reason;
1287
+ }
1288
+ if (options?.comment !== void 0) {
1289
+ eventAttributes[FEEDBACK_COMMENT] = options.comment;
1290
+ }
1291
+ if (options?.source !== void 0) {
1292
+ eventAttributes[FEEDBACK_SOURCE] = options.source;
1293
+ }
1294
+ if (options?.attributes) {
1295
+ for (const [key, value] of Object.entries(options.attributes)) {
1296
+ const k = `${FEEDBACK_ATTR_PREFIX}${key}`;
1297
+ if (eventAttributes[k] === void 0) {
1298
+ eventAttributes[k] = value;
1299
+ }
1300
+ }
1301
+ }
1302
+ const messageId = options?.messageId ?? resolveMessageIdFromContext();
1303
+ const sessionId = options?.sessionId ?? resolveSessionIdFromContext();
1304
+ if (messageId === void 0 && sessionId === void 0) {
1305
+ logger.warn(
1306
+ "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."
1307
+ );
1308
+ }
1309
+ const anchor = {};
1310
+ if (messageId !== void 0) {
1311
+ anchor[MESSAGE_ID] = messageId;
1312
+ }
1313
+ if (sessionId !== void 0) {
1314
+ anchor[SESSION_ID] = sessionId;
1315
+ }
1316
+ try {
1317
+ if (Object.keys(anchor).length === 0) {
1318
+ emitEvent(FEEDBACK_EVENT_NAME, eventAttributes);
1319
+ } else {
1320
+ callWithProperties(anchor, () => emitEvent(FEEDBACK_EVENT_NAME, eventAttributes));
1321
+ }
1322
+ } catch (error) {
1323
+ logger.warn("recordFeedback: failed to emit feedback event", error);
1324
+ }
1325
+ }
1326
+ var METRIC_NAME_PATTERN = /^[a-z][a-z0-9_.-]{0,63}$/;
1327
+ var METRIC_COMMENT_MAX_LEN = 4096;
1328
+ var METRIC_ATTRIBUTES_MAX = 20;
1329
+ var METRIC_ATTRIBUTE_VALUE_MAX_LEN = 256;
1330
+ function recordMetric(options) {
1331
+ try {
1332
+ recordMetricImpl(options);
1333
+ } catch (error) {
1334
+ logger.warn(`recordMetric(${JSON.stringify(options?.name)}) failed; metric dropped.`, error);
1335
+ }
1336
+ }
1337
+ function recordMetricImpl(options) {
1338
+ const name = typeof options.name === "string" ? options.name.toLowerCase() : "";
1339
+ if (!METRIC_NAME_PATTERN.test(name)) {
1340
+ logger.warn(
1341
+ `recordMetric called with an invalid name ${JSON.stringify(options.name)}; metric dropped. Names must match ${METRIC_NAME_PATTERN.source} after lowercasing.`
1342
+ );
1343
+ return;
1344
+ }
1345
+ if (RESERVED_METRIC_NAMES.has(name)) {
1346
+ logger.warn(
1347
+ `recordMetric called with the reserved name ${JSON.stringify(name)}; metric dropped. Brizz computes this metric itself \u2014 pick a different name.`
1348
+ );
1349
+ return;
1350
+ }
1351
+ const { value } = options;
1352
+ let numericValue;
1353
+ if (typeof value === "boolean") {
1354
+ numericValue = value ? 1 : 0;
1355
+ } else if (typeof value === "number" && Number.isFinite(value)) {
1356
+ numericValue = value;
1357
+ } else {
1358
+ logger.warn(
1359
+ `recordMetric(${name}) called with a non-finite or non-numeric value ${JSON.stringify(value)}; metric dropped.`
1360
+ );
1361
+ return;
1362
+ }
1363
+ const eventAttributes = {
1364
+ [METRIC_NAME]: name,
1365
+ [METRIC_VALUE]: numericValue
1366
+ };
1367
+ if (options.unit !== void 0) {
1368
+ eventAttributes[METRIC_UNIT] = options.unit;
1369
+ }
1370
+ if (options.minValue !== void 0) {
1371
+ eventAttributes[METRIC_MIN] = options.minValue;
1372
+ }
1373
+ if (options.maxValue !== void 0) {
1374
+ eventAttributes[METRIC_MAX] = options.maxValue;
1375
+ }
1376
+ if (options.comment !== void 0) {
1377
+ let comment = options.comment;
1378
+ if (comment.length > METRIC_COMMENT_MAX_LEN) {
1379
+ logger.warn(
1380
+ `recordMetric(${name}) comment exceeds ${METRIC_COMMENT_MAX_LEN} characters; truncated.`
1381
+ );
1382
+ comment = comment.slice(0, METRIC_COMMENT_MAX_LEN);
1383
+ }
1384
+ eventAttributes[METRIC_COMMENT] = comment;
1385
+ }
1386
+ if (options.polarity !== void 0) {
1387
+ const polarity = options.polarity;
1388
+ if (polarity === METRIC_POLARITY_POSITIVE || polarity === METRIC_POLARITY_NEGATIVE) {
1389
+ eventAttributes[METRIC_POLARITY] = polarity;
1390
+ } else {
1391
+ logger.warn(
1392
+ `recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${METRIC_POLARITY_POSITIVE}' or '${METRIC_POLARITY_NEGATIVE}'. Emitting the metric without it.`
1393
+ );
1394
+ }
1395
+ }
1396
+ if (options.timestamp !== void 0) {
1397
+ if (Number.isFinite(options.timestamp.getTime())) {
1398
+ eventAttributes[METRIC_TIMESTAMP] = options.timestamp.toISOString();
1399
+ } else {
1400
+ logger.warn(
1401
+ `recordMetric(${name}) called with an invalid timestamp; emitting the metric without it.`
1402
+ );
1403
+ }
1404
+ }
1405
+ if (options.attributes) {
1406
+ let accepted = 0;
1407
+ for (const [key, attrValue] of Object.entries(options.attributes)) {
1408
+ if (accepted >= METRIC_ATTRIBUTES_MAX) {
1409
+ logger.warn(
1410
+ `recordMetric(${name}) called with more than ${METRIC_ATTRIBUTES_MAX} attributes; the excess was dropped.`
1411
+ );
1412
+ break;
1413
+ }
1414
+ const normalizedKey = key.toLowerCase();
1415
+ if (!METRIC_NAME_PATTERN.test(normalizedKey)) {
1416
+ logger.warn(
1417
+ `recordMetric(${name}) called with an invalid attribute key ${JSON.stringify(key)}; that attribute was dropped. Keys must match ${METRIC_NAME_PATTERN.source} after lowercasing.`
1418
+ );
1419
+ continue;
1420
+ }
1421
+ let text = typeof attrValue === "string" ? attrValue : String(attrValue);
1422
+ if (text.length > METRIC_ATTRIBUTE_VALUE_MAX_LEN) {
1423
+ logger.warn(
1424
+ `recordMetric(${name}) attribute ${JSON.stringify(normalizedKey)} exceeds ${METRIC_ATTRIBUTE_VALUE_MAX_LEN} characters; truncated.`
1425
+ );
1426
+ text = text.slice(0, METRIC_ATTRIBUTE_VALUE_MAX_LEN);
1427
+ }
1428
+ eventAttributes[`${METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
1429
+ accepted += 1;
1430
+ }
1431
+ }
1432
+ const sessionId = options.sessionId ?? resolveSessionIdFromContext();
1433
+ if (sessionId === void 0) {
1434
+ logger.warn(
1435
+ `recordMetric(${name}) called with no resolvable session id; the metric cannot be attributed to a conversation and is dropped. Pass options.sessionId or call inside a startSession/callWithSessionId scope.`
1436
+ );
1437
+ return;
1438
+ }
1439
+ try {
1440
+ callWithProperties(
1441
+ { [SESSION_ID]: sessionId },
1442
+ () => emitEvent(METRIC_EVENT_NAME, eventAttributes)
1443
+ );
1444
+ } catch (error) {
1445
+ logger.warn("recordMetric: failed to emit metric event", error);
1446
+ }
1447
+ }
1067
1448
  function startSession(sessionId, callback, extraProperties, options) {
1068
1449
  const isTitle = options?.mode === "title";
1069
1450
  const spanName = isTitle ? SESSION_TITLE_SPAN_NAME : SESSION_SPAN_NAME;
@@ -1922,6 +2303,15 @@ export {
1922
2303
  setCurrentSpanCustomProperties,
1923
2304
  callWithProperties,
1924
2305
  withProperties,
2306
+ setUser,
2307
+ setOrganization,
2308
+ setMessageId,
2309
+ callWithUser,
2310
+ withUser,
2311
+ callWithOrganization,
2312
+ withOrganization,
2313
+ callWithMessageId,
2314
+ withMessageId,
1925
2315
  callWithMute,
1926
2316
  withMute,
1927
2317
  withSessionId,
@@ -1930,6 +2320,8 @@ export {
1930
2320
  SessionTitle,
1931
2321
  getActiveSession,
1932
2322
  addExternalLink,
2323
+ recordFeedback,
2324
+ recordMetric,
1933
2325
  startSession,
1934
2326
  startSessionTitle,
1935
2327
  DEFAULT_PII_PATTERNS,
@@ -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 _chunkOZCOXBB7cjs = require('./chunk-OZCOXBB7.cjs');
3
+ var _chunkNEF2O7HFcjs = require('./chunk-NEF2O7HF.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(_chunkOZCOXBB7cjs.INTERRUPT_TOOLS, value);
81
+ span.setAttribute(_chunkNEF2O7HFcjs.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(_chunkOZCOXBB7cjs.INTERRUPT_TOOLS, stashed);
97
+ span.setAttribute(_chunkNEF2O7HFcjs.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(_chunkOZCOXBB7cjs.INTERRUPT_TOOLS, JSON.stringify(names));
107
+ span.setAttribute(_chunkNEF2O7HFcjs.INTERRUPT_TOOLS, JSON.stringify(names));
108
108
  }
109
109
  }
110
110
  onEnd() {
@@ -0,0 +1,117 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/internal/semantic-conventions.ts
2
+ var _api = require('@opentelemetry/api');
3
+ var BRIZZ = "brizz";
4
+ var PROPERTIES = "properties";
5
+ var SESSION_ID = "session.id";
6
+ var PROPERTIES_CONTEXT_KEY = _api.createContextKey.call(void 0, PROPERTIES);
7
+ var SESSION_OBJECT_CONTEXT_KEY = _api.createContextKey.call(void 0, "brizz.session.object");
8
+ var SESSION_INPUT = "brizz.session.input";
9
+ var SESSION_OUTPUT = "brizz.session.output";
10
+ var SESSION_INPUT_CONTEXT = "brizz.session.input.context";
11
+ var SESSION_OUTPUT_CONTEXT = "brizz.session.output.context";
12
+ var SESSION_SPAN_NAME = "brizz.start_session";
13
+ var MUTE_INPUT = "mute.input";
14
+ var MUTE_OUTPUT = "mute.output";
15
+ var USER_ID = "user.id";
16
+ var USER_EMAIL = "user.email";
17
+ var USER_NAME = "user.name";
18
+ var USER_ROLE = "user.role";
19
+ var USER_PLAN = "user.plan";
20
+ var ORGANIZATION_ID = "organization.id";
21
+ var ORGANIZATION_NAME = "organization.name";
22
+ var ORGANIZATION_PLAN = "organization.plan";
23
+ var ORGANIZATION_DOMAIN = "organization.domain";
24
+ var MESSAGE_ID = "message.id";
25
+ var SESSION_TITLE_SPAN_NAME = "brizz.session_title";
26
+ var SESSION_TITLE_GENERATION = "session.title_generation";
27
+ var SESSION_TITLE = "brizz.session.title";
28
+ var INTERRUPT_TOOLS = "brizz.internal.interrupt";
29
+ var INTERNAL_EVENT_PREFIX = "brizz.internal.";
30
+ var EXTERNAL_LINK_EVENT_NAME = "brizz.internal.external_link";
31
+ var EXTERNAL_LINK_URL = "brizz.internal.external_link.url";
32
+ var EXTERNAL_LINK_TITLE = "brizz.internal.external_link.title";
33
+ var EXTERNAL_LINK_TYPE = "brizz.internal.external_link.type";
34
+ var FEEDBACK_EVENT_NAME = "brizz.feedback";
35
+ var FEEDBACK_TYPE = "brizz.feedback.type";
36
+ var FEEDBACK_SCORE = "brizz.feedback.score";
37
+ var FEEDBACK_REASON = "brizz.feedback.reason";
38
+ var FEEDBACK_COMMENT = "brizz.feedback.comment";
39
+ var FEEDBACK_SOURCE = "brizz.feedback.source";
40
+ var FEEDBACK_ATTR_PREFIX = "brizz.feedback.";
41
+ var METRIC_EVENT_NAME = "brizz.internal.metric";
42
+ var METRIC_NAME = "brizz.internal.metric.name";
43
+ var METRIC_VALUE = "brizz.internal.metric.value";
44
+ var METRIC_UNIT = "brizz.internal.metric.unit";
45
+ var METRIC_COMMENT = "brizz.internal.metric.comment";
46
+ var METRIC_POLARITY = "brizz.internal.metric.polarity";
47
+ var METRIC_MIN = "brizz.internal.metric.min";
48
+ var METRIC_MAX = "brizz.internal.metric.max";
49
+ var METRIC_TIMESTAMP = "brizz.internal.metric.timestamp";
50
+ var METRIC_ATTRIBUTE_PREFIX = "brizz.internal.metric.attribute.";
51
+ var RESERVED_METRIC_NAMES = /* @__PURE__ */ new Set([
52
+ "faithfulness",
53
+ "answer_relevancy",
54
+ "toxicity",
55
+ "task_completion_v2",
56
+ "prompt_alignment",
57
+ "user_frustration",
58
+ "user_satisfaction_v2",
59
+ "repetitiveness",
60
+ "session_outcome",
61
+ "response_time"
62
+ ]);
63
+ var METRIC_POLARITY_POSITIVE = "positive";
64
+ var METRIC_POLARITY_NEGATIVE = "negative";
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+ 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.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;