@langchain/core 0.3.59 → 0.3.61

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 (98) hide show
  1. package/dist/caches/base.cjs +28 -5
  2. package/dist/caches/base.d.ts +13 -1
  3. package/dist/caches/base.js +25 -2
  4. package/dist/callbacks/base.cjs +19 -9
  5. package/dist/callbacks/base.d.ts +37 -22
  6. package/dist/callbacks/dispatch/index.cjs +1 -2
  7. package/dist/callbacks/dispatch/web.cjs +1 -2
  8. package/dist/callbacks/manager.cjs +4 -4
  9. package/dist/callbacks/manager.d.ts +2 -2
  10. package/dist/errors/index.cjs +1 -2
  11. package/dist/example_selectors/conditional.cjs +3 -3
  12. package/dist/indexing/base.cjs +19 -7
  13. package/dist/indexing/base.d.ts +3 -0
  14. package/dist/indexing/base.js +14 -2
  15. package/dist/language_models/base.cjs +2 -2
  16. package/dist/language_models/chat_models.cjs +2 -2
  17. package/dist/load/import_map.cjs +17 -7
  18. package/dist/load/index.cjs +18 -9
  19. package/dist/load/map_keys.cjs +3 -4
  20. package/dist/load/serializable.cjs +2 -2
  21. package/dist/memory.cjs +2 -2
  22. package/dist/messages/ai.cjs +3 -3
  23. package/dist/messages/base.cjs +10 -10
  24. package/dist/messages/chat.cjs +3 -3
  25. package/dist/messages/content_blocks.cjs +9 -10
  26. package/dist/messages/function.cjs +3 -3
  27. package/dist/messages/human.cjs +3 -3
  28. package/dist/messages/system.cjs +3 -3
  29. package/dist/messages/tool.cjs +5 -5
  30. package/dist/messages/transformers.cjs +4 -5
  31. package/dist/messages/utils.cjs +6 -7
  32. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +4 -4
  33. package/dist/output_parsers/xml.cjs +2 -2
  34. package/dist/prompts/base.cjs +36 -3
  35. package/dist/runnables/base.cjs +7 -5
  36. package/dist/runnables/base.d.ts +1 -1
  37. package/dist/runnables/base.js +3 -1
  38. package/dist/runnables/config.cjs +6 -6
  39. package/dist/runnables/graph_mermaid.cjs +2 -3
  40. package/dist/runnables/iter.cjs +5 -5
  41. package/dist/runnables/iter.d.ts +1 -1
  42. package/dist/runnables/utils.cjs +2 -2
  43. package/dist/runnables/wrappers.cjs +1 -2
  44. package/dist/runnables/wrappers.d.ts +1 -1
  45. package/dist/singletons/async_local_storage/context.cjs +3 -3
  46. package/dist/singletons/callbacks.cjs +3 -4
  47. package/dist/singletons/callbacks.d.ts +1 -1
  48. package/dist/structured_query/utils.cjs +7 -8
  49. package/dist/tools/index.cjs +2 -2
  50. package/dist/tools/types.cjs +4 -5
  51. package/dist/tools/utils.cjs +3 -3
  52. package/dist/tracers/base.cjs +2 -2
  53. package/dist/tracers/base.d.ts +84 -84
  54. package/dist/tracers/initialize.cjs +2 -3
  55. package/dist/utils/async_caller.cjs +9 -9
  56. package/dist/utils/async_caller.js +9 -9
  57. package/dist/utils/env.cjs +4 -4
  58. package/dist/utils/event_source_parse.cjs +5 -5
  59. package/dist/utils/fast-json-patch/index.cjs +17 -7
  60. package/dist/utils/fast-json-patch/index.d.ts +4 -4
  61. package/dist/utils/fast-json-patch/src/core.cjs +8 -8
  62. package/dist/utils/fast-json-patch/src/duplex.cjs +4 -5
  63. package/dist/utils/fast-json-patch/src/helpers.cjs +10 -10
  64. package/dist/utils/fast-json-patch/src/helpers.d.ts +3 -3
  65. package/dist/utils/function_calling.cjs +3 -3
  66. package/dist/utils/hash.cjs +3 -1
  67. package/dist/utils/hash.d.ts +7 -0
  68. package/dist/utils/hash.js +1 -0
  69. package/dist/utils/js-sha1/hash.cjs +17 -0
  70. package/dist/utils/js-sha1/hash.d.ts +4 -0
  71. package/dist/utils/js-sha1/hash.js +17 -0
  72. package/dist/utils/js-sha256/hash.cjs +448 -0
  73. package/dist/utils/js-sha256/hash.d.ts +1 -0
  74. package/dist/utils/js-sha256/hash.js +445 -0
  75. package/dist/utils/json.cjs +2 -3
  76. package/dist/utils/json_schema.cjs +11 -4
  77. package/dist/utils/json_schema.js +9 -2
  78. package/dist/utils/math.cjs +6 -7
  79. package/dist/utils/ml-distance/distances.cjs +1 -2
  80. package/dist/utils/ml-distance/similarities.cjs +1 -2
  81. package/dist/utils/ml-distance-euclidean/euclidean.cjs +2 -3
  82. package/dist/utils/sax-js/sax.cjs +35 -35
  83. package/dist/utils/sax-js/sax.js +35 -35
  84. package/dist/utils/signal.cjs +1 -2
  85. package/dist/utils/stream.cjs +4 -4
  86. package/dist/utils/tiktoken.cjs +2 -3
  87. package/dist/utils/types/zod.cjs +251 -56
  88. package/dist/utils/types/zod.d.ts +40 -1
  89. package/dist/utils/types/zod.js +230 -39
  90. package/package.json +30 -4
  91. package/utils/hash/insecure.cjs +1 -0
  92. package/utils/hash/insecure.d.cts +1 -0
  93. package/utils/hash/insecure.d.ts +1 -0
  94. package/utils/hash/insecure.js +1 -0
  95. package/utils/hash/sha256.cjs +1 -0
  96. package/utils/hash/sha256.d.cts +1 -0
  97. package/utils/hash/sha256.d.ts +1 -0
  98. package/utils/hash/sha256.js +1 -0
