()
| 218 | } |
| 219 | |
| 220 | export async function checkQuotaStatus(): Promise<void> { |
| 221 | // Skip network requests if nonessential traffic is disabled |
| 222 | if (isEssentialTrafficOnly()) { |
| 223 | return |
| 224 | } |
| 225 | |
| 226 | // Check if we should process rate limits (real subscriber or mock testing) |
| 227 | if (!shouldProcessRateLimits(isClaudeAISubscriber())) { |
| 228 | return |
| 229 | } |
| 230 | |
| 231 | // In non-interactive mode (-p), the real query follows immediately and |
| 232 | // extractQuotaStatusFromHeaders() will update limits from its response |
| 233 | // headers (claude.ts), so skip this pre-check API call. |
| 234 | if (getIsNonInteractiveSession()) { |
| 235 | return |
| 236 | } |
| 237 | |
| 238 | try { |
| 239 | // Make a minimal request to check quota |
| 240 | const raw = await makeTestQuery() |
| 241 | |
| 242 | // Update limits based on the response |
| 243 | extractQuotaStatusFromHeaders(raw.headers) |
| 244 | } catch (error) { |
| 245 | if (error instanceof APIError) { |
| 246 | extractQuotaStatusFromError(error) |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * Check if early warning should be triggered based on surpassed-threshold header. |
no test coverage detected