Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
const schedulerSource = fs.readFileSync(
new URL("../../src/lib/credentialHealth/scheduler.ts", import.meta.url),
"utf8"
);
function getSweepConnectionSelection(): string {
const start = schedulerSource.indexOf("export async function sweep(): Promise<void>");
assert.notEqual(start, -1, "credential-health sweep must exist");
const end = schedulerSource.indexOf(
"\n if (connections.length === 0) return;",
start
);
assert.notEqual(end, -1, "credential-health connection-selection block must exist");
return schedulerSource.slice(start, end);
}
test("#9180 credential-health sweep queries active connections only", () => {
const selection = getSweepConnectionSelection();
assert.match(
selection,
/getProviderConnections\(\{\s*isActive:\s*true\s*\}\)/,
"the scheduler must request only active provider connections"
);
assert.doesNotMatch(
selection,
/getProviderConnections\(\{\s*\}\)/,
"the scheduler must not load disabled connections through an unfiltered query"
);
});
test("#9180 active-only selection retains API-key and OAuth scope", () => {
const selection = getSweepConnectionSelection();
assert.match(
selection,
/conn\.authType === "apikey"/,
"API-key connections must remain eligible"
);
assert.match(
selection,
/conn\.authType === "oauth"/,
"OAuth connections must remain eligible"
);
});