@@ -7,14 +7,14 @@ exports.AsyncCaller = void 0;
7
7
  const p_retry_1 = __importDefault(require("p-retry"));
8
8
  const p_queue_1 = __importDefault(require("p-queue"));
9
9
  const STATUS_NO_RETRY = [
10
- 400,
11
- 401,
12
- 402,
13
- 403,
14
- 404,
15
- 405,
16
- 406,
17
- 407,
10
+ 400, // Bad Request
11
+ 401, // Unauthorized
12
+ 402, // Payment Required
13
+ 403, // Forbidden
14
+ 404, // Not Found
15
+ 405, // Method Not Allowed
16
+ 406, // Not Acceptable
17
+ 407, // Proxy Authentication Required
18
18
  409, // Conflict
19
19
  ];
20
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -84,7 +84,7 @@ class AsyncCaller {
84
84
  this.maxRetries = params.maxRetries ?? 6;
85
85
  this.onFailedAttempt =
86
86
  params.onFailedAttempt ?? defaultFailedAttemptHandler;
87
- const PQueue = "default" in p_queue_1.default ? p_queue_1.default.default : p_queue_1.default;
87
+ const PQueue = ("default" in p_queue_1.default ? p_queue_1.default.default : p_queue_1.default);
88
88
  this.queue = new PQueue({ concurrency: this.maxConcurrency });
89
89
  }
90
90
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1,14 +1,14 @@
1
1
  import pRetry from "p-retry";
2
2
  import PQueueMod from "p-queue";
3
3
  const STATUS_NO_RETRY = [
4
- 400,
5
- 401,
6
- 402,
7
- 403,
8
- 404,
9
- 405,
10
- 406,
11
- 407,
4
+ 400, // Bad Request
5
+ 401, // Unauthorized
6
+ 402, // Payment Required
7
+ 403, // Forbidden
8
+ 404, // Not Found
9
+ 405, // Method Not Allowed
10
+ 406, // Not Acceptable
11
+ 407, // Proxy Authentication Required
12
12
  409, // Conflict
13
13
  ];
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -78,7 +78,7 @@ export class AsyncCaller {
78
78
  this.maxRetries = params.maxRetries ?? 6;
79
79
  this.onFailedAttempt =
80
80
  params.onFailedAttempt ?? defaultFailedAttemptHandler;
81
- const PQueue = "default" in PQueueMod ? PQueueMod.default : PQueueMod;
81
+ const PQueue = ("default" in PQueueMod ? PQueueMod.default : PQueueMod);
82
82
  this.queue = new PQueue({ concurrency: this.maxConcurrency });
83
83
  }
