@jaypie/llm 1.2.3 → 1.2.4

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.
@@ -1,8 +1,9 @@
1
1
  import { AnyValue, JsonObject } from "@jaypie/types";
2
+ import { z } from "zod/v4";
2
3
  export interface LlmTool {
3
4
  description: string;
4
5
  name: string;
5
- parameters: JsonObject;
6
+ parameters: JsonObject | z.ZodType;
6
7
  type: "function" | string;
7
8
  call: (args?: JsonObject) => Promise<AnyValue> | AnyValue;
8
9
  message?: string | ((args?: JsonObject, context?: {
package/dist/esm/index.js CHANGED
@@ -2907,6 +2907,15 @@ class Toolkit {
2907
2907
  const toolCopy = { ...tool };
2908
2908
  delete toolCopy.call;
2909
2909
  delete toolCopy.message;
2910
+ // Convert Zod schema to JSON Schema if needed
2911
+ if (toolCopy.parameters instanceof z.ZodType) {
2912
+ const jsonSchema = z.toJSONSchema(toolCopy.parameters);
2913
+ // Remove $schema property (causes issues with some providers)
2914
+ if (jsonSchema.$schema) {
2915
+ delete jsonSchema.$schema;
2916
+ }
2917
+ toolCopy.parameters = jsonSchema;
2918
+ }
2910
2919
  if (this.explain && toolCopy.parameters?.type === "object") {
2911
2920
  if (toolCopy.parameters?.properties) {
2912
2921
  if (!toolCopy.parameters.properties.__Explanation) {