ai 4.0.17 → 4.0.19

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # ai
2
2
 
3
+ ## 4.0.19
4
+
5
+ ### Patch Changes
6
+
7
+ - c3a6065: fix (ai/core): apply transform before callbacks and resolvables
8
+
9
+ ## 4.0.18
10
+
11
+ ### Patch Changes
12
+
13
+ - 304e6d3: feat (ai/core): standardize generateObject, streamObject, and output errors to NoObjectGeneratedError
14
+ - 304e6d3: feat (ai/core): add additional information to NoObjectGeneratedError
15
+
3
16
  ## 4.0.17
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1608,6 +1608,9 @@ interface Output<OUTPUT> {
1608
1608
  }) => LanguageModelV1CallOptions['responseFormat'];
1609
1609
  parseOutput(options: {
1610
1610
  text: string;
1611
+ }, context: {
1612
+ response: LanguageModelResponseMetadata;
1613
+ usage: LanguageModelUsage;
1611
1614
  }): OUTPUT;
1612
1615
  }
1613
1616
  declare const text: () => Output<string>;
@@ -1975,7 +1978,9 @@ type TextStreamPart<TOOLS extends Record<string, CoreTool>> = {
1975
1978
  finishReason: FinishReason;
1976
1979
  logprobs?: LogProbs;
1977
1980
  usage: LanguageModelUsage;
1981
+ request: LanguageModelRequestMetadata;
1978
1982
  response: LanguageModelResponseMetadata;
1983
+ warnings: CallWarning[] | undefined;
1979
1984
  experimental_providerMetadata?: ProviderMetadata;
1980
1985
  isContinued: boolean;
1981
1986
  } | {
@@ -2274,8 +2279,44 @@ declare class InvalidArgumentError extends AISDKError {
2274
2279
  }
2275
2280
 
2276
2281
  declare const symbol$7: unique symbol;
2277
- declare class ToolCallRepairError extends AISDKError {
2282
+ /**
2283
+ Thrown when no object could be generated. This can have several causes:
2284
+
2285
+ - The model failed to generate a response.
2286
+ - The model generated a response that could not be parsed.
2287
+ - The model generated a response that could not be validated against the schema.
2288
+
2289
+ The error contains the following properties:
2290
+
2291
+ - `text`: The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
2292
+ */
2293
+ declare class NoObjectGeneratedError extends AISDKError {
2278
2294
  private readonly [symbol$7];
2295
+ /**
2296
+ The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
2297
+ */
2298
+ readonly text: string | undefined;
2299
+ /**
2300
+ The response metadata.
2301
+ */
2302
+ readonly response: LanguageModelResponseMetadata | undefined;
2303
+ /**
2304
+ The usage of the model.
2305
+ */
2306
+ readonly usage: LanguageModelUsage | undefined;
2307
+ constructor({ message, cause, text, response, usage, }: {
2308
+ message?: string;
2309
+ cause?: Error;
2310
+ text?: string;
2311
+ response: LanguageModelResponseMetadata;
2312
+ usage: LanguageModelUsage;
2313
+ });
2314
+ static isInstance(error: unknown): error is NoObjectGeneratedError;
2315
+ }
2316
+
2317
+ declare const symbol$6: unique symbol;
2318
+ declare class ToolCallRepairError extends AISDKError {
2319
+ private readonly [symbol$6];
2279
2320
  readonly originalError: NoSuchToolError | InvalidToolArgumentsError;
2280
2321
  constructor({ cause, originalError, message, }: {
2281
2322
  message?: string;
@@ -2285,9 +2326,9 @@ declare class ToolCallRepairError extends AISDKError {
2285
2326
  static isInstance(error: unknown): error is ToolCallRepairError;
2286
2327
  }
2287
2328
 
2288
- declare const symbol$6: unique symbol;
2329
+ declare const symbol$5: unique symbol;
2289
2330
  declare class ToolExecutionError extends AISDKError {
2290
- private readonly [symbol$6];
2331
+ private readonly [symbol$5];
2291
2332
  readonly toolName: string;
2292
2333
  readonly toolArgs: JSONValue;
2293
2334
  constructor({ toolArgs, toolName, cause, message, }: {
@@ -2299,18 +2340,6 @@ declare class ToolExecutionError extends AISDKError {
2299
2340
  static isInstance(error: unknown): error is ToolExecutionError;
2300
2341
  }
2301
2342
 
2302
- declare const symbol$5: unique symbol;
2303
- /**
2304
- Thrown when the AI provider fails to generate a parsable object.
2305
- */
2306
- declare class NoObjectGeneratedError extends AISDKError {
2307
- private readonly [symbol$5];
2308
- constructor({ message }?: {
2309
- message?: string;
2310
- });
2311
- static isInstance(error: unknown): error is NoObjectGeneratedError;
2312
- }
2313
-
2314
2343
  declare const symbol$4: unique symbol;
2315
2344
  declare class InvalidDataContentError extends AISDKError {
2316
2345
  private readonly [symbol$4];
package/dist/index.d.ts CHANGED
@@ -1608,6 +1608,9 @@ interface Output<OUTPUT> {
1608
1608
  }) => LanguageModelV1CallOptions['responseFormat'];
1609
1609
  parseOutput(options: {
1610
1610
  text: string;
1611
+ }, context: {
1612
+ response: LanguageModelResponseMetadata;
1613
+ usage: LanguageModelUsage;
1611
1614
  }): OUTPUT;
1612
1615
  }
1613
1616
  declare const text: () => Output<string>;
@@ -1975,7 +1978,9 @@ type TextStreamPart<TOOLS extends Record<string, CoreTool>> = {
1975
1978
  finishReason: FinishReason;
1976
1979
  logprobs?: LogProbs;
1977
1980
  usage: LanguageModelUsage;
1981
+ request: LanguageModelRequestMetadata;
1978
1982
  response: LanguageModelResponseMetadata;
1983
+ warnings: CallWarning[] | undefined;
1979
1984
  experimental_providerMetadata?: ProviderMetadata;
1980
1985
  isContinued: boolean;
1981
1986
  } | {
@@ -2274,8 +2279,44 @@ declare class InvalidArgumentError extends AISDKError {
2274
2279
  }
2275
2280
 
2276
2281
  declare const symbol$7: unique symbol;
2277
- declare class ToolCallRepairError extends AISDKError {
2282
+ /**
2283
+ Thrown when no object could be generated. This can have several causes:
2284
+
2285
+ - The model failed to generate a response.
2286
+ - The model generated a response that could not be parsed.
2287
+ - The model generated a response that could not be validated against the schema.
2288
+
2289
+ The error contains the following properties:
2290
+
2291
+ - `text`: The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
2292
+ */
2293
+ declare class NoObjectGeneratedError extends AISDKError {
2278
2294
  private readonly [symbol$7];
2295
+ /**
2296
+ The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
2297
+ */
2298
+ readonly text: string | undefined;
2299
+ /**
2300
+ The response metadata.
2301
+ */
2302
+ readonly response: LanguageModelResponseMetadata | undefined;
2303
+ /**
2304
+ The usage of the model.
2305
+ */
2306
+ readonly usage: LanguageModelUsage | undefined;
2307
+ constructor({ message, cause, text, response, usage, }: {
2308
+ message?: string;
2309
+ cause?: Error;
2310
+ text?: string;
2311
+ response: LanguageModelResponseMetadata;
2312
+ usage: LanguageModelUsage;
2313
+ });
2314
+ static isInstance(error: unknown): error is NoObjectGeneratedError;
2315
+ }
2316
+
2317
+ declare const symbol$6: unique symbol;
2318
+ declare class ToolCallRepairError extends AISDKError {
2319
+ private readonly [symbol$6];
2279
2320
  readonly originalError: NoSuchToolError | InvalidToolArgumentsError;
2280
2321
  constructor({ cause, originalError, message, }: {
2281
2322
  message?: string;
@@ -2285,9 +2326,9 @@ declare class ToolCallRepairError extends AISDKError {
2285
2326
  static isInstance(error: unknown): error is ToolCallRepairError;
2286
2327
  }
2287
2328
 
2288
- declare const symbol$6: unique symbol;
2329
+ declare const symbol$5: unique symbol;
2289
2330
  declare class ToolExecutionError extends AISDKError {
2290
- private readonly [symbol$6];
2331
+ private readonly [symbol$5];
2291
2332
  readonly toolName: string;
2292
2333
  readonly toolArgs: JSONValue;
2293
2334
  constructor({ toolArgs, toolName, cause, message, }: {
@@ -2299,18 +2340,6 @@ declare class ToolExecutionError extends AISDKError {
2299
2340
  static isInstance(error: unknown): error is ToolExecutionError;
2300
2341
  }
2301
2342
 
2302
- declare const symbol$5: unique symbol;
2303
- /**
2304
- Thrown when the AI provider fails to generate a parsable object.
2305
- */
2306
- declare class NoObjectGeneratedError extends AISDKError {
2307
- private readonly [symbol$5];
2308
- constructor({ message }?: {
2309
- message?: string;
2310
- });
2311
- static isInstance(error: unknown): error is NoObjectGeneratedError;
2312
- }
2313
-
2314
2343
  declare const symbol$4: unique symbol;
2315
2344
  declare class InvalidDataContentError extends AISDKError {
2316
2345
  private readonly [symbol$4];