84
84
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEnvironmentVariable = exports.getRuntimeEnvironmentSync = exports.getRuntimeEnvironment = exports.getEnv = exports.isNode = exports.isDeno = exports.isJsDom = exports.isWebWorker = exports.isBrowser = void 0;
3
+ exports.getEnv = exports.isNode = exports.isDeno = exports.isJsDom = exports.isWebWorker = exports.isBrowser = void 0;
4
+ exports.getRuntimeEnvironment = getRuntimeEnvironment;
5
+ exports.getRuntimeEnvironmentSync = getRuntimeEnvironmentSync;
6
+ exports.getEnvironmentVariable = getEnvironmentVariable;
4
7
  const isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
5
8
  exports.isBrowser = isBrowser;
6
9
  const isWebWorker = () => typeof globalThis === "object" &&
@@ -50,7 +53,6 @@ let runtimeEnvironment;
50
53
  async function getRuntimeEnvironment() {
51
54
  return getRuntimeEnvironmentSync();
52
55
  }
53
- exports.getRuntimeEnvironment = getRuntimeEnvironment;
54
56
  function getRuntimeEnvironmentSync() {
55
57
  if (runtimeEnvironment === undefined) {
56
58
  const env = (0, exports.getEnv)();
@@ -61,7 +63,6 @@ function getRuntimeEnvironmentSync() {
61
63
  }
62
64
  return runtimeEnvironment;
63
65
  }
64
- exports.getRuntimeEnvironmentSync = getRuntimeEnvironmentSync;
65
66
  function getEnvironmentVariable(name) {
66
67
  // Certain Deno setups will throw an error if you try to access environment variables
67
68
  // https://github.com/langchain-ai/langchainjs/issues/1412
@@ -81,4 +82,3 @@ function getEnvironmentVariable(name) {
81
82
  return undefined;
82
83
  }
83
84
  }
84
- exports.getEnvironmentVariable = getEnvironmentVariable;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertEventStreamToIterableReadableDataStream = exports.getMessages = exports.getLines = exports.getBytes = exports.EventStreamContentType = void 0;
3
+ exports.EventStreamContentType = void 0;
4
+ exports.getBytes = getBytes;
5
+ exports.getLines = getLines;
6
+ exports.getMessages = getMessages;
7
+ exports.convertEventStreamToIterableReadableDataStream = convertEventStreamToIterableReadableDataStream;
4
8
  /* eslint-disable prefer-template */
5
9
  /* eslint-disable default-case */
6
10
  /* eslint-disable no-plusplus */
@@ -55,7 +59,6 @@ stream, onChunk) {
55
59
  }
56
60
  }
57
61
  }
