shariq-pi-extensions 0.2.21 → 0.2.22

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.
@@ -133,9 +133,19 @@ function activeKeyEntries(modelId?: string) {
133
133
 
134
134
  export function classifyFactoryKeyCooldown(message: string): { ms: number; kind: "auth" | "rate" | "quota" } | null {
135
135
  const lower = message.toLowerCase();
136
- // A bare 401/403 usually means our Factory transport or headers are wrong.
137
- // Disable a credential only when Factory explicitly identifies the key itself.
138
- if (lower.includes("invalid api key") || lower.includes("api key revoked") || lower.includes("api key expired")) return { ms: AUTH_COOLDOWN_MS, kind: "auth" };
136
+ if (
137
+ lower.includes("invalid api key") ||
138
+ lower.includes("api key revoked") ||
139
+ lower.includes("api key expired") ||
140
+ lower.includes("forbidden") ||
141
+ lower.includes("unauthorized") ||
142
+ lower.includes("permission") ||
143
+ lower.includes("access denied") ||
144
+ /\b401\b/.test(lower) ||
145
+ /\b403\b/.test(lower)
146
+ ) {
147
+ return { ms: AUTH_COOLDOWN_MS, kind: "auth" };
148
+ }
139
149
  if (/\b429\b/.test(lower) || lower.includes("rate limit")) return { ms: RATE_COOLDOWN_MS, kind: "rate" };
140
150
  if (lower.includes("quota") || lower.includes("billing") || lower.includes("credit") || lower.includes("usage limit") || lower.includes("exhaust")) return { ms: DEFAULT_COOLDOWN_MS, kind: "quota" };
141
151
  return null;
@@ -325,8 +335,8 @@ export function streamSimpleFactoryApiKeyResponses(model: any, context: any, opt
325
335
  const error = errorText(event);
326
336
  if (error) {
327
337
  lastError = error;
328
- const retryNext = !hasStarted && markKeyFailure(key, error, model.id);
329
- if (retryNext) {
338
+ markKeyFailure(key, error, model.id);
339
+ if (!hasStarted) {
330
340
  retriedBeforeStart = true;
331
341
  break;
332
342
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shariq-pi-extensions",
3
- "version": "0.2.21",
3
+ "version": "0.2.22",
4
4
  "description": "Cross-platform extension suite for the Pi coding agent.",
5
5
  "license": "MIT",
6
6
  "author": "Shariq Riaz",