@langchain/core 0.3.59-rc.2 → 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 (100) 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 +31 -7
  16. package/dist/language_models/base.d.ts +5 -0
  17. package/dist/language_models/base.js +29 -5
  18. package/dist/language_models/chat_models.cjs +2 -2
  19. package/dist/load/import_map.cjs +17 -7
  20. package/dist/load/index.cjs +18 -9
  21. package/dist/load/map_keys.cjs +3 -4
  22. package/dist/load/serializable.cjs +2 -2
  23. package/dist/memory.cjs +2 -2
  24. package/dist/messages/ai.cjs +3 -3
  25. package/dist/messages/base.cjs +10 -10
  26. package/dist/messages/chat.cjs +3 -3
  27. package/dist/messages/content_blocks.cjs +9 -10
  28. package/dist/messages/function.cjs +3 -3
  29. package/dist/messages/human.cjs +3 -3
  30. package/dist/messages/system.cjs +3 -3
  31. package/dist/messages/tool.cjs +5 -5
  32. package/dist/messages/transformers.cjs +4 -5
  33. package/dist/messages/utils.cjs +6 -7
  34. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +4 -4
  35. package/dist/output_parsers/xml.cjs +2 -2
  36. package/dist/prompts/base.cjs +36 -3
  37. package/dist/runnables/base.cjs +7 -5
  38. package/dist/runnables/base.d.ts +1 -1
  39. package/dist/runnables/base.js +3 -1
  40. package/dist/runnables/config.cjs +6 -6
  41. package/dist/runnables/graph_mermaid.cjs +2 -3
  42. package/dist/runnables/iter.cjs +5 -5
  43. package/dist/runnables/iter.d.ts +1 -1
  44. package/dist/runnables/utils.cjs +2 -2
  45. package/dist/runnables/wrappers.cjs +1 -2
  46. package/dist/runnables/wrappers.d.ts +1 -1
  47. package/dist/singletons/async_local_storage/context.cjs +3 -3
  48. package/dist/singletons/callbacks.cjs +3 -4
  49. package/dist/singletons/callbacks.d.ts +1 -1
  50. package/dist/structured_query/utils.cjs +7 -8
  51. package/dist/tools/index.cjs +2 -2
  52. package/dist/tools/types.cjs +4 -5
  53. package/dist/tools/utils.cjs +3 -3
  54. package/dist/tracers/base.cjs +2 -2
  55. package/dist/tracers/base.d.ts +84 -84
  56. package/dist/tracers/initialize.cjs +2 -3
  57. package/dist/utils/async_caller.cjs +9 -9
  58. package/dist/utils/async_caller.js +9 -9
  59. package/dist/utils/env.cjs +4 -4
  60. package/dist/utils/event_source_parse.cjs +5 -5
  61. package/dist/utils/fast-json-patch/index.cjs +17 -7
  62. package/dist/utils/fast-json-patch/index.d.ts +4 -4
  63. package/dist/utils/fast-json-patch/src/core.cjs +8 -8
  64. package/dist/utils/fast-json-patch/src/duplex.cjs +4 -5
  65. package/dist/utils/fast-json-patch/src/helpers.cjs +10 -10
  66. package/dist/utils/fast-json-patch/src/helpers.d.ts +3 -3
  67. package/dist/utils/function_calling.cjs +3 -3
  68. package/dist/utils/hash.cjs +3 -1
  69. package/dist/utils/hash.d.ts +7 -0
  70. package/dist/utils/hash.js +1 -0
  71. package/dist/utils/js-sha1/hash.cjs +17 -0
  72. package/dist/utils/js-sha1/hash.d.ts +4 -0
  73. package/dist/utils/js-sha1/hash.js +17 -0
  74. package/dist/utils/js-sha256/hash.cjs +448 -0
  75. package/dist/utils/js-sha256/hash.d.ts +1 -0
  76. package/dist/utils/js-sha256/hash.js +445 -0
  77. package/dist/utils/json.cjs +2 -3
  78. package/dist/utils/json_schema.cjs +11 -4
  79. package/dist/utils/json_schema.js +9 -2
  80. package/dist/utils/math.cjs +6 -7
  81. package/dist/utils/ml-distance/distances.cjs +1 -2
  82. package/dist/utils/ml-distance/similarities.cjs +1 -2
  83. package/dist/utils/ml-distance-euclidean/euclidean.cjs +2 -3
  84. package/dist/utils/sax-js/sax.cjs +35 -35
  85. package/dist/utils/sax-js/sax.js +35 -35
  86. package/dist/utils/signal.cjs +1 -2
  87. package/dist/utils/stream.cjs +4 -4
  88. package/dist/utils/tiktoken.cjs +2 -3
  89. package/dist/utils/types/zod.cjs +223 -56
  90. package/dist/utils/types/zod.d.ts +38 -1
  91. package/dist/utils/types/zod.js +202 -39
  92. package/package.json +30 -4
  93. package/utils/hash/insecure.cjs +1 -0
  94. package/utils/hash/insecure.d.cts +1 -0
  95. package/utils/hash/insecure.d.ts +1 -0
  96. package/utils/hash/insecure.js +1 -0
  97. package/utils/hash/sha256.cjs +1 -0
  98. package/utils/hash/sha256.d.cts +1 -0
  99. package/utils/hash/sha256.d.ts +1 -0
  100. package/utils/hash/sha256.js +1 -0
@@ -1,6 +1,39 @@
1
1
  "use strict";
2
2
  // Default generic "any" values are for backwards compatibility.
3
3
  // Replace with "string" when we are comfortable with a breaking change.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
4
37
  Object.defineProperty(exports, "__esModule", { value: true });
