@jaypie/llm 1.2.3 → 1.2.5

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) {
@@ -3705,7 +3714,8 @@ class RetryExecutor {
3705
3714
  providerRequest: options.context.providerRequest,
3706
3715
  error,
3707
3716
  });
3708
- throw new BadGatewayError();
3717
+ const errorMessage = error instanceof Error ? error.message : String(error);
3718
+ throw new BadGatewayError(errorMessage);
3709
3719
  }
3710
3720
  // Check if error is not retryable
3711
3721
  if (!this.errorClassifier.isRetryable(error)) {
@@ -3717,7 +3727,8 @@ class RetryExecutor {
3717
3727
  providerRequest: options.context.providerRequest,
3718
3728
  error,
3719
3729
  });
3720
- throw new BadGatewayError();
3730
+ const errorMessage = error instanceof Error ? error.message : String(error);
3731
+ throw new BadGatewayError(errorMessage);
3721
3732
  }
3722
3733
  // Warn if this is an unknown error type
3723
3734
  if (!this.errorClassifier.isKnownError(error)) {