- L2 连接核查: /object_info preflight (node existence + combo values) with
5-min cache + manual refresh; analyze accepts endpoint_id, saved workflows
get POST /{id}/check; unreachable degrades to 无法核查, never blocks saving
- 测试工作流: jobs.origin='workflow_test' rides the real queue → ComfyUI →
outputs pipeline; only a downloadable, correctly-typed output counts as a
pass; dry-run refused; repeat clicks reuse the in-flight job; artifacts
isolated under assets/_workflow_test/{id}; retention keeps newest 5;
clear-tests + delete-workflow cascade cleanup; tasks page shows a 测试 badge
- Media groups: Autogrow detection generalized to video/audio lists
(ref_videos/ref_audios etc.), patcher clones/rewires per media family,
validation per list kind; entries appear only for actually-wired slots;
MiniMax H3 Ref2VA official-limit hints keyed off the node class
- 25 new backend tests (preflight / workflow-test / media-groups) against the
fake ComfyUI; fake server gains /object_info + drop_outputs knobs
Co-authored-by: multica-agent <github@multica.ai>
73 lines
2.6 KiB
TypeScript
73 lines
2.6 KiB
TypeScript
import { t } from "$lib/i18n.svelte";
|
|
|
|
/** Studio image slots (ref-upload-spec §3): PNG / JPG / WebP, ≤ 20MB each. */
|
|
export const IMAGE_SLOT_ACCEPT =
|
|
".png,.jpg,.jpeg,.webp,image/png,image/jpeg,image/webp";
|
|
export const IMAGE_SLOT_MAX_BYTES = 20 * 1024 * 1024;
|
|
const IMAGE_EXTS = [".png", ".jpg", ".jpeg", ".webp"];
|
|
|
|
/** Reference video slots (HEL-643): MP4 / WebM / MOV, ≤ 500MB (upload cap). */
|
|
export const VIDEO_SLOT_ACCEPT =
|
|
"video/mp4,video/webm,video/quicktime,.mp4,.webm,.mov";
|
|
export const VIDEO_SLOT_MAX_BYTES = 500 * 1024 * 1024;
|
|
const VIDEO_EXTS = [".mp4", ".webm", ".mov"];
|
|
|
|
/** Reference audio slots (HEL-643): MP3 / WAV / M4A, ≤ 100MB. */
|
|
export const AUDIO_SLOT_ACCEPT =
|
|
"audio/mpeg,audio/wav,audio/mp4,.mp3,.wav,.m4a";
|
|
export const AUDIO_SLOT_MAX_BYTES = 100 * 1024 * 1024;
|
|
const AUDIO_EXTS = [".mp3", ".wav", ".m4a"];
|
|
|
|
export type MediaSlotKind = "image" | "video" | "audio";
|
|
|
|
export function mediaSlotAccept(kind: MediaSlotKind): string {
|
|
if (kind === "video") return VIDEO_SLOT_ACCEPT;
|
|
if (kind === "audio") return AUDIO_SLOT_ACCEPT;
|
|
return IMAGE_SLOT_ACCEPT;
|
|
}
|
|
|
|
/** Why this file cannot fill a media slot of this kind (null = fine). */
|
|
export function mediaFileProblem(
|
|
kind: MediaSlotKind,
|
|
file: { name: string; size: number },
|
|
): string | null {
|
|
const dot = file.name.lastIndexOf(".");
|
|
const ext = dot >= 0 ? file.name.slice(dot).toLowerCase() : "";
|
|
const max =
|
|
kind === "video"
|
|
? VIDEO_SLOT_MAX_BYTES
|
|
: kind === "audio"
|
|
? AUDIO_SLOT_MAX_BYTES
|
|
: IMAGE_SLOT_MAX_BYTES;
|
|
if (kind === "video" && !VIDEO_EXTS.includes(ext))
|
|
return t("studio.errVideoFormat", { name: file.name });
|
|
if (kind === "audio" && !AUDIO_EXTS.includes(ext))
|
|
return t("studio.errAudioFormat", { name: file.name });
|
|
if (kind === "image" && !IMAGE_EXTS.includes(ext))
|
|
return t("studio.errImageFormat", { name: file.name });
|
|
if (file.size > max)
|
|
return kind === "image"
|
|
? t("studio.errImageSize", { name: file.name })
|
|
: t("studio.errMediaSize", { name: file.name });
|
|
return null;
|
|
}
|
|
|
|
/** Why this file cannot fill an image slot (null = fine). */
|
|
export function imageFileProblem(file: {
|
|
name: string;
|
|
size: number;
|
|
}): string | null {
|
|
return mediaFileProblem("image", file);
|
|
}
|
|
|
|
export function formatBytes(bytes: number): string {
|
|
if (bytes >= 1024 * 1024) return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
return `${Math.max(1, Math.round(bytes / 1024))} KB`;
|
|
}
|
|
|
|
/** Display name of an uploaded path (strips the uuid8- prefix the upload endpoint writes). */
|
|
export function uploadBaseName(p: string): string {
|
|
const raw = p.split(/[/\\]/).pop() ?? p;
|
|
return /^[0-9a-f]{8}-/.test(raw) ? raw.slice(9) : raw;
|
|
}
|