@langchain/core 0.3.59 → 0.3.60

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 +223 -56
  88. package/dist/utils/types/zod.d.ts +38 -1
  89. package/dist/utils/types/zod.js +202 -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
@@ -1,13 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pickRunnableConfigKeys = exports.patchConfig = exports.ensureConfig = exports.mergeConfigs = exports.getCallbackManagerForConfig = exports.DEFAULT_RECURSION_LIMIT = void 0;
3
+ exports.DEFAULT_RECURSION_LIMIT = void 0;
4
+ exports.getCallbackManagerForConfig = getCallbackManagerForConfig;
5
+ exports.mergeConfigs = mergeConfigs;
6
+ exports.ensureConfig = ensureConfig;
7
+ exports.patchConfig = patchConfig;
8
+ exports.pickRunnableConfigKeys = pickRunnableConfigKeys;
4
9
  const manager_js_1 = require("../callbacks/manager.cjs");
5
10
  const index_js_1 = require("../singletons/index.cjs");
6
11
  exports.DEFAULT_RECURSION_LIMIT = 25;
7
12
  async function getCallbackManagerForConfig(config) {
8
13
  return manager_js_1.CallbackManager._configureSync(config?.callbacks, undefined, config?.tags, undefined, config?.metadata);
9
14
  }
10
- exports.getCallbackManagerForConfig = getCallbackManagerForConfig;
11
15
  function mergeConfigs(...configs) {
12
16
  // We do not want to call ensureConfig on the empty state here as this may cause
13
17
  // double loading of callbacks if async local storage is being used.
@@ -105,7 +109,6 @@ function mergeConfigs(...configs) {
105
109
  }
106
110
  return copy;
107
111
  }
108
- exports.mergeConfigs = mergeConfigs;
109
112
  const PRIMITIVES = new Set(["string", "number", "boolean"]);
110
113
  /**
111
114
  * Ensure that a passed config is an object with all required keys present.
@@ -173,7 +176,6 @@ function ensureConfig(config) {
173
176
  }
174
177
  return empty;
175
178
  }
176
- exports.ensureConfig = ensureConfig;
177
179
  /**
178
180
  * Helper function that patches runnable configs with updated properties.
179
181
  */
@@ -204,7 +206,6 @@ function patchConfig(config = {}, { callbacks, maxConcurrency, recursionLimit, r
204
206
  }
205
207
  return newConfig;
206
208
  }
207
- exports.patchConfig = patchConfig;
208
209
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
209
210
  function pickRunnableConfigKeys(config) {
210
211
  return config
@@ -220,4 +221,3 @@ function pickRunnableConfigKeys(config) {
220
221
  }
221
222
  : undefined;
222
223
  }
223
- exports.pickRunnableConfigKeys = pickRunnableConfigKeys;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.drawMermaidPng = exports.drawMermaid = void 0;
3
+ exports.drawMermaid = drawMermaid;
4
+ exports.drawMermaidPng = drawMermaidPng;
4
5
  function _escapeNodeLabel(nodeLabel) {
5
6
  // Escapes the node label for Mermaid syntax.
6
7
  return nodeLabel.replace(/[^a-zA-Z-_0-9]/g, "_");
@@ -122,7 +123,6 @@ function drawMermaid(nodes, edges, config) {
122
123
  }
123
124
  return mermaidGraph;
124
125
  }
125
- exports.drawMermaid = drawMermaid;
126
126
  /**
127
127
  * Renders Mermaid graph using the Mermaid.INK API.
128
128
  */
@@ -149,4 +149,3 @@ async function drawMermaidPng(mermaidSyntax, config) {
149
149
  const content = await res.blob();
150
150
  return content;
151
151
  }
152
- exports.drawMermaidPng = drawMermaidPng;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.consumeAsyncIterableInContext = exports.consumeIteratorInContext = exports.isAsyncIterable = exports.isIterator = exports.isIterableIterator = void 0;
3
+ exports.isIterator = void 0;
4
+ exports.isIterableIterator = isIterableIterator;
5
+ exports.isAsyncIterable = isAsyncIterable;
6
+ exports.consumeIteratorInContext = consumeIteratorInContext;
7
+ exports.consumeAsyncIterableInContext = consumeAsyncIterableInContext;
4
8
  const index_js_1 = require("../singletons/index.cjs");
5
9
  const config_js_1 = require("./config.cjs");
