MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / prefetchFastModeStatus

Function prefetchFastModeStatus

source code/utils/fastMode.ts:409–534  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

407}
408
409export async function prefetchFastModeStatus(): Promise<void> {
410 // Skip network requests if nonessential traffic is disabled
411 if (isEssentialTrafficOnly()) {
412 return
413 }
414
415 if (!isFastModeEnabled()) {
416 return
417 }
418
419 if (inflightPrefetch) {
420 logForDebugging(
421 'Fast mode prefetch in progress, returning in-flight promise',
422 )
423 return inflightPrefetch
424 }
425
426 // Service key OAuth sessions lack user:profile scope → endpoint 403s.
427 // Resolve orgStatus from cache and bail before burning the throttle window.
428 // API key auth is unaffected.
429 const apiKey = getAnthropicApiKey()
430 const hasUsableOAuth =
431 getClaudeAIOAuthTokens()?.accessToken && hasProfileScope()
432 if (!hasUsableOAuth && !apiKey) {
433 const isAnt = process.env.USER_TYPE === 'ant'
434 const cachedEnabled = getGlobalConfig().penguinModeOrgEnabled === true
435 orgStatus =
436 isAnt || cachedEnabled
437 ? { status: 'enabled' }
438 : { status: 'disabled', reason: 'preference' }
439 return
440 }
441
442 const now = Date.now()
443 if (now - lastPrefetchAt < PREFETCH_MIN_INTERVAL_MS) {
444 logForDebugging('Skipping fast mode prefetch, fetched recently')
445 return
446 }
447 lastPrefetchAt = now
448
449 const fetchWithCurrentAuth = async (): Promise<FastModeResponse> => {
450 const currentTokens = getClaudeAIOAuthTokens()
451 const auth =
452 currentTokens?.accessToken && hasProfileScope()
453 ? { accessToken: currentTokens.accessToken }
454 : apiKey
455 ? { apiKey }
456 : null
457 if (!auth) {
458 throw new Error('No auth available')
459 }
460 return fetchFastModeStatus(auth)
461 }
462
463 async function doFetch(): Promise<void> {
464 try {
465 let status: FastModeResponse
466 try {

Callers 2

runFunction · 0.85
callFunction · 0.85

Calls 7

isEssentialTrafficOnlyFunction · 0.85
isFastModeEnabledFunction · 0.85
logForDebuggingFunction · 0.85
getAnthropicApiKeyFunction · 0.85
getGlobalConfigFunction · 0.85
doFetchFunction · 0.85
hasProfileScopeFunction · 0.70

Tested by

no test coverage detected