5
38
  exports.BasePromptTemplate = void 0;
6
39
  const base_js_1 = require("../runnables/base.cjs");
@@ -123,15 +156,15 @@ class BasePromptTemplate extends base_js_1.Runnable {
123
156
  static async deserialize(data) {
124
157
  switch (data._type) {
125
158
  case "prompt": {
126
- const { PromptTemplate } = await import("./prompt.js");
159
+ const { PromptTemplate } = await Promise.resolve().then(() => __importStar(require("./prompt.cjs")));
127
160
  return PromptTemplate.deserialize(data);
128
161
  }
129
162
  case undefined: {
130
- const { PromptTemplate } = await import("./prompt.js");
163
+ const { PromptTemplate } = await Promise.resolve().then(() => __importStar(require("./prompt.cjs")));
131
164
  return PromptTemplate.deserialize({ ...data, _type: "prompt" });
132
165
  }
133
166
  case "few_shot": {
134
- const { FewShotPromptTemplate } = await import("./few_shot.js");
167
+ const { FewShotPromptTemplate } = await Promise.resolve().then(() => __importStar(require("./few_shot.cjs")));
135
168
  return FewShotPromptTemplate.deserialize(data);
136
169
  }
137
170
  default:
@@ -3,7 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.convertRunnableToTool = exports.RunnableToolLike = exports.RunnablePick = exports.RunnableAssign = exports._coerceToRunnable = exports.RunnableWithFallbacks = exports.RunnableParallel = exports.RunnableLambda = exports.RunnableTraceable = exports.RunnableMap = exports.RunnableSequence = exports.RunnableRetry = exports.RunnableEach = exports.RunnableBinding = exports.Runnable = exports._coerceToDict = void 0;
6
+ exports.RunnableToolLike = exports.RunnablePick = exports.RunnableAssign = exports.RunnableWithFallbacks = exports.RunnableParallel = exports.RunnableLambda = exports.RunnableTraceable = exports.RunnableMap = exports.RunnableSequence = exports.RunnableRetry = exports.RunnableEach = exports.RunnableBinding = exports.Runnable = void 0;
7
+ exports._coerceToDict = _coerceToDict;
8
+ exports._coerceToRunnable = _coerceToRunnable;
9
+ exports.convertRunnableToTool = convertRunnableToTool;
7
10
  const v3_1 = require("zod/v3");
8
11
  const p_retry_1 = __importDefault(require("p-retry"));
9
12
  const uuid_1 = require("uuid");
@@ -33,7 +36,6 @@ function _coerceToDict(value, defaultKey) {
33
36
  ? value
34
37
  : { [defaultKey]: value };
35
38
  }
36
- exports._coerceToDict = _coerceToDict;
37
39
  /**
38
40
  * A Runnable is a generic unit of work that can be invoked, batched, streamed, and/or
39
41
  * transformed.
@@ -2123,7 +2125,6 @@ function _coerceToRunnable(coerceable) {
2123
2125
  throw new Error(`Expected a Runnable, function or object.\nInstead got an unsupported type.`);
2124
2126
  }
2125
2127
  }
2126
- exports._coerceToRunnable = _coerceToRunnable;
2127
2128
  /**
2128
2129
  * A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.
2129
2130
  * @example
@@ -2297,7 +2298,9 @@ class RunnablePick extends Runnable {
2297
2298
  const picked = this.keys
2298
2299
  .map((key) => [key, input[key]])
2299
2300
  .filter((v) => v[1] !== undefined);
2300
- return picked.length === 0 ? undefined : Object.fromEntries(picked);
2301
+ return picked.length === 0
2302
+ ? undefined
2303
+ : Object.fromEntries(picked);
2301
2304
  }
2302
2305
  }
2303
2306
  async invoke(input, options) {
@@ -2412,4 +2415,3 @@ function convertRunnableToTool(runnable, fields) {
2412
2415
  bound: runnable,
2413
2416
  });
2414
2417
  }
2415
- exports.convertRunnableToTool = convertRunnableToTool;
@@ -395,7 +395,7 @@ export declare class RunnableBinding<RunInput, RunOutput, CallOptions extends Ru
395
395
  returnExceptions: true;
396
396
  }): Promise<(RunOutput | Error)[]>;
397
397
  batch(inputs: RunInput[], options?: Partial<CallOptions> | Partial<CallOptions>[], batchOptions?: RunnableBatchOptions): Promise<(RunOutput | Error)[]>;
398
- _streamIterator(input: RunInput, options?: Partial<CallOptions> | undefined): AsyncGenerator<Awaited<RunOutput>, void, unknown>;
398
+ _streamIterator(input: RunInput, options?: Partial<CallOptions> | undefined): AsyncGenerator<Awaited<RunOutput>, void, any>;
399
399
  stream(input: RunInput, options?: Partial<CallOptions> | undefined): Promise<IterableReadableStream<RunOutput>>;
400
400
  transform(generator: AsyncGenerator<RunInput>, options?: Partial<CallOptions>): AsyncGenerator<RunOutput>;
401
401
  streamEvents(input: RunInput, options: Partial<CallOptions> & {
@@ -2278,7 +2278,9 @@ export class RunnablePick extends Runnable {
2278
2278
  const picked = this.keys
2279
2279
  .map((key) => [key, input[key]])
2280
2280
  .filter((v) => v[1] !== undefined);
2281
- return picked.length === 0 ? undefined : Object.fromEntries(picked);
2281
+ return picked.length === 0
2282
+ ? undefined
2283
+ : Object.fromEntries(picked);
2282
2284
  }
2283
2285
  }
2284
2286
  async invoke(input, options) {
@@ -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);