mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-14 10:52:17 +03:00
Three related things that genuinely belong together: the registry and suffix splitter not knowing Astra while the live catalog serves it, the Codex client pin Astra requires, and dropping `next/font/google` so a production image build does not reach fonts.googleapis.com. --- Validated in one consolidated worktree cut from `release/v3.8.51`, boarded with the other 19 PRs of this batch. Two in-batch conflicts, both additive and resolved by keeping each side: the `ENVIRONMENT.md` table (#13035 + #13011) and the `chatHelpers.ts` import block (#12975 on the tip + #13017). - `typecheck:core` clean; `check:dashboard-typecheck` OK (206 pre-existing, within baseline); `check:changelog-integrity` OK; `check:docs-counts` migrations ✓ - complexity 2816 / baseline 3218 and cognitive-complexity 1271 / baseline 1437 — both under baseline - 531 of 532 focused assertions green across the batch's 46 test files - `check-file-size` rebaselined for the batch's real growth (annotation `_rebaseline_2026_09_11_mergebatch_v3851_houminxi`, landed on #13038), attributed per PR The single red is **not this batch**: `tests/unit/combo/quota-weighted-strategy.test.ts` → "A/B isolation: 7 hard-empty + 2 at 0.5% + 1 at 40%, floor=1" asserts an order between two connections of identical weight and flakes on the pure tip too — 2 failures in 4 runs at `origin/release/v3.8.51` with nothing from this batch applied. ⚠️ base-red inherited: #12732 — `Docs Gates`, `Merge integrity`, `No new ESLint warnings`, `Unit Tests fast-path` and `Fast Quality Gates` reproduce on the pure tip (provider count 356 vs the 358 the modules define, SKILL.md drift, and `open-sse/utils/stream.ts` at 3115 > frozen 3098, untouched here). Thanks @HouMinXi — the live evidence on these (X500 logs, `storage.sqlite` state, real `/v1/models` probes, the 36-minute outage write-up) is what let a 20-PR batch be reviewed as a unit.
110 lines
4.3 KiB
TypeScript
110 lines
4.3 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { getModelsByProviderId } from "../../open-sse/config/providerModels.ts";
|
|
import { CodexExecutor } from "../../open-sse/executors/codex.ts";
|
|
import { openaiToOpenAIResponsesRequest } from "../../open-sse/translator/request/openai-responses/toResponses.ts";
|
|
import { getModelSpec } from "../../src/shared/constants/modelSpecs.ts";
|
|
import { getPricingForModel } from "../../src/shared/constants/pricing.ts";
|
|
import { getCodexFastCostMultiplier } from "../../src/lib/usage/costCalculator.ts";
|
|
|
|
const MODEL = "gpt-6-astra";
|
|
const EFFORTS = ["ultra", "max", "xhigh", "high", "medium", "low"] as const;
|
|
|
|
test.after(async () => {
|
|
const { resetDbInstance } = await import("../../src/lib/db/core.ts");
|
|
resetDbInstance();
|
|
});
|
|
|
|
test("Codex exposes Astra and its effort variants with live OAuth limits", () => {
|
|
const ids = [MODEL, ...EFFORTS.map((effort) => `${MODEL}-${effort}`)];
|
|
for (const provider of ["codex", "codex-app-server"]) {
|
|
const models = getModelsByProviderId(provider);
|
|
assert.deepEqual(
|
|
models.filter((model) => model.id.startsWith(MODEL)).map((model) => model.id),
|
|
ids
|
|
);
|
|
for (const id of ids) {
|
|
const model = models.find((entry) => entry.id === id);
|
|
assert.ok(model, `${provider}/${id}`);
|
|
assert.equal(model.contextLength, 872000);
|
|
assert.equal(model.maxInputTokens, 872000);
|
|
assert.equal(model.maxOutputTokens, 128000);
|
|
assert.equal(model.targetFormat, "openai-responses");
|
|
assert.equal(model.toolCalling, true);
|
|
assert.equal(model.supportsReasoning, true);
|
|
assert.equal(model.supportsVision, true);
|
|
assert.equal(model.supportsXHighEffort, true);
|
|
}
|
|
assert.deepEqual(
|
|
models.slice(0, ids.length).map((model) => model.id),
|
|
ids
|
|
);
|
|
}
|
|
});
|
|
|
|
test("Astra specs retain the public context window separately from Codex limits", () => {
|
|
const spec = getModelSpec(MODEL);
|
|
assert.equal(spec?.contextWindow, 1050000);
|
|
assert.equal(spec?.maxOutputTokens, 128000);
|
|
assert.equal(spec?.supportsTools, true);
|
|
assert.equal(spec?.supportsVision, true);
|
|
assert.equal(spec?.supportsThinking, true);
|
|
});
|
|
|
|
test("Astra effort aliases reach Codex as the base model and supported wire effort", () => {
|
|
const executor = new CodexExecutor();
|
|
for (const effort of EFFORTS) {
|
|
const model = `${MODEL}-${effort}`;
|
|
const result = executor.transformRequest(model, { model, input: [] }, false, {
|
|
requestEndpointPath: "/responses",
|
|
});
|
|
assert.equal(result.model, MODEL, effort);
|
|
assert.equal(result.reasoning.effort, effort === "ultra" ? "max" : effort, effort);
|
|
}
|
|
});
|
|
|
|
test("Chat-to-Codex translation preserves Astra max reasoning", () => {
|
|
const translated = openaiToOpenAIResponsesRequest(
|
|
MODEL,
|
|
{ model: MODEL, messages: [{ role: "user", content: "test" }], reasoning_effort: "max" },
|
|
true,
|
|
{}
|
|
);
|
|
const result = new CodexExecutor().transformRequest(MODEL, translated, true, {
|
|
requestEndpointPath: "/chat/completions",
|
|
});
|
|
assert.equal(result.model, MODEL);
|
|
assert.equal(result.reasoning.effort, "max");
|
|
});
|
|
|
|
test("Astra parenthesized effort overrides preserve the reasoning summary", () => {
|
|
for (const effort of ["max", "ultra"]) {
|
|
const model = `${MODEL}(${effort})`;
|
|
const result = new CodexExecutor().transformRequest(
|
|
model,
|
|
{ model, input: [], reasoning: { effort: "low", summary: "detailed" } },
|
|
false,
|
|
{ requestEndpointPath: "/responses" }
|
|
);
|
|
assert.equal(result.model, MODEL);
|
|
assert.equal(result.reasoning.effort, "max");
|
|
assert.equal(result.reasoning.summary, "detailed");
|
|
}
|
|
});
|
|
|
|
test("Astra Codex pricing and Fast multiplier match the Codex credit rate card", () => {
|
|
for (const model of [MODEL, ...EFFORTS.map((effort) => `${MODEL}-${effort}`)]) {
|
|
const pricing = getPricingForModel("cx", model);
|
|
assert.ok(pricing, model);
|
|
assert.equal(pricing.input, 10);
|
|
assert.equal(pricing.cached, 1);
|
|
assert.equal(pricing.output, 50);
|
|
assert.equal(pricing.reasoning, 50);
|
|
assert.equal(getCodexFastCostMultiplier("codex", model, "priority"), 2.5);
|
|
assert.equal(getCodexFastCostMultiplier("cx", model, "fast"), 2.5);
|
|
assert.equal(getCodexFastCostMultiplier("codex", model, "default"), 1);
|
|
}
|
|
assert.equal(getCodexFastCostMultiplier("openai", MODEL, "priority"), 1);
|
|
});
|