- 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>
319 lines
9.8 KiB
Python
319 lines
9.8 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Any, Literal
|
|
|
|
from pydantic import AliasChoices, BaseModel, ConfigDict, Field
|
|
|
|
|
|
class ProjectCreate(BaseModel):
|
|
"""`name` is accepted as an alias for `title` — LLM agents and external API
|
|
clients very often emit `name` for the required project title field and get
|
|
an opaque 422 otherwise."""
|
|
|
|
model_config = ConfigDict(populate_by_name=True)
|
|
|
|
title: str = Field(..., min_length=1, max_length=200, validation_alias=AliasChoices("title", "name"))
|
|
idea: str | None = None
|
|
genre: str | None = None
|
|
tone: str | None = None
|
|
target_duration: str | None = None
|
|
|
|
|
|
class ProjectUpdate(BaseModel):
|
|
model_config = ConfigDict(populate_by_name=True)
|
|
|
|
title: str | None = Field(
|
|
None, min_length=1, max_length=200, validation_alias=AliasChoices("title", "name")
|
|
)
|
|
idea: str | None = None
|
|
genre: str | None = None
|
|
tone: str | None = None
|
|
target_duration: str | None = None
|
|
cover_path: str | None = None
|
|
status: str | None = None
|
|
|
|
|
|
class ProjectStats(BaseModel):
|
|
scene_count: int
|
|
character_count: int
|
|
asset_ready_count: int
|
|
asset_total_count: int
|
|
# Five-stage workbench progress (HEL-614) — real stage rows + live jobs.
|
|
stage_confirmed: int = 0
|
|
stage_status: dict[str, str] = Field(default_factory=dict)
|
|
active_jobs: int = 0
|
|
|
|
|
|
class Project(BaseModel):
|
|
id: int
|
|
title: str
|
|
idea: str | None
|
|
genre: str | None
|
|
tone: str | None
|
|
target_duration: str | None
|
|
cover_path: str | None = None
|
|
status: str
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
stats: ProjectStats | None = None
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class ProjectList(BaseModel):
|
|
projects: list[Project]
|
|
|
|
|
|
class ProjectStats(BaseModel):
|
|
scene_count: int = 0
|
|
character_count: int = 0
|
|
asset_ready_count: int = 0
|
|
asset_total_count: int = 0
|
|
|
|
|
|
class BeatCreate(BaseModel):
|
|
order_index: int = 0
|
|
title: str = Field(..., min_length=1)
|
|
description: str | None = None
|
|
|
|
|
|
class BeatUpdate(BaseModel):
|
|
order_index: int | None = None
|
|
title: str | None = None
|
|
description: str | None = None
|
|
|
|
|
|
class CharacterCreate(BaseModel):
|
|
name: str = Field(..., min_length=1)
|
|
role: str | None = None
|
|
age: str | None = None
|
|
appearance: str | None = None
|
|
personality: str | None = None
|
|
consistency_prompt: str | None = None
|
|
|
|
|
|
class CharacterUpdate(BaseModel):
|
|
name: str | None = None
|
|
role: str | None = None
|
|
age: str | None = None
|
|
appearance: str | None = None
|
|
personality: str | None = None
|
|
consistency_prompt: str | None = None
|
|
portrait_path: str | None = None
|
|
sheet_path: str | None = None
|
|
|
|
|
|
class LocationCreate(BaseModel):
|
|
name: str = Field(..., min_length=1)
|
|
description: str | None = None
|
|
consistency_prompt: str | None = None
|
|
|
|
|
|
class LocationUpdate(BaseModel):
|
|
name: str | None = None
|
|
description: str | None = None
|
|
consistency_prompt: str | None = None
|
|
reference_image_path: str | None = None
|
|
|
|
|
|
class ItemCreate(BaseModel):
|
|
name: str = Field(..., min_length=1)
|
|
description: str | None = None
|
|
consistency_prompt: str | None = None
|
|
|
|
|
|
class ItemUpdate(BaseModel):
|
|
name: str | None = None
|
|
description: str | None = None
|
|
consistency_prompt: str | None = None
|
|
reference_image_path: str | None = None
|
|
|
|
|
|
class SceneCreate(BaseModel):
|
|
order_index: int = 0
|
|
heading: str | None = None
|
|
action: str | None = None
|
|
dialog: str | None = None
|
|
duration_sec: int | None = None
|
|
workflow_id: int | None = None
|
|
env_image_path: str | None = None
|
|
beat_id: int | None = None
|
|
character_ids: list[int] = Field(default_factory=list)
|
|
location_id: int | None = None
|
|
|
|
|
|
class SceneUpdate(BaseModel):
|
|
order_index: int | None = None
|
|
heading: str | None = None
|
|
action: str | None = None
|
|
dialog: str | None = None
|
|
duration_sec: int | None = None
|
|
workflow_id: int | None = None
|
|
env_image_path: str | None = None
|
|
beat_id: int | None = None
|
|
character_ids: list[int] | None = None
|
|
location_id: int | None = None
|
|
video_path: str | None = None
|
|
chain_from_prev: bool | None = None
|
|
# Persisted video-stage setup: form input_values, clip source, prompt
|
|
# draft + metadata. Serialized into scenes.video_settings_json.
|
|
video_settings: dict[str, Any] | None = None
|
|
|
|
|
|
class SceneReorder(BaseModel):
|
|
scene_ids: list[int]
|
|
|
|
|
|
class ClipCreate(BaseModel):
|
|
order_index: int | None = None # default: append at end of the scene
|
|
description: str | None = None
|
|
shot_size: str | None = None
|
|
dialog_lines_covered: list[int] | None = None
|
|
duration_sec: int | None = None
|
|
workflow_id: int | None = None
|
|
chain_from_prev: bool = False
|
|
video_settings: dict[str, Any] | None = None
|
|
|
|
|
|
class ClipUpdate(BaseModel):
|
|
order_index: int | None = None
|
|
description: str | None = None
|
|
shot_size: str | None = None
|
|
dialog_lines_covered: list[int] | None = None
|
|
duration_sec: int | None = None
|
|
workflow_id: int | None = None
|
|
clip_path: str | None = None
|
|
chain_from_prev: bool | None = None
|
|
video_settings: dict[str, Any] | None = None
|
|
|
|
|
|
class ClipReorder(BaseModel):
|
|
clip_ids: list[int]
|
|
|
|
|
|
class ExpandClipsRequest(BaseModel):
|
|
scene_ids: list[int] | None = None
|
|
guidance: str | None = None
|
|
clip_cap: int | None = None
|
|
|
|
|
|
WorkflowUsageKind = Literal[
|
|
"text2image",
|
|
"image2image",
|
|
"text2video",
|
|
"image2video",
|
|
"ref2video",
|
|
]
|
|
|
|
|
|
class WorkflowCreate(BaseModel):
|
|
name: str = Field(..., min_length=1)
|
|
kind: Literal["image", "video"] | None = None
|
|
workflow_json: dict[str, Any]
|
|
description: str | None = None
|
|
prompt_profile: Literal["prose", "minimax_h3_ref"] | None = None
|
|
# Optional binding to a ComfyUI connection id (settings.comfyui_endpoints).
|
|
endpoint_id: str | None = None
|
|
# HEL-636: five-way usage. Given by the import confirm page (possibly a
|
|
# user correction of the auto judgment); when absent it is classified
|
|
# from the graph, and indeterminate workflows stay pending (disabled).
|
|
usage: WorkflowUsageKind | None = None
|
|
usage_source: Literal["auto", "user"] | None = None
|
|
# Schema corrected on the confirm page (manual role overrides included).
|
|
input_schema: list[dict[str, Any]] | None = None
|
|
# HEL-638: explicit output-node designation for unknown custom output
|
|
# nodes — [{nodeId, kind: image|video}]. Required before a workflow
|
|
# with unknown outputs can be enabled or generated.
|
|
output_map: list[dict[str, Any]] | None = None
|
|
output_map_source: Literal["auto", "user"] | None = None
|
|
|
|
|
|
class WorkflowUpdate(BaseModel):
|
|
name: str | None = None
|
|
kind: Literal["image", "video"] | None = None
|
|
description: str | None = None
|
|
prompt_profile: Literal["prose", "minimax_h3_ref"] | None = None
|
|
is_enabled: bool | None = None
|
|
endpoint_id: str | None = None
|
|
usage: WorkflowUsageKind | None = None
|
|
usage_source: Literal["auto", "user"] | None = None
|
|
input_schema: list[dict[str, Any]] | None = None
|
|
# HEL-638: set/replace the user output mapping; an explicit empty list
|
|
# resets the workflow to pending confirmation.
|
|
output_map: list[dict[str, Any]] | None = None
|
|
output_map_source: Literal["auto", "user"] | None = None
|
|
|
|
|
|
class WorkflowAnalyze(BaseModel):
|
|
workflow_json: dict[str, Any]
|
|
# HEL-643: optional target connection — given, the analyze response also
|
|
# carries an L2 connection check (node/model availability via /object_info).
|
|
endpoint_id: str | None = None
|
|
# Bypass the /object_info cache (user re-checks after installing nodes).
|
|
refresh: bool = False
|
|
|
|
|
|
class WorkflowCheckRequest(BaseModel):
|
|
"""L2 re-check of a saved workflow against a live ComfyUI (HEL-643)."""
|
|
endpoint_id: str | None = None
|
|
refresh: bool = False
|
|
|
|
|
|
class WorkflowTestRequest(BaseModel):
|
|
"""Launch one real test run of a workflow (HEL-643 L3)."""
|
|
endpoint_id: str | None = None
|
|
input_values: dict[str, Any] = Field(default_factory=dict)
|
|
|
|
|
|
class JobCreate(BaseModel):
|
|
scene_id: int | None = None
|
|
clip_id: int | None = None
|
|
kind: str
|
|
workflow_id: int | None = None
|
|
input_values: dict[str, Any] | None = None
|
|
character_id: int | None = None
|
|
location_id: int | None = None
|
|
|
|
|
|
class GenerateAssetsRequest(BaseModel):
|
|
character_ids: list[int] | None = None
|
|
location_ids: list[int] | None = None
|
|
item_ids: list[int] | None = None
|
|
missing_only: bool = True
|
|
workflow_id: int | None = None
|
|
input_values: dict[str, Any] | None = None
|
|
# For characters: which image slot to write. Default/UI is "sheet" only
|
|
# (sheet includes face close-up). "portrait" remains for legacy queued jobs.
|
|
asset_target: str | None = "sheet"
|
|
# Optional one-shot prompt override (must still be user-visible text from the UI).
|
|
prompt: str | None = None
|
|
|
|
|
|
class GenerateScenesRequest(BaseModel):
|
|
replace: bool = True
|
|
# When set (or inferred from existing scenes), regenerate must produce at least this many.
|
|
scene_count: int | None = None
|
|
|
|
|
|
class GenerateVideosRequest(BaseModel):
|
|
# Clip scoping is canonical; scene_ids expands to all clips of those scenes.
|
|
scene_ids: list[int] | None = None
|
|
clip_ids: list[int] | None = None
|
|
workflow_id: int | None = None
|
|
input_values: dict[str, Any] | None = None
|
|
# Clip-id → confirmed prompt text (from the review modal). Wins over the
|
|
# LLM rewrite and over any saved draft.
|
|
prompts: dict[int, str] | None = None
|
|
|
|
|
|
class PreviewPromptRequest(BaseModel):
|
|
scene_id: int | None = None
|
|
clip_id: int | None = None
|
|
workflow_id: int | None = None
|
|
# Live Video-tab form values. Image and video slots here are the files the
|
|
# H3 rewrite must describe; they win over the saved clip setup.
|
|
input_values: dict[str, Any] | None = None
|
|
# Skip a fresh saved draft and rewrite from the current references.
|
|
force: bool = False
|