| 654 | // google-auth-library throws plain Error (no typed name like AWS's |
| 655 | // CredentialsProviderError). Match common SDK-level credential-failure messages. |
| 656 | function isGoogleAuthLibraryCredentialError(error: unknown): boolean { |
| 657 | if (!(error instanceof Error)) return false |
| 658 | const msg = error.message |
| 659 | return ( |
| 660 | msg.includes('Could not load the default credentials') || |
| 661 | msg.includes('Could not refresh access token') || |
| 662 | msg.includes('invalid_grant') |
| 663 | ) |
| 664 | } |
| 665 | |
| 666 | function isVertexAuthError(error: unknown): boolean { |
| 667 | if (isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX)) { |