@langchain/core 0.2.24 → 0.2.25

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.
@@ -250,7 +250,7 @@ class DynamicStructuredTool extends StructuredTool {
250
250
  this.description = fields.description;
251
251
  this.func = fields.func;
252
252
  this.returnDirect = fields.returnDirect ?? this.returnDirect;
253
- this.schema = ((0, is_zod_schema_js_1.isZodSchema)(fields.schema) ? fields.schema : zod_1.z.object({}));
253
+ this.schema = ((0, is_zod_schema_js_1.isZodSchema)(fields.schema) ? fields.schema : zod_1.z.object({}).passthrough());
254
254
  }
255
255
  /**
256
256
  * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
@@ -283,7 +283,9 @@ class BaseToolkit {
283
283
  exports.BaseToolkit = BaseToolkit;
284
284
  function tool(func, fields) {
285
285
  // If the schema is not provided, or it's a string schema, create a DynamicTool
286
- if (!fields.schema || !("shape" in fields.schema) || !fields.schema.shape) {
286
+ if (!fields.schema ||
287
+ ((0, is_zod_schema_js_1.isZodSchema)(fields.schema) &&
288
+ (!("shape" in fields.schema) || !fields.schema.shape))) {
287
289
  return new DynamicTool({
288
290
  ...fields,
289
291
  description: fields.description ??
@@ -244,7 +244,7 @@ export class DynamicStructuredTool extends StructuredTool {
244
244
  this.description = fields.description;
245
245
  this.func = fields.func;
246
246
  this.returnDirect = fields.returnDirect ?? this.returnDirect;
247
- this.schema = (isZodSchema(fields.schema) ? fields.schema : z.object({}));
247
+ this.schema = (isZodSchema(fields.schema) ? fields.schema : z.object({}).passthrough());
248
248
  }
249
249
  /**
250
250
  * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
@@ -275,7 +275,9 @@ export class BaseToolkit {
275
275
  }
276
276
  export function tool(func, fields) {
277
277
  // If the schema is not provided, or it's a string schema, create a DynamicTool
278
- if (!fields.schema || !("shape" in fields.schema) || !fields.schema.shape) {
278
+ if (!fields.schema ||
279
+ (isZodSchema(fields.schema) &&
280
+ (!("shape" in fields.schema) || !fields.schema.shape))) {
279
281
  return new DynamicTool({
280
282
  ...fields,
281
283
  description: fields.description ??
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/core",
3
- "version": "0.2.24",
3
+ "version": "0.2.25",
4
4
  "description": "Core LangChain.js abstractions and schemas",
5
5
  "type": "module",
6
6
  "engines": {