Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

feat: add unit tests for registryUtils, media playground page, TypeScript fixes

diegosouzapwe11bcc2848c4
diff --git a/.agents/workflows/resolve-issues.md b/.agents/workflows/resolve-issues.md
index aee2d41656..c5a07b7b04 100644
--- a/.agents/workflows/resolve-issues.md
+++ b/.agents/workflows/resolve-issues.md
@@ -1,12 +1,12 @@
---
-description: Fetch all open GitHub issues, analyze bugs, resolve what's possible, triage the rest, then commit and release
+description: Fetch all open GitHub issues, analyze bugs, resolve what's possible, triage the rest, wait for user validation, then commit and release
---
# /resolve-issues — Automated Issue Resolution Workflow
## Overview
-This workflow fetches all open issues from the project's GitHub repository, classifies them, analyzes bugs, resolves what can be fixed, triages issues with insufficient information, and generates a release with all fixes.
+This workflow fetches all open issues from the project's GitHub repository, classifies them, analyzes bugs, resolves what can be fixed, and triages issues with insufficient information. **It does NOT commit or release automatically** — it presents a report and waits for user validation before proceeding.
## Steps
@@ -64,32 +64,39 @@ Proceed with resolution:
2. **Root Cause** — Identify the root cause by reading the relevant source files
3. **Implement Fix** — Apply the fix following existing code patterns and conventions
4. **Test** — Build the project and run tests to verify the fix
-5. **Commit** — Commit with message format: `fix: <description> (#<issue_number>)`
+5. **DO NOT commit yet** — Leave changes staged but uncommitted
-### 5. Commit All Fixes
+### 5. Generate Report & Wait for Validation
-After processing all issues:
+Present a summary report to the user via `notify_user` with `BlockedOnUser: true`:
-- Ensure all fixes are committed with proper issue references
+| Issue | Title | Status | Action |
+| ----- | ----- | ------------- | ----------------------------- |
+| #N | Title | ✅ Ready | Files changed (not committed) |
+| #N | Title | ❓ Needs Info | Triage comment posted |
+| #N | Title | ⏭️ Skipped | Feature request / not a bug |
+
+> **⚠️ IMPORTANT**: Do NOT commit, close issues, or generate releases at this step.
+> Wait for the user to review the changes and respond with **OK** before proceeding.
+
+- If the user says **OK** or approves → Proceed to step 6
+- If the user requests changes → Apply the requested adjustments first, then present the report again
+- If the user rejects → Revert the changes and stop
+
+### 6. Commit All Fixes (only after user approval)
+
+After the user validates:
+
+- Commit each fix individually with message format: `fix: <description> (#<issue_number>)`
- Each fix should be its own commit for clean git history
-### 6. Close Resolved Issues
+### 7. Close Resolved Issues
For each successfully fixed issue:
// turbo
- Close with a comment: `gh issue close <NUMBER> --repo <owner>/<repo> --comment "Fixed in <commit_hash>. The fix will be included in the next release."`
-### 7. Generate Report
-
-Present a summary report to the user via `notify_user`:
-
-| Issue | Title | Status | Action |
-| ----- | ----- | ------------- | --------------------------- |
-| #N | Title | ✅ Fixed | Commit hash |
-| #N | Title | ❓ Needs Info | Triage comment posted |
-| #N | Title | ⏭️ Skipped | Feature request / not a bug |
-
### 8. Update Docs & Release
If any fixes were committed:
diff --git a/open-sse/config/registryUtils.ts b/open-sse/config/registryUtils.ts
index cd20cc6f46..869d04dcc0 100644
--- a/open-sse/config/registryUtils.ts
+++ b/open-sse/config/registryUtils.ts
@@ -53,9 +53,10 @@ export function parseModelFromRegistry<P extends BaseProvider>(
*/
export function getAllModelsFromRegistry<P extends BaseProvider>(
registry: Record<string, P>,
- extra?: (providerId: string, config: P) => Record<string, any>
-): Array<{ id: string; name: string; provider: string } & Record<string, any>> {
- const models: Array<{ id: string; name: string; provider: string } & Record<string, any>> = [];
+ extra?: (providerId: string, config: P) => Record<string, unknown>
+): Array<{ id: string; name: string; provider: string } & Record<string, unknown>> {
+ const models: Array<{ id: string; name: string; provider: string } & Record<string, unknown>> =
+ [];
for (const [providerId, config] of Object.entries(registry)) {
const extraFields = extra ? extra(providerId, config) : {};
diff --git a/src/app/(dashboard)/dashboard/media/MediaPageClient.tsx b/src/app/(dashboard)/dashboard/media/MediaPageClient.tsx
new file mode 100644
index 0000000000..813293f5b3
--- /dev/null
+++ b/src/app/(dashboard)/dashboard/media/MediaPageClient.tsx
@@ -0,0 +1,261 @@
+"use client";
+
+import { useState } from "react";
+import { useTranslations } from "next-intl";
+
+type Modality = "image" | "video" | "music";
+type GenerationResult = {
+ type: Modality;
+ data: any;
+ timestamp: number;
+};
+
+const MODALITY_CONFIG: Record<
+ Modality,
+ { icon: string; endpoint: string; label: string; placeholder: string; color: string }
+> = {
+ image: {
+ icon: "image",
+ endpoint: "/api/v1/images/generations",
+ label: "Image Generation",
+ placeholder: "A serene landscape with mountains at sunset...",
+ color: "from-purple-500 to-pink-500",
+ },
+ video: {
+ icon: "videocam",
+ endpoint: "/api/v1/videos/generations",
+ label: "Video Generation",
+ placeholder: "A timelapse of a flower blooming...",
+ color: "from-blue-500 to-cyan-500",
+ },
+ music: {
+ icon: "music_note",
+ endpoint: "/api/v1/music/generations",
+ label: "Music Generation",
+ placeholder: "Upbeat electronic music with synth pads...",
+ color: "from-orange-500 to-yellow-500",
+ },
+};
+
+export default function MediaPageClient() {
+ const t = useTranslations("media");
+ const [activeTab, setActiveTab] = useState<Modality>("image");
+ const [prompt, setPrompt] = useState("");
+ const [model, setModel] = useState("");
+ const [models, setModels] = useState<any[]>([]);
+ const [loading, setLoading] = useState(false);
+ const [loadingModels, setLoadingModels] = useState(false);
+ const [result, setResult] = useState<GenerationResult | null>(null);
+ const [error, setError] = useState<string | null>(null);
+
+ // Fetch available models for each modality
+ const fetchModels = async (modality: Modality) => {
+ setLoadingModels(true);
+ try {
+ const res = await fetch(MODALITY_CONFIG[modality].endpoint);
+ if (res.ok) {
+ const data = await res.json();
+ const modelList = data.data || [];
+ setModels(modelList);
+ if (modelList.length > 0) setModel(modelList[0].id);
+ }
+ } catch {
+ setModels([]);
+ }
+ setLoadingModels(false);
+ };
+
+ const switchTab = (tab: Modality) => {
+ setActiveTab(tab);
+ setPrompt("");
+ setResult(null);
+ setError(null);
+ fetchModels(tab);
+ };
+
+ const handleGenerate = async () => {
+ if (!prompt.trim()) return;
+ setLoading(true);
+ setError(null);
+ setResult(null);
+
+ try {
+ const config = MODALITY_CONFIG[activeTab];
+ const res = await fetch(config.endpoint, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ model: model || undefined,
+ prompt: prompt.trim(),
+ ...(activeTab === "image" ? { size: "1024x1024", n: 1 } : {}),
+ }),
+ });
+
+ if (!res.ok) {
+ const errData = await res.json().catch(() => ({}));
+ throw new Error(errData?.error?.message || `Generation failed (${res.status})`);
+ }
+
+ const data = await res.json();
+ setResult({ type: activeTab, data, timestamp: Date.now() });
+ } catch (err: any) {
+ setError(err.message || "Generation failed");
+ }
+ setLoading(false);
+ };
+
+ // Load models on first render
+ useState(() => {
+ fetchModels("image");
+ });
+
+ const config = MODALITY_CONFIG[activeTab];
+
+ return (
+ <div className="space-y-6">
+ {/* Header */}
+ <div>
+ <h1 className="text-2xl font-bold text-text-main">{t("title")}</h1>
+ <p className="text-text-muted text-sm mt-1">{t("subtitle")}</p>
+ </div>
+
+ {/* Modality Tabs */}
+ <div className="flex gap-2 p-1 bg-surface/50 rounded-xl border border-black/5 dark:border-white/5">
+ {(Object.keys(MODALITY_CONFIG) as Modality[]).map((key) => {
+ const cfg = MODALITY_CONFIG[key];
+ const isActive = key === activeTab;
+ return (
+ <button
+ key={key}
+ onClick={() => switchTab(key)}
+ className={`flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg text-sm font-medium transition-all ${
+ isActive
+ ? "bg-primary/10 text-primary shadow-sm border border-primary/20"
+ : "text-text-muted hover:text-text-main hover:bg-surface/80"
+ }`}
+ >
+ <span className="material-symbols-outlined text-[18px]">{cfg.icon}</span>
+ {cfg.label}
+ </button>
+ );
+ })}
+ </div>
+
+ {/* Generation Form */}
+ <div className="bg-surface/30 rounded-xl border border-black/5 dark:border-white/5 p-6 space-y-4">
+ {/* Model selector */}
+ <div>
+ <label className="block text-sm font-medium text-text-main mb-2">{t("model")}</label>
+ {loadingModels ? (
+ <div className="flex items-center gap-2 text-text-muted text-sm">
+ <span className="material-symbols-outlined animate-spin text-[16px]">progress_activity</span>
+ {t("loadingModels")}
+ </div>
+ ) : models.length > 0 ? (
+ <select
+ value={model}
+ onChange={(e) => setModel(e.target.value)}
+ className="w-full px-3 py-2 rounded-lg bg-surface border border-black/10 dark:border-white/10 text-text-main text-sm focus:outline-none focus:ring-2 focus:ring-primary/30"
+ >
+ {models.map((m) => (
+ <option key={m.id} value={m.id}>
+ {m.id}
+ </option>
+ ))}
+ </select>
+ ) : (
+ <p className="text-text-muted text-sm">{t("noModels")}</p>
+ )}
+ </div>
+
+ {/* Prompt */}
+ <div>
+ <label className="block text-sm font-medium text-text-main mb-2">{t("prompt")}</label>
+ <textarea
+ rows={3}
+ value={prompt}
+ onChange={(e) => setPrompt(e.target.value)}
+ placeholder={config.placeholder}
+ className="w-full px-3 py-2 rounded-lg bg-surface border border-black/10 dark:border-white/10 text-text-main text-sm placeholder:text-text-muted/50 focus:outline-none focus:ring-2 focus:ring-primary/30 resize-none"
+ />
+ </div>
+
+ {/* Generate button */}
+ <button
+ onClick={handleGenerate}
+ disabled={loading || !prompt.trim()}
+ className={`w-full flex items-center justify-center gap-2 px-4 py-3 rounded-lg text-white font-medium transition-all bg-gradient-to-r ${config.color} ${
+ loading || !prompt.trim() ? "opacity-50 cursor-not-allowed" : "hover:opacity-90 hover:shadow-lg"
+ }`}
+ >
+ {loading ? (
+ <>
+ <span className="material-symbols-outlined animate-spin text-[18px]">progress_activity</span>
+ {t("generating")}
+ </>
+ ) : (
+ <>
+ <span className="material-symbols-outlined text-[18px]">auto_awesome</span>
+ {t("generate")} {config.label}
+ </>
+ )}
+ </button>
+ </div>
+
+ {/* Error */}
+ {error && (
+ <div className="bg-red-500/10 border border-red-500/20 rounded-xl p-4 flex items-start gap-3">
+ <span className="material-symbols-outlined text-red-500 text-[20px] mt-0.5">error</span>
+ <div>
+ <p className="text-sm font-medium text-red-500">{t("error")}</p>
+ <p className="text-sm text-text-muted mt-1">{error}</p>
+ </div>
+ </div>
+ )}
+
+ {/* Result */}
+ {result && (
+ <div className="bg-surface/30 rounded-xl border border-black/5 dark:border-white/5 p-6">
+ <div className="flex items-center gap-2 mb-4">
+ <span className={`material-symbols-outlined text-[20px] bg-gradient-to-r ${config.color} bg-clip-text text-transparent`}>
+ {config.icon}
+ </span>
+ <h3 className="text-sm font-medium text-text-main">{t("result")}</h3>
+ <span className="text-xs text-text-muted ml-auto">
+ {new Date(result.timestamp).toLocaleTimeString()}
+ </span>
+ </div>
+ <pre className="bg-surface rounded-lg p-4 text-xs text-text-muted overflow-auto max-h-96 custom-scrollbar">
+ {JSON.stringify(result.data, null, 2)}
+ </pre>
+ </div>
+ )}
+
+ {/* Info cards */}
+ <div className="grid grid-cols-1 md:grid-cols-3 gap-4">
+ {(Object.keys(MODALITY_CONFIG) as Modality[]).map((key) => {
+ const cfg = MODALITY_CONFIG[key];
+ return (
+ <div
+ key={key}
+ className="bg-surface/30 rounded-xl border border-black/5 dark:border-white/5 p-4"
+ >
+ <div className="flex items-center gap-2 mb-2">
+ <div className={`flex items-center justify-center size-8 rounded-lg bg-gradient-to-r ${cfg.color}`}>
+ <span className="material-symbols-outlined text-white text-[16px]">{cfg.icon}</span>
+ </div>
+ <span className="text-sm font-medium text-text-main">{cfg.label}</span>
+ </div>
+ <p className="text-xs text-text-muted">
+ {t(`${key}Description`)}
+ </p>
+ <code className="block mt-2 text-xs text-primary/70 bg-primary/5 rounded px-2 py-1">
+ POST {cfg.endpoint}
+ </code>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ );
+}
diff --git a/src/app/(dashboard)/dashboard/media/page.tsx b/src/app/(dashboard)/dashboard/media/page.tsx
new file mode 100644
index 0000000000..936304f932
--- /dev/null
+++ b/src/app/(dashboard)/dashboard/media/page.tsx
@@ -0,0 +1,5 @@
+import MediaPageClient from "./MediaPageClient";
+
+export default function MediaPage() {
+ return <MediaPageClient />;
+}
diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json
index fa12288dda..f84770bf51 100644
--- a/src/i18n/messages/en.json
+++ b/src/i18n/messages/en.json
@@ -69,6 +69,7 @@
"health": "Health",
"limits": "Limits & Quotas",
"cliTools": "CLI Tools",
+ "media": "Media",
"settings": "Settings",
"translator": "Translator",
"docs": "Docs",
@@ -110,7 +111,9 @@
"settings": "Settings",
"settingsDescription": "Manage your preferences",
"openaiCompatible": "OpenAI Compatible",
- "anthropicCompatible": "Anthropic Compatible"
+ "anthropicCompatible": "Anthropic Compatible",
+ "media": "Media",
+ "mediaDescription": "Generate images, videos, and music"
},
"home": {
"quickStart": "Quick Start",
@@ -260,6 +263,21 @@
"showing": "Showing {count} entries (offset {offset})",
"previous": "Previous"
},
+ "media": {
+ "title": "Media Playground",
+ "subtitle": "Generate images, videos, and music using your configured providers",
+ "model": "Model",
+ "prompt": "Prompt",
+ "generate": "Generate",
+ "generating": "Generating...",
+ "loadingModels": "Loading available models...",
+ "noModels": "No models available. Configure providers with media capabilities first.",
+ "error": "Generation Failed",
+ "result": "Result",
+ "imageDescription": "Generate images from text prompts using OpenAI, xAI, Together, Hyperbolic, SD WebUI, ComfyUI and more.",
+ "videoDescription": "Create videos with AnimateDiff, Stable Video Diffusion via ComfyUI or SD WebUI.",
+ "musicDescription": "Compose music using Stable Audio Open or MusicGen via ComfyUI."
+ },
"cliTools": {
"title": "CLI Tools",
"noActiveProviders": "No active providers",
diff --git a/src/i18n/messages/pt-BR.json b/src/i18n/messages/pt-BR.json
index b50fcdb015..cc8bba6a59 100644
--- a/src/i18n/messages/pt-BR.json
+++ b/src/i18n/messages/pt-BR.json
@@ -69,6 +69,7 @@
"health": "Saúde",
"limits": "Limites e Cotas",
"cliTools": "Ferramentas CLI",
+ "media": "Mídia",
"settings": "Configurações",
"translator": "Tradutor",
"docs": "Documentação",
@@ -110,7 +111,9 @@
"settings": "Configurações",
"settingsDescription": "Gerencie suas preferências",
"openaiCompatible": "Compatível com OpenAI",
- "anthropicCompatible": "Compatível com Anthropic"
+ "anthropicCompatible": "Compatível com Anthropic",
+ "media": "Mídia",
+ "mediaDescription": "Gerar imagens, vídeos e músicas"
},
"home": {
"quickStart": "Início Rápido",
@@ -260,6 +263,21 @@
"showing": "Mostrando {count} entradas (offset {offset})",
"previous": "Anterior"
},
+ "media": {
+ "title": "Playground de Mídia",
+ "subtitle": "Gere imagens, vídeos e músicas usando seus provedores configurados",
+ "model": "Modelo",
+ "prompt": "Prompt",
+ "generate": "Gerar",
+ "generating": "Gerando...",
+ "loadingModels": "Carregando modelos disponíveis...",
+ "noModels": "Nenhum modelo disponível. Configure provedores com suporte a mídia primeiro.",
+ "error": "Falha na Geração",
+ "result": "Resultado",
+ "imageDescription": "Gere imagens a partir de prompts de texto usando OpenAI, xAI, Together, Hyperbolic, SD WebUI, ComfyUI e mais.",
+ "videoDescription": "Crie vídeos com AnimateDiff, Stable Video Diffusion via ComfyUI ou SD WebUI.",
+ "musicDescription": "Componha músicas usando Stable Audio Open ou MusicGen via ComfyUI."
+ },
"cliTools": {
"title": "Ferramentas CLI",
"noActiveProviders": "Nenhum provedor ativo",
diff --git a/src/shared/components/Sidebar.tsx b/src/shared/components/Sidebar.tsx
index e402262e40..f88ff8b7c0 100644
--- a/src/shared/components/Sidebar.tsx
+++ b/src/shared/components/Sidebar.tsx
@@ -25,6 +25,7 @@ const navItemDefs = [
{ href: "/dashboard/limits", i18nKey: "limits", icon: "tune" },
{ href: "/dashboard/health", i18nKey: "health", icon: "health_and_safety" },
{ href: "/dashboard/cli-tools", i18nKey: "cliTools", icon: "terminal" },
+ { href: "/dashboard/media", i18nKey: "media", icon: "auto_awesome" },
];
const debugItemDefs = [{ href: "/dashboard/translator", i18nKey: "translator", icon: "translate" }];
diff --git a/tests/unit/registry-utils.test.mjs b/tests/unit/registry-utils.test.mjs
new file mode 100644
index 0000000000..e5e9a64c86
--- /dev/null
+++ b/tests/unit/registry-utils.test.mjs
@@ -0,0 +1,211 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+
+// ═══════════════════════════════════════════════════════════════
+// Registry Utilities Unit Tests
+// Tests for parseModelFromRegistry, getAllModelsFromRegistry,
+// buildAuthHeaders — shared abstractions from PR #167
+// ═══════════════════════════════════════════════════════════════
+
+const { parseModelFromRegistry, getAllModelsFromRegistry, buildAuthHeaders } =
+ await import("../../open-sse/config/registryUtils.ts");
+
+// ─── Test fixtures ────────────────────────────────────────────
+
+const MOCK_REGISTRY = {
+ elevenlabs: {
+ id: "elevenlabs",
+ baseUrl: "https://api.elevenlabs.io/v1",
+ authType: "apikey",
+ authHeader: "xi-api-key",
+ models: [
+ { id: "eleven_multilingual_v2", name: "Multilingual V2" },
+ { id: "eleven_turbo_v2_5", name: "Turbo V2.5" },
+ ],
+ },
+ comfyui: {
+ id: "comfyui",
+ baseUrl: "http://localhost:8188",
+ authType: "none",
+ authHeader: "none",
+ models: [
+ { id: "flux-dev", name: "FLUX Dev" },
+ { id: "sdxl", name: "SDXL" },
+ ],
+ },
+ nvidia: {
+ id: "nvidia",
+ baseUrl: "https://integrate.api.nvidia.com/v1",
+ authType: "apikey",
+ authHeader: "bearer",
+ models: [{ id: "parakeet-ctc-1.1b-asr", name: "Parakeet CTC 1.1B" }],
+ },
+};
+
+// ═══════════════════════════════════════════════════════════════
+// parseModelFromRegistry
+// ═══════════════════════════════════════════════════════════════
+
+test("parseModelFromRegistry: returns null provider for null input", () => {
+ const result = parseModelFromRegistry(null, MOCK_REGISTRY);
+ assert.deepEqual(result, { provider: null, model: null });
+});
+
+test("parseModelFromRegistry: returns null provider for empty string", () => {
+ const result = parseModelFromRegistry("", MOCK_REGISTRY);
+ assert.deepEqual(result, { provider: null, model: null });
+});
+
+test("parseModelFromRegistry: parses provider/model prefix correctly", () => {
+ const result = parseModelFromRegistry("elevenlabs/eleven_multilingual_v2", MOCK_REGISTRY);
+ assert.deepEqual(result, {
+ provider: "elevenlabs",
+ model: "eleven_multilingual_v2",
+ });
+});
+
+test("parseModelFromRegistry: parses comfyui/flux-dev correctly", () => {
+ const result = parseModelFromRegistry("comfyui/flux-dev", MOCK_REGISTRY);
+ assert.deepEqual(result, { provider: "comfyui", model: "flux-dev" });
+});
+
+test("parseModelFromRegistry: finds bare model ID without provider prefix", () => {
+ const result = parseModelFromRegistry("sdxl", MOCK_REGISTRY);
+ assert.deepEqual(result, { provider: "comfyui", model: "sdxl" });
+});
+
+test("parseModelFromRegistry: finds bare model in first matching provider", () => {
+ const result = parseModelFromRegistry("parakeet-ctc-1.1b-asr", MOCK_REGISTRY);
+ assert.deepEqual(result, { provider: "nvidia", model: "parakeet-ctc-1.1b-asr" });
+});
+
+test("parseModelFromRegistry: returns null provider for unknown model", () => {
+ const result = parseModelFromRegistry("nonexistent-model", MOCK_REGISTRY);
+ assert.deepEqual(result, { provider: null, model: "nonexistent-model" });
+});
+
+test("parseModelFromRegistry: handles model ID that looks like a provider prefix but isn't", () => {
+ const result = parseModelFromRegistry("unknown-provider/some-model", MOCK_REGISTRY);
+ assert.deepEqual(result, { provider: null, model: "unknown-provider/some-model" });
+});
+
+test("parseModelFromRegistry: handles provider prefix with no matching model", () => {
+ // Provider exists but model doesn't — still returns the provider from prefix match
+ const result = parseModelFromRegistry("nvidia/nonexistent", MOCK_REGISTRY);
+ assert.deepEqual(result, { provider: "nvidia", model: "nonexistent" });
+});
+
+// ═══════════════════════════════════════════════════════════════
+// getAllModelsFromRegistry
+// ═══════════════════════════════════════════════════════════════
+
+test("getAllModelsFromRegistry: returns all models with prefixed IDs", () => {
+ const models = getAllModelsFromRegistry(MOCK_REGISTRY);
+
+ // Total: elevenlabs(2) + comfyui(2) + nvidia(1) = 5
+ assert.equal(models.length, 5);
+
+ // Check IDs are prefixed
+ const ids = models.map((m) => m.id);
+ assert.ok(ids.includes("elevenlabs/eleven_multilingual_v2"));
+ assert.ok(ids.includes("comfyui/flux-dev"));
+ assert.ok(ids.includes("nvidia/parakeet-ctc-1.1b-asr"));
+});
+
+test("getAllModelsFromRegistry: each model has provider field", () => {
+ const models = getAllModelsFromRegistry(MOCK_REGISTRY);
+
+ for (const model of models) {
+ assert.ok(model.provider, `Model ${model.id} missing provider field`);
+ assert.ok(model.name, `Model ${model.id} missing name field`);
+ }
+});
+
+test("getAllModelsFromRegistry: extra callback adds fields per provider", () => {
+ const models = getAllModelsFromRegistry(MOCK_REGISTRY, (providerId, config) => ({
+ authType: config.authType,
+ }));
+
+ const elevenlabsModel = models.find((m) => m.id === "elevenlabs/eleven_multilingual_v2");
+ assert.equal(elevenlabsModel.authType, "apikey");
+
+ const comfyuiModel = models.find((m) => m.id === "comfyui/flux-dev");
+ assert.equal(comfyuiModel.authType, "none");
+});
+
+test("getAllModelsFromRegistry: returns empty array for empty registry", () => {
+ const models = getAllModelsFromRegistry({});
+ assert.deepEqual(models, []);
+});
+
+// ═══════════════════════════════════════════════════════════════
+// buildAuthHeaders
+// ═══════════════════════════════════════════════════════════════
+
+test("buildAuthHeaders: returns Bearer header for bearer authHeader", () => {
+ const headers = buildAuthHeaders(MOCK_REGISTRY.nvidia, "my-api-key");
+ assert.deepEqual(headers, { Authorization: "Bearer my-api-key" });
+});
+
+test("buildAuthHeaders: returns xi-api-key header for ElevenLabs", () => {
+ const headers = buildAuthHeaders(MOCK_REGISTRY.elevenlabs, "eleven-key-123");
+ assert.deepEqual(headers, { "xi-api-key": "eleven-key-123" });
+});
+
+test("buildAuthHeaders: returns empty object for authType none", () => {
+ const headers = buildAuthHeaders(MOCK_REGISTRY.comfyui, "any-token");
+ assert.deepEqual(headers, {});
+});
+
+test("buildAuthHeaders: returns empty object for null token", () => {
+ const headers = buildAuthHeaders(MOCK_REGISTRY.nvidia, null);
+ assert.deepEqual(headers, {});
+});
+
+test("buildAuthHeaders: returns Token header for token authHeader", () => {
+ const provider = { ...MOCK_REGISTRY.nvidia, authHeader: "token", authType: "apikey" };
+ const headers = buildAuthHeaders(provider, "hf-token");
+ assert.deepEqual(headers, { Authorization: "Token hf-token" });
+});
+
+test("buildAuthHeaders: returns x-api-key header", () => {
+ const provider = { ...MOCK_REGISTRY.nvidia, authHeader: "x-api-key", authType: "apikey" };
+ const headers = buildAuthHeaders(provider, "custom-key");
+ assert.deepEqual(headers, { "x-api-key": "custom-key" });
+});
+
+test("buildAuthHeaders: returns empty object for authHeader none", () => {
+ const provider = { ...MOCK_REGISTRY.nvidia, authHeader: "none", authType: "apikey" };
+ const headers = buildAuthHeaders(provider, "some-token");
+ assert.deepEqual(headers, {});
+});
+
+// ═══════════════════════════════════════════════════════════════
+// Integration: Video/Music/Audio registry utils
+// ═══════════════════════════════════════════════════════════════
+
+test("parseVideoModel: works via video registry", async () => {
+ const { parseVideoModel } = await import("../../open-sse/config/videoRegistry.ts");
+ const result = parseVideoModel("comfyui/animatediff");
+ assert.deepEqual(result, { provider: "comfyui", model: "animatediff" });
+});
+
+test("parseMusicModel: works via music registry", async () => {
+ const { parseMusicModel } = await import("../../open-sse/config/musicRegistry.ts");
+ const result = parseMusicModel("comfyui/stable-audio-open");
+ assert.deepEqual(result, { provider: "comfyui", model: "stable-audio-open" });
+});
+
+test("getAllVideoModels: returns video models with provider prefix", async () => {
+ const { getAllVideoModels } = await import("../../open-sse/config/videoRegistry.ts");
+ const models = getAllVideoModels();
+ assert.ok(models.length >= 3, `Expected at least 3 video models, got ${models.length}`);
+ assert.ok(models.some((m) => m.id === "comfyui/animatediff"));
+});
+
+test("getAllMusicModels: returns music models with provider prefix", async () => {
+ const { getAllMusicModels } = await import("../../open-sse/config/musicRegistry.ts");
+ const models = getAllMusicModels();
+ assert.ok(models.length >= 2, `Expected at least 2 music models, got ${models.length}`);
+ assert.ok(models.some((m) => m.id === "comfyui/stable-audio-open"));
+});