mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-25 16:42:16 +03:00
Second base-red batch from the release pre-flight, measured on the .113 with a
clean npm ci (the devbox tree resolves eslint-plugin-react-hooks 7.1.1 from a
stray pnpm store instead of the lockfile 7.0.1 and reports 925 phantom errors).
Provider count 350 -> 352, one root cause behind three reds. Two providers
landed this cycle (volcengine-agent-plan, volcengine-coding-plan) without
regenerating the artifacts that quote the count:
- docs/reference/PROVIDER_REFERENCE.md regenerated (gen:provider-reference).
- README / AGENTS / llm.txt (+42 mirrors) / package.json description / 4 SVG
diagrams updated, including the section heading AND the anchor that links to
it, so the link does not break.
- tests/snapshots/provider/translate-path.json regenerated. The diff is purely
additive: 46 insertions, 0 deletions, exactly the two new providers.
GLM effort tiers. #11415 added the explicit glm-5.3-max tier and left two
sibling vitest specs pinning the old 16-model inventory and an empty tier list
for it. Aligned to the shipped contract (inventory order matches glmProvider.ts;
glm-5.3-max declares ["max"]).
Test-masking. Four assert reductions surfaced once the deleted-file signal was
resolved. Three are legitimate and are allowlisted with their reasoning:
#11355 inverted the startup-cooldown contract (preserve future quota cooldowns),
#11280 replaced two unrolled hops with a 3-hop loop that asserts MORE, and the
Gemini 3.5 Flash retirement removed the models those capability asserts described.
The fourth was real masking: #10960 rewrote the oneproxy status test to install a
stream mock, immediately overwrite it with a passthrough to the real fetch, and
assert `calls.length >= 0` — always true. Restored to assert what the test name
claims (the JSON-RPC tools/call carries omniroute_oneproxy_stats and its result
reaches the caller), with a scope note that it pins the MCP client contract
rather than the commander wiring.
Also allowlists the Gemini 3.5 Flash test deletion as _deletedWithReplacement
(the model was retired by 2764812ee4; gemini-models-parser.test.ts pins the new
"excluded from the parsed list" contract), and rebaselines bundleSize
8045 -> 8461 with per-entry measurements — every entrypoint stays far below its
absolute budget.
111 lines
4.7 KiB
TypeScript
111 lines
4.7 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { makeMcpResp, makeMcpStreamFetch } from "./helpers/mcpStreamMock.ts";
|
|
|
|
function makeResp(data: unknown, status = 200) {
|
|
return makeMcpResp(data, status) as any;
|
|
}
|
|
|
|
function makeCmd(output = "json") {
|
|
return { optsWithGlobals: () => ({ output, quiet: output !== "table" }) };
|
|
}
|
|
|
|
test("oneproxy status chama omniroute_oneproxy_stats via MCP", async () => {
|
|
// #10960 rewrote this test around the shared stream mock but left it asserting
|
|
// `calls.length >= 0` — always true — while the mock it installed was
|
|
// immediately overwritten by a passthrough to the real fetch. Restored to
|
|
// assert what the test name claims: the JSON-RPC tools/call carries the
|
|
// omniroute_oneproxy_stats tool name and its result reaches the caller.
|
|
// Scope note: like the pre-#10960 version, this drives mcpCallTool directly
|
|
// rather than the `oneproxy status` commander action, so it pins the MCP
|
|
// client contract, not the subcommand wiring (covered by the import test below).
|
|
const toolCalls: Array<Record<string, unknown>> = [];
|
|
const origFetch = globalThis.fetch;
|
|
const streamFetch = makeMcpStreamFetch({ toolResult: { poolSize: 10, activeProxies: 8 } });
|
|
globalThis.fetch = (async (url: string | URL, init?: any) => {
|
|
const parsed = init?.body ? JSON.parse(init.body) : {};
|
|
if (parsed.method === "tools/call") toolCalls.push(parsed.params ?? {});
|
|
return streamFetch(url as string, init);
|
|
}) as any;
|
|
|
|
try {
|
|
const { mcpCallTool } = await import("../../bin/cli/mcpClient.mjs");
|
|
const result = await mcpCallTool("omniroute_oneproxy_stats", {});
|
|
assert.deepEqual(result, { poolSize: 10, activeProxies: 8 });
|
|
} finally {
|
|
globalThis.fetch = origFetch;
|
|
}
|
|
|
|
assert.equal(toolCalls.length, 1, "exactly one tools/call must reach the MCP endpoint");
|
|
assert.equal(toolCalls[0].name, "omniroute_oneproxy_stats");
|
|
});
|
|
|
|
test("oneproxy stats passa provider e period para MCP", async () => {
|
|
const origFetch = globalThis.fetch;
|
|
globalThis.fetch = makeMcpStreamFetch({ toolResult: { requests: 5000 } });
|
|
const { mcpCallTool } = await import("../../bin/cli/mcpClient.mjs");
|
|
const result = await mcpCallTool("omniroute_oneproxy_stats", { provider: "openai", period: "24h" });
|
|
globalThis.fetch = origFetch;
|
|
assert.deepEqual(result, { requests: 5000 });
|
|
});
|
|
|
|
test("oneproxy fetch chama omniroute_oneproxy_fetch com count e type", async () => {
|
|
const origFetch = globalThis.fetch;
|
|
globalThis.fetch = makeMcpStreamFetch({ toolResult: { proxies: [{ host: "10.0.0.1", type: "http" }] } });
|
|
const { mcpCallTool } = await import("../../bin/cli/mcpClient.mjs");
|
|
const result = await mcpCallTool("omniroute_oneproxy_fetch", { count: 5, type: "http" });
|
|
globalThis.fetch = origFetch;
|
|
assert.equal((result as any).proxies[0].host, "10.0.0.1");
|
|
assert.equal((result as any).proxies[0].type, "http");
|
|
});
|
|
|
|
test("oneproxy rotate chama omniroute_oneproxy_rotate com provider", async () => {
|
|
const origFetch = globalThis.fetch;
|
|
globalThis.fetch = makeMcpStreamFetch({ toolResult: { rotated: true, newProxy: "10.0.0.2" } });
|
|
const { mcpCallTool } = await import("../../bin/cli/mcpClient.mjs");
|
|
const result = await mcpCallTool("omniroute_oneproxy_rotate", { provider: "anthropic" });
|
|
globalThis.fetch = origFetch;
|
|
assert.equal((result as any).rotated, true);
|
|
assert.equal((result as any).newProxy, "10.0.0.2");
|
|
});
|
|
|
|
test("oneproxy config set envia PUT /api/settings/oneproxy", async () => {
|
|
let capturedBody: any = null;
|
|
let capturedUrl = "";
|
|
const origFetch = globalThis.fetch;
|
|
globalThis.fetch = ((url: string, opts: any) => {
|
|
capturedUrl = url;
|
|
if (opts?.body) capturedBody = JSON.parse(opts.body);
|
|
return Promise.resolve(makeResp({ enabled: true, poolSize: 20 }));
|
|
}) as any;
|
|
|
|
await (globalThis.fetch as any)("/api/settings/oneproxy", {
|
|
method: "PUT",
|
|
body: JSON.stringify({ enabled: true, poolSize: 20 }),
|
|
});
|
|
|
|
globalThis.fetch = origFetch;
|
|
assert.ok(capturedUrl.includes("/api/settings/oneproxy"));
|
|
assert.equal(capturedBody.enabled, true);
|
|
assert.equal(capturedBody.poolSize, 20);
|
|
});
|
|
|
|
test("oneproxy pool chama /api/settings/oneproxy?include=pool", async () => {
|
|
let capturedUrl = "";
|
|
const origFetch = globalThis.fetch;
|
|
globalThis.fetch = ((url: string) => {
|
|
capturedUrl = url;
|
|
return Promise.resolve(makeResp({ pool: [] }));
|
|
}) as any;
|
|
|
|
await (globalThis.fetch as any)("/api/settings/oneproxy?include=pool");
|
|
|
|
globalThis.fetch = origFetch;
|
|
assert.ok(capturedUrl.includes("include=pool"));
|
|
});
|
|
|
|
test("oneproxy.mjs pode ser importado sem erro", async () => {
|
|
const mod = await import("../../bin/cli/commands/oneproxy.mjs");
|
|
assert.equal(typeof mod.registerOneProxy, "function");
|
|
});
|