implement wp testing

This commit is contained in:
southseact-3d
2026-02-08 19:27:26 +00:00
parent 541b6bc946
commit 39136e863f
16 changed files with 954 additions and 8 deletions

View File

@@ -15220,6 +15220,15 @@ async function handleNewMessage(req, res, sessionId, userId) {
const friendlyRemaining = allowance.remaining > 0 ? `${allowance.remaining.toLocaleString()} remaining` : 'no remaining balance';
return sendJson(res, 402, { error: `You have reached your token allowance (${friendlyRemaining}). Upgrade or add a boost.`, allowance });
}
// If this request will trigger an external WP test, enforce plan limits immediately and return a friendly upgrade prompt
if (body.isProceedWithBuild && body.externalTestingEnabled === true) {
const user = findUserById(session.userId);
const limitCheck = canUseExternalTesting(session.userId, userPlan, user?.unlimitedUsage === true);
if (!limitCheck.allowed) {
return sendJson(res, 402, { error: 'External WP CLI testing limit reached for your plan. Upgrade to run more tests.', externalTesting: limitCheck.summary, upgradeUrl: '/topup' });
}
}
const cli = normalizeCli(body.cli || session.cli);
const now = new Date().toISOString();
const message = { id: randomUUID(), role: 'user', content, displayContent, model, cli, status: 'queued', createdAt: now, updatedAt: now, opencodeTokensUsed: null };
@@ -17210,6 +17219,7 @@ async function bootstrap() {
await loadProviderLimits();
await loadProviderUsage();
await loadTokenUsage();
await loadExternalTestUsage();
await loadTopupSessions();
await loadPendingTopups();
await loadPaygSessions();