MCPcopy Create free account
hub / github.com/dwgx/WindsurfAPI / getAvailableModelsForAccount

Function getAvailableModelsForAccount

src/auth.js:566–586  ·  view source on GitHub ↗
(account)

Source from the content-addressed store, hash-verified

564
565/** List of model keys this account is currently allowed to call. */
566export function getAvailableModelsForAccount(account) {
567 const blocked = new Set(account.blockedModels || []);
568 const tierModels = getTierModels(account.tier || 'unknown');
569 // Manual tier override or no GetUserStatus yet → tier static table.
570 if (account.tierManual || !account.userStatusLastFetched || !account.capabilities) {
571 return tierModels.filter(m => !blocked.has(m));
572 }
573 // After GetUserStatus: per-account allowlist is authoritative for every
574 // enum-keyed catalog entry; UID-only entries (no enum) fall back to tier.
575 const allowed = [];
576 for (const [key, info] of Object.entries(MODELS)) {
577 if (blocked.has(key)) continue;
578 if (info.enumValue && info.enumValue > 0) {
579 const cap = account.capabilities[key];
580 if (cap?.reason === 'user_status' && cap.ok === true) allowed.push(key);
581 } else if (tierModels.includes(key)) {
582 allowed.push(key);
583 }
584 }
585 return allowed;
586}
587
588/**
589 * Set account status (active, disabled, error).

Callers 2

publicAccountFunction · 0.85

Calls 2

getTierModelsFunction · 0.90
pushMethod · 0.80

Tested by

no test coverage detected