58
- exports.getBytes = getBytes;
59
62
  /**
60
63
  * Parses arbitary byte chunks into EventSource line buffers.
61
64
  * Each line should be of the format "field: value" and ends with \r, \n, or \r\n.
@@ -132,7 +135,6 @@ function getLines(onLine) {
132
135
  }
133
136
  };
134
137
  }
135
- exports.getLines = getLines;
136
138
  /**
137
139
  * Parses line buffers into EventSourceMessages.
138
140
  * @param onId A function that will be called on each `id` field.
@@ -188,7 +190,6 @@ function getMessages(onMessage, onId, onRetry) {
188
190
  }
189
191
  };
190
192
  }
191
- exports.getMessages = getMessages;
192
193
  function concat(a, b) {
193
194
  const res = new Uint8Array(a.length + b.length);
194
195
  res.set(a);
@@ -232,7 +233,6 @@ function convertEventStreamToIterableReadableDataStream(stream, onMetadataEvent)
232
233
  });
233
234
  return stream_js_1.IterableReadableStream.fromReadableStream(dataStream);
234
235
  }
235
- exports.convertEventStreamToIterableReadableDataStream = convertEventStreamToIterableReadableDataStream;
236
236
  function isEmpty(message) {
237
237
  return (message.data === "" &&
238
238
  message.event === "" &&
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
20
  };
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.unescapePathComponent = exports.escapePathComponent = exports.deepClone = exports.JsonPatchError = void 0;
30
40
  __exportStar(require("./src/core.cjs"), exports);
@@ -13,10 +13,10 @@ declare const _default: {
13
13
  unescapePathComponent: typeof unescapePathComponent;
14
14
  getValueByPointer(document: any, pointer: string): any;
15
15
  applyOperation<T>(document: T, operation: core.Operation, validateOperation?: boolean | core.Validator<T>, mutateDocument?: boolean, banPrototypeModifications?: boolean, index?: number): core.OperationResult<T>;
16
- applyPatch<T_1>(document: T_1, patch: readonly core.Operation[], validateOperation?: boolean | core.Validator<T_1> | undefined, mutateDocument?: boolean, banPrototypeModifications?: boolean): core.PatchResult<T_1>;
17
- applyReducer<T_2>(document: T_2, operation: core.Operation, index: number): T_2;
18
- validator(operation: core.Operation, index: number, document?: any, existingPathFragment?: string | undefined): void;
19
- validate<T_3>(sequence: readonly core.Operation[], document?: T_3 | undefined, externalValidator?: core.Validator<T_3> | undefined): JsonPatchError;
16
+ applyPatch<T>(document: T, patch: ReadonlyArray<core.Operation>, validateOperation?: boolean | core.Validator<T>, mutateDocument?: boolean, banPrototypeModifications?: boolean): core.PatchResult<T>;
17
+ applyReducer<T>(document: T, operation: core.Operation, index: number): T;
18
+ validator(operation: core.Operation, index: number, document?: any, existingPathFragment?: string): void;
19
+ validate<T>(sequence: ReadonlyArray<core.Operation>, document?: T, externalValidator?: core.Validator<T>): JsonPatchError;
20
20
  _areEquals(a: any, b: any): boolean;
21
21
  };
22
22
  export default _default;
@@ -1,7 +1,14 @@
1
1
  "use strict";
2
2
  // @ts-nocheck
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports._areEquals = exports.validate = exports.validator = exports.applyReducer = exports.applyPatch = exports.applyOperation = exports.getValueByPointer = exports.deepClone = exports.JsonPatchError = void 0;
4
+ exports.deepClone = exports.JsonPatchError = void 0;
5
+ exports.getValueByPointer = getValueByPointer;
6
+ exports.applyOperation = applyOperation;
7
+ exports.applyPatch = applyPatch;
8
+ exports.applyReducer = applyReducer;
9
+ exports.validator = validator;
10
+ exports.validate = validate;
11
+ exports._areEquals = _areEquals;
5
12
  const helpers_js_1 = require("./helpers.cjs");
6
13
  exports.JsonPatchError = helpers_js_1.PatchError;
7
14
  exports.deepClone = helpers_js_1._deepClone;
@@ -107,7 +114,6 @@ function getValueByPointer(document, pointer) {
107
114
  applyOperation(document, getOriginalDestination);
108
115
  return getOriginalDestination.value;
109
116
  }
110
- exports.getValueByPointer = getValueByPointer;
111
117
  /**
112
118
  * Apply a single JSON Patch Operation on a JSON document.
113
119
  * Returns the {newDocument, result} of the operation.
@@ -263,7 +269,6 @@ function applyOperation(document, operation, validateOperation = false, mutateDo
263
269
  }
264
270
  }
265
271
  }
266
- exports.applyOperation = applyOperation;
267
272
  /**
268
273
  * Apply a full JSON Patch array on a JSON document.
269
274
  * Returns the {newDocument, result} of the patch.
@@ -296,7 +301,6 @@ function applyPatch(document, patch, validateOperation, mutateDocument = true, b
296
301
  results.newDocument = document;
297
302
  return results;
298
303
  }
299
- exports.applyPatch = applyPatch;
300
304
  /**
301
305
  * Apply a single JSON Patch Operation on a JSON document.
302
306
  * Returns the updated document.
@@ -314,7 +318,6 @@ function applyReducer(document, operation, index) {
314
318
  }
315
319
  return operationResult.newDocument;
316
320
  }
317
- exports.applyReducer = applyReducer;
318
321
  /**
319
322
  * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.
320
323
  * @param {object} operation - operation object (patch)
@@ -382,7 +385,6 @@ function validator(operation, index, document, existingPathFragment) {
382
385
  }
383
386
  }
384
387
  }
385
- exports.validator = validator;
386
388
  /**
387
389
  * Validates a sequence of operations. If `document` parameter is provided, the sequence is additionally validated against the object document.
388
390
  * If error is encountered, returns a JsonPatchError object
@@ -415,7 +417,6 @@ function validate(sequence, document, externalValidator) {
415
417
  }
416
418
  }
417
419
  }
418
- exports.validate = validate;
419
420
  // based on https://github.com/epoberezkin/fast-deep-equal
420
421
  // MIT License
421
422
  // Copyright (c) 2017 Evgeny Poberezkin
@@ -466,4 +467,3 @@ function _areEquals(a, b) {
466
467
  }
467
468
  return a !== a && b !== b;
468
469
  }
469
- exports._areEquals = _areEquals;
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  // @ts-nocheck
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.compare = exports.generate = exports.observe = exports.unobserve = void 0;
4
+ exports.unobserve = unobserve;
5
+ exports.observe = observe;
6
+ exports.generate = generate;
7
+ exports.compare = compare;
5
8
  // Inlined because of ESM import issues
6
9
  /*!
7
10
  * https://github.com/Starcounter-Jack/JSON-Patch
@@ -67,7 +70,6 @@ function removeObserverFromMirror(mirror, observer) {
67
70
  function unobserve(root, observer) {
68
71
  observer.unobserve();
69
72
  }
70
- exports.unobserve = unobserve;
71
73
  /**
72
74
  * Observes changes made to an object, which can then be retrieved using generate
73
75
  */
