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

Function _probeAccountImpl

src/auth.js:1654–1806  ·  view source on GitHub ↗
(account, { allowLsStart = true } = {})

Source from the content-addressed store, hash-verified

1652}
1653
1654async function _probeAccountImpl(account, { allowLsStart = true } = {}) {
1655 let accountMaintenanceToken = null;
1656 let lsMaintenanceToken = null;
1657 try {
1658 const { beginLsMaintenanceUse } = await import('./langserver.js');
1659 const preAdmission = getLsAdmissionForAccount(account.id);
1660 if (!allowLsStart) {
1661 const skipped = residentProbeSkip(account, preAdmission);
1662 if (skipped) return skipped;
1663 }
1664 if (preAdmission.reason === 'already_running' && preAdmission.port) {
1665 accountMaintenanceToken = beginAccountMaintenance(account);
1666 lsMaintenanceToken = beginLsMaintenanceUse(preAdmission.port);
1667 if (!lsMaintenanceToken) {
1668 endAccountMaintenance(accountMaintenanceToken);
1669 accountMaintenanceToken = null;
1670 return {
1671 skipped: true,
1672 reason: 'ls_not_idle_resident',
1673 tier: account.tier || 'unknown',
1674 capabilities: account.capabilities || {},
1675 admission: preAdmission,
1676 };
1677 }
1678 }
1679
1680 // ── Step 1: authoritative tier via GetUserStatus ──
1681 const status = await fetchUserStatus(account.id, { allowLsStart });
1682
1683 const { WindsurfClient } = await import('./client.js');
1684 const { getModelInfo } = await import('./models.js');
1685 const { ensureLs, getLsFor } = await import('./langserver.js');
1686
1687 const proxy = getEffectiveProxy(account.id) || null;
1688 if (!allowLsStart) {
1689 const skipped = residentProbeSkip(account, getLsAdmissionForAccount(account.id));
1690 if (skipped) return skipped;
1691 }
1692 if (allowLsStart) await ensureLs(proxy);
1693 const ls = getLsFor(proxy);
1694 if (!ls) { log.error(`No LS available for account ${account.id}`); return null; }
1695 const port = ls.port;
1696 const csrf = ls.csrfToken;
1697
1698 // ── Step 2: canary probe, skipping models already classified by GetUserStatus ──
1699 // When allowlist is available we only need to probe UID-only models (no enum,
1700 // so server can't include them in allowlist) to get their actual status.
1701 const needsProbe = PROBE_CANARIES.filter(key => {
1702 const info = getModelInfo(key);
1703 if (!info) return false;
1704 // If GetUserStatus already gave us a definitive answer, skip.
1705 if (status && info.enumValue > 0) {
1706 const cap = account.capabilities?.[key];
1707 if (cap && cap.reason === 'user_status') return false;
1708 if (cap && cap.reason === 'not_entitled') return false;
1709 }
1710 return true;
1711 });

Callers 1

probeAccountFunction · 0.85

Calls 15

cascadeChatMethod · 0.95
rawGetChatMessageMethod · 0.95
getEffectiveProxyFunction · 0.90
safeAccountRefFunction · 0.90
getLsAdmissionForAccountFunction · 0.85
residentProbeSkipFunction · 0.85
beginAccountMaintenanceFunction · 0.85
beginLsMaintenanceUseFunction · 0.85
endAccountMaintenanceFunction · 0.85
fetchUserStatusFunction · 0.85
getModelInfoFunction · 0.85
updateCapabilityFunction · 0.85

Tested by

no test coverage detected