6
10
  function isIterableIterator(thing) {
@@ -10,7 +14,6 @@ function isIterableIterator(thing) {
10
14
  // avoid detecting array/set as iterator
11
15
  typeof thing.next === "function");
12
16
  }
13
- exports.isIterableIterator = isIterableIterator;
14
17
  const isIterator = (x) => x != null &&
15
18
  typeof x === "object" &&
16
19
  "next" in x &&
@@ -22,7 +25,6 @@ function isAsyncIterable(thing) {
22
25
  typeof thing[Symbol.asyncIterator] ===
23
26
  "function");
24
27
  }
25
- exports.isAsyncIterable = isAsyncIterable;
26
28
  function* consumeIteratorInContext(context, iter) {
27
29
  while (true) {
28
30
  const { value, done } = index_js_1.AsyncLocalStorageProviderSingleton.runWithConfig((0, config_js_1.pickRunnableConfigKeys)(context), iter.next.bind(iter), true);
@@ -34,7 +36,6 @@ function* consumeIteratorInContext(context, iter) {
34
36
  }
35
37
  }
36
38
  }
37
- exports.consumeIteratorInContext = consumeIteratorInContext;
38
39
  async function* consumeAsyncIterableInContext(context, iter) {
39
40
  const iterator = iter[Symbol.asyncIterator]();
40
41
  while (true) {
@@ -47,4 +48,3 @@ async function* consumeAsyncIterableInContext(context, iter) {
47
48
  }
48
49
  }
49
50
  }
50
- exports.consumeAsyncIterableInContext = consumeAsyncIterableInContext;
@@ -1,6 +1,6 @@
1
1
  import type { RunnableConfig } from "../runnables/types.js";
2
2
  export declare function isIterableIterator(thing: unknown): thing is IterableIterator<unknown>;
3
- export declare const isIterator: (x: unknown) => x is Iterator<unknown, any, undefined>;
3
+ export declare const isIterator: (x: unknown) => x is Iterator<unknown>;
4
4
  export declare function isAsyncIterable(thing: unknown): thing is AsyncIterable<unknown>;
5
5
  export declare function consumeIteratorInContext<T>(context: Partial<RunnableConfig> | undefined, iter: IterableIterator<T>): IterableIterator<T>;
6
6
  export declare function consumeAsyncIterableInContext<T>(context: Partial<RunnableConfig> | undefined, iter: AsyncIterable<T>): AsyncIterableIterator<T>;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._RootEventFilter = exports.isRunnableInterface = void 0;
3
+ exports._RootEventFilter = void 0;
4
+ exports.isRunnableInterface = isRunnableInterface;
4
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
6
  function isRunnableInterface(thing) {
6
7
  return thing ? thing.lc_runnable : false;
7
8
  }
