@warlock.js/ai-openai 5.53.1 → 5.54.0
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 +7 -0
- package/cjs/index.cjs +21 -1
- package/cjs/index.cjs.map +1 -1
- package/esm/utils/wrap-openai-error.mjs +22 -2
- package/esm/utils/wrap-openai-error.mjs.map +1 -1
- package/llms-full.txt +2 -0
- package/package.json +3 -3
- package/skills/SKILL.md +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All notable changes to `@warlock.js/ai-openai` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
|
|
6
6
|
|
|
7
|
+
## 5.54.0 - 2026-11-16
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- A 429 (or any status) whose error `type` is `insufficient_quota`, or whose `code` is `credit_balance_exhausted`, `billing_hard_limit_reached` or `billing_not_active`, now maps to `QuotaExceededError` instead of the retryable `ProviderRateLimitError`, so retries and workflow retry stop repeating a call that cannot succeed. A plain 429 is still a rate limit. The default fallback chain still does not advance on `PROVIDER_QUOTA_EXCEEDED`; add it through `alsoRetryOn` to switch providers when credit runs out. DeepSeek, Groq, xAI and Mistral use the same mapping.
|
|
12
|
+
- A caller's own abort (the SDK's `APIUserAbortError`) is raised as a `ProviderAbortError` (name `AbortError`, category `cancelled`) instead of a plain `ProviderError`, so a fallback chain no longer treats it as a provider failure.
|
|
13
|
+
|
|
7
14
|
## 5.47.0 - 2026-11-06
|
|
8
15
|
|
|
9
16
|
### Added
|
package/cjs/index.cjs
CHANGED
|
@@ -325,6 +325,22 @@ function buildUsage(counts, pricing) {
|
|
|
325
325
|
|
|
326
326
|
//#endregion
|
|
327
327
|
//#region ../../packages/ai-openai/src/utils/wrap-openai-error.ts
|
|
328
|
+
/** Codes (and the `type` value) OpenAI uses when the account's credit or spend limit is used up. */
|
|
329
|
+
const SPENT_CREDIT_CODES = /* @__PURE__ */ new Set([
|
|
330
|
+
"insufficient_quota",
|
|
331
|
+
"credit_balance_exhausted",
|
|
332
|
+
"billing_hard_limit_reached",
|
|
333
|
+
"billing_not_active"
|
|
334
|
+
]);
|
|
335
|
+
/**
|
|
336
|
+
* Whether the error means the account has no credit left, which no retry
|
|
337
|
+
* fixes. Decided on `code` or on `type`, before the status-429 branch, so a
|
|
338
|
+
* 429 that carries `type: "insufficient_quota"` with another code is not
|
|
339
|
+
* mistaken for a retryable rate limit.
|
|
340
|
+
*/
|
|
341
|
+
function isSpentCredit(shape) {
|
|
342
|
+
return typeof shape.code === "string" && SPENT_CREDIT_CODES.has(shape.code) || shape.type === "insufficient_quota";
|
|
343
|
+
}
|
|
328
344
|
/**
|
|
329
345
|
* Wrap any thrown value caught inside the OpenAI adapter into the
|
|
330
346
|
* appropriate `@warlock.js/ai` `AIError` subclass.
|
|
@@ -351,6 +367,10 @@ function wrapOpenAIError(thrown) {
|
|
|
351
367
|
const shape = toShape(thrown);
|
|
352
368
|
const context = buildContext(thrown, shape);
|
|
353
369
|
const message = shape.message ?? (thrown instanceof Error ? thrown.message : String(thrown));
|
|
370
|
+
if (thrown instanceof openai.default.APIUserAbortError || shape.name === "APIUserAbortError") return new _warlock_js_ai.ProviderAbortError(message, {
|
|
371
|
+
cause: thrown,
|
|
372
|
+
context
|
|
373
|
+
});
|
|
354
374
|
if (isTimeout(thrown, shape)) return new _warlock_js_ai.ProviderTimeoutError(message, {
|
|
355
375
|
cause: thrown,
|
|
356
376
|
context
|
|
@@ -359,7 +379,7 @@ function wrapOpenAIError(thrown) {
|
|
|
359
379
|
cause: thrown,
|
|
360
380
|
context
|
|
361
381
|
});
|
|
362
|
-
if (shape
|
|
382
|
+
if (isSpentCredit(shape)) return new _warlock_js_ai.QuotaExceededError(message, {
|
|
363
383
|
cause: thrown,
|
|
364
384
|
context
|
|
365
385
|
});
|