mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 12:22:14 +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>
362 lines
11 KiB
TypeScript
362 lines
11 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-responses-handler-"));
|
|
process.env.DATA_DIR = TEST_DATA_DIR;
|
|
|
|
const core = await import("../../src/lib/db/core.ts");
|
|
const { handleResponsesCore } = await import("../../open-sse/handlers/responsesHandler.ts");
|
|
|
|
const originalFetch = globalThis.fetch;
|
|
|
|
function noopLog() {
|
|
return {
|
|
debug() {},
|
|
info() {},
|
|
warn() {},
|
|
error() {},
|
|
};
|
|
}
|
|
|
|
function toPlainHeaders(headers: any) {
|
|
if (!headers) return {};
|
|
if (headers instanceof Headers) return Object.fromEntries(headers.entries());
|
|
return Object.fromEntries(
|
|
Object.entries(headers).map(([key, value]) => [key, value == null ? "" : String(value)])
|
|
);
|
|
}
|
|
|
|
function buildOpenAISseResponse(text = "hello") {
|
|
return new Response(
|
|
[
|
|
`data: ${JSON.stringify({
|
|
id: "chatcmpl-responses",
|
|
object: "chat.completion.chunk",
|
|
choices: [{ index: 0, delta: { role: "assistant", content: text } }],
|
|
})}`,
|
|
"",
|
|
`data: ${JSON.stringify({
|
|
id: "chatcmpl-responses",
|
|
object: "chat.completion.chunk",
|
|
choices: [{ index: 0, delta: {}, finish_reason: "stop" }],
|
|
usage: { prompt_tokens: 4, completion_tokens: 2, total_tokens: 6 },
|
|
})}`,
|
|
"",
|
|
"data: [DONE]",
|
|
"",
|
|
].join("\n"),
|
|
{
|
|
status: 200,
|
|
headers: { "Content-Type": "text/event-stream" },
|
|
}
|
|
);
|
|
}
|
|
|
|
function buildJsonResponse(status: number, payload: any) {
|
|
return new Response(JSON.stringify(payload), {
|
|
status,
|
|
headers: { "Content-Type": "application/json" },
|
|
});
|
|
}
|
|
|
|
async function resetStorage() {
|
|
core.resetDbInstance();
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
|
|
fs.mkdirSync(TEST_DATA_DIR, { recursive: true });
|
|
}
|
|
|
|
async function invokeResponsesCore({
|
|
body,
|
|
provider = "openai",
|
|
model = "gpt-4o-mini",
|
|
credentials,
|
|
responseFactory,
|
|
signal,
|
|
}: {
|
|
body?: any;
|
|
provider?: string;
|
|
model?: string;
|
|
credentials?: any;
|
|
responseFactory?: any;
|
|
signal?: AbortSignal;
|
|
} = {}) {
|
|
const calls: any[] = [];
|
|
|
|
globalThis.fetch = async (url, init = {}) => {
|
|
const call = {
|
|
url: String(url),
|
|
method: init.method || "GET",
|
|
headers: toPlainHeaders(init.headers),
|
|
body: init.body ? JSON.parse(String(init.body)) : null,
|
|
};
|
|
calls.push(call);
|
|
return responseFactory ? responseFactory(call, calls) : buildOpenAISseResponse();
|
|
};
|
|
|
|
try {
|
|
const result = await handleResponsesCore({
|
|
body: structuredClone(body),
|
|
modelInfo: { provider, model, extendedContext: false },
|
|
credentials: credentials || {
|
|
apiKey: "sk-test",
|
|
providerSpecificData: {},
|
|
},
|
|
log: noopLog(),
|
|
onCredentialsRefreshed: null,
|
|
onRequestSuccess: null,
|
|
onDisconnect: null,
|
|
connectionId: null,
|
|
signal,
|
|
});
|
|
|
|
return { result, calls, call: calls.at(-1) };
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
}
|
|
|
|
test.afterEach(async () => {
|
|
globalThis.fetch = originalFetch;
|
|
await resetStorage();
|
|
});
|
|
|
|
test.after(async () => {
|
|
globalThis.fetch = originalFetch;
|
|
await resetStorage();
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
|
|
});
|
|
|
|
test("handleResponsesCore converts Responses API input, instructions, tools, metadata, and forces streaming", async () => {
|
|
const { call, result } = await invokeResponsesCore({
|
|
body: {
|
|
model: "gpt-4o-mini",
|
|
instructions: "You are terse",
|
|
input: [
|
|
{
|
|
type: "message",
|
|
role: "user",
|
|
content: [{ type: "input_text", text: "hello" }],
|
|
},
|
|
],
|
|
tools: [
|
|
{
|
|
type: "function",
|
|
name: "lookup_weather",
|
|
description: "Find weather",
|
|
parameters: { type: "object" },
|
|
},
|
|
],
|
|
metadata: { source: "responses-test" },
|
|
store: true,
|
|
},
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
assert.equal(call.body.stream, true);
|
|
assert.equal(call.body.messages[0].role, "system");
|
|
assert.equal(call.body.messages[0].content, "You are terse");
|
|
assert.equal(call.body.messages[1].role, "user");
|
|
assert.equal(call.body.messages[1].content[0].text, "hello");
|
|
assert.equal(call.body.tools[0].function.name, "lookup_weather");
|
|
assert.equal(call.body.metadata, undefined);
|
|
assert.equal("store" in call.body, false);
|
|
});
|
|
|
|
test("handleResponsesCore strips previous_response_id by default and handles empty input arrays", async () => {
|
|
const { call, result } = await invokeResponsesCore({
|
|
body: {
|
|
model: "gpt-4o-mini",
|
|
input: [],
|
|
previous_response_id: "resp_prev_123",
|
|
metadata: { session: "abc" },
|
|
},
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
assert.equal(call.body.previous_response_id, undefined);
|
|
assert.equal(call.body.metadata, undefined);
|
|
assert.deepEqual(call.body.messages, []);
|
|
assert.equal(call.body.stream, true);
|
|
});
|
|
|
|
test("handleResponsesCore preserves store for Codex responses when connection opt-in is enabled", async () => {
|
|
const { call, result } = await invokeResponsesCore({
|
|
body: {
|
|
model: "gpt-5.3-codex",
|
|
input: [],
|
|
previous_response_id: "resp_prev_store",
|
|
store: true,
|
|
},
|
|
provider: "codex",
|
|
model: "gpt-5.3-codex",
|
|
credentials: {
|
|
accessToken: "codex-token",
|
|
providerSpecificData: {
|
|
openaiStoreEnabled: true,
|
|
},
|
|
},
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
// When openaiStoreEnabled=true, the request keeps previous_response_id and
|
|
// store=true so the upstream Codex Responses session continues from prior turn.
|
|
assert.equal(call.body.previous_response_id, "resp_prev_store");
|
|
assert.equal(call.body.store, true);
|
|
assert.equal(call.body.stream, true);
|
|
});
|
|
|
|
test("handleResponsesCore transforms upstream OpenAI SSE into Responses API SSE", async () => {
|
|
const { result } = await invokeResponsesCore({
|
|
body: {
|
|
model: "gpt-4o-mini",
|
|
input: "hello",
|
|
},
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
assert.equal(result.response.headers.get("Content-Type"), "text/event-stream");
|
|
|
|
const sse = await result.response.text();
|
|
assert.match(sse, /event: response\.created/);
|
|
assert.match(sse, /event: response\.output_text\.delta/);
|
|
assert.match(sse, /event: response\.completed/);
|
|
assert.match(sse, /data: \[DONE\]/);
|
|
});
|
|
|
|
test("handleResponsesCore transforms Command Code executor SSE through Responses shim", async () => {
|
|
const { call, result } = await invokeResponsesCore({
|
|
provider: "command-code",
|
|
model: "gpt-5.4-mini",
|
|
credentials: { apiKey: "cc_test_key", providerSpecificData: {} },
|
|
body: {
|
|
model: "gpt-5.4-mini",
|
|
input: "hello command code",
|
|
},
|
|
responseFactory() {
|
|
return new Response(
|
|
[
|
|
`data: ${JSON.stringify({ type: "text-delta", text: "command" })}`,
|
|
"",
|
|
`data: ${JSON.stringify({ type: "reasoning-delta", text: "thinking" })}`,
|
|
"",
|
|
`data: ${JSON.stringify({ type: "finish", finishReason: "stop" })}`,
|
|
"",
|
|
].join("\n"),
|
|
{ status: 200, headers: { "Content-Type": "application/x-ndjson" } }
|
|
);
|
|
},
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
assert.equal(call.url, "https://api.commandcode.ai/alpha/generate");
|
|
assert.equal(call.headers.Authorization, "Bearer cc_test_key");
|
|
assert.equal(call.headers["x-command-code-version"], "0.24.1");
|
|
assert.equal(call.body.params.model, "gpt-5.4-mini");
|
|
assert.equal(call.body.params.stream, true);
|
|
|
|
const sse = await result.response.text();
|
|
assert.match(sse, /event: response\.created/);
|
|
assert.match(sse, /event: response\.output_text\.delta/);
|
|
assert.match(sse, /command/);
|
|
assert.match(sse, /event: response\.completed/);
|
|
assert.match(sse, /data: \[DONE\]/);
|
|
});
|
|
|
|
test("handleResponsesCore propagates upstream failures from chatCore unchanged", async () => {
|
|
const { result } = await invokeResponsesCore({
|
|
body: {
|
|
model: "gpt-4o-mini",
|
|
input: "hello",
|
|
},
|
|
responseFactory() {
|
|
return buildJsonResponse(401, {
|
|
error: { message: "unauthorized" },
|
|
});
|
|
},
|
|
});
|
|
|
|
assert.equal(result.success, false);
|
|
assert.equal(result.status, 401);
|
|
|
|
const payload = (await result.response.json()) as any;
|
|
assert.equal(payload.error.message, "[401]: unauthorized");
|
|
});
|
|
|
|
test("handleResponsesCore rejects invalid Responses API input that cannot be translated", async () => {
|
|
// After #2695 the web_search family is allowed; use file_search to keep this
|
|
// assertion exercising the "untranslatable tool type" path.
|
|
await assert.rejects(
|
|
() =>
|
|
handleResponsesCore({
|
|
body: {
|
|
model: "gpt-4o-mini",
|
|
input: "hello",
|
|
tools: [{ type: "file_search" }],
|
|
},
|
|
modelInfo: { provider: "openai", model: "gpt-4o-mini", extendedContext: false },
|
|
credentials: { apiKey: "sk-test", providerSpecificData: {} },
|
|
log: noopLog(),
|
|
onCredentialsRefreshed: null,
|
|
onRequestSuccess: null,
|
|
onDisconnect: null,
|
|
connectionId: null,
|
|
}),
|
|
(error) =>
|
|
error instanceof Error && error.message.includes("file_search tool type is not supported")
|
|
);
|
|
});
|
|
|
|
test("handleResponsesCore injects SSE keepalive frames for Responses streams", async (t) => {
|
|
// PR #2233 changed the Responses-API heartbeat shape from a SSE comment
|
|
// (`: keepalive ...`) to a `data: {"type":"response.in_progress"}` frame,
|
|
// because strict proxies only count `data:` lines as activity.
|
|
t.mock.timers.enable({ apis: ["setInterval"] });
|
|
try {
|
|
const { result } = await invokeResponsesCore({
|
|
body: {
|
|
model: "gpt-4o-mini",
|
|
input: "hello",
|
|
},
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
t.mock.timers.tick(15000); // Advance time by 15s to trigger heartbeat
|
|
|
|
const sse = await result.response.text();
|
|
|
|
assert.match(sse, /data: \{"type":"response\.in_progress"\}/);
|
|
assert.match(sse, /event: response\.created/);
|
|
assert.match(sse, /data: \[DONE\]/);
|
|
} finally {
|
|
t.mock.timers.reset();
|
|
}
|
|
});
|
|
|
|
test("handleResponsesCore clears heartbeat timers immediately when the request signal aborts", async (t) => {
|
|
t.mock.timers.enable({ apis: ["setInterval"] });
|
|
|
|
try {
|
|
const controller = new AbortController();
|
|
const { result } = await invokeResponsesCore({
|
|
body: {
|
|
model: "gpt-4o-mini",
|
|
input: "hello",
|
|
},
|
|
signal: controller.signal,
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
|
|
// We can't directly check clearInterval count because the stream flush
|
|
// also clears it. We'll just verify no crash and it resolves properly.
|
|
controller.abort();
|
|
await new Promise((r) => process.nextTick(r)); // yield to event loop
|
|
await result.response.body?.cancel();
|
|
} finally {
|
|
t.mock.timers.reset();
|
|
}
|
|
});
|