@friskai/frisk-js 0.2.8 → 0.2.10

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.
@@ -1434,7 +1434,7 @@ var require_max = __commonJS((exports) => {
1434
1434
  value: true
1435
1435
  });
1436
1436
  exports.default = undefined;
1437
- var _default2 = exports.default = "ffffffff-ffff-ffff-ffff-ffffffffffff";
1437
+ var _default = exports.default = "ffffffff-ffff-ffff-ffff-ffffffffffff";
1438
1438
  });
1439
1439
 
1440
1440
  // ../../node_modules/uuid/dist/nil.js
@@ -1443,7 +1443,7 @@ var require_nil = __commonJS((exports) => {
1443
1443
  value: true
1444
1444
  });
1445
1445
  exports.default = undefined;
1446
- var _default2 = exports.default = "00000000-0000-0000-0000-000000000000";
1446
+ var _default = exports.default = "00000000-0000-0000-0000-000000000000";
1447
1447
  });
1448
1448
 
1449
1449
  // ../../node_modules/uuid/dist/regex.js
@@ -1452,7 +1452,7 @@ var require_regex = __commonJS((exports) => {
1452
1452
  value: true
1453
1453
  });
1454
1454
  exports.default = undefined;
1455
- var _default2 = exports.default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
1455
+ var _default = exports.default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
1456
1456
  });
1457
1457
 
1458
1458
  // ../../node_modules/uuid/dist/validate.js
@@ -1461,14 +1461,14 @@ var require_validate = __commonJS((exports) => {
1461
1461
  value: true
1462
1462
  });
1463
1463
  exports.default = undefined;
1464
- var _regex2 = _interopRequireDefault(require_regex());
1464
+ var _regex = _interopRequireDefault(require_regex());
1465
1465
  function _interopRequireDefault(e) {
1466
1466
  return e && e.__esModule ? e : { default: e };
1467
1467
  }
1468
- function validate(uuid2) {
1469
- return typeof uuid2 === "string" && _regex2.default.test(uuid2);
1468
+ function validate(uuid) {
1469
+ return typeof uuid === "string" && _regex.default.test(uuid);
1470
1470
  }
1471
- var _default2 = exports.default = validate;
1471
+ var _default = exports.default = validate;
1472
1472
  });
1473
1473
 
1474
1474
  // ../../node_modules/uuid/dist/parse.js
