OmniRoute/scripts/check-t11-any-budget.mjs
Diego Rodrigues de Sa e Souza 1442c47bbb
chore(release): v3.5.6 — email masking, model toggle, OpenRouter registries & bug fixes (#1080)
* fix(minimax): switch auth from x-api-key to Authorization Bearer (#1076)

Integrated into release/v3.5.6 — MiniMax auth fix with authHeader consistency normalization

* feat(CI,i18n): autogenerate language files + Add missing strings (#1071)

Integrated into release/v3.5.6 — i18n translations for memory, skills, and missing keys across 31 languages

* fix(ci): restore i18n continue-on-error, remove auto-commit race condition

* fix(husky): load nvm in hooks for VS Code compatibility

* fix(husky): gracefully skip hooks when npm is not in PATH

* fix: convert OpenAI function tool_choice to Claude tool format (#1072)

* fix: prevent EPIPE feedback loop filling logs at GB/s (#1006)

* fix: fallback to native fetch when undici dispatcher fails (#1054)

* fix: improve Qoder PAT validation with actionable error messages (#966)

- Add QODER_PERSONAL_ACCESS_TOKEN env var fallback for both validation and execution
- Pre-flight ping check to diagnose connectivity issues (Docker/proxy)
- Detect encrypted auth blobs from ~/.qoder/.auth/user and guide to website PAT
- Clear error messages for auth failures with link to integrations page
- Treat non-auth 4xx as auth-pass (request format issue, not token issue)
- Update tests to cover new validation paths (23 tests, all passing)

* feat: Improve the Chinese translation (#1079)

Integrated into release/v3.5.6

* chore(release): v3.5.6 — i18n updates and credential security fixes

* fix(ci): resolve e2e and docs-sync pipeline failures

* fix(security): bump next to 16.2.3 to resolve SNYK-JS-NEXT-15954202

* fix: guard Memory/Cache UI against null toLocaleString crash (#1083)

* fix: translate OpenAI tool_choice type 'function' to Claude 'tool' format (#1072)

* fix: pass custom baseUrl in provider API key validation (#1078)

* docs: update CHANGELOG with v3.5.6 bug fixes and security patches

* docs: rewrite implement-features workflow with 5-phase harvest-research-report-plan-execute pipeline

* docs: organize _ideia/ into viable/defer/notfit + add Phase 2.5 auto-response workflow

* docs: implementation plans for #1025, #750, #960, #1046 + close already-implemented #833, #973, #982

* feat: mask email addresses in dashboard for privacy (#1025)

* feat: add OpenRouter and GitHub to embedding/image provider registries (#960)

* feat: add model visibility toggle and search filter to provider page (#750)

* docs: move implemented features to notfit, update task plans status

* chore: untrack _ideia/ and _tasks/ from git — private/internal only

* chore(release): bump to v3.5.6 — changelog, docs, version sync & any-budget fix

* fix: remove explicit .ts extension in qoderCli import that caused 500 error in production build

---------

Co-authored-by: Jean Brito <jeanfbrito@gmail.com>
Co-authored-by: zenobit <zenobit@disroot.org>
Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
Co-authored-by: Ethan Hunt <136065060+only4copilot@users.noreply.github.com>
2026-04-09 15:55:59 -03:00

133 lines
6.5 KiB
JavaScript

#!/usr/bin/env node
import fs from "node:fs";
import path from "node:path";
const cwd = process.cwd();
/**
* T11 Phase-A budget:
* keep explicit `any` at zero in files already hardened.
*/
const budget = [
{ file: "src/app/api/settings/proxy/route.ts", maxAny: 0 },
{ file: "src/app/api/settings/proxy/test/route.ts", maxAny: 0 },
{ file: "src/shared/components/OAuthModal.tsx", maxAny: 0 },
{ file: "open-sse/translator/index.ts", maxAny: 0 },
{ file: "open-sse/translator/registry.ts", maxAny: 0 },
// Freeze legacy hot spots to avoid any-regression while strict migration continues.
{ file: "src/lib/db/apiKeys.ts", maxAny: 0 },
{ file: "src/lib/db/cliToolState.ts", maxAny: 0 },
{ file: "src/lib/db/encryption.ts", maxAny: 0 },
{ file: "src/lib/db/prompts.ts", maxAny: 0 },
{ file: "src/lib/db/providers.ts", maxAny: 0 },
{ file: "src/lib/db/settings.ts", maxAny: 0 },
{ file: "open-sse/config/providerRegistry.ts", maxAny: 0 },
{ file: "open-sse/config/providerModels.ts", maxAny: 0 },
{ file: "open-sse/mcp-server/audit.ts", maxAny: 0 },
{ file: "open-sse/mcp-server/server.ts", maxAny: 0 },
{ file: "open-sse/mcp-server/tools/advancedTools.ts", maxAny: 0 },
{ file: "open-sse/services/signatureCache.ts", maxAny: 0 },
{ file: "open-sse/services/comboMetrics.ts", maxAny: 0 },
{ file: "open-sse/services/sessionManager.ts", maxAny: 0 },
{ file: "open-sse/services/provider.ts", maxAny: 0 },
{ file: "open-sse/services/contextManager.ts", maxAny: 0 },
{ file: "open-sse/services/comboConfig.ts", maxAny: 0 },
{ file: "open-sse/services/accountSelector.ts", maxAny: 0 },
{ file: "open-sse/services/wildcardRouter.ts", maxAny: 0 },
{ file: "open-sse/services/rateLimitSemaphore.ts", maxAny: 0 },
{ file: "open-sse/services/roleNormalizer.ts", maxAny: 0 },
{ file: "open-sse/services/usage.ts", maxAny: 0 },
{ file: "open-sse/services/rateLimitManager.ts", maxAny: 0 },
{ file: "open-sse/services/tokenRefresh.ts", maxAny: 0 },
{ file: "open-sse/services/backgroundTaskDetector.ts", maxAny: 0 },
{ file: "open-sse/services/accountFallback.ts", maxAny: 0 },
{ file: "open-sse/handlers/responseSanitizer.ts", maxAny: 0 },
{ file: "open-sse/handlers/responseTranslator.ts", maxAny: 0 },
{ file: "open-sse/utils/stream.ts", maxAny: 0 },
{ file: "open-sse/translator/request/openai-responses.ts", maxAny: 0 },
{ file: "open-sse/executors/base.ts", maxAny: 0 },
{ file: "open-sse/executors/kiro.ts", maxAny: 0 },
{ file: "open-sse/executors/cursor.ts", maxAny: 0 },
{ file: "open-sse/executors/qoder.ts", maxAny: 0 },
{ file: "open-sse/utils/comfyuiClient.ts", maxAny: 0 },
{ file: "open-sse/utils/tlsClient.ts", maxAny: 0 },
{ file: "open-sse/utils/proxyFetch.ts", maxAny: 0 },
{ file: "open-sse/utils/error.ts", maxAny: 0 },
{ file: "open-sse/translator/request/openai-to-gemini.ts", maxAny: 0 },
{ file: "open-sse/translator/request/antigravity-to-openai.ts", maxAny: 0 },
{ file: "open-sse/translator/request/claude-to-openai.ts", maxAny: 0 },
{ file: "open-sse/handlers/audioTranscription.ts", maxAny: 0 },
{ file: "open-sse/handlers/sseParser.ts", maxAny: 0 },
{ file: "open-sse/handlers/chatCore.ts", maxAny: 0 },
{ file: "open-sse/config/codexInstructions.ts", maxAny: 0 },
{ file: "open-sse/config/imageRegistry.ts", maxAny: 0 },
{ file: "open-sse/config/registryUtils.ts", maxAny: 0 },
{ file: "open-sse/executors/antigravity.ts", maxAny: 0 },
{ file: "open-sse/executors/default.ts", maxAny: 0 },
{ file: "open-sse/handlers/audioSpeech.ts", maxAny: 0 },
{ file: "open-sse/handlers/embeddings.ts", maxAny: 0 },
{ file: "open-sse/handlers/imageGeneration.ts", maxAny: 0 },
{ file: "open-sse/handlers/moderations.ts", maxAny: 0 },
{ file: "open-sse/handlers/rerank.ts", maxAny: 0 },
{ file: "open-sse/handlers/responsesHandler.ts", maxAny: 0 },
{ file: "open-sse/mcp-server/__tests__/advancedTools.test.ts", maxAny: 0 },
{ file: "open-sse/mcp-server/__tests__/essentialTools.test.ts", maxAny: 0 },
{ file: "open-sse/services/combo.ts", maxAny: 0 },
{ file: "open-sse/services/thinkingBudget.ts", maxAny: 0 },
{ file: "open-sse/translator/helpers/geminiHelper.ts", maxAny: 0 },
{ file: "open-sse/translator/helpers/openaiHelper.ts", maxAny: 0 },
{ file: "open-sse/translator/helpers/responsesApiHelper.ts", maxAny: 0 },
{ file: "open-sse/translator/request/claude-to-gemini.ts", maxAny: 0 },
{ file: "open-sse/translator/request/gemini-to-openai.ts", maxAny: 0 },
{ file: "open-sse/translator/request/openai-to-claude.ts", maxAny: 1 }, // 1 = string literal "any" (Claude tool_choice value, not a TS type) — #1072
{ file: "open-sse/translator/request/openai-to-cursor.ts", maxAny: 0 },
{ file: "open-sse/translator/request/openai-to-kiro.ts", maxAny: 0 },
{ file: "open-sse/translator/response/claude-to-openai.ts", maxAny: 0 },
{ file: "open-sse/translator/response/gemini-to-openai.ts", maxAny: 0 },
{ file: "open-sse/translator/response/kiro-to-openai.ts", maxAny: 0 },
{ file: "open-sse/translator/response/openai-responses.ts", maxAny: 0 },
{ file: "open-sse/translator/response/openai-to-antigravity.ts", maxAny: 0 },
{ file: "open-sse/utils/bypassHandler.ts", maxAny: 0 },
{ file: "open-sse/utils/logger.ts", maxAny: 0 },
{ file: "open-sse/utils/networkProxy.ts", maxAny: 0 },
{ file: "open-sse/utils/ollamaTransform.ts", maxAny: 0 },
{ file: "open-sse/utils/proxyDispatcher.ts", maxAny: 0 },
{ file: "open-sse/utils/requestLogger.ts", maxAny: 0 },
{ file: "open-sse/utils/streamHandler.ts", maxAny: 0 },
{ file: "open-sse/utils/usageTracking.ts", maxAny: 0 },
];
const anyRegex = /\bany\b/g;
let hasFailure = false;
for (const item of budget) {
const absolutePath = path.resolve(cwd, item.file);
if (!fs.existsSync(absolutePath)) {
console.error(`[t11:any-budget] FAIL - file not found: ${item.file}`);
hasFailure = true;
continue;
}
const content = fs.readFileSync(absolutePath, "utf8");
// Remove block and line comments to avoid false positives with the word "any" in comments
let cleanContent = content.replace(/\/\*[\s\S]*?\*\//g, "");
cleanContent = cleanContent.replace(/\/\/.*$/gm, "");
const matches = cleanContent.match(anyRegex);
const count = matches ? matches.length : 0;
const status = count <= item.maxAny ? "OK" : "FAIL";
if (status === "FAIL") {
hasFailure = true;
}
console.log(
`[t11:any-budget] ${status} - ${item.file} (explicit any: ${count}, budget: ${item.maxAny})`
);
}
if (hasFailure) {
process.exit(1);
}
console.log("[t11:any-budget] PASS - explicit any budget respected.");