mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 04:12:10 +03:00
* chore(release): open v3.8.10 development cycle Bump 3.8.9 → 3.8.10 across package.json, lockfile, electron, open-sse, and docs/reference/openapi.yaml; add the [3.8.10] CHANGELOG section (root + 41 i18n mirrors) as the integration target for the cycle. Entries land here as work merges into release/v3.8.10; finalized by the release flow. * fix(providers): resolve web provider alias collisions Assign unique aliases to HuggingChat, Kimi Web, and Qwen Web so they no longer shadow primary providers or trigger startup warnings. Add a unit test to enforce provider alias uniqueness and prevent future collisions. Also expand local ignore and VS Code exclude rules for agent, build, and worktree artifacts. * fix(responses): normalize image_url parts across input paths (#3150) Normalize image_url parts across all Responses input paths. Integrated into release/v3.8.10. * fix(api-manager): preserve API key expiration local time (#3146) Preserve API key expiration local time + clear button. Integrated into release/v3.8.10. * Strip previous_response_id for stateless Responses upstreams (#3143) Strip previous_response_id for stateless Responses upstreams (auto/strip/preserve). Integrated into release/v3.8.10. * fix(opencode-plugin): map thinking cap to interleaved in model+combo (#3138) Map caps.thinking to ModelV2.capabilities.interleaved for opencode-plugin. Integrated into release/v3.8.10. * fix(providers): use synced models as fallback for all providers (#3148) Use synced models as authoritative local catalog for all providers (+regression test). Integrated into release/v3.8.10. * fix(qoder): bifurcate validation by token type — PAT→Cosy, regular API key→dashscope (#3149) Bifurcate Qoder validation by token type (PAT→Cosy, regular→dashscope) +regression test. Integrated into release/v3.8.10. * fix(antigravity): dynamic model resolution via MITM alias table (#3144) Dynamic antigravity MITM model resolution in the executor (+bug fix +regression test; DB import dropped from client-reachable config). Integrated into release/v3.8.10. * Feature/batch allow big (#3128) Podman deployment options + larger upload body-size limits (+CONTAINER_HOST docs). Integrated into release/v3.8.10. * fix(fireworks): preserve fully-qualified router/model IDs (#3133) (#3160) Fireworks router IDs (accounts/fireworks/routers/...) were double-prefixed with accounts/fireworks/models/ → upstream 404. Add optional acceptedModelIdPrefixes to the registry entry and skip the prepend when the model already starts with an accepted prefix. Co-authored-by: KooshaPari <KooshaPari@users.noreply.github.com> * fix(llama-cpp): route to configured local baseUrl instead of OpenAI (#3136) (#3161) llama-cpp was missing from the local-provider group in buildUrl(), so it fell through to the OpenAI baseUrl and returned an OpenAI 401. Add the case to resolve the connection's providerSpecificData.baseUrl. Co-authored-by: tjengbudi <tjengbudi@users.noreply.github.com> * fix(t3-chat-web): parse cookies + convexSessionId from stored credential (#3007) (#3162) The executor read credentials.cookies/convexSessionId, but the pipeline only stores the pasted string under apiKey → t3.chat always 400'd. Parse both values from apiKey (fallback accessToken), mirroring validation.ts. Co-authored-by: minhtran162 <minhtran162@users.noreply.github.com> * fix(minimax): stop capping MiniMax-M3 / M2.7 max_tokens at 8192 (#3141) (#3163) MiniMax-M3 had no MODEL_SPECS entry and capitalized MiniMax-M2.7 missed its lowercase spec (case-sensitive lookup) → both fell to the 8192 default cap. Add the M3 spec (512K output), alias the capitalized ids, and make getModelSpec lookups case-insensitive. Co-authored-by: totaltube <totaltube@users.noreply.github.com> * fix(github-copilot): discover model catalog live from api.githubcopilot.com (#3120, #3121) (#3164) The github (Copilot) provider had a static hardcoded catalog with no discovery source, so Import Models never refreshed (#3120) and advertised non-entitled models that 400 on use (#3121). Add a live /models fetch with fallback to the static list. Co-authored-by: gabrielmoreira <gabrielmoreira@users.noreply.github.com> * fix(combo): invalidate nested-combo cache on edits + log DATA_DIR (#3147) (#3165) Editing a combo did not invalidate the 10s nested-combo expansion caches (chat.ts getCombosCachedForChat + chatCore.ts getCombosCached; the exported clearCombosCache was dead code), so a removed nested target/model could be served as a phantom for up to 10s. Wire a shared monotonic combos-cache version in readCache (bumped by invalidateDbCache("combos") on every combo write); both cache layers treat a version mismatch as a miss. Also log the resolved DATA_DIR/SQLITE_FILE absolute path at DB init so the reporter's 'persists across restart + volume wipe' symptom (a multi-replica Docker volume/DATA_DIR mismatch, not a routing bug) is diagnosable from logs. Includes consolidated CHANGELOG entries for #3133/#3136/#3007/#3141/#3120/#3121. Co-authored-by: ViFigueiredo <ViFigueiredo@users.noreply.github.com> * fix(web-tools): parse bare JSON tool calls (#3157) Parse bare JSON tool calls for deepseek-web (#2820) + fuzzy tool-name matching. Integrated into release/v3.8.10. * fix(misc): minor fixes across reasoning cache, account fallback, binary manager (#3177) Misc: ProviderProfile export, DeepSeek reasoning regex, binary guard. Integrated into release/v3.8.10. * fix(kiro): minor OAuth social exchange tweaks (#3176) Kiro social OAuth: optional targetProvider passthrough. Integrated into release/v3.8.10. * deps: bump hono from 4.12.18 to 4.12.23 (#3179) Bump hono to 4.12.23. Integrated into release/v3.8.10. * fix(providerRegistry): update kilocode format and executor (#3166) kilocode: openai format + default executor (matches kilo-gateway) + registry test. Integrated into release/v3.8.10. * feat(metrics): cross-request TTFT and gap latency after tool calls (#3173) Cross-request TTFT + gap-after-tool latency metrics (+test). Integrated into release/v3.8.10. * feat(dashboard): provider stats API endpoint and dashboard page (#3175) Provider stats dashboard + API (SQL moved to db module per Hard Rule #5, +test). Integrated into release/v3.8.10. * fix(usage): sequential+spaced OAuth quota sync, reactive force-refresh, actionable 401 (#3156) Sequential+spaced OAuth quota sync, reactive force-refresh on 401, actionable 401 in UI. Integrated into release/v3.8.10. * fix(healthcheck): per-provider proactive-refresh skip list (rescue short-TTL OAuth) (#3159) Per-provider proactive-refresh skip list (OMNIROUTE_HEALTHCHECK_SKIP_PROVIDERS) to rescue short-TTL OAuth. Integrated into release/v3.8.10. * feat(quota): show OAuth token expiry on provider cards (small, blue, informative) (#3178) Show OAuth token expiry on provider cards (small, blue, informative). Integrated into release/v3.8.10. * fix(providers): empty refresh must not resurface just-cleared synced models (#3181) Empty refresh must not resurface just-cleared synced models (fixes the release-blocking provider-models-route test). Integrated into release/v3.8.10. * chore(release): v3.8.10 — 2026-06-04 (finalize CHANGELOG) --------- Co-authored-by: Wilson <pedbookmed@gmail.com> Co-authored-by: Xiangzhe <32761048+xz-dev@users.noreply.github.com> Co-authored-by: Jan Leon <Jan.gaschler@gmail.com> Co-authored-by: M.M <mr.maatoug@gmail.com> Co-authored-by: Hernan Javier Ardila Sanchez <hjasgr@gmail.com> Co-authored-by: Markus Hartung <mail@hartmark.se> Co-authored-by: KooshaPari <KooshaPari@users.noreply.github.com> Co-authored-by: tjengbudi <tjengbudi@users.noreply.github.com> Co-authored-by: minhtran162 <minhtran162@users.noreply.github.com> Co-authored-by: totaltube <totaltube@users.noreply.github.com> Co-authored-by: gabrielmoreira <gabrielmoreira@users.noreply.github.com> Co-authored-by: ViFigueiredo <ViFigueiredo@users.noreply.github.com> Co-authored-by: PizzaV <103120356+pizzav-xyz@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Nicolas Lorin <androw95220@gmail.com>
356 lines
13 KiB
TypeScript
356 lines
13 KiB
TypeScript
// @ts-nocheck
|
|
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
const { T3ChatWebExecutor, T3_CHAT_BASE } = await import("../../open-sse/executors/t3-chat-web.ts");
|
|
const { getExecutor, hasSpecializedExecutor } = await import("../../open-sse/executors/index.ts");
|
|
|
|
// NOTE: These tests use mocked HTTP transport. The COMPLETION_URL constant in
|
|
// t3-chat-web.ts is a best-guess placeholder. Tests verify executor behavior
|
|
// and OpenAI output format, not the specific endpoint URL.
|
|
// TODO(post-devtools-capture): Update mock URL matchers once endpoint is confirmed.
|
|
|
|
// ─── Registration ────────────────────────────────────────────────────────
|
|
|
|
test("hasSpecializedExecutor returns true for t3-web", () => {
|
|
assert.ok(hasSpecializedExecutor("t3-web"));
|
|
});
|
|
|
|
test("hasSpecializedExecutor returns true for t3chat alias", () => {
|
|
assert.ok(hasSpecializedExecutor("t3chat"));
|
|
});
|
|
|
|
test("getExecutor returns T3ChatWebExecutor for t3-web", () => {
|
|
const exec = getExecutor("t3-web");
|
|
assert.ok(exec instanceof T3ChatWebExecutor);
|
|
});
|
|
|
|
test("getExecutor returns T3ChatWebExecutor for t3chat alias", () => {
|
|
const exec = getExecutor("t3chat");
|
|
assert.ok(exec instanceof T3ChatWebExecutor);
|
|
});
|
|
|
|
test("T3ChatWebExecutor.getProvider() returns t3-web", () => {
|
|
assert.equal(new T3ChatWebExecutor().getProvider(), "t3-web");
|
|
});
|
|
|
|
// ─── Credential validation ───────────────────────────────────────────────
|
|
|
|
test("execute returns 400 with empty credentials", async () => {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.execute({
|
|
model: "gpt-4o",
|
|
body: { messages: [{ role: "user", content: "hi" }] },
|
|
stream: true,
|
|
credentials: {},
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
assert.equal(result.response.status, 400);
|
|
const body = JSON.parse(await result.response.text());
|
|
assert.ok(body.error?.message, "Should have error message");
|
|
});
|
|
|
|
// #3007: credentials arrive as the single pasted string under `apiKey`
|
|
// (fallback `accessToken`) — the old `cookies`/`convexSessionId` object shape
|
|
// was never produced by the credential pipeline, so it must be rejected.
|
|
test("execute returns 400 with legacy cookies/convexSessionId object shape (no apiKey)", async () => {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.execute({
|
|
model: "gpt-4o",
|
|
body: { messages: [{ role: "user", content: "hi" }] },
|
|
stream: true,
|
|
credentials: { cookies: "some-cookie=value", convexSessionId: "abc" },
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
assert.equal(result.response.status, 400);
|
|
const body = JSON.parse(await result.response.text());
|
|
assert.ok(body.error?.message?.length > 0, "Should have error message");
|
|
});
|
|
|
|
test("execute returns 400 with apiKey that has no convex-session-id", async () => {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.execute({
|
|
model: "gpt-4o",
|
|
body: { messages: [{ role: "user", content: "hi" }] },
|
|
stream: true,
|
|
credentials: { apiKey: "sessionToken=value; theme=dark" },
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
assert.equal(result.response.status, 400);
|
|
const body = JSON.parse(await result.response.text());
|
|
assert.ok(body.error?.message?.length > 0, "Should have error message");
|
|
});
|
|
|
|
test("execute returns 400 with empty apiKey string", async () => {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.execute({
|
|
model: "gpt-4o",
|
|
body: { messages: [{ role: "user", content: "hi" }] },
|
|
stream: true,
|
|
credentials: { apiKey: "" },
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
assert.equal(result.response.status, 400);
|
|
});
|
|
|
|
// ─── testConnection ──────────────────────────────────────────────────────
|
|
|
|
test("testConnection returns false with empty credentials", async () => {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.testConnection({});
|
|
assert.equal(result, false);
|
|
});
|
|
|
|
test("testConnection returns false when convex-session-id is missing from apiKey", async () => {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.testConnection({ apiKey: "some-cookie=value" });
|
|
assert.equal(result, false);
|
|
});
|
|
|
|
// ─── API flow helpers ─────────────────────────────────────────────────────
|
|
|
|
function makeValidCreds() {
|
|
// The credential pipeline stores the single pasted string under `apiKey`.
|
|
return {
|
|
apiKey: "t3-auth=session-token-xyz; other=value; convex-session-id=convex-abc123",
|
|
};
|
|
}
|
|
|
|
function mockT3ChatSSEResponse(chunks: string[]) {
|
|
const original = globalThis.fetch;
|
|
const calls: Array<{
|
|
url: string;
|
|
method: string;
|
|
headers: Record<string, string>;
|
|
body: unknown;
|
|
}> = [];
|
|
|
|
globalThis.fetch = async (url, opts) => {
|
|
const urlStr = typeof url === "string" ? url : url.toString();
|
|
calls.push({
|
|
url: urlStr,
|
|
method: opts?.method ?? "GET",
|
|
headers: (opts?.headers as Record<string, string>) ?? {},
|
|
body: opts?.body ? JSON.parse(opts.body as string) : null,
|
|
});
|
|
|
|
const encoder = new TextEncoder();
|
|
const sseData = chunks.map((c) => `data: ${c}\n\n`).join("");
|
|
return new Response(encoder.encode(sseData), {
|
|
status: 200,
|
|
headers: { "Content-Type": "text/event-stream" },
|
|
});
|
|
};
|
|
|
|
return {
|
|
calls,
|
|
restore: () => {
|
|
globalThis.fetch = original;
|
|
},
|
|
};
|
|
}
|
|
|
|
// ─── Mocked streaming flow ───────────────────────────────────────────────
|
|
|
|
test("execute: POSTs to completion URL with Cookie containing convex-session-id (streaming)", async () => {
|
|
const sseChunks = [
|
|
JSON.stringify({ text: "Hello" }),
|
|
JSON.stringify({ text: " world" }),
|
|
JSON.stringify({ done: true }),
|
|
];
|
|
const mock = mockT3ChatSSEResponse(sseChunks);
|
|
|
|
try {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.execute({
|
|
model: "gpt-4o",
|
|
body: { messages: [{ role: "user", content: "Say hello" }] },
|
|
stream: true,
|
|
credentials: makeValidCreds(),
|
|
signal: AbortSignal.timeout(10000),
|
|
});
|
|
|
|
assert.ok(result.response.ok, `Expected 200, got ${result.response.status}`);
|
|
assert.equal(mock.calls.length, 1, "Should make exactly one fetch call");
|
|
|
|
// Verify Cookie header contains convex-session-id (confirmed from live capture:
|
|
// t3.chat sets convex-session-id as a cookie, sent in Cookie header)
|
|
const sentHeaders = mock.calls[0].headers;
|
|
assert.ok(sentHeaders["Cookie"]?.length > 0, "Should send Cookie header");
|
|
assert.ok(
|
|
sentHeaders["Cookie"]?.includes("convex-session-id="),
|
|
"Cookie header should contain convex-session-id"
|
|
);
|
|
} finally {
|
|
mock.restore();
|
|
}
|
|
});
|
|
|
|
test("execute: streaming response contains content, finish_reason stop, and [DONE]", async () => {
|
|
const sseChunks = [
|
|
JSON.stringify({ text: "Hello" }),
|
|
JSON.stringify({ text: " there" }),
|
|
"[DONE]",
|
|
];
|
|
const mock = mockT3ChatSSEResponse(sseChunks);
|
|
|
|
try {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.execute({
|
|
model: "gpt-4o",
|
|
body: { messages: [{ role: "user", content: "hi" }] },
|
|
stream: true,
|
|
credentials: makeValidCreds(),
|
|
signal: AbortSignal.timeout(10000),
|
|
});
|
|
|
|
assert.ok(result.response.ok);
|
|
assert.equal(result.response.headers.get("content-type"), "text/event-stream");
|
|
|
|
const text = await result.response.text();
|
|
assert.ok(text.includes('"content"'), "Should contain content field");
|
|
assert.ok(text.includes('"finish_reason":"stop"'), "Should have finish_reason stop");
|
|
assert.ok(text.includes("[DONE]"), "Should end with [DONE]");
|
|
} finally {
|
|
mock.restore();
|
|
}
|
|
});
|
|
|
|
test("execute: non-streaming response has choices[0].message.content", async () => {
|
|
const sseChunks = [JSON.stringify({ text: "Hello non-stream" }), "[DONE]"];
|
|
const mock = mockT3ChatSSEResponse(sseChunks);
|
|
|
|
try {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.execute({
|
|
model: "gpt-4o",
|
|
body: { messages: [{ role: "user", content: "hi" }] },
|
|
stream: false,
|
|
credentials: makeValidCreds(),
|
|
signal: AbortSignal.timeout(10000),
|
|
});
|
|
|
|
assert.ok(result.response.ok);
|
|
const json = JSON.parse(await result.response.text());
|
|
assert.equal(json.object, "chat.completion");
|
|
assert.ok(Array.isArray(json.choices) && json.choices.length > 0, "Should have choices");
|
|
assert.equal(json.choices[0].message.role, "assistant");
|
|
assert.ok(typeof json.choices[0].message.content === "string", "Should have string content");
|
|
} finally {
|
|
mock.restore();
|
|
}
|
|
});
|
|
|
|
// ─── Error handling ──────────────────────────────────────────────────────
|
|
|
|
test("execute: upstream 401 → returns 401 with session expired message", async () => {
|
|
const original = globalThis.fetch;
|
|
globalThis.fetch = async () => new Response("Unauthorized", { status: 401 });
|
|
|
|
try {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.execute({
|
|
model: "gpt-4o",
|
|
body: { messages: [{ role: "user", content: "hi" }] },
|
|
stream: true,
|
|
credentials: makeValidCreds(),
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
assert.equal(result.response.status, 401);
|
|
const body = JSON.parse(await result.response.text());
|
|
assert.ok(
|
|
body.error?.message?.toLowerCase().includes("session") ||
|
|
body.error?.message?.toLowerCase().includes("expired") ||
|
|
body.error?.message?.toLowerCase().includes("unauthorized"),
|
|
"Should mention session/expired/unauthorized"
|
|
);
|
|
} finally {
|
|
globalThis.fetch = original;
|
|
}
|
|
});
|
|
|
|
test("execute: upstream 403 → returns 403 with descriptive message", async () => {
|
|
const original = globalThis.fetch;
|
|
globalThis.fetch = async () => new Response("Forbidden", { status: 403 });
|
|
|
|
try {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.execute({
|
|
model: "gpt-4o",
|
|
body: { messages: [{ role: "user", content: "hi" }] },
|
|
stream: true,
|
|
credentials: makeValidCreds(),
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
assert.equal(result.response.status, 403);
|
|
const body = JSON.parse(await result.response.text());
|
|
assert.ok(body.error?.message?.length > 0, "Should have error message");
|
|
} finally {
|
|
globalThis.fetch = original;
|
|
}
|
|
});
|
|
|
|
test("execute: upstream 429 → returns 429", async () => {
|
|
const original = globalThis.fetch;
|
|
globalThis.fetch = async () => new Response("Too Many Requests", { status: 429 });
|
|
|
|
try {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.execute({
|
|
model: "gpt-4o",
|
|
body: { messages: [{ role: "user", content: "hi" }] },
|
|
stream: true,
|
|
credentials: makeValidCreds(),
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
assert.equal(result.response.status, 429);
|
|
} finally {
|
|
globalThis.fetch = original;
|
|
}
|
|
});
|
|
|
|
test("execute: AbortSignal abort → returns 499", async () => {
|
|
const executor = new T3ChatWebExecutor();
|
|
const controller = new AbortController();
|
|
controller.abort();
|
|
|
|
const result = await executor.execute({
|
|
model: "gpt-4o",
|
|
body: { messages: [{ role: "user", content: "hi" }] },
|
|
stream: true,
|
|
credentials: makeValidCreds(),
|
|
signal: controller.signal,
|
|
});
|
|
|
|
// AbortError before fetch is even called returns 499 or 400 from creds check;
|
|
// with valid creds and aborted signal the fetch throws AbortError → 499.
|
|
assert.ok(result.response.status >= 400, "Should indicate an error status");
|
|
});
|
|
|
|
// ─── Error sanitization ──────────────────────────────────────────────────
|
|
|
|
test("execute: error responses do not include raw stack traces", async () => {
|
|
const original = globalThis.fetch;
|
|
globalThis.fetch = async () => {
|
|
throw new Error("Something went wrong\n at /home/user/app/executor.ts:42:5");
|
|
};
|
|
|
|
try {
|
|
const executor = new T3ChatWebExecutor();
|
|
const result = await executor.execute({
|
|
model: "gpt-4o",
|
|
body: { messages: [{ role: "user", content: "hi" }] },
|
|
stream: true,
|
|
credentials: makeValidCreds(),
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
|
|
assert.ok(result.response.status >= 400, "Should return error status");
|
|
const body = JSON.parse(await result.response.text());
|
|
const msg = body.error?.message ?? "";
|
|
assert.ok(!msg.includes("at /"), "Should not expose raw stack trace paths");
|
|
} finally {
|
|
globalThis.fetch = original;
|
|
}
|
|
});
|