mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-20 13:52:28 +03:00
Declares the accepted thinking-effort tiers per Agnes chat model (2.0/2.5: none/low/medium/high/max; 3.0 adds minimal/xhigh), so the generic declared-tier clamp maps `xhigh`/`off` onto values the upstream accepts instead of forwarding them verbatim and collecting a 400. Validated as a combined board first (this PR merged with the 11 siblings of the same batch on the release tip): eslint on every changed file with the suppressions file, typecheck:core, check:open-sse-typecheck, complexity, cognitive-complexity, changelog-integrity, i18n new-key coverage, docs-sync, migration-numbering, provider-consistency and a duplicate-identifier audit all green, plus 275 passing / 0 failing focused node:test cases across the 28 test files the batch touches. Then re-validated alone on the fresh tip before this merge: conflicts re-resolved, file sizes rebaselined for this PR's own growth, eslint and this PR's focused tests re-run. Thanks @HouMinXi! Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com>
520 lines
19 KiB
TypeScript
520 lines
19 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-agnes-provider-"));
|
|
process.env.DATA_DIR = TEST_DATA_DIR;
|
|
|
|
const { APIKEY_PROVIDERS } = await import("../../src/shared/constants/providers.ts");
|
|
const { VIDEO_PROVIDER_IDS } = await import("../../src/shared/constants/providers.ts");
|
|
const { REGISTRY: providerRegistry, getRegistryModelThinkingEfforts } =
|
|
await import("../../open-sse/config/providerRegistry.ts");
|
|
const { IMAGE_PROVIDERS, getAllImageModels } =
|
|
await import("../../open-sse/config/imageRegistry.ts");
|
|
const { VIDEO_PROVIDERS, getAllVideoModels } =
|
|
await import("../../open-sse/config/videoRegistry.ts");
|
|
const { FREE_MODEL_BUDGETS } = await import("../../open-sse/config/freeModelCatalog.ts");
|
|
const { DefaultExecutor } = await import("../../open-sse/executors/default.ts");
|
|
const { sanitizeReasoningEffortForProvider } =
|
|
await import("../../open-sse/executors/base/reasoningEffort.ts");
|
|
const { getThinkingCapabilityFields } =
|
|
await import("../../src/app/api/v1/models/catalogHelpers.ts");
|
|
const { handleImageGeneration } = await import("../../open-sse/handlers/imageGeneration.ts");
|
|
const { handleVideoGeneration } = await import("../../open-sse/handlers/videoGeneration.ts");
|
|
const { resolveChatCoreTargetFormat } =
|
|
await import("../../open-sse/handlers/chatCore/targetFormat.ts");
|
|
const { resolveModelAlias } = await import("../../open-sse/services/modelDeprecation.ts");
|
|
const dbCore = await import("../../src/lib/db/core.ts");
|
|
|
|
test.after(() => {
|
|
dbCore.closeDbInstance();
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
});
|
|
|
|
const AGNES_CHAT_URL = "https://apihub.agnes-ai.com/v1/chat/completions";
|
|
const AGNES_MODELS_URL = "https://apihub.agnes-ai.com/v1/models";
|
|
const AGNES_CN_BASE_URL = "https://api.agnes-ai.cn/v1";
|
|
|
|
test("agnes is registered as an API-key provider with complete metadata", () => {
|
|
const entry = APIKEY_PROVIDERS.agnes;
|
|
assert.ok(entry, "APIKEY_PROVIDERS.agnes must be defined");
|
|
assert.equal(entry.id, "agnes");
|
|
assert.equal(entry.alias, "agnes");
|
|
assert.equal(entry.name, "Agnes AI");
|
|
assert.equal(entry.icon, "auto_awesome");
|
|
assert.equal(entry.color, "#10B981");
|
|
assert.equal(entry.textIcon, "AG");
|
|
assert.equal(entry.website, "https://agnes-ai.com");
|
|
assert.equal(entry.hasFree, true);
|
|
assert.ok(entry.freeNote, "freeNote must be defined");
|
|
assert.ok(entry.authHint, "authHint must be defined");
|
|
});
|
|
|
|
test("agnes registry entry uses OpenAI Chat Completions format with bearer API-key auth", () => {
|
|
const entry = providerRegistry.agnes;
|
|
assert.ok(entry, "providerRegistry.agnes must be defined");
|
|
assert.equal(entry.id, "agnes");
|
|
assert.equal(entry.format, "openai");
|
|
assert.equal(entry.executor, "default");
|
|
assert.equal(entry.authType, "apikey");
|
|
assert.equal(entry.authHeader, "bearer");
|
|
assert.equal(entry.baseUrl, AGNES_CHAT_URL);
|
|
});
|
|
|
|
test("agnes routes Chat Completions clients through its OpenAI chat upstream", () => {
|
|
const { targetFormat } = resolveChatCoreTargetFormat({
|
|
provider: "agnes",
|
|
resolvedModel: "agnes-2.5-flash",
|
|
apiFormat: undefined,
|
|
sourceFormat: "openai",
|
|
customModelTargetFormat: undefined,
|
|
providerSpecificData: null,
|
|
});
|
|
|
|
assert.equal(targetFormat, "openai");
|
|
assert.equal(
|
|
new DefaultExecutor("agnes").buildUrl("agnes-2.5-flash", true, 0, null),
|
|
AGNES_CHAT_URL
|
|
);
|
|
});
|
|
|
|
test("agnes ships the current public chat models with the correct capabilities", () => {
|
|
const entry = providerRegistry.agnes;
|
|
assert.deepEqual(
|
|
entry.models.map((model) => model.id),
|
|
["agnes-2.0-flash", "agnes-2.5-flash", "agnes-3.0-flash"]
|
|
);
|
|
|
|
const flash20 = entry.models.find((m) => m.id === "agnes-2.0-flash");
|
|
assert.ok(flash20, "agnes-2.0-flash must be defined");
|
|
assert.equal(flash20.contextLength, 262144);
|
|
assert.equal(flash20.maxOutputTokens, 65536);
|
|
assert.equal(flash20.supportsReasoning, true);
|
|
assert.deepEqual(flash20.supportedThinkingEfforts, ["none", "low", "medium", "high", "max"]);
|
|
assert.equal(flash20.supportsVision, true);
|
|
assert.equal(flash20.toolCalling, true);
|
|
|
|
const flash25 = entry.models.find((m) => m.id === "agnes-2.5-flash");
|
|
assert.ok(flash25, "agnes-2.5-flash must be defined");
|
|
assert.equal(flash25.contextLength, 524288);
|
|
assert.equal(flash25.maxOutputTokens, 65536);
|
|
assert.equal(flash25.supportsReasoning, true);
|
|
assert.deepEqual(flash25.supportedThinkingEfforts, ["none", "low", "medium", "high", "max"]);
|
|
|
|
const flash30 = entry.models.find((m) => m.id === "agnes-3.0-flash");
|
|
assert.ok(flash30, "agnes-3.0-flash must be defined");
|
|
assert.equal(flash30.contextLength, 524288);
|
|
assert.equal(flash30.maxOutputTokens, 65536);
|
|
assert.equal(flash30.supportsReasoning, true);
|
|
assert.deepEqual(flash30.supportedThinkingEfforts, [
|
|
"none",
|
|
"minimal",
|
|
"low",
|
|
"medium",
|
|
"high",
|
|
"xhigh",
|
|
"max",
|
|
]);
|
|
assert.equal(flash30.supportsVision, true);
|
|
assert.equal(flash30.toolCalling, true);
|
|
assert.equal(flash30.interleavedField, "reasoning_content");
|
|
});
|
|
|
|
test("agnes chat models advertise official thinking vocabulary", () => {
|
|
for (const id of ["agnes-2.0-flash", "agnes-2.5-flash"]) {
|
|
assert.deepEqual(getRegistryModelThinkingEfforts("agnes", id), [
|
|
"none",
|
|
"low",
|
|
"medium",
|
|
"high",
|
|
"max",
|
|
]);
|
|
}
|
|
assert.deepEqual(getRegistryModelThinkingEfforts("agnes", "agnes-3.0-flash"), [
|
|
"none",
|
|
"minimal",
|
|
"low",
|
|
"medium",
|
|
"high",
|
|
"xhigh",
|
|
"max",
|
|
]);
|
|
});
|
|
|
|
test("agnes catalog effort_tiers match declared vocabulary, not six-tier fallback", () => {
|
|
const efforts = getRegistryModelThinkingEfforts("agnes", "agnes-3.0-flash");
|
|
assert.ok(efforts && efforts.length > 0);
|
|
assert.deepEqual(
|
|
getThinkingCapabilityFields("agnes", "agnes-3.0-flash", true, efforts, !efforts.length),
|
|
{
|
|
thinking: true,
|
|
supportsThinking: true,
|
|
effort_tiers: ["none", "minimal", "low", "medium", "high", "xhigh", "max"],
|
|
}
|
|
);
|
|
});
|
|
|
|
test("agnes sanitizer keeps official tiers and clamps undocumented ones", () => {
|
|
const clamp = (model: string, effort: string) =>
|
|
(
|
|
sanitizeReasoningEffortForProvider({ reasoning_effort: effort }, "agnes", model) as {
|
|
reasoning_effort?: string;
|
|
}
|
|
).reasoning_effort;
|
|
|
|
assert.equal(clamp("agnes-3.0-flash", "none"), "none");
|
|
assert.equal(clamp("agnes-3.0-flash", "minimal"), "minimal");
|
|
assert.equal(clamp("agnes-3.0-flash", "low"), "low");
|
|
assert.equal(clamp("agnes-3.0-flash", "high"), "high");
|
|
assert.equal(clamp("agnes-3.0-flash", "xhigh"), "xhigh");
|
|
assert.equal(clamp("agnes-3.0-flash", "max"), "max");
|
|
assert.equal(clamp("agnes-3.0-flash", "ultra"), "max");
|
|
assert.equal(clamp("agnes-3.0-flash", "off"), "none");
|
|
|
|
// 2.0/2.5 reject xhigh (HTTP 400); clamp up to the next accepted tier (max).
|
|
assert.equal(clamp("agnes-2.0-flash", "xhigh"), "max");
|
|
assert.equal(clamp("agnes-2.5-flash", "xhigh"), "max");
|
|
assert.equal(clamp("agnes-2.0-flash", "max"), "max");
|
|
assert.equal(clamp("agnes-2.0-flash", "off"), "none");
|
|
assert.equal(clamp("agnes-2.0-flash", "minimal"), "low");
|
|
assert.equal(clamp("agnes-2.5-flash", "minimal"), "low");
|
|
assert.equal(clamp("agnes-2.5-flash", "off"), "none");
|
|
});
|
|
|
|
test("agnes registry advertises the live OpenAI-style /models endpoint", () => {
|
|
const entry = providerRegistry.agnes;
|
|
assert.equal(entry.modelsUrl, AGNES_MODELS_URL);
|
|
});
|
|
|
|
test("agnes is classified for live OpenAI-style /models discovery", async () => {
|
|
const { isNamedOpenAIStyleProvider } =
|
|
await import("../../src/app/api/providers/[id]/models/discovery/providerSets.ts");
|
|
assert.equal(isNamedOpenAIStyleProvider("agnes"), true);
|
|
});
|
|
|
|
test("agnes honors per-connection CN base URL override", () => {
|
|
const url = new DefaultExecutor("agnes").buildUrl("agnes-3.0-flash", true, 0, {
|
|
providerSpecificData: { baseUrl: AGNES_CN_BASE_URL },
|
|
});
|
|
assert.equal(url, `${AGNES_CN_BASE_URL}/chat/completions`);
|
|
});
|
|
|
|
test("agnes base-URL field is always-on so CN keys can point at api.agnes-ai.cn", async () => {
|
|
const helpers =
|
|
await import("../../src/app/(dashboard)/dashboard/providers/[id]/providerPageHelpers.ts");
|
|
assert.equal(helpers.isBaseUrlConfigurableProvider("agnes"), true);
|
|
assert.equal(helpers.getProviderBaseUrlDefault("agnes"), "https://apihub.agnes-ai.com/v1");
|
|
assert.equal(helpers.getProviderBaseUrlPlaceholder("agnes"), AGNES_CN_BASE_URL);
|
|
});
|
|
|
|
test("agnes-1.5-flash is retired and forwards to agnes-3.0-flash", () => {
|
|
const entry = providerRegistry.agnes;
|
|
assert.equal(
|
|
entry.models.some((model) => model.id === "agnes-1.5-flash"),
|
|
false
|
|
);
|
|
assert.equal(resolveModelAlias("agnes-1.5-flash", "agnes"), "agnes-3.0-flash");
|
|
});
|
|
|
|
test("agnes free catalog exposes the current free chat models through one shared pool", () => {
|
|
const rows = FREE_MODEL_BUDGETS.filter((model) => model.provider === "agnes");
|
|
assert.deepEqual(
|
|
rows.map((model) => model.modelId),
|
|
["agnes-2.0-flash", "agnes-2.5-flash", "agnes-3.0-flash"]
|
|
);
|
|
assert.ok(rows.every((model) => model.poolKey === "agnes-free"));
|
|
});
|
|
|
|
test("agnes has no collision with zenmux-free sapiens-ai prefixed models", (t) => {
|
|
const zenmux = providerRegistry["zenmux-free"];
|
|
if (!zenmux) {
|
|
t.skip("zenmux-free not registered in this environment");
|
|
return;
|
|
}
|
|
const agnesInZenmux = zenmux.models.filter((m) => m.id.includes("agnes"));
|
|
for (const m of agnesInZenmux) {
|
|
assert.ok(
|
|
m.id.startsWith("sapiens-ai/"),
|
|
`zenmux agnes model ${m.id} must use sapiens-ai/ prefix to avoid collision`
|
|
);
|
|
}
|
|
});
|
|
|
|
test("agnes registers Image 2.x Flash models on the current image-generation contract", () => {
|
|
const entry = IMAGE_PROVIDERS.agnes;
|
|
assert.ok(entry, "IMAGE_PROVIDERS.agnes must be defined");
|
|
assert.equal(entry.baseUrl, "https://apihub.agnes-ai.com/v1/images/generations");
|
|
assert.equal(entry.authHeader, "bearer");
|
|
assert.equal(entry.format, "agnes-image");
|
|
assert.deepEqual(entry.supportedSizes, ["1K", "2K", "3K", "4K"]);
|
|
assert.deepEqual(
|
|
entry.models.map((model) => model.id),
|
|
["agnes-image-2.0-flash", "agnes-image-2.1-flash", "agnes-image-2.5-flash"]
|
|
);
|
|
assert.ok(getAllImageModels().some((model) => model.id === "agnes/agnes-image-2.1-flash"));
|
|
assert.ok(getAllImageModels().some((model) => model.id === "agnes/agnes-image-2.5-flash"));
|
|
});
|
|
|
|
test("agnes Image 2.1 maps standard image inputs into extra_body", async () => {
|
|
const originalFetch = globalThis.fetch;
|
|
let captured:
|
|
{ url: string; headers: Record<string, string>; body: Record<string, unknown> } | undefined;
|
|
|
|
globalThis.fetch = (async (url: string | URL | Request, init?: RequestInit) => {
|
|
captured = {
|
|
url: String(url),
|
|
headers: init?.headers as Record<string, string>,
|
|
body: JSON.parse(String(init?.body)) as Record<string, unknown>,
|
|
};
|
|
return new Response(
|
|
JSON.stringify({
|
|
created: 123,
|
|
data: [{ b64_json: "generated-image", revised_prompt: "combined references" }],
|
|
}),
|
|
{ status: 200, headers: { "content-type": "application/json" } }
|
|
);
|
|
}) as typeof fetch;
|
|
|
|
try {
|
|
const result = await handleImageGeneration({
|
|
body: {
|
|
model: "agnes/agnes-image-2.1-flash",
|
|
prompt: "Combine both references into one cinematic poster",
|
|
size: "2K",
|
|
aspect_ratio: "16:9",
|
|
image_urls: ["https://example.com/one.png", "data:image/png;base64,dHdv"],
|
|
response_format: "b64_json",
|
|
extra_body: { workflow_hint: "preserve-composition" },
|
|
},
|
|
credentials: { apiKey: "agnes-key" },
|
|
log: null,
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
assert.ok(captured, "Agnes image request must be sent upstream");
|
|
assert.equal(captured.url, "https://apihub.agnes-ai.com/v1/images/generations");
|
|
assert.equal(captured.headers.Authorization, "Bearer agnes-key");
|
|
assert.deepEqual(captured.body, {
|
|
model: "agnes-image-2.1-flash",
|
|
prompt: "Combine both references into one cinematic poster",
|
|
size: "2K",
|
|
ratio: "16:9",
|
|
extra_body: {
|
|
workflow_hint: "preserve-composition",
|
|
image: ["https://example.com/one.png", "data:image/png;base64,dHdv"],
|
|
response_format: "b64_json",
|
|
},
|
|
});
|
|
assert.equal(result.data.data[0].b64_json, "generated-image");
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|
|
|
|
test("agnes Image 2.1 requires the current size parameter", async () => {
|
|
const result = await handleImageGeneration({
|
|
body: {
|
|
model: "agnes/agnes-image-2.1-flash",
|
|
prompt: "A detailed cityscape",
|
|
},
|
|
credentials: { apiKey: "agnes-key" },
|
|
log: null,
|
|
});
|
|
|
|
assert.equal(result.success, false);
|
|
assert.equal(result.status, 400);
|
|
assert.equal(result.error, "Size is required for Agnes Image 2.1 Flash");
|
|
});
|
|
|
|
test("agnes registers Video V2.0 and Video 2.5 on the current job contracts", () => {
|
|
const entry = VIDEO_PROVIDERS.agnes;
|
|
assert.ok(entry, "VIDEO_PROVIDERS.agnes must be defined");
|
|
assert.equal(entry.baseUrl, "https://apihub.agnes-ai.com");
|
|
assert.equal(entry.statusUrl, "https://apihub.agnes-ai.com/agnesapi");
|
|
assert.equal(entry.authHeader, "bearer");
|
|
assert.equal(entry.format, "agnes-video-job");
|
|
assert.deepEqual(
|
|
entry.models.map((model) => model.id),
|
|
["agnes-video-v2.0", "agnes-video-2.5-flash", "agnes-video-2.5"]
|
|
);
|
|
assert.equal(VIDEO_PROVIDER_IDS.has("agnes"), true);
|
|
assert.ok(getAllVideoModels().some((model) => model.id === "agnes/agnes-video-v2.0"));
|
|
assert.ok(getAllVideoModels().some((model) => model.id === "agnes/agnes-video-2.5-flash"));
|
|
assert.ok(getAllVideoModels().some((model) => model.id === "agnes/agnes-video-2.5"));
|
|
});
|
|
|
|
test("agnes Video V2.0 submits with Bearer auth and polls by video_id and model_name", async () => {
|
|
const originalFetch = globalThis.fetch;
|
|
const originalSetTimeout = globalThis.setTimeout;
|
|
const calls: Array<{
|
|
url: string;
|
|
method: string;
|
|
headers: Record<string, string>;
|
|
body?: Record<string, unknown>;
|
|
}> = [];
|
|
|
|
globalThis.setTimeout = ((callback: (...args: unknown[]) => void, _ms?: number, ...args) => {
|
|
callback(...args);
|
|
return 0;
|
|
}) as typeof setTimeout;
|
|
globalThis.fetch = (async (url: string | URL | Request, init?: RequestInit) => {
|
|
const call = {
|
|
url: String(url),
|
|
method: init?.method || "GET",
|
|
headers: init?.headers as Record<string, string>,
|
|
...(init?.body ? { body: JSON.parse(String(init.body)) as Record<string, unknown> } : {}),
|
|
};
|
|
calls.push(call);
|
|
|
|
if (call.method === "POST") {
|
|
return new Response(
|
|
JSON.stringify({
|
|
id: "task-123",
|
|
task_id: "task-123",
|
|
video_id: "video-123",
|
|
status: "queued",
|
|
}),
|
|
{ status: 200, headers: { "content-type": "application/json" } }
|
|
);
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
status: "completed",
|
|
metadata: { url: "https://platform-outputs.agnes-ai.space/video-123.mp4" },
|
|
}),
|
|
{ status: 200, headers: { "content-type": "application/json" } }
|
|
);
|
|
}) as typeof fetch;
|
|
|
|
try {
|
|
const result = await handleVideoGeneration({
|
|
body: {
|
|
model: "agnes/agnes-video-v2.0",
|
|
prompt: "A product rotates slowly under studio lighting",
|
|
width: 1152,
|
|
height: 768,
|
|
num_frames: 121,
|
|
frame_rate: 24,
|
|
extra_body: {
|
|
image: ["https://example.com/keyframe-one.png", "https://example.com/keyframe-two.png"],
|
|
mode: "keyframes",
|
|
},
|
|
},
|
|
credentials: { apiKey: "agnes-key" },
|
|
log: null,
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
assert.equal(result.data.data[0].url, "https://platform-outputs.agnes-ai.space/video-123.mp4");
|
|
assert.equal(calls.length, 2);
|
|
assert.deepEqual(calls[0], {
|
|
url: "https://apihub.agnes-ai.com/v1/videos",
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
Authorization: "Bearer agnes-key",
|
|
},
|
|
body: {
|
|
model: "agnes-video-v2.0",
|
|
prompt: "A product rotates slowly under studio lighting",
|
|
width: 1152,
|
|
height: 768,
|
|
num_frames: 121,
|
|
frame_rate: 24,
|
|
extra_body: {
|
|
image: ["https://example.com/keyframe-one.png", "https://example.com/keyframe-two.png"],
|
|
mode: "keyframes",
|
|
},
|
|
},
|
|
});
|
|
assert.deepEqual(calls[1], {
|
|
url: "https://apihub.agnes-ai.com/agnesapi?video_id=video-123&model_name=agnes-video-v2.0",
|
|
method: "GET",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
Authorization: "Bearer agnes-key",
|
|
},
|
|
});
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
globalThis.setTimeout = originalSetTimeout;
|
|
}
|
|
});
|
|
|
|
test("agnes Video 2.5-flash submits Bearer auth and polls /v1/videos/{id}", async () => {
|
|
const originalFetch = globalThis.fetch;
|
|
const originalSetTimeout = globalThis.setTimeout;
|
|
const calls: Array<{
|
|
url: string;
|
|
method: string;
|
|
headers: Record<string, string>;
|
|
body?: Record<string, unknown>;
|
|
}> = [];
|
|
|
|
globalThis.setTimeout = ((callback: (...args: unknown[]) => void, _ms?: number, ...args) => {
|
|
callback(...args);
|
|
return 0;
|
|
}) as typeof setTimeout;
|
|
globalThis.fetch = (async (url: string | URL | Request, init?: RequestInit) => {
|
|
const call = {
|
|
url: String(url),
|
|
method: init?.method || "GET",
|
|
headers: (init?.headers || {}) as Record<string, string>,
|
|
...(init?.body ? { body: JSON.parse(String(init.body)) as Record<string, unknown> } : {}),
|
|
};
|
|
calls.push(call);
|
|
|
|
if (call.method === "POST") {
|
|
return new Response(
|
|
JSON.stringify({
|
|
id: "task_nEV6cJjyzWnix1g1O9QHjnHzTstegDGM",
|
|
status: "queued",
|
|
}),
|
|
{ status: 200, headers: { "content-type": "application/json" } }
|
|
);
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
id: "task_nEV6cJjyzWnix1g1O9QHjnHzTstegDGM",
|
|
status: "completed",
|
|
url: "https://platform-outputs.agnes-ai.space/video-25.mp4",
|
|
}),
|
|
{ status: 200, headers: { "content-type": "application/json" } }
|
|
);
|
|
}) as typeof fetch;
|
|
|
|
try {
|
|
const result = await handleVideoGeneration({
|
|
body: {
|
|
model: "agnes/agnes-video-2.5-flash",
|
|
prompt: "a red ball rolling on a white floor",
|
|
seconds: "4",
|
|
mode: "text",
|
|
size: "720P",
|
|
aspect_ratio: "16:9",
|
|
},
|
|
credentials: { apiKey: "agnes-key" },
|
|
log: null,
|
|
});
|
|
|
|
assert.equal(result.success, true);
|
|
assert.equal(result.data.data[0].url, "https://platform-outputs.agnes-ai.space/video-25.mp4");
|
|
assert.equal(calls.length, 2);
|
|
assert.equal(calls[0].url, "https://apihub.agnes-ai.com/v1/videos");
|
|
assert.equal(calls[0].method, "POST");
|
|
assert.equal(calls[0].body?.model, "agnes-video-2.5-flash");
|
|
assert.equal(calls[0].body?.seconds, "4");
|
|
assert.equal(calls[0].body?.mode, "text");
|
|
assert.equal(
|
|
calls[1].url,
|
|
"https://apihub.agnes-ai.com/v1/videos/task_nEV6cJjyzWnix1g1O9QHjnHzTstegDGM"
|
|
);
|
|
assert.equal(calls[1].method, "GET");
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
globalThis.setTimeout = originalSetTimeout;
|
|
}
|
|
});
|