@oh-my-pi/pi-ai 17.2.7 → 17.2.9
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 +11 -0
- package/dist/types/auth/sqlite-credential-store.d.ts +117 -0
- package/dist/types/auth-storage.d.ts +1 -108
- package/dist/types/error/flags.d.ts +4 -2
- package/dist/types/error/index.d.ts +1 -0
- package/dist/types/error/rate-limit.d.ts +21 -5
- package/dist/types/error/retryable.d.ts +1 -1
- package/dist/types/providers/anthropic.d.ts +2 -2
- package/dist/types/providers/cursor/exec-modern.d.ts +1 -1
- package/dist/types/providers/cursor-pi-args.d.ts +6 -0
- package/dist/types/providers/mock.d.ts +1 -0
- package/dist/types/providers/openai-codex/request-transformer.d.ts +1 -1
- package/dist/types/providers/openai-codex-responses.d.ts +1 -1
- package/dist/types/providers/pi-native-server.d.ts +1 -1
- package/dist/types/utils/http-inspector.d.ts +5 -4
- package/dist/types/utils/retry.d.ts +3 -2
- package/package.json +5 -5
- package/src/auth/sqlite-credential-store.ts +2049 -0
- package/src/auth-retry.ts +8 -5
- package/src/auth-storage.ts +30 -2023
- package/src/error/auth-classify.ts +5 -4
- package/src/error/flags.ts +74 -18
- package/src/error/index.ts +1 -0
- package/src/error/rate-limit.ts +64 -5
- package/src/error/retryable.ts +1 -1
- package/src/providers/anthropic.ts +15 -3
- package/src/providers/cursor/exec-modern.ts +1 -0
- package/src/providers/cursor-pi-args.ts +30 -0
- package/src/providers/cursor.ts +16 -9
- package/src/providers/mock.ts +1 -1
- package/src/providers/openai-codex/request-transformer.ts +21 -27
- package/src/providers/openai-codex-responses.ts +2 -2
- package/src/providers/pi-native-client.ts +1 -1
- package/src/providers/pi-native-server.ts +1 -1
- package/src/registry/oauth/devin.ts +1 -1
- package/src/stream.ts +3 -3
- package/src/usage/openai-codex.ts +30 -19
- package/src/utils/http-inspector.ts +6 -5
- package/src/utils/retry.ts +24 -5
package/src/auth-retry.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { OAuthAccess } from "./auth-storage";
|
|
|
3
3
|
import * as AIError from "./error";
|
|
4
4
|
import { isAuthRetryableError, isInvalidatedOAuthTokenError } from "./error/auth-classify";
|
|
5
5
|
import { isUsageLimit } from "./error/flags";
|
|
6
|
-
import { isUsageLimitOutcome } from "./error/rate-limit";
|
|
6
|
+
import { isConcurrencyCapExclusion, isUsageLimitOutcome } from "./error/rate-limit";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Context passed to an {@link ApiKeyResolver} on each resolution attempt.
|
|
@@ -93,11 +93,14 @@ export const AUTH_RETRY_MAX_ATTEMPTS = 64;
|
|
|
93
93
|
function isDirectCredentialRotationError(error: unknown): boolean {
|
|
94
94
|
if (isUsageLimit(error) || isInvalidatedOAuthTokenError(error)) return true;
|
|
95
95
|
const status = AIError.status(error);
|
|
96
|
-
// 403: the token is valid but access was denied, so refreshing the same
|
|
97
|
-
// credential can't help — rotate straight through the sibling pool.
|
|
98
|
-
if (status === 403) return true;
|
|
99
96
|
const message = error instanceof Error ? error.message : typeof error === "string" ? error : undefined;
|
|
100
|
-
|
|
97
|
+
// A 403 normally means a valid token lacks access, so rotate through
|
|
98
|
+
// siblings. A concurrency-cap 403 is transient instead; do not burn a
|
|
99
|
+
// sibling before the caller's backoff layer can retry it.
|
|
100
|
+
const isForbidden =
|
|
101
|
+
status === 403 ||
|
|
102
|
+
(status === undefined && message !== undefined && extractHttpStatusFromError({ message }) === 403);
|
|
103
|
+
if (isForbidden && !isConcurrencyCapExclusion(status, message)) return true;
|
|
101
104
|
return isUsageLimitOutcome(status, message);
|
|
102
105
|
}
|
|
103
106
|
|