@rulvar/openai 1.28.0 → 1.29.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/dist/index.js +19 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -535,6 +535,24 @@ function failedResponseError(code, message) {
|
|
|
535
535
|
}
|
|
536
536
|
};
|
|
537
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* Largest delay a Node timer represents exactly; a bigger value would
|
|
540
|
+
* overflow into an almost immediate (storm inducing) retry.
|
|
541
|
+
*/
|
|
542
|
+
const MAX_RETRY_AFTER_MS = 2147483647;
|
|
543
|
+
/**
|
|
544
|
+
* Parses a Retry-After header into milliseconds. Only the delta
|
|
545
|
+
* seconds form is honored: the HTTP date form and any other
|
|
546
|
+
* unparsable value return undefined so the engine falls back to its
|
|
547
|
+
* computed policy backoff instead of receiving NaN, and a huge but
|
|
548
|
+
* finite value is clamped to the Node timer maximum (v1.28.0 review
|
|
549
|
+
* P2).
|
|
550
|
+
*/
|
|
551
|
+
function retryAfterMsFrom(header) {
|
|
552
|
+
const seconds = Number(header);
|
|
553
|
+
if (!Number.isFinite(seconds) || seconds < 0) return;
|
|
554
|
+
return Math.min(Math.round(seconds * 1e3), MAX_RETRY_AFTER_MS);
|
|
555
|
+
}
|
|
538
556
|
/** Projects SDK/API errors into the retryable WireError vocabulary. */
|
|
539
557
|
function openAiErrorToWire(error) {
|
|
540
558
|
const record = error;
|
|
@@ -545,7 +563,7 @@ function openAiErrorToWire(error) {
|
|
|
545
563
|
const headers = record.headers;
|
|
546
564
|
if (headers !== void 0 && headers !== null) {
|
|
547
565
|
const value = typeof headers.get === "function" ? headers.get("retry-after") ?? void 0 : headers["retry-after"];
|
|
548
|
-
if (value !== void 0) retryAfterMs =
|
|
566
|
+
if (value !== void 0) retryAfterMs = retryAfterMsFrom(value);
|
|
549
567
|
}
|
|
550
568
|
return {
|
|
551
569
|
code: "agent",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/openai",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
4
4
|
"description": "Rulvar first-class provider adapter for the OpenAI Responses API, plus the openaiCompatible factory.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"openai": "^6.45.0",
|
|
26
|
-
"@rulvar/core": "1.
|
|
26
|
+
"@rulvar/core": "1.29.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^22.20.0",
|
|
30
30
|
"tsdown": "^0.22.3",
|
|
31
31
|
"typescript": "~6.0.3",
|
|
32
|
-
"@rulvar/testing": "1.
|
|
32
|
+
"@rulvar/testing": "1.29.0"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|