mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-13 10:43:43 +03:00
* fix(quality): green release/v3.8.50 base-reds round 2 — gateways/conol/deepai corruption, migrations, docs, ratchets, dashboard-typecheck Base-red fix for issue #9985 after the 2026-08-11 merge storm (99 PRs). Real defects fixed: - gateways.ts: close regolo entry (was swallowing naga-ac + chatanywhere from #9421), drop stale duplicate chatanywhere entry (#9594) - conol-web + deepai registry: correct ../shared import depth + deepai executor:default - modelSelectModalHelpers: close isProviderModelHidden (#9011) - driverFactory.test.ts: restore eaten test-closing brace (#9173) - usageTracking: remove duplicate cache_* props - modelCapability{Overrides,ResolutionSnapshot,Capabilities}: max_token -> max_output_tokens (#9199 vs #8908) + test align - videoGeneration: drop duplicate handleFalVideoGeneration import (mediaGeneration/fal canonical, #9982) - responseSanitizer: cast input_tokens_details before .cached_tokens access - EditConnectionModal: missing alibaba code fields, hoist validationPsd, providerPageHelpers Badge variant union - FreeBudgetCard: t() -> labels.noApiKey - peerRouting + cliRuntime: ProcessEnv typing - image-combo.test.ts: type any -> unknown - fal.test.ts: moved to tests/unit/services (collected path) 14 tests green - remove duplicate 143_job_registry.sql (146 canonical), KNOWN_GAPS fix Docs/ratchets (owner-authorized rebaselines, annotated): - CHANGELOG 3.8.50 living section restored + 42 i18n mirrors - MCP-SERVER.md 104->105 tools + i18n - ENVIRONMENT.md/.env.example: ADOBE_FIREFLY_CHROME_HEADED + DEBUG_CLAUDE_NONSTREAM - fabricated-docs allowlist: TELEGRAM proposal env vars - file-size: 5 grown files + proxyFetch 1207->1220 - dead-code 230->248, codeql 2->9 (drift from merged PRs, not this PR) - untrack _tasks symlink; agent-skills-sync --apply (config-codex-cli) * fix(changelog): reformat two feature fragments to the bullet convention (#9239, #9490) * fix(quality): prune stale ESLint suppressions (base-red) * fix(quality): resolve open-sse type errors + catalog/build regressions (base-red round 3) Storm-merge splices repaired in the base-fix PR #10131: - doctor.ts: AppConfig missing brokerSocketPath - conol-web.ts: Buffer not assignable to BodyInit (Uint8Array) - tinycms.ts: TinyCmsExecutor.execute return matches BaseExecutor (response/url/transformedBody) - tinycmsSigner.ts: encodeInto never-narrowing guard + dead wasm URL fallback (Turbopack) - virtualFactory.ts: options slot for resolutionSnapshot - bottleneckPatch.ts: insufficient-overlap casts (as unknown as) - imageCombo.ts: narrow handleImageGeneration union result - browser-worker.ts: AppConfig + turn.capabilities splice - conolDiscovery.ts: getProviderOutboundGuard from Policy module - catalog.ts: drop removed SWR hooks (getCatalogStaleWhileRevalidateMs + accessors), CatalogCachePolicy -> inline settings, resolve 4-arg call - catalogCache.ts: remove dead inFlight/promise refs - chat.ts: add isProviderBreakerFailureStatus import - model-catalog-cache-swr-8728.test.ts: align to #9199 new API (policy injection removed) * fix(quality): align UI test fixtures to current component contracts (base-red vitest) - setup-wizard: provide required serverState prop (component gained it in a merged PR) - grok-device-oauth-modal: next-intl stub resolves grok flow keys to EN labels - provider-quota-widget: label now inline (PR #8916 removed AutoRefreshButtonLabel extraction) — test the widget - use-provider-connections-cursor-refresh + phase1f: match /api/providers?provider=<id> query form; hoist heavy dynamic imports to module scope (timeout flake) - home-topology: mock next/navigation useRouter (component added node-click navigation) - cooling/lobe/AutoComboCatalog: raise cold-import describe timeouts to 30-60s - request-logger-*: align to current detail-view contract * fix(search): guard params.token undefined in serper headers (typecheck base-red) * fix(search): guard token headers + non-null providerConfig (typecheck base-red) * fix(changelog): restore base CHANGELOGs eaten by merge auto-resolve (43 files) --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com> Co-authored-by: backryun <bakryun0718@proton.me>
360 lines
11 KiB
TypeScript
360 lines
11 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
buildFalMusicRequestBody,
|
|
buildFalVideoRequestBody,
|
|
handleFalMusicGeneration,
|
|
handleFalVideoGeneration,
|
|
normalizeFalMediaResult,
|
|
} from "../../../open-sse/handlers/mediaGeneration/fal.ts";
|
|
import { parseImageModel } from "../../../open-sse/config/imageRegistry.ts";
|
|
import { parseMusicModel } from "../../../open-sse/config/musicRegistry.ts";
|
|
import { parseVideoModel } from "../../../open-sse/config/videoRegistry.ts";
|
|
|
|
test("buildFalVideoRequestBody maps the OpenAI-compatible request", () => {
|
|
assert.deepEqual(
|
|
buildFalVideoRequestBody({
|
|
prompt: "A quiet train crossing a snowy bridge",
|
|
aspect_ratio: "9:16",
|
|
duration: 6,
|
|
resolution: "1080p",
|
|
generate_audio: false,
|
|
negative_prompt: "text overlays",
|
|
seed: 42,
|
|
}),
|
|
{
|
|
prompt: "A quiet train crossing a snowy bridge",
|
|
aspect_ratio: "9:16",
|
|
duration: "6s",
|
|
resolution: "1080p",
|
|
generate_audio: false,
|
|
negative_prompt: "text overlays",
|
|
seed: 42,
|
|
}
|
|
);
|
|
});
|
|
|
|
test("buildFalVideoRequestBody maps the Fal-hosted Grok endpoint schema", () => {
|
|
assert.deepEqual(
|
|
buildFalVideoRequestBody(
|
|
{
|
|
prompt: "A realistic dog walking through a park",
|
|
aspect_ratio: "16:9",
|
|
duration: "8s",
|
|
resolution: "720p",
|
|
generate_audio: true,
|
|
},
|
|
"xai/grok-imagine-video/text-to-video"
|
|
),
|
|
{
|
|
prompt: "A realistic dog walking through a park",
|
|
aspect_ratio: "16:9",
|
|
duration: 8,
|
|
resolution: "720p",
|
|
}
|
|
);
|
|
});
|
|
|
|
test("buildFalVideoRequestBody maps one provider-neutral image reference", () => {
|
|
assert.deepEqual(
|
|
buildFalVideoRequestBody(
|
|
{
|
|
prompt: "Animate this dog",
|
|
image_urls: ["data:image/png;base64,ZmFrZQ=="],
|
|
},
|
|
"xai/grok-imagine-video/text-to-video"
|
|
),
|
|
{
|
|
prompt: "Animate this dog",
|
|
aspect_ratio: "16:9",
|
|
duration: 6,
|
|
resolution: "720p",
|
|
image_url: "data:image/png;base64,ZmFrZQ==",
|
|
}
|
|
);
|
|
});
|
|
|
|
test("buildFalVideoRequestBody maps multiple provider-neutral image references", () => {
|
|
assert.deepEqual(
|
|
buildFalVideoRequestBody(
|
|
{
|
|
prompt: "Combine these references",
|
|
image_urls: ["data:image/png;base64,YQ==", "data:image/png;base64,Yg=="],
|
|
},
|
|
"xai/grok-imagine-video/text-to-video"
|
|
),
|
|
{
|
|
prompt: "Combine these references",
|
|
aspect_ratio: "16:9",
|
|
duration: 6,
|
|
resolution: "720p",
|
|
reference_image_urls: ["data:image/png;base64,YQ==", "data:image/png;base64,Yg=="],
|
|
}
|
|
);
|
|
});
|
|
|
|
test("buildFalVideoRequestBody maps the Gemini Omni Flash video schema", () => {
|
|
assert.deepEqual(
|
|
buildFalVideoRequestBody(
|
|
{
|
|
prompt: "A realistic dog walking through a park",
|
|
aspect_ratio: "9:16",
|
|
duration: 10,
|
|
resolution: "1080p",
|
|
generate_audio: false,
|
|
},
|
|
"google/gemini-omni-flash"
|
|
),
|
|
{
|
|
prompt: "A realistic dog walking through a park",
|
|
aspect_ratio: "9:16",
|
|
duration: 10,
|
|
}
|
|
);
|
|
});
|
|
|
|
test("handleFalVideoGeneration selects Gemini Omni Flash image-to-video", async () => {
|
|
const originalFetch = globalThis.fetch;
|
|
const requests: Array<{ url: string; body: string }> = [];
|
|
globalThis.fetch = async (input, init) => {
|
|
requests.push({ url: String(input), body: String(init?.body) });
|
|
return new Response(JSON.stringify({ video: { url: "https://cdn.example/gemini.mp4" } }), {
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
});
|
|
};
|
|
|
|
try {
|
|
const result = await handleFalVideoGeneration({
|
|
model: "google/gemini-omni-flash",
|
|
provider: "fal-ai",
|
|
providerConfig: { baseUrl: "https://queue.fal.run" },
|
|
body: {
|
|
prompt: "Animate this dog",
|
|
image_urls: ["data:image/png;base64,ZmFrZQ=="],
|
|
duration: 8,
|
|
},
|
|
credentials: { apiKey: "test-key" },
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
assert.equal(requests[0]?.url, "https://queue.fal.run/google/gemini-omni-flash/image-to-video");
|
|
assert.deepEqual(JSON.parse(requests[0]?.body || "{}"), {
|
|
prompt: "Animate this dog",
|
|
aspect_ratio: "16:9",
|
|
duration: 8,
|
|
image_url: "data:image/png;base64,ZmFrZQ==",
|
|
});
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("buildFalMusicRequestBody uses prompt as tags and supports lyrics", () => {
|
|
assert.deepEqual(
|
|
buildFalMusicRequestBody({
|
|
prompt: "warm analog synthwave",
|
|
lyrics: "[verse] Drive through the night",
|
|
duration: 30,
|
|
seed: 7,
|
|
}),
|
|
{
|
|
tags: "warm analog synthwave",
|
|
lyrics: "[verse] Drive through the night",
|
|
duration: 30,
|
|
seed: 7,
|
|
}
|
|
);
|
|
});
|
|
|
|
test("normalizeFalMediaResult returns typed media URLs", () => {
|
|
assert.deepEqual(
|
|
normalizeFalMediaResult(
|
|
{
|
|
video: {
|
|
url: "https://cdn.example/video.mp4",
|
|
content_type: "video/mp4",
|
|
},
|
|
},
|
|
"video"
|
|
),
|
|
{
|
|
success: true,
|
|
data: {
|
|
created: 0,
|
|
data: [{ url: "https://cdn.example/video.mp4", format: "mp4" }],
|
|
},
|
|
}
|
|
);
|
|
|
|
assert.deepEqual(
|
|
normalizeFalMediaResult({ audio: { url: "https://cdn.example/song.wav" } }, "music"),
|
|
{
|
|
success: true,
|
|
data: {
|
|
created: 0,
|
|
data: [{ url: "https://cdn.example/song.wav", format: "wav" }],
|
|
},
|
|
}
|
|
);
|
|
});
|
|
|
|
test("normalizeFalMediaResult rejects a missing artifact", () => {
|
|
assert.deepEqual(normalizeFalMediaResult({}, "video"), {
|
|
success: false,
|
|
status: 502,
|
|
error: "Fal video generation returned no media URL",
|
|
});
|
|
});
|
|
|
|
test("media registries expose provider-neutral model IDs", () => {
|
|
assert.deepEqual(parseImageModel("fal-ai/flux-2-pro"), {
|
|
provider: "fal-ai",
|
|
model: "flux-2-pro",
|
|
});
|
|
assert.deepEqual(parseVideoModel("fal-ai/veo3.1/lite"), {
|
|
provider: "fal-ai",
|
|
model: "veo3.1/lite",
|
|
});
|
|
assert.deepEqual(parseMusicModel("fal-ai/ace-step"), {
|
|
provider: "fal-ai",
|
|
model: "ace-step",
|
|
});
|
|
});
|
|
|
|
test("handleFalVideoGeneration uses the provider-neutral queue contract", async () => {
|
|
const originalFetch = globalThis.fetch;
|
|
const requests: Array<{ url: string; body: string }> = [];
|
|
globalThis.fetch = async (input, init) => {
|
|
requests.push({ url: String(input), body: String(init?.body) });
|
|
return new Response(JSON.stringify({ video: { url: "https://cdn.example/video.mp4" } }), {
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
});
|
|
};
|
|
|
|
try {
|
|
const result = await handleFalVideoGeneration({
|
|
model: "veo3.1/lite",
|
|
provider: "fal-ai",
|
|
providerConfig: { baseUrl: "https://queue.fal.run" },
|
|
body: { prompt: "a slow pan across a forest", duration: 4 },
|
|
credentials: { apiKey: "test-key" },
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
assert.equal(requests[0]?.url, "https://queue.fal.run/fal-ai/veo3.1/lite");
|
|
assert.deepEqual(JSON.parse(requests[0]?.body || "{}"), {
|
|
prompt: "a slow pan across a forest",
|
|
aspect_ratio: "16:9",
|
|
duration: "4s",
|
|
resolution: "720p",
|
|
generate_audio: true,
|
|
});
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("handleFalVideoGeneration preserves Fal model paths outside the fal-ai namespace", async () => {
|
|
const originalFetch = globalThis.fetch;
|
|
const requests: Array<{ url: string; body: string }> = [];
|
|
globalThis.fetch = async (input, init) => {
|
|
requests.push({ url: String(input), body: String(init?.body) });
|
|
return new Response(JSON.stringify({ video: { url: "https://cdn.example/grok.mp4" } }), {
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
});
|
|
};
|
|
|
|
try {
|
|
const result = await handleFalVideoGeneration({
|
|
model: "xai/grok-imagine-video/text-to-video",
|
|
provider: "fal-ai",
|
|
providerConfig: { baseUrl: "https://queue.fal.run" },
|
|
body: { prompt: "a dog walking through a park", duration: 8 },
|
|
credentials: { apiKey: "test-key" },
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
assert.equal(requests[0]?.url, "https://queue.fal.run/xai/grok-imagine-video/text-to-video");
|
|
assert.deepEqual(JSON.parse(requests[0]?.body || "{}"), {
|
|
prompt: "a dog walking through a park",
|
|
aspect_ratio: "16:9",
|
|
duration: 8,
|
|
resolution: "720p",
|
|
});
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("handleFalVideoGeneration selects Grok image-to-video for one reference image", async () => {
|
|
const originalFetch = globalThis.fetch;
|
|
const requests: Array<{ url: string; body: string }> = [];
|
|
globalThis.fetch = async (input, init) => {
|
|
requests.push({ url: String(input), body: String(init?.body) });
|
|
return new Response(JSON.stringify({ video: { url: "https://cdn.example/grok-i2v.mp4" } }), {
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
});
|
|
};
|
|
|
|
try {
|
|
const result = await handleFalVideoGeneration({
|
|
model: "xai/grok-imagine-video/text-to-video",
|
|
provider: "fal-ai",
|
|
providerConfig: { baseUrl: "https://queue.fal.run" },
|
|
body: {
|
|
prompt: "Animate this dog",
|
|
image_urls: ["data:image/png;base64,ZmFrZQ=="],
|
|
},
|
|
credentials: { apiKey: "test-key" },
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
assert.equal(requests[0]?.url, "https://queue.fal.run/xai/grok-imagine-video/image-to-video");
|
|
assert.deepEqual(JSON.parse(requests[0]?.body || "{}"), {
|
|
prompt: "Animate this dog",
|
|
aspect_ratio: "16:9",
|
|
duration: 6,
|
|
resolution: "720p",
|
|
image_url: "data:image/png;base64,ZmFrZQ==",
|
|
});
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("handleFalMusicGeneration uses the provider-neutral queue contract", async () => {
|
|
const originalFetch = globalThis.fetch;
|
|
const requests: Array<{ url: string; body: string }> = [];
|
|
globalThis.fetch = async (input, init) => {
|
|
requests.push({ url: String(input), body: String(init?.body) });
|
|
return new Response(JSON.stringify({ audio: { url: "https://cdn.example/music.wav" } }), {
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
});
|
|
};
|
|
|
|
try {
|
|
const result = await handleFalMusicGeneration({
|
|
model: "ace-step",
|
|
provider: "fal-ai",
|
|
providerConfig: { baseUrl: "https://queue.fal.run" },
|
|
body: { prompt: "ambient synthwave", lyrics: "stay awake", duration: 30 },
|
|
credentials: { apiKey: "test-key" },
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
assert.equal(requests[0]?.url, "https://queue.fal.run/fal-ai/ace-step");
|
|
assert.deepEqual(JSON.parse(requests[0]?.body || "{}"), {
|
|
tags: "ambient synthwave",
|
|
lyrics: "stay awake",
|
|
duration: 30,
|
|
});
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|