@digipair/skill-vespa 0.41.4 → 0.43.2

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.
Files changed (3) hide show
  1. package/index.cjs.js +523 -199
  2. package/index.esm.js +2048 -1237
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -61,7 +61,7 @@ function _array_like_to_array$C(arr, len) {
61
61
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
62
62
  return arr2;
63
63
  }
64
- function _array_with_holes$i(arr) {
64
+ function _array_with_holes$h(arr) {
65
65
  if (Array.isArray(arr)) return arr;
66
66
  }
67
67
  function _array_without_holes$y(arr) {
@@ -183,7 +183,7 @@ function _is_native_function$6(fn) {
183
183
  function _iterable_to_array$y(iter) {
184
184
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
185
185
  }
186
- function _iterable_to_array_limit$i(arr, i) {
186
+ function _iterable_to_array_limit$h(arr, i) {
187
187
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
188
188
  if (_i == null) return;
189
189
  var _arr = [];
@@ -207,7 +207,7 @@ function _iterable_to_array_limit$i(arr, i) {
207
207
  }
208
208
  return _arr;
209
209
  }
210
- function _non_iterable_rest$i() {
210
+ function _non_iterable_rest$h() {
211
211
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
212
212
  }
213
213
  function _non_iterable_spread$y() {
@@ -265,8 +265,8 @@ function _set_prototype_of$k(o, p) {
265
265
  };
266
266
  return _set_prototype_of$k(o, p);
267
267
  }
268
- function _sliced_to_array$i(arr, i) {
269
- return _array_with_holes$i(arr) || _iterable_to_array_limit$i(arr, i) || _unsupported_iterable_to_array$C(arr, i) || _non_iterable_rest$i();
268
+ function _sliced_to_array$h(arr, i) {
269
+ return _array_with_holes$h(arr) || _iterable_to_array_limit$h(arr, i) || _unsupported_iterable_to_array$C(arr, i) || _non_iterable_rest$h();
270
270
  }
271
271
  function _to_consumable_array$y(arr) {
272
272
  return _array_without_holes$y(arr) || _iterable_to_array$y(arr) || _unsupported_iterable_to_array$C(arr) || _non_iterable_spread$y();
@@ -1725,7 +1725,7 @@ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-
1725
1725
  // /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
1726
1726
  // from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
1727
1727
  var _emojiRegex = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
1728
- var emojiRegex;
1728
+ var emojiRegex$1;
1729
1729
  // faster, simpler, safer
1730
1730
  var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
1731
1731
  var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
@@ -1862,10 +1862,10 @@ var ZodString = /*#__PURE__*/ function(ZodType) {
1862
1862
  status.dirty();
1863
1863
  }
1864
1864
  } else if (check.kind === "emoji") {
1865
- if (!emojiRegex) {
1866
- emojiRegex = new RegExp(_emojiRegex, "u");
1865
+ if (!emojiRegex$1) {
1866
+ emojiRegex$1 = new RegExp(_emojiRegex, "u");
1867
1867
  }
1868
- if (!emojiRegex.test(input.data)) {
1868
+ if (!emojiRegex$1.test(input.data)) {
1869
1869
  ctx1 = this._getOrReturnCtx(input, ctx1);
1870
1870
  addIssueToContext(ctx1, {
1871
1871
  validation: "emoji",
@@ -4814,7 +4814,7 @@ var ZodIntersection = /*#__PURE__*/ function(ZodType) {
4814
4814
  parent: ctx
4815
4815
  })
4816
4816
  ]).then(function(param) {
4817
- var _param = _sliced_to_array$i(param, 2), left = _param[0], right = _param[1];
4817
+ var _param = _sliced_to_array$h(param, 2), left = _param[0], right = _param[1];
4818
4818
  return handleParsed(left, right);
4819
4819
  });
4820
4820
  } else {
@@ -5036,7 +5036,7 @@ var ZodMap = /*#__PURE__*/ function(ZodType) {
5036
5036
  var keyType = this._def.keyType;
5037
5037
  var valueType = this._def.valueType;
5038
5038
  var pairs = _to_consumable_array$y(ctx.data.entries()).map(function(param, index) {
5039
- var _param = _sliced_to_array$i(param, 2), key = _param[0], value = _param[1];
5039
+ var _param = _sliced_to_array$h(param, 2), key = _param[0], value = _param[1];
5040
5040
  return {
5041
5041
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [
5042
5042
  index,
@@ -11122,10 +11122,10 @@ function _array_like_to_array$x(arr, len) {
11122
11122
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
11123
11123
  return arr2;
11124
11124
  }
11125
- function _array_with_holes$h(arr) {
11125
+ function _array_with_holes$g(arr) {
11126
11126
  if (Array.isArray(arr)) return arr;
11127
11127
  }
11128
- function _iterable_to_array_limit$h(arr, i) {
11128
+ function _iterable_to_array_limit$g(arr, i) {
11129
11129
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
11130
11130
  if (_i == null) return;
11131
11131
  var _arr = [];
@@ -11149,11 +11149,11 @@ function _iterable_to_array_limit$h(arr, i) {
11149
11149
  }
11150
11150
  return _arr;
11151
11151
  }
11152
- function _non_iterable_rest$h() {
11152
+ function _non_iterable_rest$g() {
11153
11153
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
11154
11154
  }
11155
- function _sliced_to_array$h(arr, i) {
11156
- return _array_with_holes$h(arr) || _iterable_to_array_limit$h(arr, i) || _unsupported_iterable_to_array$x(arr, i) || _non_iterable_rest$h();
11155
+ function _sliced_to_array$g(arr, i) {
11156
+ return _array_with_holes$g(arr) || _iterable_to_array_limit$g(arr, i) || _unsupported_iterable_to_array$x(arr, i) || _non_iterable_rest$g();
11157
11157
  }
11158
11158
  function _unsupported_iterable_to_array$x(o, minLen) {
11159
11159
  if (!o) return;
@@ -11217,7 +11217,7 @@ var simplify = function(versions, range, options) {
11217
11217
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
11218
11218
  try {
11219
11219
  for(var _iterator1 = set[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
11220
- var _step_value = _sliced_to_array$h(_step1.value, 2), min = _step_value[0], max = _step_value[1];
11220
+ var _step_value = _sliced_to_array$g(_step1.value, 2), min = _step_value[0], max = _step_value[1];
11221
11221
  if (min === max) {
11222
11222
  ranges.push(min);
11223
11223
  } else if (!max && min === v[0]) {
@@ -11658,10 +11658,10 @@ function _array_like_to_array$w(arr, len) {
11658
11658
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
11659
11659
  return arr2;
11660
11660
  }
11661
- function _array_with_holes$g(arr) {
11661
+ function _array_with_holes$f(arr) {
11662
11662
  if (Array.isArray(arr)) return arr;
11663
11663
  }
11664
- function _iterable_to_array_limit$g(arr, i) {
11664
+ function _iterable_to_array_limit$f(arr, i) {
11665
11665
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
11666
11666
  if (_i == null) return;
11667
11667
  var _arr = [];
@@ -11685,11 +11685,11 @@ function _iterable_to_array_limit$g(arr, i) {
11685
11685
  }
11686
11686
  return _arr;
11687
11687
  }
11688
- function _non_iterable_rest$g() {
11688
+ function _non_iterable_rest$f() {
11689
11689
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
11690
11690
  }
11691
- function _sliced_to_array$g(arr, i) {
11692
- return _array_with_holes$g(arr) || _iterable_to_array_limit$g(arr, i) || _unsupported_iterable_to_array$w(arr, i) || _non_iterable_rest$g();
11691
+ function _sliced_to_array$f(arr, i) {
11692
+ return _array_with_holes$f(arr) || _iterable_to_array_limit$f(arr, i) || _unsupported_iterable_to_array$w(arr, i) || _non_iterable_rest$f();
11693
11693
  }
11694
11694
  function _unsupported_iterable_to_array$w(o, minLen) {
11695
11695
  if (!o) return;
@@ -11711,10 +11711,10 @@ function parsePromptIdentifier(identifier) {
11711
11711
  if (!identifier || identifier.split("/").length > 2 || identifier.startsWith("/") || identifier.endsWith("/") || identifier.split(":").length > 2) {
11712
11712
  throw new Error("Invalid identifier format: ".concat(identifier));
11713
11713
  }
11714
- var _identifier_split = _sliced_to_array$g(identifier.split(":"), 2), ownerNamePart = _identifier_split[0], commitPart = _identifier_split[1];
11714
+ var _identifier_split = _sliced_to_array$f(identifier.split(":"), 2), ownerNamePart = _identifier_split[0], commitPart = _identifier_split[1];
11715
11715
  var commit = commitPart || "latest";
11716
11716
  if (ownerNamePart.includes("/")) {
11717
- var _ownerNamePart_split = _sliced_to_array$g(ownerNamePart.split("/", 2), 2), owner = _ownerNamePart_split[0], name = _ownerNamePart_split[1];
11717
+ var _ownerNamePart_split = _sliced_to_array$f(ownerNamePart.split("/", 2), 2), owner = _ownerNamePart_split[0], name = _ownerNamePart_split[1];
11718
11718
  if (!owner || !name) {
11719
11719
  throw new Error("Invalid identifier format: ".concat(identifier));
11720
11720
  }
@@ -12211,7 +12211,7 @@ function _array_like_to_array$v(arr, len) {
12211
12211
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
12212
12212
  return arr2;
12213
12213
  }
12214
- function _array_with_holes$f(arr) {
12214
+ function _array_with_holes$e(arr) {
12215
12215
  if (Array.isArray(arr)) return arr;
12216
12216
  }
12217
12217
  function _array_without_holes$t(arr) {
@@ -12456,7 +12456,7 @@ function _instanceof$7(left, right) {
12456
12456
  function _iterable_to_array$t(iter) {
12457
12457
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
12458
12458
  }
12459
- function _iterable_to_array_limit$f(arr, i) {
12459
+ function _iterable_to_array_limit$e(arr, i) {
12460
12460
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
12461
12461
  if (_i == null) return;
12462
12462
  var _arr = [];
@@ -12480,7 +12480,7 @@ function _iterable_to_array_limit$f(arr, i) {
12480
12480
  }
12481
12481
  return _arr;
12482
12482
  }
12483
- function _non_iterable_rest$f() {
12483
+ function _non_iterable_rest$e() {
12484
12484
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
12485
12485
  }
12486
12486
  function _non_iterable_spread$t() {
@@ -12525,9 +12525,9 @@ function _object_spread_props$q(target, source) {
12525
12525
  }
12526
12526
  return target;
12527
12527
  }
12528
- function _object_without_properties$4(source, excluded) {
12528
+ function _object_without_properties$5(source, excluded) {
12529
12529
  if (source == null) return {};
12530
- var target = _object_without_properties_loose$4(source, excluded);
12530
+ var target = _object_without_properties_loose$5(source, excluded);
12531
12531
  var key, i;
12532
12532
  if (Object.getOwnPropertySymbols) {
12533
12533
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
@@ -12540,7 +12540,7 @@ function _object_without_properties$4(source, excluded) {
12540
12540
  }
12541
12541
  return target;
12542
12542
  }
12543
- function _object_without_properties_loose$4(source, excluded) {
12543
+ function _object_without_properties_loose$5(source, excluded) {
12544
12544
  if (source == null) return {};
12545
12545
  var target = {};
12546
12546
  var sourceKeys = Object.keys(source);
@@ -12552,8 +12552,8 @@ function _object_without_properties_loose$4(source, excluded) {
12552
12552
  }
12553
12553
  return target;
12554
12554
  }
12555
- function _sliced_to_array$f(arr, i) {
12556
- return _array_with_holes$f(arr) || _iterable_to_array_limit$f(arr, i) || _unsupported_iterable_to_array$v(arr, i) || _non_iterable_rest$f();
12555
+ function _sliced_to_array$e(arr, i) {
12556
+ return _array_with_holes$e(arr) || _iterable_to_array_limit$e(arr, i) || _unsupported_iterable_to_array$v(arr, i) || _non_iterable_rest$e();
12557
12557
  }
12558
12558
  function _to_consumable_array$t(arr) {
12559
12559
  return _array_without_holes$t(arr) || _iterable_to_array$t(arr) || _unsupported_iterable_to_array$v(arr) || _non_iterable_spread$t();
@@ -13043,17 +13043,11 @@ var Client = /*#__PURE__*/ function() {
13043
13043
  writable: true,
13044
13044
  value: void 0
13045
13045
  });
13046
- Object.defineProperty(this, "autoBatchInitialDelayMs", {
13047
- enumerable: true,
13048
- configurable: true,
13049
- writable: true,
13050
- value: 250
13051
- });
13052
13046
  Object.defineProperty(this, "autoBatchAggregationDelayMs", {
13053
13047
  enumerable: true,
13054
13048
  configurable: true,
13055
13049
  writable: true,
13056
- value: 50
13050
+ value: 250
13057
13051
  });
13058
13052
  Object.defineProperty(this, "batchSizeBytesLimit", {
13059
13053
  enumerable: true,
@@ -13539,7 +13533,7 @@ var Client = /*#__PURE__*/ function() {
13539
13533
  key: "drainAutoBatchQueue",
13540
13534
  value: function drainAutoBatchQueue(batchSizeLimit) {
13541
13535
  while(this.autoBatchQueue.items.length > 0){
13542
- var _this_autoBatchQueue_pop = _sliced_to_array$f(this.autoBatchQueue.pop(batchSizeLimit), 2), batch = _this_autoBatchQueue_pop[0], done = _this_autoBatchQueue_pop[1];
13536
+ var _this_autoBatchQueue_pop = _sliced_to_array$e(this.autoBatchQueue.pop(batchSizeLimit), 2), batch = _this_autoBatchQueue_pop[0], done = _this_autoBatchQueue_pop[1];
13543
13537
  if (!batch.length) {
13544
13538
  done();
13545
13539
  break;
@@ -13635,11 +13629,10 @@ var Client = /*#__PURE__*/ function() {
13635
13629
  value: function processRunOperation(item) {
13636
13630
  var _this = this;
13637
13631
  return _async_to_generator$h(function() {
13638
- var oldTimeout, itemPromise, sizeLimitBytes;
13632
+ var itemPromise, sizeLimitBytes;
13639
13633
  return _ts_generator$i(this, function(_state) {
13640
13634
  switch(_state.label){
13641
13635
  case 0:
13642
- oldTimeout = _this.autoBatchTimeout;
13643
13636
  clearTimeout(_this.autoBatchTimeout);
13644
13637
  _this.autoBatchTimeout = undefined;
13645
13638
  if (item.action === "create") {
@@ -13659,7 +13652,7 @@ var Client = /*#__PURE__*/ function() {
13659
13652
  _this.autoBatchTimeout = setTimeout(function() {
13660
13653
  _this.autoBatchTimeout = undefined;
13661
13654
  _this.drainAutoBatchQueue(sizeLimitBytes);
13662
- }, oldTimeout ? _this.autoBatchAggregationDelayMs : _this.autoBatchInitialDelayMs);
13655
+ }, _this.autoBatchAggregationDelayMs);
13663
13656
  }
13664
13657
  return [
13665
13658
  2,
@@ -14141,7 +14134,7 @@ var Client = /*#__PURE__*/ function() {
14141
14134
  var runCreates = param.runCreates, runUpdates = param.runUpdates;
14142
14135
  var _this = this;
14143
14136
  return _async_to_generator$h(function() {
14144
- var allAttachments, preparedCreateParams, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, create, preparedCreate, preparedUpdateParams, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, update, invalidRunCreate, invalidRunUpdate, createById, standaloneUpdates, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, updateParam, accumulatedContext, accumulatedParts, _i, _iter, _ref, _ref1, method, payloads, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _ref2, originalPayload, inputs, outputs, events, payload, fields, stringifiedPayload, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _step_value, key, value, stringifiedValue, attachments, _iteratorNormalCompletion5, _didIteratorError5, _iteratorError5, _iterator5, _step5, _step_value1, name, _step_value_, contentType, content;
14137
+ var allAttachments, preparedCreateParams, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, create, preparedCreate, preparedUpdateParams, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, update, invalidRunCreate, invalidRunUpdate, createById, standaloneUpdates, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, updateParam, accumulatedContext, accumulatedParts, _i, _iter, _ref, _ref1, method, payloads, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _ref2, originalPayload, inputs, outputs, events, attachments, payload, fields, stringifiedPayload, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, _step_value, key, value, stringifiedValue, attachments1, _iteratorNormalCompletion5, _didIteratorError5, _iteratorError5, _iterator5, _step5, _step_value1, name, _step_value_, contentType, content;
14145
14138
  return _ts_generator$i(this, function(_state) {
14146
14139
  switch(_state.label){
14147
14140
  case 0:
@@ -14268,17 +14261,18 @@ var Client = /*#__PURE__*/ function() {
14268
14261
  ]
14269
14262
  ]; _i < _iter.length; _i++){
14270
14263
  _ref = _iter[_i];
14271
- _ref1 = _sliced_to_array$f(_ref, 2), method = _ref1[0], payloads = _ref1[1];
14264
+ _ref1 = _sliced_to_array$e(_ref, 2), method = _ref1[0], payloads = _ref1[1];
14272
14265
  _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = undefined;
14273
14266
  try {
14274
14267
  for(_iterator3 = payloads[Symbol.iterator](); !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true){
14275
14268
  _ref2 = _step3.value;
14276
14269
  originalPayload = _ref2;
14277
14270
  // collect fields to be sent as separate parts
14278
- inputs = originalPayload.inputs, outputs = originalPayload.outputs, events = originalPayload.events, payload = _object_without_properties$4(originalPayload, [
14271
+ inputs = originalPayload.inputs, outputs = originalPayload.outputs, events = originalPayload.events, attachments = originalPayload.attachments, payload = _object_without_properties$5(originalPayload, [
14279
14272
  "inputs",
14280
14273
  "outputs",
14281
- "events"
14274
+ "events",
14275
+ "attachments"
14282
14276
  ]);
14283
14277
  fields = {
14284
14278
  inputs: inputs,
@@ -14299,7 +14293,7 @@ var Client = /*#__PURE__*/ function() {
14299
14293
  try {
14300
14294
  // encode the fields we collected
14301
14295
  for(_iterator4 = Object.entries(fields)[Symbol.iterator](); !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true){
14302
- _step_value = _sliced_to_array$f(_step4.value, 2), key = _step_value[0], value = _step_value[1];
14296
+ _step_value = _sliced_to_array$e(_step4.value, 2), key = _step_value[0], value = _step_value[1];
14303
14297
  if (value === undefined) {
14304
14298
  continue;
14305
14299
  }
@@ -14329,19 +14323,24 @@ var Client = /*#__PURE__*/ function() {
14329
14323
  }
14330
14324
  // encode the attachments
14331
14325
  if (payload.id !== undefined) {
14332
- attachments = allAttachments[payload.id];
14333
- if (attachments) {
14326
+ attachments1 = allAttachments[payload.id];
14327
+ if (attachments1) {
14334
14328
  delete allAttachments[payload.id];
14335
14329
  _iteratorNormalCompletion5 = true, _didIteratorError5 = false, _iteratorError5 = undefined;
14336
14330
  try {
14337
- for(_iterator5 = Object.entries(attachments)[Symbol.iterator](); !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true){
14338
- _step_value1 = _sliced_to_array$f(_step5.value, 2), name = _step_value1[0], _step_value_ = _sliced_to_array$f(_step_value1[1], 2), contentType = _step_value_[0], content = _step_value_[1];
14331
+ for(_iterator5 = Object.entries(attachments1)[Symbol.iterator](); !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true){
14332
+ _step_value1 = _sliced_to_array$e(_step5.value, 2), name = _step_value1[0], _step_value_ = _sliced_to_array$e(_step_value1[1], 2), contentType = _step_value_[0], content = _step_value_[1];
14333
+ // Validate that the attachment name doesn't contain a '.'
14334
+ if (name.includes(".")) {
14335
+ console.warn("Skipping attachment '".concat(name, "' for run ").concat(payload.id, ": Invalid attachment name. ") + "Attachment names must not contain periods ('.'). Please rename the attachment and try again.");
14336
+ continue;
14337
+ }
14339
14338
  accumulatedParts.push({
14340
14339
  name: "attachment.".concat(payload.id, ".").concat(name),
14341
14340
  payload: new Blob([
14342
14341
  content
14343
14342
  ], {
14344
- type: "".concat(contentType, "; length=").concat(content.length)
14343
+ type: "".concat(contentType, "; length=").concat(content.byteLength)
14345
14344
  })
14346
14345
  });
14347
14346
  }
@@ -14429,6 +14428,7 @@ var Client = /*#__PURE__*/ function() {
14429
14428
  }
14430
14429
  }
14431
14430
  }
14431
+ // Log the form data
14432
14432
  return [
14433
14433
  4,
14434
14434
  _this.batchIngestCaller.call(_getFetchImplementation(), "".concat(_this.apiUrl, "/runs/multipart"), _object_spread$B({
@@ -15113,7 +15113,7 @@ var Client = /*#__PURE__*/ function() {
15113
15113
  };
15114
15114
  // Remove undefined values from the payload
15115
15115
  filteredPayload = Object.fromEntries(Object.entries(payload).filter(function(param) {
15116
- var _param = _sliced_to_array$f(param, 2); _param[0]; var value = _param[1];
15116
+ var _param = _sliced_to_array$e(param, 2); _param[0]; var value = _param[1];
15117
15117
  return value !== undefined;
15118
15118
  }));
15119
15119
  return [
@@ -15525,7 +15525,7 @@ var Client = /*#__PURE__*/ function() {
15525
15525
  }
15526
15526
  urlParams = new URLSearchParams();
15527
15527
  Object.entries(params).forEach(function(param) {
15528
- var _param = _sliced_to_array$f(param, 2), key = _param[0], value = _param[1];
15528
+ var _param = _sliced_to_array$e(param, 2), key = _param[0], value = _param[1];
15529
15529
  if (Array.isArray(value)) {
15530
15530
  value.forEach(function(v) {
15531
15531
  return urlParams.append(key, v);
@@ -16708,7 +16708,7 @@ var Client = /*#__PURE__*/ function() {
16708
16708
  return _ts_generator$i(this, function(_state) {
16709
16709
  switch(_state.label){
16710
16710
  case 0:
16711
- datasetId = props.datasetId, datasetName = props.datasetName, update = _object_without_properties$4(props, [
16711
+ datasetId = props.datasetId, datasetName = props.datasetName, update = _object_without_properties$5(props, [
16712
16712
  "datasetId",
16713
16713
  "datasetName"
16714
16714
  ]);
@@ -17826,7 +17826,7 @@ var Client = /*#__PURE__*/ function() {
17826
17826
  _this._logEvaluationFeedback(feedbackResult, run_, sourceInfo)
17827
17827
  ];
17828
17828
  case 7:
17829
- _ref = _sliced_to_array$f.apply(void 0, [
17829
+ _ref = _sliced_to_array$e.apply(void 0, [
17830
17830
  _state.sent(),
17831
17831
  2
17832
17832
  ]), _ref[0], feedbacks = _ref[1];
@@ -18551,7 +18551,7 @@ var Client = /*#__PURE__*/ function() {
18551
18551
  _this._logEvaluationFeedback(evaluatorResponse, run, sourceInfo)
18552
18552
  ];
18553
18553
  case 1:
18554
- _ref = _sliced_to_array$f.apply(void 0, [
18554
+ _ref = _sliced_to_array$e.apply(void 0, [
18555
18555
  _state.sent(),
18556
18556
  1
18557
18557
  ]), results = _ref[0];
@@ -18723,7 +18723,7 @@ var Client = /*#__PURE__*/ function() {
18723
18723
  "Content-Type": "application/json"
18724
18724
  }),
18725
18725
  body: JSON.stringify(Object.fromEntries(Object.entries(body).filter(function(param) {
18726
- var _param = _sliced_to_array$f(param, 2); _param[0]; var v = _param[1];
18726
+ var _param = _sliced_to_array$e(param, 2); _param[0]; var v = _param[1];
18727
18727
  return v !== undefined;
18728
18728
  }))),
18729
18729
  signal: AbortSignal.timeout(_this.timeout_ms)
@@ -19063,7 +19063,7 @@ var Client = /*#__PURE__*/ function() {
19063
19063
  return _ts_generator$i(this, function(_state) {
19064
19064
  switch(_state.label){
19065
19065
  case 0:
19066
- _parsePromptIdentifier = _sliced_to_array$f(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], _parsePromptIdentifier[2];
19066
+ _parsePromptIdentifier = _sliced_to_array$e(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], _parsePromptIdentifier[2];
19067
19067
  return [
19068
19068
  4,
19069
19069
  _this.caller.call(_getFetchImplementation(), "".concat(_this.apiUrl, "/likes/").concat(owner, "/").concat(promptName), _object_spread$B({
@@ -19108,7 +19108,7 @@ var Client = /*#__PURE__*/ function() {
19108
19108
  return _ts_generator$i(this, function(_state) {
19109
19109
  switch(_state.label){
19110
19110
  case 0:
19111
- _parsePromptIdentifier = _sliced_to_array$f(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], commitHash = _parsePromptIdentifier[2];
19111
+ _parsePromptIdentifier = _sliced_to_array$e(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], commitHash = _parsePromptIdentifier[2];
19112
19112
  return [
19113
19113
  4,
19114
19114
  _this._currentTenantIsOwner(owner)
@@ -19433,7 +19433,7 @@ var Client = /*#__PURE__*/ function() {
19433
19433
  return _ts_generator$i(this, function(_state) {
19434
19434
  switch(_state.label){
19435
19435
  case 0:
19436
- _parsePromptIdentifier = _sliced_to_array$f(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], _parsePromptIdentifier[2];
19436
+ _parsePromptIdentifier = _sliced_to_array$e(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], _parsePromptIdentifier[2];
19437
19437
  return [
19438
19438
  4,
19439
19439
  _this.caller.call(_getFetchImplementation(), "".concat(_this.apiUrl, "/repos/").concat(owner, "/").concat(promptName), _object_spread$B({
@@ -19496,7 +19496,7 @@ var Client = /*#__PURE__*/ function() {
19496
19496
  if ((options === null || options === void 0 ? void 0 : options.isPublic) && !settings.tenant_handle) {
19497
19497
  throw new Error("Cannot create a public prompt without first\n\n creating a LangChain Hub handle. \n You can add a handle by creating a public prompt at:\n\n https://smith.langchain.com/prompts");
19498
19498
  }
19499
- _parsePromptIdentifier = _sliced_to_array$f(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], _parsePromptIdentifier[2];
19499
+ _parsePromptIdentifier = _sliced_to_array$e(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], _parsePromptIdentifier[2];
19500
19500
  return [
19501
19501
  4,
19502
19502
  _this._currentTenantIsOwner(owner)
@@ -19575,7 +19575,7 @@ var Client = /*#__PURE__*/ function() {
19575
19575
  if (!_state.sent()) {
19576
19576
  throw new Error("Prompt does not exist, you must create it first.");
19577
19577
  }
19578
- _parsePromptIdentifier = _sliced_to_array$f(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], _parsePromptIdentifier[2];
19578
+ _parsePromptIdentifier = _sliced_to_array$e(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], _parsePromptIdentifier[2];
19579
19579
  if (!((options === null || options === void 0 ? void 0 : options.parentCommitHash) === "latest" || !(options === null || options === void 0 ? void 0 : options.parentCommitHash))) return [
19580
19580
  3,
19581
19581
  3
@@ -19650,7 +19650,7 @@ var Client = /*#__PURE__*/ function() {
19650
19650
  if (!_state.sent()) {
19651
19651
  throw new Error("Prompt does not exist, you must create it first.");
19652
19652
  }
19653
- _parsePromptIdentifier = _sliced_to_array$f(parsePromptIdentifier(promptIdentifier), 2), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1];
19653
+ _parsePromptIdentifier = _sliced_to_array$e(parsePromptIdentifier(promptIdentifier), 2), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1];
19654
19654
  return [
19655
19655
  4,
19656
19656
  _this._currentTenantIsOwner(owner)
@@ -19722,7 +19722,7 @@ var Client = /*#__PURE__*/ function() {
19722
19722
  if (!_state.sent()) {
19723
19723
  throw new Error("Prompt does not exist, you must create it first.");
19724
19724
  }
19725
- _parsePromptIdentifier = _sliced_to_array$f(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], _parsePromptIdentifier[2];
19725
+ _parsePromptIdentifier = _sliced_to_array$e(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], _parsePromptIdentifier[2];
19726
19726
  return [
19727
19727
  4,
19728
19728
  _this._currentTenantIsOwner(owner)
@@ -19772,7 +19772,7 @@ var Client = /*#__PURE__*/ function() {
19772
19772
  return _ts_generator$i(this, function(_state) {
19773
19773
  switch(_state.label){
19774
19774
  case 0:
19775
- _parsePromptIdentifier = _sliced_to_array$f(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], commitHash = _parsePromptIdentifier[2];
19775
+ _parsePromptIdentifier = _sliced_to_array$e(parsePromptIdentifier(promptIdentifier), 3), owner = _parsePromptIdentifier[0], promptName = _parsePromptIdentifier[1], commitHash = _parsePromptIdentifier[2];
19776
19776
  return [
19777
19777
  4,
19778
19778
  _this._getServerInfo()
@@ -19973,7 +19973,7 @@ var Client = /*#__PURE__*/ function() {
19973
19973
  switch(_state.label){
19974
19974
  case 0:
19975
19975
  _options_sourceApiUrl = options.sourceApiUrl, sourceApiUrl = _options_sourceApiUrl === void 0 ? _this.apiUrl : _options_sourceApiUrl, datasetName = options.datasetName;
19976
- _this_parseTokenOrUrl = _sliced_to_array$f(_this.parseTokenOrUrl(tokenOrUrl, sourceApiUrl), 2), parsedApiUrl = _this_parseTokenOrUrl[0], tokenUuid = _this_parseTokenOrUrl[1];
19976
+ _this_parseTokenOrUrl = _sliced_to_array$e(_this.parseTokenOrUrl(tokenOrUrl, sourceApiUrl), 2), parsedApiUrl = _this_parseTokenOrUrl[0], tokenUuid = _this_parseTokenOrUrl[1];
19977
19977
  sourceClient = new Client({
19978
19978
  apiUrl: parsedApiUrl,
19979
19979
  // Placeholder API key not needed anymore in most cases, but
@@ -20166,7 +20166,7 @@ var Client = /*#__PURE__*/ function() {
20166
20166
  }();
20167
20167
 
20168
20168
  // Update using yarn bump-version
20169
- var __version__ = "0.2.2";
20169
+ var __version__ = "0.2.4";
20170
20170
 
20171
20171
  // Inlined from https://github.com/flexdinesh/browser-or-node
20172
20172
  function _array_like_to_array$u(arr, len) {
@@ -20174,7 +20174,7 @@ function _array_like_to_array$u(arr, len) {
20174
20174
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
20175
20175
  return arr2;
20176
20176
  }
20177
- function _array_with_holes$e(arr) {
20177
+ function _array_with_holes$d(arr) {
20178
20178
  if (Array.isArray(arr)) return arr;
20179
20179
  }
20180
20180
  function _define_property$B(obj, key, value) {
@@ -20190,7 +20190,7 @@ function _define_property$B(obj, key, value) {
20190
20190
  }
20191
20191
  return obj;
20192
20192
  }
20193
- function _iterable_to_array_limit$e(arr, i) {
20193
+ function _iterable_to_array_limit$d(arr, i) {
20194
20194
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
20195
20195
  if (_i == null) return;
20196
20196
  var _arr = [];
@@ -20214,7 +20214,7 @@ function _iterable_to_array_limit$e(arr, i) {
20214
20214
  }
20215
20215
  return _arr;
20216
20216
  }
20217
- function _non_iterable_rest$e() {
20217
+ function _non_iterable_rest$d() {
20218
20218
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
20219
20219
  }
20220
20220
  function _object_spread$A(target) {
@@ -20232,8 +20232,8 @@ function _object_spread$A(target) {
20232
20232
  }
20233
20233
  return target;
20234
20234
  }
20235
- function _sliced_to_array$e(arr, i) {
20236
- return _array_with_holes$e(arr) || _iterable_to_array_limit$e(arr, i) || _unsupported_iterable_to_array$u(arr, i) || _non_iterable_rest$e();
20235
+ function _sliced_to_array$d(arr, i) {
20236
+ return _array_with_holes$d(arr) || _iterable_to_array_limit$d(arr, i) || _unsupported_iterable_to_array$u(arr, i) || _non_iterable_rest$d();
20237
20237
  }
20238
20238
  function _unsupported_iterable_to_array$u(o, minLen) {
20239
20239
  if (!o) return;
@@ -20313,7 +20313,7 @@ function getRuntimeEnvironment$1() {
20313
20313
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
20314
20314
  try {
20315
20315
  for(var _iterator = Object.entries(allEnvVars)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
20316
- var _step_value = _sliced_to_array$e(_step.value, 2), key = _step_value[0], value = _step_value[1];
20316
+ var _step_value = _sliced_to_array$d(_step.value, 2), key = _step_value[0], value = _step_value[1];
20317
20317
  if (key.startsWith("LANGCHAIN_") && typeof value === "string" && !excluded.includes(key) && !key.toLowerCase().includes("key") && !key.toLowerCase().includes("secret") && !key.toLowerCase().includes("token")) {
20318
20318
  if (key === "LANGCHAIN_REVISION_ID") {
20319
20319
  envVars["revision_id"] = value;
@@ -20354,7 +20354,7 @@ function getRuntimeEnvironment$1() {
20354
20354
  if (typeof process !== "undefined" && process.env) {
20355
20355
  // eslint-disable-next-line no-process-env
20356
20356
  return Object.entries(process.env).reduce(function(acc, param) {
20357
- var _param = _sliced_to_array$e(param, 2), key = _param[0], value = _param[1];
20357
+ var _param = _sliced_to_array$d(param, 2), key = _param[0], value = _param[1];
20358
20358
  acc[key] = String(value);
20359
20359
  return acc;
20360
20360
  }, {});
@@ -20458,7 +20458,7 @@ function _array_like_to_array$t(arr, len) {
20458
20458
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
20459
20459
  return arr2;
20460
20460
  }
20461
- function _array_with_holes$d(arr) {
20461
+ function _array_with_holes$c(arr) {
20462
20462
  if (Array.isArray(arr)) return arr;
20463
20463
  }
20464
20464
  function _array_without_holes$s(arr) {
@@ -20528,7 +20528,7 @@ function _define_property$A(obj, key, value) {
20528
20528
  function _iterable_to_array$s(iter) {
20529
20529
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
20530
20530
  }
20531
- function _iterable_to_array_limit$d(arr, i) {
20531
+ function _iterable_to_array_limit$c(arr, i) {
20532
20532
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
20533
20533
  if (_i == null) return;
20534
20534
  var _arr = [];
@@ -20552,7 +20552,7 @@ function _iterable_to_array_limit$d(arr, i) {
20552
20552
  }
20553
20553
  return _arr;
20554
20554
  }
20555
- function _non_iterable_rest$d() {
20555
+ function _non_iterable_rest$c() {
20556
20556
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
20557
20557
  }
20558
20558
  function _non_iterable_spread$s() {
@@ -20597,9 +20597,9 @@ function _object_spread_props$p(target, source) {
20597
20597
  }
20598
20598
  return target;
20599
20599
  }
20600
- function _object_without_properties$3(source, excluded) {
20600
+ function _object_without_properties$4(source, excluded) {
20601
20601
  if (source == null) return {};
20602
- var target = _object_without_properties_loose$3(source, excluded);
20602
+ var target = _object_without_properties_loose$4(source, excluded);
20603
20603
  var key, i;
20604
20604
  if (Object.getOwnPropertySymbols) {
20605
20605
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
@@ -20612,7 +20612,7 @@ function _object_without_properties$3(source, excluded) {
20612
20612
  }
20613
20613
  return target;
20614
20614
  }
20615
- function _object_without_properties_loose$3(source, excluded) {
20615
+ function _object_without_properties_loose$4(source, excluded) {
20616
20616
  if (source == null) return {};
20617
20617
  var target = {};
20618
20618
  var sourceKeys = Object.keys(source);
@@ -20624,8 +20624,8 @@ function _object_without_properties_loose$3(source, excluded) {
20624
20624
  }
20625
20625
  return target;
20626
20626
  }
20627
- function _sliced_to_array$d(arr, i) {
20628
- return _array_with_holes$d(arr) || _iterable_to_array_limit$d(arr, i) || _unsupported_iterable_to_array$t(arr, i) || _non_iterable_rest$d();
20627
+ function _sliced_to_array$c(arr, i) {
20628
+ return _array_with_holes$c(arr) || _iterable_to_array_limit$c(arr, i) || _unsupported_iterable_to_array$t(arr, i) || _non_iterable_rest$c();
20629
20629
  }
20630
20630
  function _to_consumable_array$s(arr) {
20631
20631
  return _array_without_holes$s(arr) || _iterable_to_array$s(arr) || _unsupported_iterable_to_array$t(arr) || _non_iterable_spread$s();
@@ -20788,7 +20788,7 @@ function convertToDottedOrderFormat$1(epoch, runId) {
20788
20788
  try {
20789
20789
  for(var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
20790
20790
  var item = _step.value;
20791
- var _item_split = _sliced_to_array$d(item.split("="), 2), key = _item_split[0], uriValue = _item_split[1];
20791
+ var _item_split = _sliced_to_array$c(item.split("="), 2), key = _item_split[0], uriValue = _item_split[1];
20792
20792
  var _$value = decodeURIComponent(uriValue);
20793
20793
  if (key === "langsmith-metadata") {
20794
20794
  metadata = JSON.parse(_$value);
@@ -20952,13 +20952,22 @@ var RunTree = /*#__PURE__*/ function() {
20952
20952
  writable: true,
20953
20953
  value: void 0
20954
20954
  });
20955
+ /**
20956
+ * Attachments associated with the run.
20957
+ * Each entry is a tuple of [mime_type, bytes]
20958
+ */ Object.defineProperty(this, "attachments", {
20959
+ enumerable: true,
20960
+ configurable: true,
20961
+ writable: true,
20962
+ value: void 0
20963
+ });
20955
20964
  // If you pass in a run tree directly, return a shallow clone
20956
20965
  if (isRunTree(originalConfig)) {
20957
20966
  Object.assign(this, _object_spread$z({}, originalConfig));
20958
20967
  return;
20959
20968
  }
20960
20969
  var defaultConfig = RunTree.getDefaultConfig();
20961
- var metadata = originalConfig.metadata, config = _object_without_properties$3(originalConfig, [
20970
+ var metadata = originalConfig.metadata, config = _object_without_properties$4(originalConfig, [
20962
20971
  "metadata"
20963
20972
  ]);
20964
20973
  var _config_client;
@@ -21081,7 +21090,7 @@ var RunTree = /*#__PURE__*/ function() {
21081
21090
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
21082
21091
  try {
21083
21092
  for(var _iterator = Object.entries(runtimeEnv)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
21084
- var _step_value = _sliced_to_array$d(_step.value, 2), k = _step_value[0], v = _step_value[1];
21093
+ var _step_value = _sliced_to_array$c(_step.value, 2), k = _step_value[0], v = _step_value[1];
21085
21094
  if (!runExtra.runtime[k]) {
21086
21095
  runExtra.runtime[k] = v;
21087
21096
  }
@@ -21130,7 +21139,8 @@ var RunTree = /*#__PURE__*/ function() {
21130
21139
  parent_run_id: parent_run_id,
21131
21140
  trace_id: run.trace_id,
21132
21141
  dotted_order: run.dotted_order,
21133
- tags: run.tags
21142
+ tags: run.tags,
21143
+ attachments: run.attachments
21134
21144
  };
21135
21145
  return persistedRun;
21136
21146
  }
@@ -21272,7 +21282,8 @@ var RunTree = /*#__PURE__*/ function() {
21272
21282
  events: _this.events,
21273
21283
  dotted_order: _this.dotted_order,
21274
21284
  trace_id: _this.trace_id,
21275
- tags: _this.tags
21285
+ tags: _this.tags,
21286
+ attachments: _this.attachments
21276
21287
  };
21277
21288
  return [
21278
21289
  4,
@@ -21318,7 +21329,7 @@ var RunTree = /*#__PURE__*/ function() {
21318
21329
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
21319
21330
  try {
21320
21331
  for(var _iterator = Object.entries(result)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
21321
- var _step_value = _sliced_to_array$d(_step.value, 2), key = _step_value[0], value = _step_value[1];
21332
+ var _step_value = _sliced_to_array$c(_step.value, 2), key = _step_value[0], value = _step_value[1];
21322
21333
  headers.set(key, value);
21323
21334
  }
21324
21335
  } catch (err) {
@@ -21435,7 +21446,7 @@ var RunTree = /*#__PURE__*/ function() {
21435
21446
  if (!headerTrace || typeof headerTrace !== "string") return undefined;
21436
21447
  var parentDottedOrder = headerTrace.trim();
21437
21448
  var parsedDottedOrder = parentDottedOrder.split(".").map(function(part) {
21438
- var _part_split = _sliced_to_array$d(part.split("Z"), 2), strTime = _part_split[0], uuid = _part_split[1];
21449
+ var _part_split = _sliced_to_array$c(part.split("Z"), 2), strTime = _part_split[0], uuid = _part_split[1];
21439
21450
  return {
21440
21451
  strTime: strTime,
21441
21452
  time: Date.parse(strTime + "Z"),
@@ -22536,7 +22547,7 @@ function _array_like_to_array$s(arr, len) {
22536
22547
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
22537
22548
  return arr2;
22538
22549
  }
22539
- function _array_with_holes$c(arr) {
22550
+ function _array_with_holes$b(arr) {
22540
22551
  if (Array.isArray(arr)) return arr;
22541
22552
  }
22542
22553
  function _array_without_holes$r(arr) {
@@ -22584,7 +22595,7 @@ function _instanceof$4(left, right) {
22584
22595
  function _iterable_to_array$r(iter) {
22585
22596
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
22586
22597
  }
22587
- function _iterable_to_array_limit$c(arr, i) {
22598
+ function _iterable_to_array_limit$b(arr, i) {
22588
22599
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
22589
22600
  if (_i == null) return;
22590
22601
  var _arr = [];
@@ -22608,7 +22619,7 @@ function _iterable_to_array_limit$c(arr, i) {
22608
22619
  }
22609
22620
  return _arr;
22610
22621
  }
22611
- function _non_iterable_rest$c() {
22622
+ function _non_iterable_rest$b() {
22612
22623
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
22613
22624
  }
22614
22625
  function _non_iterable_spread$r() {
@@ -22629,11 +22640,11 @@ function _object_spread$w(target) {
22629
22640
  }
22630
22641
  return target;
22631
22642
  }
22632
- function _sliced_to_array$c(arr, i) {
22633
- return _array_with_holes$c(arr) || _iterable_to_array_limit$c(arr, i) || _unsupported_iterable_to_array$s(arr, i) || _non_iterable_rest$c();
22643
+ function _sliced_to_array$b(arr, i) {
22644
+ return _array_with_holes$b(arr) || _iterable_to_array_limit$b(arr, i) || _unsupported_iterable_to_array$s(arr, i) || _non_iterable_rest$b();
22634
22645
  }
22635
22646
  function _to_array$2(arr) {
22636
- return _array_with_holes$c(arr) || _iterable_to_array$r(arr) || _unsupported_iterable_to_array$s(arr) || _non_iterable_rest$c();
22647
+ return _array_with_holes$b(arr) || _iterable_to_array$r(arr) || _unsupported_iterable_to_array$s(arr) || _non_iterable_rest$b();
22637
22648
  }
22638
22649
  function _to_consumable_array$r(arr) {
22639
22650
  return _array_without_holes$r(arr) || _iterable_to_array$r(arr) || _unsupported_iterable_to_array$s(arr) || _non_iterable_spread$r();
@@ -22654,7 +22665,7 @@ function replaceSecrets(root, secretsMap) {
22654
22665
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
22655
22666
  try {
22656
22667
  for(var _iterator = Object.entries(secretsMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
22657
- var _step_value = _sliced_to_array$c(_step.value, 2), path = _step_value[0], secretId = _step_value[1];
22668
+ var _step_value = _sliced_to_array$b(_step.value, 2), path = _step_value[0], secretId = _step_value[1];
22658
22669
  var _path_split_reverse = _to_array$2(path.split(".").reverse()), last = _path_split_reverse[0], partsReverse = _path_split_reverse.slice(1);
22659
22670
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
22660
22671
  var current = result;
@@ -24604,6 +24615,14 @@ var BaseTracer = /*#__PURE__*/ function(BaseCallbackHandler) {
24604
24615
  return BaseTracer;
24605
24616
  }(BaseCallbackHandler);
24606
24617
 
24618
+ var TRACING_ALS_KEY = Symbol.for("ls:tracing_async_local_storage");
24619
+ var setGlobalAsyncLocalStorageInstance = function(instance) {
24620
+ globalThis[TRACING_ALS_KEY] = instance;
24621
+ };
24622
+ var getGlobalAsyncLocalStorageInstance = function() {
24623
+ return globalThis[TRACING_ALS_KEY];
24624
+ };
24625
+
24607
24626
  var ansiStyles = {
24608
24627
  exports: {}
24609
24628
  };
@@ -25592,7 +25611,7 @@ function _array_like_to_array$p(arr, len) {
25592
25611
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
25593
25612
  return arr2;
25594
25613
  }
25595
- function _array_with_holes$b(arr) {
25614
+ function _array_with_holes$a(arr) {
25596
25615
  if (Array.isArray(arr)) return arr;
25597
25616
  }
25598
25617
  function _array_without_holes$o(arr) {
@@ -25658,7 +25677,7 @@ function _inherits$a(subClass, superClass) {
25658
25677
  function _iterable_to_array$o(iter) {
25659
25678
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
25660
25679
  }
25661
- function _iterable_to_array_limit$b(arr, i) {
25680
+ function _iterable_to_array_limit$a(arr, i) {
25662
25681
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
25663
25682
  if (_i == null) return;
25664
25683
  var _arr = [];
@@ -25682,7 +25701,7 @@ function _iterable_to_array_limit$b(arr, i) {
25682
25701
  }
25683
25702
  return _arr;
25684
25703
  }
25685
- function _non_iterable_rest$b() {
25704
+ function _non_iterable_rest$a() {
25686
25705
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
25687
25706
  }
25688
25707
  function _non_iterable_spread$o() {
@@ -25716,8 +25735,8 @@ function _set_prototype_of$a(o, p) {
25716
25735
  };
25717
25736
  return _set_prototype_of$a(o, p);
25718
25737
  }
25719
- function _sliced_to_array$b(arr, i) {
25720
- return _array_with_holes$b(arr) || _iterable_to_array_limit$b(arr, i) || _unsupported_iterable_to_array$p(arr, i) || _non_iterable_rest$b();
25738
+ function _sliced_to_array$a(arr, i) {
25739
+ return _array_with_holes$a(arr) || _iterable_to_array_limit$a(arr, i) || _unsupported_iterable_to_array$p(arr, i) || _non_iterable_rest$a();
25721
25740
  }
25722
25741
  function _to_consumable_array$o(arr) {
25723
25742
  return _array_without_holes$o(arr) || _iterable_to_array$o(arr) || _unsupported_iterable_to_array$p(arr) || _non_iterable_spread$o();
@@ -26006,7 +26025,7 @@ right) {
26006
26025
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
26007
26026
  try {
26008
26027
  for(var _iterator = Object.entries(right)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
26009
- var _step_value = _sliced_to_array$b(_step.value, 2), key = _step_value[0], value = _step_value[1];
26028
+ var _step_value = _sliced_to_array$a(_step.value, 2), key = _step_value[0], value = _step_value[1];
26010
26029
  if (merged[key] == null) {
26011
26030
  merged[key] = value;
26012
26031
  } else if (value == null) {
@@ -26528,12 +26547,24 @@ function _create_super$9(Derived) {
26528
26547
  return string_messages.join("\n");
26529
26548
  }
26530
26549
 
26550
+ var client;
26551
+ var getDefaultLangChainClientSingleton = function() {
26552
+ if (client === undefined) {
26553
+ var clientParams = getEnvironmentVariable("LANGCHAIN_CALLBACKS_BACKGROUND") === "false" ? {
26554
+ // LangSmith has its own backgrounding system
26555
+ blockOnRootRunFinalization: true
26556
+ } : {};
26557
+ client = new Client(clientParams);
26558
+ }
26559
+ return client;
26560
+ };
26561
+
26531
26562
  function _array_like_to_array$o(arr, len) {
26532
26563
  if (len == null || len > arr.length) len = arr.length;
26533
26564
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
26534
26565
  return arr2;
26535
26566
  }
26536
- function _array_with_holes$a(arr) {
26567
+ function _array_with_holes$9(arr) {
26537
26568
  if (Array.isArray(arr)) return arr;
26538
26569
  }
26539
26570
  function _array_without_holes$n(arr) {
@@ -26628,7 +26659,7 @@ function _inherits$8(subClass, superClass) {
26628
26659
  function _iterable_to_array$n(iter) {
26629
26660
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
26630
26661
  }
26631
- function _iterable_to_array_limit$a(arr, i) {
26662
+ function _iterable_to_array_limit$9(arr, i) {
26632
26663
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
26633
26664
  if (_i == null) return;
26634
26665
  var _arr = [];
@@ -26652,7 +26683,7 @@ function _iterable_to_array_limit$a(arr, i) {
26652
26683
  }
26653
26684
  return _arr;
26654
26685
  }
26655
- function _non_iterable_rest$a() {
26686
+ function _non_iterable_rest$9() {
26656
26687
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
26657
26688
  }
26658
26689
  function _non_iterable_spread$n() {
@@ -26710,8 +26741,8 @@ function _set_prototype_of$8(o, p) {
26710
26741
  };
26711
26742
  return _set_prototype_of$8(o, p);
26712
26743
  }
26713
- function _sliced_to_array$a(arr, i) {
26714
- return _array_with_holes$a(arr) || _iterable_to_array_limit$a(arr, i) || _unsupported_iterable_to_array$o(arr, i) || _non_iterable_rest$a();
26744
+ function _sliced_to_array$9(arr, i) {
26745
+ return _array_with_holes$9(arr) || _iterable_to_array_limit$9(arr, i) || _unsupported_iterable_to_array$o(arr, i) || _non_iterable_rest$9();
26715
26746
  }
26716
26747
  function _to_consumable_array$n(arr) {
26717
26748
  return _array_without_holes$n(arr) || _iterable_to_array$n(arr) || _unsupported_iterable_to_array$o(arr) || _non_iterable_spread$n();
@@ -26883,10 +26914,7 @@ var LangChainTracer = /*#__PURE__*/ function(BaseTracer) {
26883
26914
  var _ref;
26884
26915
  _this.projectName = (_ref = projectName !== null && projectName !== void 0 ? projectName : getEnvironmentVariable("LANGCHAIN_PROJECT")) !== null && _ref !== void 0 ? _ref : getEnvironmentVariable("LANGCHAIN_SESSION");
26885
26916
  _this.exampleId = exampleId;
26886
- _this.client = client !== null && client !== void 0 ? client : new Client({
26887
- // LangChain has its own backgrounding system
26888
- blockOnRootRunFinalization: true
26889
- });
26917
+ _this.client = client !== null && client !== void 0 ? client : getDefaultLangChainClientSingleton();
26890
26918
  var traceableTree = LangChainTracer.getTraceableRunTree();
26891
26919
  if (traceableTree) {
26892
26920
  _this.updateFromRunTree(traceableTree);
@@ -27052,7 +27080,7 @@ var LangChainTracer = /*#__PURE__*/ function(BaseTracer) {
27052
27080
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
27053
27081
  try {
27054
27082
  for(var _iterator = this.runMap[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
27055
- var _step_value = _sliced_to_array$a(_step.value, 2), _$id = _step_value[0], run = _step_value[1];
27083
+ var _step_value = _sliced_to_array$9(_step.value, 2), _$id = _step_value[0], run = _step_value[1];
27056
27084
  // by converting the run map to a run tree, we are doing a copy
27057
27085
  // thus, any mutation performed on the run tree will not be reflected
27058
27086
  // back in the run map
@@ -27093,7 +27121,7 @@ var LangChainTracer = /*#__PURE__*/ function(BaseTracer) {
27093
27121
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
27094
27122
  try {
27095
27123
  for(var _iterator1 = runTreeList[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
27096
- var _step_value1 = _sliced_to_array$a(_step1.value, 1), _$id1 = _step_value1[0];
27124
+ var _step_value1 = _sliced_to_array$9(_step1.value, 1), _$id1 = _step_value1[0];
27097
27125
  var run1 = this.runMap.get(_$id1);
27098
27126
  var runTree1 = runTreeMap[_$id1];
27099
27127
  if (!run1 || !runTree1) continue;
@@ -27137,7 +27165,7 @@ var LangChainTracer = /*#__PURE__*/ function(BaseTracer) {
27137
27165
  return LangChainTracer;
27138
27166
  }(BaseTracer);
27139
27167
 
27140
- function asyncGeneratorStep$c(gen, resolve, reject, _next, _throw, key, arg) {
27168
+ /* eslint-disable @typescript-eslint/no-explicit-any */ function asyncGeneratorStep$c(gen, resolve, reject, _next, _throw, key, arg) {
27141
27169
  try {
27142
27170
  var info = gen[key](arg);
27143
27171
  var value = info.value;
@@ -27273,6 +27301,12 @@ var queue;
27273
27301
  concurrency: 1
27274
27302
  });
27275
27303
  }
27304
+ function getQueue() {
27305
+ if (typeof queue === "undefined") {
27306
+ queue = createQueue();
27307
+ }
27308
+ return queue;
27309
+ }
27276
27310
  /**
27277
27311
  * Consume a promise, either adding it to the queue or waiting for it to resolve
27278
27312
  * @param promiseFn Promise to consume
@@ -27286,26 +27320,87 @@ function _consumeCallback() {
27286
27320
  switch(_state.label){
27287
27321
  case 0:
27288
27322
  if (!(wait === true)) return [
27323
+ 3,
27324
+ 5
27325
+ ];
27326
+ if (!(getGlobalAsyncLocalStorageInstance() !== undefined)) return [
27289
27327
  3,
27290
27328
  2
27291
27329
  ];
27292
27330
  return [
27293
27331
  4,
27294
- promiseFn()
27332
+ getGlobalAsyncLocalStorageInstance().run(undefined, /*#__PURE__*/ _async_to_generator$c(function() {
27333
+ return _ts_generator$d(this, function(_state) {
27334
+ return [
27335
+ 2,
27336
+ promiseFn()
27337
+ ];
27338
+ });
27339
+ }))
27295
27340
  ];
27296
27341
  case 1:
27297
27342
  _state.sent();
27298
27343
  return [
27299
27344
  3,
27300
- 3
27345
+ 4
27301
27346
  ];
27302
27347
  case 2:
27303
- if (typeof queue === "undefined") {
27304
- queue = createQueue();
27305
- }
27306
- void queue.add(promiseFn);
27307
- _state.label = 3;
27348
+ return [
27349
+ 4,
27350
+ promiseFn()
27351
+ ];
27308
27352
  case 3:
27353
+ _state.sent();
27354
+ _state.label = 4;
27355
+ case 4:
27356
+ return [
27357
+ 3,
27358
+ 6
27359
+ ];
27360
+ case 5:
27361
+ queue = getQueue();
27362
+ void queue.add(/*#__PURE__*/ _async_to_generator$c(function() {
27363
+ return _ts_generator$d(this, function(_state) {
27364
+ switch(_state.label){
27365
+ case 0:
27366
+ if (!(getGlobalAsyncLocalStorageInstance() !== undefined)) return [
27367
+ 3,
27368
+ 2
27369
+ ];
27370
+ return [
27371
+ 4,
27372
+ getGlobalAsyncLocalStorageInstance().run(undefined, /*#__PURE__*/ _async_to_generator$c(function() {
27373
+ return _ts_generator$d(this, function(_state) {
27374
+ return [
27375
+ 2,
27376
+ promiseFn()
27377
+ ];
27378
+ });
27379
+ }))
27380
+ ];
27381
+ case 1:
27382
+ _state.sent();
27383
+ return [
27384
+ 3,
27385
+ 4
27386
+ ];
27387
+ case 2:
27388
+ return [
27389
+ 4,
27390
+ promiseFn()
27391
+ ];
27392
+ case 3:
27393
+ _state.sent();
27394
+ _state.label = 4;
27395
+ case 4:
27396
+ return [
27397
+ 2
27398
+ ];
27399
+ }
27400
+ });
27401
+ }));
27402
+ _state.label = 6;
27403
+ case 6:
27309
27404
  return [
27310
27405
  2
27311
27406
  ];
@@ -29652,7 +29747,6 @@ var MockAsyncLocalStorage = /*#__PURE__*/ function() {
29652
29747
  return MockAsyncLocalStorage;
29653
29748
  }();
29654
29749
  var mockAsyncLocalStorage = new MockAsyncLocalStorage();
29655
- var TRACING_ALS_KEY = Symbol.for("ls:tracing_async_local_storage");
29656
29750
  var LC_CHILD_KEY = Symbol.for("lc:child_config");
29657
29751
  var _CONTEXT_VARIABLES_KEY = Symbol.for("lc:context_variables");
29658
29752
  var AsyncLocalStorageProvider = /*#__PURE__*/ function() {
@@ -29663,8 +29757,8 @@ var AsyncLocalStorageProvider = /*#__PURE__*/ function() {
29663
29757
  {
29664
29758
  key: "getInstance",
29665
29759
  value: function getInstance() {
29666
- var _globalThis_TRACING_ALS_KEY;
29667
- return (_globalThis_TRACING_ALS_KEY = globalThis[TRACING_ALS_KEY]) !== null && _globalThis_TRACING_ALS_KEY !== void 0 ? _globalThis_TRACING_ALS_KEY : mockAsyncLocalStorage;
29760
+ var _getGlobalAsyncLocalStorageInstance;
29761
+ return (_getGlobalAsyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance()) !== null && _getGlobalAsyncLocalStorageInstance !== void 0 ? _getGlobalAsyncLocalStorageInstance : mockAsyncLocalStorage;
29668
29762
  }
29669
29763
  },
29670
29764
  {
@@ -29710,8 +29804,8 @@ var AsyncLocalStorageProvider = /*#__PURE__*/ function() {
29710
29804
  {
29711
29805
  key: "initializeGlobalInstance",
29712
29806
  value: function initializeGlobalInstance(instance) {
29713
- if (globalThis[TRACING_ALS_KEY] === undefined) {
29714
- globalThis[TRACING_ALS_KEY] = instance;
29807
+ if (getGlobalAsyncLocalStorageInstance() === undefined) {
29808
+ setGlobalAsyncLocalStorageInstance(instance);
29715
29809
  }
29716
29810
  }
29717
29811
  }
@@ -29891,7 +29985,7 @@ function _array_like_to_array$m(arr, len) {
29891
29985
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
29892
29986
  return arr2;
29893
29987
  }
29894
- function _array_with_holes$9(arr) {
29988
+ function _array_with_holes$8(arr) {
29895
29989
  if (Array.isArray(arr)) return arr;
29896
29990
  }
29897
29991
  function _array_without_holes$l(arr) {
@@ -30093,7 +30187,7 @@ function _is_native_function(fn) {
30093
30187
  function _iterable_to_array$l(iter) {
30094
30188
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
30095
30189
  }
30096
- function _iterable_to_array_limit$9(arr, i) {
30190
+ function _iterable_to_array_limit$8(arr, i) {
30097
30191
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
30098
30192
  if (_i == null) return;
30099
30193
  var _arr = [];
@@ -30117,7 +30211,7 @@ function _iterable_to_array_limit$9(arr, i) {
30117
30211
  }
30118
30212
  return _arr;
30119
30213
  }
30120
- function _non_iterable_rest$9() {
30214
+ function _non_iterable_rest$8() {
30121
30215
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
30122
30216
  }
30123
30217
  function _non_iterable_spread$l() {
@@ -30151,8 +30245,8 @@ function _set_prototype_of$6(o, p) {
30151
30245
  };
30152
30246
  return _set_prototype_of$6(o, p);
30153
30247
  }
30154
- function _sliced_to_array$9(arr, i) {
30155
- return _array_with_holes$9(arr) || _iterable_to_array_limit$9(arr, i) || _unsupported_iterable_to_array$m(arr, i) || _non_iterable_rest$9();
30248
+ function _sliced_to_array$8(arr, i) {
30249
+ return _array_with_holes$8(arr) || _iterable_to_array_limit$8(arr, i) || _unsupported_iterable_to_array$m(arr, i) || _non_iterable_rest$8();
30156
30250
  }
30157
30251
  function _to_consumable_array$l(arr) {
30158
30252
  return _array_without_holes$l(arr) || _iterable_to_array$l(arr) || _unsupported_iterable_to_array$m(arr) || _non_iterable_spread$l();
@@ -30683,7 +30777,7 @@ function concat(first, second) {
30683
30777
  try {
30684
30778
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
30685
30779
  for(var _iterator = Object.entries(second)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
30686
- var _step_value = _sliced_to_array$9(_step.value, 2), key = _step_value[0], value = _step_value[1];
30780
+ var _step_value = _sliced_to_array$8(_step.value, 2), key = _step_value[0], value = _step_value[1];
30687
30781
  if (key in chunk && !Array.isArray(chunk[key])) {
30688
30782
  chunk[key] = concat(chunk[key], value);
30689
30783
  } else {
@@ -33610,7 +33704,7 @@ function _array_like_to_array$k(arr, len) {
33610
33704
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
33611
33705
  return arr2;
33612
33706
  }
33613
- function _array_with_holes$8(arr) {
33707
+ function _array_with_holes$7(arr) {
33614
33708
  if (Array.isArray(arr)) return arr;
33615
33709
  }
33616
33710
  function _array_without_holes$j(arr) {
@@ -33661,7 +33755,7 @@ function _define_property$m(obj, key, value) {
33661
33755
  function _iterable_to_array$j(iter) {
33662
33756
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
33663
33757
  }
33664
- function _iterable_to_array_limit$8(arr, i) {
33758
+ function _iterable_to_array_limit$7(arr, i) {
33665
33759
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
33666
33760
  if (_i == null) return;
33667
33761
  var _arr = [];
@@ -33685,7 +33779,7 @@ function _iterable_to_array_limit$8(arr, i) {
33685
33779
  }
33686
33780
  return _arr;
33687
33781
  }
33688
- function _non_iterable_rest$8() {
33782
+ function _non_iterable_rest$7() {
33689
33783
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
33690
33784
  }
33691
33785
  function _non_iterable_spread$j() {
@@ -33706,9 +33800,9 @@ function _object_spread$l(target) {
33706
33800
  }
33707
33801
  return target;
33708
33802
  }
33709
- function _object_without_properties$2(source, excluded) {
33803
+ function _object_without_properties$3(source, excluded) {
33710
33804
  if (source == null) return {};
33711
- var target = _object_without_properties_loose$2(source, excluded);
33805
+ var target = _object_without_properties_loose$3(source, excluded);
33712
33806
  var key, i;
33713
33807
  if (Object.getOwnPropertySymbols) {
33714
33808
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
@@ -33721,7 +33815,7 @@ function _object_without_properties$2(source, excluded) {
33721
33815
  }
33722
33816
  return target;
33723
33817
  }
33724
- function _object_without_properties_loose$2(source, excluded) {
33818
+ function _object_without_properties_loose$3(source, excluded) {
33725
33819
  if (source == null) return {};
33726
33820
  var target = {};
33727
33821
  var sourceKeys = Object.keys(source);
@@ -33733,8 +33827,8 @@ function _object_without_properties_loose$2(source, excluded) {
33733
33827
  }
33734
33828
  return target;
33735
33829
  }
33736
- function _sliced_to_array$8(arr, i) {
33737
- return _array_with_holes$8(arr) || _iterable_to_array_limit$8(arr, i) || _unsupported_iterable_to_array$k(arr, i) || _non_iterable_rest$8();
33830
+ function _sliced_to_array$7(arr, i) {
33831
+ return _array_with_holes$7(arr) || _iterable_to_array_limit$7(arr, i) || _unsupported_iterable_to_array$k(arr, i) || _non_iterable_rest$7();
33738
33832
  }
33739
33833
  function _to_consumable_array$j(arr) {
33740
33834
  return _array_without_holes$j(arr) || _iterable_to_array$j(arr) || _unsupported_iterable_to_array$k(arr) || _non_iterable_spread$j();
@@ -34036,13 +34130,13 @@ var PRIMITIVES = new Set([
34036
34130
  // Don't allow runId and runName to be loaded implicitly, as this can cause
34037
34131
  // child runs to improperly inherit their parents' run ids.
34038
34132
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
34039
- implicitConfig.runId; implicitConfig.runName; var rest = _object_without_properties$2(implicitConfig, [
34133
+ implicitConfig.runId; implicitConfig.runName; var rest = _object_without_properties$3(implicitConfig, [
34040
34134
  "runId",
34041
34135
  "runName"
34042
34136
  ]);
34043
34137
  empty = Object.entries(rest).reduce(// eslint-disable-next-line @typescript-eslint/no-explicit-any
34044
34138
  function(currentConfig, param) {
34045
- var _param = _sliced_to_array$8(param, 2), key = _param[0], value = _param[1];
34139
+ var _param = _sliced_to_array$7(param, 2), key = _param[0], value = _param[1];
34046
34140
  if (value !== undefined) {
34047
34141
  // eslint-disable-next-line no-param-reassign
34048
34142
  currentConfig[key] = value;
@@ -34053,7 +34147,7 @@ var PRIMITIVES = new Set([
34053
34147
  if (config) {
34054
34148
  empty = Object.entries(config).reduce(// eslint-disable-next-line @typescript-eslint/no-explicit-any
34055
34149
  function(currentConfig, param) {
34056
- var _param = _sliced_to_array$8(param, 2), key = _param[0], value = _param[1];
34150
+ var _param = _sliced_to_array$7(param, 2), key = _param[0], value = _param[1];
34057
34151
  if (value !== undefined) {
34058
34152
  // eslint-disable-next-line no-param-reassign
34059
34153
  currentConfig[key] = value;
@@ -34912,7 +35006,7 @@ function _array_like_to_array$i(arr, len) {
34912
35006
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
34913
35007
  return arr2;
34914
35008
  }
34915
- function _array_with_holes$7(arr) {
35009
+ function _array_with_holes$6(arr) {
34916
35010
  if (Array.isArray(arr)) return arr;
34917
35011
  }
34918
35012
  function _array_without_holes$h(arr) {
@@ -34934,7 +35028,7 @@ function _define_property$k(obj, key, value) {
34934
35028
  function _iterable_to_array$h(iter) {
34935
35029
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
34936
35030
  }
34937
- function _iterable_to_array_limit$7(arr, i) {
35031
+ function _iterable_to_array_limit$6(arr, i) {
34938
35032
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
34939
35033
  if (_i == null) return;
34940
35034
  var _arr = [];
@@ -34958,7 +35052,7 @@ function _iterable_to_array_limit$7(arr, i) {
34958
35052
  }
34959
35053
  return _arr;
34960
35054
  }
34961
- function _non_iterable_rest$7() {
35055
+ function _non_iterable_rest$6() {
34962
35056
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
34963
35057
  }
34964
35058
  function _non_iterable_spread$h() {
@@ -35003,8 +35097,8 @@ function _object_spread_props$h(target, source) {
35003
35097
  }
35004
35098
  return target;
35005
35099
  }
35006
- function _sliced_to_array$7(arr, i) {
35007
- return _array_with_holes$7(arr) || _iterable_to_array_limit$7(arr, i) || _unsupported_iterable_to_array$i(arr, i) || _non_iterable_rest$7();
35100
+ function _sliced_to_array$6(arr, i) {
35101
+ return _array_with_holes$6(arr) || _iterable_to_array_limit$6(arr, i) || _unsupported_iterable_to_array$i(arr, i) || _non_iterable_rest$6();
35008
35102
  }
35009
35103
  function _to_consumable_array$h(arr) {
35010
35104
  return _array_without_holes$h(arr) || _iterable_to_array$h(arr) || _unsupported_iterable_to_array$i(arr) || _non_iterable_spread$h();
@@ -35027,7 +35121,7 @@ var getRefs = function(options) {
35027
35121
  currentPath: currentPath,
35028
35122
  propertyPath: undefined,
35029
35123
  seen: new Map(Object.entries(_options.definitions).map(function(param) {
35030
- var _param = _sliced_to_array$7(param, 2), name = _param[0], def = _param[1];
35124
+ var _param = _sliced_to_array$6(param, 2), name = _param[0], def = _param[1];
35031
35125
  return [
35032
35126
  def._def,
35033
35127
  {
@@ -35189,11 +35283,11 @@ function _unsupported_iterable_to_array$h(o, minLen) {
35189
35283
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$h(o, minLen);
35190
35284
  }
35191
35285
  function parseArrayDef(def, refs) {
35192
- var _def_type__def, _def_type;
35286
+ var _def_type, _def_type__def, _def_type1;
35193
35287
  var res = {
35194
35288
  type: "array"
35195
35289
  };
35196
- if (((_def_type = def.type) === null || _def_type === void 0 ? void 0 : (_def_type__def = _def_type._def) === null || _def_type__def === void 0 ? void 0 : _def_type__def.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
35290
+ if (((_def_type = def.type) === null || _def_type === void 0 ? void 0 : _def_type._def) && ((_def_type1 = def.type) === null || _def_type1 === void 0 ? void 0 : (_def_type__def = _def_type1._def) === null || _def_type__def === void 0 ? void 0 : _def_type__def.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
35197
35291
  res.items = parseDef(def.type._def, _object_spread_props$f(_object_spread$h({}, refs), {
35198
35292
  currentPath: _to_consumable_array$g(refs.currentPath).concat([
35199
35293
  "items"
@@ -35486,9 +35580,9 @@ function _object_spread_props$d(target, source) {
35486
35580
  }
35487
35581
  return target;
35488
35582
  }
35489
- function _object_without_properties$1(source, excluded) {
35583
+ function _object_without_properties$2(source, excluded) {
35490
35584
  if (source == null) return {};
35491
- var target = _object_without_properties_loose$1(source, excluded);
35585
+ var target = _object_without_properties_loose$2(source, excluded);
35492
35586
  var key, i;
35493
35587
  if (Object.getOwnPropertySymbols) {
35494
35588
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
@@ -35501,7 +35595,7 @@ function _object_without_properties$1(source, excluded) {
35501
35595
  }
35502
35596
  return target;
35503
35597
  }
35504
- function _object_without_properties_loose$1(source, excluded) {
35598
+ function _object_without_properties_loose$2(source, excluded) {
35505
35599
  if (source == null) return {};
35506
35600
  var target = {};
35507
35601
  var sourceKeys = Object.keys(source);
@@ -35562,7 +35656,7 @@ function parseIntersectionDef(def, refs) {
35562
35656
  } else {
35563
35657
  var nestedSchema = schema;
35564
35658
  if ("additionalProperties" in schema && schema.additionalProperties === false) {
35565
- schema.additionalProperties; var rest = _object_without_properties$1(schema, [
35659
+ schema.additionalProperties; var rest = _object_without_properties$2(schema, [
35566
35660
  "additionalProperties"
35567
35661
  ]);
35568
35662
  nestedSchema = rest;
@@ -35631,6 +35725,7 @@ function _object_spread$e(target) {
35631
35725
  }
35632
35726
  return target;
35633
35727
  }
35728
+ var emojiRegex;
35634
35729
  /**
35635
35730
  * Generated from the regular expressions found here as of 2024-05-22:
35636
35731
  * https://github.com/colinhacks/zod/blob/master/src/types.ts.
@@ -35647,7 +35742,20 @@ function _object_spread$e(target) {
35647
35742
  */ email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
35648
35743
  /**
35649
35744
  * Constructed a valid Unicode RegExp
35650
- */ emoji: RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u"),
35745
+ *
35746
+ * Lazily instantiate since this type of regex isn't supported
35747
+ * in all envs (e.g. React Native).
35748
+ *
35749
+ * See:
35750
+ * https://github.com/colinhacks/zod/issues/2433
35751
+ * Fix in Zod:
35752
+ * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
35753
+ */ emoji: function() {
35754
+ if (emojiRegex === undefined) {
35755
+ emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
35756
+ }
35757
+ return emojiRegex;
35758
+ },
35651
35759
  /**
35652
35760
  * Unused
35653
35761
  */ uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
@@ -35782,7 +35890,7 @@ function parseStringDef(def, refs) {
35782
35890
  case "trim":
35783
35891
  break;
35784
35892
  default:
35785
- (function(_) {})(check);
35893
+ /* c8 ignore next */ (function(_) {})(check);
35786
35894
  }
35787
35895
  }
35788
35896
  } catch (err) {
@@ -35878,7 +35986,8 @@ var addPattern = function(schema, regex, message, refs) {
35878
35986
  }
35879
35987
  };
35880
35988
  // Mutate z.string.regex() in a best attempt to accommodate for regex flags when applyRegexFlags is true
35881
- var processRegExp = function(regex, refs) {
35989
+ var processRegExp = function(regexOrFunction, refs) {
35990
+ var regex = typeof regexOrFunction === "function" ? regexOrFunction() : regexOrFunction;
35882
35991
  if (!refs.applyRegexFlags || !regex.flags) return regex.source;
35883
35992
  // Currently handled flags
35884
35993
  var flags = {
@@ -35955,9 +36064,6 @@ function _array_like_to_array$f(arr, len) {
35955
36064
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
35956
36065
  return arr2;
35957
36066
  }
35958
- function _array_with_holes$6(arr) {
35959
- if (Array.isArray(arr)) return arr;
35960
- }
35961
36067
  function _array_without_holes$e(arr) {
35962
36068
  if (Array.isArray(arr)) return _array_like_to_array$f(arr);
35963
36069
  }
@@ -35977,33 +36083,6 @@ function _define_property$e(obj, key, value) {
35977
36083
  function _iterable_to_array$e(iter) {
35978
36084
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
35979
36085
  }
35980
- function _iterable_to_array_limit$6(arr, i) {
35981
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
35982
- if (_i == null) return;
35983
- var _arr = [];
35984
- var _n = true;
35985
- var _d = false;
35986
- var _s, _e;
35987
- try {
35988
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
35989
- _arr.push(_s.value);
35990
- if (i && _arr.length === i) break;
35991
- }
35992
- } catch (err) {
35993
- _d = true;
35994
- _e = err;
35995
- } finally{
35996
- try {
35997
- if (!_n && _i["return"] != null) _i["return"]();
35998
- } finally{
35999
- if (_d) throw _e;
36000
- }
36001
- }
36002
- return _arr;
36003
- }
36004
- function _non_iterable_rest$6() {
36005
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
36006
- }
36007
36086
  function _non_iterable_spread$e() {
36008
36087
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
36009
36088
  }
@@ -36046,8 +36125,32 @@ function _object_spread_props$c(target, source) {
36046
36125
  }
36047
36126
  return target;
36048
36127
  }
36049
- function _sliced_to_array$6(arr, i) {
36050
- return _array_with_holes$6(arr) || _iterable_to_array_limit$6(arr, i) || _unsupported_iterable_to_array$f(arr, i) || _non_iterable_rest$6();
36128
+ function _object_without_properties$1(source, excluded) {
36129
+ if (source == null) return {};
36130
+ var target = _object_without_properties_loose$1(source, excluded);
36131
+ var key, i;
36132
+ if (Object.getOwnPropertySymbols) {
36133
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
36134
+ for(i = 0; i < sourceSymbolKeys.length; i++){
36135
+ key = sourceSymbolKeys[i];
36136
+ if (excluded.indexOf(key) >= 0) continue;
36137
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
36138
+ target[key] = source[key];
36139
+ }
36140
+ }
36141
+ return target;
36142
+ }
36143
+ function _object_without_properties_loose$1(source, excluded) {
36144
+ if (source == null) return {};
36145
+ var target = {};
36146
+ var sourceKeys = Object.keys(source);
36147
+ var key, i;
36148
+ for(i = 0; i < sourceKeys.length; i++){
36149
+ key = sourceKeys[i];
36150
+ if (excluded.indexOf(key) >= 0) continue;
36151
+ target[key] = source[key];
36152
+ }
36153
+ return target;
36051
36154
  }
36052
36155
  function _to_consumable_array$e(arr) {
36053
36156
  return _array_without_holes$e(arr) || _iterable_to_array$e(arr) || _unsupported_iterable_to_array$f(arr) || _non_iterable_spread$e();
@@ -36061,7 +36164,7 @@ function _unsupported_iterable_to_array$f(o, minLen) {
36061
36164
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$f(o, minLen);
36062
36165
  }
36063
36166
  function parseRecordDef(def, refs) {
36064
- var _def_keyType, _def_keyType1, _def_keyType__def_checks, _def_keyType2;
36167
+ var _def_keyType, _def_keyType1, _def_keyType__def_checks, _def_keyType2, _def_keyType3, _def_keyType__def_type__def_checks;
36065
36168
  if (refs.target === "openApi3" && ((_def_keyType = def.keyType) === null || _def_keyType === void 0 ? void 0 : _def_keyType._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) {
36066
36169
  return {
36067
36170
  type: "object",
@@ -36091,10 +36194,9 @@ function parseRecordDef(def, refs) {
36091
36194
  return schema;
36092
36195
  }
36093
36196
  if (((_def_keyType1 = def.keyType) === null || _def_keyType1 === void 0 ? void 0 : _def_keyType1._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_def_keyType__def_checks = def.keyType._def.checks) === null || _def_keyType__def_checks === void 0 ? void 0 : _def_keyType__def_checks.length)) {
36094
- var keyType = Object.entries(parseStringDef(def.keyType._def, refs)).reduce(function(acc, param) {
36095
- var _param = _sliced_to_array$6(param, 2), key = _param[0], value = _param[1];
36096
- return key === "type" ? acc : _object_spread_props$c(_object_spread$d({}, acc), _define_property$e({}, key, value));
36097
- }, {});
36197
+ var _parseStringDef = parseStringDef(def.keyType._def, refs); _parseStringDef.type; var keyType = _object_without_properties$1(_parseStringDef, [
36198
+ "type"
36199
+ ]);
36098
36200
  return _object_spread_props$c(_object_spread$d({}, schema), {
36099
36201
  propertyNames: keyType
36100
36202
  });
@@ -36104,6 +36206,13 @@ function parseRecordDef(def, refs) {
36104
36206
  enum: def.keyType._def.values
36105
36207
  }
36106
36208
  });
36209
+ } else if (((_def_keyType3 = def.keyType) === null || _def_keyType3 === void 0 ? void 0 : _def_keyType3._def.typeName) === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && ((_def_keyType__def_type__def_checks = def.keyType._def.type._def.checks) === null || _def_keyType__def_type__def_checks === void 0 ? void 0 : _def_keyType__def_type__def_checks.length)) {
36210
+ var _parseBrandedDef = parseBrandedDef(def.keyType._def, refs); _parseBrandedDef.type; var keyType1 = _object_without_properties$1(_parseBrandedDef, [
36211
+ "type"
36212
+ ]);
36213
+ return _object_spread_props$c(_object_spread$d({}, schema), {
36214
+ propertyNames: keyType1
36215
+ });
36107
36216
  }
36108
36217
  return schema;
36109
36218
  }
@@ -37391,7 +37500,7 @@ var selectParser = function(def, typeName, refs) {
37391
37500
  case ZodFirstPartyTypeKind.ZodSymbol:
37392
37501
  return undefined;
37393
37502
  default:
37394
- return function(_) {
37503
+ /* c8 ignore next */ return function(_) {
37395
37504
  return undefined;
37396
37505
  }();
37397
37506
  }
@@ -41673,6 +41782,43 @@ function _coerceToDict(value, defaultKey) {
41673
41782
  }(Serializable);
41674
41783
  /**
41675
41784
  * A runnable that delegates calls to another runnable with a set of kwargs.
41785
+ * @example
41786
+ * ```typescript
41787
+ * import {
41788
+ * type RunnableConfig,
41789
+ * RunnableLambda,
41790
+ * } from "@langchain/core/runnables";
41791
+ *
41792
+ * const enhanceProfile = (
41793
+ * profile: Record<string, any>,
41794
+ * config?: RunnableConfig
41795
+ * ) => {
41796
+ * if (config?.configurable?.role) {
41797
+ * return { ...profile, role: config.configurable.role };
41798
+ * }
41799
+ * return profile;
41800
+ * };
41801
+ *
41802
+ * const runnable = RunnableLambda.from(enhanceProfile);
41803
+ *
41804
+ * // Bind configuration to the runnable to set the user's role dynamically
41805
+ * const adminRunnable = runnable.bind({ configurable: { role: "Admin" } });
41806
+ * const userRunnable = runnable.bind({ configurable: { role: "User" } });
41807
+ *
41808
+ * const result1 = await adminRunnable.invoke({
41809
+ * name: "Alice",
41810
+ * email: "alice@example.com"
41811
+ * });
41812
+ *
41813
+ * // { name: "Alice", email: "alice@example.com", role: "Admin" }
41814
+ *
41815
+ * const result2 = await userRunnable.invoke({
41816
+ * name: "Bob",
41817
+ * email: "bob@example.com"
41818
+ * });
41819
+ *
41820
+ * // { name: "Bob", email: "bob@example.com", role: "User" }
41821
+ * ```
41676
41822
  */ var RunnableBinding = /*#__PURE__*/ function(Runnable1) {
41677
41823
  _inherits$2(RunnableBinding, Runnable1);
41678
41824
  var _super = _create_super$2(RunnableBinding);
@@ -42142,6 +42288,24 @@ function _coerceToDict(value, defaultKey) {
42142
42288
  /**
42143
42289
  * A runnable that delegates calls to another runnable
42144
42290
  * with each element of the input sequence.
42291
+ * @example
42292
+ * ```typescript
42293
+ * import { RunnableEach, RunnableLambda } from "@langchain/core/runnables";
42294
+ *
42295
+ * const toUpperCase = (input: string): string => input.toUpperCase();
42296
+ * const addGreeting = (input: string): string => `Hello, ${input}!`;
42297
+ *
42298
+ * const upperCaseLambda = RunnableLambda.from(toUpperCase);
42299
+ * const greetingLambda = RunnableLambda.from(addGreeting);
42300
+ *
42301
+ * const chain = new RunnableEach({
42302
+ * bound: upperCaseLambda.pipe(greetingLambda),
42303
+ * });
42304
+ *
42305
+ * const result = await chain.invoke(["alice", "bob", "carol"])
42306
+ *
42307
+ * // ["Hello, ALICE!", "Hello, BOB!", "Hello, CAROL!"]
42308
+ * ```
42145
42309
  */ var RunnableEach = /*#__PURE__*/ function(Runnable) {
42146
42310
  _inherits$2(RunnableEach, Runnable);
42147
42311
  var _super = _create_super$2(RunnableEach);
@@ -42262,6 +42426,45 @@ function _coerceToDict(value, defaultKey) {
42262
42426
  /**
42263
42427
  * Base class for runnables that can be retried a
42264
42428
  * specified number of times.
42429
+ * @example
42430
+ * ```typescript
42431
+ * import {
42432
+ * RunnableLambda,
42433
+ * RunnableRetry,
42434
+ * } from "@langchain/core/runnables";
42435
+ *
42436
+ * // Simulate an API call that fails
42437
+ * const simulateApiCall = (input: string): string => {
42438
+ * console.log(`Attempting API call with input: ${input}`);
42439
+ * throw new Error("API call failed due to network issue");
42440
+ * };
42441
+ *
42442
+ * const apiCallLambda = RunnableLambda.from(simulateApiCall);
42443
+ *
42444
+ * // Apply retry logic using the .withRetry() method
42445
+ * const apiCallWithRetry = apiCallLambda.withRetry({ stopAfterAttempt: 3 });
42446
+ *
42447
+ * // Alternatively, create a RunnableRetry instance manually
42448
+ * const manualRetry = new RunnableRetry({
42449
+ * bound: apiCallLambda,
42450
+ * maxAttemptNumber: 3,
42451
+ * config: {},
42452
+ * });
42453
+ *
42454
+ * // Example invocation using the .withRetry() method
42455
+ * const res = await apiCallWithRetry
42456
+ * .invoke("Request 1")
42457
+ * .catch((error) => {
42458
+ * console.error("Failed after multiple retries:", error.message);
42459
+ * });
42460
+ *
42461
+ * // Example invocation using the manual retry instance
42462
+ * const res2 = await manualRetry
42463
+ * .invoke("Request 2")
42464
+ * .catch((error) => {
42465
+ * console.error("Failed after multiple retries:", error.message);
42466
+ * });
42467
+ * ```
42265
42468
  */ var RunnableRetry = /*#__PURE__*/ function(RunnableBinding) {
42266
42469
  _inherits$2(RunnableRetry, RunnableBinding);
42267
42470
  var _super = _create_super$2(RunnableRetry);
@@ -43675,7 +43878,30 @@ function assertNonTraceableFunction(func) {
43675
43878
  }
43676
43879
  }
43677
43880
  /**
43678
- * A runnable that runs a callable.
43881
+ * A runnable that wraps an arbitrary function that takes a single argument.
43882
+ * @example
43883
+ * ```typescript
43884
+ * import { RunnableLambda } from "@langchain/core/runnables";
43885
+ *
43886
+ * const add = (input: { x: number; y: number }) => input.x + input.y;
43887
+ *
43888
+ * const multiply = (input: { value: number; multiplier: number }) =>
43889
+ * input.value * input.multiplier;
43890
+ *
43891
+ * // Create runnables for the functions
43892
+ * const addLambda = RunnableLambda.from(add);
43893
+ * const multiplyLambda = RunnableLambda.from(multiply);
43894
+ *
43895
+ * // Chain the lambdas for a mathematical operation
43896
+ * const chainedLambda = addLambda.pipe((result) =>
43897
+ * multiplyLambda.invoke({ value: result, multiplier: 2 })
43898
+ * );
43899
+ *
43900
+ * // Example invocation of the chainedLambda
43901
+ * const result = await chainedLambda.invoke({ x: 2, y: 3 });
43902
+ *
43903
+ * // Will log "10" (since (2 + 3) * 2 = 10)
43904
+ * ```
43679
43905
  */ var RunnableLambda = /*#__PURE__*/ function(Runnable1) {
43680
43906
  _inherits$2(RunnableLambda, Runnable1);
43681
43907
  var _super = _create_super$2(RunnableLambda);
@@ -44453,6 +44679,55 @@ function assertNonTraceableFunction(func) {
44453
44679
  * When streaming, fallbacks will only be called on failures during the initial
44454
44680
  * stream creation. Errors that occur after a stream starts will not fallback
44455
44681
  * to the next Runnable.
44682
+ *
44683
+ * @example
44684
+ * ```typescript
44685
+ * import {
44686
+ * RunnableLambda,
44687
+ * RunnableWithFallbacks,
44688
+ * } from "@langchain/core/runnables";
44689
+ *
44690
+ * const primaryOperation = (input: string): string => {
44691
+ * if (input !== "safe") {
44692
+ * throw new Error("Primary operation failed due to unsafe input");
44693
+ * }
44694
+ * return `Processed: ${input}`;
44695
+ * };
44696
+ *
44697
+ * // Define a fallback operation that processes the input differently
44698
+ * const fallbackOperation = (input: string): string =>
44699
+ * `Fallback processed: ${input}`;
44700
+ *
44701
+ * const primaryRunnable = RunnableLambda.from(primaryOperation);
44702
+ * const fallbackRunnable = RunnableLambda.from(fallbackOperation);
44703
+ *
44704
+ * // Apply the fallback logic using the .withFallbacks() method
44705
+ * const runnableWithFallback = primaryRunnable.withFallbacks([fallbackRunnable]);
44706
+ *
44707
+ * // Alternatively, create a RunnableWithFallbacks instance manually
44708
+ * const manualFallbackChain = new RunnableWithFallbacks({
44709
+ * runnable: primaryRunnable,
44710
+ * fallbacks: [fallbackRunnable],
44711
+ * });
44712
+ *
44713
+ * // Example invocation using .withFallbacks()
44714
+ * const res = await runnableWithFallback
44715
+ * .invoke("unsafe input")
44716
+ * .catch((error) => {
44717
+ * console.error("Failed after all attempts:", error.message);
44718
+ * });
44719
+ *
44720
+ * // "Fallback processed: unsafe input"
44721
+ *
44722
+ * // Example invocation using manual instantiation
44723
+ * const res = await manualFallbackChain
44724
+ * .invoke("safe")
44725
+ * .catch((error) => {
44726
+ * console.error("Failed after all attempts:", error.message);
44727
+ * });
44728
+ *
44729
+ * // "Processed: safe"
44730
+ * ```
44456
44731
  */ var RunnableWithFallbacks = /*#__PURE__*/ function(Runnable) {
44457
44732
  _inherits$2(RunnableWithFallbacks, Runnable);
44458
44733
  var _super = _create_super$2(RunnableWithFallbacks);
@@ -45168,6 +45443,34 @@ function _coerceToRunnable(coerceable) {
45168
45443
  }
45169
45444
  /**
45170
45445
  * A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.
45446
+ * @example
45447
+ * ```typescript
45448
+ * import {
45449
+ * RunnableAssign,
45450
+ * RunnableLambda,
45451
+ * RunnableParallel,
45452
+ * } from "@langchain/core/runnables";
45453
+ *
45454
+ * const calculateAge = (x: { birthYear: number }): { age: number } => {
45455
+ * const currentYear = new Date().getFullYear();
45456
+ * return { age: currentYear - x.birthYear };
45457
+ * };
45458
+ *
45459
+ * const createGreeting = (x: { name: string }): { greeting: string } => {
45460
+ * return { greeting: `Hello, ${x.name}!` };
45461
+ * };
45462
+ *
45463
+ * const mapper = RunnableParallel.from({
45464
+ * age_step: RunnableLambda.from(calculateAge),
45465
+ * greeting_step: RunnableLambda.from(createGreeting),
45466
+ * });
45467
+ *
45468
+ * const runnableAssign = new RunnableAssign({ mapper });
45469
+ *
45470
+ * const res = await runnableAssign.invoke({ name: "Alice", birthYear: 1990 });
45471
+ *
45472
+ * // { name: "Alice", birthYear: 1990, age_step: { age: 34 }, greeting_step: { greeting: "Hello, Alice!" } }
45473
+ * ```
45171
45474
  */ var RunnableAssign = /*#__PURE__*/ function(Runnable) {
45172
45475
  _inherits$2(RunnableAssign, Runnable);
45173
45476
  var _super = _create_super$2(RunnableAssign);
@@ -45518,6 +45821,27 @@ function _coerceToRunnable(coerceable) {
45518
45821
  }(Runnable);
45519
45822
  /**
45520
45823
  * A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.
45824
+ * Useful for streaming, can be automatically created and chained by calling `runnable.pick();`.
45825
+ * @example
45826
+ * ```typescript
45827
+ * import { RunnablePick } from "@langchain/core/runnables";
45828
+ *
45829
+ * const inputData = {
45830
+ * name: "John",
45831
+ * age: 30,
45832
+ * city: "New York",
45833
+ * country: "USA",
45834
+ * email: "john.doe@example.com",
45835
+ * phone: "+1234567890",
45836
+ * };
45837
+ *
45838
+ * const basicInfoRunnable = new RunnablePick(["name", "city"]);
45839
+ *
45840
+ * // Example invocation
45841
+ * const res = await basicInfoRunnable.invoke(inputData);
45842
+ *
45843
+ * // { name: 'John', city: 'New York' }
45844
+ * ```
45521
45845
  */ var RunnablePick = /*#__PURE__*/ function(Runnable) {
45522
45846
  _inherits$2(RunnablePick, Runnable);
45523
45847
  var _super = _create_super$2(RunnablePick);