@@ -1481,23 +1481,23 @@ var require_parse = __commonJS((exports) => {
1481
1481
  function _interopRequireDefault(e) {
1482
1482
  return e && e.__esModule ? e : { default: e };
1483
1483
  }
1484
- function parse5(uuid2) {
1485
- if (!(0, _validate.default)(uuid2)) {
1484
+ function parse(uuid) {
1485
+ if (!(0, _validate.default)(uuid)) {
1486
1486
  throw TypeError("Invalid UUID");
1487
1487
  }
1488
1488
  let v;
1489
1489
  const arr = new Uint8Array(16);
1490
- arr[0] = (v = parseInt(uuid2.slice(0, 8), 16)) >>> 24;
1490
+ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
1491
1491
  arr[1] = v >>> 16 & 255;
1492
1492
  arr[2] = v >>> 8 & 255;
1493
1493
  arr[3] = v & 255;
1494
- arr[4] = (v = parseInt(uuid2.slice(9, 13), 16)) >>> 8;
1494
+ arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
1495
1495
  arr[5] = v & 255;
1496
- arr[6] = (v = parseInt(uuid2.slice(14, 18), 16)) >>> 8;
1496
+ arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
1497
1497
  arr[7] = v & 255;
1498
- arr[8] = (v = parseInt(uuid2.slice(19, 23), 16)) >>> 8;
1498
+ arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
1499
1499
  arr[9] = v & 255;
1500
- arr[10] = (v = parseInt(uuid2.slice(24, 36), 16)) / 1099511627776 & 255;
1500
+ arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255;
1501
1501
  arr[11] = v / 4294967296 & 255;
1502
1502
  arr[12] = v >>> 24 & 255;
1503
1503
  arr[13] = v >>> 16 & 255;
@@ -1505,7 +1505,7 @@ var require_parse = __commonJS((exports) => {
1505
1505
  arr[15] = v & 255;
1506
1506
  return arr;
1507
1507
  }
1508
- var _default2 = exports.default = parse5;
1508
+ var _default = exports.default = parse;
1509
1509
  });
1510
1510
 
1511
1511
  // ../../node_modules/uuid/dist/stringify.js
@@ -1527,13 +1527,13 @@ var require_stringify = __commonJS((exports) => {
1527
1527
  return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
1528
1528
  }
1529
1529
  function stringify(arr, offset = 0) {
1530
- const uuid2 = unsafeStringify(arr, offset);
1531
- if (!(0, _validate.default)(uuid2)) {
1530
+ const uuid = unsafeStringify(arr, offset);
1531
+ if (!(0, _validate.default)(uuid)) {
1532
1532
  throw TypeError("Stringified UUID is invalid");
1533
1533
  }
1534
- return uuid2;
1534
+ return uuid;
1535
1535
  }
1536
- var _default2 = exports.default = stringify;
1536
+ var _default = exports.default = stringify;
1537
1537
  });
1538
1538
 
1539
1539
  // ../../node_modules/uuid/dist/rng.js
@@ -1635,7 +1635,7 @@ var require_v1 = __commonJS((exports) => {
1635
1635
  }
1636
1636
  return buf || (0, _stringify.unsafeStringify)(b);
1637
1637
  }
1638
- var _default2 = exports.default = v1;
1638
+ var _default = exports.default = v1;
1639
1639
  });
1640
1640
 
1641
1641
  // ../../node_modules/uuid/dist/v1ToV6.js
@@ -1644,15 +1644,15 @@ var require_v1ToV6 = __commonJS((exports) => {
1644
1644
  value: true
1645
1645
  });
1646
1646
  exports.default = v1ToV6;
1647
- var _parse2 = _interopRequireDefault(require_parse());
1647
+ var _parse = _interopRequireDefault(require_parse());
1648
1648
  var _stringify = require_stringify();
1649
1649
  function _interopRequireDefault(e) {
1650
1650
  return e && e.__esModule ? e : { default: e };
1651
1651
  }
1652
- function v1ToV6(uuid2) {
1653
- const v1Bytes = typeof uuid2 === "string" ? (0, _parse2.default)(uuid2) : uuid2;
1652
+ function v1ToV6(uuid) {
1653
+ const v1Bytes = typeof uuid === "string" ? (0, _parse.default)(uuid) : uuid;
1654
1654
  const v6Bytes = _v1ToV6(v1Bytes);
1655
- return typeof uuid2 === "string" ? (0, _stringify.unsafeStringify)(v6Bytes) : v6Bytes;
1655
+ return typeof uuid === "string" ? (0, _stringify.unsafeStringify)(v6Bytes) : v6Bytes;
1656
1656
  }
1657
1657
  function _v1ToV6(v1Bytes, randomize = false) {
1658
1658
  return Uint8Array.of((v1Bytes[6] & 15) << 4 | v1Bytes[7] >> 4 & 15, (v1Bytes[7] & 15) << 4 | (v1Bytes[4] & 240) >> 4, (v1Bytes[4] & 15) << 4 | (v1Bytes[5] & 240) >> 4, (v1Bytes[5] & 15) << 4 | (v1Bytes[0] & 240) >> 4, (v1Bytes[0] & 15) << 4 | (v1Bytes[1] & 240) >> 4, (v1Bytes[1] & 15) << 4 | (v1Bytes[2] & 240) >> 4, 96 | v1Bytes[2] & 15, v1Bytes[3], v1Bytes[8], v1Bytes[9], v1Bytes[10], v1Bytes[11], v1Bytes[12], v1Bytes[13], v1Bytes[14], v1Bytes[15]);
@@ -1667,7 +1667,7 @@ var require_v35 = __commonJS((exports) => {
1667
1667
  exports.URL = exports.DNS = undefined;
1668
1668
  exports.default = v35;
1669
1669
  var _stringify = require_stringify();
1670
- var _parse2 = _interopRequireDefault(require_parse());
1670
+ var _parse = _interopRequireDefault(require_parse());
1671
1671
  function _interopRequireDefault(e) {
1672
1672
  return e && e.__esModule ? e : { default: e };
1673
1673
  }
@@ -1681,14 +1681,14 @@ var require_v35 = __commonJS((exports) => {
1681
1681
  }
1682
1682
  var DNS = exports.DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
1683
1683
  var URL2 = exports.URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
1684
- function v35(name, version2, hashfunc) {
1684
+ function v35(name, version, hashfunc) {
1685
1685
  function generateUUID(value, namespace, buf, offset) {
1686
1686
  var _namespace;
1687
1687
  if (typeof value === "string") {
1688
1688
  value = stringToBytes(value);
1689
1689
  }
1690
1690
  if (typeof namespace === "string") {
1691
- namespace = (0, _parse2.default)(namespace);
1691
+ namespace = (0, _parse.default)(namespace);
1692
1692
  }
1693
1693
  if (((_namespace = namespace) === null || _namespace === undefined ? undefined : _namespace.length) !== 16) {
1694
1694
  throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
@@ -1697,7 +1697,7 @@ var require_v35 = __commonJS((exports) => {
1697
1697
  bytes.set(namespace);
1698
1698
  bytes.set(value, namespace.length);
1699
1699
  bytes = hashfunc(bytes);
1700
- bytes[6] = bytes[6] & 15 | version2;
1700
+ bytes[6] = bytes[6] & 15 | version;
1701
1701
  bytes[8] = bytes[8] & 63 | 128;
1702
1702
  if (buf) {
1703
1703
  offset = offset || 0;
@@ -1735,7 +1735,7 @@ var require_md5 = __commonJS((exports) => {
1735
1735
  }
1736
1736
  return _nodeCrypto.default.createHash("md5").update(bytes).digest();
1737
1737
  }
1738
- var _default2 = exports.default = md5;
1738
+ var _default = exports.default = md5;
1739
1739
  });
1740
1740
 
1741
1741
  // ../../node_modules/uuid/dist/v3.js
@@ -1750,7 +1750,7 @@ var require_v3 = __commonJS((exports) => {
1750
1750
  return e && e.__esModule ? e : { default: e };
1751
1751
  }
1752
1752
  var v3 = (0, _v.default)("v3", 48, _md.default);
1753
- var _default2 = exports.default = v3;
1753
+ var _default = exports.default = v3;
1754
1754
  });
1755
1755
 
1756
1756
  // ../../node_modules/uuid/dist/native.js
@@ -1763,7 +1763,7 @@ var require_native = __commonJS((exports) => {
1763
1763
  function _interopRequireDefault(e) {
1764
1764
  return e && e.__esModule ? e : { default: e };
1765
1765
  }
1766
- var _default2 = exports.default = {
1766
+ var _default = exports.default = {
1767
1767
  randomUUID: _nodeCrypto.default.randomUUID
1768
1768
  };
1769
1769
  });
@@ -1797,7 +1797,7 @@ var require_v4 = __commonJS((exports) => {
1797
1797
  }
1798
1798
  return (0, _stringify.unsafeStringify)(rnds);
1799
1799
  }
1800
- var _default2 = exports.default = v4;
1800
+ var _default = exports.default = v4;
1801
1801
  });
1802
1802
 
1803
1803
  // ../../node_modules/uuid/dist/sha1.js
@@ -1818,7 +1818,7 @@ var require_sha1 = __commonJS((exports) => {
1818
1818
  }
1819
1819
  return _nodeCrypto.default.createHash("sha1").update(bytes).digest();
1820
1820
  }
1821
- var _default2 = exports.default = sha1;
1821
+ var _default = exports.default = sha1;
1822
1822
  });
1823
1823
 
1824
1824
  // ../../node_modules/uuid/dist/v5.js
@@ -1833,7 +1833,7 @@ var require_v5 = __commonJS((exports) => {
1833
1833
  return e && e.__esModule ? e : { default: e };
1834
1834
  }
1835
1835
  var v5 = (0, _v.default)("v5", 80, _sha.default);
1836
- var _default2 = exports.default = v5;
1836
+ var _default = exports.default = v5;
1837
1837
  });
1838
1838
 
1839
1839
  // ../../node_modules/uuid/dist/v6.js
@@ -1870,15 +1870,15 @@ var require_v6ToV1 = __commonJS((exports) => {
1870
1870
  value: true
1871
1871
  });
1872
1872
  exports.default = v6ToV1;
1873
- var _parse2 = _interopRequireDefault(require_parse());
1873
+ var _parse = _interopRequireDefault(require_parse());
1874
1874
  var _stringify = require_stringify();
1875
1875
  function _interopRequireDefault(e) {
1876
1876
  return e && e.__esModule ? e : { default: e };
1877
1877
  }
1878
- function v6ToV1(uuid2) {
1879
- const v6Bytes = typeof uuid2 === "string" ? (0, _parse2.default)(uuid2) : uuid2;
1878
+ function v6ToV1(uuid) {
1879
+ const v6Bytes = typeof uuid === "string" ? (0, _parse.default)(uuid) : uuid;
1880
1880
  const v1Bytes = _v6ToV1(v6Bytes);
1881
- return typeof uuid2 === "string" ? (0, _stringify.unsafeStringify)(v1Bytes) : v1Bytes;
1881
+ return typeof uuid === "string" ? (0, _stringify.unsafeStringify)(v1Bytes) : v1Bytes;
1882
1882
  }
1883
1883
  function _v6ToV1(v6Bytes) {
1884
1884
  return Uint8Array.of((v6Bytes[3] & 15) << 4 | v6Bytes[4] >> 4 & 15, (v6Bytes[4] & 15) << 4 | (v6Bytes[5] & 240) >> 4, (v6Bytes[5] & 15) << 4 | v6Bytes[6] & 15, v6Bytes[7], (v6Bytes[1] & 15) << 4 | (v6Bytes[2] & 240) >> 4, (v6Bytes[2] & 15) << 4 | (v6Bytes[3] & 240) >> 4, 16 | (v6Bytes[0] & 240) >> 4, (v6Bytes[0] & 15) << 4 | (v6Bytes[1] & 240) >> 4, v6Bytes[8], v6Bytes[9], v6Bytes[10], v6Bytes[11], v6Bytes[12], v6Bytes[13], v6Bytes[14], v6Bytes[15]);
@@ -1960,7 +1960,7 @@ var require_v7 = __commonJS((exports) => {
1960
1960
  b[i++] = rnds[15];
1961
1961
  return buf || (0, _stringify.unsafeStringify)(b);
1962
1962
  }
1963
- var _default2 = exports.default = v7;
1963
+ var _default = exports.default = v7;
1964
1964
  });
1965
1965
 
1966
1966
  // ../../node_modules/uuid/dist/version.js
@@ -1973,13 +1973,13 @@ var require_version2 = __commonJS((exports) => {
1973
1973
  function _interopRequireDefault(e) {
1974
1974
  return e && e.__esModule ? e : { default: e };
1975
1975
  }
1976
- function version2(uuid2) {
1977
- if (!(0, _validate.default)(uuid2)) {
1976
+ function version(uuid) {
1977
+ if (!(0, _validate.default)(uuid)) {
1978
1978
  throw TypeError("Invalid UUID");
1979
1979
  }
1980
- return parseInt(uuid2.slice(14, 15), 16);
1980
+ return parseInt(uuid.slice(14, 15), 16);
1981
1981
  }
1982
- var _default2 = exports.default = version2;
1982
+ var _default = exports.default = version;
1983
1983
  });
1984
1984
 
1985
1985
  // ../../node_modules/uuid/dist/index.js
@@ -2002,7 +2002,7 @@ var require_dist = __commonJS((exports) => {
2002
2002
  Object.defineProperty(exports, "parse", {
2003
2003
  enumerable: true,
2004
2004
  get: function() {
2005
- return _parse2.default;
2005
+ return _parse.default;
2006
2006
  }
2007
2007
  });
2008
2008
  Object.defineProperty(exports, "stringify", {
@@ -2073,7 +2073,7 @@ var require_dist = __commonJS((exports) => {
2073
2073
  });
2074
2074
  var _max = _interopRequireDefault(require_max());
2075
2075
  var _nil = _interopRequireDefault(require_nil());
2076
- var _parse2 = _interopRequireDefault(require_parse());
2076
+ var _parse = _interopRequireDefault(require_parse());
2077
2077
  var _stringify = _interopRequireDefault(require_stringify());
2078
2078
  var _v = _interopRequireDefault(require_v1());
2079
2079
  var _v1ToV = _interopRequireDefault(require_v1ToV6());
@@ -2234,7 +2234,7 @@ var require_logging = __commonJS((exports) => {
2234
2234
  var _d;
2235
2235
  Object.defineProperty(exports, "__esModule", { value: true });
2236
2236
  exports.log = exports.setLoggerVerbosity = exports.setLogger = exports.getLogger = undefined;
2237
- exports.trace = trace2;
2237
+ exports.trace = trace3;
2238
2238
  exports.isTracerEnabled = isTracerEnabled;
2239
2239
  var constants_1 = require_constants();
2240
2240
  var process_1 = __require("process");
@@ -2314,7 +2314,7 @@ var require_logging = __commonJS((exports) => {
2314
2314
  }
2315
2315
  }
2316
2316
  var allEnabled = enabledTracers.has("all");
2317
- function trace2(severity, tracer, text) {
2317
+ function trace3(severity, tracer, text) {
2318
2318
  if (isTracerEnabled(tracer)) {
2319
2319
  (0, exports.log)(severity, new Date().toISOString() + " | v" + clientVersion + " " + process_1.pid + " | " + tracer + " | " + text);
2320
2320
  }
@@ -3931,7 +3931,7 @@ var require_resolving_load_balancer = __commonJS((exports) => {
3931
3931
  var uri_parser_1 = require_uri_parser();
3932
3932
  var load_balancer_child_handler_1 = require_load_balancer_child_handler();
3933
3933
  var TRACER_NAME2 = "resolving_load_balancer";
3934
- function trace2(text) {
3934
+ function trace3(text) {
3935
3935
  logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME2, text);
3936
3936
  }
3937
3937
  var NAME_MATCH_LEVEL_ORDER = [
@@ -4025,7 +4025,7 @@ var require_resolving_load_balancer = __commonJS((exports) => {
4025
4025
  createSubchannel: channelControlHelper.createSubchannel.bind(channelControlHelper),
4026
4026
  requestReresolution: () => {
4027
4027
  if (this.backoffTimeout.isRunning()) {
4028
- trace2("requestReresolution delayed by backoff timer until " + this.backoffTimeout.getEndTime().toISOString());
4028
+ trace3("requestReresolution delayed by backoff timer until " + this.backoffTimeout.getEndTime().toISOString());
4029
4029
  this.continueResolving = true;
4030
4030
  } else {
4031
4031
  this.updateResolution();
@@ -4100,7 +4100,7 @@ var require_resolving_load_balancer = __commonJS((exports) => {
4100
4100
  this.backoffTimeout.runOnce();
4101
4101
  }
4102
4102
  updateState(connectivityState, picker, errorMessage) {
4103
- trace2((0, uri_parser_1.uriToString)(this.target) + " " + connectivity_state_1.ConnectivityState[this.currentState] + " -> " + connectivity_state_1.ConnectivityState[connectivityState]);
4103
+ trace3((0, uri_parser_1.uriToString)(this.target) + " " + connectivity_state_1.ConnectivityState[this.currentState] + " -> " + connectivity_state_1.ConnectivityState[connectivityState]);
4104
4104
  if (connectivityState === connectivity_state_1.ConnectivityState.IDLE) {
4105
4105
  picker = new picker_1.QueuePicker(this, picker);
4106
4106
  }
@@ -5317,14 +5317,14 @@ ${callerStack}`;
5317
5317
  }
5318
5318
  _write(chunk, encoding, cb) {
5319
5319
  var _a2;
5320
- const context2 = {
5320
+ const context3 = {
5321
5321
  callback: cb
5322
5322
  };
5323
5323
  const flags = Number(encoding);
5324
5324
  if (!Number.isNaN(flags)) {
5325
- context2.flags = flags;
5325
+ context3.flags = flags;
5326
5326
  }
5327
- (_a2 = this.call) === null || _a2 === undefined || _a2.sendMessageWithContext(context2, chunk);
5327
+ (_a2 = this.call) === null || _a2 === undefined || _a2.sendMessageWithContext(context3, chunk);
5328
5328
  }
5329
5329
  _final(cb) {
5330
5330
  var _a2;
@@ -5358,14 +5358,14 @@ ${callerStack}`;
5358
5358
  }
5359
5359
  _write(chunk, encoding, cb) {
5360
5360
  var _a2;
5361
- const context2 = {
5361
+ const context3 = {
5362
5362
  callback: cb
5363
5363
  };
5364
5364
  const flags = Number(encoding);
5365
5365
  if (!Number.isNaN(flags)) {
5366
- context2.flags = flags;
5366
+ context3.flags = flags;
5367
5367
  }
5368
- (_a2 = this.call) === null || _a2 === undefined || _a2.sendMessageWithContext(context2, chunk);
5368
+ (_a2 = this.call) === null || _a2 === undefined || _a2.sendMessageWithContext(context3, chunk);
5369
5369
  }
5370
5370
  _final(cb) {
5371
5371
  var _a2;
@@ -5629,15 +5629,15 @@ var require_client_interceptors = __commonJS((exports) => {
5629
5629
  this.processPendingHalfClose();
5630
5630
  });
5631
5631
  }
5632
- sendMessageWithContext(context2, message) {
5632
+ sendMessageWithContext(context3, message) {
5633
5633
  this.processingMessage = true;
5634
5634
  this.requester.sendMessage(message, (finalMessage) => {
5635
5635
  this.processingMessage = false;
5636
5636
  if (this.processingMetadata) {
5637
- this.pendingMessageContext = context2;
5637
+ this.pendingMessageContext = context3;
5638
5638
  this.pendingMessage = message;
5639
5639
  } else {
5640
- this.nextCall.sendMessageWithContext(context2, finalMessage);
5640
+ this.nextCall.sendMessageWithContext(context3, finalMessage);
5641
5641
  this.processPendingHalfClose();
5642
5642
  }
5643
5643
  });
@@ -5687,7 +5687,7 @@ var require_client_interceptors = __commonJS((exports) => {
5687
5687
  getPeer() {
5688
5688
  return this.call.getPeer();
5689
5689
  }
5690
- sendMessageWithContext(context2, message) {
5690
+ sendMessageWithContext(context3, message) {
5691
5691
  let serialized;
5692
5692
  try {
5693
5693
  serialized = this.methodDefinition.requestSerialize(message);
@@ -5695,7 +5695,7 @@ var require_client_interceptors = __commonJS((exports) => {
5695
5695
  this.call.cancelWithStatus(constants_1.Status.INTERNAL, `Request message serialization failure: ${(0, error_1.getErrorMessage)(e)}`);
5696
5696
  return;
5697
5697
  }
5698
- this.call.sendMessageWithContext(context2, serialized);
5698
+ this.call.sendMessageWithContext(context3, serialized);
5699
5699
  }
5700
5700
  sendMessage(message) {
5701
5701
  this.sendMessageWithContext({}, message);
@@ -16120,17 +16120,17 @@ var require_single_subchannel_channel = __commonJS((exports) => {
16120
16120
  this.childCall.halfClose();
16121
16121
  }
16122
16122
  }
16123
- async sendMessageWithContext(context2, message) {
16123
+ async sendMessageWithContext(context3, message) {
16124
16124
  this.writeFilterPending = true;
16125
- const filteredMessage = await this.filterStack.sendMessage(Promise.resolve({ message, flags: context2.flags }));
16125
+ const filteredMessage = await this.filterStack.sendMessage(Promise.resolve({ message, flags: context3.flags }));
16126
16126
  this.writeFilterPending = false;
16127
16127
  if (this.childCall) {
16128
- this.childCall.sendMessageWithContext(context2, filteredMessage.message);
16128
+ this.childCall.sendMessageWithContext(context3, filteredMessage.message);
16129
16129
  if (this.halfClosePending) {
16130
16130
  this.childCall.halfClose();
16131
16131
  }
16132
16132
  } else {
16133
- this.pendingMessage = { context: context2, message: filteredMessage.message };
16133
+ this.pendingMessage = { context: context3, message: filteredMessage.message };
16134
16134
  }
16135
16135
  }
16136
16136
  startRead() {
@@ -16522,7 +16522,7 @@ var require_resolver_dns = __commonJS((exports) => {
16522
16522
  var backoff_timeout_1 = require_backoff_timeout();
16523
16523
  var environment_1 = require_environment();
16524
16524
  var TRACER_NAME2 = "dns_resolver";
16525
- function trace2(text) {
16525
+ function trace3(text) {
16526
16526
  logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME2, text);
16527
16527
  }
16528
16528
  exports.DEFAULT_PORT = 443;
@@ -16542,7 +16542,7 @@ var require_resolver_dns = __commonJS((exports) => {
16542
16542
  this.isServiceConfigEnabled = true;
16543
16543
  this.returnedIpResult = false;
16544
16544
  this.alternativeResolver = new dns_1.promises.Resolver;
16545
- trace2("Resolver constructed for target " + (0, uri_parser_1.uriToString)(target));
16545
+ trace3("Resolver constructed for target " + (0, uri_parser_1.uriToString)(target));
16546
16546
  if (target.authority) {
16547
16547
  this.alternativeResolver.setServers([target.authority]);
16548
16548
  }
@@ -16597,7 +16597,7 @@ var require_resolver_dns = __commonJS((exports) => {
16597
16597
  startResolution() {
16598
16598
  if (this.ipResult !== null) {
16599
16599
  if (!this.returnedIpResult) {
16600
- trace2("Returning IP address for target " + (0, uri_parser_1.uriToString)(this.target));
16600
+ trace3("Returning IP address for target " + (0, uri_parser_1.uriToString)(this.target));
16601
16601
  setImmediate(() => {
16602
16602
  this.listener((0, call_interface_1.statusOrFromValue)(this.ipResult), {}, null, "");
16603
16603
  });
@@ -16609,7 +16609,7 @@ var require_resolver_dns = __commonJS((exports) => {
16609
16609
  return;
16610
16610
  }
16611
16611
  if (this.dnsHostname === null) {
16612
- trace2("Failed to parse DNS address " + (0, uri_parser_1.uriToString)(this.target));
16612
+ trace3("Failed to parse DNS address " + (0, uri_parser_1.uriToString)(this.target));
16613
16613
  setImmediate(() => {
16614
16614
  this.listener((0, call_interface_1.statusOrFromError)({
16615
16615
  code: constants_1.Status.UNAVAILABLE,
@@ -16621,7 +16621,7 @@ var require_resolver_dns = __commonJS((exports) => {
16621
16621
  if (this.pendingLookupPromise !== null) {
16622
16622
  return;
16623
16623
  }
16624
- trace2("Looking up DNS hostname " + this.dnsHostname);
16624
+ trace3("Looking up DNS hostname " + this.dnsHostname);
16625
16625
  this.latestLookupResult = null;
16626
16626
  const hostname = this.dnsHostname;
16627
16627
  this.pendingLookupPromise = this.lookup(hostname);
@@ -16634,14 +16634,14 @@ var require_resolver_dns = __commonJS((exports) => {
16634
16634
  addresses: [address]
16635
16635
  })));
16636
16636
  const allAddressesString = "[" + addressList.map((addr) => addr.host + ":" + addr.port).join(",") + "]";
16637
- trace2("Resolved addresses for target " + (0, uri_parser_1.uriToString)(this.target) + ": " + allAddressesString);
16637
+ trace3("Resolved addresses for target " + (0, uri_parser_1.uriToString)(this.target) + ": " + allAddressesString);
16638
16638
  const healthStatus = this.listener(this.latestLookupResult, {}, this.latestServiceConfigResult, "");
16639
16639
  this.handleHealthStatus(healthStatus);
16640
16640
  }, (err) => {
16641
16641
  if (this.pendingLookupPromise === null) {
16642
16642
  return;
16643
16643
  }
16644
- trace2("Resolution error for target " + (0, uri_parser_1.uriToString)(this.target) + ": " + err.message);
16644
+ trace3("Resolution error for target " + (0, uri_parser_1.uriToString)(this.target) + ": " + err.message);
16645
16645
  this.pendingLookupPromise = null;
16646
16646
  this.stopNextResolutionTimer();
16647
16647
  this.listener((0, call_interface_1.statusOrFromError)(this.defaultResolutionError), {}, this.latestServiceConfigResult, "");
@@ -16684,7 +16684,7 @@ var require_resolver_dns = __commonJS((exports) => {
16684
16684
  }
16685
16685
  async lookup(hostname) {
16686
16686
  if (environment_1.GRPC_NODE_USE_ALTERNATIVE_RESOLVER) {
16687
- trace2("Using alternative DNS resolver.");
16687
+ trace3("Using alternative DNS resolver.");
16688
16688
  const records = await Promise.allSettled([
16689
16689
  this.alternativeResolver.resolve4(hostname),
16690
16690
  this.alternativeResolver.resolve6(hostname)
@@ -16704,7 +16704,7 @@ var require_resolver_dns = __commonJS((exports) => {
16704
16704
  }
16705
16705
  async resolveTxt(hostname) {
16706
16706
  if (environment_1.GRPC_NODE_USE_ALTERNATIVE_RESOLVER) {
16707
- trace2("Using alternative DNS resolver.");
16707
+ trace3("Using alternative DNS resolver.");
16708
16708
  return this.alternativeResolver.resolveTxt(hostname);
16709
16709
  }
16710
16710
  return dns_1.promises.resolveTxt(hostname);
@@ -16737,9 +16737,9 @@ var require_resolver_dns = __commonJS((exports) => {
16737
16737
  if (this.pendingLookupPromise === null) {
16738
16738
  if (this.isNextResolutionTimerRunning || this.backoff.isRunning()) {
16739
16739
  if (this.isNextResolutionTimerRunning) {
16740
- trace2('resolution update delayed by "min time between resolutions" rate limit');
16740
+ trace3('resolution update delayed by "min time between resolutions" rate limit');
16741
16741
  } else {
16742
- trace2("resolution update delayed by backoff timer until " + this.backoff.getEndTime().toISOString());
16742
+ trace3("resolution update delayed by backoff timer until " + this.backoff.getEndTime().toISOString());
16743
16743
  }
16744
16744
  this.continueResolving = true;
16745
16745
  } else {
@@ -16784,7 +16784,7 @@ var require_http_proxy = __commonJS((exports) => {
16784
16784
  var url_1 = __require("url");
16785
16785
  var resolver_dns_1 = require_resolver_dns();
16786
16786
  var TRACER_NAME2 = "proxy";
16787
- function trace2(text) {
16787
+ function trace3(text) {
16788
16788
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME2, text);
16789
16789
  }
16790
16790
  function getProxyInfo() {
@@ -16833,7 +16833,7 @@ var require_http_proxy = __commonJS((exports) => {
16833
16833
  if (userCred) {
16834
16834
  result.creds = userCred;
16835
16835
  }
16836
- trace2("Proxy server " + result.address + " set by environment variable " + envVar);
16836
+ trace3("Proxy server " + result.address + " set by environment variable " + envVar);
16837
16837
  return result;
16838
16838
  }
16839
16839
  function getNoProxyHostList() {
@@ -16844,7 +16844,7 @@ var require_http_proxy = __commonJS((exports) => {
16844
16844
  envVar = "no_proxy";
16845
16845
  }
16846
16846
  if (noProxyStr) {
16847
- trace2("No proxy server list set by environment variable " + envVar);
16847
+ trace3("No proxy server list set by environment variable " + envVar);
16848
16848
  return noProxyStr.split(",");
16849
16849
  } else {
16850
16850
  return [];
@@ -16906,7 +16906,7 @@ var require_http_proxy = __commonJS((exports) => {
16906
16906
  }
16907
16907
  const serverHost = hostPort.host;
16908
16908
  if (hostMatchesNoProxyList(serverHost)) {
16909
- trace2("Not using proxy for target in no_proxy list: " + (0, uri_parser_1.uriToString)(target));
16909
+ trace3("Not using proxy for target in no_proxy list: " + (0, uri_parser_1.uriToString)(target));
16910
16910
  return noProxyResult;
16911
16911
  }
16912
16912
  const extraOptions = {
@@ -16956,18 +16956,18 @@ var require_http_proxy = __commonJS((exports) => {
16956
16956
  }
16957
16957
  options.headers = headers;
16958
16958
  const proxyAddressString = (0, subchannel_address_1.subchannelAddressToString)(address);
16959
- trace2("Using proxy " + proxyAddressString + " to connect to " + options.path);
16959
+ trace3("Using proxy " + proxyAddressString + " to connect to " + options.path);
16960
16960
  return new Promise((resolve2, reject) => {
16961
16961
  const request = http.request(options);
16962
16962
  request.once("connect", (res, socket, head) => {
16963
16963
  request.removeAllListeners();
16964
16964
  socket.removeAllListeners();
16965
16965
  if (res.statusCode === 200) {
16966
- trace2("Successfully connected to " + options.path + " through proxy " + proxyAddressString);
16966
+ trace3("Successfully connected to " + options.path + " through proxy " + proxyAddressString);
16967
16967
  if (head.length > 0) {
16968
16968
  socket.unshift(head);
16969
16969
  }
16970
- trace2("Successfully established a plaintext connection to " + options.path + " through proxy " + proxyAddressString);
16970
+ trace3("Successfully established a plaintext connection to " + options.path + " through proxy " + proxyAddressString);
16971
16971
  resolve2(socket);
16972
16972
  } else {
16973
16973
  (0, logging_1.log)(constants_1.LogVerbosity.ERROR, "Failed to connect to " + options.path + " through proxy " + proxyAddressString + " with status " + res.statusCode);
@@ -17433,7 +17433,7 @@ var require_subchannel_call = __commonJS((exports) => {
17433
17433
  }
17434
17434
  this.http2Stream.resume();
17435
17435
  }
17436
- sendMessageWithContext(context2, message) {
17436
+ sendMessageWithContext(context3, message) {
17437
17437
  this.trace("write() called with message of length " + message.length);
17438
17438
  const cb = (error2) => {
17439
17439
  process.nextTick(() => {
@@ -17445,7 +17445,7 @@ var require_subchannel_call = __commonJS((exports) => {
17445
17445
  if (error2) {
17446
17446
  this.cancelWithStatus(code, `Write error: ${error2.message}`);
17447
17447
  }
17448
- (_a2 = context2.callback) === null || _a2 === undefined || _a2.call(context2);
17448
+ (_a2 = context3.callback) === null || _a2 === undefined || _a2.call(context3);
17449
17449
  });
17450
17450
  };
17451
17451
  this.trace("sending data chunk of length " + message.length);
@@ -18247,12 +18247,12 @@ var require_load_balancing_call = __commonJS((exports) => {
18247
18247
  this.metadata = metadata;
18248
18248
  this.doPick();
18249
18249
  }
18250
- sendMessageWithContext(context2, message) {
18250
+ sendMessageWithContext(context3, message) {
18251
18251
  this.trace("write() called with message of length " + message.length);
18252
18252
  if (this.child) {
18253
- this.child.sendMessageWithContext(context2, message);
18253
+ this.child.sendMessageWithContext(context3, message);
18254
18254
  } else {
18255
- this.pendingMessage = { context: context2, message };
18255
+ this.pendingMessage = { context: context3, message };
18256
18256
  }
18257
18257
  }
18258
18258
  startRead() {
@@ -18399,15 +18399,15 @@ var require_resolving_call = __commonJS((exports) => {
18399
18399
  });
18400
18400
  }
18401
18401
  }
18402
- sendMessageOnChild(context2, message) {
18402
+ sendMessageOnChild(context3, message) {
18403
18403
  if (!this.child) {
18404
18404
  throw new Error("sendMessageonChild called with child not populated");
18405
18405
  }
18406
18406
  const child = this.child;
18407
18407
  this.writeFilterPending = true;
18408
- this.filterStack.sendMessage(Promise.resolve({ message, flags: context2.flags })).then((filteredMessage) => {
18408
+ this.filterStack.sendMessage(Promise.resolve({ message, flags: context3.flags })).then((filteredMessage) => {
18409
18409
  this.writeFilterPending = false;
18410
- child.sendMessageWithContext(context2, filteredMessage.message);
18410
+ child.sendMessageWithContext(context3, filteredMessage.message);
18411
18411
  if (this.pendingHalfClose) {
18412
18412
  child.halfClose();
18413
18413
  }
@@ -18526,12 +18526,12 @@ var require_resolving_call = __commonJS((exports) => {
18526
18526
  this.listener = listener;
18527
18527
  this.getConfig();
18528
18528
  }
18529
- sendMessageWithContext(context2, message) {
18529
+ sendMessageWithContext(context3, message) {
18530
18530
  this.trace("write() called with message of length " + message.length);
18531
18531
  if (this.child) {
18532
- this.sendMessageOnChild(context2, message);
18532
+ this.sendMessageOnChild(context3, message);
18533
18533
  } else {
18534
- this.pendingMessage = { context: context2, message };
18534
+ this.pendingMessage = { context: context3, message };
18535
18535
  }
18536
18536
  }
18537
18537
  startRead() {
@@ -19107,11 +19107,11 @@ var require_retrying_call = __commonJS((exports) => {
19107
19107
  }
19108
19108
  }
19109
19109
  }
19110
- sendMessageWithContext(context2, message) {
19110
+ sendMessageWithContext(context3, message) {
19111
19111
  this.trace("write() called with message of length " + message.length);
19112
19112
  const writeObj = {
19113
19113
  message,
19114
- flags: context2.flags
19114
+ flags: context3.flags
19115
19115
  };
19116
19116
  const messageIndex = this.getNextBufferIndex();
19117
19117
  const bufferEntry = {
@@ -19123,7 +19123,7 @@ var require_retrying_call = __commonJS((exports) => {
19123
19123
  if (bufferEntry.allocated) {
19124
19124
  process.nextTick(() => {
19125
19125
  var _a2;
19126
- (_a2 = context2.callback) === null || _a2 === undefined || _a2.call(context2);
19126
+ (_a2 = context3.callback) === null || _a2 === undefined || _a2.call(context3);
19127
19127
  });
19128
19128
  for (const [callIndex, call] of this.underlyingCalls.entries()) {
19129
19129
  if (call.state === "ACTIVE" && call.nextMessageToSend === messageIndex) {
@@ -19140,7 +19140,7 @@ var require_retrying_call = __commonJS((exports) => {
19140
19140
  return;
19141
19141
  }
19142
19142
  const call = this.underlyingCalls[this.committedCallIndex];
19143
- bufferEntry.callback = context2.callback;
19143
+ bufferEntry.callback = context3.callback;
19144
19144
  if (call.state === "ACTIVE" && call.nextMessageToSend === messageIndex) {
19145
19145
  call.call.sendMessageWithContext({
19146
19146
  callback: (error2) => {
@@ -20685,7 +20685,7 @@ var require_server_interceptors = __commonJS((exports) => {
20685
20685
  var tls_1 = __require("tls");
20686
20686
  var orca_1 = require_orca();
20687
20687
  var TRACER_NAME2 = "server_call";
20688
- function trace2(text) {
20688
+ function trace3(text) {
20689
20689
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME2, text);
20690
20690
  }
20691
20691
 
@@ -21016,7 +21016,7 @@ var require_server_interceptors = __commonJS((exports) => {
21016
21016
  this.stream.once("error", (err) => {});
21017
21017
  this.stream.once("close", () => {
21018
21018
  var _a3;
21019
- trace2("Request to method " + ((_a3 = this.handler) === null || _a3 === undefined ? undefined : _a3.path) + " stream closed with rstCode " + this.stream.rstCode);
21019
+ trace3("Request to method " + ((_a3 = this.handler) === null || _a3 === undefined ? undefined : _a3.path) + " stream closed with rstCode " + this.stream.rstCode);
21020
21020
  if (this.callEventTracker && !this.streamEnded) {
21021
21021
  this.streamEnded = true;
21022
21022
  this.callEventTracker.onStreamEnd(false);
@@ -21045,7 +21045,7 @@ var require_server_interceptors = __commonJS((exports) => {
21045
21045
  this.decoder = new stream_decoder_1.StreamDecoder(this.maxReceiveMessageSize);
21046
21046
  const metadata = metadata_1.Metadata.fromHttp2Headers(headers);
21047
21047
  if (logging.isTracerEnabled(TRACER_NAME2)) {
21048
- trace2("Request to " + this.handler.path + " received headers " + JSON.stringify(metadata.toJSON()));
21048
+ trace3("Request to " + this.handler.path + " received headers " + JSON.stringify(metadata.toJSON()));
21049
21049
  }
21050
21050
  const timeoutHeader = metadata.get(GRPC_TIMEOUT_HEADER);
21051
21051
  if (timeoutHeader.length > 0) {
@@ -21211,7 +21211,7 @@ var require_server_interceptors = __commonJS((exports) => {
21211
21211
  if (this.checkCancelled()) {
21212
21212
  return;
21213
21213
  }
21214
- trace2("Request to " + this.handler.path + " received data frame of size " + data.length);
21214
+ trace3("Request to " + this.handler.path + " received data frame of size " + data.length);
21215
21215
  let rawMessages;
21216
21216
  try {
21217
21217
  rawMessages = this.decoder.write(data);
@@ -21241,7 +21241,7 @@ var require_server_interceptors = __commonJS((exports) => {
21241
21241
  this.maybePushNextMessage();
21242
21242
  }
21243
21243
  start(listener) {
21244
- trace2("Request to " + this.handler.path + " start called");
21244
+ trace3("Request to " + this.handler.path + " start called");
21245
21245
  if (this.checkCancelled()) {
21246
21246
  return;
21247
21247
  }
@@ -21284,7 +21284,7 @@ var require_server_interceptors = __commonJS((exports) => {
21284
21284
  return;
21285
21285
  }
21286
21286
  this.maybeSendMetadata();
21287
- trace2("Request to " + this.handler.path + " sent data frame of size " + response.length);
21287
+ trace3("Request to " + this.handler.path + " sent data frame of size " + response.length);
21288
21288
  this.stream.write(response, (error2) => {
21289
21289
  var _a2;
21290
21290
  if (error2) {
@@ -21304,7 +21304,7 @@ var require_server_interceptors = __commonJS((exports) => {
21304
21304
  if (this.checkCancelled()) {
21305
21305
  return;
21306
21306
  }
21307
- trace2("Request to method " + ((_a2 = this.handler) === null || _a2 === undefined ? undefined : _a2.path) + " ended with status code: " + constants_1.Status[status.code] + " details: " + status.details);
21307
+ trace3("Request to method " + ((_a2 = this.handler) === null || _a2 === undefined ? undefined : _a2.path) + " ended with status code: " + constants_1.Status[status.code] + " details: " + status.details);
21308
21308
  const statusMetadata = (_c = (_b = status.metadata) === null || _b === undefined ? undefined : _b.clone()) !== null && _c !== undefined ? _c : new metadata_1.Metadata;
21309
21309
  if (this.shouldSendMetrics) {
21310
21310
  statusMetadata.set(orca_1.GRPC_METRICS_HEADER, this.metricsRecorder.serialize());
@@ -21338,7 +21338,7 @@ var require_server_interceptors = __commonJS((exports) => {
21338
21338
  }
21339
21339
  }
21340
21340
  startRead() {
21341
- trace2("Request to " + this.handler.path + " startRead called");
21341
+ trace3("Request to " + this.handler.path + " startRead called");
21342
21342
  if (this.checkCancelled()) {
21343
21343
  return;
21344
21344
  }
@@ -21425,17 +21425,17 @@ var require_server = __commonJS((exports) => {
21425
21425
  var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
21426
21426
  var _, done = false;
21427
21427
  for (var i = decorators.length - 1;i >= 0; i--) {
21428
- var context2 = {};
21428
+ var context3 = {};
21429
21429
  for (var p in contextIn)
21430
- context2[p] = p === "access" ? {} : contextIn[p];
21430
+ context3[p] = p === "access" ? {} : contextIn[p];
21431
21431
  for (var p in contextIn.access)
21432
- context2.access[p] = contextIn.access[p];
21433
- context2.addInitializer = function(f) {
21432
+ context3.access[p] = contextIn.access[p];
21433
+ context3.addInitializer = function(f) {
21434
21434
  if (done)
21435
21435
  throw new TypeError("Cannot add initializers after decoration has completed");
21436
21436
  extraInitializers.push(accept(f || null));
21437
21437
  };
21438
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context2);
21438
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context3);
21439
21439
  if (kind === "accessor") {
21440
21440
  if (result === undefined)
21441
21441
  continue;
@@ -21483,7 +21483,7 @@ var require_server = __commonJS((exports) => {
21483
21483
  }
21484
21484
  function noop() {}
21485
21485
  function deprecate(message) {
21486
- return function(target, context2) {
21486
+ return function(target, context3) {
21487
21487
  return util.deprecate(target, message);
21488
21488
  };
21489
21489
  }
@@ -22879,7 +22879,7 @@ var require_load_balancer_pick_first = __commonJS((exports) => {
22879
22879
  var net_1 = __require("net");
22880
22880
  var call_interface_1 = require_call_interface();
22881
22881
  var TRACER_NAME2 = "pick_first";
22882
- function trace2(text) {
22882
+ function trace3(text) {
22883
22883
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME2, text);
22884
22884
  }
22885
22885
  var TYPE_NAME = "pick_first";
@@ -23094,7 +23094,7 @@ var require_load_balancer_pick_first = __commonJS((exports) => {
23094
23094
  clearTimeout(this.connectionDelayTimeout);
23095
23095
  this.currentSubchannelIndex = subchannelIndex;
23096
23096
  if (this.children[subchannelIndex].subchannel.getConnectivityState() === connectivity_state_1.ConnectivityState.IDLE) {
23097
- trace2("Start connecting to subchannel with address " + this.children[subchannelIndex].subchannel.getAddress());
23097
+ trace3("Start connecting to subchannel with address " + this.children[subchannelIndex].subchannel.getAddress());
23098
23098
  process.nextTick(() => {
23099
23099
  var _a3;
23100
23100
  (_a3 = this.children[subchannelIndex]) === null || _a3 === undefined || _a3.subchannel.startConnecting();
@@ -23106,7 +23106,7 @@ var require_load_balancer_pick_first = __commonJS((exports) => {
23106
23106
  (_b = (_a2 = this.connectionDelayTimeout).unref) === null || _b === undefined || _b.call(_a2);
23107
23107
  }
23108
23108
  pickSubchannel(subchannel) {
23109
- trace2("Pick subchannel with address " + subchannel.getAddress());
23109
+ trace3("Pick subchannel with address " + subchannel.getAddress());
23110
23110
  this.stickyTransientFailureMode = false;
23111
23111
  subchannel.ref();
23112
23112
  this.channelControlHelper.addChannelzChild(subchannel.getChannelzRef());
@@ -23119,7 +23119,7 @@ var require_load_balancer_pick_first = __commonJS((exports) => {
23119
23119
  this.calculateAndReportNewState();
23120
23120
  }
23121
23121
  updateState(newState, picker, errorMessage) {
23122
- trace2(connectivity_state_1.ConnectivityState[this.currentState] + " -> " + connectivity_state_1.ConnectivityState[newState]);
23122
+ trace3(connectivity_state_1.ConnectivityState[this.currentState] + " -> " + connectivity_state_1.ConnectivityState[newState]);
23123
23123
  this.currentState = newState;
23124
23124
  this.channelControlHelper.updateState(newState, picker, errorMessage);
23125
23125
  }
@@ -23133,7 +23133,7 @@ var require_load_balancer_pick_first = __commonJS((exports) => {
23133
23133
  this.children = [];
23134
23134
  }
23135
23135
  connectToAddressList(addressList, options) {
23136
- trace2("connectToAddressList([" + addressList.map((address) => (0, subchannel_address_1.subchannelAddressToString)(address)) + "])");
23136
+ trace3("connectToAddressList([" + addressList.map((address) => (0, subchannel_address_1.subchannelAddressToString)(address)) + "])");
23137
23137
  const newChildrenList = addressList.map((address) => ({
23138
23138
  subchannel: this.channelControlHelper.createSubchannel(address, options),
23139
23139
  hasReportedTransientFailure: false
@@ -23177,7 +23177,7 @@ var require_load_balancer_pick_first = __commonJS((exports) => {
23177
23177
  endpointList = shuffled(endpointList);
23178
23178
  }
23179
23179
  const rawAddressList = [].concat(...endpointList.map((endpoint) => endpoint.addresses));
23180
- trace2("updateAddressList([" + rawAddressList.map((address) => (0, subchannel_address_1.subchannelAddressToString)(address)) + "])");
23180
+ trace3("updateAddressList([" + rawAddressList.map((address) => (0, subchannel_address_1.subchannelAddressToString)(address)) + "])");
23181
23181
  const addressList = interleaveAddressFamilies(rawAddressList);
23182
23182
  this.latestAddressList = addressList;
23183
23183
  this.latestOptions = options;
@@ -23265,7 +23265,7 @@ var require_certificate_provider = __commonJS((exports) => {
23265
23265
  var constants_1 = require_constants();
23266
23266
  var util_1 = __require("util");
23267
23267
  var TRACER_NAME2 = "certificate_provider";
23268
- function trace2(text) {
23268
+ function trace3(text) {
23269
23269
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME2, text);
23270
23270
  }
23271
23271
  var readFilePromise = (0, util_1.promisify)(fs.readFile);
@@ -23286,7 +23286,7 @@ var require_certificate_provider = __commonJS((exports) => {
23286
23286
  if (config2.certificateFile === undefined && config2.caCertificateFile === undefined) {
23287
23287
  throw new Error("At least one of certificateFile and caCertificateFile must be set");
23288
23288
  }
23289
- trace2("File watcher constructed with config " + JSON.stringify(config2));
23289
+ trace3("File watcher constructed with config " + JSON.stringify(config2));
23290
23290
  }
23291
23291
  updateCertificates() {
23292
23292
  if (this.fileResultPromise) {
@@ -23301,7 +23301,7 @@ var require_certificate_provider = __commonJS((exports) => {
23301
23301
  if (!this.refreshTimer) {
23302
23302
  return;
23303
23303
  }
23304
- trace2("File watcher read certificates certificate " + certificateResult.status + ", privateKey " + privateKeyResult.status + ", CA certificate " + caCertificateResult.status);
23304
+ trace3("File watcher read certificates certificate " + certificateResult.status + ", privateKey " + privateKeyResult.status + ", CA certificate " + caCertificateResult.status);
23305
23305
  this.lastUpdateTime = new Date;
23306
23306
  this.fileResultPromise = null;
23307
23307
  if (certificateResult.status === "fulfilled" && privateKeyResult.status === "fulfilled") {
@@ -23326,7 +23326,7 @@ var require_certificate_provider = __commonJS((exports) => {
23326
23326
  listener(this.latestCaUpdate);
23327
23327
  }
23328
23328
  });
23329
- trace2("File watcher initiated certificate update");
23329
+ trace3("File watcher initiated certificate update");
23330
23330
  }
23331
23331
  maybeStartWatchingFiles() {
23332
23332
  if (!this.refreshTimer) {
@@ -23339,7 +23339,7 @@ var require_certificate_provider = __commonJS((exports) => {
23339
23339
  this.latestIdentityUpdate = undefined;
23340
23340
  }
23341
23341
  this.refreshTimer = setInterval(() => this.updateCertificates(), this.config.refreshIntervalMs);
23342
- trace2("File watcher started watching");
23342
+ trace3("File watcher started watching");
23343
23343
  }
23344
23344
  }
23345
23345
  maybeStopWatchingFiles() {
@@ -23558,7 +23558,7 @@ var require_resolver_ip = __commonJS((exports) => {
23558
23558
  var uri_parser_1 = require_uri_parser();
23559
23559
  var logging = require_logging();
23560
23560
  var TRACER_NAME2 = "ip_resolver";
23561
- function trace2(text) {
23561
+ function trace3(text) {
23562
23562
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME2, text);
23563
23563
  }
23564
23564
  var IPV4_SCHEME = "ipv4";
@@ -23572,7 +23572,7 @@ var require_resolver_ip = __commonJS((exports) => {
23572
23572
  this.endpoints = [];
23573
23573
  this.error = null;
23574
23574
  this.hasReturnedResult = false;
23575
- trace2("Resolver constructed for target " + (0, uri_parser_1.uriToString)(target));
23575
+ trace3("Resolver constructed for target " + (0, uri_parser_1.uriToString)(target));
23576
23576
  const addresses = [];
23577
23577
  if (!(target.scheme === IPV4_SCHEME || target.scheme === IPV6_SCHEME)) {
23578
23578
  this.error = {
@@ -23607,7 +23607,7 @@ var require_resolver_ip = __commonJS((exports) => {
23607
23607
  });
23608
23608
  }
23609
23609
  this.endpoints = addresses.map((address) => ({ addresses: [address] }));
23610
- trace2("Parsed " + target.scheme + " address list " + addresses.map(subchannel_address_1.subchannelAddressToString));
23610
+ trace3("Parsed " + target.scheme + " address list " + addresses.map(subchannel_address_1.subchannelAddressToString));
23611
23611
  }
23612
23612
  updateResolution() {
23613
23613
  if (!this.hasReturnedResult) {
@@ -23647,7 +23647,7 @@ var require_load_balancer_round_robin = __commonJS((exports) => {
23647
23647
  var subchannel_address_1 = require_subchannel_address();
23648
23648
  var load_balancer_pick_first_1 = require_load_balancer_pick_first();
23649
23649
  var TRACER_NAME2 = "round_robin";
23650
- function trace2(text) {
23650
+ function trace3(text) {
23651
23651
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME2, text);
23652
23652
  }
23653
23653
  var TYPE_NAME = "round_robin";
@@ -23743,7 +23743,7 @@ var require_load_balancer_round_robin = __commonJS((exports) => {
23743
23743
  }
23744
23744
  }
23745
23745
  updateState(newState, picker, errorMessage) {
23746
- trace2(connectivity_state_1.ConnectivityState[this.currentState] + " -> " + connectivity_state_1.ConnectivityState[newState]);
23746
+ trace3(connectivity_state_1.ConnectivityState[this.currentState] + " -> " + connectivity_state_1.ConnectivityState[newState]);
23747
23747
  if (newState === connectivity_state_1.ConnectivityState.READY) {
23748
23748
  this.currentReadyPicker = picker;
23749
23749
  } else {
@@ -23775,7 +23775,7 @@ var require_load_balancer_round_robin = __commonJS((exports) => {
23775
23775
  const errorMessage = `No addresses resolved. Resolution note: ${resolutionNote}`;
23776
23776
  this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({ details: errorMessage }), errorMessage);
23777
23777
  }
23778
- trace2("Connect to endpoint list " + endpointList.map(subchannel_address_1.endpointToString));
23778
+ trace3("Connect to endpoint list " + endpointList.map(subchannel_address_1.endpointToString));
23779
23779
  this.updatesPaused = true;
23780
23780
  this.children = endpointList.map((endpoint) => new load_balancer_pick_first_1.LeafLoadBalancer(endpoint, this.childChannelControlHelper, options, resolutionNote));
23781
23781
  for (const child of this.children) {
@@ -23817,7 +23817,7 @@ var require_load_balancer_outlier_detection = __commonJS((exports) => {
23817
23817
  var subchannel_interface_1 = require_subchannel_interface();
23818
23818
  var logging = require_logging();
23819
23819
  var TRACER_NAME2 = "outlier_detection";
23820
- function trace2(text) {
23820
+ function trace3(text) {
23821
23821
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME2, text);
23822
23822
  }
23823
23823
  var TYPE_NAME = "outlier_detection";
@@ -24091,20 +24091,20 @@ var require_load_balancer_outlier_detection = __commonJS((exports) => {
24091
24091
  if (!successRateConfig) {
24092
24092
  return;
24093
24093
  }
24094
- trace2("Running success rate check");
24094
+ trace3("Running success rate check");
24095
24095
  const targetRequestVolume = successRateConfig.request_volume;
24096
24096
  let addresesWithTargetVolume = 0;
24097
24097
  const successRates = [];
24098
24098
  for (const [endpoint, mapEntry] of this.entryMap.entries()) {
24099
24099
  const successes = mapEntry.counter.getLastSuccesses();
24100
24100
  const failures = mapEntry.counter.getLastFailures();
24101
- trace2("Stats for " + (0, subchannel_address_1.endpointToString)(endpoint) + ": successes=" + successes + " failures=" + failures + " targetRequestVolume=" + targetRequestVolume);
24101
+ trace3("Stats for " + (0, subchannel_address_1.endpointToString)(endpoint) + ": successes=" + successes + " failures=" + failures + " targetRequestVolume=" + targetRequestVolume);
24102
24102
  if (successes + failures >= targetRequestVolume) {
24103
24103
  addresesWithTargetVolume += 1;
24104
24104
  successRates.push(successes / (successes + failures));
24105
24105
  }
24106
24106
  }
24107
- trace2("Found " + addresesWithTargetVolume + " success rate candidates; currentEjectionPercent=" + this.getCurrentEjectionPercent() + " successRates=[" + successRates + "]");
24107
+ trace3("Found " + addresesWithTargetVolume + " success rate candidates; currentEjectionPercent=" + this.getCurrentEjectionPercent() + " successRates=[" + successRates + "]");
24108
24108
  if (addresesWithTargetVolume < successRateConfig.minimum_hosts) {
24109
24109
  return;
24110
24110
  }
@@ -24117,7 +24117,7 @@ var require_load_balancer_outlier_detection = __commonJS((exports) => {
24117
24117
  const successRateVariance = successRateDeviationSum / successRates.length;
24118
24118
  const successRateStdev = Math.sqrt(successRateVariance);
24119
24119
  const ejectionThreshold = successRateMean - successRateStdev * (successRateConfig.stdev_factor / 1000);
24120
- trace2("stdev=" + successRateStdev + " ejectionThreshold=" + ejectionThreshold);
24120
+ trace3("stdev=" + successRateStdev + " ejectionThreshold=" + ejectionThreshold);
24121
24121
  for (const [address, mapEntry] of this.entryMap.entries()) {
24122
24122
  if (this.getCurrentEjectionPercent() >= this.latestConfig.getMaxEjectionPercent()) {
24123
24123
  break;
@@ -24128,12 +24128,12 @@ var require_load_balancer_outlier_detection = __commonJS((exports) => {
24128
24128
  continue;
24129
24129
  }
24130
24130
  const successRate = successes / (successes + failures);
24131
- trace2("Checking candidate " + address + " successRate=" + successRate);
24131
+ trace3("Checking candidate " + address + " successRate=" + successRate);
24132
24132
  if (successRate < ejectionThreshold) {
24133
24133
  const randomNumber = Math.random() * 100;
24134
- trace2("Candidate " + address + " randomNumber=" + randomNumber + " enforcement_percentage=" + successRateConfig.enforcement_percentage);
24134
+ trace3("Candidate " + address + " randomNumber=" + randomNumber + " enforcement_percentage=" + successRateConfig.enforcement_percentage);
24135
24135
  if (randomNumber < successRateConfig.enforcement_percentage) {
24136
- trace2("Ejecting candidate " + address);
24136
+ trace3("Ejecting candidate " + address);
24137
24137
  this.eject(mapEntry, ejectionTimestamp);
24138
24138
  }
24139
24139
  }
@@ -24147,7 +24147,7 @@ var require_load_balancer_outlier_detection = __commonJS((exports) => {
24147
24147
  if (!failurePercentageConfig) {
24148
24148
  return;
24149
24149
  }
24150
- trace2("Running failure percentage check. threshold=" + failurePercentageConfig.threshold + " request volume threshold=" + failurePercentageConfig.request_volume);
24150
+ trace3("Running failure percentage check. threshold=" + failurePercentageConfig.threshold + " request volume threshold=" + failurePercentageConfig.request_volume);
24151
24151
  let addressesWithTargetVolume = 0;
24152
24152
  for (const mapEntry of this.entryMap.values()) {
24153
24153
  const successes = mapEntry.counter.getLastSuccesses();
@@ -24165,16 +24165,16 @@ var require_load_balancer_outlier_detection = __commonJS((exports) => {
24165
24165
  }
24166
24166
  const successes = mapEntry.counter.getLastSuccesses();
24167
24167
  const failures = mapEntry.counter.getLastFailures();
24168
- trace2("Candidate successes=" + successes + " failures=" + failures);
24168
+ trace3("Candidate successes=" + successes + " failures=" + failures);
24169
24169
  if (successes + failures < failurePercentageConfig.request_volume) {
24170
24170
  continue;
24171
24171
  }
24172
24172
  const failurePercentage = failures * 100 / (failures + successes);
24173
24173
  if (failurePercentage > failurePercentageConfig.threshold) {
24174
24174
  const randomNumber = Math.random() * 100;
24175
- trace2("Candidate " + address + " randomNumber=" + randomNumber + " enforcement_percentage=" + failurePercentageConfig.enforcement_percentage);
24175
+ trace3("Candidate " + address + " randomNumber=" + randomNumber + " enforcement_percentage=" + failurePercentageConfig.enforcement_percentage);
24176
24176
  if (randomNumber < failurePercentageConfig.enforcement_percentage) {
24177
- trace2("Ejecting candidate " + address);
24177
+ trace3("Ejecting candidate " + address);
24178
24178
  this.eject(mapEntry, ejectionTimestamp);
24179
24179
  }
24180
24180
  }
@@ -24205,7 +24205,7 @@ var require_load_balancer_outlier_detection = __commonJS((exports) => {
24205
24205
  }
24206
24206
  runChecks() {
24207
24207
  const ejectionTimestamp = new Date;
24208
- trace2("Ejection timer running");
24208
+ trace3("Ejection timer running");
24209
24209
  this.switchAllBuckets();
24210
24210
  if (!this.latestConfig) {
24211
24211
  return;
@@ -24225,7 +24225,7 @@ var require_load_balancer_outlier_detection = __commonJS((exports) => {
24225
24225
  const returnTime = new Date(mapEntry.currentEjectionTimestamp.getTime());
24226
24226
  returnTime.setMilliseconds(returnTime.getMilliseconds() + Math.min(baseEjectionTimeMs * mapEntry.ejectionTimeMultiplier, Math.max(baseEjectionTimeMs, maxEjectionTimeMs)));
24227
24227
  if (returnTime < new Date) {
24228
- trace2("Unejecting " + address);
24228
+ trace3("Unejecting " + address);
24229
24229
  this.uneject(mapEntry);
24230
24230
  }
24231
24231
  }
@@ -24235,11 +24235,11 @@ var require_load_balancer_outlier_detection = __commonJS((exports) => {
24235
24235
  if (!(lbConfig instanceof OutlierDetectionLoadBalancingConfig)) {
24236
24236
  return false;
24237
24237
  }
24238
- trace2("Received update with config: " + JSON.stringify(lbConfig.toJsonObject(), undefined, 2));
24238
+ trace3("Received update with config: " + JSON.stringify(lbConfig.toJsonObject(), undefined, 2));
24239
24239
  if (endpointList.ok) {
24240
24240
  for (const endpoint of endpointList.value) {
24241
24241
  if (!this.entryMap.has(endpoint)) {
24242
- trace2("Adding map entry for " + (0, subchannel_address_1.endpointToString)(endpoint));
24242
+ trace3("Adding map entry for " + (0, subchannel_address_1.endpointToString)(endpoint));
24243
24243
  this.entryMap.set(endpoint, {
24244
24244
  counter: new CallCounter,
24245
24245
  currentEjectionTimestamp: null,
@@ -24254,18 +24254,18 @@ var require_load_balancer_outlier_detection = __commonJS((exports) => {
24254
24254
  this.childBalancer.updateAddressList(endpointList, childPolicy, options, resolutionNote);
24255
24255
  if (lbConfig.getSuccessRateEjectionConfig() || lbConfig.getFailurePercentageEjectionConfig()) {
24256
24256
  if (this.timerStartTime) {
24257
- trace2("Previous timer existed. Replacing timer");
24257
+ trace3("Previous timer existed. Replacing timer");
24258
24258
  clearTimeout(this.ejectionTimer);
24259
24259
  const remainingDelay = lbConfig.getIntervalMs() - (new Date().getTime() - this.timerStartTime.getTime());
24260
24260
  this.startTimer(remainingDelay);
24261
24261
  } else {
24262
- trace2("Starting new timer");
24262
+ trace3("Starting new timer");
24263
24263
  this.timerStartTime = new Date;
24264
24264
  this.startTimer(lbConfig.getIntervalMs());
24265
24265
  this.switchAllBuckets();
24266
24266
  }
24267
24267
  } else {
24268
- trace2("Counting disabled. Cancelling timer.");
24268
+ trace3("Counting disabled. Cancelling timer.");
24269
24269
  this.timerStartTime = null;
24270
24270
  clearTimeout(this.ejectionTimer);
24271
24271
  for (const mapEntry of this.entryMap.values()) {
@@ -24385,7 +24385,7 @@ var require_load_balancer_weighted_round_robin = __commonJS((exports) => {
24385
24385
  var priority_queue_1 = require_priority_queue();
24386
24386
  var subchannel_address_1 = require_subchannel_address();
24387
24387
  var TRACER_NAME2 = "weighted_round_robin";
24388
- function trace2(text) {
24388
+ function trace3(text) {
24389
24389
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME2, text);
24390
24390
  }
24391
24391
  var TYPE_NAME = "weighted_round_robin";
@@ -24581,7 +24581,7 @@ var require_load_balancer_weighted_round_robin = __commonJS((exports) => {
24581
24581
  weight: this.getWeight(entry)
24582
24582
  });
24583
24583
  }
24584
- trace2("Created picker with weights: " + weightedPickers.map((entry) => entry.endpointName + ":" + entry.weight).join(","));
24584
+ trace3("Created picker with weights: " + weightedPickers.map((entry) => entry.endpointName + ":" + entry.weight).join(","));
24585
24585
  let metricsHandler;
24586
24586
  if (!this.latestConfig.getEnableOobLoadReport()) {
24587
24587
  metricsHandler = (loadReport, endpointName) => {
@@ -24611,7 +24611,7 @@ var require_load_balancer_weighted_round_robin = __commonJS((exports) => {
24611
24611
  }
24612
24612
  }
24613
24613
  updateState(newState, picker, errorMessage) {
24614
- trace2(connectivity_state_1.ConnectivityState[this.currentState] + " -> " + connectivity_state_1.ConnectivityState[newState]);
24614
+ trace3(connectivity_state_1.ConnectivityState[this.currentState] + " -> " + connectivity_state_1.ConnectivityState[newState]);
24615
24615
  this.currentState = newState;
24616
24616
  this.channelControlHelper.updateState(newState, picker, errorMessage);
24617
24617
  }
@@ -24631,7 +24631,7 @@ var require_load_balancer_weighted_round_robin = __commonJS((exports) => {
24631
24631
  this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({ details: errorMessage }), errorMessage);
24632
24632
  return false;
24633
24633
  }
24634
- trace2("Connect to endpoint list " + maybeEndpointList.value.map(subchannel_address_1.endpointToString));
24634
+ trace3("Connect to endpoint list " + maybeEndpointList.value.map(subchannel_address_1.endpointToString));
24635
24635
  const now = new Date;
24636
24636
  const seenEndpointNames = new Set;
24637
24637
  this.updatesPaused = true;
@@ -25011,16 +25011,16 @@ var require_suppress_tracing = __commonJS((exports) => {
25011
25011
  exports.isTracingSuppressed = exports.unsuppressTracing = exports.suppressTracing = undefined;
25012
25012
  var api_1 = require_src();
25013
25013
  var SUPPRESS_TRACING_KEY = (0, api_1.createContextKey)("OpenTelemetry SDK Context Key SUPPRESS_TRACING");
25014
- function suppressTracing(context2) {
25015
- return context2.setValue(SUPPRESS_TRACING_KEY, true);
25014
+ function suppressTracing(context3) {
25015
+ return context3.setValue(SUPPRESS_TRACING_KEY, true);
25016
25016
  }
25017
25017
  exports.suppressTracing = suppressTracing;
25018
- function unsuppressTracing(context2) {
25019
- return context2.deleteValue(SUPPRESS_TRACING_KEY);
25018
+ function unsuppressTracing(context3) {
25019
+ return context3.deleteValue(SUPPRESS_TRACING_KEY);
25020
25020
  }
25021
25021
  exports.unsuppressTracing = unsuppressTracing;
25022
- function isTracingSuppressed(context2) {
25023
- return context2.getValue(SUPPRESS_TRACING_KEY) === true;
25022
+ function isTracingSuppressed(context3) {
25023
+ return context3.getValue(SUPPRESS_TRACING_KEY) === true;
25024
25024
  }
25025
25025
  exports.isTracingSuppressed = isTracingSuppressed;
25026
25026
  });
@@ -25114,9 +25114,9 @@ var require_W3CBaggagePropagator = __commonJS((exports) => {
25114
25114
  var utils_1 = require_utils3();
25115
25115
 
25116
25116
  class W3CBaggagePropagator {
25117
- inject(context2, carrier, setter) {
25118
- const baggage = api_1.propagation.getBaggage(context2);
25119
- if (!baggage || (0, suppress_tracing_1.isTracingSuppressed)(context2))
25117
+ inject(context3, carrier, setter) {
25118
+ const baggage = api_1.propagation.getBaggage(context3);
25119
+ if (!baggage || (0, suppress_tracing_1.isTracingSuppressed)(context3))
25120
25120
  return;
25121
25121
  const keyPairs = (0, utils_1.getKeyPairs)(baggage).filter((pair) => {
25122
25122
  return pair.length <= constants_1.BAGGAGE_MAX_PER_NAME_VALUE_PAIRS;
@@ -25126,14 +25126,14 @@ var require_W3CBaggagePropagator = __commonJS((exports) => {
25126
25126
  setter.set(carrier, constants_1.BAGGAGE_HEADER, headerValue);
25127
25127
  }
25128
25128
  }
25129
- extract(context2, carrier, getter) {
25129
+ extract(context3, carrier, getter) {
25130
25130
  const headerValue = getter.get(carrier, constants_1.BAGGAGE_HEADER);
25131
25131
  const baggageString = Array.isArray(headerValue) ? headerValue.join(constants_1.BAGGAGE_ITEMS_SEPARATOR) : headerValue;
25132
25132
  if (!baggageString)
25133
- return context2;
25133
+ return context3;
25134
25134
  const baggage = {};
25135
25135
  if (baggageString.length === 0) {
25136
- return context2;
25136
+ return context3;
25137
25137
  }
25138
25138
  const pairs = baggageString.split(constants_1.BAGGAGE_ITEMS_SEPARATOR);
25139
25139
  pairs.forEach((entry) => {
@@ -25147,9 +25147,9 @@ var require_W3CBaggagePropagator = __commonJS((exports) => {
25147
25147
  }
25148
25148
  });
25149
25149
  if (Object.entries(baggage).length === 0) {
25150
- return context2;
25150
+ return context3;
25151
25151
  }
25152
- return api_1.propagation.setBaggage(context2, api_1.propagation.createBaggage(baggage));
25152
+ return api_1.propagation.setBaggage(context3, api_1.propagation.createBaggage(baggage));
25153
25153
  }
25154
25154
  fields() {
25155
25155
  return [constants_1.BAGGAGE_HEADER];
@@ -27124,16 +27124,16 @@ var require_composite = __commonJS((exports) => {
27124
27124
  this._propagators = config2.propagators ?? [];
27125
27125
  this._fields = Array.from(new Set(this._propagators.map((p) => typeof p.fields === "function" ? p.fields() : []).reduce((x, y) => x.concat(y), [])));
27126
27126
  }
27127
- inject(context2, carrier, setter) {
27127
+ inject(context3, carrier, setter) {
27128
27128
  for (const propagator of this._propagators) {
27129
27129
  try {
27130
- propagator.inject(context2, carrier, setter);
27130
+ propagator.inject(context3, carrier, setter);
27131
27131
  } catch (err) {
27132
27132
  api_1.diag.warn(`Failed to inject with ${propagator.constructor.name}. Err: ${err.message}`);
27133
27133
  }
27134
27134
  }
27135
27135
  }
27136
- extract(context2, carrier, getter) {
27136
+ extract(context3, carrier, getter) {
27137
27137
  return this._propagators.reduce((ctx, propagator) => {
27138
27138
  try {
27139
27139
  return propagator.extract(ctx, carrier, getter);
@@ -27141,7 +27141,7 @@ var require_composite = __commonJS((exports) => {
27141
27141
  api_1.diag.warn(`Failed to extract with ${propagator.constructor.name}. Err: ${err.message}`);
27142
27142
  }
27143
27143
  return ctx;
27144
- }, context2);
27144
+ }, context3);
27145
27145
  }
27146
27146
  fields() {
27147
27147
  return this._fields.slice();
@@ -27269,9 +27269,9 @@ var require_W3CTraceContextPropagator = __commonJS((exports) => {
27269
27269
  exports.parseTraceParent = parseTraceParent;
27270
27270
 
27271
27271
  class W3CTraceContextPropagator {
27272
- inject(context2, carrier, setter) {
27273
- const spanContext = api_1.trace.getSpanContext(context2);
27274
- if (!spanContext || (0, suppress_tracing_1.isTracingSuppressed)(context2) || !(0, api_1.isSpanContextValid)(spanContext))
27272
+ inject(context3, carrier, setter) {
27273
+ const spanContext = api_1.trace.getSpanContext(context3);
27274
+ if (!spanContext || (0, suppress_tracing_1.isTracingSuppressed)(context3) || !(0, api_1.isSpanContextValid)(spanContext))
27275
27275
  return;
27276
27276
  const traceParent = `${VERSION}-${spanContext.traceId}-${spanContext.spanId}-0${Number(spanContext.traceFlags || api_1.TraceFlags.NONE).toString(16)}`;
27277
27277
  setter.set(carrier, exports.TRACE_PARENT_HEADER, traceParent);
@@ -27279,23 +27279,23 @@ var require_W3CTraceContextPropagator = __commonJS((exports) => {
27279
27279
  setter.set(carrier, exports.TRACE_STATE_HEADER, spanContext.traceState.serialize());
27280
27280
  }
27281
27281
  }
27282
- extract(context2, carrier, getter) {
27282
+ extract(context3, carrier, getter) {
27283
27283
  const traceParentHeader = getter.get(carrier, exports.TRACE_PARENT_HEADER);
27284
27284
  if (!traceParentHeader)
27285
- return context2;
27285
+ return context3;
27286
27286
  const traceParent = Array.isArray(traceParentHeader) ? traceParentHeader[0] : traceParentHeader;
27287
27287
  if (typeof traceParent !== "string")
27288
- return context2;
27288
+ return context3;
27289
27289
  const spanContext = parseTraceParent(traceParent);
27290
27290
  if (!spanContext)
27291
- return context2;
27291
+ return context3;
27292
27292
  spanContext.isRemote = true;
27293
27293
  const traceStateHeader = getter.get(carrier, exports.TRACE_STATE_HEADER);
27294
27294
  if (traceStateHeader) {
27295
27295
  const state = Array.isArray(traceStateHeader) ? traceStateHeader.join(",") : traceStateHeader;
27296
27296
  spanContext.traceState = new TraceState_1.TraceState(typeof state === "string" ? state : undefined);
27297
27297
  }
27298
- return api_1.trace.setSpanContext(context2, spanContext);
27298
+ return api_1.trace.setSpanContext(context3, spanContext);
27299
27299
  }
27300
27300
  fields() {
27301
27301
  return [exports.TRACE_PARENT_HEADER, exports.TRACE_STATE_HEADER];
@@ -27314,16 +27314,16 @@ var require_rpc_metadata = __commonJS((exports) => {
27314
27314
  (function(RPCType2) {
27315
27315
  RPCType2["HTTP"] = "http";
27316
27316
  })(RPCType = exports.RPCType || (exports.RPCType = {}));
27317
- function setRPCMetadata(context2, meta2) {
27318
- return context2.setValue(RPC_METADATA_KEY, meta2);
27317
+ function setRPCMetadata(context3, meta2) {
27318
+ return context3.setValue(RPC_METADATA_KEY, meta2);
27319
27319
  }
27320
27320
  exports.setRPCMetadata = setRPCMetadata;
27321
- function deleteRPCMetadata(context2) {
27322
- return context2.deleteValue(RPC_METADATA_KEY);
27321
+ function deleteRPCMetadata(context3) {
27322
+ return context3.deleteValue(RPC_METADATA_KEY);
27323
27323
  }
27324
27324
  exports.deleteRPCMetadata = deleteRPCMetadata;
27325
- function getRPCMetadata(context2) {
27326
- return context2.getValue(RPC_METADATA_KEY);
27325
+ function getRPCMetadata(context3) {
27326
+ return context3.getValue(RPC_METADATA_KEY);
27327
27327
  }
27328
27328
  exports.getRPCMetadata = getRPCMetadata;
27329
27329
  });
@@ -30857,8 +30857,8 @@ var require_root2 = __commonJS((exports, module) => {
30857
30857
  return resource;
30858
30858
  }();
30859
30859
  proto.trace = function() {
30860
- var trace2 = {};
30861
- trace2.v1 = function() {
30860
+ var trace3 = {};
30861
+ trace3.v1 = function() {
30862
30862
  var v12 = {};
30863
30863
  v12.TracesData = function() {
30864
30864
  function TracesData(properties) {
@@ -32270,13 +32270,13 @@ var require_root2 = __commonJS((exports, module) => {
32270
32270
  }();
32271
32271
  return v12;
32272
32272
  }();
32273
- return trace2;
32273
+ return trace3;
32274
32274
  }();
32275
32275
  proto.collector = function() {
32276
32276
  var collector = {};
32277
32277
  collector.trace = function() {
32278
- var trace2 = {};
32279
- trace2.v1 = function() {
32278
+ var trace3 = {};
32279
+ trace3.v1 = function() {
32280
32280
  var v12 = {};
32281
32281
  v12.TraceService = function() {
32282
32282
  function TraceService(rpcImpl, requestDelimited, responseDelimited) {
@@ -32604,7 +32604,7 @@ var require_root2 = __commonJS((exports, module) => {
32604
32604
  }();
32605
32605
  return v12;
32606
32606
  }();
32607
- return trace2;
32607
+ return trace3;
32608
32608
  }();
32609
32609
  collector.metrics = function() {
32610
32610
  var metrics = {};
@@ -40093,7 +40093,7 @@ var require_Instruments = __commonJS((exports) => {
40093
40093
  this._writableMetricStorage = writableMetricStorage;
40094
40094
  this._descriptor = descriptor;
40095
40095
  }
40096
- _record(value, attributes = {}, context2 = api_1.context.active()) {
40096
+ _record(value, attributes = {}, context3 = api_1.context.active()) {
40097
40097
  if (typeof value !== "number") {
40098
40098
  api_1.diag.warn(`non-number value provided to metric ${this._descriptor.name}: ${value}`);
40099
40099
  return;
@@ -40105,7 +40105,7 @@ var require_Instruments = __commonJS((exports) => {
40105
40105
  return;
40106
40106
  }
40107
40107
  }
40108
- this._writableMetricStorage.record(value, attributes, context2, (0, core_1.millisToHrTime)(Date.now()));
40108
+ this._writableMetricStorage.record(value, attributes, context3, (0, core_1.millisToHrTime)(Date.now()));
40109
40109
  }
40110
40110
  }
40111
40111
  exports.SyncInstrument = SyncInstrument;
@@ -40713,9 +40713,9 @@ var require_MultiWritableMetricStorage = __commonJS((exports) => {
40713
40713
  constructor(backingStorages) {
40714
40714
  this._backingStorages = backingStorages;
40715
40715
  }
40716
- record(value, attributes, context2, recordTime) {
40716
+ record(value, attributes, context3, recordTime) {
40717
40717
  this._backingStorages.forEach((it) => {
40718
- it.record(value, attributes, context2, recordTime);
40718
+ it.record(value, attributes, context3, recordTime);
40719
40719
  });
40720
40720
  }
40721
40721
  }
@@ -40905,9 +40905,9 @@ var require_SyncMetricStorage = __commonJS((exports) => {
40905
40905
  this._temporalMetricStorage = new TemporalMetricProcessor_1.TemporalMetricProcessor(aggregator, collectorHandles);
40906
40906
  this._attributesProcessor = attributesProcessor;
40907
40907
  }
40908
- record(value, attributes, context2, recordTime) {
40909
- attributes = this._attributesProcessor.process(attributes, context2);
40910
- this._deltaMetricStorage.record(value, attributes, context2, recordTime);
40908
+ record(value, attributes, context3, recordTime) {
40909
+ attributes = this._attributesProcessor.process(attributes, context3);
40910
+ this._deltaMetricStorage.record(value, attributes, context3, recordTime);
40911
40911
  }
40912
40912
  collect(collector, collectionTime) {
40913
40913
  const accumulations = this._deltaMetricStorage.collect();
@@ -40933,10 +40933,10 @@ var require_AttributesProcessor = __commonJS((exports) => {
40933
40933
  constructor(processors) {
40934
40934
  this._processors = processors;
40935
40935
  }
40936
- process(incoming, context2) {
40936
+ process(incoming, context3) {
40937
40937
  let filteredAttributes = incoming;
40938
40938
  for (const processor of this._processors) {
40939
- filteredAttributes = processor.process(filteredAttributes, context2);
40939
+ filteredAttributes = processor.process(filteredAttributes, context3);
40940
40940
  }
40941
40941
  return filteredAttributes;
40942
40942
  }
@@ -41953,19 +41953,19 @@ var require_AbstractAsyncHooksContextManager = __commonJS((exports) => {
41953
41953
  ];
41954
41954
 
41955
41955
  class AbstractAsyncHooksContextManager {
41956
- bind(context2, target) {
41956
+ bind(context3, target) {
41957
41957
  if (target instanceof events_1.EventEmitter) {
41958
- return this._bindEventEmitter(context2, target);
41958
+ return this._bindEventEmitter(context3, target);
41959
41959
  }
41960
41960
  if (typeof target === "function") {
41961
- return this._bindFunction(context2, target);
41961
+ return this._bindFunction(context3, target);
41962
41962
  }
41963
41963
  return target;
41964
41964
  }
41965
- _bindFunction(context2, target) {
41965
+ _bindFunction(context3, target) {
41966
41966
  const manager = this;
41967
41967
  const contextWrapper = function(...args) {
41968
- return manager.with(context2, () => target.apply(this, args));
41968
+ return manager.with(context3, () => target.apply(this, args));
41969
41969
  };
41970
41970
  Object.defineProperty(contextWrapper, "length", {
41971
41971
  enumerable: false,
@@ -41975,7 +41975,7 @@ var require_AbstractAsyncHooksContextManager = __commonJS((exports) => {
41975
41975
  });
41976
41976
  return contextWrapper;
41977
41977
  }
41978
- _bindEventEmitter(context2, ee) {
41978
+ _bindEventEmitter(context3, ee) {
41979
41979
  const map = this._getPatchMap(ee);
41980
41980
  if (map !== undefined)
41981
41981
  return ee;
@@ -41983,7 +41983,7 @@ var require_AbstractAsyncHooksContextManager = __commonJS((exports) => {
41983
41983
  ADD_LISTENER_METHODS.forEach((methodName) => {
41984
41984
  if (ee[methodName] === undefined)
41985
41985
  return;
41986
- ee[methodName] = this._patchAddListener(ee, ee[methodName], context2);
41986
+ ee[methodName] = this._patchAddListener(ee, ee[methodName], context3);
41987
41987
  });
41988
41988
  if (typeof ee.removeListener === "function") {
41989
41989
  ee.removeListener = this._patchRemoveListener(ee, ee.removeListener);
@@ -42021,7 +42021,7 @@ var require_AbstractAsyncHooksContextManager = __commonJS((exports) => {
42021
42021
  return original.apply(this, arguments);
42022
42022
  };
42023
42023
  }
42024
- _patchAddListener(ee, original, context2) {
42024
+ _patchAddListener(ee, original, context3) {
42025
42025
  const contextManager = this;
42026
42026
  return function(event, listener) {
42027
42027
  if (contextManager._wrapped) {
@@ -42036,7 +42036,7 @@ var require_AbstractAsyncHooksContextManager = __commonJS((exports) => {
42036
42036
  listeners = new WeakMap;
42037
42037
  map[event] = listeners;
42038
42038
  }
42039
- const patchedListener = contextManager.bind(context2, listener);
42039
+ const patchedListener = contextManager.bind(context3, listener);
42040
42040
  listeners.set(listener, patchedListener);
42041
42041
  contextManager._wrapped = true;
42042
42042
  try {
@@ -42085,8 +42085,8 @@ var require_AsyncHooksContextManager = __commonJS((exports) => {
42085
42085
  active() {
42086
42086
  return this._stack[this._stack.length - 1] ?? api_1.ROOT_CONTEXT;
42087
42087
  }
42088
- with(context2, fn, thisArg, ...args) {
42089
- this._enterContext(context2);
42088
+ with(context3, fn, thisArg, ...args) {
42089
+ this._enterContext(context3);
42090
42090
  try {
42091
42091
  return fn.call(thisArg, ...args);
42092
42092
  } finally {
@@ -42106,25 +42106,25 @@ var require_AsyncHooksContextManager = __commonJS((exports) => {
42106
42106
  _init(uid, type) {
42107
42107
  if (type === "TIMERWRAP")
42108
42108
  return;
42109
- const context2 = this._stack[this._stack.length - 1];
42110
- if (context2 !== undefined) {
42111
- this._contexts.set(uid, context2);
42109
+ const context3 = this._stack[this._stack.length - 1];
42110
+ if (context3 !== undefined) {
42111
+ this._contexts.set(uid, context3);
42112
42112
  }
42113
42113
  }
42114
42114
  _destroy(uid) {
42115
42115
  this._contexts.delete(uid);
42116
42116
  }
42117
42117
  _before(uid) {
42118
- const context2 = this._contexts.get(uid);
42119
- if (context2 !== undefined) {
42120
- this._enterContext(context2);
42118
+ const context3 = this._contexts.get(uid);
42119
+ if (context3 !== undefined) {
42120
+ this._enterContext(context3);
42121
42121
  }
42122
42122
  }
42123
42123
  _after() {
42124
42124
  this._exitContext();
42125
42125
  }
42126
- _enterContext(context2) {
42127
- this._stack.push(context2);
42126
+ _enterContext(context3) {
42127
+ this._stack.push(context3);
42128
42128
  }
42129
42129
  _exitContext() {
42130
42130
  this._stack.pop();
@@ -42150,9 +42150,9 @@ var require_AsyncLocalStorageContextManager = __commonJS((exports) => {
42150
42150
  active() {
42151
42151
  return this._asyncLocalStorage.getStore() ?? api_1.ROOT_CONTEXT;
42152
42152
  }
42153
- with(context2, fn, thisArg, ...args) {
42153
+ with(context3, fn, thisArg, ...args) {
42154
42154
  const cb = thisArg == null ? fn : fn.bind(thisArg);
42155
- return this._asyncLocalStorage.run(context2, cb, ...args);
42155
+ return this._asyncLocalStorage.run(context3, cb, ...args);
42156
42156
  }
42157
42157
  enable() {
42158
42158
  return this;
@@ -42518,21 +42518,21 @@ var require_ParentBasedSampler = __commonJS((exports) => {
42518
42518
  this._localParentSampled = config2.localParentSampled ?? new AlwaysOnSampler_1.AlwaysOnSampler;
42519
42519
  this._localParentNotSampled = config2.localParentNotSampled ?? new AlwaysOffSampler_1.AlwaysOffSampler;
42520
42520
  }
42521
- shouldSample(context2, traceId, spanName, spanKind, attributes, links) {
42522
- const parentContext = api_1.trace.getSpanContext(context2);
42521
+ shouldSample(context3, traceId, spanName, spanKind, attributes, links) {
42522
+ const parentContext = api_1.trace.getSpanContext(context3);
42523
42523
  if (!parentContext || !(0, api_1.isSpanContextValid)(parentContext)) {
42524
- return this._root.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
42524
+ return this._root.shouldSample(context3, traceId, spanName, spanKind, attributes, links);
42525
42525
  }
42526
42526
  if (parentContext.isRemote) {
42527
42527
  if (parentContext.traceFlags & api_1.TraceFlags.SAMPLED) {
42528
- return this._remoteParentSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
42528
+ return this._remoteParentSampled.shouldSample(context3, traceId, spanName, spanKind, attributes, links);
42529
42529
  }
42530
- return this._remoteParentNotSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
42530
+ return this._remoteParentNotSampled.shouldSample(context3, traceId, spanName, spanKind, attributes, links);
42531
42531
  }
42532
42532
  if (parentContext.traceFlags & api_1.TraceFlags.SAMPLED) {
42533
- return this._localParentSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
42533
+ return this._localParentSampled.shouldSample(context3, traceId, spanName, spanKind, attributes, links);
42534
42534
  }
42535
- return this._localParentNotSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
42535
+ return this._localParentNotSampled.shouldSample(context3, traceId, spanName, spanKind, attributes, links);
42536
42536
  }
42537
42537
  toString() {
42538
42538
  return `ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`;
@@ -42555,7 +42555,7 @@ var require_TraceIdRatioBasedSampler = __commonJS((exports) => {
42555
42555
  this._ratio = this._normalize(ratio);
42556
42556
  this._upperBound = Math.floor(this._ratio * 4294967295);
42557
42557
  }
42558
- shouldSample(context2, traceId) {
42558
+ shouldSample(context3, traceId) {
42559
42559
  return {
42560
42560
  decision: (0, api_1.isValidTraceId)(traceId) && this._accumulate(traceId) < this._upperBound ? Sampler_1.SamplingDecision.RECORD_AND_SAMPLED : Sampler_1.SamplingDecision.NOT_RECORD
42561
42561
  };
@@ -42935,7 +42935,7 @@ var require_Tracer = __commonJS((exports) => {
42935
42935
  var utility_1 = require_utility();
42936
42936
  var platform_1 = require_platform4();
42937
42937
 
42938
- class Tracer {
42938
+ class Tracer2 {
42939
42939
  _sampler;
42940
42940
  _generalLimits;
42941
42941
  _spanLimits;
@@ -42953,12 +42953,12 @@ var require_Tracer = __commonJS((exports) => {
42953
42953
  this._spanProcessor = spanProcessor;
42954
42954
  this.instrumentationScope = instrumentationScope;
42955
42955
  }
42956
- startSpan(name, options = {}, context2 = api2.context.active()) {
42956
+ startSpan(name, options = {}, context3 = api2.context.active()) {
42957
42957
  if (options.root) {
42958
- context2 = api2.trace.deleteSpan(context2);
42958
+ context3 = api2.trace.deleteSpan(context3);
42959
42959
  }
42960
- const parentSpan = api2.trace.getSpan(context2);
42961
- if ((0, core_1.isTracingSuppressed)(context2)) {
42960
+ const parentSpan = api2.trace.getSpan(context3);
42961
+ if ((0, core_1.isTracingSuppressed)(context3)) {
42962
42962
  api2.diag.debug("Instrumentation suppressed, returning Noop Span");
42963
42963
  const nonRecordingSpan = api2.trace.wrapSpanContext(api2.INVALID_SPAN_CONTEXT);
42964
42964
  return nonRecordingSpan;
@@ -42983,7 +42983,7 @@ var require_Tracer = __commonJS((exports) => {
42983
42983
  };
42984
42984
  });
42985
42985
  const attributes = (0, core_1.sanitizeAttributes)(options.attributes);
42986
- const samplingResult = this._sampler.shouldSample(context2, traceId, name, spanKind, attributes, links);
42986
+ const samplingResult = this._sampler.shouldSample(context3, traceId, name, spanKind, attributes, links);
42987
42987
  traceState = samplingResult.traceState ?? traceState;
42988
42988
  const traceFlags = samplingResult.decision === api2.SamplingDecision.RECORD_AND_SAMPLED ? api2.TraceFlags.SAMPLED : api2.TraceFlags.NONE;
42989
42989
  const spanContext = { traceId, spanId, traceFlags, traceState };
@@ -42996,7 +42996,7 @@ var require_Tracer = __commonJS((exports) => {
42996
42996
  const span = new Span_1.SpanImpl({
42997
42997
  resource: this._resource,
42998
42998
  scope: this.instrumentationScope,
42999
- context: context2,
42999
+ context: context3,
43000
43000
  spanContext,
43001
43001
  name,
43002
43002
  kind: spanKind,
@@ -43037,7 +43037,7 @@ var require_Tracer = __commonJS((exports) => {
43037
43037
  return this._spanLimits;
43038
43038
  }
43039
43039
  }
43040
- exports.Tracer = Tracer;
43040
+ exports.Tracer = Tracer2;
43041
43041
  });
43042
43042
 
43043
43043
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/src/MultiSpanProcessor.js
@@ -43065,9 +43065,9 @@ var require_MultiSpanProcessor = __commonJS((exports) => {
43065
43065
  });
43066
43066
  });
43067
43067
  }
43068
- onStart(span, context2) {
43068
+ onStart(span, context3) {
43069
43069
  for (const spanProcessor of this._spanProcessors) {
43070
- spanProcessor.onStart(span, context2);
43070
+ spanProcessor.onStart(span, context3);
43071
43071
  }
43072
43072
  }
43073
43073
  onEnding(span) {
@@ -43486,9 +43486,293 @@ var require_src15 = __commonJS((exports) => {
43486
43486
  });
43487
43487
 
43488
43488
  // src/adapters/langchain/frisk-callback-handler.ts
43489
- var import_api = __toESM(require_src(), 1);
43490
43489
  import { BaseCallbackHandler } from "@langchain/core/callbacks/base";
43491
43490
 
43491
+ // src/core/frisk-session.ts
43492
+ var import_api2 = __toESM(require_src(), 1);
43493
+
43494
+ // ../../node_modules/uuid/wrapper.mjs
43495
+ var import_dist = __toESM(require_dist(), 1);
43496
+ var v1 = import_dist.default.v1;
43497
+ var v1ToV6 = import_dist.default.v1ToV6;
43498
+ var v3 = import_dist.default.v3;
43499
+ var v4 = import_dist.default.v4;
43500
+ var v5 = import_dist.default.v5;
43501
+ var v6 = import_dist.default.v6;
43502
+ var v6ToV1 = import_dist.default.v6ToV1;
43503
+ var v7 = import_dist.default.v7;
43504
+ var NIL = import_dist.default.NIL;
43505
+ var MAX = import_dist.default.MAX;
43506
+ var version = import_dist.default.version;
43507
+ var validate = import_dist.default.validate;
43508
+ var stringify = import_dist.default.stringify;
43509
+ var parse = import_dist.default.parse;
43510
+
43511
+ // src/errors/index.ts
43512
+ class FriskError extends Error {
43513
+ context;
43514
+ constructor(message, options) {
43515
+ super(message, options);
43516
+ this.name = "FriskError";
43517
+ this.context = options?.context;
43518
+ if (Error.captureStackTrace) {
43519
+ Error.captureStackTrace(this, this.constructor);
43520
+ }
43521
+ }
43522
+ }
43523
+
43524
+ class MissingAPIKeyError extends FriskError {
43525
+ constructor(options) {
43526
+ super("Frisk API key is required. Provide it via the apiKey parameter or set the FRISK_API_KEY environment variable.", options);
43527
+ this.name = "MissingAPIKeyError";
43528
+ }
43529
+ }
43530
+
43531
+ class MissingBaseURLError extends FriskError {
43532
+ constructor(options) {
43533
+ super("Frisk base URL is required. Provide it via the baseUrl parameter or set the FRISK_BASE_URL environment variable.", options);
43534
+ this.name = "MissingBaseURLError";
43535
+ }
43536
+ }
43537
+
43538
+ class MissingOtlpEndpointError extends FriskError {
43539
+ constructor(options) {
43540
+ super("Frisk telemetry endpoint is required. Provide it via the telemetryEndpoint parameter or set the FRISK_TELEMETRY_ENDPOINT environment variable.", options);
43541
+ this.name = "MissingTelemetryEndpointError";
43542
+ }
43543
+ }
43544
+
43545
+ class SessionNotFoundError extends FriskError {
43546
+ constructor(sessionId, options) {
43547
+ super(`Session with ID ${sessionId} was not found in the registry.`, options);
43548
+ this.name = "SessionNotFoundError";
43549
+ }
43550
+ }
43551
+
43552
+ class MissingFriskSessionContextError extends FriskError {
43553
+ constructor(options) {
43554
+ super("Frisk session context is missing. Ensure you have created a session with frisk.session() and passed it to the context.", options);
43555
+ this.name = "MissingFriskSessionContextError";
43556
+ }
43557
+ }
43558
+
43559
+ class InvalidFriskSessionError extends FriskError {
43560
+ constructor(options) {
43561
+ super("Invalid Frisk session. The session may have expired or been invalidated.", options);
43562
+ this.name = "InvalidFriskSessionError";
43563
+ }
43564
+ }
43565
+
43566
+ class FriskNotInitializedError extends FriskError {
43567
+ constructor(options) {
43568
+ super("Frisk SDK is not initialized. Call frisk.connect() before using the SDK.", options);
43569
+ this.name = "FriskNotInitializedError";
43570
+ }
43571
+ }
43572
+
43573
+ class UnsupportedToolSchemaError extends FriskError {
43574
+ constructor(expectedType, options) {
43575
+ super(`Unsupported tool schema type. Expected ${expectedType} schema but received an incompatible schema type.`, options);
43576
+ this.name = "UnsupportedToolSchemaError";
43577
+ }
43578
+ }
43579
+
43580
+ class ToolCallEvaluationError extends FriskError {
43581
+ originalError;
43582
+ constructor(originalError, options) {
43583
+ const message = `An error occurred while evaluating the tool call.
43584
+ The tool call will be allowed by default.
43585
+ Original error:
43586
+ ${originalError}`;
43587
+ super(message, { ...options, cause: originalError });
43588
+ this.name = "ToolCallEvaluationError";
43589
+ this.originalError = originalError;
43590
+ }
43591
+ }
43592
+
43593
+ class InvalidAccessTokenError extends Error {
43594
+ constructor(message = "Invalid access token format") {
43595
+ super(message);
43596
+ this.name = "InvalidAccessTokenError";
43597
+ }
43598
+ }
43599
+
43600
+ class FriskBaseURLNotFoundError extends Error {
43601
+ constructor(message = "Frisk base URL not reachable") {
43602
+ super(message);
43603
+ this.name = "FriskBaseURLNotFoundError";
43604
+ }
43605
+ }
43606
+
43607
+ class FriskInvalidAPIKeyError extends Error {
43608
+ constructor(message = "Invalid Frisk API key") {
43609
+ super(message);
43610
+ this.name = "FriskInvalidAPIKeyError";
43611
+ }
43612
+ }
43613
+
43614
+ class UnexpectedFriskServerResponseError extends Error {
43615
+ constructor(message = "Unexpected response from Frisk server") {
43616
+ super(message);
43617
+ this.name = "UnexpectedFriskServerResponseError";
43618
+ }
43619
+ }
43620
+
43621
+ class ToolCallSpanNotInitializedError extends Error {
43622
+ constructor(message = "Tool call span has not been initialized. Call enter() first.") {
43623
+ super(message);
43624
+ this.name = "ToolCallSpanNotInitializedError";
43625
+ }
43626
+ }
43627
+
43628
+ // src/logging/console-logger.ts
43629
+ var LEVEL_PRIORITY = {
43630
+ error: 0,
43631
+ warn: 1,
43632
+ info: 2,
43633
+ debug: 3,
43634
+ trace: 4
43635
+ };
43636
+ function shouldLog(configured, level) {
43637
+ if (configured === "silent")
43638
+ return false;
43639
+ return LEVEL_PRIORITY[level] <= LEVEL_PRIORITY[configured];
43640
+ }
43641
+ function isErrorLike(value) {
43642
+ return value instanceof Error || typeof value === "object" && value !== null && "message" in value && "stack" in value;
43643
+ }
43644
+ function formatArgs(level, bindings, args) {
43645
+ const prefix = bindings ? `[sdk=${bindings.sdk ?? "sdk"}${bindings.component ? `:${bindings.component}` : ""}]` : "";
43646
+ if (args.length === 0)
43647
+ return [prefix];
43648
+ const [first, ...rest] = args;
43649
+ if (isErrorLike(first)) {
43650
+ return [
43651
+ prefix,
43652
+ first,
43653
+ ...rest,
43654
+ bindings ? { ...bindings } : undefined
43655
+ ].filter(Boolean);
43656
+ }
43657
+ return [prefix, ...args, bindings ? { ...bindings } : undefined].filter(Boolean);
43658
+ }
43659
+ function consoleLogger(level = "info", bindings) {
43660
+ const make = (method) => (...args) => {
43661
+ if (!shouldLog(level, method))
43662
+ return;
43663
+ const formatted = formatArgs(method, bindings, args);
43664
+ switch (method) {
43665
+ case "error":
43666
+ console.error(...formatted);
43667
+ break;
43668
+ case "warn":
43669
+ console.warn(...formatted);
43670
+ break;
43671
+ case "info":
43672
+ console.info(...formatted);
43673
+ break;
43674
+ case "debug":
43675
+ console.debug(...formatted);
43676
+ break;
43677
+ case "trace":
43678
+ console.trace(...formatted);
43679
+ break;
43680
+ }
43681
+ };
43682
+ return {
43683
+ error: make("error"),
43684
+ warn: make("warn"),
43685
+ info: make("info"),
43686
+ debug: make("debug"),
43687
+ trace: make("trace"),
43688
+ child(childBindings) {
43689
+ return consoleLogger(level, {
43690
+ ...bindings,
43691
+ ...childBindings
43692
+ });
43693
+ }
43694
+ };
43695
+ }
43696
+
43697
+ // src/logging/derive-sdk-logger.ts
43698
+ function deriveSdkLogger(options = {}, bindings = {}) {
43699
+ const { logger, logLevel = "error" } = options;
43700
+ if (!logger) {
43701
+ return consoleLogger(logLevel, bindings);
43702
+ }
43703
+ let scoped;
43704
+ if (typeof logger.child === "function") {
43705
+ scoped = logger.child(bindings);
43706
+ if (logLevel !== "silent" && "level" in scoped) {
43707
+ try {
43708
+ scoped.level = logLevel;
43709
+ } catch {}
43710
+ }
43711
+ return scoped;
43712
+ }
43713
+ return wrapLogger(logger, bindings);
43714
+ }
43715
+ function wrapLogger(base, bindings) {
43716
+ const wrap = (method) => (...args) => {
43717
+ if (typeof base[method] !== "function")
43718
+ return;
43719
+ base[method](...args, bindings);
43720
+ };
43721
+ return {
43722
+ trace: wrap("trace"),
43723
+ debug: wrap("debug"),
43724
+ info: wrap("info"),
43725
+ warn: wrap("warn"),
43726
+ error: wrap("error")
43727
+ };
43728
+ }
43729
+ // src/logging/log-error.ts
43730
+ function logError(logger, message, error, meta) {
43731
+ if (!logger?.error) {
43732
+ return;
43733
+ }
43734
+ if (error !== undefined) {
43735
+ logger.error(error, message, meta);
43736
+ } else if (meta) {
43737
+ logger.error(message, meta);
43738
+ } else {
43739
+ logger.error(message);
43740
+ }
43741
+ }
43742
+ // src/errors/capture-error.ts
43743
+ function captureError(e, logger, meta) {
43744
+ logError(logger, e.message, e, meta);
43745
+ }
43746
+
43747
+ // src/telemetry/constants.ts
43748
+ var TRACER_NAME = "frisk_js_sdk";
43749
+ var TRACER_VERSION = "0.1.0";
43750
+ var SPAN_NAME_DECIDE_TOOL_CALL = "frisk.tool_call.decide";
43751
+ var SPAN_NAME_OBSERVE_TOOL_CALL = "frisk.tool_call.observation";
43752
+ var SPAN_NAME_FRISK_SESSION = "frisk.session";
43753
+ var ATTRIBUTE_NAME_SESSION_PROMPT = "frisk.session.prompt";
43754
+ var ATTRIBUTE_NAME_SESSION_ID = "frisk.session.id";
43755
+ var ATTRIBUTE_NAME_REMOTE_SESSION_ID = "frisk.session.remote_id";
43756
+ var ATTRIBUTE_NAME_LLM_REASONING = "frisk.llm_reasoning";
43757
+ var ATTRIBUTE_NAME_TOOL_NAME = "frisk.tool.name";
43758
+ var ATTRIBUTE_NAME_FRISK_TOOL_ID = "frisk.tool.id";
43759
+ var ATTRIBUTE_NAME_FRISK_TOOL_VERSION_ID = "frisk.tool.version_id";
43760
+ var ATTRIBUTE_NAME_TOOL_CALL_ID = "frisk.tool_call.id";
43761
+ var ATTRIBUTE_NAME_TOOL_ARGS_JSON = "frisk.tool.args.json";
43762
+ var ATTRIBUTE_NAME_TOOL_ARGS_REDACTED_PATHS_JSON = "frisk.tool.args_redacted_paths.json";
43763
+ var ATTRIBUTE_NAME_AGENT_STATE_JSON = "frisk.agent_state.json";
43764
+ var ATTRIBUTE_NAME_AGENT_STATE_REDACTED_PATHS_JSON = "frisk.agent_state_redacted_paths.json";
43765
+ var ATTRIBUTE_NAME_DECISION_MATCHED_RULE_COUNT = "frisk.decision.matched_rule_count";
43766
+ var ATTRIBUTE_NAME_DECISION_OUTCOME = "frisk.decision.outcome";
43767
+ var ATTRIBUTE_NAME_DECISION_REASON = "frisk.decision.reason";
43768
+ var ATTRIBUTE_NAME_ERROR_TYPE = "error.type";
43769
+ var ATTRIBUTE_NAME_ERROR_MESSAGE = "error.message";
43770
+ var ATTRIBUTE_NAME_TOOL_CALL_IS_SUCCESS = "frisk.tool_call.is_success";
43771
+ var ATTRIBUTE_NAME_TOOL_CALL_IS_ERROR = "frisk.tool_call.is_error";
43772
+ var ATTRIBUTE_NAME_TOOL_CALL_COUNT = "frisk.tool_calls.count";
43773
+ var ATTRIBUTE_NAME_TOOL_CALL_ERROR_COUNT = "frisk.tool_calls.error_count";
43774
+ var ATTRIBUTE_NAME_TOOL_CALL_SEQUENCE_NUMBER = "frisk.tool_call.sequence_number";
43775
+
43492
43776
  // ../../node_modules/zod/v4/core/core.js
43493
43777
  var NEVER = Object.freeze({
43494
43778
  status: "aborted"
@@ -44391,10 +44675,10 @@ var ksuid = /^[A-Za-z0-9]{27}$/;
44391
44675
  var nanoid = /^[a-zA-Z0-9_-]{21}$/;
44392
44676
  var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
44393
44677
  var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
44394
- var uuid = (version) => {
44395
- if (!version)
44678
+ var uuid2 = (version2) => {
44679
+ if (!version2)
44396
44680
  return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
44397
- return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
44681
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
44398
44682
  };
44399
44683
  var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
44400
44684
  var _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
@@ -44701,7 +44985,7 @@ class Doc {
44701
44985
  }
44702
44986
 
44703
44987
  // ../../node_modules/zod/v4/core/versions.js
44704
- var version = {
44988
+ var version2 = {
44705
44989
  major: 4,
44706
44990
  minor: 3,
44707
44991
  patch: 6
@@ -44713,7 +44997,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
44713
44997
  inst ?? (inst = {});
44714
44998
  inst._zod.def = def;
44715
44999
  inst._zod.bag = inst._zod.bag || {};
44716
- inst._zod.version = version;
45000
+ inst._zod.version = version2;
44717
45001
  const checks = [...inst._zod.def.checks ?? []];
44718
45002
  if (inst._zod.traits.has("$ZodCheck")) {
44719
45003
  checks.unshift(inst);
@@ -44859,9 +45143,9 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
44859
45143
  const v = versionMap[def.version];
44860
45144
  if (v === undefined)
44861
45145
  throw new Error(`Invalid UUID version: "${def.version}"`);
44862
- def.pattern ?? (def.pattern = uuid(v));
45146
+ def.pattern ?? (def.pattern = uuid2(v));
44863
45147
  } else
44864
- def.pattern ?? (def.pattern = uuid());
45148
+ def.pattern ?? (def.pattern = uuid2());
44865
45149
  $ZodStringFormat.init(inst, def);
44866
45150
  });
44867
45151
  var $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
@@ -47332,7 +47616,7 @@ var ZodRealError = $constructor("ZodError", initializer2, {
47332
47616
  });
47333
47617
 
47334
47618
  // ../../node_modules/zod/v4/classic/parse.js
47335
- var parse3 = /* @__PURE__ */ _parse(ZodRealError);
47619
+ var parse4 = /* @__PURE__ */ _parse(ZodRealError);
47336
47620
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
47337
47621
  var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
47338
47622
  var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
@@ -47375,7 +47659,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
47375
47659
  reg.add(inst, meta2);
47376
47660
  return inst;
47377
47661
  };
47378
- inst.parse = (data, params) => parse3(inst, data, params, { callee: inst.parse });
47662
+ inst.parse = (data, params) => parse4(inst, data, params, { callee: inst.parse });
47379
47663
  inst.safeParse = (data, params) => safeParse2(inst, data, params);
47380
47664
  inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
47381
47665
  inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
@@ -47890,157 +48174,378 @@ function removeLlmReasoningArg(input) {
47890
48174
  return inputClone;
47891
48175
  }
47892
48176
 
47893
- // src/logging/console-logger.ts
47894
- var LEVEL_PRIORITY = {
47895
- error: 0,
47896
- warn: 1,
47897
- info: 2,
47898
- debug: 3,
47899
- trace: 4
47900
- };
47901
- function shouldLog(configured, level) {
47902
- if (configured === "silent")
47903
- return false;
47904
- return LEVEL_PRIORITY[level] <= LEVEL_PRIORITY[configured];
48177
+ // src/core/session-registry.ts
48178
+ class SessionRegistry {
48179
+ static instance = null;
48180
+ sessions = new Map;
48181
+ static getInstance() {
48182
+ if (!SessionRegistry.instance) {
48183
+ SessionRegistry.instance = new SessionRegistry;
48184
+ }
48185
+ return SessionRegistry.instance;
48186
+ }
48187
+ constructor() {}
48188
+ register(sessionId, session) {
48189
+ this.sessions.set(sessionId, session);
48190
+ }
48191
+ get(sessionId) {
48192
+ const session = this.sessions.get(sessionId);
48193
+ if (!session) {
48194
+ throw new SessionNotFoundError(sessionId);
48195
+ }
48196
+ return session;
48197
+ }
48198
+ has(sessionId) {
48199
+ return this.sessions.has(sessionId);
48200
+ }
48201
+ unregister(sessionId) {
48202
+ return this.sessions.delete(sessionId);
48203
+ }
48204
+ clear() {
48205
+ this.sessions.clear();
48206
+ }
48207
+ get size() {
48208
+ return this.sessions.size;
48209
+ }
47905
48210
  }
47906
- function isErrorLike(value) {
47907
- return value instanceof Error || typeof value === "object" && value !== null && "message" in value && "stack" in value;
48211
+
48212
+ // src/core/tool-call-span.ts
48213
+ var import_api = __toESM(require_src(), 1);
48214
+
48215
+ // src/core/redaction-options.ts
48216
+ function resolveRedactionOptions(options) {
48217
+ return {
48218
+ redactToolArgs: options?.redactToolArgs ?? false,
48219
+ redactAgentState: options?.redactAgentState ?? false
48220
+ };
47908
48221
  }
47909
- function formatArgs(level, bindings, args) {
47910
- const prefix = bindings ? `[sdk=${bindings.sdk ?? "sdk"}${bindings.component ? `:${bindings.component}` : ""}]` : "";
47911
- if (args.length === 0)
47912
- return [prefix];
47913
- const [first, ...rest] = args;
47914
- if (isErrorLike(first)) {
47915
- return [
47916
- prefix,
47917
- first,
47918
- ...rest,
47919
- bindings ? { ...bindings } : undefined
47920
- ].filter(Boolean);
48222
+
48223
+ // src/core/tool-call-span.ts
48224
+ class ToolCallSpan {
48225
+ adapter;
48226
+ toolCall;
48227
+ friskToolId;
48228
+ agentState;
48229
+ parent;
48230
+ tracer;
48231
+ redaction;
48232
+ _span = null;
48233
+ _traceContextCarrier = null;
48234
+ sessionId;
48235
+ friskToolVersionId;
48236
+ constructor({
48237
+ sessionId,
48238
+ adapter,
48239
+ toolCall,
48240
+ friskToolId,
48241
+ friskToolVersionId,
48242
+ agentState,
48243
+ parent,
48244
+ tracer,
48245
+ redact
48246
+ }) {
48247
+ this.sessionId = sessionId;
48248
+ this.adapter = adapter;
48249
+ this.toolCall = toolCall;
48250
+ this.friskToolId = friskToolId ?? null;
48251
+ this.friskToolVersionId = friskToolVersionId ?? null;
48252
+ this.agentState = agentState;
48253
+ this.parent = parent;
48254
+ this.tracer = tracer;
48255
+ this.redaction = resolveRedactionOptions(redact);
47921
48256
  }
47922
- return [prefix, ...args, bindings ? { ...bindings } : undefined].filter(Boolean);
47923
- }
47924
- function consoleLogger(level = "info", bindings) {
47925
- const make = (method) => (...args) => {
47926
- if (!shouldLog(level, method))
48257
+ get span() {
48258
+ if (!this._span) {
48259
+ throw new ToolCallSpanNotInitializedError;
48260
+ }
48261
+ return this._span;
48262
+ }
48263
+ get traceContextCarrier() {
48264
+ return this._traceContextCarrier;
48265
+ }
48266
+ run(callback) {
48267
+ this.enter();
48268
+ try {
48269
+ return callback(this);
48270
+ } finally {
48271
+ this.exit();
48272
+ }
48273
+ }
48274
+ async runAsync(callback) {
48275
+ this.enter();
48276
+ try {
48277
+ return await callback(this);
48278
+ } finally {
48279
+ this.exit();
48280
+ }
48281
+ }
48282
+ setAttribute(key, value) {
48283
+ this.span.setAttribute(key, value);
48284
+ }
48285
+ setAttributes(attributes) {
48286
+ this.span.setAttributes(attributes);
48287
+ }
48288
+ saveResult(decision) {
48289
+ if (!this.span) {
47927
48290
  return;
47928
- const formatted = formatArgs(method, bindings, args);
47929
- switch (method) {
47930
- case "error":
47931
- console.error(...formatted);
47932
- break;
47933
- case "warn":
47934
- console.warn(...formatted);
47935
- break;
47936
- case "info":
47937
- console.info(...formatted);
47938
- break;
47939
- case "debug":
47940
- console.debug(...formatted);
47941
- break;
47942
- case "trace":
47943
- console.trace(...formatted);
47944
- break;
47945
48291
  }
47946
- };
47947
- return {
47948
- error: make("error"),
47949
- warn: make("warn"),
47950
- info: make("info"),
47951
- debug: make("debug"),
47952
- trace: make("trace"),
47953
- child(childBindings) {
47954
- return consoleLogger(level, {
47955
- ...bindings,
47956
- ...childBindings
47957
- });
48292
+ this.setAttributes({
48293
+ [ATTRIBUTE_NAME_DECISION_OUTCOME]: decision.outcome,
48294
+ [ATTRIBUTE_NAME_DECISION_MATCHED_RULE_COUNT]: Number(decision.rulesMatchedCount)
48295
+ });
48296
+ if (decision.reason) {
48297
+ this.setAttribute(ATTRIBUTE_NAME_DECISION_REASON, decision.reason);
47958
48298
  }
47959
- };
48299
+ }
48300
+ saveError(error2) {
48301
+ if (!this.span) {
48302
+ return;
48303
+ }
48304
+ const errorMessage = error2 instanceof Error ? error2.message : String(error2);
48305
+ const errorType = error2 instanceof Error ? error2.constructor.name : typeof error2;
48306
+ this.setAttributes({
48307
+ [ATTRIBUTE_NAME_ERROR_TYPE]: errorType,
48308
+ [ATTRIBUTE_NAME_ERROR_MESSAGE]: errorMessage
48309
+ });
48310
+ }
48311
+ enter() {
48312
+ const parentContext = this.parent ? import_api.trace.setSpan(import_api.context.active(), this.parent) : import_api.context.active();
48313
+ const redactedToolArgsResult = this.adapter.serializeToolArgs(removeLlmReasoningArg(this.toolCall.args), { redact: this.redaction.redactToolArgs });
48314
+ const redactedAgentStateResult = this.adapter.serializeAgentState(this.agentState, { redact: this.redaction.redactAgentState });
48315
+ this._span = this.tracer.startSpan(SPAN_NAME_DECIDE_TOOL_CALL, {
48316
+ attributes: {
48317
+ [ATTRIBUTE_NAME_SESSION_ID]: this.sessionId,
48318
+ [ATTRIBUTE_NAME_TOOL_NAME]: this.toolCall.name,
48319
+ ...this.friskToolId !== null ? { [ATTRIBUTE_NAME_FRISK_TOOL_ID]: this.friskToolId } : {},
48320
+ ...this.friskToolVersionId !== null ? {
48321
+ [ATTRIBUTE_NAME_FRISK_TOOL_VERSION_ID]: this.friskToolVersionId
48322
+ } : {},
48323
+ [ATTRIBUTE_NAME_TOOL_CALL_ID]: this.toolCall.id,
48324
+ [ATTRIBUTE_NAME_TOOL_ARGS_JSON]: redactedToolArgsResult.value ?? "",
48325
+ [ATTRIBUTE_NAME_TOOL_ARGS_REDACTED_PATHS_JSON]: JSON.stringify(redactedToolArgsResult.redactedPaths),
48326
+ [ATTRIBUTE_NAME_AGENT_STATE_JSON]: redactedAgentStateResult.value ?? "",
48327
+ [ATTRIBUTE_NAME_AGENT_STATE_REDACTED_PATHS_JSON]: JSON.stringify(redactedAgentStateResult.redactedPaths)
48328
+ }
48329
+ }, parentContext);
48330
+ this._traceContextCarrier = {};
48331
+ const spanContext = import_api.trace.setSpan(import_api.context.active(), this.span);
48332
+ import_api.propagation.inject(spanContext, this._traceContextCarrier);
48333
+ }
48334
+ exit() {
48335
+ if (!this.span) {
48336
+ return;
48337
+ }
48338
+ this.span.end();
48339
+ }
47960
48340
  }
47961
48341
 
47962
- // src/logging/derive-sdk-logger.ts
47963
- function deriveSdkLogger(options = {}, bindings = {}) {
47964
- const { logger, logLevel = "error" } = options;
47965
- if (!logger) {
47966
- return consoleLogger(logLevel, bindings);
48342
+ // src/core/types.ts
48343
+ var DecisionOutcome;
48344
+ ((DecisionOutcome2) => {
48345
+ DecisionOutcome2["ALLOW"] = "allow";
48346
+ DecisionOutcome2["DENY"] = "deny";
48347
+ DecisionOutcome2["ERROR"] = "error";
48348
+ DecisionOutcome2["ESCALATE"] = "escalate";
48349
+ })(DecisionOutcome ||= {});
48350
+
48351
+ // src/core/frisk-session.ts
48352
+ class FriskSession {
48353
+ frisk;
48354
+ id;
48355
+ _rootSpan = null;
48356
+ redaction;
48357
+ tracer;
48358
+ logger;
48359
+ _rootRunId = null;
48360
+ _isTracing = false;
48361
+ toolCallSequenceNumber = 0;
48362
+ toolCallSequenceGenerator = this.createToolCallSequenceGenerator();
48363
+ toolCallErrorCount = 0;
48364
+ constructor({ frisk, redact, tracer, logging }) {
48365
+ const sessionId = this.constructor.generateSessionId();
48366
+ this.logger = deriveSdkLogger(logging, {
48367
+ component: "FriskSession"
48368
+ });
48369
+ this.frisk = frisk;
48370
+ this.id = sessionId;
48371
+ this.redaction = redact;
48372
+ this.tracer = tracer;
47967
48373
  }
47968
- let scoped;
47969
- if (typeof logger.child === "function") {
47970
- scoped = logger.child(bindings);
47971
- if (logLevel !== "silent" && "level" in scoped) {
48374
+ get rootSpan() {
48375
+ return this._rootSpan;
48376
+ }
48377
+ getTracer() {
48378
+ return this.tracer;
48379
+ }
48380
+ get isTracing() {
48381
+ return this._isTracing;
48382
+ }
48383
+ get rootRunId() {
48384
+ return this._rootRunId;
48385
+ }
48386
+ async createToolCallSpan({
48387
+ name,
48388
+ args: toolArgsInput
48389
+ }) {
48390
+ const toolArgs = this.validateToolArgs(toolArgsInput);
48391
+ const redactedToolArgsResult = this.frisk.adapter?.serializeToolArgs(removeLlmReasoningArg(toolArgs), { redact: this.redaction.redactToolArgs }) ?? {
48392
+ value: "{}",
48393
+ redactedPaths: []
48394
+ };
48395
+ const sessionSpan = this.rootSpan;
48396
+ const parentContext = sessionSpan ? import_api2.trace.setSpan(import_api2.context.active(), sessionSpan) : import_api2.context.active();
48397
+ const spanAttributes = {
48398
+ [ATTRIBUTE_NAME_SESSION_ID]: this.id,
48399
+ [ATTRIBUTE_NAME_TOOL_NAME]: name,
48400
+ [ATTRIBUTE_NAME_TOOL_ARGS_JSON]: redactedToolArgsResult.value,
48401
+ [ATTRIBUTE_NAME_TOOL_ARGS_REDACTED_PATHS_JSON]: JSON.stringify(redactedToolArgsResult.redactedPaths),
48402
+ [ATTRIBUTE_NAME_TOOL_CALL_SEQUENCE_NUMBER]: this.toolCallSequenceGenerator.next().value
48403
+ };
48404
+ await this.frisk.toolRegistrationComplete;
48405
+ const registeredTool = this.frisk.getRegisteredTool(name);
48406
+ if (registeredTool) {
48407
+ spanAttributes[ATTRIBUTE_NAME_FRISK_TOOL_ID] = registeredTool.id;
48408
+ spanAttributes[ATTRIBUTE_NAME_FRISK_TOOL_VERSION_ID] = registeredTool.versionId;
48409
+ }
48410
+ const span = this.getTracer().startSpan(SPAN_NAME_OBSERVE_TOOL_CALL, {
48411
+ attributes: spanAttributes
48412
+ }, parentContext);
48413
+ return span;
48414
+ }
48415
+ closeToolCallSpan({
48416
+ toolCallId,
48417
+ span,
48418
+ err,
48419
+ status
48420
+ }) {
48421
+ if (toolCallId) {
48422
+ span.setAttribute(ATTRIBUTE_NAME_TOOL_CALL_ID, toolCallId);
48423
+ }
48424
+ if (status === "error" /* Error */ || !!err) {
48425
+ this.incrementToolCallErrors();
48426
+ span.setAttribute(ATTRIBUTE_NAME_TOOL_CALL_IS_ERROR, true);
48427
+ span.setAttribute(ATTRIBUTE_NAME_TOOL_CALL_IS_SUCCESS, false);
48428
+ } else if (status === "success" /* Success */) {
48429
+ span.setAttribute(ATTRIBUTE_NAME_TOOL_CALL_IS_SUCCESS, true);
48430
+ span.setAttribute(ATTRIBUTE_NAME_TOOL_CALL_IS_ERROR, false);
48431
+ }
48432
+ if (err && err instanceof Error) {
48433
+ span.setAttribute(ATTRIBUTE_NAME_ERROR_MESSAGE, `${err}`);
48434
+ span.setAttribute(ATTRIBUTE_NAME_ERROR_TYPE, `${err.constructor.name}`);
48435
+ }
48436
+ span.end();
48437
+ }
48438
+ validateToolArgs(parsedToolArgs) {
48439
+ const isPlainObject2 = typeof parsedToolArgs === "object" && parsedToolArgs !== null && !Array.isArray(parsedToolArgs) && (Object.getPrototypeOf(parsedToolArgs) === Object.prototype || Object.getPrototypeOf(parsedToolArgs) === null);
48440
+ const toolArgs = isPlainObject2 ? parsedToolArgs : {};
48441
+ return toolArgs;
48442
+ }
48443
+ decideToolCall({
48444
+ toolCall,
48445
+ agentState
48446
+ }) {
48447
+ const registeredTool = this.frisk.getRegisteredTool(toolCall.name);
48448
+ const toolCallSpan = new ToolCallSpan({
48449
+ sessionId: this.id,
48450
+ adapter: this.frisk.adapter,
48451
+ toolCall,
48452
+ friskToolId: registeredTool?.id ?? null,
48453
+ friskToolVersionId: registeredTool?.versionId ?? null,
48454
+ agentState,
48455
+ parent: this._rootSpan,
48456
+ tracer: this.tracer,
48457
+ redact: this.redaction
48458
+ });
48459
+ const toolArgs = toolCall.args;
48460
+ return toolCallSpan.run((span) => {
47972
48461
  try {
47973
- scoped.level = logLevel;
47974
- } catch {}
48462
+ if (LLM_REASONING_ARG_NAME in toolArgs) {
48463
+ const llmReasoning = toolArgs[LLM_REASONING_ARG_NAME];
48464
+ span.setAttribute(ATTRIBUTE_NAME_LLM_REASONING, llmReasoning);
48465
+ }
48466
+ const baseToolCallArgs = removeLlmReasoningArg(toolCall.args);
48467
+ const coreResult = this.frisk.decideToolCall({
48468
+ toolCall: {
48469
+ ...toolCall,
48470
+ args: baseToolCallArgs
48471
+ },
48472
+ agentState,
48473
+ traceContextCarrier: span.traceContextCarrier ?? undefined
48474
+ });
48475
+ const result = {
48476
+ outcome: coreResult.outcome,
48477
+ rulesMatchedCount: coreResult.rulesMatchedCount,
48478
+ reason: coreResult.reason,
48479
+ policyId: coreResult.policyId,
48480
+ policyVersionId: coreResult.policyVersionId
48481
+ };
48482
+ span.saveResult(result);
48483
+ return result;
48484
+ } catch (error2) {
48485
+ const wrapped = new ToolCallEvaluationError(error2);
48486
+ captureError(wrapped, this.logger, {
48487
+ toolName: toolCall.name,
48488
+ toolCallId: toolCall.id
48489
+ });
48490
+ span.saveError(wrapped);
48491
+ return {
48492
+ outcome: "error" /* ERROR */,
48493
+ rulesMatchedCount: 0,
48494
+ reason: wrapped.message
48495
+ };
48496
+ }
48497
+ });
48498
+ }
48499
+ *createToolCallSequenceGenerator() {
48500
+ while (true) {
48501
+ yield this.toolCallSequenceNumber++;
47975
48502
  }
47976
- return scoped;
47977
48503
  }
47978
- return wrapLogger(logger, bindings);
47979
- }
47980
- function wrapLogger(base, bindings) {
47981
- const wrap = (method) => (...args) => {
47982
- if (typeof base[method] !== "function")
47983
- return;
47984
- base[method](...args, bindings);
47985
- };
47986
- return {
47987
- trace: wrap("trace"),
47988
- debug: wrap("debug"),
47989
- info: wrap("info"),
47990
- warn: wrap("warn"),
47991
- error: wrap("error")
47992
- };
47993
- }
47994
- // src/logging/log-error.ts
47995
- function logError(logger, message, error2, meta2) {
47996
- if (!logger?.error) {
47997
- return;
48504
+ getToolCallCount() {
48505
+ return this.toolCallSequenceNumber;
47998
48506
  }
47999
- if (error2 !== undefined) {
48000
- logger.error(error2, message, meta2);
48001
- } else if (meta2) {
48002
- logger.error(message, meta2);
48003
- } else {
48004
- logger.error(message);
48507
+ incrementToolCallErrors() {
48508
+ this.toolCallErrorCount += 1;
48509
+ }
48510
+ getToolCallErrorCount() {
48511
+ return this.toolCallErrorCount;
48512
+ }
48513
+ initTracing({ runId, inputs }) {
48514
+ this._rootRunId = runId;
48515
+ this._isTracing = true;
48516
+ const span = this.tracer.startSpan(SPAN_NAME_FRISK_SESSION);
48517
+ span.setAttribute(ATTRIBUTE_NAME_SESSION_ID, this.id);
48518
+ span.setAttribute(ATTRIBUTE_NAME_REMOTE_SESSION_ID, runId);
48519
+ const userPrompt = this.frisk.adapter.extractPrompt?.(inputs);
48520
+ if (userPrompt) {
48521
+ span.setAttribute(ATTRIBUTE_NAME_SESSION_PROMPT, userPrompt);
48522
+ }
48523
+ this.setRootSpan(span);
48524
+ return span;
48525
+ }
48526
+ endTracing() {
48527
+ if (this._rootSpan) {
48528
+ this._rootSpan.setAttribute(ATTRIBUTE_NAME_TOOL_CALL_COUNT, this.getToolCallCount());
48529
+ this._rootSpan.setAttribute(ATTRIBUTE_NAME_TOOL_CALL_ERROR_COUNT, this.getToolCallErrorCount());
48530
+ this._rootSpan.end();
48531
+ }
48532
+ this._isTracing = false;
48533
+ const registry2 = SessionRegistry.getInstance();
48534
+ registry2.unregister(this.id);
48535
+ }
48536
+ setRootSpan(span) {
48537
+ this._rootSpan = span;
48538
+ }
48539
+ static generateSessionId() {
48540
+ return v4();
48005
48541
  }
48006
- }
48007
- // src/errors/capture-error.ts
48008
- function captureError(e, logger, meta2) {
48009
- logError(logger, e.message, e, meta2);
48010
48542
  }
48011
48543
 
48012
- // src/telemetry/constants.ts
48013
- var TRACER_NAME = "frisk_js_sdk";
48014
- var TRACER_VERSION = "0.1.0";
48015
- var SPAN_NAME_DECIDE_TOOL_CALL = "frisk.tool_call.decide";
48016
- var SPAN_NAME_OBSERVE_TOOL_CALL = "frisk.tool_call.observation";
48017
- var SPAN_NAME_FRISK_SESSION = "frisk.session";
48018
- var ATTRIBUTE_NAME_SESSION_PROMPT = "frisk.session.prompt";
48019
- var ATTRIBUTE_NAME_SESSION_ID = "frisk.session.id";
48020
- var ATTRIBUTE_NAME_REMOTE_SESSION_ID = "frisk.session.remote_id";
48021
- var ATTRIBUTE_NAME_LLM_REASONING = "frisk.llm_reasoning";
48022
- var ATTRIBUTE_NAME_TOOL_NAME = "frisk.tool.name";
48023
- var ATTRIBUTE_NAME_FRISK_TOOL_ID = "frisk.tool.id";
48024
- var ATTRIBUTE_NAME_FRISK_TOOL_VERSION_ID = "frisk.tool.version_id";
48025
- var ATTRIBUTE_NAME_TOOL_CALL_ID = "frisk.tool_call.id";
48026
- var ATTRIBUTE_NAME_TOOL_ARGS_JSON = "frisk.tool.args.json";
48027
- var ATTRIBUTE_NAME_TOOL_ARGS_REDACTED_PATHS_JSON = "frisk.tool.args_redacted_paths.json";
48028
- var ATTRIBUTE_NAME_AGENT_STATE_JSON = "frisk.agent_state.json";
48029
- var ATTRIBUTE_NAME_AGENT_STATE_REDACTED_PATHS_JSON = "frisk.agent_state_redacted_paths.json";
48030
- var ATTRIBUTE_NAME_DECISION_MATCHED_RULE_COUNT = "frisk.decision.matched_rule_count";
48031
- var ATTRIBUTE_NAME_DECISION_OUTCOME = "frisk.decision.outcome";
48032
- var ATTRIBUTE_NAME_DECISION_REASON = "frisk.decision.reason";
48033
- var ATTRIBUTE_NAME_ERROR_TYPE = "error.type";
48034
- var ATTRIBUTE_NAME_ERROR_MESSAGE = "error.message";
48035
- var ATTRIBUTE_NAME_LATENCY_NS = "latency_ns";
48036
- var ATTRIBUTE_NAME_TOOL_CALL_IS_SUCCESS = "frisk.tool_call.is_success";
48037
- var ATTRIBUTE_NAME_TOOL_CALL_IS_ERROR = "frisk.tool_call.is_error";
48038
48544
  // src/adapters/langchain/frisk-callback-handler.ts
48039
48545
  class FriskCallbackHandler extends BaseCallbackHandler {
48040
48546
  name = "FriskCallbackHandler";
48041
48547
  session;
48042
48548
  spansByRunId;
48043
- startTimesByRunId;
48044
48549
  frisk;
48045
48550
  logger;
48046
48551
  constructor({
@@ -48052,7 +48557,6 @@ class FriskCallbackHandler extends BaseCallbackHandler {
48052
48557
  this.session = session;
48053
48558
  this.frisk = frisk;
48054
48559
  this.spansByRunId = new Map;
48055
- this.startTimesByRunId = new Map;
48056
48560
  this.logger = deriveSdkLogger(logging, {
48057
48561
  component: "FriskCallbackHandler"
48058
48562
  });
@@ -48076,7 +48580,6 @@ class FriskCallbackHandler extends BaseCallbackHandler {
48076
48580
  captureError(new Error(`Langchain invoked handleToolStart without a tool name. This tool call won't be included in Frisk telemetry data.`), this.logger);
48077
48581
  return;
48078
48582
  }
48079
- this.startTimesByRunId.set(runId, process.hrtime.bigint());
48080
48583
  let parsedToolArgs = {};
48081
48584
  try {
48082
48585
  parsedToolArgs = JSON.parse(input);
@@ -48086,118 +48589,60 @@ class FriskCallbackHandler extends BaseCallbackHandler {
48086
48589
  }), this.logger);
48087
48590
  parsedToolArgs = {};
48088
48591
  }
48089
- const isPlainObject2 = typeof parsedToolArgs === "object" && parsedToolArgs !== null && !Array.isArray(parsedToolArgs) && (Object.getPrototypeOf(parsedToolArgs) === Object.prototype || Object.getPrototypeOf(parsedToolArgs) === null);
48090
- const toolArgs = isPlainObject2 ? parsedToolArgs : {};
48091
- const redactedToolArgsResult = this.frisk.adapter?.serializeToolArgs(removeLlmReasoningArg(toolArgs), { redact: this.frisk.redaction.redactToolArgs }) ?? {
48092
- value: "{}",
48093
- redactedPaths: []
48094
- };
48095
- await this.frisk.toolRegistrationComplete;
48096
- const registeredTool = this.frisk.getRegisteredTool(toolName);
48097
- const spanAttributes = {
48098
- [ATTRIBUTE_NAME_SESSION_ID]: this.session.id,
48099
- [ATTRIBUTE_NAME_TOOL_NAME]: toolName,
48100
- [ATTRIBUTE_NAME_TOOL_ARGS_JSON]: redactedToolArgsResult.value,
48101
- [ATTRIBUTE_NAME_TOOL_ARGS_REDACTED_PATHS_JSON]: JSON.stringify(redactedToolArgsResult.redactedPaths)
48102
- };
48103
- if (registeredTool) {
48104
- spanAttributes[ATTRIBUTE_NAME_FRISK_TOOL_ID] = registeredTool.id;
48105
- spanAttributes[ATTRIBUTE_NAME_FRISK_TOOL_VERSION_ID] = registeredTool.versionId;
48106
- }
48107
- const sessionSpan = this.session.rootSpan;
48108
- const parentContext = sessionSpan ? import_api.trace.setSpan(import_api.context.active(), sessionSpan) : import_api.context.active();
48109
- const span = this.session.getTracer().startSpan(SPAN_NAME_OBSERVE_TOOL_CALL, {
48110
- attributes: spanAttributes
48111
- }, parentContext);
48592
+ const span = await this.session.createToolCallSpan({
48593
+ name: toolName,
48594
+ args: parsedToolArgs
48595
+ });
48112
48596
  this.spansByRunId.set(runId, span);
48113
48597
  }
48114
48598
  async handleToolEnd(output, runId, parentRunId, tags) {
48115
48599
  const span = this.spansByRunId.get(runId);
48116
48600
  if (!span) {
48117
48601
  captureError(new Error("Langchain invoked handleToolEnd but no span was found for the given runId. This tool call won't be included in Frisk telemetry data."), this.logger);
48118
- this.startTimesByRunId.delete(runId);
48119
48602
  return;
48120
48603
  }
48121
48604
  const toolCallId = output.tool_call_id;
48122
48605
  const status = output.status;
48123
- const startTimeNs = this.startTimesByRunId.get(runId);
48124
- this.closeSpan({
48606
+ this.closeToolCallSpan({
48125
48607
  toolCallId,
48126
48608
  span,
48127
- startTimeNs,
48128
48609
  status,
48129
48610
  err: null
48130
48611
  });
48131
- this.startTimesByRunId.delete(runId);
48132
48612
  this.spansByRunId.delete(runId);
48133
48613
  }
48134
48614
  async handleToolError(err, runId, parentRunId, tags) {
48135
48615
  const span = this.spansByRunId.get(runId);
48136
48616
  if (!span) {
48137
48617
  captureError(new Error("Langchain invoked handleToolError but no span was found for the given runId. This tool call won't be included in Frisk telemetry data."), this.logger);
48138
- this.startTimesByRunId.delete(runId);
48139
48618
  return;
48140
48619
  }
48141
- const startTimeNs = this.startTimesByRunId.get(runId);
48142
- this.closeSpan({
48620
+ this.closeToolCallSpan({
48143
48621
  toolCallId: null,
48144
48622
  span,
48145
- startTimeNs,
48146
48623
  status: "error",
48147
48624
  err
48148
48625
  });
48149
- this.startTimesByRunId.delete(runId);
48150
48626
  this.spansByRunId.delete(runId);
48151
48627
  }
48152
- closeSpan({
48628
+ closeToolCallSpan({
48153
48629
  toolCallId,
48154
48630
  span,
48155
- startTimeNs,
48156
48631
  status,
48157
48632
  err
48158
48633
  }) {
48159
- if (toolCallId) {
48160
- span.setAttribute(ATTRIBUTE_NAME_TOOL_CALL_ID, toolCallId);
48161
- }
48162
- if (startTimeNs) {
48163
- const endTimeNs = process.hrtime.bigint();
48164
- const latencyNs = endTimeNs - startTimeNs;
48165
- span.setAttribute(ATTRIBUTE_NAME_LATENCY_NS, Number(latencyNs));
48166
- }
48167
- if (status === "success") {
48168
- span.setAttribute(ATTRIBUTE_NAME_TOOL_CALL_IS_SUCCESS, true);
48169
- span.setAttribute(ATTRIBUTE_NAME_TOOL_CALL_IS_ERROR, false);
48170
- } else if (status === "error") {
48171
- span.setAttribute(ATTRIBUTE_NAME_TOOL_CALL_IS_ERROR, true);
48172
- span.setAttribute(ATTRIBUTE_NAME_TOOL_CALL_IS_SUCCESS, false);
48173
- }
48174
- if (err && err instanceof Error) {
48175
- span.setAttribute(ATTRIBUTE_NAME_ERROR_MESSAGE, `${err}`);
48176
- span.setAttribute(ATTRIBUTE_NAME_ERROR_TYPE, `${err.constructor.name}`);
48177
- }
48178
- span.end();
48634
+ const coreToolCallStatus = status === "success" ? "success" /* Success */ : status === "error" ? "error" /* Error */ : null;
48635
+ this.session.closeToolCallSpan({
48636
+ toolCallId,
48637
+ span,
48638
+ err,
48639
+ status: coreToolCallStatus
48640
+ });
48179
48641
  }
48180
48642
  }
48181
48643
  // src/adapters/langchain/frisk-langchain.ts
48182
48644
  import { createMiddleware } from "langchain";
48183
48645
 
48184
- // ../../node_modules/uuid/wrapper.mjs
48185
- var import_dist = __toESM(require_dist(), 1);
48186
- var v1 = import_dist.default.v1;
48187
- var v1ToV6 = import_dist.default.v1ToV6;
48188
- var v3 = import_dist.default.v3;
48189
- var v4 = import_dist.default.v4;
48190
- var v5 = import_dist.default.v5;
48191
- var v6 = import_dist.default.v6;
48192
- var v6ToV1 = import_dist.default.v6ToV1;
48193
- var v7 = import_dist.default.v7;
48194
- var NIL = import_dist.default.NIL;
48195
- var MAX = import_dist.default.MAX;
48196
- var version2 = import_dist.default.version;
48197
- var validate = import_dist.default.validate;
48198
- var stringify = import_dist.default.stringify;
48199
- var parse5 = import_dist.default.parse;
48200
-
48201
48646
  // src/env/index.ts
48202
48647
  var FRISK_API_KEY = "FRISK_API_KEY";
48203
48648
  var FRISK_BASE_URL = "FRISK_BASE_URL";
@@ -48215,123 +48660,6 @@ function requireEnv(name) {
48215
48660
  return value;
48216
48661
  }
48217
48662
 
48218
- // src/errors/index.ts
48219
- class FriskError extends Error {
48220
- context;
48221
- constructor(message, options) {
48222
- super(message, options);
48223
- this.name = "FriskError";
48224
- this.context = options?.context;
48225
- if (Error.captureStackTrace) {
48226
- Error.captureStackTrace(this, this.constructor);
48227
- }
48228
- }
48229
- }
48230
-
48231
- class MissingAPIKeyError extends FriskError {
48232
- constructor(options) {
48233
- super("Frisk API key is required. Provide it via the apiKey parameter or set the FRISK_API_KEY environment variable.", options);
48234
- this.name = "MissingAPIKeyError";
48235
- }
48236
- }
48237
-
48238
- class MissingBaseURLError extends FriskError {
48239
- constructor(options) {
48240
- super("Frisk base URL is required. Provide it via the baseUrl parameter or set the FRISK_BASE_URL environment variable.", options);
48241
- this.name = "MissingBaseURLError";
48242
- }
48243
- }
48244
-
48245
- class MissingOtlpEndpointError extends FriskError {
48246
- constructor(options) {
48247
- super("Frisk telemetry endpoint is required. Provide it via the telemetryEndpoint parameter or set the FRISK_TELEMETRY_ENDPOINT environment variable.", options);
48248
- this.name = "MissingTelemetryEndpointError";
48249
- }
48250
- }
48251
-
48252
- class SessionNotFoundError extends FriskError {
48253
- constructor(sessionId, options) {
48254
- super(`Session with ID ${sessionId} was not found in the registry.`, options);
48255
- this.name = "SessionNotFoundError";
48256
- }
48257
- }
48258
-
48259
- class MissingFriskSessionContextError extends FriskError {
48260
- constructor(options) {
48261
- super("Frisk session context is missing. Ensure you have created a session with frisk.session() and passed it to the context.", options);
48262
- this.name = "MissingFriskSessionContextError";
48263
- }
48264
- }
48265
-
48266
- class InvalidFriskSessionError extends FriskError {
48267
- constructor(options) {
48268
- super("Invalid Frisk session. The session may have expired or been invalidated.", options);
48269
- this.name = "InvalidFriskSessionError";
48270
- }
48271
- }
48272
-
48273
- class FriskNotInitializedError extends FriskError {
48274
- constructor(options) {
48275
- super("Frisk SDK is not initialized. Call frisk.connect() before using the SDK.", options);
48276
- this.name = "FriskNotInitializedError";
48277
- }
48278
- }
48279
-
48280
- class UnsupportedToolSchemaError extends FriskError {
48281
- constructor(expectedType, options) {
48282
- super(`Unsupported tool schema type. Expected ${expectedType} schema but received an incompatible schema type.`, options);
48283
- this.name = "UnsupportedToolSchemaError";
48284
- }
48285
- }
48286
-
48287
- class ToolCallEvaluationError extends FriskError {
48288
- originalError;
48289
- constructor(originalError, options) {
48290
- const message = `An error occurred while evaluating the tool call.
48291
- The tool call will be allowed by default.
48292
- Original error:
48293
- ${originalError}`;
48294
- super(message, { ...options, cause: originalError });
48295
- this.name = "ToolCallEvaluationError";
48296
- this.originalError = originalError;
48297
- }
48298
- }
48299
-
48300
- class InvalidAccessTokenError extends Error {
48301
- constructor(message = "Invalid access token format") {
48302
- super(message);
48303
- this.name = "InvalidAccessTokenError";
48304
- }
48305
- }
48306
-
48307
- class FriskBaseURLNotFoundError extends Error {
48308
- constructor(message = "Frisk base URL not reachable") {
48309
- super(message);
48310
- this.name = "FriskBaseURLNotFoundError";
48311
- }
48312
- }
48313
-
48314
- class FriskInvalidAPIKeyError extends Error {
48315
- constructor(message = "Invalid Frisk API key") {
48316
- super(message);
48317
- this.name = "FriskInvalidAPIKeyError";
48318
- }
48319
- }
48320
-
48321
- class UnexpectedFriskServerResponseError extends Error {
48322
- constructor(message = "Unexpected response from Frisk server") {
48323
- super(message);
48324
- this.name = "UnexpectedFriskServerResponseError";
48325
- }
48326
- }
48327
-
48328
- class ToolCallSpanNotInitializedError extends Error {
48329
- constructor(message = "Tool call span has not been initialized. Call enter() first.") {
48330
- super(message);
48331
- this.name = "ToolCallSpanNotInitializedError";
48332
- }
48333
- }
48334
-
48335
48663
  // src/utils/redact.ts
48336
48664
  function combineRedactOptions(...options) {
48337
48665
  const paths = [];
@@ -48437,7 +48765,6 @@ function resolveNativePath() {
48437
48765
  var nativeBindings = require2(resolveNativePath());
48438
48766
  var FriskHandle = nativeBindings.FriskHandle;
48439
48767
  var redactDictionary = nativeBindings.redactDictionary;
48440
-
48441
48768
  // src/telemetry/tracing-manager.ts
48442
48769
  var import_grpc_js = __toESM(require_src4(), 1);
48443
48770
  var import_exporter_trace_otlp_grpc = __toESM(require_src12(), 1);
@@ -48713,304 +49040,6 @@ class AccessTokenProvider {
48713
49040
  }
48714
49041
  }
48715
49042
 
48716
- // src/core/session-registry.ts
48717
- class SessionRegistry {
48718
- static instance = null;
48719
- sessions = new Map;
48720
- static getInstance() {
48721
- if (!SessionRegistry.instance) {
48722
- SessionRegistry.instance = new SessionRegistry;
48723
- }
48724
- return SessionRegistry.instance;
48725
- }
48726
- constructor() {}
48727
- register(sessionId, session) {
48728
- this.sessions.set(sessionId, session);
48729
- }
48730
- get(sessionId) {
48731
- const session = this.sessions.get(sessionId);
48732
- if (!session) {
48733
- throw new SessionNotFoundError(sessionId);
48734
- }
48735
- return session;
48736
- }
48737
- has(sessionId) {
48738
- return this.sessions.has(sessionId);
48739
- }
48740
- unregister(sessionId) {
48741
- return this.sessions.delete(sessionId);
48742
- }
48743
- clear() {
48744
- this.sessions.clear();
48745
- }
48746
- get size() {
48747
- return this.sessions.size;
48748
- }
48749
- }
48750
-
48751
- // src/core/tool-call-span.ts
48752
- var import_api2 = __toESM(require_src(), 1);
48753
-
48754
- // src/core/redaction-options.ts
48755
- function resolveRedactionOptions(options) {
48756
- return {
48757
- redactToolArgs: options?.redactToolArgs ?? false,
48758
- redactAgentState: options?.redactAgentState ?? false
48759
- };
48760
- }
48761
-
48762
- // src/core/tool-call-span.ts
48763
- class ToolCallSpan {
48764
- adapter;
48765
- toolCall;
48766
- friskToolId;
48767
- agentState;
48768
- parent;
48769
- tracer;
48770
- redaction;
48771
- _span = null;
48772
- _startTimeNs = null;
48773
- _traceContextCarrier = null;
48774
- sessionId;
48775
- friskToolVersionId;
48776
- constructor({
48777
- sessionId,
48778
- adapter,
48779
- toolCall,
48780
- friskToolId,
48781
- friskToolVersionId,
48782
- agentState,
48783
- parent,
48784
- tracer,
48785
- redact
48786
- }) {
48787
- this.sessionId = sessionId;
48788
- this.adapter = adapter;
48789
- this.toolCall = toolCall;
48790
- this.friskToolId = friskToolId ?? null;
48791
- this.friskToolVersionId = friskToolVersionId ?? null;
48792
- this.agentState = agentState;
48793
- this.parent = parent;
48794
- this.tracer = tracer;
48795
- this.redaction = resolveRedactionOptions(redact);
48796
- }
48797
- get span() {
48798
- if (!this._span) {
48799
- throw new ToolCallSpanNotInitializedError;
48800
- }
48801
- return this._span;
48802
- }
48803
- get traceContextCarrier() {
48804
- return this._traceContextCarrier;
48805
- }
48806
- run(callback) {
48807
- this.enter();
48808
- try {
48809
- return callback(this);
48810
- } finally {
48811
- this.exit();
48812
- }
48813
- }
48814
- async runAsync(callback) {
48815
- this.enter();
48816
- try {
48817
- return await callback(this);
48818
- } finally {
48819
- this.exit();
48820
- }
48821
- }
48822
- setAttribute(key, value) {
48823
- this.span.setAttribute(key, value);
48824
- }
48825
- setAttributes(attributes) {
48826
- this.span.setAttributes(attributes);
48827
- }
48828
- saveResult(decision) {
48829
- if (!this.span) {
48830
- return;
48831
- }
48832
- this.setAttributes({
48833
- [ATTRIBUTE_NAME_DECISION_OUTCOME]: decision.outcome,
48834
- [ATTRIBUTE_NAME_DECISION_MATCHED_RULE_COUNT]: Number(decision.rulesMatchedCount)
48835
- });
48836
- if (decision.reason) {
48837
- this.setAttribute(ATTRIBUTE_NAME_DECISION_REASON, decision.reason);
48838
- }
48839
- }
48840
- saveError(error2) {
48841
- if (!this.span) {
48842
- return;
48843
- }
48844
- const errorMessage = error2 instanceof Error ? error2.message : String(error2);
48845
- const errorType = error2 instanceof Error ? error2.constructor.name : typeof error2;
48846
- this.setAttributes({
48847
- [ATTRIBUTE_NAME_ERROR_TYPE]: errorType,
48848
- [ATTRIBUTE_NAME_ERROR_MESSAGE]: errorMessage
48849
- });
48850
- }
48851
- enter() {
48852
- const parentContext = this.parent ? import_api2.trace.setSpan(import_api2.context.active(), this.parent) : import_api2.context.active();
48853
- this._startTimeNs = process.hrtime.bigint();
48854
- const redactedToolArgsResult = this.adapter.serializeToolArgs(removeLlmReasoningArg(this.toolCall.args), { redact: this.redaction.redactToolArgs });
48855
- const redactedAgentStateResult = this.adapter.serializeAgentState(this.agentState, { redact: this.redaction.redactAgentState });
48856
- this._span = this.tracer.startSpan(SPAN_NAME_DECIDE_TOOL_CALL, {
48857
- attributes: {
48858
- [ATTRIBUTE_NAME_SESSION_ID]: this.sessionId,
48859
- [ATTRIBUTE_NAME_TOOL_NAME]: this.toolCall.name,
48860
- ...this.friskToolId !== null ? { [ATTRIBUTE_NAME_FRISK_TOOL_ID]: this.friskToolId } : {},
48861
- ...this.friskToolVersionId !== null ? {
48862
- [ATTRIBUTE_NAME_FRISK_TOOL_VERSION_ID]: this.friskToolVersionId
48863
- } : {},
48864
- [ATTRIBUTE_NAME_TOOL_CALL_ID]: this.toolCall.id,
48865
- [ATTRIBUTE_NAME_TOOL_ARGS_JSON]: redactedToolArgsResult.value ?? "",
48866
- [ATTRIBUTE_NAME_TOOL_ARGS_REDACTED_PATHS_JSON]: JSON.stringify(redactedToolArgsResult.redactedPaths),
48867
- [ATTRIBUTE_NAME_AGENT_STATE_JSON]: redactedAgentStateResult.value ?? "",
48868
- [ATTRIBUTE_NAME_AGENT_STATE_REDACTED_PATHS_JSON]: JSON.stringify(redactedAgentStateResult.redactedPaths)
48869
- }
48870
- }, parentContext);
48871
- this._traceContextCarrier = {};
48872
- const spanContext = import_api2.trace.setSpan(import_api2.context.active(), this.span);
48873
- import_api2.propagation.inject(spanContext, this._traceContextCarrier);
48874
- }
48875
- exit() {
48876
- if (!this.span) {
48877
- return;
48878
- }
48879
- if (this._startTimeNs !== null) {
48880
- const endTimeNs = process.hrtime.bigint();
48881
- const latencyNs = endTimeNs - this._startTimeNs;
48882
- this.setAttribute(ATTRIBUTE_NAME_LATENCY_NS, Number(latencyNs));
48883
- }
48884
- this.span.end();
48885
- }
48886
- }
48887
-
48888
- // src/core/types.ts
48889
- var DecisionOutcome;
48890
- ((DecisionOutcome2) => {
48891
- DecisionOutcome2["ALLOW"] = "allow";
48892
- DecisionOutcome2["DENY"] = "deny";
48893
- DecisionOutcome2["ERROR"] = "error";
48894
- DecisionOutcome2["ESCALATE"] = "escalate";
48895
- })(DecisionOutcome ||= {});
48896
-
48897
- // src/core/frisk-session.ts
48898
- class FriskSession {
48899
- frisk;
48900
- id;
48901
- _rootSpan = null;
48902
- redaction;
48903
- tracer;
48904
- logger;
48905
- _rootRunId = null;
48906
- _isTracing = false;
48907
- constructor({ frisk, redact, tracer, logging }) {
48908
- const sessionId = this.constructor.generateSessionId();
48909
- this.logger = deriveSdkLogger(logging, {
48910
- component: "FriskSession"
48911
- });
48912
- this.frisk = frisk;
48913
- this.id = sessionId;
48914
- this.redaction = redact;
48915
- this.tracer = tracer;
48916
- }
48917
- get rootSpan() {
48918
- return this._rootSpan;
48919
- }
48920
- getTracer() {
48921
- return this.tracer;
48922
- }
48923
- get isTracing() {
48924
- return this._isTracing;
48925
- }
48926
- get rootRunId() {
48927
- return this._rootRunId;
48928
- }
48929
- decideToolCall({
48930
- toolCall,
48931
- agentState
48932
- }) {
48933
- const registeredTool = this.frisk.getRegisteredTool(toolCall.name);
48934
- const toolCallSpan = new ToolCallSpan({
48935
- sessionId: this.id,
48936
- adapter: this.frisk.adapter,
48937
- toolCall,
48938
- friskToolId: registeredTool?.id ?? null,
48939
- friskToolVersionId: registeredTool?.versionId ?? null,
48940
- agentState,
48941
- parent: this._rootSpan,
48942
- tracer: this.tracer,
48943
- redact: this.redaction
48944
- });
48945
- const toolArgs = toolCall.args;
48946
- return toolCallSpan.run((span) => {
48947
- try {
48948
- if (LLM_REASONING_ARG_NAME in toolArgs) {
48949
- const llmReasoning = toolArgs[LLM_REASONING_ARG_NAME];
48950
- span.setAttribute(ATTRIBUTE_NAME_LLM_REASONING, llmReasoning);
48951
- }
48952
- const baseToolCallArgs = removeLlmReasoningArg(toolCall.args);
48953
- const coreResult = this.frisk.decideToolCall({
48954
- toolCall: {
48955
- ...toolCall,
48956
- args: baseToolCallArgs
48957
- },
48958
- agentState,
48959
- traceContextCarrier: span.traceContextCarrier ?? undefined
48960
- });
48961
- const result = {
48962
- outcome: coreResult.outcome,
48963
- rulesMatchedCount: coreResult.rulesMatchedCount,
48964
- reason: coreResult.reason,
48965
- policyId: coreResult.policyId,
48966
- policyVersionId: coreResult.policyVersionId
48967
- };
48968
- span.saveResult(result);
48969
- return result;
48970
- } catch (error2) {
48971
- const wrapped = new ToolCallEvaluationError(error2);
48972
- captureError(wrapped, this.logger, {
48973
- toolName: toolCall.name,
48974
- toolCallId: toolCall.id
48975
- });
48976
- span.saveError(wrapped);
48977
- return {
48978
- outcome: "error" /* ERROR */,
48979
- rulesMatchedCount: 0,
48980
- reason: wrapped.message
48981
- };
48982
- }
48983
- });
48984
- }
48985
- initTracing({ runId, inputs }) {
48986
- this._rootRunId = runId;
48987
- this._isTracing = true;
48988
- const span = this.tracer.startSpan(SPAN_NAME_FRISK_SESSION);
48989
- span.setAttribute(ATTRIBUTE_NAME_SESSION_ID, this.id);
48990
- span.setAttribute(ATTRIBUTE_NAME_REMOTE_SESSION_ID, runId);
48991
- const userPrompt = this.frisk.adapter.extractPrompt?.(inputs);
48992
- if (userPrompt) {
48993
- span.setAttribute(ATTRIBUTE_NAME_SESSION_PROMPT, userPrompt);
48994
- }
48995
- this.setRootSpan(span);
48996
- return span;
48997
- }
48998
- endTracing() {
48999
- if (this._rootSpan) {
49000
- this._rootSpan.end();
49001
- }
49002
- this._isTracing = false;
49003
- const registry2 = SessionRegistry.getInstance();
49004
- registry2.unregister(this.id);
49005
- }
49006
- setRootSpan(span) {
49007
- this._rootSpan = span;
49008
- }
49009
- static generateSessionId() {
49010
- return v4();
49011
- }
49012
- }
49013
-
49014
49043
  // src/core/sdk-attributes/detect-runtime.ts
49015
49044
  function detectRuntime() {
49016
49045
  const g = globalThis;
@@ -49051,7 +49080,7 @@ import { fileURLToPath } from "node:url";
49051
49080
 
49052
49081
  // src/generated/sdk-meta.ts
49053
49082
  var SDK_NAME = "@friskai/frisk-js";
49054
- var SDK_VERSION = "0.2.8";
49083
+ var SDK_VERSION = "0.2.10";
49055
49084
 
49056
49085
  // src/core/sdk-attributes/read-sdk-meta.ts
49057
49086
  function getSdkMeta() {
@@ -50250,5 +50279,5 @@ export {
50250
50279
  FRISK_SESSION_ID_KEY
50251
50280
  };
50252
50281
 
50253
- //# debugId=889F4C22F819342664756E2164756E21
50282
+ //# debugId=A5DABECDF865C55064756E2164756E21
50254
50283
  //# sourceMappingURL=index.js.map