8
- exports.isRunnableInterface = isRunnableInterface;
9
9
  /**
10
10
  * Utility to filter the root event in the streamEvents implementation.
11
11
  * This is simply binding the arguments to the namespace to make save on
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertToHttpEventStream = void 0;
3
+ exports.convertToHttpEventStream = convertToHttpEventStream;
4
4
  const stream_js_1 = require("../utils/stream.cjs");
5
5
  function convertToHttpEventStream(stream) {
6
6
  const encoder = new TextEncoder();
@@ -15,4 +15,3 @@ function convertToHttpEventStream(stream) {
15
15
  });
16
16
  return stream_js_1.IterableReadableStream.fromReadableStream(finalStream);
17
17
  }
18
- exports.convertToHttpEventStream = convertToHttpEventStream;
@@ -1,2 +1,2 @@
1
1
  import { IterableReadableStream } from "../utils/stream.js";
2
- export declare function convertToHttpEventStream(stream: AsyncGenerator): IterableReadableStream<Uint8Array>;
2
+ export declare function convertToHttpEventStream(stream: AsyncGenerator): IterableReadableStream<Uint8Array<ArrayBufferLike>>;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerConfigureHook = exports._getConfigureHooks = exports.getContextVariable = exports.setContextVariable = void 0;
3
+ exports.registerConfigureHook = exports._getConfigureHooks = void 0;
4
+ exports.setContextVariable = setContextVariable;
5
+ exports.getContextVariable = getContextVariable;
4
6
  const run_trees_1 = require("langsmith/run_trees");
5
7
  const globals_js_1 = require("./globals.cjs");
6
8
  /**
@@ -71,7 +73,6 @@ function setContextVariable(name, value) {
71
73
  newValue[globals_js_1._CONTEXT_VARIABLES_KEY] = contextVars;
72
74
  asyncLocalStorageInstance.enterWith(newValue);
73
75
  }
74
- exports.setContextVariable = setContextVariable;
75
76
  /**
76
77
  * Get the value of a previously set context variable. Context variables
77
78
  * are scoped to any child runnables called by the current runnable,
@@ -131,7 +132,6 @@ function getContextVariable(name) {
131
132
  const runTree = asyncLocalStorageInstance.getStore();
132
133
  return runTree?.[globals_js_1._CONTEXT_VARIABLES_KEY]?.[name];
133
134
  }
134
- exports.getContextVariable = getContextVariable;
135
135
  const LC_CONFIGURE_HOOKS_KEY = Symbol("lc:configure_hooks");
136
136
  const _getConfigureHooks = () => getContextVariable(LC_CONFIGURE_HOOKS_KEY) || [];
137
137
  exports._getConfigureHooks = _getConfigureHooks;
@@ -4,7 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.awaitAllCallbacks = exports.consumeCallback = exports.getQueue = void 0;
7
+ exports.getQueue = getQueue;
8
+ exports.consumeCallback = consumeCallback;
9
+ exports.awaitAllCallbacks = awaitAllCallbacks;
8
10
  const p_queue_1 = __importDefault(require("p-queue"));
9
11
  const globals_js_1 = require("./async_local_storage/globals.cjs");
10
12
  const tracer_js_1 = require("./tracer.cjs");
@@ -27,7 +29,6 @@ function getQueue() {
27
29
  }
28
30
  return queue;
29
31
  }
30
- exports.getQueue = getQueue;
31
32
  /**
32
33
  * Consume a promise, either adding it to the queue or waiting for it to resolve
33
34
  * @param promiseFn Promise to consume
@@ -58,7 +59,6 @@ async function consumeCallback(promiseFn, wait) {
58
59
  });
59
60
  }
60
61
  }
61
- exports.consumeCallback = consumeCallback;
62
62
  /**
63
63
  * Waits for all promises in the queue to resolve. If the queue is
64
64
  * undefined, it immediately resolves a promise.
@@ -70,4 +70,3 @@ async function awaitAllCallbacks() {
70
70
  defaultClient.awaitPendingTraceBatches(),
71
71
  ]);
72
72
  }
73
- exports.awaitAllCallbacks = awaitAllCallbacks;
@@ -1,5 +1,5 @@
1
1
  import PQueueMod from "p-queue";
2
- export declare function getQueue(): PQueueMod.default<any, any>;
2
+ export declare function getQueue(): PQueueMod<any, any>;
3
3
  /**
4
4
  * Consume a promise, either adding it to the queue or waiting for it to resolve
5
5
  * @param promiseFn Promise to consume
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.castValue = exports.isBoolean = exports.isString = exports.isFloat = exports.isInt = exports.isFilterEmpty = exports.isObject = void 0;
3
+ exports.isObject = isObject;
4
+ exports.isFilterEmpty = isFilterEmpty;
5
+ exports.isInt = isInt;
6
+ exports.isFloat = isFloat;
7
+ exports.isString = isString;
8
+ exports.isBoolean = isBoolean;
9
+ exports.castValue = castValue;
4
10
  /**
5
11
  * Checks if the provided argument is an object and not an array.
6
12
  */
@@ -8,7 +14,6 @@ exports.castValue = exports.isBoolean = exports.isString = exports.isFloat = exp
8
14
  function isObject(obj) {
9
15
  return obj && typeof obj === "object" && !Array.isArray(obj);
10
16
  }
11
- exports.isObject = isObject;
12
17
  /**
13
18
  * Checks if a provided filter is empty. The filter can be a function, an
14
19
  * object, a string, or undefined.
@@ -27,7 +32,6 @@ filter) {
27
32
  }
28
33
  return isObject(filter) && Object.keys(filter).length === 0;
29
34
  }
30
- exports.isFilterEmpty = isFilterEmpty;
31
35
  /**
32
36
  * Checks if the provided value is an integer.
33
37
  */
@@ -43,7 +47,6 @@ function isInt(value) {
43
47
  }
44
48
  return false;
45
49
  }
