ai-retry 1.0.1 → 1.0.2
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/README.md +1 -1
- package/dist/index.d.mts +11 -1
- package/dist/index.mjs +4 -2
- package/dist/retryables/index.mjs +2 -3
- package/dist/{utils-BXFlA2mh.mjs → utils-Vtk_GA9U.mjs} +11 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ It supports two types of retries:
|
|
|
19
19
|
|
|
20
20
|
### Installation
|
|
21
21
|
|
|
22
|
-
This library supports both AI SDK v5 and v6. The main branch reflects the latest stable version for AI SDK v6. See the [v0 branch](https://github.com/zirkelc/ai-retry/tree/v0) for documentation.
|
|
22
|
+
This library supports both AI SDK v5 and v6. The main branch reflects the latest stable version for AI SDK v6. See the [v0 branch](https://github.com/zirkelc/ai-retry/tree/v0) for the AI SDK v5 documentation.
|
|
23
23
|
|
|
24
24
|
> [!WARNING]
|
|
25
25
|
> Version compatibility:
|
package/dist/index.d.mts
CHANGED
|
@@ -62,5 +62,15 @@ declare const isStreamContentPart: (part: LanguageModelStreamPart) => part is {
|
|
|
62
62
|
type: "raw";
|
|
63
63
|
rawValue: unknown;
|
|
64
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Check if an error is a user-initiated abort error (manual controller.abort()).
|
|
67
|
+
* This is distinct from TimeoutError which is thrown by AbortSignal.timeout().
|
|
68
|
+
*/
|
|
69
|
+
declare const isAbortError: (error: unknown) => boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Check if an error is a timeout error from AbortSignal.timeout().
|
|
72
|
+
* This is distinct from AbortError which is thrown by manual controller.abort().
|
|
73
|
+
*/
|
|
74
|
+
declare const isTimeoutError: (error: unknown) => boolean;
|
|
65
75
|
//#endregion
|
|
66
|
-
export { EmbeddingModel, EmbeddingModelCallOptions, EmbeddingModelEmbed, EmbeddingModelRetryCallOptions, GatewayLanguageModelId, LanguageModel, LanguageModelCallOptions, LanguageModelGenerate, LanguageModelRetryCallOptions, LanguageModelStream, LanguageModelStreamPart, ProviderOptions, ResolvableLanguageModel, ResolvableModel, ResolvedModel, Retries, Retry, RetryAttempt, RetryContext, RetryErrorAttempt, RetryResultAttempt, Retryable, RetryableModelOptions, RetryableOptions, createRetryable, getModelKey, isEmbeddingModel, isErrorAttempt, isGenerateResult, isLanguageModel, isModel, isObject, isResultAttempt, isStreamContentPart, isStreamResult, isString };
|
|
76
|
+
export { EmbeddingModel, EmbeddingModelCallOptions, EmbeddingModelEmbed, EmbeddingModelRetryCallOptions, GatewayLanguageModelId, LanguageModel, LanguageModelCallOptions, LanguageModelGenerate, LanguageModelRetryCallOptions, LanguageModelStream, LanguageModelStreamPart, ProviderOptions, ResolvableLanguageModel, ResolvableModel, ResolvedModel, Retries, Retry, RetryAttempt, RetryContext, RetryErrorAttempt, RetryResultAttempt, Retryable, RetryableModelOptions, RetryableOptions, createRetryable, getModelKey, isAbortError, isEmbeddingModel, isErrorAttempt, isGenerateResult, isLanguageModel, isModel, isObject, isResultAttempt, isStreamContentPart, isStreamResult, isString, isTimeoutError };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as isLanguageModel, c as isResultAttempt, d as isString, f as isTimeoutError, i as isGenerateResult, l as isStreamContentPart, n as isEmbeddingModel, o as isModel, r as isErrorAttempt, s as isObject, t as isAbortError, u as isStreamResult } from "./utils-Vtk_GA9U.mjs";
|
|
2
2
|
import { RetryError, gateway } from "ai";
|
|
3
3
|
import { delay } from "@ai-sdk/provider-utils";
|
|
4
4
|
import { getErrorMessage } from "@ai-sdk/provider";
|
|
@@ -183,6 +183,7 @@ var RetryableEmbeddingModel = class {
|
|
|
183
183
|
attempts
|
|
184
184
|
};
|
|
185
185
|
} catch (error) {
|
|
186
|
+
if (isAbortError(error)) throw error;
|
|
186
187
|
const { retryModel, attempt } = await this.handleError(error, attempts, retryCallOptions);
|
|
187
188
|
attempts.push(attempt);
|
|
188
189
|
if (retryModel.delay) {
|
|
@@ -375,6 +376,7 @@ var RetryableLanguageModel = class {
|
|
|
375
376
|
attempts
|
|
376
377
|
};
|
|
377
378
|
} catch (error) {
|
|
379
|
+
if (isAbortError(error)) throw error;
|
|
378
380
|
const { retryModel, attempt } = await this.handleError(error, attempts, retryCallOptions);
|
|
379
381
|
attempts.push(attempt);
|
|
380
382
|
if (retryModel.delay) {
|
|
@@ -578,4 +580,4 @@ function createRetryable(options) {
|
|
|
578
580
|
}
|
|
579
581
|
|
|
580
582
|
//#endregion
|
|
581
|
-
export { createRetryable, getModelKey, isEmbeddingModel, isErrorAttempt, isGenerateResult, isLanguageModel, isModel, isObject, isResultAttempt, isStreamContentPart, isStreamResult, isString };
|
|
583
|
+
export { createRetryable, getModelKey, isAbortError, isEmbeddingModel, isErrorAttempt, isGenerateResult, isLanguageModel, isModel, isObject, isResultAttempt, isStreamContentPart, isStreamResult, isString, isTimeoutError };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as isResultAttempt, d as isString, f as isTimeoutError, r as isErrorAttempt, s as isObject } from "../utils-Vtk_GA9U.mjs";
|
|
2
2
|
import { APICallError } from "ai";
|
|
3
|
-
import { isAbortError } from "@ai-sdk/provider-utils";
|
|
4
3
|
|
|
5
4
|
//#region src/retryables/content-filter-triggered.ts
|
|
6
5
|
/**
|
|
@@ -61,7 +60,7 @@ function requestTimeout(model, options) {
|
|
|
61
60
|
* Fallback to the specified model after a timeout/abort error.
|
|
62
61
|
* Provides a fresh timeout signal for the retry attempt.
|
|
63
62
|
*/
|
|
64
|
-
if (
|
|
63
|
+
if (isTimeoutError(current.error)) return {
|
|
65
64
|
model,
|
|
66
65
|
maxAttempts: 1,
|
|
67
66
|
timeout: options?.timeout ?? 6e4,
|
|
@@ -26,6 +26,16 @@ function isResultAttempt(attempt) {
|
|
|
26
26
|
const isStreamContentPart = (part) => {
|
|
27
27
|
return part.type === "text-delta" || part.type === "reasoning-delta" || part.type === "source" || part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-input-start" || part.type === "tool-input-delta" || part.type === "raw";
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Check if an error is a user-initiated abort error (manual controller.abort()).
|
|
31
|
+
* This is distinct from TimeoutError which is thrown by AbortSignal.timeout().
|
|
32
|
+
*/
|
|
33
|
+
const isAbortError = (error) => error instanceof Error && error.name === "AbortError";
|
|
34
|
+
/**
|
|
35
|
+
* Check if an error is a timeout error from AbortSignal.timeout().
|
|
36
|
+
* This is distinct from AbortError which is thrown by manual controller.abort().
|
|
37
|
+
*/
|
|
38
|
+
const isTimeoutError = (error) => error instanceof Error && error.name === "TimeoutError";
|
|
29
39
|
|
|
30
40
|
//#endregion
|
|
31
|
-
export {
|
|
41
|
+
export { isLanguageModel as a, isResultAttempt as c, isString as d, isTimeoutError as f, isGenerateResult as i, isStreamContentPart as l, isEmbeddingModel as n, isModel as o, isErrorAttempt as r, isObject as s, isAbortError as t, isStreamResult as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-retry",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "AI SDK Retry",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"ai": "6.x"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@ai-sdk/anthropic": "3.0.
|
|
37
|
-
"@ai-sdk/azure": "3.0.
|
|
38
|
-
"@ai-sdk/gateway": "
|
|
39
|
-
"@ai-sdk/groq": "3.0.
|
|
40
|
-
"@ai-sdk/openai": "3.0.
|
|
41
|
-
"@ai-sdk/test-server": "1.0.
|
|
36
|
+
"@ai-sdk/anthropic": "3.0.9",
|
|
37
|
+
"@ai-sdk/azure": "3.0.7",
|
|
38
|
+
"@ai-sdk/gateway": "3.0.10",
|
|
39
|
+
"@ai-sdk/groq": "3.0.4",
|
|
40
|
+
"@ai-sdk/openai": "3.0.7",
|
|
41
|
+
"@ai-sdk/test-server": "1.0.1",
|
|
42
42
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
43
43
|
"@biomejs/biome": "^2.3.10",
|
|
44
44
|
"@total-typescript/tsconfig": "^1.0.4",
|
|
45
45
|
"@types/node": "^25.0.3",
|
|
46
|
-
"ai": "6.0.
|
|
46
|
+
"ai": "6.0.20",
|
|
47
47
|
"husky": "^9.1.7",
|
|
48
48
|
"msw": "^2.12.4",
|
|
49
49
|
"pkg-pr-new": "^0.0.62",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"zod": "^4.2.1"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@ai-sdk/provider": "3.0.
|
|
59
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
58
|
+
"@ai-sdk/provider": "3.0.2",
|
|
59
|
+
"@ai-sdk/provider-utils": "4.0.4"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsdown",
|