@@ -124,7 +126,6 @@ function observe(obj, callback) {
124
126
  mirror.observers.set(callback, new ObserverInfo(callback, observer));
125
127
  return observer;
126
128
  }
127
- exports.observe = observe;
128
129
  /**
129
130
  * Generate an array of patches from an observer
130
131
  */
@@ -143,7 +144,6 @@ function generate(observer, invertible = false) {
143
144
  }
144
145
  return temp;
145
146
  }
146
- exports.generate = generate;
147
147
  // Dirty check if obj is different from mirror, generate patches and update mirror
148
148
  function _generate(mirror, obj, patches, path, invertible) {
149
149
  if (obj === mirror) {
@@ -234,4 +234,3 @@ function compare(tree1, tree2, invertible = false) {
234
234
  _generate(tree1, tree2, patches, "", invertible);
235
235
  return patches;
236
236
  }
237
- exports.compare = compare;
@@ -1,7 +1,16 @@
1
1
  "use strict";
2
2
  // @ts-nocheck
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.PatchError = exports.hasUndefined = exports.getPath = exports._getPathRecursive = exports.unescapePathComponent = exports.escapePathComponent = exports.isInteger = exports._deepClone = exports._objectKeys = exports.hasOwnProperty = void 0;
4
+ exports.PatchError = void 0;
5
+ exports.hasOwnProperty = hasOwnProperty;
6
+ exports._objectKeys = _objectKeys;
7
+ exports._deepClone = _deepClone;
8
+ exports.isInteger = isInteger;
9
+ exports.escapePathComponent = escapePathComponent;
10
+ exports.unescapePathComponent = unescapePathComponent;
11
+ exports._getPathRecursive = _getPathRecursive;
12
+ exports.getPath = getPath;
13
+ exports.hasUndefined = hasUndefined;
5
14
  // Inlined because of ESM import issues
6
15
  /*!
7
16
  * https://github.com/Starcounter-Jack/JSON-Patch
@@ -12,7 +21,6 @@ const _hasOwnProperty = Object.prototype.hasOwnProperty;
12
21
  function hasOwnProperty(obj, key) {
13
22
  return _hasOwnProperty.call(obj, key);
14
23
  }
15
- exports.hasOwnProperty = hasOwnProperty;
16
24
  function _objectKeys(obj) {
17
25
  if (Array.isArray(obj)) {
18
26
  const keys = new Array(obj.length);
@@ -32,7 +40,6 @@ function _objectKeys(obj) {
32
40
  }
33
41
  return keys;
34
42
  }
35
- exports._objectKeys = _objectKeys;
36
43
  /**
37
44
  * Deeply clone the object.
38
45
  * https://jsperf.com/deep-copy-vs-json-stringify-json-parse/25 (recursiveDeepCopy)
@@ -49,7 +56,6 @@ function _deepClone(obj) {
49
56
  return obj; //no need to clone primitives
50
57
  }
51
58
  }
52
- exports._deepClone = _deepClone;
53
59
  //3x faster than cached /^\d+$/.test(str)
54
60
  function isInteger(str) {
55
61
  let i = 0;
@@ -65,7 +71,6 @@ function isInteger(str) {
65
71
  }
66
72
  return true;
67
73
  }
68
- exports.isInteger = isInteger;
69
74
  /**
70
75
  * Escapes a json pointer path
71
76
  * @param path The raw pointer
@@ -76,7 +81,6 @@ function escapePathComponent(path) {
76
81
  return path;
77
82
  return path.replace(/~/g, "~0").replace(/\//g, "~1");
78
83
  }
79
- exports.escapePathComponent = escapePathComponent;
80
84
  /**
81
85
  * Unescapes a json pointer path
82
86
  * @param path The escaped pointer
@@ -85,7 +89,6 @@ exports.escapePathComponent = escapePathComponent;
85
89
  function unescapePathComponent(path) {
86
90
  return path.replace(/~1/g, "/").replace(/~0/g, "~");
87
91
  }
88
- exports.unescapePathComponent = unescapePathComponent;
89
92
  function _getPathRecursive(root, obj) {
90
93
  let found;
91
94
  for (let key in root) {
@@ -103,7 +106,6 @@ function _getPathRecursive(root, obj) {
103
106
  }
104
107
  return "";
105
108
  }
106
- exports._getPathRecursive = _getPathRecursive;
107
109
  function getPath(root, obj) {
108
110
  if (root === obj) {
109
111
  return "/";
@@ -114,7 +116,6 @@ function getPath(root, obj) {
114
116
  }
115
117
  return `/${path}`;
116
118
  }
117
- exports.getPath = getPath;
118
119
  /**
119
120
  * Recursively checks whether an object has any undefined values inside.
120
121
  */
@@ -142,7 +143,6 @@ function hasUndefined(obj) {
142
143
  }
143
144
  return false;
144
145
  }
145
- exports.hasUndefined = hasUndefined;
146
146
  function patchErrorMessageFormatter(message, args) {
147
147
  const messageParts = [message];
148
148
  for (const key in args) {
@@ -30,7 +30,7 @@ export type JsonPatchErrorName = "SEQUENCE_NOT_AN_ARRAY" | "OPERATION_NOT_AN_OBJ
30
30
  export declare class PatchError extends Error {
31
31
  name: JsonPatchErrorName;
32
32
  index?: number | undefined;
33
- operation?: any;
34
- tree?: any;
35
- constructor(message: string, name: JsonPatchErrorName, index?: number | undefined, operation?: any, tree?: any);
33
+ operation?: any | undefined;
34
+ tree?: any | undefined;
35
+ constructor(message: string, name: JsonPatchErrorName, index?: number | undefined, operation?: any | undefined, tree?: any | undefined);
36
36
  }
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertToOpenAITool = exports.convertToOpenAIFunction = exports.isLangChainTool = exports.isRunnableToolLike = exports.isStructuredToolParams = exports.isStructuredTool = void 0;
3
+ exports.isLangChainTool = exports.isRunnableToolLike = exports.isStructuredToolParams = exports.isStructuredTool = void 0;
4
+ exports.convertToOpenAIFunction = convertToOpenAIFunction;
5
+ exports.convertToOpenAITool = convertToOpenAITool;
4
6
  const types_js_1 = require("../tools/types.cjs");
5
7
  const json_schema_js_1 = require("./json_schema.cjs");
6
8
  // These utility functions were moved to a more appropriate location,
@@ -30,7 +32,6 @@ function convertToOpenAIFunction(tool, fields) {
30
32
  ...(fieldsCopy?.strict !== undefined ? { strict: fieldsCopy.strict } : {}),
31
33
  };
32
34
  }
33
- exports.convertToOpenAIFunction = convertToOpenAIFunction;
34
35
  /**
35
36
  * Formats a `StructuredTool` or `RunnableToolLike` instance into a
36
37
  * format that is compatible with OpenAI tool calling. If `StructuredTool` or
@@ -61,4 +62,3 @@ tool, fields) {
61
62
  }
62
63
  return toolDef;
63
64
  }
64
- exports.convertToOpenAITool = convertToOpenAITool;
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.insecureHash = void 0;
3
+ exports.sha256 = exports.insecureHash = void 0;
4
4
  var hash_js_1 = require("./js-sha1/hash.cjs");
5
5
  Object.defineProperty(exports, "insecureHash", { enumerable: true, get: function () { return hash_js_1.insecureHash; } });
6
+ var hash_js_2 = require("./js-sha256/hash.cjs");
7
+ Object.defineProperty(exports, "sha256", { enumerable: true, get: function () { return hash_js_2.sha256; } });
@@ -1 +1,8 @@
1
1
  export { insecureHash } from "./js-sha1/hash.js";
2
+ export { sha256 } from "./js-sha256/hash.js";
3
+ /**
4
+ * A function type for encoding hash keys.
5
+ * Accepts any number of string arguments (such as prompt and LLM key)
6
+ * and returns a single string to be used as the hash key.
7
+ */
8
+ export type HashKeyEncoder = (...strings: string[]) => string;
@@ -1 +1,2 @@
1
1
  export { insecureHash } from "./js-sha1/hash.js";
2
+ export { sha256 } from "./js-sha256/hash.js";
@@ -352,7 +352,24 @@ Sha1.prototype.arrayBuffer = function () {
352
352
  dataView.setUint32(16, this.h4);
353
353
  return buffer;
354
354
  };
355
+ let hasLoggedWarning = false;
356
+ /**
357
+ * @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.
358
+ * This function will be removed in a future version.
359
+ */
355
360
  const insecureHash = (message) => {
361
+ if (!hasLoggedWarning) {
362
+ console.warn([
363
+ `The default method for hashing keys is insecure and will be replaced in a future version,`,
364
+ `but hasn't been replaced yet as to not break existing caches. It's recommended that you use`,
365
+ `a more secure hashing algorithm to avoid cache poisoning.`,
366
+ ``,
367
+ `See this page for more information:`,
368
+ `|`,
369
+ `└> https://js.langchain.com/docs/troubleshooting/warnings/insecure-cache-algorithm`,
370
+ ].join("\n"));
371
+ hasLoggedWarning = true;
372
+ }
356
373
  return new Sha1(true).update(message)["hex"]();
357
374
  };
358
375
  exports.insecureHash = insecureHash;
@@ -1 +1,5 @@
1
+ /**
2
+ * @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.
3
+ * This function will be removed in a future version.
4
+ */
1
5
  export declare const insecureHash: (message: any) => any;
@@ -350,6 +350,23 @@ Sha1.prototype.arrayBuffer = function () {
350
350
  dataView.setUint32(16, this.h4);
351
351
  return buffer;
352
352
  };
353
+ let hasLoggedWarning = false;
354
+ /**
355
+ * @deprecated Use `makeDefaultKeyEncoder()` to create a custom key encoder.
356
+ * This function will be removed in a future version.
357
+ */
353
358
  export const insecureHash = (message) => {
359
+ if (!hasLoggedWarning) {
360
+ console.warn([
361
+ `The default method for hashing keys is insecure and will be replaced in a future version,`,
362
+ `but hasn't been replaced yet as to not break existing caches. It's recommended that you use`,
363
+ `a more secure hashing algorithm to avoid cache poisoning.`,
364
+ ``,
365
+ `See this page for more information:`,
366
+ `|`,
367
+ `└> https://js.langchain.com/docs/troubleshooting/warnings/insecure-cache-algorithm`,
368
+ ].join("\n"));
369
+ hasLoggedWarning = true;
370
+ }
354
371
  return new Sha1(true).update(message)["hex"]();
355
372
  };