46
- exports.isInt = isInt;
47
50
  /**
48
51
  * Checks if the provided value is a floating-point number.
49
52
  */
@@ -59,7 +62,6 @@ function isFloat(value) {
59
62
  }
60
63
  return false;
61
64
  }
62
- exports.isFloat = isFloat;
63
65
  /**
64
66
  * Checks if the provided value is a string that cannot be parsed into a
65
67
  * number.
@@ -68,14 +70,12 @@ function isString(value) {
68
70
  return (typeof value === "string" &&
69
71
  (Number.isNaN(parseFloat(value)) || parseFloat(value).toString() !== value));
70
72
  }
71
- exports.isString = isString;
72
73
  /**
73
74
  * Checks if the provided value is a boolean.
74
75
  */
75
76
  function isBoolean(value) {
76
77
  return typeof value === "boolean";
77
78
  }
78
- exports.isBoolean = isBoolean;
79
79
  /**
80
80
  * Casts a value that might be string or number to actual string or number.
81
81
  * Since LLM might return back an integer/float as a string, we need to cast
@@ -101,4 +101,3 @@ function castValue(input) {
101
101
  }
102
102
  return value;
103
103
  }
104
- exports.castValue = castValue;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tool = exports.BaseToolkit = exports.DynamicStructuredTool = exports.DynamicTool = exports.Tool = exports.StructuredTool = exports.ToolInputParsingException = exports.isStructuredToolParams = exports.isStructuredTool = exports.isRunnableToolLike = exports.isLangChainTool = void 0;
3
+ exports.BaseToolkit = exports.DynamicStructuredTool = exports.DynamicTool = exports.Tool = exports.StructuredTool = exports.ToolInputParsingException = exports.isStructuredToolParams = exports.isStructuredTool = exports.isRunnableToolLike = exports.isLangChainTool = void 0;
4
+ exports.tool = tool;
4
5
  const v3_1 = require("zod/v3");
5
6
  const json_schema_1 = require("@cfworker/json-schema");
6
7
  const manager_js_1 = require("../callbacks/manager.cjs");
@@ -395,7 +396,6 @@ function tool(func, fields) {
395
396
  },
396
397
  });
397
398
  }
398
- exports.tool = tool;
399
399
  function _formatToolOutput(params) {
400
400
  const { content, artifact, toolCallId } = params;
401
401
  if (toolCallId && !(0, tool_js_1.isDirectToolOutput)(content)) {
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLangChainTool = exports.isStructuredToolParams = exports.isRunnableToolLike = exports.isStructuredTool = void 0;
3
+ exports.isStructuredTool = isStructuredTool;
4
+ exports.isRunnableToolLike = isRunnableToolLike;
5
+ exports.isStructuredToolParams = isStructuredToolParams;
6
+ exports.isLangChainTool = isLangChainTool;
4
7
  const base_js_1 = require("../runnables/base.cjs");
5
8
  const zod_js_1 = require("../utils/types/zod.cjs");
6
9
  /**
@@ -13,7 +16,6 @@ function isStructuredTool(tool) {
13
16
  return (tool !== undefined &&
14
17
  Array.isArray(tool.lc_namespace));
15
18
  }
16
- exports.isStructuredTool = isStructuredTool;
17
19
  /**
18
20
  * Confirm whether the inputted tool is an instance of `RunnableToolLike`.
19
21
  *
@@ -27,7 +29,6 @@ function isRunnableToolLike(tool) {
27
29
  typeof tool.constructor.lc_name === "function" &&
28
30
  tool.constructor.lc_name() === "RunnableToolLike");
29
31
  }
30
- exports.isRunnableToolLike = isRunnableToolLike;
31
32
  /**
32
33
  * Confirm whether or not the tool contains the necessary properties to be considered a `StructuredToolParams`.
33
34
  *
@@ -47,7 +48,6 @@ function isStructuredToolParams(tool) {
47
48
  typeof tool.schema.type === "string" &&
48
49
  ["null", "boolean", "object", "array", "number", "string"].includes(tool.schema.type))));
49
50
  }
50
- exports.isStructuredToolParams = isStructuredToolParams;
51
51
  /**
52
52
  * Whether or not the tool is one of StructuredTool, RunnableTool or StructuredToolParams.
53
53
  * It returns `is StructuredToolParams` since that is the most minimal interface of the three,
@@ -62,4 +62,3 @@ function isLangChainTool(tool) {
62
62
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
63
  isStructuredTool(tool));
64
64
  }
65
- exports.isLangChainTool = isLangChainTool;
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToolInputParsingException = exports._configHasToolCallId = exports._isToolCall = void 0;
3
+ exports.ToolInputParsingException = void 0;
4
+ exports._isToolCall = _isToolCall;
5
+ exports._configHasToolCallId = _configHasToolCallId;
4
6
  function _isToolCall(toolCall) {
5
7
  return !!(toolCall &&
6
8
  typeof toolCall === "object" &&
7
9
  "type" in toolCall &&
8
10
  toolCall.type === "tool_call");
9
11
  }
10
- exports._isToolCall = _isToolCall;
11
12
  function _configHasToolCallId(config) {
12
13
  return !!(config &&
13
14
  typeof config === "object" &&
@@ -17,7 +18,6 @@ function _configHasToolCallId(config) {
17
18
  "id" in config.toolCall &&
18
19
  typeof config.toolCall.id === "string");
19
20
  }
20
- exports._configHasToolCallId = _configHasToolCallId;
21
21
  /**
22
22
  * Custom error class used to handle exceptions related to tool input parsing.
23
23
  * It extends the built-in `Error` class and adds an optional `output`
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseTracer = exports.isBaseTracer = void 0;
3
+ exports.BaseTracer = void 0;
4
+ exports.isBaseTracer = isBaseTracer;
4
5
  const run_trees_1 = require("langsmith/run_trees");
5
6
  const base_js_1 = require("../callbacks/base.cjs");
6
7
  const env_js_1 = require("../utils/env.cjs");
@@ -52,7 +53,6 @@ function convertToDottedOrderFormat(epoch, runId, executionOrder) {
52
53
  function isBaseTracer(x) {
53
54
  return typeof x._addRunToRunMap === "function";
54
55
  }
55
- exports.isBaseTracer = isBaseTracer;
56
56
  class BaseTracer extends base_js_1.BaseCallbackHandler {
57
57
  constructor(_fields) {
58
58
  super(...arguments);
@@ -43,25 +43,25 @@ export declare abstract class BaseTracer extends BaseCallbackHandler {
43
43
  execution_order: number;
44
44
  child_runs: Run[];
45
45
  child_execution_order: number;
46
- events: {
46
+ events: Array<{
47
47
  name: string;
48
48
  time: string;
49
- kwargs?: Record<string, unknown> | undefined;
50
- }[];
51
- trace_id?: string | undefined;
52
- dotted_order?: string | undefined;
49
+ kwargs?: Record<string, unknown>;
50
+ }>;
51
+ trace_id?: string;
52
+ dotted_order?: string;
53
53
  name: string;
54
54
  run_type: string;
55
- end_time?: number | undefined;
56
- extra?: KVMap | undefined;
57
- error?: string | undefined;
58
- serialized?: object | undefined;
55
+ end_time?: number;
56
+ extra?: KVMap;
57
+ error?: string;
58
+ serialized?: object;
59
59
  inputs: KVMap;
60
- outputs?: KVMap | undefined;
61
- reference_example_id?: string | undefined;
62
- parent_run_id?: string | undefined;
63
- tags?: string[] | undefined;
64
- attachments?: import("langsmith/schemas").Attachments | undefined;
60
+ outputs?: KVMap;
61
+ reference_example_id?: string;
62
+ parent_run_id?: string;
63
+ tags?: string[];
64
+ attachments?: import("langsmith/schemas").Attachments;
65
65
  };
66
66
  protected _endTrace(run: Run): Promise<void>;
67
67
  protected _getExecutionOrder(parentRunId: string | undefined): number;
@@ -76,25 +76,25 @@ export declare abstract class BaseTracer extends BaseCallbackHandler {
76
76
  execution_order: number;
77
77
  child_runs: Run[];
78
78
  child_execution_order: number;
79
- events: {
79
+ events: Array<{
80
80
  name: string;
81
81
  time: string;
82
- kwargs?: Record<string, unknown> | undefined;
83
- }[];
84
- trace_id?: string | undefined;
85
- dotted_order?: string | undefined;
82
+ kwargs?: Record<string, unknown>;
83
+ }>;
84
+ trace_id?: string;
85
+ dotted_order?: string;
86
86
  name: string;
87
87
  run_type: string;
88
- end_time?: number | undefined;
89
- extra?: KVMap | undefined;
90
- error?: string | undefined;
91
- serialized?: object | undefined;
88
+ end_time?: number;
89
+ extra?: KVMap;
90
+ error?: string;
91
+ serialized?: object;
92
92
  inputs: KVMap;
93
- outputs?: KVMap | undefined;
94
- reference_example_id?: string | undefined;
95
- parent_run_id?: string | undefined;
96
- tags?: string[] | undefined;
97
- attachments?: import("langsmith/schemas").Attachments | undefined;
93
+ outputs?: KVMap;
94
+ reference_example_id?: string;
95
+ parent_run_id?: string;
96
+ tags?: string[];
97
+ attachments?: import("langsmith/schemas").Attachments;
98
98
  };
99
99
  handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: KVMap, tags?: string[], metadata?: KVMap, name?: string): Promise<Run>;
100
100
  /**
@@ -108,25 +108,25 @@ export declare abstract class BaseTracer extends BaseCallbackHandler {
108
108
  execution_order: number;
109
109
  child_runs: Run[];
110
110
  child_execution_order: number;
111
- events: {
111
+ events: Array<{
112
112
  name: string;
113
113
  time: string;
114
- kwargs?: Record<string, unknown> | undefined;
115
- }[];
116
- trace_id?: string | undefined;
117
- dotted_order?: string | undefined;
114
+ kwargs?: Record<string, unknown>;
115
+ }>;
116
+ trace_id?: string;
117
+ dotted_order?: string;
118
118
  name: string;
119
119
  run_type: string;
120
- end_time?: number | undefined;
121
- extra?: KVMap | undefined;
122
- error?: string | undefined;
123
- serialized?: object | undefined;
120
+ end_time?: number;
121
+ extra?: KVMap;
122
+ error?: string;
123
+ serialized?: object;
124
124
  inputs: KVMap;
125
- outputs?: KVMap | undefined;
126
- reference_example_id?: string | undefined;
127
- parent_run_id?: string | undefined;
128
- tags?: string[] | undefined;
129
- attachments?: import("langsmith/schemas").Attachments | undefined;
125
+ outputs?: KVMap;
126
+ reference_example_id?: string;
127
+ parent_run_id?: string;
128
+ tags?: string[];
129
+ attachments?: import("langsmith/schemas").Attachments;
130
130
  };
131
131
  handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: KVMap, tags?: string[], metadata?: KVMap, name?: string): Promise<Run>;
132
132
  handleLLMEnd(output: LLMResult, runId: string, _parentRunId?: string, _tags?: string[], extraParams?: Record<string, unknown>): Promise<Run>;
@@ -142,25 +142,25 @@ export declare abstract class BaseTracer extends BaseCallbackHandler {
142
142
  execution_order: number;
143
143
  child_runs: Run[];
144
144
  child_execution_order: number;
145
- events: {
145
+ events: Array<{
146
146
  name: string;
147
147
  time: string;
148
- kwargs?: Record<string, unknown> | undefined;
149
- }[];
150
- trace_id?: string | undefined;
151
- dotted_order?: string | undefined;
148
+ kwargs?: Record<string, unknown>;
149
+ }>;
150
+ trace_id?: string;
151
+ dotted_order?: string;
152
152
  name: string;
153
153
  run_type: string;
154
- end_time?: number | undefined;
155
- extra?: KVMap | undefined;
156
- error?: string | undefined;
157
- serialized?: object | undefined;
154
+ end_time?: number;
155
+ extra?: KVMap;
156
+ error?: string;
157
+ serialized?: object;
158
158
  inputs: KVMap;
159
- outputs?: KVMap | undefined;
160
- reference_example_id?: string | undefined;
161
- parent_run_id?: string | undefined;
162
- tags?: string[] | undefined;
163
- attachments?: import("langsmith/schemas").Attachments | undefined;
159
+ outputs?: KVMap;
160
+ reference_example_id?: string;
161
+ parent_run_id?: string;
162
+ tags?: string[];
163
+ attachments?: import("langsmith/schemas").Attachments;
164
164
  };
165
165
  handleChainStart(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: KVMap, runType?: string, name?: string): Promise<Run>;
166
166
  handleChainEnd(outputs: ChainValues, runId: string, _parentRunId?: string, _tags?: string[], kwargs?: {
@@ -180,25 +180,25 @@ export declare abstract class BaseTracer extends BaseCallbackHandler {
180
180
  execution_order: number;
181
181
  child_runs: Run[];
182
182
  child_execution_order: number;
183
- events: {
183
+ events: Array<{
184
184
  name: string;
185
185
  time: string;
186
- kwargs?: Record<string, unknown> | undefined;
187
- }[];
188
- trace_id?: string | undefined;
189
- dotted_order?: string | undefined;
186
+ kwargs?: Record<string, unknown>;
187
+ }>;
188
+ trace_id?: string;
189
+ dotted_order?: string;
190
190
  name: string;
191
191
  run_type: string;
192
- end_time?: number | undefined;
193
- extra?: KVMap | undefined;
194
- error?: string | undefined;
195
- serialized?: object | undefined;
192
+ end_time?: number;
193
+ extra?: KVMap;
194
+ error?: string;
195
+ serialized?: object;
196
196
  inputs: KVMap;
197
- outputs?: KVMap | undefined;
198
- reference_example_id?: string | undefined;
199
- parent_run_id?: string | undefined;
200
- tags?: string[] | undefined;
201
- attachments?: import("langsmith/schemas").Attachments | undefined;
197
+ outputs?: KVMap;
198
+ reference_example_id?: string;
199
+ parent_run_id?: string;
200
+ tags?: string[];
201
+ attachments?: import("langsmith/schemas").Attachments;
202
202
  };
203
203
  handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: KVMap, name?: string): Promise<Run>;
204
204
  handleToolEnd(output: any, runId: string): Promise<Run>;
@@ -216,25 +216,25 @@ export declare abstract class BaseTracer extends BaseCallbackHandler {
216
216
  execution_order: number;
217
217
  child_runs: Run[];
218
218
  child_execution_order: number;
219
- events: {
219
+ events: Array<{
220
220
  name: string;
221
221
  time: string;
222
- kwargs?: Record<string, unknown> | undefined;
223
- }[];
224
- trace_id?: string | undefined;
225
- dotted_order?: string | undefined;
222
+ kwargs?: Record<string, unknown>;
223
+ }>;
224
+ trace_id?: string;
225
+ dotted_order?: string;
226
226
  name: string;
227
227
  run_type: string;
228
- end_time?: number | undefined;
229
- extra?: KVMap | undefined;
230
- error?: string | undefined;
231
- serialized?: object | undefined;
228
+ end_time?: number;
229
+ extra?: KVMap;
230
+ error?: string;
231
+ serialized?: object;
232
232
  inputs: KVMap;
233
- outputs?: KVMap | undefined;
234
- reference_example_id?: string | undefined;
235
- parent_run_id?: string | undefined;
236
- tags?: string[] | undefined;
237
- attachments?: import("langsmith/schemas").Attachments | undefined;
233
+ outputs?: KVMap;
234
+ reference_example_id?: string;
235
+ parent_run_id?: string;
236
+ tags?: string[];
237
+ attachments?: import("langsmith/schemas").Attachments;
238
238
  };
239
239
  handleRetrieverStart(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: KVMap, name?: string): Promise<Run>;
240
240
  handleRetrieverEnd(documents: Document<Record<string, unknown>>[], runId: string): Promise<Run>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTracingV2CallbackHandler = exports.getTracingCallbackHandler = void 0;
3
+ exports.getTracingCallbackHandler = getTracingCallbackHandler;
4
+ exports.getTracingV2CallbackHandler = getTracingV2CallbackHandler;
4
5
  const tracer_langchain_js_1 = require("./tracer_langchain.cjs");
5
6
  const tracer_langchain_v1_js_1 = require("./tracer_langchain_v1.cjs");
6
7
  /**
@@ -22,7 +23,6 @@ async function getTracingCallbackHandler(session) {
22
23
  }
23
24
  return tracer;
24
25
  }
25
- exports.getTracingCallbackHandler = getTracingCallbackHandler;
26
26
  /**
27
27
  * @deprecated Instantiate directly using the LangChainTracer constructor.
28
28
  *
@@ -33,4 +33,3 @@ exports.getTracingCallbackHandler = getTracingCallbackHandler;
33
33
  async function getTracingV2CallbackHandler() {
34
34
  return new tracer_langchain_js_1.LangChainTracer();
35
35
  }
36
- exports.getTracingV2CallbackHandler = getTracingV2CallbackHandler;