dsh-plugin-subscription-oauth 0.17.6 → 0.17.7
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/lib/providers/antigravity.js +41 -1
- package/package.json +1 -1
|
@@ -66,6 +66,8 @@ async function paceAntigravityAttempt(signal) {
|
|
|
66
66
|
const NETWORK_RETRY_ATTEMPTS = 3;
|
|
67
67
|
/** Base delay between network retries; it doubles each attempt. */
|
|
68
68
|
const NETWORK_RETRY_BASE_MS = 800;
|
|
69
|
+
/** How many times a stream that closes early is retried before the account is skipped. */
|
|
70
|
+
const STREAM_RETRY_ATTEMPTS = 3;
|
|
69
71
|
/**
|
|
70
72
|
* Whether an error from `fetch` is a transient network fault worth retrying.
|
|
71
73
|
*
|
|
@@ -79,6 +81,17 @@ function isTransientNetworkFault(error) {
|
|
|
79
81
|
const text = errorChain(error).toLowerCase();
|
|
80
82
|
return /fetch failed|connect timeout|connection reset|econnreset|etimedout|econnrefused|socket hang up|network error|timed out/.test(text);
|
|
81
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Whether an error raised while reading a live stream is a transient cut worth redispatching.
|
|
86
|
+
*
|
|
87
|
+
* `streamAntigravity` throws `STREAM_CLOSED` when the SSE body ends before a finish chunk —
|
|
88
|
+
* a dropped or reset connection mid-answer, not a refusal. The request arrived and the
|
|
89
|
+
* account is fine; the answer just never completed, so redispatching the same request is
|
|
90
|
+
* safe. Content refusals (`CONTENT_FILTER`), quota and credential failures are not retried.
|
|
91
|
+
*/
|
|
92
|
+
function isRetryableStreamError(error) {
|
|
93
|
+
return error instanceof LlmError && error.failure.code === 'STREAM_CLOSED';
|
|
94
|
+
}
|
|
82
95
|
/**
|
|
83
96
|
* Sleep for a backoff beat, honouring the caller's abort.
|
|
84
97
|
* @param ms - how long to wait.
|
|
@@ -626,7 +639,34 @@ export class AntigravityAdapter extends LlmAdapter {
|
|
|
626
639
|
if (response.body === null) {
|
|
627
640
|
throw new LlmError('Antigravity API returned no response body', EMPTY_RESPONSE_CODE);
|
|
628
641
|
}
|
|
629
|
-
|
|
642
|
+
// A stream that closes before a finish chunk is a dropped connection, not a
|
|
643
|
+
// refusal: the account is fine and the request arrived, so redispatch it a few
|
|
644
|
+
// times with backoff before giving up on the account. Content refusals and quota
|
|
645
|
+
// failures propagate untouched.
|
|
646
|
+
let lastStreamError;
|
|
647
|
+
for (let attempt = 0; attempt < STREAM_RETRY_ATTEMPTS; attempt++) {
|
|
648
|
+
try {
|
|
649
|
+
yield* streamAntigravity(response.body, () => { watchdog.pulse(); });
|
|
650
|
+
lastStreamError = undefined;
|
|
651
|
+
break;
|
|
652
|
+
}
|
|
653
|
+
catch (error) {
|
|
654
|
+
if (!isRetryableStreamError(error) || watchdog.signal.aborted)
|
|
655
|
+
throw error;
|
|
656
|
+
lastStreamError = error;
|
|
657
|
+
this.options.onWarn?.(`antigravity: stream closed early (${errorChain(error)}); redispatching`);
|
|
658
|
+
if (attempt < STREAM_RETRY_ATTEMPTS - 1) {
|
|
659
|
+
await backoff(NETWORK_RETRY_BASE_MS * 2 ** attempt, watchdog.signal);
|
|
660
|
+
response = await this.requestWithRetry(options, model, token.account, token.accessToken, watchdog.signal);
|
|
661
|
+
if (!response.ok)
|
|
662
|
+
throw await httpLlmError(response, 'Antigravity API');
|
|
663
|
+
if (response.body === null)
|
|
664
|
+
throw new LlmError('Antigravity API returned no response body', EMPTY_RESPONSE_CODE);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
if (lastStreamError !== undefined)
|
|
669
|
+
throw lastStreamError;
|
|
630
670
|
return;
|
|
631
671
|
}
|
|
632
672
|
// Every account was tried and none served. The headline names the most actionable
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-subscription-oauth",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.7",
|
|
4
4
|
"description": "Use subscription accounts as DeepSeek Harness LLM providers — Kimi Code (OAuth device flow), Grok / X Premium (OIDC + PKCE), Google Antigravity (Google OAuth + Cloud Code Assist) and GLM / BigModel (ZCode's browser sign-in) — with per-model visibility, drag-to-reorder Auto fallback and plan quotas from the web Settings page",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "EricFL1998",
|