@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.
- package/dist/caches/base.cjs +28 -5
- package/dist/caches/base.d.ts +13 -1
- package/dist/caches/base.js +25 -2
- package/dist/callbacks/base.cjs +19 -9
- package/dist/callbacks/base.d.ts +37 -22
- package/dist/callbacks/dispatch/index.cjs +1 -2
- package/dist/callbacks/dispatch/web.cjs +1 -2
- package/dist/callbacks/manager.cjs +4 -4
- package/dist/callbacks/manager.d.ts +2 -2
- package/dist/errors/index.cjs +1 -2
- package/dist/example_selectors/conditional.cjs +3 -3
- package/dist/indexing/base.cjs +19 -7
- package/dist/indexing/base.d.ts +3 -0
- package/dist/indexing/base.js +14 -2
- package/dist/language_models/base.cjs +2 -2
- package/dist/language_models/chat_models.cjs +2 -2
- package/dist/load/import_map.cjs +17 -7
- package/dist/load/index.cjs +18 -9
- package/dist/load/map_keys.cjs +3 -4
- package/dist/load/serializable.cjs +2 -2
- package/dist/memory.cjs +2 -2
- package/dist/messages/ai.cjs +3 -3
- package/dist/messages/base.cjs +10 -10
- package/dist/messages/chat.cjs +3 -3
- package/dist/messages/content_blocks.cjs +9 -10
- package/dist/messages/function.cjs +3 -3
- package/dist/messages/human.cjs +3 -3
- package/dist/messages/system.cjs +3 -3
- package/dist/messages/tool.cjs +5 -5
- package/dist/messages/transformers.cjs +4 -5
- package/dist/messages/utils.cjs +6 -7
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +4 -4
- package/dist/output_parsers/xml.cjs +2 -2
- package/dist/prompts/base.cjs +36 -3
- package/dist/runnables/base.cjs +7 -5
- package/dist/runnables/base.d.ts +1 -1
- package/dist/runnables/base.js +3 -1
- package/dist/runnables/config.cjs +6 -6
- package/dist/runnables/graph_mermaid.cjs +2 -3
- package/dist/runnables/iter.cjs +5 -5
- package/dist/runnables/iter.d.ts +1 -1
- package/dist/runnables/utils.cjs +2 -2
- package/dist/runnables/wrappers.cjs +1 -2
- package/dist/runnables/wrappers.d.ts +1 -1
- package/dist/singletons/async_local_storage/context.cjs +3 -3
- package/dist/singletons/callbacks.cjs +3 -4
- package/dist/singletons/callbacks.d.ts +1 -1
- package/dist/structured_query/utils.cjs +7 -8
- package/dist/tools/index.cjs +2 -2
- package/dist/tools/types.cjs +4 -5
- package/dist/tools/utils.cjs +3 -3
- package/dist/tracers/base.cjs +2 -2
- package/dist/tracers/base.d.ts +84 -84
- package/dist/tracers/initialize.cjs +2 -3
- package/dist/utils/async_caller.cjs +9 -9
- package/dist/utils/async_caller.js +9 -9
- package/dist/utils/env.cjs +4 -4
- package/dist/utils/event_source_parse.cjs +5 -5
- package/dist/utils/fast-json-patch/index.cjs +17 -7
- package/dist/utils/fast-json-patch/index.d.ts +4 -4
- package/dist/utils/fast-json-patch/src/core.cjs +8 -8
- package/dist/utils/fast-json-patch/src/duplex.cjs +4 -5
- package/dist/utils/fast-json-patch/src/helpers.cjs +10 -10
- package/dist/utils/fast-json-patch/src/helpers.d.ts +3 -3
- package/dist/utils/function_calling.cjs +3 -3
- package/dist/utils/hash.cjs +3 -1
- package/dist/utils/hash.d.ts +7 -0
- package/dist/utils/hash.js +1 -0
- package/dist/utils/js-sha1/hash.cjs +17 -0
- package/dist/utils/js-sha1/hash.d.ts +4 -0
- package/dist/utils/js-sha1/hash.js +17 -0
- package/dist/utils/js-sha256/hash.cjs +448 -0
- package/dist/utils/js-sha256/hash.d.ts +1 -0
- package/dist/utils/js-sha256/hash.js +445 -0
- package/dist/utils/json.cjs +2 -3
- package/dist/utils/json_schema.cjs +11 -4
- package/dist/utils/json_schema.js +9 -2
- package/dist/utils/math.cjs +6 -7
- package/dist/utils/ml-distance/distances.cjs +1 -2
- package/dist/utils/ml-distance/similarities.cjs +1 -2
- package/dist/utils/ml-distance-euclidean/euclidean.cjs +2 -3
- package/dist/utils/sax-js/sax.cjs +35 -35
- package/dist/utils/sax-js/sax.js +35 -35
- package/dist/utils/signal.cjs +1 -2
- package/dist/utils/stream.cjs +4 -4
- package/dist/utils/tiktoken.cjs +2 -3
- package/dist/utils/types/zod.cjs +223 -56
- package/dist/utils/types/zod.d.ts +38 -1
- package/dist/utils/types/zod.js +202 -39
- package/package.json +30 -4
- package/utils/hash/insecure.cjs +1 -0
- package/utils/hash/insecure.d.cts +1 -0
- package/utils/hash/insecure.d.ts +1 -0
- package/utils/hash/insecure.js +1 -0
- package/utils/hash/sha256.cjs +1 -0
- package/utils/hash/sha256.d.cts +1 -0
- package/utils/hash/sha256.d.ts +1 -0
- package/utils/hash/sha256.js +1 -0
|
@@ -22,6 +22,9 @@ export type InferInteropZodOutput<T> = T extends z3.ZodType<infer Output, z3.Zod
|
|
|
22
22
|
output: infer Output;
|
|
23
23
|
};
|
|
24
24
|
} ? Output : never;
|
|
25
|
+
export type Mutable<T> = {
|
|
26
|
+
-readonly [P in keyof T]: T[P];
|
|
27
|
+
};
|
|
25
28
|
export declare function isZodSchemaV4(schema: unknown): schema is z4.$ZodType<unknown, unknown>;
|
|
26
29
|
export declare function isZodSchemaV3(schema: unknown): schema is z3.ZodType<unknown, z3.ZodTypeDef, unknown>;
|
|
27
30
|
/** Backward compatible isZodSchema for Zod 3 */
|
|
@@ -122,6 +125,9 @@ export declare function isShapelessZodSchema(schema: unknown): boolean;
|
|
|
122
125
|
* @returns {boolean} True if the schema is a basic ZodString, false otherwise.
|
|
123
126
|
*/
|
|
124
127
|
export declare function isSimpleStringZodSchema(schema: unknown): schema is InteropZodType<string | undefined>;
|
|
128
|
+
export declare function isZodObjectV3(obj: unknown): obj is ZodObjectV3;
|
|
129
|
+
export declare function isZodObjectV4(obj: unknown): obj is z4.$ZodObject;
|
|
130
|
+
export declare function isZodArrayV4(obj: unknown): obj is z4.$ZodArray;
|
|
125
131
|
/**
|
|
126
132
|
* Determines if the provided value is an InteropZodObject (Zod v3 or v4 object schema).
|
|
127
133
|
*
|
|
@@ -158,7 +164,30 @@ export declare function extendInteropZodObject<T extends InteropZodObject>(schem
|
|
|
158
164
|
* @throws {Error} If the schema is not a Zod v3 or v4 object.
|
|
159
165
|
*/
|
|
160
166
|
export declare function interopZodObjectPartial<T extends InteropZodObject>(schema: T): InteropZodObject;
|
|
161
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Returns a strict version of a Zod object schema, disallowing unknown keys.
|
|
169
|
+
* Supports both Zod v3 and v4 object schemas. If `recursive` is true, applies strictness
|
|
170
|
+
* recursively to all nested object schemas and arrays of object schemas.
|
|
171
|
+
*
|
|
172
|
+
* @template T - The type of the Zod object schema.
|
|
173
|
+
* @param {T} schema - The Zod object schema instance (either v3 or v4).
|
|
174
|
+
* @param {boolean} [recursive=false] - Whether to apply strictness recursively to nested objects/arrays.
|
|
175
|
+
* @returns {InteropZodObject} The strict Zod object schema.
|
|
176
|
+
* @throws {Error} If the schema is not a Zod v3 or v4 object.
|
|
177
|
+
*/
|
|
178
|
+
export declare function interopZodObjectStrict<T extends InteropZodObject>(schema: T, recursive?: boolean): InteropZodObject;
|
|
179
|
+
/**
|
|
180
|
+
* Returns a passthrough version of a Zod object schema, allowing unknown keys.
|
|
181
|
+
* Supports both Zod v3 and v4 object schemas. If `recursive` is true, applies passthrough
|
|
182
|
+
* recursively to all nested object schemas and arrays of object schemas.
|
|
183
|
+
*
|
|
184
|
+
* @template T - The type of the Zod object schema.
|
|
185
|
+
* @param {T} schema - The Zod object schema instance (either v3 or v4).
|
|
186
|
+
* @param {boolean} [recursive=false] - Whether to apply passthrough recursively to nested objects/arrays.
|
|
187
|
+
* @returns {InteropZodObject} The passthrough Zod object schema.
|
|
188
|
+
* @throws {Error} If the schema is not a Zod v3 or v4 object.
|
|
189
|
+
*/
|
|
190
|
+
export declare function interopZodObjectPassthrough<T extends InteropZodObject>(schema: T, recursive?: boolean): InteropZodObject;
|
|
162
191
|
/**
|
|
163
192
|
* Returns a getter function for the default value of a Zod schema, if one is defined.
|
|
164
193
|
* Supports both Zod v3 and v4 schemas. If the schema has a default value,
|
|
@@ -170,4 +199,12 @@ export declare function interopZodObjectPassthrough<T extends InteropZodObject>(
|
|
|
170
199
|
* @returns {(() => InferInteropZodOutput<T>) | undefined} A function that returns the default value, or undefined if no default is set.
|
|
171
200
|
*/
|
|
172
201
|
export declare function getInteropZodDefaultGetter<T extends InteropZodType>(schema: T): (() => InferInteropZodOutput<T>) | undefined;
|
|
202
|
+
/**
|
|
203
|
+
* Returns the input type of a Zod transform schema, for both v3 and v4.
|
|
204
|
+
* If the schema is not a transform, returns undefined.
|
|
205
|
+
*
|
|
206
|
+
* @param schema - The Zod schema instance (v3 or v4)
|
|
207
|
+
* @returns The input Zod schema of the transform, or undefined if not a transform
|
|
208
|
+
*/
|
|
209
|
+
export declare function interopZodTransformInputSchema(schema: InteropZodType): InteropZodType | undefined;
|
|
173
210
|
export {};
|
package/dist/utils/types/zod.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parse, parseAsync, globalRegistry, util, clone, _unknown, $ZodUnknown, $ZodOptional, } from "zod/v4/core";
|
|
1
|
+
import { parse, parseAsync, globalRegistry, util, clone, _unknown, _never, $ZodUnknown, $ZodNever, $ZodOptional, } from "zod/v4/core";
|
|
2
2
|
export function isZodSchemaV4(schema) {
|
|
3
3
|
if (typeof schema !== "object" || schema === null) {
|
|
4
4
|
return false;
|
|
@@ -264,6 +264,55 @@ export function isSimpleStringZodSchema(schema) {
|
|
|
264
264
|
}
|
|
265
265
|
return false;
|
|
266
266
|
}
|
|
267
|
+
export function isZodObjectV3(obj) {
|
|
268
|
+
// Zod v3 object schemas have _def.typeName === "ZodObject"
|
|
269
|
+
if (typeof obj === "object" &&
|
|
270
|
+
obj !== null &&
|
|
271
|
+
"_def" in obj &&
|
|
272
|
+
typeof obj._def === "object" &&
|
|
273
|
+
obj._def !== null &&
|
|
274
|
+
"typeName" in obj._def &&
|
|
275
|
+
obj._def.typeName === "ZodObject") {
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
export function isZodObjectV4(obj) {
|
|
281
|
+
if (!isZodSchemaV4(obj))
|
|
282
|
+
return false;
|
|
283
|
+
// Zod v4 object schemas have _zod.def.type === "object"
|
|
284
|
+
if (typeof obj === "object" &&
|
|
285
|
+
obj !== null &&
|
|
286
|
+
"_zod" in obj &&
|
|
287
|
+
typeof obj._zod === "object" &&
|
|
288
|
+
obj._zod !== null &&
|
|
289
|
+
"def" in obj._zod &&
|
|
290
|
+
typeof obj._zod.def === "object" &&
|
|
291
|
+
obj._zod.def !== null &&
|
|
292
|
+
"type" in obj._zod.def &&
|
|
293
|
+
obj._zod.def.type === "object") {
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
export function isZodArrayV4(obj) {
|
|
299
|
+
if (!isZodSchemaV4(obj))
|
|
300
|
+
return false;
|
|
301
|
+
// Zod v4 array schemas have _zod.def.type === "array"
|
|
302
|
+
if (typeof obj === "object" &&
|
|
303
|
+
obj !== null &&
|
|
304
|
+
"_zod" in obj &&
|
|
305
|
+
typeof obj._zod === "object" &&
|
|
306
|
+
obj._zod !== null &&
|
|
307
|
+
"def" in obj._zod &&
|
|
308
|
+
typeof obj._zod.def === "object" &&
|
|
309
|
+
obj._zod.def !== null &&
|
|
310
|
+
"type" in obj._zod.def &&
|
|
311
|
+
obj._zod.def.type === "array") {
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
267
316
|
/**
|
|
268
317
|
* Determines if the provided value is an InteropZodObject (Zod v3 or v4 object schema).
|
|
269
318
|
*
|
|
@@ -271,33 +320,10 @@ export function isSimpleStringZodSchema(schema) {
|
|
|
271
320
|
* @returns {boolean} True if the value is a Zod v3 or v4 object schema, false otherwise.
|
|
272
321
|
*/
|
|
273
322
|
export function isInteropZodObject(obj) {
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
"_def" in obj &&
|
|
279
|
-
typeof obj._def === "object" &&
|
|
280
|
-
obj._def !== null &&
|
|
281
|
-
"typeName" in obj._def &&
|
|
282
|
-
obj._def.typeName === "ZodObject") {
|
|
283
|
-
return true;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
if (isZodSchemaV4(obj)) {
|
|
287
|
-
// Zod v4 object schemas have _zod.def.type === "object"
|
|
288
|
-
if (typeof obj === "object" &&
|
|
289
|
-
obj !== null &&
|
|
290
|
-
"_zod" in obj &&
|
|
291
|
-
typeof obj._zod === "object" &&
|
|
292
|
-
obj._zod !== null &&
|
|
293
|
-
"def" in obj._zod &&
|
|
294
|
-
typeof obj._zod.def === "object" &&
|
|
295
|
-
obj._zod.def !== null &&
|
|
296
|
-
"type" in obj._zod.def &&
|
|
297
|
-
obj._zod.def.type === "object") {
|
|
298
|
-
return true;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
323
|
+
if (isZodObjectV3(obj))
|
|
324
|
+
return true;
|
|
325
|
+
if (isZodObjectV4(obj))
|
|
326
|
+
return true;
|
|
301
327
|
return false;
|
|
302
328
|
}
|
|
303
329
|
/**
|
|
@@ -355,19 +381,123 @@ export function interopZodObjectPartial(schema) {
|
|
|
355
381
|
}
|
|
356
382
|
throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject");
|
|
357
383
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
384
|
+
/**
|
|
385
|
+
* Returns a strict version of a Zod object schema, disallowing unknown keys.
|
|
386
|
+
* Supports both Zod v3 and v4 object schemas. If `recursive` is true, applies strictness
|
|
387
|
+
* recursively to all nested object schemas and arrays of object schemas.
|
|
388
|
+
*
|
|
389
|
+
* @template T - The type of the Zod object schema.
|
|
390
|
+
* @param {T} schema - The Zod object schema instance (either v3 or v4).
|
|
391
|
+
* @param {boolean} [recursive=false] - Whether to apply strictness recursively to nested objects/arrays.
|
|
392
|
+
* @returns {InteropZodObject} The strict Zod object schema.
|
|
393
|
+
* @throws {Error} If the schema is not a Zod v3 or v4 object.
|
|
394
|
+
*/
|
|
395
|
+
export function interopZodObjectStrict(schema, recursive = false) {
|
|
396
|
+
if (isZodSchemaV3(schema)) {
|
|
397
|
+
// TODO: v3 schemas aren't recursively handled here
|
|
398
|
+
// (currently not necessary since zodToJsonSchema handles this)
|
|
399
|
+
return schema.strict();
|
|
400
|
+
}
|
|
401
|
+
if (isZodObjectV4(schema)) {
|
|
402
|
+
const outputShape = schema._zod.def.shape;
|
|
403
|
+
if (recursive) {
|
|
404
|
+
for (const [key, keySchema] of Object.entries(schema._zod.def.shape)) {
|
|
405
|
+
// If the shape key is a v4 object schema, we need to make it strict
|
|
406
|
+
if (isZodObjectV4(keySchema)) {
|
|
407
|
+
const outputSchema = interopZodObjectStrict(keySchema, recursive);
|
|
408
|
+
outputShape[key] = outputSchema;
|
|
409
|
+
}
|
|
410
|
+
// If the shape key is a v4 array schema, we need to make the element
|
|
411
|
+
// schema strict if it's an object schema
|
|
412
|
+
else if (isZodArrayV4(keySchema)) {
|
|
413
|
+
let elementSchema = keySchema._zod.def.element;
|
|
414
|
+
if (isZodObjectV4(elementSchema)) {
|
|
415
|
+
elementSchema = interopZodObjectStrict(elementSchema, recursive);
|
|
416
|
+
}
|
|
417
|
+
outputShape[key] = clone(keySchema, {
|
|
418
|
+
...keySchema._zod.def,
|
|
419
|
+
element: elementSchema,
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
// Otherwise, just use the keySchema
|
|
423
|
+
else {
|
|
424
|
+
outputShape[key] = keySchema;
|
|
425
|
+
}
|
|
426
|
+
// Assign meta fields to the keySchema
|
|
427
|
+
const meta = globalRegistry.get(keySchema);
|
|
428
|
+
if (meta)
|
|
429
|
+
globalRegistry.add(outputShape[key], meta);
|
|
430
|
+
}
|
|
362
431
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
432
|
+
const modifiedSchema = clone(schema, {
|
|
433
|
+
...schema._zod.def,
|
|
434
|
+
shape: outputShape,
|
|
435
|
+
catchall: _never($ZodNever),
|
|
436
|
+
});
|
|
437
|
+
const meta = globalRegistry.get(schema);
|
|
438
|
+
if (meta)
|
|
439
|
+
globalRegistry.add(modifiedSchema, meta);
|
|
440
|
+
return modifiedSchema;
|
|
441
|
+
}
|
|
442
|
+
throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject");
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Returns a passthrough version of a Zod object schema, allowing unknown keys.
|
|
446
|
+
* Supports both Zod v3 and v4 object schemas. If `recursive` is true, applies passthrough
|
|
447
|
+
* recursively to all nested object schemas and arrays of object schemas.
|
|
448
|
+
*
|
|
449
|
+
* @template T - The type of the Zod object schema.
|
|
450
|
+
* @param {T} schema - The Zod object schema instance (either v3 or v4).
|
|
451
|
+
* @param {boolean} [recursive=false] - Whether to apply passthrough recursively to nested objects/arrays.
|
|
452
|
+
* @returns {InteropZodObject} The passthrough Zod object schema.
|
|
453
|
+
* @throws {Error} If the schema is not a Zod v3 or v4 object.
|
|
454
|
+
*/
|
|
455
|
+
export function interopZodObjectPassthrough(schema, recursive = false) {
|
|
456
|
+
if (isZodObjectV3(schema)) {
|
|
457
|
+
// TODO: v3 schemas aren't recursively handled here
|
|
458
|
+
// (currently not necessary since zodToJsonSchema handles this)
|
|
459
|
+
return schema.passthrough();
|
|
460
|
+
}
|
|
461
|
+
if (isZodObjectV4(schema)) {
|
|
462
|
+
const outputShape = schema._zod.def.shape;
|
|
463
|
+
if (recursive) {
|
|
464
|
+
for (const [key, keySchema] of Object.entries(schema._zod.def.shape)) {
|
|
465
|
+
// If the shape key is a v4 object schema, we need to make it passthrough
|
|
466
|
+
if (isZodObjectV4(keySchema)) {
|
|
467
|
+
const outputSchema = interopZodObjectPassthrough(keySchema, recursive);
|
|
468
|
+
outputShape[key] = outputSchema;
|
|
469
|
+
}
|
|
470
|
+
// If the shape key is a v4 array schema, we need to make the element
|
|
471
|
+
// schema passthrough if it's an object schema
|
|
472
|
+
else if (isZodArrayV4(keySchema)) {
|
|
473
|
+
let elementSchema = keySchema._zod.def.element;
|
|
474
|
+
if (isZodObjectV4(elementSchema)) {
|
|
475
|
+
elementSchema = interopZodObjectPassthrough(elementSchema, recursive);
|
|
476
|
+
}
|
|
477
|
+
outputShape[key] = clone(keySchema, {
|
|
478
|
+
...keySchema._zod.def,
|
|
479
|
+
element: elementSchema,
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
// Otherwise, just use the keySchema
|
|
483
|
+
else {
|
|
484
|
+
outputShape[key] = keySchema;
|
|
485
|
+
}
|
|
486
|
+
// Assign meta fields to the keySchema
|
|
487
|
+
const meta = globalRegistry.get(keySchema);
|
|
488
|
+
if (meta)
|
|
489
|
+
globalRegistry.add(outputShape[key], meta);
|
|
490
|
+
}
|
|
370
491
|
}
|
|
492
|
+
const modifiedSchema = clone(schema, {
|
|
493
|
+
...schema._zod.def,
|
|
494
|
+
shape: outputShape,
|
|
495
|
+
catchall: _unknown($ZodUnknown),
|
|
496
|
+
});
|
|
497
|
+
const meta = globalRegistry.get(schema);
|
|
498
|
+
if (meta)
|
|
499
|
+
globalRegistry.add(modifiedSchema, meta);
|
|
500
|
+
return modifiedSchema;
|
|
371
501
|
}
|
|
372
502
|
throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject");
|
|
373
503
|
}
|
|
@@ -402,3 +532,36 @@ export function getInteropZodDefaultGetter(schema) {
|
|
|
402
532
|
}
|
|
403
533
|
return undefined;
|
|
404
534
|
}
|
|
535
|
+
function isZodTransformV3(schema) {
|
|
536
|
+
return (isZodSchemaV3(schema) &&
|
|
537
|
+
"typeName" in schema._def &&
|
|
538
|
+
schema._def.typeName === "ZodEffects");
|
|
539
|
+
}
|
|
540
|
+
function isZodTransformV4(schema) {
|
|
541
|
+
return isZodSchemaV4(schema) && schema._zod.def.type === "pipe";
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Returns the input type of a Zod transform schema, for both v3 and v4.
|
|
545
|
+
* If the schema is not a transform, returns undefined.
|
|
546
|
+
*
|
|
547
|
+
* @param schema - The Zod schema instance (v3 or v4)
|
|
548
|
+
* @returns The input Zod schema of the transform, or undefined if not a transform
|
|
549
|
+
*/
|
|
550
|
+
export function interopZodTransformInputSchema(schema) {
|
|
551
|
+
// Zod v3: ._def.schema is the input schema for ZodEffects (transform)
|
|
552
|
+
if (isZodSchemaV3(schema)) {
|
|
553
|
+
if (isZodTransformV3(schema)) {
|
|
554
|
+
return interopZodTransformInputSchema(schema._def.schema);
|
|
555
|
+
}
|
|
556
|
+
return schema;
|
|
557
|
+
}
|
|
558
|
+
// Zod v4: _def.type is the input schema for ZodEffects (transform)
|
|
559
|
+
if (isZodSchemaV4(schema)) {
|
|
560
|
+
if (isZodTransformV4(schema)) {
|
|
561
|
+
const inner = interopZodTransformInputSchema(schema._zod.def.in);
|
|
562
|
+
return inner ?? schema;
|
|
563
|
+
}
|
|
564
|
+
return schema;
|
|
565
|
+
}
|
|
566
|
+
throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType");
|
|
567
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.60",
|
|
4
4
|
"description": "Core LangChain.js abstractions and schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"build:internal": "yarn lc_build --create-entrypoints --pre --tree-shaking",
|
|
19
19
|
"clean": "rm -rf .turbo dist/",
|
|
20
20
|
"lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
|
|
21
|
-
"lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
|
|
21
|
+
"lint:dpdm": "dpdm --skip-dynamic-imports circular --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
|
|
22
22
|
"lint": "yarn lint:eslint && yarn lint:dpdm",
|
|
23
23
|
"lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
|
|
24
24
|
"prepack": "yarn build",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@swc/jest": "^0.2.29",
|
|
54
54
|
"@types/decamelize": "^1.2.0",
|
|
55
55
|
"@types/mustache": "^4",
|
|
56
|
-
"dpdm": "^3.
|
|
56
|
+
"dpdm": "^3.14.0",
|
|
57
57
|
"eslint": "^8.33.0",
|
|
58
58
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
59
59
|
"eslint-config-prettier": "^8.6.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"release-it": "^18.1.2",
|
|
69
69
|
"rimraf": "^5.0.1",
|
|
70
70
|
"ts-jest": "^29.1.0",
|
|
71
|
-
"typescript": "~5.
|
|
71
|
+
"typescript": "~5.8.3",
|
|
72
72
|
"web-streams-polyfill": "^4.0.0"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
@@ -557,6 +557,24 @@
|
|
|
557
557
|
"import": "./utils/hash.js",
|
|
558
558
|
"require": "./utils/hash.cjs"
|
|
559
559
|
},
|
|
560
|
+
"./utils/hash/insecure": {
|
|
561
|
+
"types": {
|
|
562
|
+
"import": "./utils/hash/insecure.d.ts",
|
|
563
|
+
"require": "./utils/hash/insecure.d.cts",
|
|
564
|
+
"default": "./utils/hash/insecure.d.ts"
|
|
565
|
+
},
|
|
566
|
+
"import": "./utils/hash/insecure.js",
|
|
567
|
+
"require": "./utils/hash/insecure.cjs"
|
|
568
|
+
},
|
|
569
|
+
"./utils/hash/sha256": {
|
|
570
|
+
"types": {
|
|
571
|
+
"import": "./utils/hash/sha256.d.ts",
|
|
572
|
+
"require": "./utils/hash/sha256.d.cts",
|
|
573
|
+
"default": "./utils/hash/sha256.d.ts"
|
|
574
|
+
},
|
|
575
|
+
"import": "./utils/hash/sha256.js",
|
|
576
|
+
"require": "./utils/hash/sha256.cjs"
|
|
577
|
+
},
|
|
560
578
|
"./utils/json_patch": {
|
|
561
579
|
"types": {
|
|
562
580
|
"import": "./utils/json_patch.d.ts",
|
|
@@ -841,6 +859,14 @@
|
|
|
841
859
|
"utils/hash.js",
|
|
842
860
|
"utils/hash.d.ts",
|
|
843
861
|
"utils/hash.d.cts",
|
|
862
|
+
"utils/hash/insecure.cjs",
|
|
863
|
+
"utils/hash/insecure.js",
|
|
864
|
+
"utils/hash/insecure.d.ts",
|
|
865
|
+
"utils/hash/insecure.d.cts",
|
|
866
|
+
"utils/hash/sha256.cjs",
|
|
867
|
+
"utils/hash/sha256.js",
|
|
868
|
+
"utils/hash/sha256.d.ts",
|
|
869
|
+
"utils/hash/sha256.d.cts",
|
|
844
870
|
"utils/json_patch.cjs",
|
|
845
871
|
"utils/json_patch.js",
|
|
846
872
|
"utils/json_patch.d.ts",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/utils/js-sha1/hash.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/utils/js-sha1/hash.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/utils/js-sha1/hash.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/utils/js-sha1/hash.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/utils/js-sha256/hash.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/utils/js-sha256/hash.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/utils/js-sha256/hash.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/utils/js-sha256/hash.js'
|