Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48e16ae443 | ||
|
|
319c7b049b | ||
|
|
e3bfe771af | ||
|
|
e6f761f8c8 |
@@ -13,6 +13,11 @@ from calliope.comfyui.registry import IMAGE_CLASSES, AUDIO_CLASSES, VIDEO_CLASSE
|
|||||||
|
|
||||||
logger = logging.getLogger("calliope.comfyui")
|
logger = logging.getLogger("calliope.comfyui")
|
||||||
|
|
||||||
|
# Reachability probe budget (HEL-619): matches the connections-page test
|
||||||
|
# probe (5s). Without it health() inherits the 120s client default, so a
|
||||||
|
# bad endpoint hangs every queued job for two minutes before failing.
|
||||||
|
HEALTH_TIMEOUT_SEC = 5.0
|
||||||
|
|
||||||
|
|
||||||
def _surface_error(prefix: str, resp: httpx.Response) -> RuntimeError:
|
def _surface_error(prefix: str, resp: httpx.Response) -> RuntimeError:
|
||||||
"""Raise with ComfyUI's own error body instead of an opaque status line.
|
"""Raise with ComfyUI's own error body instead of an opaque status line.
|
||||||
@@ -76,7 +81,9 @@ class ComfyUIClient:
|
|||||||
|
|
||||||
async def health(self) -> bool:
|
async def health(self) -> bool:
|
||||||
try:
|
try:
|
||||||
resp = await self._http.get(f"{self.base_url}/system_stats")
|
resp = await self._http.get(
|
||||||
|
f"{self.base_url}/system_stats", timeout=HEALTH_TIMEOUT_SEC
|
||||||
|
)
|
||||||
return resp.status_code == 200
|
return resp.status_code == 200
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
@@ -285,16 +292,46 @@ class ComfyUIClient:
|
|||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.warning("ComfyUI interrupt failed: %s", exc)
|
logger.warning("ComfyUI interrupt failed: %s", exc)
|
||||||
|
|
||||||
def extract_outputs(self, history: dict[str, Any]) -> list[dict[str, str]]:
|
# History items carry no explicit media type — infer from the file
|
||||||
|
# extension first, then the history key the node reported under.
|
||||||
|
_VIDEO_EXTS = frozenset({".mp4", ".webm", ".mkv", ".mov", ".gif", ".m4v", ".avi", ".flv"})
|
||||||
|
_IMAGE_EXTS = frozenset({".png", ".jpg", ".jpeg", ".webp", ".bmp", ".tif", ".tiff"})
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _infer_media_kind(cls, filename: str, history_key: str) -> str | None:
|
||||||
|
ext = Path(str(filename)).suffix.lower()
|
||||||
|
if ext in cls._VIDEO_EXTS:
|
||||||
|
return "video"
|
||||||
|
if ext in cls._IMAGE_EXTS:
|
||||||
|
return "image"
|
||||||
|
if history_key in ("gifs", "videos"):
|
||||||
|
return "video"
|
||||||
|
return None
|
||||||
|
|
||||||
|
def extract_outputs(
|
||||||
|
self, history: dict[str, Any], node_kinds: dict[str, str] | None = None
|
||||||
|
) -> list[dict[str, str]]:
|
||||||
|
"""Media items in a finished prompt's history.
|
||||||
|
|
||||||
|
``node_kinds`` (HEL-638) scopes the harvest to the workflow's
|
||||||
|
confirmed output nodes — {nodeId: image|video} — so results from
|
||||||
|
nodes the user never designated are ignored, and each item carries
|
||||||
|
the node id plus its inferred media kind for mismatch checks.
|
||||||
|
"""
|
||||||
outputs: list[dict[str, str]] = []
|
outputs: list[dict[str, str]] = []
|
||||||
for _node_id, node_out in (history.get("outputs") or {}).items():
|
for node_id, node_out in (history.get("outputs") or {}).items():
|
||||||
|
if node_kinds is not None and str(node_id) not in node_kinds:
|
||||||
|
continue
|
||||||
for key in ("images", "gifs", "videos"):
|
for key in ("images", "gifs", "videos"):
|
||||||
for item in node_out.get(key) or []:
|
for item in node_out.get(key) or []:
|
||||||
|
filename = item.get("filename", "")
|
||||||
outputs.append(
|
outputs.append(
|
||||||
{
|
{
|
||||||
"filename": item.get("filename", ""),
|
"filename": filename,
|
||||||
"subfolder": item.get("subfolder", ""),
|
"subfolder": item.get("subfolder", ""),
|
||||||
"type": item.get("type", "output"),
|
"type": item.get("type", "output"),
|
||||||
|
"node_id": str(node_id),
|
||||||
|
"media_kind": self._infer_media_kind(filename, key) or "",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return outputs
|
return outputs
|
||||||
|
|||||||
@@ -78,10 +78,42 @@ def workflow_warnings(workflow: dict[str, Any]) -> list[dict[str, str]]:
|
|||||||
"level": "warning",
|
"level": "warning",
|
||||||
"code": "orphan_latent",
|
"code": "orphan_latent",
|
||||||
"node_id": nid,
|
"node_id": nid,
|
||||||
"message": f"{_title(nid, node)}没有接到任何节点,"
|
"message": f"{_title(nid, nodes[nid])}没有接到任何节点,"
|
||||||
"它的宽高不会生效,已不在表单中显示",
|
"它的宽高不会生效,已不在表单中显示",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# HEL-636/638: a workflow without any recognizable output node can never
|
||||||
|
# return a result — block it with a readable reason instead of letting
|
||||||
|
# ComfyUI run blind. Unknown candidates (needs_mapping) don't trigger
|
||||||
|
# this: the user designates them on the import/connections page, and
|
||||||
|
# until then the row stays disabled.
|
||||||
|
from calliope.comfyui.parser import detect_output_nodes
|
||||||
|
|
||||||
|
outputs = detect_output_nodes(workflow)
|
||||||
|
if not any(o.get("kind") in ("image", "video") for o in outputs):
|
||||||
|
unknown = [o for o in outputs if o.get("evidence") == "unknown_node"]
|
||||||
|
if not unknown:
|
||||||
|
found.append(
|
||||||
|
{
|
||||||
|
"level": "error",
|
||||||
|
"code": "no_output",
|
||||||
|
"node_id": "",
|
||||||
|
"message": "未在图中找到输出节点(SaveImage / 视频合成等),"
|
||||||
|
"请确认导出的是 API 格式且包含保存节点",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
names = "、".join(f"节点 {o['nodeId']}" for o in unknown[:4])
|
||||||
|
found.append(
|
||||||
|
{
|
||||||
|
"level": "warning",
|
||||||
|
"code": "unknown_output_node",
|
||||||
|
"node_id": names,
|
||||||
|
"message": f"存在无法识别的输出节点({names}),"
|
||||||
|
"需人工指定实际输出节点及其媒体类型(图片/视频)后才能生成",
|
||||||
|
}
|
||||||
|
)
|
||||||
return found
|
return found
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
"""Stored output-node mapping for imported workflows (HEL-638).
|
||||||
|
|
||||||
|
Unknown custom output nodes are never auto-typed. The import confirm page
|
||||||
|
(or the connections table) stores the user's explicit designation — which
|
||||||
|
node ids are the real outputs and each one's media type — in
|
||||||
|
``workflows.output_map`` with ``output_map_source='user'``. Everything that
|
||||||
|
re-derives schemas (reanalyze, migration, plain field edits) must keep that
|
||||||
|
decision; only a fresh explicit payload replaces it.
|
||||||
|
|
||||||
|
Rows without unknown candidates carry an ``auto`` map derived from the
|
||||||
|
trusted registry/tagged outputs so the generation path always knows which
|
||||||
|
history nodes to harvest.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from calliope.comfyui.parser import parse_dynamic_outputs
|
||||||
|
from calliope.comfyui.registry import (
|
||||||
|
IMAGE_OUTPUT_CLASSES,
|
||||||
|
NUMBER_CLASSES,
|
||||||
|
TEXT_AREA_CLASSES,
|
||||||
|
VIDEO_OUTPUT_CLASSES,
|
||||||
|
)
|
||||||
|
|
||||||
|
VALID_OUTPUT_KINDS = ("image", "video")
|
||||||
|
|
||||||
|
|
||||||
|
def _wiring_class(class_type: str) -> bool:
|
||||||
|
"""Parameter / wiring classes can never be designated as outputs."""
|
||||||
|
return (
|
||||||
|
not class_type
|
||||||
|
or class_type in TEXT_AREA_CLASSES
|
||||||
|
or class_type in NUMBER_CLASSES
|
||||||
|
or class_type.startswith("Empty")
|
||||||
|
or class_type.startswith("Primitive")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _entry_public(entry: dict[str, Any]) -> dict[str, Any]:
|
||||||
|
out = {
|
||||||
|
"nodeId": str(entry.get("nodeId") or ""),
|
||||||
|
"kind": entry.get("kind"),
|
||||||
|
}
|
||||||
|
if entry.get("label"):
|
||||||
|
out["label"] = entry["label"]
|
||||||
|
if entry.get("class_type"):
|
||||||
|
out["class_type"] = entry["class_type"]
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def auto_output_map(workflow: dict[str, Any]) -> list[dict[str, Any]]:
|
||||||
|
"""Trusted outputs only (tagged titles / registry classes)."""
|
||||||
|
if not isinstance(workflow, dict):
|
||||||
|
return []
|
||||||
|
return [
|
||||||
|
_entry_public(o)
|
||||||
|
for o in parse_dynamic_outputs(workflow)
|
||||||
|
if o.get("kind") in VALID_OUTPUT_KINDS
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def needs_user_output_map(workflow: dict[str, Any]) -> bool:
|
||||||
|
"""True when the graph has unknown output candidates (HEL-638)."""
|
||||||
|
if not isinstance(workflow, dict):
|
||||||
|
return False
|
||||||
|
return any(
|
||||||
|
o.get("evidence") == "unknown_node" for o in parse_dynamic_outputs(workflow)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_output_map(
|
||||||
|
workflow: dict[str, Any], entries: Any
|
||||||
|
) -> list[str]:
|
||||||
|
"""Chinese problems with a user-supplied output map; empty = valid."""
|
||||||
|
if not isinstance(entries, list) or not entries:
|
||||||
|
return ["输出节点映射不能为空:请至少指定一个输出节点及其媒体类型"]
|
||||||
|
seen: set[str] = set()
|
||||||
|
problems: list[str] = []
|
||||||
|
for entry in entries:
|
||||||
|
if not isinstance(entry, dict):
|
||||||
|
problems.append("输出节点映射格式有误(应为对象数组)")
|
||||||
|
continue
|
||||||
|
nid = str(entry.get("nodeId") or "")
|
||||||
|
node = workflow.get(nid) if isinstance(workflow, dict) else None
|
||||||
|
if not nid or not isinstance(node, dict):
|
||||||
|
problems.append(f"输出节点 {nid or '?'} 不存在于该工作流中")
|
||||||
|
continue
|
||||||
|
ct = str(node.get("class_type") or "").strip()
|
||||||
|
if not ct:
|
||||||
|
problems.append(f"节点 {nid} 缺少节点类型,不能作为输出节点")
|
||||||
|
elif _wiring_class(ct) and ct not in (IMAGE_OUTPUT_CLASSES | VIDEO_OUTPUT_CLASSES):
|
||||||
|
problems.append(f"节点 {nid}({ct})是参数/连线节点,不能作为输出节点")
|
||||||
|
if entry.get("kind") not in VALID_OUTPUT_KINDS:
|
||||||
|
problems.append(f"输出节点 {nid} 的媒体类型必须是图片或视频")
|
||||||
|
if nid in seen:
|
||||||
|
problems.append(f"输出节点 {nid} 重复指定")
|
||||||
|
seen.add(nid)
|
||||||
|
return problems
|
||||||
|
|
||||||
|
|
||||||
|
def load_output_map(raw: str | None) -> list[dict[str, Any]]:
|
||||||
|
if not raw:
|
||||||
|
return []
|
||||||
|
try:
|
||||||
|
data = json.loads(raw)
|
||||||
|
except (json.JSONDecodeError, TypeError):
|
||||||
|
return []
|
||||||
|
return data if isinstance(data, list) else []
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_output_map(
|
||||||
|
output_map_raw: str | None, source: str | None, workflow: dict[str, Any]
|
||||||
|
) -> tuple[list[dict[str, Any]], str | None]:
|
||||||
|
"""The map generation harvests, plus whose decision it is.
|
||||||
|
|
||||||
|
A user map wins as long as its node ids still exist in the stored JSON
|
||||||
|
(defensive pruning — PATCH cannot edit the JSON, but keep it safe);
|
||||||
|
otherwise the trusted auto map applies. Empty list back means "not
|
||||||
|
confirmed yet".
|
||||||
|
"""
|
||||||
|
if source == "user":
|
||||||
|
entries = [
|
||||||
|
e for e in load_output_map(output_map_raw) if str(e.get("nodeId") or "") in
|
||||||
|
(workflow if isinstance(workflow, dict) else {})
|
||||||
|
]
|
||||||
|
if entries:
|
||||||
|
return entries, "user"
|
||||||
|
return [], None
|
||||||
|
auto = auto_output_map(workflow)
|
||||||
|
return (auto, "auto") if auto else ([], None)
|
||||||
|
|
||||||
|
|
||||||
|
def mapping_problem(
|
||||||
|
workflow: dict[str, Any], output_map_raw: str | None, source: str | None
|
||||||
|
) -> str | None:
|
||||||
|
"""Chinese reason this workflow's outputs are not confirmed, else None."""
|
||||||
|
if not needs_user_output_map(workflow):
|
||||||
|
return None
|
||||||
|
entries, resolved = resolve_output_map(output_map_raw, source, workflow)
|
||||||
|
if resolved == "user" and entries:
|
||||||
|
return None
|
||||||
|
return (
|
||||||
|
"该工作流含无法识别的自定义输出节点,需在「ComfyUI 连接」页指定"
|
||||||
|
"实际输出节点及其媒体类型(图片/视频)后才能启用或生成"
|
||||||
|
)
|
||||||
@@ -3,18 +3,25 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
import re
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from calliope.comfyui.patcher import FIELD_KEY_SEP, resolve_patch_field
|
from calliope.comfyui.patcher import FIELD_KEY_SEP, resolve_patch_field
|
||||||
from calliope.comfyui.registry import (
|
from calliope.comfyui.registry import (
|
||||||
AUDIO_CLASSES,
|
AUDIO_CLASSES,
|
||||||
IMAGE_CLASSES,
|
IMAGE_CLASSES,
|
||||||
|
IMAGE_OUTPUT_CLASSES,
|
||||||
|
IMAGE_URL_CLASSES,
|
||||||
|
NUMBER_CLASSES,
|
||||||
|
TEXT_AREA_CLASSES,
|
||||||
VIDEO_CLASSES,
|
VIDEO_CLASSES,
|
||||||
|
VIDEO_OUTPUT_CLASSES,
|
||||||
ComfyOutputKind,
|
ComfyOutputKind,
|
||||||
class_to_input_kind,
|
class_to_input_kind,
|
||||||
class_to_output_kind,
|
class_to_output_kind,
|
||||||
)
|
)
|
||||||
from calliope.comfyui.roles import (
|
from calliope.comfyui.roles import (
|
||||||
|
USAGE_VALUES,
|
||||||
normalize_input_role,
|
normalize_input_role,
|
||||||
normalize_output_role,
|
normalize_output_role,
|
||||||
parse_title_tag,
|
parse_title_tag,
|
||||||
@@ -76,9 +83,17 @@ def effective_input_schema(
|
|||||||
Auto-detected (and empty) schemas are re-derived from the workflow JSON
|
Auto-detected (and empty) schemas are re-derived from the workflow JSON
|
||||||
on every read, so parser upgrades reach workflows imported earlier
|
on every read, so parser upgrades reach workflows imported earlier
|
||||||
without a re-import. Tagged ``(Input:…)`` schemas are kept as stored.
|
without a re-import. Tagged ``(Input:…)`` schemas are kept as stored.
|
||||||
|
Entries the user corrected on the import confirm page carry
|
||||||
|
``manual: true`` — their role/label survive re-derivation.
|
||||||
"""
|
"""
|
||||||
if not stored or any(isinstance(e, dict) and e.get("auto") for e in stored):
|
if not stored:
|
||||||
return parse_dynamic_inputs(workflow)
|
return parse_dynamic_inputs(workflow)
|
||||||
|
manual_by_id = {
|
||||||
|
str(e.get("nodeId")): e for e in stored if isinstance(e, dict) and e.get("manual")
|
||||||
|
}
|
||||||
|
if any(isinstance(e, dict) and e.get("auto") for e in stored):
|
||||||
|
fresh = parse_dynamic_inputs(workflow)
|
||||||
|
return [manual_by_id.get(str(e.get("nodeId")), e) for e in fresh]
|
||||||
return stored
|
return stored
|
||||||
|
|
||||||
|
|
||||||
@@ -266,15 +281,22 @@ def resolution_selector_size(aspect_ratio: str, megapixels: float, multiple: int
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# ComfyUI Autogrow image inputs a studio form fills as one 1…max list
|
# ComfyUI Autogrow image inputs a studio form fills as one 1…max list.
|
||||||
# (values read from /object_info). The workflow wires ``<group>.<prefix>N``;
|
# The workflow wires ``<group>.<prefix>N``; extra images are cloned LoadImage
|
||||||
# extra images are cloned LoadImage nodes added at patch time (patcher.py).
|
# nodes added at patch time (patcher.py). This registry only beautifies known
|
||||||
|
# classes (label + real max from /object_info); detection itself is generic —
|
||||||
|
# any ``<group>.<prefix>N`` run of image-loader links folds into a group.
|
||||||
IMAGE_GROUPS: dict[str, dict[str, dict[str, Any]]] = {
|
IMAGE_GROUPS: dict[str, dict[str, dict[str, Any]]] = {
|
||||||
"MiniMaxH3ReferenceToVideo": {
|
"MiniMaxH3ReferenceToVideo": {
|
||||||
"ref_images": {"prefix": "ref_image_", "max": 9, "label": "参考图"},
|
"ref_images": {"prefix": "ref_image_", "max": 9, "label": "参考图"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ``ref_images.ref_image_0`` / ``images.image_1`` style Autogrow input names.
|
||||||
|
_GROUP_INPUT_RE = re.compile(
|
||||||
|
r"^(?P<group>[A-Za-z0-9_+-]+)\.(?P<rest>[A-Za-z0-9_+-]+?)(?P<n>\d+)$"
|
||||||
|
)
|
||||||
|
|
||||||
# Consumer input name → (role, label) of the LoadImage wired into it.
|
# Consumer input name → (role, label) of the LoadImage wired into it.
|
||||||
_FRAME_SLOT_ROLES: dict[str, tuple[str, str]] = {
|
_FRAME_SLOT_ROLES: dict[str, tuple[str, str]] = {
|
||||||
"first_frame": ("first_frame", "首帧"),
|
"first_frame": ("first_frame", "首帧"),
|
||||||
@@ -288,6 +310,28 @@ def image_group_spec(class_type: str, group: str) -> dict[str, Any] | None:
|
|||||||
return IMAGE_GROUPS.get(class_type, {}).get(group)
|
return IMAGE_GROUPS.get(class_type, {}).get(group)
|
||||||
|
|
||||||
|
|
||||||
|
def image_group_prefix(node: dict[str, Any], group: str) -> str | None:
|
||||||
|
"""The ``<prefix>`` this node numbers its ``<group>.<prefix>N`` inputs with.
|
||||||
|
|
||||||
|
Known classes read it from the registry; anything else derives it from
|
||||||
|
the node's own wired input names (generic Autogrow detection).
|
||||||
|
"""
|
||||||
|
spec = image_group_spec(str(node.get("class_type") or ""), group)
|
||||||
|
if spec:
|
||||||
|
return str(spec["prefix"])
|
||||||
|
head = f"{group}."
|
||||||
|
prefixes = set()
|
||||||
|
for name in (node.get("inputs") or {}):
|
||||||
|
if not name.startswith(head):
|
||||||
|
continue
|
||||||
|
m = _GROUP_INPUT_RE.match(name)
|
||||||
|
if m and m.group("group") == group:
|
||||||
|
prefixes.add(m.group("rest"))
|
||||||
|
if len(prefixes) == 1:
|
||||||
|
return prefixes.pop()
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def image_group_slots(
|
def image_group_slots(
|
||||||
node: dict[str, Any], group: str, prefix: str
|
node: dict[str, Any], group: str, prefix: str
|
||||||
) -> list[tuple[int, str, Any]]:
|
) -> list[tuple[int, str, Any]]:
|
||||||
@@ -300,6 +344,43 @@ def image_group_slots(
|
|||||||
return sorted(out)
|
return sorted(out)
|
||||||
|
|
||||||
|
|
||||||
|
def _detected_group_runs(
|
||||||
|
workflow: dict[str, Any], node: dict[str, Any]
|
||||||
|
) -> list[tuple[str, str, list[str]]]:
|
||||||
|
"""``[(group, prefix, source LoadImage ids)]`` for generic Autogrow inputs.
|
||||||
|
|
||||||
|
A run qualifies when the numbers are consecutive, every slot links to an
|
||||||
|
image-loader class, and the run either starts at 0 (single-slot Autogrow
|
||||||
|
exports like H3's ``ref_image_0``) or has ≥2 slots. Single runs numbered
|
||||||
|
from 1 (e.g. TextEncodeQwenImage21's ``images.image_1``) stay ordinary
|
||||||
|
image slots.
|
||||||
|
"""
|
||||||
|
runs: dict[tuple[str, str], dict[int, Any]] = {}
|
||||||
|
for name, val in (node.get("inputs") or {}).items():
|
||||||
|
m = _GROUP_INPUT_RE.match(name)
|
||||||
|
if not m or not (isinstance(val, list) and len(val) == 2):
|
||||||
|
continue
|
||||||
|
runs.setdefault((m.group("group"), m.group("rest")), {})[int(m.group("n"))] = val
|
||||||
|
out: list[tuple[str, str, list[str]]] = []
|
||||||
|
for (group, prefix), slots in sorted(runs.items()):
|
||||||
|
ns = sorted(slots)
|
||||||
|
if any(b - a != 1 for a, b in zip(ns, ns[1:])):
|
||||||
|
continue
|
||||||
|
if not (ns[0] == 0 or len(ns) >= 2):
|
||||||
|
continue
|
||||||
|
sources: list[str] = []
|
||||||
|
for n in ns:
|
||||||
|
link = slots[n]
|
||||||
|
src = workflow.get(str(link[0]))
|
||||||
|
if not (isinstance(src, dict) and src.get("class_type") in IMAGE_CLASSES):
|
||||||
|
sources = []
|
||||||
|
break
|
||||||
|
sources.append(str(link[0]))
|
||||||
|
if sources:
|
||||||
|
out.append((group, prefix, sources))
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
def _image_groups(
|
def _image_groups(
|
||||||
workflow: dict[str, Any],
|
workflow: dict[str, Any],
|
||||||
) -> tuple[list[dict[str, Any]], set[str]]:
|
) -> tuple[list[dict[str, Any]], set[str]]:
|
||||||
@@ -310,27 +391,19 @@ def _image_groups(
|
|||||||
((str(k), v) for k, v in workflow.items() if isinstance(v, dict)),
|
((str(k), v) for k, v in workflow.items() if isinstance(v, dict)),
|
||||||
key=lambda kv: _node_sort_key(kv[0]),
|
key=lambda kv: _node_sort_key(kv[0]),
|
||||||
):
|
):
|
||||||
for group, spec in IMAGE_GROUPS.get(str(node.get("class_type") or ""), {}).items():
|
for group, _prefix, sources in _detected_group_runs(workflow, node):
|
||||||
sources: list[str] = []
|
spec = image_group_spec(str(node.get("class_type") or ""), group) or {}
|
||||||
for _n, _name, link in image_group_slots(node, group, spec["prefix"]):
|
|
||||||
if not (isinstance(link, list) and len(link) == 2):
|
|
||||||
continue
|
|
||||||
src = workflow.get(str(link[0]))
|
|
||||||
if isinstance(src, dict) and src.get("class_type") in IMAGE_CLASSES:
|
|
||||||
sources.append(str(link[0]))
|
|
||||||
if not sources:
|
|
||||||
continue
|
|
||||||
absorbed.update(sources)
|
absorbed.update(sources)
|
||||||
entries.append(
|
entries.append(
|
||||||
_entry(
|
_entry(
|
||||||
f"{nid}{FIELD_KEY_SEP}{group}",
|
f"{nid}{FIELD_KEY_SEP}{group}",
|
||||||
spec["label"],
|
str(spec.get("label") or "参考图"),
|
||||||
"reference_image",
|
"reference_image",
|
||||||
"image_list",
|
"image_list",
|
||||||
None,
|
None,
|
||||||
True,
|
True,
|
||||||
min=1,
|
min=1,
|
||||||
max=spec["max"],
|
max=spec.get("max", 9),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return entries, absorbed
|
return entries, absorbed
|
||||||
@@ -624,4 +697,341 @@ def parse_dynamic_outputs(workflow: dict[str, Any]) -> list[dict[str, Any]]:
|
|||||||
"kind": out_kind,
|
"kind": out_kind,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
if not results:
|
||||||
|
results = detect_output_nodes(workflow)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Output (sink) detection + five-usage classification (HEL-636)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Nodes whose output another node consumes are wiring, not results. A node
|
||||||
|
# nothing consumes is a sink; media sinks are the workflow's outputs.
|
||||||
|
_INPUT_ONLY_CLASSES = IMAGE_CLASSES | IMAGE_URL_CLASSES | AUDIO_CLASSES | VIDEO_CLASSES
|
||||||
|
# Latent/source shapers (EmptyLatentImage…) are wiring even when nothing
|
||||||
|
# consumes them — they never carry results out of the graph.
|
||||||
|
_SOURCE_ONLY_CLASSES = _INPUT_ONLY_CLASSES | TEXT_AREA_CLASSES | NUMBER_CLASSES
|
||||||
|
|
||||||
|
# Classes that are known-internal tails: standard decode steps and cache
|
||||||
|
# cleaners consume media but never emit history outputs, so they can never
|
||||||
|
# be output candidates (HEL-638: a graph ending in these has no output).
|
||||||
|
_NON_OUTPUT_CLASSES = frozenset(
|
||||||
|
{"VAEDecode", "VAEDecodeTiled", "VAEDecodeAudio", "easy cleanGpuUsed"}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Widget names save-style custom nodes carry, and link input names that mark
|
||||||
|
# "consumes rendered media" — used to flag unknown sinks that need mapping.
|
||||||
|
_SAVE_WIDGET_NAMES = frozenset(
|
||||||
|
{"filename_prefix", "filename", "prefix", "path", "output_path", "save_output"}
|
||||||
|
)
|
||||||
|
_MEDIA_LINK_NAMES = frozenset(
|
||||||
|
{"images", "image", "video", "frames", "latent", "latents", "audio", "audios"}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _sinks(
|
||||||
|
workflow: dict[str, Any], consumers: dict[str, list[tuple[str, str]]]
|
||||||
|
) -> list[tuple[str, dict[str, Any]]]:
|
||||||
|
out: list[tuple[str, dict[str, Any]]] = []
|
||||||
|
for nid, node in sorted(
|
||||||
|
((str(k), v) for k, v in workflow.items() if isinstance(v, dict)),
|
||||||
|
key=lambda kv: _node_sort_key(kv[0]),
|
||||||
|
):
|
||||||
|
if not consumers.get(nid):
|
||||||
|
out.append((nid, node))
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def _unknown_sink_looks_like_save(node: dict[str, Any], workflow: dict[str, Any]) -> bool:
|
||||||
|
inputs = node.get("inputs") or {}
|
||||||
|
for name, val in inputs.items():
|
||||||
|
if name in _SAVE_WIDGET_NAMES and isinstance(val, (str, int, float, bool)):
|
||||||
|
return True
|
||||||
|
if name in _MEDIA_LINK_NAMES and isinstance(val, list) and len(val) == 2:
|
||||||
|
src = workflow.get(str(val[0]))
|
||||||
|
if isinstance(src, dict) and "decode" in str(src.get("class_type") or "").lower():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _node_has_save_widget(node: dict[str, Any]) -> bool:
|
||||||
|
"""A concrete save widget (filename/prefix/path) — the only signal that
|
||||||
|
counts for unknown nodes that something else consumes; media links from
|
||||||
|
decode steps are meaningless there (every transform has them)."""
|
||||||
|
inputs = node.get("inputs") or {}
|
||||||
|
return any(
|
||||||
|
name in _SAVE_WIDGET_NAMES and isinstance(val, (str, int, float, bool))
|
||||||
|
for name, val in inputs.items()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _video_semantics(workflow: dict[str, Any]) -> bool:
|
||||||
|
"""Auxiliary evidence the graph renders video (frame counts, video nodes)."""
|
||||||
|
for node in workflow.values():
|
||||||
|
if not isinstance(node, dict):
|
||||||
|
continue
|
||||||
|
ct = str(node.get("class_type") or "").lower()
|
||||||
|
if "video" in ct or "animatediff" in ct:
|
||||||
|
return True
|
||||||
|
for name in (node.get("inputs") or {}):
|
||||||
|
if name in _FRAME_INPUTS:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _suggest_output_kind(class_type: str, videoish: bool) -> str | None:
|
||||||
|
"""Best-guess media type for an unknown candidate — UI default only."""
|
||||||
|
lower = class_type.lower()
|
||||||
|
if "video" in lower or "animatediff" in lower:
|
||||||
|
return "video"
|
||||||
|
if "image" in lower or "save" in lower:
|
||||||
|
return "image"
|
||||||
|
return "video" if videoish else None
|
||||||
|
|
||||||
|
|
||||||
|
def _unknown_output_entry(
|
||||||
|
nid: str, node: dict[str, Any], workflow: dict[str, Any], videoish: bool
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
ct = str(node.get("class_type") or "")
|
||||||
|
return {
|
||||||
|
"nodeId": nid,
|
||||||
|
"label": _title_of(node) or ct,
|
||||||
|
"role": None,
|
||||||
|
# HEL-638: unknown custom nodes are never auto-typed — the user
|
||||||
|
# picks the media type; `suggested_kind` is only a form default.
|
||||||
|
"kind": None,
|
||||||
|
"class_type": ct,
|
||||||
|
"evidence": "unknown_node",
|
||||||
|
"suggested_kind": _suggest_output_kind(ct, videoish),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def detect_output_nodes(workflow: dict[str, Any]) -> list[dict[str, Any]]:
|
||||||
|
"""Infer output nodes of an untagged workflow from its sinks.
|
||||||
|
|
||||||
|
Exact registry classes (SaveImage, VHS_VideoCombine…) count whether or
|
||||||
|
not something downstream consumes them (a SaveVideo feeding a
|
||||||
|
cache-cleanup tail is still the output). Every OTHER class at an output
|
||||||
|
position is an *unknown candidate*: kind stays null, the import page
|
||||||
|
asks the user to designate the real output node(s) and their media
|
||||||
|
type, and the workflow stays pending until then (HEL-638). Sinks with
|
||||||
|
no save features only become candidates when the graph has no trusted
|
||||||
|
output at all — next to a real saver they are utility tails.
|
||||||
|
"""
|
||||||
|
if not isinstance(workflow, dict):
|
||||||
|
return []
|
||||||
|
consumers = _consumers(workflow)
|
||||||
|
videoish = _video_semantics(workflow)
|
||||||
|
registry_outputs: list[dict[str, Any]] = []
|
||||||
|
candidates: list[dict[str, Any]] = []
|
||||||
|
seen: set[str] = set()
|
||||||
|
|
||||||
|
def _is_wiring(ct: str) -> bool:
|
||||||
|
return (
|
||||||
|
not ct
|
||||||
|
or ct in _SOURCE_ONLY_CLASSES
|
||||||
|
or ct in _NON_OUTPUT_CLASSES
|
||||||
|
or ct.startswith("Empty")
|
||||||
|
)
|
||||||
|
|
||||||
|
# 1) Trusted registry outputs at sink positions.
|
||||||
|
for nid, node in _sinks(workflow, consumers):
|
||||||
|
ct = str(node.get("class_type") or "")
|
||||||
|
if ct in IMAGE_OUTPUT_CLASSES or ct in VIDEO_OUTPUT_CLASSES:
|
||||||
|
registry_outputs.append(
|
||||||
|
{
|
||||||
|
"nodeId": nid,
|
||||||
|
"label": _title_of(node) or ct,
|
||||||
|
"role": None,
|
||||||
|
"kind": "video" if ct in VIDEO_OUTPUT_CLASSES else "image",
|
||||||
|
"class_type": ct,
|
||||||
|
"evidence": "registry",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
seen.add(nid)
|
||||||
|
|
||||||
|
# 2) Registry output classes consumed by other nodes are outputs too.
|
||||||
|
for nid, node in sorted(
|
||||||
|
((str(k), v) for k, v in workflow.items() if isinstance(v, dict)),
|
||||||
|
key=lambda kv: _node_sort_key(kv[0]),
|
||||||
|
):
|
||||||
|
ct = str(node.get("class_type") or "")
|
||||||
|
if nid in seen or ct not in (IMAGE_OUTPUT_CLASSES | VIDEO_OUTPUT_CLASSES):
|
||||||
|
continue
|
||||||
|
registry_outputs.append(
|
||||||
|
{
|
||||||
|
"nodeId": nid,
|
||||||
|
"label": _title_of(node) or ct,
|
||||||
|
"role": None,
|
||||||
|
"kind": "video" if ct in VIDEO_OUTPUT_CLASSES else "image",
|
||||||
|
"class_type": ct,
|
||||||
|
"evidence": "registry",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
seen.add(nid)
|
||||||
|
|
||||||
|
# 3) Unknown sink candidates. Save-looking sinks always need mapping;
|
||||||
|
# feature-less sinks only when nothing trusted exists (utility tails
|
||||||
|
# next to a real saver stay invisible).
|
||||||
|
has_trusted = bool(registry_outputs)
|
||||||
|
for nid, node in _sinks(workflow, consumers):
|
||||||
|
ct = str(node.get("class_type") or "")
|
||||||
|
if nid in seen or _is_wiring(ct) or ct in (IMAGE_OUTPUT_CLASSES | VIDEO_OUTPUT_CLASSES):
|
||||||
|
continue
|
||||||
|
if _unknown_sink_looks_like_save(node, workflow) or not has_trusted:
|
||||||
|
candidates.append(_unknown_output_entry(nid, node, workflow, videoish))
|
||||||
|
seen.add(nid)
|
||||||
|
|
||||||
|
# 4) Unknown save-looking nodes that something consumes (a custom saver
|
||||||
|
# feeding a cleanup tail is still an output candidate). Only concrete
|
||||||
|
# save widgets count here — decode-fed media links are ubiquitous among
|
||||||
|
# mid-graph transforms (CreateVideo & co.) and never mark an output.
|
||||||
|
for nid, node in sorted(
|
||||||
|
((str(k), v) for k, v in workflow.items() if isinstance(v, dict)),
|
||||||
|
key=lambda kv: _node_sort_key(kv[0]),
|
||||||
|
):
|
||||||
|
ct = str(node.get("class_type") or "")
|
||||||
|
if nid in seen or _is_wiring(ct) or ct in (IMAGE_OUTPUT_CLASSES | VIDEO_OUTPUT_CLASSES):
|
||||||
|
continue
|
||||||
|
if _node_has_save_widget(node):
|
||||||
|
candidates.append(_unknown_output_entry(nid, node, workflow, videoish))
|
||||||
|
seen.add(nid)
|
||||||
|
|
||||||
|
results = registry_outputs + candidates
|
||||||
|
results.sort(key=lambda r: _node_sort_key(r["nodeId"]))
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
# Title heuristics the studio form applies to tagged (Input:…) slots; the
|
||||||
|
# classifier must judge a workflow the same way the form renders it.
|
||||||
|
_TAGGED_FIRST_RE = re.compile(r"first|start|首帧", re.IGNORECASE)
|
||||||
|
_TAGGED_LAST_RE = re.compile(r"last|end|尾帧", re.IGNORECASE)
|
||||||
|
_TAGGED_MASK_RE = re.compile(r"mask|遮罩", re.IGNORECASE)
|
||||||
|
|
||||||
|
|
||||||
|
def _slot_effective_role(entry: dict[str, Any]) -> str | None:
|
||||||
|
"""The role the generate form will act on for this schema entry."""
|
||||||
|
kind = str(entry.get("kind") or "")
|
||||||
|
if kind == "image_list":
|
||||||
|
return "reference_image"
|
||||||
|
role = normalize_input_role(entry.get("role"))
|
||||||
|
if entry.get("auto") or kind not in ("image", "image_url"):
|
||||||
|
return role
|
||||||
|
label = str(entry.get("label") or "")
|
||||||
|
if _TAGGED_MASK_RE.search(label):
|
||||||
|
return "mask"
|
||||||
|
if _TAGGED_FIRST_RE.search(label):
|
||||||
|
return "first_frame"
|
||||||
|
if _TAGGED_LAST_RE.search(label):
|
||||||
|
return "last_frame"
|
||||||
|
return role
|
||||||
|
|
||||||
|
|
||||||
|
def classify_usage(workflow: dict[str, Any]) -> dict[str, Any]:
|
||||||
|
"""Judge a workflow's usage from graph evidence (HEL-636 §2).
|
||||||
|
|
||||||
|
Returns ``usage`` plus everything the import confirm page shows:
|
||||||
|
``ambiguous`` (needs a human decision), ``needs_mapping`` (unknown
|
||||||
|
output nodes), ``problem`` (Chinese reason when usage is None) and
|
||||||
|
``evidence`` (output nodes, image/video slots, summary lines). Never
|
||||||
|
looks at file names, model names or fixed node ids.
|
||||||
|
"""
|
||||||
|
inputs = parse_dynamic_inputs(workflow) if isinstance(workflow, dict) else []
|
||||||
|
outputs = parse_dynamic_outputs(workflow)
|
||||||
|
media_outputs = [o for o in outputs if o.get("kind") in ("image", "video")]
|
||||||
|
unknown_outputs = [o for o in outputs if o.get("evidence") == "unknown_node"]
|
||||||
|
out_kinds = sorted({o["kind"] for o in media_outputs})
|
||||||
|
|
||||||
|
image_slots: list[dict[str, Any]] = []
|
||||||
|
video_slots: list[dict[str, Any]] = []
|
||||||
|
for entry in inputs:
|
||||||
|
kind = str(entry.get("kind") or "")
|
||||||
|
if kind in ("image", "image_list", "image_url"):
|
||||||
|
image_slots.append(
|
||||||
|
{
|
||||||
|
"nodeId": entry.get("nodeId"),
|
||||||
|
"label": entry.get("label"),
|
||||||
|
"kind": kind,
|
||||||
|
"role": _slot_effective_role(entry),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
elif kind == "video":
|
||||||
|
video_slots.append(
|
||||||
|
{
|
||||||
|
"nodeId": entry.get("nodeId"),
|
||||||
|
"label": entry.get("label"),
|
||||||
|
"kind": kind,
|
||||||
|
"role": normalize_input_role(entry.get("role")),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
effective = [s["role"] or "image" for s in image_slots if s["role"] != "mask"]
|
||||||
|
bulk = [r for r in effective if r in (None, "image")]
|
||||||
|
has_frame = any(r in ("first_frame", "last_frame") for r in effective)
|
||||||
|
has_ref_group = any(s["kind"] == "image_list" for s in image_slots)
|
||||||
|
|
||||||
|
summary: list[str] = []
|
||||||
|
for o in media_outputs:
|
||||||
|
zh = "图片" if o["kind"] == "image" else "视频"
|
||||||
|
summary.append(f"输出:节点 {o['nodeId']}({o.get('class_type') or o['label']})→ {zh}")
|
||||||
|
if unknown_outputs:
|
||||||
|
names = "、".join(
|
||||||
|
f"节点 {o['nodeId']}({o.get('class_type') or '?'})" for o in unknown_outputs[:4]
|
||||||
|
)
|
||||||
|
summary.append(f"存在无法识别的输出节点:{names},需人工指定输出节点及媒体类型")
|
||||||
|
for s in image_slots:
|
||||||
|
if s["role"] != "mask":
|
||||||
|
summary.append(f"图片输入:节点 {s['nodeId']}({s['label']})")
|
||||||
|
if video_slots:
|
||||||
|
summary.append("含视频输入槽(本版本不支持参考视频上传)")
|
||||||
|
|
||||||
|
usage: str | None = None
|
||||||
|
ambiguous = False
|
||||||
|
problem: str | None = None
|
||||||
|
if not out_kinds and not unknown_outputs:
|
||||||
|
problem = (
|
||||||
|
"未在图中找到输出节点(SaveImage / 视频合成等),"
|
||||||
|
"请确认导出的是 API 格式且包含保存节点"
|
||||||
|
)
|
||||||
|
elif unknown_outputs:
|
||||||
|
# HEL-638: any unknown custom output node keeps the workflow
|
||||||
|
# pending — no name-based guessing, and picking a usage alone must
|
||||||
|
# not bypass the output-node designation.
|
||||||
|
names = "、".join(
|
||||||
|
f"节点 {o['nodeId']}({o.get('class_type') or '?'})" for o in unknown_outputs[:4]
|
||||||
|
)
|
||||||
|
ambiguous = True
|
||||||
|
problem = (
|
||||||
|
f"存在无法识别的输出节点({names}),"
|
||||||
|
"需人工指定实际输出节点及其媒体类型(图片/视频)后才能保存启用"
|
||||||
|
)
|
||||||
|
elif len(out_kinds) > 1:
|
||||||
|
ambiguous = True
|
||||||
|
problem = "同一工作流同时输出图片和视频,需人工选择主用途"
|
||||||
|
elif len(out_kinds) == 1:
|
||||||
|
if out_kinds[0] == "image":
|
||||||
|
usage = "image2image" if bulk else "text2image"
|
||||||
|
elif has_ref_group or len(bulk) >= 2:
|
||||||
|
usage = "ref2video"
|
||||||
|
elif has_frame and not bulk:
|
||||||
|
usage = "image2video"
|
||||||
|
elif not effective:
|
||||||
|
usage = "text2video"
|
||||||
|
else:
|
||||||
|
ambiguous = True
|
||||||
|
problem = "视频工作流中的单张图片输入无法判定是首帧还是参考图,需人工确认"
|
||||||
|
|
||||||
|
return {
|
||||||
|
"usage": usage,
|
||||||
|
"ambiguous": ambiguous,
|
||||||
|
"needs_mapping": bool(unknown_outputs),
|
||||||
|
"problem": problem,
|
||||||
|
"evidence": {
|
||||||
|
"outputs": outputs,
|
||||||
|
"image_slots": image_slots,
|
||||||
|
"video_slots": video_slots,
|
||||||
|
"summary": summary,
|
||||||
|
},
|
||||||
|
"usable_usage": list(USAGE_VALUES),
|
||||||
|
}
|
||||||
|
|||||||
@@ -53,15 +53,15 @@ def apply_image_group(
|
|||||||
first, and slots/loaders left over from the export are removed so no
|
first, and slots/loaders left over from the export are removed so no
|
||||||
stale image reaches ComfyUI.
|
stale image reaches ComfyUI.
|
||||||
"""
|
"""
|
||||||
from calliope.comfyui.parser import image_group_slots, image_group_spec
|
from calliope.comfyui.parser import image_group_prefix, image_group_slots
|
||||||
|
|
||||||
node = workflow.get(node_id)
|
node = workflow.get(node_id)
|
||||||
if not isinstance(node, dict):
|
if not isinstance(node, dict):
|
||||||
return
|
return
|
||||||
spec = image_group_spec(str(node.get("class_type") or ""), group)
|
prefix = image_group_prefix(node, group)
|
||||||
if spec is None:
|
if prefix is None:
|
||||||
return
|
return
|
||||||
prefix = spec["prefix"]
|
label = "参考图"
|
||||||
inputs = dict(node.get("inputs") or {})
|
inputs = dict(node.get("inputs") or {})
|
||||||
slots = image_group_slots(node, group, prefix)
|
slots = image_group_slots(node, group, prefix)
|
||||||
loaders: list[str] = []
|
loaders: list[str] = []
|
||||||
@@ -96,7 +96,7 @@ def apply_image_group(
|
|||||||
loader_inputs = dict(loader.get("inputs") or {})
|
loader_inputs = dict(loader.get("inputs") or {})
|
||||||
loader_inputs["image"] = path
|
loader_inputs["image"] = path
|
||||||
loader["inputs"] = loader_inputs
|
loader["inputs"] = loader_inputs
|
||||||
loader["_meta"] = {**(loader.get("_meta") or {}), "title": f"{spec['label']} {i + 1}"}
|
loader["_meta"] = {**(loader.get("_meta") or {}), "title": f"{label} {i + 1}"}
|
||||||
workflow[nid] = loader
|
workflow[nid] = loader
|
||||||
inputs[f"{group}.{prefix}{i}"] = [nid, 0]
|
inputs[f"{group}.{prefix}{i}"] = [nid, 0]
|
||||||
node["inputs"] = inputs
|
node["inputs"] = inputs
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ VIDEO_OUTPUT_CLASSES = frozenset(
|
|||||||
{"VHS_VideoCombine", "SaveVideo", "VideoOutput", "AnimateDiffCombine"}
|
{"VHS_VideoCombine", "SaveVideo", "VideoOutput", "AnimateDiffCombine"}
|
||||||
)
|
)
|
||||||
IMAGE_OUTPUT_CLASSES = frozenset(
|
IMAGE_OUTPUT_CLASSES = frozenset(
|
||||||
{"SaveImage", "PreviewImage", "SaveImageWebsocket", "ETN_SendImageWebSocket"}
|
{"SaveImage", "PreviewImage", "SaveImageWebsocket", "ETN_SendImageWebSocket",
|
||||||
|
"SaveImageAdvanced"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,27 @@ OUTPUT_ROLE_ALIASES: dict[str, frozenset[str]] = {
|
|||||||
"video": frozenset({"video", "vid"}),
|
"video": frozenset({"video", "vid"}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The five workflow usages the studio distinguishes (HEL-636). Derived from
|
||||||
|
# graph evidence only (output media + consumed image inputs) — never from
|
||||||
|
# file names, model names or fixed node ids.
|
||||||
|
WorkflowUsage = str
|
||||||
|
USAGE_VALUES: tuple[str, ...] = (
|
||||||
|
"text2image",
|
||||||
|
"image2image",
|
||||||
|
"text2video",
|
||||||
|
"image2video",
|
||||||
|
"ref2video",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def usage_to_kind(usage: str | None) -> str | None:
|
||||||
|
"""Output media kind of a usage (image / video); None when unknown."""
|
||||||
|
if usage in ("text2image", "image2image"):
|
||||||
|
return "image"
|
||||||
|
if usage in ("text2video", "image2video", "ref2video"):
|
||||||
|
return "video"
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def parse_title_tag(title: str) -> tuple[str | None, str | None, str]:
|
def parse_title_tag(title: str) -> tuple[str | None, str | None, str]:
|
||||||
"""Return (kind, role, label) from a Comfy node title.
|
"""Return (kind, role, label) from a Comfy node title.
|
||||||
|
|||||||
@@ -121,7 +121,11 @@ CREATE TABLE IF NOT EXISTS workflows (
|
|||||||
description TEXT,
|
description TEXT,
|
||||||
prompt_profile TEXT NOT NULL DEFAULT 'prose',
|
prompt_profile TEXT NOT NULL DEFAULT 'prose',
|
||||||
is_enabled INTEGER NOT NULL DEFAULT 1,
|
is_enabled INTEGER NOT NULL DEFAULT 1,
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
usage TEXT,
|
||||||
|
usage_source TEXT,
|
||||||
|
output_map TEXT,
|
||||||
|
output_map_source TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS jobs (
|
CREATE TABLE IF NOT EXISTS jobs (
|
||||||
@@ -338,6 +342,74 @@ def _sqlite_connect(path: Path) -> sqlite3.Connection:
|
|||||||
return sqlite3.connect(path)
|
return sqlite3.connect(path)
|
||||||
|
|
||||||
|
|
||||||
|
def _backfill_workflow_usage(conn: sqlite3.Connection) -> None:
|
||||||
|
"""HEL-636: settle `workflows.usage` for rows that still have none.
|
||||||
|
|
||||||
|
Determinate graphs get ``usage='auto'``; indeterminate ones keep NULL
|
||||||
|
and are disabled (they must be confirmed on the connections page before
|
||||||
|
they can generate). Rows the user already confirmed (usage_source='user')
|
||||||
|
never pass through here again — their usage is set, so the WHERE clause
|
||||||
|
skips them. Old jobs / history / `kind` semantics are untouched.
|
||||||
|
"""
|
||||||
|
from calliope.comfyui.parser import classify_usage
|
||||||
|
|
||||||
|
rows = conn.execute(
|
||||||
|
"SELECT id, workflow_json FROM workflows WHERE usage IS NULL OR usage = ''"
|
||||||
|
).fetchall()
|
||||||
|
for row in rows: # plain connect — positional access
|
||||||
|
try:
|
||||||
|
workflow = json.loads(row[1])
|
||||||
|
except (json.JSONDecodeError, TypeError):
|
||||||
|
workflow = None
|
||||||
|
judgment = classify_usage(workflow) if isinstance(workflow, dict) else {}
|
||||||
|
if judgment.get("usage"):
|
||||||
|
conn.execute(
|
||||||
|
"UPDATE workflows SET usage = ?, usage_source = 'auto' WHERE id = ?",
|
||||||
|
(judgment["usage"], row[0]),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
conn.execute(
|
||||||
|
"UPDATE workflows SET is_enabled = 0 WHERE id = ? AND usage IS NULL",
|
||||||
|
(row[0],),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _backfill_workflow_output_map(conn: sqlite3.Connection) -> None:
|
||||||
|
"""HEL-638: settle the output-node mapping for existing rows.
|
||||||
|
|
||||||
|
Rows the user already mapped (output_map_source='user') are never
|
||||||
|
touched. Determinate graphs get the trusted ``auto`` map. Rows whose
|
||||||
|
graph now contains unknown custom output candidates get no auto map and
|
||||||
|
are parked disabled — the usage decision survives, but until the user
|
||||||
|
designates the output nodes the workflow must not generate.
|
||||||
|
"""
|
||||||
|
from calliope.comfyui.output_map import auto_output_map, needs_user_output_map
|
||||||
|
|
||||||
|
rows = conn.execute(
|
||||||
|
"SELECT id, workflow_json FROM workflows"
|
||||||
|
" WHERE output_map_source IS NULL OR output_map_source != 'user'"
|
||||||
|
).fetchall()
|
||||||
|
for row in rows:
|
||||||
|
try:
|
||||||
|
workflow = json.loads(row[1])
|
||||||
|
except (json.JSONDecodeError, TypeError):
|
||||||
|
workflow = None
|
||||||
|
if not isinstance(workflow, dict):
|
||||||
|
continue
|
||||||
|
if needs_user_output_map(workflow):
|
||||||
|
conn.execute(
|
||||||
|
"UPDATE workflows SET output_map = NULL, output_map_source = NULL,"
|
||||||
|
" is_enabled = 0 WHERE id = ?",
|
||||||
|
(row[0],),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
conn.execute(
|
||||||
|
"UPDATE workflows SET output_map = ?, output_map_source = 'auto'"
|
||||||
|
" WHERE id = ?",
|
||||||
|
(json.dumps(auto_output_map(workflow)), row[0]),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def migrate_db(db_path: Path) -> None:
|
async def migrate_db(db_path: Path) -> None:
|
||||||
db_path.parent.mkdir(parents=True, exist_ok=True)
|
db_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
conn = sqlite3.connect(db_path)
|
conn = sqlite3.connect(db_path)
|
||||||
@@ -383,6 +455,23 @@ async def migrate_db(db_path: Path) -> None:
|
|||||||
# comfyui_endpoints id). Dangling ids are tolerated — enqueue falls
|
# comfyui_endpoints id). Dangling ids are tolerated — enqueue falls
|
||||||
# back to the active connection.
|
# back to the active connection.
|
||||||
conn.execute("ALTER TABLE workflows ADD COLUMN endpoint_id TEXT")
|
conn.execute("ALTER TABLE workflows ADD COLUMN endpoint_id TEXT")
|
||||||
|
# HEL-636: five-way usage (text2image…ref2video). NULL = pending human
|
||||||
|
# confirmation; `kind` keeps meaning output media for history/paths.
|
||||||
|
if "usage" not in cols:
|
||||||
|
conn.execute("ALTER TABLE workflows ADD COLUMN usage TEXT")
|
||||||
|
if "usage_source" not in cols:
|
||||||
|
conn.execute("ALTER TABLE workflows ADD COLUMN usage_source TEXT")
|
||||||
|
# HEL-638: explicit output-node designation for unknown custom output
|
||||||
|
# nodes ({nodeId, kind} JSON + 'user'|'auto'). Idempotent backfill
|
||||||
|
# below parks unmapped unknown-output rows (disabled) like usage does.
|
||||||
|
if "output_map" not in cols:
|
||||||
|
conn.execute("ALTER TABLE workflows ADD COLUMN output_map TEXT")
|
||||||
|
if "output_map_source" not in cols:
|
||||||
|
conn.execute("ALTER TABLE workflows ADD COLUMN output_map_source TEXT")
|
||||||
|
# Idempotent backfill: pending rows are re-judged on every boot (parser
|
||||||
|
# upgrades can settle them); confirmed rows are never touched.
|
||||||
|
_backfill_workflow_usage(conn)
|
||||||
|
_backfill_workflow_output_map(conn)
|
||||||
scene_cols = {r[1] for r in conn.execute("PRAGMA table_info(scenes)").fetchall()}
|
scene_cols = {r[1] for r in conn.execute("PRAGMA table_info(scenes)").fetchall()}
|
||||||
if "location_id" not in scene_cols:
|
if "location_id" not in scene_cols:
|
||||||
conn.execute("ALTER TABLE scenes ADD COLUMN location_id INTEGER")
|
conn.execute("ALTER TABLE scenes ADD COLUMN location_id INTEGER")
|
||||||
|
|||||||
@@ -198,14 +198,35 @@ class ExpandClipsRequest(BaseModel):
|
|||||||
clip_cap: int | None = None
|
clip_cap: int | None = None
|
||||||
|
|
||||||
|
|
||||||
|
WorkflowUsageKind = Literal[
|
||||||
|
"text2image",
|
||||||
|
"image2image",
|
||||||
|
"text2video",
|
||||||
|
"image2video",
|
||||||
|
"ref2video",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class WorkflowCreate(BaseModel):
|
class WorkflowCreate(BaseModel):
|
||||||
name: str = Field(..., min_length=1)
|
name: str = Field(..., min_length=1)
|
||||||
kind: Literal["image", "video"] = "image"
|
kind: Literal["image", "video"] | None = None
|
||||||
workflow_json: dict[str, Any]
|
workflow_json: dict[str, Any]
|
||||||
description: str | None = None
|
description: str | None = None
|
||||||
prompt_profile: Literal["prose", "minimax_h3_ref"] | None = None
|
prompt_profile: Literal["prose", "minimax_h3_ref"] | None = None
|
||||||
# Optional binding to a ComfyUI connection id (settings.comfyui_endpoints).
|
# Optional binding to a ComfyUI connection id (settings.comfyui_endpoints).
|
||||||
endpoint_id: str | None = None
|
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):
|
class WorkflowUpdate(BaseModel):
|
||||||
@@ -215,6 +236,13 @@ class WorkflowUpdate(BaseModel):
|
|||||||
prompt_profile: Literal["prose", "minimax_h3_ref"] | None = None
|
prompt_profile: Literal["prose", "minimax_h3_ref"] | None = None
|
||||||
is_enabled: bool | None = None
|
is_enabled: bool | None = None
|
||||||
endpoint_id: str | 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):
|
class WorkflowAnalyze(BaseModel):
|
||||||
|
|||||||
@@ -196,15 +196,25 @@ class QueueWorker:
|
|||||||
)
|
)
|
||||||
|
|
||||||
workflow_id = job.get("workflow_id") or payload.get("workflow_id")
|
workflow_id = job.get("workflow_id") or payload.get("workflow_id")
|
||||||
workflow = self._load_workflow(workflow_id)
|
workflow_row = self._load_workflow_row(workflow_id)
|
||||||
if not workflow:
|
if not workflow_row:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"找不到该任务使用的工作流(可能已被删除),请重新选择工作流后再生成"
|
"找不到该任务使用的工作流(可能已被删除),请重新选择工作流后再生成"
|
||||||
)
|
)
|
||||||
|
workflow = workflow_row["workflow_json"]
|
||||||
broken = blocking_problem(workflow)
|
broken = blocking_problem(workflow)
|
||||||
if broken:
|
if broken:
|
||||||
raise RuntimeError(broken)
|
raise RuntimeError(broken)
|
||||||
|
|
||||||
|
# HEL-638: harvest only the confirmed output nodes. A workflow
|
||||||
|
# with unknown custom outputs and no user mapping must not run.
|
||||||
|
node_kinds = self._output_node_kinds(workflow_row)
|
||||||
|
if node_kinds is None:
|
||||||
|
raise RuntimeError(
|
||||||
|
"该工作流含无法识别的自定义输出节点,尚未指定输出节点及媒体类型,"
|
||||||
|
"请到「ComfyUI 连接」页确认后再生成"
|
||||||
|
)
|
||||||
|
|
||||||
input_values = payload.get("input_values") or {}
|
input_values = payload.get("input_values") or {}
|
||||||
if payload.get("continue_source") and kind == "video":
|
if payload.get("continue_source") and kind == "video":
|
||||||
input_values = await self._resolve_continue_source(
|
input_values = await self._resolve_continue_source(
|
||||||
@@ -240,13 +250,31 @@ class QueueWorker:
|
|||||||
f"ComfyUI 执行出错(任务 ID {prompt_id}):{_comfy_messages(messages)}"
|
f"ComfyUI 执行出错(任务 ID {prompt_id}):{_comfy_messages(messages)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
outputs_meta = client.extract_outputs(history)
|
outputs_meta = client.extract_outputs(history, node_kinds=node_kinds)
|
||||||
saved = [m for m in outputs_meta if m.get("type") == "output"]
|
saved = [m for m in outputs_meta if m.get("type") == "output"]
|
||||||
outputs_meta = saved or outputs_meta
|
outputs_meta = saved or outputs_meta
|
||||||
if not outputs_meta:
|
if not outputs_meta:
|
||||||
|
checked = "、".join(sorted(node_kinds))
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
f"ComfyUI 显示任务已结束(任务 ID {prompt_id}),但没有返回任何图片或视频,"
|
f"ComfyUI 显示任务已结束(任务 ID {prompt_id}),但没有返回任何图片或视频,"
|
||||||
"不算生成完成。请确认工作流带有保存/预览节点,并到 ComfyUI 历史中核对该任务。"
|
"不算生成完成。已按输出映射检查节点:" f"{checked};"
|
||||||
|
"请到 ComfyUI 历史中核对该任务,并确认所指定的输出节点正确。"
|
||||||
|
)
|
||||||
|
mismatch = next(
|
||||||
|
(
|
||||||
|
m
|
||||||
|
for m in outputs_meta
|
||||||
|
if m.get("media_kind") and m["media_kind"] != node_kinds.get(m["node_id"])
|
||||||
|
),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
if mismatch:
|
||||||
|
want = node_kinds.get(mismatch["node_id"])
|
||||||
|
raise RuntimeError(
|
||||||
|
f"输出节点 {mismatch['node_id']} 的媒体类型与映射不符"
|
||||||
|
f"(映射为{'视频' if want == 'video' else '图片'},"
|
||||||
|
f"实际返回 {mismatch['filename']}),任务不算生成完成。"
|
||||||
|
"请到「ComfyUI 连接」页修正该节点的媒体类型。"
|
||||||
)
|
)
|
||||||
queue_manager.set_phase(job["id"], "saving")
|
queue_manager.set_phase(job["id"], "saving")
|
||||||
dest_dir = config.settings.assets_dir / str(project_id) / kind
|
dest_dir = config.settings.assets_dir / str(project_id) / kind
|
||||||
@@ -476,20 +504,45 @@ class QueueWorker:
|
|||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
def _load_workflow(self, workflow_id: int | None) -> dict[str, Any] | None:
|
def _load_workflow_row(self, workflow_id: int | None) -> dict[str, Any] | None:
|
||||||
if not workflow_id:
|
if not workflow_id:
|
||||||
return None
|
return None
|
||||||
conn = get_db(config.settings.db_path)
|
conn = get_db(config.settings.db_path)
|
||||||
try:
|
try:
|
||||||
row = conn.execute(
|
row = conn.execute(
|
||||||
"SELECT workflow_json FROM workflows WHERE id = ?", (workflow_id,)
|
"SELECT workflow_json, output_map, output_map_source FROM workflows"
|
||||||
|
" WHERE id = ?",
|
||||||
|
(workflow_id,),
|
||||||
).fetchone()
|
).fetchone()
|
||||||
if not row:
|
if not row:
|
||||||
return None
|
return None
|
||||||
return json.loads(row["workflow_json"])
|
return {
|
||||||
|
"workflow_json": json.loads(row["workflow_json"]),
|
||||||
|
"output_map": row["output_map"],
|
||||||
|
"output_map_source": row["output_map_source"],
|
||||||
|
}
|
||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _output_node_kinds(workflow_row: dict[str, Any]) -> dict[str, str] | None:
|
||||||
|
"""Confirmed {nodeId: image|video} for this workflow, or None when
|
||||||
|
the outputs are not confirmed (unknown nodes, no user mapping)."""
|
||||||
|
from calliope.comfyui.output_map import mapping_problem, resolve_output_map
|
||||||
|
|
||||||
|
workflow = workflow_row["workflow_json"]
|
||||||
|
problem = mapping_problem(
|
||||||
|
workflow, workflow_row.get("output_map"), workflow_row.get("output_map_source")
|
||||||
|
)
|
||||||
|
if problem:
|
||||||
|
return None
|
||||||
|
entries, _source = resolve_output_map(
|
||||||
|
workflow_row.get("output_map"),
|
||||||
|
workflow_row.get("output_map_source"),
|
||||||
|
workflow,
|
||||||
|
)
|
||||||
|
return {str(e["nodeId"]): str(e["kind"]) for e in entries} or None
|
||||||
|
|
||||||
def _job_label(self, job: dict[str, Any]) -> str:
|
def _job_label(self, job: dict[str, Any]) -> str:
|
||||||
payload = json.loads(job.get("payload_json") or "{}")
|
payload = json.loads(job.get("payload_json") or "{}")
|
||||||
kind = job.get("kind") or "job"
|
kind = job.get("kind") or "job"
|
||||||
|
|||||||
@@ -77,8 +77,11 @@ def _parsed_url(base_url: str) -> tuple[str, str]:
|
|||||||
url = (base_url or "").strip()
|
url = (base_url or "").strip()
|
||||||
if not url:
|
if not url:
|
||||||
raise HTTPException(status_code=400, detail="API 地址不能为空")
|
raise HTTPException(status_code=400, detail="API 地址不能为空")
|
||||||
if "://" not in url:
|
# HEL-619: the server validates format as strictly as the UI already
|
||||||
url = f"http://{url}"
|
# does. A schemeless garbled string used to be silently prefixed with
|
||||||
|
# http:// and then reported as a DNS failure; it is a 400 format error.
|
||||||
|
if "://" not in url or any(ch.isspace() for ch in url):
|
||||||
|
raise HTTPException(status_code=400, detail="地址必须是 http:// 或 https:// 开头的有效 URL")
|
||||||
parsed = urlparse(url)
|
parsed = urlparse(url)
|
||||||
if parsed.scheme not in ("http", "https") or not parsed.hostname:
|
if parsed.scheme not in ("http", "https") or not parsed.hostname:
|
||||||
raise HTTPException(status_code=400, detail="地址必须是 http:// 或 https:// 开头的有效 URL")
|
raise HTTPException(status_code=400, detail="地址必须是 http:// 或 https:// 开头的有效 URL")
|
||||||
@@ -135,7 +138,12 @@ async def list_endpoints() -> dict[str, Any]:
|
|||||||
|
|
||||||
@router.post("/endpoints")
|
@router.post("/endpoints")
|
||||||
async def create_endpoint(payload: EndpointIn) -> dict[str, Any]:
|
async def create_endpoint(payload: EndpointIn) -> dict[str, Any]:
|
||||||
base_url, _host = _parsed_url(payload.base_url)
|
base_url, host = _parsed_url(payload.base_url)
|
||||||
|
# HEL-619: the same SSRF guard as the connectivity test applies on
|
||||||
|
# save — otherwise a blocked address can be stored and later probed by
|
||||||
|
# the worker path. Unresolvable hosts still pass (resolution happens
|
||||||
|
# again at probe time).
|
||||||
|
_assert_not_ssrf(host)
|
||||||
incoming = [ep for ep in settings.comfyui_endpoints or []]
|
incoming = [ep for ep in settings.comfyui_endpoints or []]
|
||||||
incoming.append(payload.model_dump() | {"base_url": base_url})
|
incoming.append(payload.model_dump() | {"base_url": base_url})
|
||||||
try:
|
try:
|
||||||
@@ -151,7 +159,8 @@ async def update_endpoint(endpoint_id: str, payload: EndpointPatch) -> dict[str,
|
|||||||
_stored_endpoint(endpoint_id)
|
_stored_endpoint(endpoint_id)
|
||||||
base_url = payload.base_url
|
base_url = payload.base_url
|
||||||
if base_url is not None:
|
if base_url is not None:
|
||||||
base_url, _host = _parsed_url(base_url)
|
base_url, host = _parsed_url(base_url)
|
||||||
|
_assert_not_ssrf(host) # same save-time guard as create (HEL-619)
|
||||||
patch = payload.model_dump(exclude_unset=True)
|
patch = payload.model_dump(exclude_unset=True)
|
||||||
if base_url is not None:
|
if base_url is not None:
|
||||||
patch["base_url"] = base_url
|
patch["base_url"] = base_url
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from pydantic import BaseModel, Field
|
|||||||
from calliope import config
|
from calliope import config
|
||||||
from calliope.agent.prompts import item_reference_prompt
|
from calliope.agent.prompts import item_reference_prompt
|
||||||
from calliope.comfyui.lint import blocking_problem
|
from calliope.comfyui.lint import blocking_problem
|
||||||
|
from calliope.comfyui.output_map import mapping_problem
|
||||||
from calliope.comfyui.parser import effective_input_schema
|
from calliope.comfyui.parser import effective_input_schema
|
||||||
from calliope.comfyui.validate import validate_input_values
|
from calliope.comfyui.validate import validate_input_values
|
||||||
from calliope.db import get_db, row_to_dict
|
from calliope.db import get_db, row_to_dict
|
||||||
@@ -335,7 +336,8 @@ async def generate(payload: PlaygroundGenerate) -> dict[str, Any]:
|
|||||||
try:
|
try:
|
||||||
pid = ensure_playground_project(conn)
|
pid = ensure_playground_project(conn)
|
||||||
wf = conn.execute(
|
wf = conn.execute(
|
||||||
"SELECT id, kind, is_enabled, workflow_json, input_schema FROM workflows WHERE id = ?",
|
"SELECT id, kind, is_enabled, workflow_json, input_schema, output_map,"
|
||||||
|
" output_map_source FROM workflows WHERE id = ?",
|
||||||
(payload.workflow_id,),
|
(payload.workflow_id,),
|
||||||
).fetchone()
|
).fetchone()
|
||||||
if not wf:
|
if not wf:
|
||||||
@@ -348,6 +350,11 @@ async def generate(payload: PlaygroundGenerate) -> dict[str, Any]:
|
|||||||
)
|
)
|
||||||
kind = wf["kind"]
|
kind = wf["kind"]
|
||||||
workflow_json = json.loads(wf["workflow_json"])
|
workflow_json = json.loads(wf["workflow_json"])
|
||||||
|
# HEL-638: a workflow with unknown custom output nodes must have a
|
||||||
|
# confirmed output mapping before anything is queued.
|
||||||
|
map_problem = mapping_problem(workflow_json, wf["output_map"], wf["output_map_source"])
|
||||||
|
if map_problem:
|
||||||
|
raise HTTPException(status_code=400, detail=map_problem)
|
||||||
schema = effective_input_schema(
|
schema = effective_input_schema(
|
||||||
json.loads(wf["input_schema"]) if wf["input_schema"] else [], workflow_json
|
json.loads(wf["input_schema"]) if wf["input_schema"] else [], workflow_json
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -107,7 +107,11 @@ async def update_settings(payload: SettingsUpdate) -> dict[str, Any]:
|
|||||||
if assignments_in is not None:
|
if assignments_in is not None:
|
||||||
settings.ensure_llm_profiles()
|
settings.ensure_llm_profiles()
|
||||||
ids = {p["id"] for p in settings.llm_profiles}
|
ids = {p["id"] for p in settings.llm_profiles}
|
||||||
cleaned: dict[str, str | None] = {}
|
# HEL-619: per-role INCREMENTAL update. Rapid dropdown switches used
|
||||||
|
# to send whole cached snapshots that fully overwrote the map, so a
|
||||||
|
# stale snapshot could wipe a newer choice. Roles absent from the
|
||||||
|
# payload keep their stored value; a role sent as null is cleared.
|
||||||
|
cleaned: dict[str, str | None] = dict(settings.agent_llm_assignments or {})
|
||||||
for role, pid in assignments_in.items():
|
for role, pid in assignments_in.items():
|
||||||
if role not in AGENT_LLM_ROLES:
|
if role not in AGENT_LLM_ROLES:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -6,12 +6,21 @@ from typing import Any
|
|||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
|
|
||||||
from calliope.comfyui.lint import workflow_warnings
|
from calliope.comfyui.lint import workflow_warnings
|
||||||
|
from calliope.comfyui.output_map import (
|
||||||
|
auto_output_map,
|
||||||
|
load_output_map,
|
||||||
|
mapping_problem,
|
||||||
|
needs_user_output_map,
|
||||||
|
validate_output_map,
|
||||||
|
)
|
||||||
from calliope.comfyui.parser import (
|
from calliope.comfyui.parser import (
|
||||||
|
classify_usage,
|
||||||
effective_input_schema,
|
effective_input_schema,
|
||||||
parse_dynamic_inputs,
|
parse_dynamic_inputs,
|
||||||
parse_dynamic_outputs,
|
parse_dynamic_outputs,
|
||||||
)
|
)
|
||||||
from calliope.comfyui.profiles import detect_prompt_profile
|
from calliope.comfyui.profiles import detect_prompt_profile
|
||||||
|
from calliope.comfyui.roles import usage_to_kind
|
||||||
from calliope.config import settings
|
from calliope.config import settings
|
||||||
from calliope.db import get_db, row_to_dict
|
from calliope.db import get_db, row_to_dict
|
||||||
from calliope.models.schemas import WorkflowAnalyze, WorkflowCreate, WorkflowUpdate
|
from calliope.models.schemas import WorkflowAnalyze, WorkflowCreate, WorkflowUpdate
|
||||||
@@ -24,9 +33,17 @@ def _serialize_workflow(row: Any) -> dict[str, Any]:
|
|||||||
data["workflow_json"] = json.loads(data["workflow_json"])
|
data["workflow_json"] = json.loads(data["workflow_json"])
|
||||||
stored = json.loads(data["input_schema"]) if data.get("input_schema") else []
|
stored = json.loads(data["input_schema"]) if data.get("input_schema") else []
|
||||||
data["input_schema"] = effective_input_schema(stored, data["workflow_json"])
|
data["input_schema"] = effective_input_schema(stored, data["workflow_json"])
|
||||||
data["output_schema"] = json.loads(data["output_schema"]) if data.get("output_schema") else []
|
# Outputs are pure graph derivation (no manual overrides) — always fresh,
|
||||||
|
# so parser upgrades reach old rows without a re-import.
|
||||||
|
data["output_schema"] = parse_dynamic_outputs(data["workflow_json"])
|
||||||
data["is_enabled"] = bool(data.get("is_enabled"))
|
data["is_enabled"] = bool(data.get("is_enabled"))
|
||||||
data["warnings"] = workflow_warnings(data["workflow_json"])
|
data["warnings"] = workflow_warnings(data["workflow_json"])
|
||||||
|
raw_map = data.get("output_map")
|
||||||
|
data["output_map"] = load_output_map(raw_map)
|
||||||
|
# Pending flag: unknown output candidates the user has not mapped yet.
|
||||||
|
data["needs_mapping"] = (
|
||||||
|
mapping_problem(data["workflow_json"], raw_map, data.get("output_map_source")) is not None
|
||||||
|
)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
@@ -34,20 +51,36 @@ def _serialize_workflow(row: Any) -> dict[str, Any]:
|
|||||||
async def analyze_workflow(payload: WorkflowAnalyze) -> dict[str, Any]:
|
async def analyze_workflow(payload: WorkflowAnalyze) -> dict[str, Any]:
|
||||||
inputs = parse_dynamic_inputs(payload.workflow_json)
|
inputs = parse_dynamic_inputs(payload.workflow_json)
|
||||||
outputs = parse_dynamic_outputs(payload.workflow_json)
|
outputs = parse_dynamic_outputs(payload.workflow_json)
|
||||||
|
judgment = classify_usage(payload.workflow_json)
|
||||||
return {
|
return {
|
||||||
"inputs": inputs,
|
"inputs": inputs,
|
||||||
"outputs": outputs,
|
"outputs": outputs,
|
||||||
"suggested_profile": detect_prompt_profile(payload.workflow_json),
|
"suggested_profile": detect_prompt_profile(payload.workflow_json),
|
||||||
"warnings": workflow_warnings(payload.workflow_json),
|
"warnings": workflow_warnings(payload.workflow_json),
|
||||||
|
"usage": judgment["usage"],
|
||||||
|
"usage_ambiguous": judgment["ambiguous"],
|
||||||
|
"needs_mapping": judgment["needs_mapping"],
|
||||||
|
"usage_problem": judgment["problem"],
|
||||||
|
"usage_evidence": judgment["evidence"],
|
||||||
|
"usable_usage": judgment["usable_usage"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _stored_schema(payload_schema: list[dict[str, Any]] | None, workflow: dict[str, Any]) -> str:
|
||||||
|
"""Schema to persist: the confirm page's corrected copy, else the auto one."""
|
||||||
|
if payload_schema and all(isinstance(e, dict) for e in payload_schema):
|
||||||
|
return json.dumps(payload_schema)
|
||||||
|
return json.dumps(parse_dynamic_inputs(workflow))
|
||||||
|
|
||||||
|
|
||||||
@router.post("/{workflow_id}/reanalyze")
|
@router.post("/{workflow_id}/reanalyze")
|
||||||
async def reanalyze_workflow(workflow_id: int) -> dict[str, Any]:
|
async def reanalyze_workflow(workflow_id: int) -> dict[str, Any]:
|
||||||
"""Recompute input/output schemas from the stored workflow JSON.
|
"""Recompute usage and input/output schemas from the stored workflow JSON.
|
||||||
|
|
||||||
Workflows imported before a parser upgrade keep stale (often empty)
|
Workflows imported before a parser upgrade keep stale (often empty)
|
||||||
schemas — this refreshes them without re-importing.
|
schemas — this refreshes them without re-importing. A usage or output
|
||||||
|
mapping the user set by hand is never overwritten; only ``auto`` (and
|
||||||
|
pending NULL) rows get the new judgment.
|
||||||
"""
|
"""
|
||||||
conn = get_db(settings.db_path)
|
conn = get_db(settings.db_path)
|
||||||
try:
|
try:
|
||||||
@@ -56,11 +89,40 @@ async def reanalyze_workflow(workflow_id: int) -> dict[str, Any]:
|
|||||||
raise HTTPException(status_code=404, detail="Workflow not found")
|
raise HTTPException(status_code=404, detail="Workflow not found")
|
||||||
data = row_to_dict(row)
|
data = row_to_dict(row)
|
||||||
workflow = json.loads(data["workflow_json"])
|
workflow = json.loads(data["workflow_json"])
|
||||||
inputs = parse_dynamic_inputs(workflow)
|
judgment = classify_usage(workflow)
|
||||||
|
usage = data["usage"]
|
||||||
|
usage_source = data["usage_source"]
|
||||||
|
if data["usage_source"] != "user" and judgment["usage"]:
|
||||||
|
usage = judgment["usage"]
|
||||||
|
usage_source = "auto"
|
||||||
|
stored = json.loads(data["input_schema"]) if data["input_schema"] else []
|
||||||
|
schema = effective_input_schema(stored, workflow)
|
||||||
outputs = parse_dynamic_outputs(workflow)
|
outputs = parse_dynamic_outputs(workflow)
|
||||||
|
if data["output_map_source"] == "user":
|
||||||
|
output_map, output_map_source = data["output_map"], "user"
|
||||||
|
elif needs_user_output_map(workflow):
|
||||||
|
# Unknown output candidates: no auto map, and the row must not
|
||||||
|
# generate until the user designates the output nodes.
|
||||||
|
output_map, output_map_source = None, None
|
||||||
|
else:
|
||||||
|
output_map, output_map_source = json.dumps(auto_output_map(workflow)), "auto"
|
||||||
|
is_enabled = data["is_enabled"]
|
||||||
|
if output_map_source is None or usage is None:
|
||||||
|
is_enabled = 0
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"UPDATE workflows SET input_schema = ?, output_schema = ? WHERE id = ?",
|
"UPDATE workflows SET input_schema = ?, output_schema = ?,"
|
||||||
(json.dumps(inputs), json.dumps(outputs), workflow_id),
|
" usage = ?, usage_source = ?, output_map = ?, output_map_source = ?,"
|
||||||
|
" is_enabled = ? WHERE id = ?",
|
||||||
|
(
|
||||||
|
json.dumps(schema),
|
||||||
|
json.dumps(outputs),
|
||||||
|
usage,
|
||||||
|
usage_source,
|
||||||
|
output_map,
|
||||||
|
output_map_source,
|
||||||
|
is_enabled,
|
||||||
|
workflow_id,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
fresh = conn.execute(
|
fresh = conn.execute(
|
||||||
@@ -118,38 +180,77 @@ async def dedupe_workflows() -> dict[str, Any]:
|
|||||||
|
|
||||||
@router.post("")
|
@router.post("")
|
||||||
async def create_workflow(payload: WorkflowCreate) -> dict[str, Any]:
|
async def create_workflow(payload: WorkflowCreate) -> dict[str, Any]:
|
||||||
inputs = parse_dynamic_inputs(payload.workflow_json)
|
judgment = classify_usage(payload.workflow_json)
|
||||||
outputs = parse_dynamic_outputs(payload.workflow_json)
|
usage = payload.usage or judgment["usage"]
|
||||||
|
usage_source = "user" if payload.usage else "auto"
|
||||||
|
kind = payload.kind or usage_to_kind(usage)
|
||||||
|
if kind is None:
|
||||||
|
# Indeterminate and nothing chosen: classify_output hint keeps old
|
||||||
|
# callers working while the workflow stays pending confirmation.
|
||||||
|
out_kinds = {
|
||||||
|
o.get("kind")
|
||||||
|
for o in parse_dynamic_outputs(payload.workflow_json)
|
||||||
|
if o.get("kind") in ("image", "video")
|
||||||
|
}
|
||||||
|
kind = "video" if out_kinds == {"video"} else "image"
|
||||||
profile = payload.prompt_profile or detect_prompt_profile(payload.workflow_json)
|
profile = payload.prompt_profile or detect_prompt_profile(payload.workflow_json)
|
||||||
|
# HEL-638: an explicit user output map wins; otherwise the trusted auto
|
||||||
|
# map. Either way a graph with unknown output candidates is unusable
|
||||||
|
# until the user designates the output nodes.
|
||||||
|
if payload.output_map:
|
||||||
|
problems = validate_output_map(payload.workflow_json, payload.output_map)
|
||||||
|
if problems:
|
||||||
|
raise HTTPException(status_code=422, detail=";".join(problems))
|
||||||
|
output_map = json.dumps(payload.output_map)
|
||||||
|
output_map_source = payload.output_map_source or "user"
|
||||||
|
else:
|
||||||
|
auto_map = auto_output_map(payload.workflow_json)
|
||||||
|
output_map = json.dumps(auto_map) if auto_map else None
|
||||||
|
output_map_source = "auto" if auto_map else None
|
||||||
|
mapping_ok = not needs_user_output_map(payload.workflow_json) or bool(payload.output_map)
|
||||||
conn = get_db(settings.db_path)
|
conn = get_db(settings.db_path)
|
||||||
try:
|
try:
|
||||||
# Byte-identical re-imports are the main way the library fills up with
|
# Byte-identical re-imports are the main way the library fills up with
|
||||||
# same-named clones (the "@" typeahead then shows 20 identical rows).
|
# same-named clones (the "@" typeahead then shows 20 identical rows).
|
||||||
existing = conn.execute(
|
existing = conn.execute(
|
||||||
"SELECT id, name FROM workflows WHERE name = ? AND kind = ? AND workflow_json = ?",
|
"SELECT id, name FROM workflows WHERE name = ? AND kind = ? AND workflow_json = ?",
|
||||||
(payload.name, payload.kind, json.dumps(payload.workflow_json)),
|
(payload.name, kind, json.dumps(payload.workflow_json)),
|
||||||
).fetchone()
|
).fetchone()
|
||||||
if existing:
|
if existing:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=409,
|
status_code=409,
|
||||||
detail=f"An identical workflow already exists (id {existing['id']}, “{existing['name']}”).",
|
detail=(
|
||||||
|
f"An identical workflow already exists (id {existing['id']},"
|
||||||
|
f" “{existing['name']}”)."
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
# Unconfirmed workflows (ambiguous usage / unknown outputs without a
|
||||||
|
# user mapping) are stored but disabled: they must not reach the
|
||||||
|
# generate pages until the user confirms usage AND, for unknown
|
||||||
|
# output nodes, designates the outputs on the connections page.
|
||||||
|
is_enabled = 1 if (usage and mapping_ok) else 0
|
||||||
cur = conn.execute(
|
cur = conn.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO workflows (name, kind, workflow_json, input_schema,
|
INSERT INTO workflows (name, kind, workflow_json, input_schema,
|
||||||
output_schema, description, prompt_profile,
|
output_schema, description, prompt_profile,
|
||||||
endpoint_id, is_enabled)
|
endpoint_id, is_enabled, usage, usage_source,
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1)
|
output_map, output_map_source)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
""",
|
""",
|
||||||
(
|
(
|
||||||
payload.name,
|
payload.name,
|
||||||
payload.kind,
|
kind,
|
||||||
json.dumps(payload.workflow_json),
|
json.dumps(payload.workflow_json),
|
||||||
json.dumps(inputs),
|
_stored_schema(payload.input_schema, payload.workflow_json),
|
||||||
json.dumps(outputs),
|
json.dumps(parse_dynamic_outputs(payload.workflow_json)),
|
||||||
payload.description,
|
payload.description,
|
||||||
profile,
|
profile,
|
||||||
payload.endpoint_id,
|
payload.endpoint_id,
|
||||||
|
is_enabled,
|
||||||
|
usage,
|
||||||
|
usage_source,
|
||||||
|
output_map,
|
||||||
|
output_map_source,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
@@ -181,9 +282,54 @@ async def update_workflow(workflow_id: int, payload: WorkflowUpdate) -> dict[str
|
|||||||
data = payload.model_dump(exclude_unset=True)
|
data = payload.model_dump(exclude_unset=True)
|
||||||
if "is_enabled" in data and data["is_enabled"] is not None:
|
if "is_enabled" in data and data["is_enabled"] is not None:
|
||||||
data["is_enabled"] = 1 if data["is_enabled"] else 0
|
data["is_enabled"] = 1 if data["is_enabled"] else 0
|
||||||
# endpoint_id: explicit null clears the binding; other Nones are skips.
|
workflow_json = json.loads(existing["workflow_json"])
|
||||||
explicit_null = {"endpoint_id"} & {k for k, v in data.items() if v is None}
|
# HEL-638: output_map payload. A non-empty list validates against the
|
||||||
|
# stored JSON and becomes the user decision; an explicit empty list
|
||||||
|
# resets the row to pending (disabled).
|
||||||
|
if "output_map" in data:
|
||||||
|
if data["output_map"]:
|
||||||
|
problems = validate_output_map(workflow_json, data["output_map"])
|
||||||
|
if problems:
|
||||||
|
raise HTTPException(status_code=422, detail=";".join(problems))
|
||||||
|
data["output_map"] = json.dumps(data["output_map"])
|
||||||
|
data.setdefault("output_map_source", "user")
|
||||||
|
else:
|
||||||
|
data["output_map"] = None
|
||||||
|
data["output_map_source"] = None
|
||||||
|
data["is_enabled"] = 0
|
||||||
|
if data.get("usage"):
|
||||||
|
# Confirming / correcting the usage is an explicit user decision:
|
||||||
|
# kind (output media) follows the usage. Whether it re-enables is
|
||||||
|
# decided by the gate below — with unknown output nodes the user
|
||||||
|
# must also designate the output nodes (HEL-638).
|
||||||
|
data.setdefault("usage_source", "user")
|
||||||
|
data["kind"] = usage_to_kind(data["usage"]) or existing["kind"]
|
||||||
|
if "input_schema" in data and data["input_schema"] is not None:
|
||||||
|
if not all(isinstance(e, dict) for e in data["input_schema"]):
|
||||||
|
raise HTTPException(status_code=422, detail="input_schema 必须是参数对象数组")
|
||||||
|
data["input_schema"] = json.dumps(data["input_schema"])
|
||||||
|
# endpoint_id: explicit null clears the binding; other Nones are skips
|
||||||
|
# (an output_map reset keeps its explicit NULLs).
|
||||||
|
explicit_null = {"endpoint_id", "output_map", "output_map_source"} & {
|
||||||
|
k for k, v in data.items() if v is None
|
||||||
|
}
|
||||||
data = {k: v for k, v in data.items() if v is not None or k in explicit_null}
|
data = {k: v for k, v in data.items() if v is not None or k in explicit_null}
|
||||||
|
|
||||||
|
# Enable gate: usage must be settled and, when the graph carries
|
||||||
|
# unknown custom output nodes, a user output mapping must exist.
|
||||||
|
usage_ok = bool(data.get("usage") or existing["usage"])
|
||||||
|
map_raw = data.get("output_map", existing["output_map"])
|
||||||
|
map_source = data.get("output_map_source", existing["output_map_source"])
|
||||||
|
map_problem = mapping_problem(workflow_json, map_raw, map_source)
|
||||||
|
if data.get("is_enabled"):
|
||||||
|
if not usage_ok:
|
||||||
|
raise HTTPException(status_code=400, detail="请先选择工作流用途,再启用该工作流")
|
||||||
|
if map_problem:
|
||||||
|
raise HTTPException(status_code=400, detail=map_problem)
|
||||||
|
elif (data.get("usage") or data.get("output_map")) and "is_enabled" not in data:
|
||||||
|
# A usage-confirm or output-map-confirm path: enabled only when
|
||||||
|
# both decisions are settled.
|
||||||
|
data["is_enabled"] = 1 if (usage_ok and not map_problem) else 0
|
||||||
if data:
|
if data:
|
||||||
fields = ", ".join(f"{k} = :{k}" for k in data)
|
fields = ", ".join(f"{k} = :{k}" for k in data)
|
||||||
data["id"] = workflow_id
|
data["id"] = workflow_id
|
||||||
@@ -199,10 +345,29 @@ async def update_workflow(workflow_id: int, payload: WorkflowUpdate) -> dict[str
|
|||||||
async def delete_workflow(workflow_id: int) -> dict[str, bool]:
|
async def delete_workflow(workflow_id: int) -> dict[str, bool]:
|
||||||
conn = get_db(settings.db_path)
|
conn = get_db(settings.db_path)
|
||||||
try:
|
try:
|
||||||
cur = conn.execute("DELETE FROM workflows WHERE id = ?", (workflow_id,))
|
# HEL-619: refuse to delete while queued/running jobs still use the
|
||||||
conn.commit()
|
# workflow — deleting sets their workflow_id NULL and the job dies
|
||||||
if cur.rowcount == 0:
|
# with "工作流已被删除" only after the user waits for it.
|
||||||
|
row = conn.execute(
|
||||||
|
"SELECT id FROM workflows WHERE id = ?", (workflow_id,)
|
||||||
|
).fetchone()
|
||||||
|
if not row:
|
||||||
raise HTTPException(status_code=404, detail="Workflow not found")
|
raise HTTPException(status_code=404, detail="Workflow not found")
|
||||||
|
pending = conn.execute(
|
||||||
|
"SELECT COUNT(*) AS n FROM jobs"
|
||||||
|
" WHERE workflow_id = ? AND status IN ('pending', 'running')",
|
||||||
|
(workflow_id,),
|
||||||
|
).fetchone()["n"]
|
||||||
|
if pending:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=409,
|
||||||
|
detail=(
|
||||||
|
f"该工作流还有 {pending} 个排队或执行中的任务,"
|
||||||
|
"请先等任务完成或取消任务,再删除该工作流"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
conn.execute("DELETE FROM workflows WHERE id = ?", (workflow_id,))
|
||||||
|
conn.commit()
|
||||||
return {"ok": True}
|
return {"ok": True}
|
||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ from fastapi.testclient import TestClient
|
|||||||
from calliope.db import migrate_db
|
from calliope.db import migrate_db
|
||||||
from calliope.main import create_app
|
from calliope.main import create_app
|
||||||
|
|
||||||
|
# Shared fake-ComfyUI HTTP server (defined in test_studio_generation,
|
||||||
|
# reused by the generation / status / unknown-output-mapping suites).
|
||||||
|
from tests.test_studio_generation import fake_comfy # noqa: F401,E402
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def client(monkeypatch):
|
def client(monkeypatch):
|
||||||
|
|||||||
@@ -374,6 +374,61 @@ def test_comfy_test_requires_url(client):
|
|||||||
assert r.status_code == 400
|
assert r.status_code == 400
|
||||||
|
|
||||||
|
|
||||||
|
def test_schemeless_url_is_format_error_everywhere(client):
|
||||||
|
"""HEL-619: a schemeless/garbled address is a 400 format error on every
|
||||||
|
entry point (probe + save), not a silent http:// prefix that later
|
||||||
|
surfaces as a DNS-classified probe failure."""
|
||||||
|
prev = _snapshot_settings()
|
||||||
|
try:
|
||||||
|
for url in ("192.168.0.1:8188", "http:192.168.0.1", "ht!tp://x", "http://a b.test/"):
|
||||||
|
r = client.post(
|
||||||
|
"/api/comfyui/endpoints/test", json={"base_url": url, "timeout_sec": 2}
|
||||||
|
)
|
||||||
|
assert r.status_code == 400, url
|
||||||
|
assert "http://" in r.json()["detail"] or "https://" in r.json()["detail"]
|
||||||
|
r = client.post(
|
||||||
|
"/api/comfyui/endpoints", json={"name": "无协议", "base_url": url}
|
||||||
|
)
|
||||||
|
assert r.status_code == 400, url
|
||||||
|
assert "无协议" not in [ep.get("name") for ep in settings.comfyui_endpoints or []]
|
||||||
|
finally:
|
||||||
|
for key, value in prev.items():
|
||||||
|
setattr(settings, key, value)
|
||||||
|
|
||||||
|
|
||||||
|
def test_save_endpoint_runs_ssrf_guard(client):
|
||||||
|
"""HEL-619: the SSRF guard applies on save (create + edit), not only on
|
||||||
|
the connectivity probe; loopback stays allowed."""
|
||||||
|
prev = _snapshot_settings()
|
||||||
|
try:
|
||||||
|
_clear_endpoints()
|
||||||
|
r = client.post(
|
||||||
|
"/api/comfyui/endpoints",
|
||||||
|
json={"name": "元数据", "base_url": "http://169.254.169.254/latest"},
|
||||||
|
)
|
||||||
|
assert r.status_code == 400
|
||||||
|
assert "禁止" in r.json()["detail"]
|
||||||
|
|
||||||
|
r = client.post(
|
||||||
|
"/api/comfyui/endpoints",
|
||||||
|
json={"name": "本机", "base_url": "http://127.0.0.1:8188"},
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
eid = r.json()["endpoints"][-1]["id"]
|
||||||
|
|
||||||
|
r = client.patch(
|
||||||
|
f"/api/comfyui/endpoints/{eid}",
|
||||||
|
json={"base_url": "http://169.254.169.254/latest"},
|
||||||
|
)
|
||||||
|
assert r.status_code == 400
|
||||||
|
# the stored endpoint is untouched
|
||||||
|
stored = next(ep for ep in settings.comfyui_endpoints if ep["id"] == eid)
|
||||||
|
assert stored["base_url"] == "http://127.0.0.1:8188"
|
||||||
|
finally:
|
||||||
|
for key, value in prev.items():
|
||||||
|
setattr(settings, key, value)
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# workflow binding + job snapshots
|
# workflow binding + job snapshots
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
@@ -389,6 +444,13 @@ def _import_workflow(client, name="H3 视频", kind="video", endpoint_id=None):
|
|||||||
"class_type": "CLIPTextEncode",
|
"class_type": "CLIPTextEncode",
|
||||||
"inputs": {"text": "placeholder prompt", "clip": ["4", 1]},
|
"inputs": {"text": "placeholder prompt", "clip": ["4", 1]},
|
||||||
},
|
},
|
||||||
|
# HEL-636: a workflow needs a recognizable output node to classify a
|
||||||
|
# usage and stay enabled; without it generation is refused.
|
||||||
|
"9": {
|
||||||
|
"class_type": "VHS_VideoCombine",
|
||||||
|
"inputs": {"images": ["6", 0]},
|
||||||
|
"_meta": {"title": "Video Output (Output:video)"},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
payload = {"name": name, "kind": kind, "workflow_json": wf_json}
|
payload = {"name": name, "kind": kind, "workflow_json": wf_json}
|
||||||
if endpoint_id is not None:
|
if endpoint_id is not None:
|
||||||
@@ -535,6 +597,41 @@ def test_queue_enqueue_stamps_all_paths(client):
|
|||||||
setattr(settings, key, value)
|
setattr(settings, key, value)
|
||||||
|
|
||||||
|
|
||||||
|
def test_workflow_delete_blocked_while_jobs_pending(client):
|
||||||
|
"""HEL-619: deleting a workflow with pending/running jobs is refused
|
||||||
|
with 409 instead of silently nulling the jobs' workflow_id."""
|
||||||
|
from calliope.db import get_db
|
||||||
|
from calliope.queue.manager import queue_manager
|
||||||
|
|
||||||
|
wf = _import_workflow(client).json()
|
||||||
|
project = client.post(
|
||||||
|
"/api/projects", json={"title": "删除保护测试", "idea": "x"}
|
||||||
|
).json()
|
||||||
|
# Pause the lifespan-started worker so the pending job STAYS pending.
|
||||||
|
queue_manager.paused = True
|
||||||
|
try:
|
||||||
|
queue_manager.enqueue(
|
||||||
|
project_id=project["id"], kind="video", workflow_id=wf["id"], payload={}
|
||||||
|
)
|
||||||
|
|
||||||
|
r = client.delete(f"/api/workflows/{wf['id']}")
|
||||||
|
assert r.status_code == 409
|
||||||
|
assert "排队" in r.json()["detail"]
|
||||||
|
finally:
|
||||||
|
queue_manager.paused = False
|
||||||
|
|
||||||
|
# job finished → deletion allowed again
|
||||||
|
conn = get_db(settings.db_path)
|
||||||
|
try:
|
||||||
|
conn.execute("UPDATE jobs SET status = 'done' WHERE project_id = ?", (project["id"],))
|
||||||
|
conn.commit()
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
r = client.delete(f"/api/workflows/{wf['id']}")
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert r.json() == {"ok": True}
|
||||||
|
|
||||||
|
|
||||||
def test_settings_public_dict_masks_endpoint_tokens(client):
|
def test_settings_public_dict_masks_endpoint_tokens(client):
|
||||||
prev = _snapshot_settings()
|
prev = _snapshot_settings()
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -216,6 +216,18 @@ def test_settings_accepts_agent_llm_assignments(client):
|
|||||||
# Unknown role keys are dropped, known roles stored (incl. explicit None)
|
# Unknown role keys are dropped, known roles stored (incl. explicit None)
|
||||||
assert body["agent_llm_assignments"] == {"video": a_id, "story": None}
|
assert body["agent_llm_assignments"] == {"video": a_id, "story": None}
|
||||||
|
|
||||||
|
# HEL-619: updates are per-role incremental — a partial payload must
|
||||||
|
# not wipe roles it does not mention (rapid-switch race).
|
||||||
|
r = client.post(
|
||||||
|
"/api/settings",
|
||||||
|
json={"agent_llm_assignments": {"main": a_id}},
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
body = r.json()
|
||||||
|
assert body["agent_llm_assignments"]["main"] == a_id
|
||||||
|
assert body["agent_llm_assignments"]["video"] == a_id
|
||||||
|
assert body["agent_llm_assignments"]["story"] is None
|
||||||
|
|
||||||
r = client.post(
|
r = client.post(
|
||||||
"/api/settings",
|
"/api/settings",
|
||||||
json={"agent_llm_assignments": {"video": "no-such-profile"}},
|
json={"agent_llm_assignments": {"video": "no-such-profile"}},
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ The shell is default-OFF; every guard branch here is a security contract:
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -25,6 +26,23 @@ from calliope.agent.harness.registry import ToolContext
|
|||||||
PYTHON = Path(sys.executable).stem # bare name ("python") — the tool refuses paths
|
PYTHON = Path(sys.executable).stem # bare name ("python") — the tool refuses paths
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True, scope="module")
|
||||||
|
def _interpreter_on_path():
|
||||||
|
"""Make the bare interpreter name resolvable via PATH (HEL-619).
|
||||||
|
|
||||||
|
The guard resolves the command with ``shutil.which`` against PATH —
|
||||||
|
running pytest as ``path/to/.venv/bin/python -m pytest`` (or on a box
|
||||||
|
with no ``python`` alias) leaves the stem unresolvable and every
|
||||||
|
exec-path test fails for environmental reasons only. Prepending the
|
||||||
|
interpreter's own bin dir (restored afterwards) pins the lookup to the
|
||||||
|
interpreter actually running the suite, on every OS.
|
||||||
|
"""
|
||||||
|
prev = os.environ.get("PATH", "")
|
||||||
|
os.environ["PATH"] = f"{Path(sys.executable).parent}{os.pathsep}{prev}"
|
||||||
|
yield
|
||||||
|
os.environ["PATH"] = prev
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="module")
|
@pytest.fixture(autouse=True, scope="module")
|
||||||
def _never_touch_real_db():
|
def _never_touch_real_db():
|
||||||
"""Redirect data_dir before ANY write in this module (repo test rule)."""
|
"""Redirect data_dir before ANY write in this module (repo test rule)."""
|
||||||
@@ -210,12 +228,19 @@ def test_structured_shell_approval_allows(enabled):
|
|||||||
|
|
||||||
|
|
||||||
def test_cwd_outside_workspace_denied(enabled):
|
def test_cwd_outside_workspace_denied(enabled):
|
||||||
|
"""Guard denial tests use PYTHON + a structured approval card (not
|
||||||
|
ffprobe): the interpreter resolves on every machine, and the card
|
||||||
|
clears the approval gate so the LATER containment check is what fires
|
||||||
|
(HEL-619 — ffprobe-absent boxes used to fail these for environmental
|
||||||
|
reasons)."""
|
||||||
registry, _ = build_harness()
|
registry, _ = build_harness()
|
||||||
|
sid = _session()
|
||||||
|
_answer_card(sid, "Yes, run it")
|
||||||
out = asyncio.run(
|
out = asyncio.run(
|
||||||
registry.execute(
|
registry.execute(
|
||||||
_ctx(),
|
ToolContext(session_id=sid, project_id=None),
|
||||||
"run_command",
|
"run_command",
|
||||||
{"command": "ffprobe", "cwd": str(Path(settings_data_dir_home()))},
|
{"command": PYTHON, "cwd": str(settings_data_dir_home())},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assert out["reason_code"] == "guard_shell_outside_workspace"
|
assert out["reason_code"] == "guard_shell_outside_workspace"
|
||||||
@@ -230,11 +255,13 @@ def test_sensitive_arg_denied(enabled, tmp_path):
|
|||||||
registry, _ = build_harness()
|
registry, _ = build_harness()
|
||||||
secret = tmp_path / "calliope_config.json"
|
secret = tmp_path / "calliope_config.json"
|
||||||
secret.write_text("{}", encoding="utf-8")
|
secret.write_text("{}", encoding="utf-8")
|
||||||
|
sid = _session()
|
||||||
|
_answer_card(sid, "Yes, run it")
|
||||||
out = asyncio.run(
|
out = asyncio.run(
|
||||||
registry.execute(
|
registry.execute(
|
||||||
_ctx(),
|
ToolContext(session_id=sid, project_id=None),
|
||||||
"run_command",
|
"run_command",
|
||||||
{"command": "ffprobe", "args": [str(secret)]},
|
{"command": PYTHON, "args": ["-c", "print('x')", str(secret)]},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assert out["reason_code"] == "guard_shell_denied_path"
|
assert out["reason_code"] == "guard_shell_denied_path"
|
||||||
@@ -244,11 +271,13 @@ def test_db_arg_denied(enabled, tmp_path):
|
|||||||
registry, _ = build_harness()
|
registry, _ = build_harness()
|
||||||
db = tmp_path / "calliope.db"
|
db = tmp_path / "calliope.db"
|
||||||
db.write_bytes(b"")
|
db.write_bytes(b"")
|
||||||
|
sid = _session()
|
||||||
|
_answer_card(sid, "Yes, run it")
|
||||||
out = asyncio.run(
|
out = asyncio.run(
|
||||||
registry.execute(
|
registry.execute(
|
||||||
_ctx(),
|
ToolContext(session_id=sid, project_id=None),
|
||||||
"run_command",
|
"run_command",
|
||||||
{"command": "ffprobe", "args": [str(db)]},
|
{"command": PYTHON, "args": ["-c", "print('x')", str(db)]},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assert out["reason_code"] == "guard_shell_denied_path"
|
assert out["reason_code"] == "guard_shell_denied_path"
|
||||||
@@ -256,11 +285,13 @@ def test_db_arg_denied(enabled, tmp_path):
|
|||||||
|
|
||||||
def test_env_file_arg_denied(enabled):
|
def test_env_file_arg_denied(enabled):
|
||||||
registry, _ = build_harness()
|
registry, _ = build_harness()
|
||||||
|
sid = _session()
|
||||||
|
_answer_card(sid, "Yes, run it")
|
||||||
out = asyncio.run(
|
out = asyncio.run(
|
||||||
registry.execute(
|
registry.execute(
|
||||||
_ctx(),
|
ToolContext(session_id=sid, project_id=None),
|
||||||
"run_command",
|
"run_command",
|
||||||
{"command": "ffprobe", "args": ["--", ".env"]},
|
{"command": PYTHON, "args": ["-c", "print('x')", "--", ".env"]},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assert out["reason_code"] == "guard_shell_denied_path"
|
assert out["reason_code"] == "guard_shell_denied_path"
|
||||||
@@ -270,11 +301,13 @@ def test_outside_absolute_arg_denied(enabled, tmp_path):
|
|||||||
registry, _ = build_harness()
|
registry, _ = build_harness()
|
||||||
outside = tmp_path / "movie.mp4"
|
outside = tmp_path / "movie.mp4"
|
||||||
outside.write_bytes(b"00")
|
outside.write_bytes(b"00")
|
||||||
|
sid = _session()
|
||||||
|
_answer_card(sid, "Yes, run it")
|
||||||
out = asyncio.run(
|
out = asyncio.run(
|
||||||
registry.execute(
|
registry.execute(
|
||||||
_ctx(),
|
ToolContext(session_id=sid, project_id=None),
|
||||||
"run_command",
|
"run_command",
|
||||||
{"command": "ffprobe", "args": [str(outside)]},
|
{"command": PYTHON, "args": ["-c", "print('x')", str(outside)]},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assert out["reason_code"] == "guard_shell_outside_workspace"
|
assert out["reason_code"] == "guard_shell_outside_workspace"
|
||||||
@@ -287,16 +320,22 @@ def test_inside_asset_arg_allowed(enabled):
|
|||||||
registry, _ = build_harness()
|
registry, _ = build_harness()
|
||||||
ref = settings.assets_dir / "ref.mp4"
|
ref = settings.assets_dir / "ref.mp4"
|
||||||
ref.write_bytes(b"00")
|
ref.write_bytes(b"00")
|
||||||
|
sid = _session()
|
||||||
|
_answer_card(sid, "Yes, run it")
|
||||||
out = asyncio.run(
|
out = asyncio.run(
|
||||||
registry.execute(
|
registry.execute(
|
||||||
_ctx(),
|
ToolContext(session_id=sid, project_id=None),
|
||||||
"run_command",
|
"run_command",
|
||||||
{"command": "ffprobe", "args": ["-v", "error", str(ref)]},
|
{
|
||||||
|
# The asset path is a real argv entry the guard must allow
|
||||||
|
# (and the interpreter actually reads it).
|
||||||
|
"command": PYTHON,
|
||||||
|
"args": ["-c", "import sys; print(open(sys.argv[1]).read())", str(ref)],
|
||||||
|
},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Not a real mp4 — ffprobe fails, but the GUARD must not have denied it.
|
assert out["ok"] is True, out
|
||||||
assert out.get("reason_code") is None
|
assert "00" in out["stdout"]
|
||||||
assert out.get("exit_code") != 0 or out.get("ok") is False or out["ok"] is True
|
|
||||||
|
|
||||||
|
|
||||||
def test_workspace_relative_cwd_allowed(enabled, tmp_path):
|
def test_workspace_relative_cwd_allowed(enabled, tmp_path):
|
||||||
|
|||||||
@@ -25,9 +25,19 @@ PNG_1PX = bytes.fromhex(
|
|||||||
|
|
||||||
|
|
||||||
class _FakeComfyHandler(BaseHTTPRequestHandler):
|
class _FakeComfyHandler(BaseHTTPRequestHandler):
|
||||||
"""Minimal ComfyUI: /system_stats, /prompt, /history/{id}, /view, /upload/image."""
|
"""Minimal ComfyUI: /system_stats, /prompt, /history/{id}, /view, /upload/image.
|
||||||
|
|
||||||
|
History outputs are keyed by the prompt's real output node id (what
|
||||||
|
ComfyUI does); a known output class that is absent falls back to
|
||||||
|
``server.forced_output_node`` (default "9"). Scripted tests can pin
|
||||||
|
``server.forced_output_node`` or drop entries via ``server.drop_outputs``.
|
||||||
|
"""
|
||||||
|
|
||||||
server_version = "FakeComfy/1.0"
|
server_version = "FakeComfy/1.0"
|
||||||
|
KNOWN_OUTPUT_CLASSES = {
|
||||||
|
"SaveImage", "PreviewImage", "SaveImageAdvanced", "SaveImageWebsocket",
|
||||||
|
"SaveVideo", "VideoOutput", "VHS_VideoCombine", "AnimateDiffCombine",
|
||||||
|
}
|
||||||
|
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
self.server.requests.append(self.path)
|
self.server.requests.append(self.path)
|
||||||
@@ -64,11 +74,13 @@ class _FakeComfyHandler(BaseHTTPRequestHandler):
|
|||||||
prompt_id = uuid.uuid4().hex
|
prompt_id = uuid.uuid4().hex
|
||||||
outputs_key = self.server.outputs_key
|
outputs_key = self.server.outputs_key
|
||||||
out_entry = {
|
out_entry = {
|
||||||
outputs_key: [{"filename": self.server.out_name, "subfolder": "", "type": "output"}]
|
outputs_key: [
|
||||||
|
{"filename": self.server.out_name, "subfolder": "", "type": "output"}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
self.server.history[prompt_id] = {
|
self.server.history[prompt_id] = {
|
||||||
"status": {"status_str": "success", "completed": True},
|
"status": {"status_str": "success", "completed": True},
|
||||||
"outputs": {"9": out_entry},
|
"outputs": {self._output_node(body): out_entry},
|
||||||
"prompt": [],
|
"prompt": [],
|
||||||
}
|
}
|
||||||
self.server.prompts.append(json.loads(body.decode("utf-8") or "{}"))
|
self.server.prompts.append(json.loads(body.decode("utf-8") or "{}"))
|
||||||
@@ -80,6 +92,19 @@ class _FakeComfyHandler(BaseHTTPRequestHandler):
|
|||||||
return
|
return
|
||||||
self._json(404, {"error": "not found"})
|
self._json(404, {"error": "not found"})
|
||||||
|
|
||||||
|
def _output_node(self, body: bytes) -> str:
|
||||||
|
forced = getattr(self.server, "forced_output_node", None)
|
||||||
|
if forced:
|
||||||
|
return forced
|
||||||
|
try:
|
||||||
|
prompt = json.loads(body.decode("utf-8") or "{}").get("prompt") or {}
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
prompt = {}
|
||||||
|
for nid, node in prompt.items():
|
||||||
|
if isinstance(node, dict) and node.get("class_type") in self.KNOWN_OUTPUT_CLASSES:
|
||||||
|
return str(nid)
|
||||||
|
return "9"
|
||||||
|
|
||||||
def _json(self, status: int, payload: dict) -> None:
|
def _json(self, status: int, payload: dict) -> None:
|
||||||
data = json.dumps(payload).encode("utf-8")
|
data = json.dumps(payload).encode("utf-8")
|
||||||
self.send_response(status)
|
self.send_response(status)
|
||||||
@@ -109,6 +134,7 @@ def fake_comfy():
|
|||||||
server.fail_prompt = False
|
server.fail_prompt = False
|
||||||
server.out_name = "out-1.png"
|
server.out_name = "out-1.png"
|
||||||
server.outputs_key = "images"
|
server.outputs_key = "images"
|
||||||
|
server.forced_output_node = None
|
||||||
thread = threading.Thread(target=server.serve_forever, daemon=True)
|
thread = threading.Thread(target=server.serve_forever, daemon=True)
|
||||||
thread.start()
|
thread.start()
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -0,0 +1,371 @@
|
|||||||
|
"""HEL-638: unknown custom output nodes close the loop — no name-based
|
||||||
|
auto-typing, feature-less sinks become mappable candidates, a usage choice
|
||||||
|
alone never bypasses the output designation, and generation harvests (and
|
||||||
|
checks) exactly the nodes the user mapped.
|
||||||
|
|
||||||
|
Two brand-new class names drive the cases:
|
||||||
|
|
||||||
|
* ``NebulaGlaxVideoVault`` — screams "video" in its name and carries a
|
||||||
|
filename_prefix; before HEL-638 the fuzzy name match auto-typed it video
|
||||||
|
and enabled the workflow.
|
||||||
|
* ``QuarkMuffinDisplay`` — no save widget, no media link name; before
|
||||||
|
HEL-638 such a graph only reported ``no_output`` with no way to map.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from calliope.config import settings
|
||||||
|
from calliope.db import get_db, migrate_db
|
||||||
|
from tests.test_studio_generation import _real_run, _wait_done
|
||||||
|
|
||||||
|
FIXTURES = Path(__file__).parent / "fixtures" / "comfy_native"
|
||||||
|
|
||||||
|
|
||||||
|
def _vault_workflow() -> dict:
|
||||||
|
return {
|
||||||
|
"1": {"class_type": "PrimitiveStringMultiline", "inputs": {"value": "p"}},
|
||||||
|
"7": {
|
||||||
|
"class_type": "GlaxSamplerNode",
|
||||||
|
"inputs": {"prompt": ["1", 0], "length": 121},
|
||||||
|
},
|
||||||
|
"12": {
|
||||||
|
"class_type": "NebulaGlaxVideoVault",
|
||||||
|
"inputs": {"filename_prefix": "anim", "frames": ["7", 0]},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _muffin_workflow() -> dict:
|
||||||
|
return {
|
||||||
|
"1": {"class_type": "PrimitiveStringMultiline", "inputs": {"value": "p"}},
|
||||||
|
"7": {
|
||||||
|
"class_type": "GlaxSamplerNode",
|
||||||
|
"inputs": {"prompt": ["1", 0], "length": 121},
|
||||||
|
},
|
||||||
|
"15": {"class_type": "QuarkMuffinDisplay", "inputs": {"payload": ["7", 0]}},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _analyze(client, wf: dict) -> dict:
|
||||||
|
r = client.post("/api/workflows/analyze", json={"workflow_json": wf})
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 1. Unknown outputs stay pending — names never decide (gap 1)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_video_semantic_unknown_node_is_never_auto_typed(client):
|
||||||
|
body = _analyze(client, _vault_workflow())
|
||||||
|
entry = next(o for o in body["usage_evidence"]["outputs"] if o["nodeId"] == "12")
|
||||||
|
assert entry["evidence"] == "unknown_node"
|
||||||
|
assert entry["kind"] is None # the user picks the media type
|
||||||
|
assert entry["suggested_kind"] == "video" # only a form default
|
||||||
|
assert body["needs_mapping"] is True
|
||||||
|
assert body["usage"] is None and body["usage_ambiguous"] is True
|
||||||
|
assert "指定实际输出节点" in body["usage_problem"]
|
||||||
|
codes = {(w["level"], w["code"]) for w in body["warnings"]}
|
||||||
|
assert ("warning", "unknown_output_node") in codes
|
||||||
|
assert ("error", "no_output") not in codes
|
||||||
|
|
||||||
|
|
||||||
|
def test_choosing_a_usage_alone_does_not_bypass_output_mapping(client):
|
||||||
|
"""create/PATCH with a usage but no output map keeps the row disabled."""
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "未知·视频语义", "workflow_json": _vault_workflow(),
|
||||||
|
"usage": "text2video", "usage_source": "user"},
|
||||||
|
)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
|
wf = r.json()
|
||||||
|
assert wf["usage"] == "text2video" and wf["usage_source"] == "user"
|
||||||
|
assert wf["is_enabled"] is False # usage set, outputs still unconfirmed
|
||||||
|
assert wf["needs_mapping"] is True and not wf["output_map"]
|
||||||
|
|
||||||
|
gen = client.post(
|
||||||
|
"/api/playground/generate",
|
||||||
|
json={"workflow_id": wf["id"], "input_values": {"1": "x"}},
|
||||||
|
)
|
||||||
|
assert gen.status_code == 400
|
||||||
|
|
||||||
|
# forcing the switch on is refused with the mapping reason
|
||||||
|
r = client.patch(f"/api/workflows/{wf['id']}", json={"is_enabled": True})
|
||||||
|
assert r.status_code == 400
|
||||||
|
assert "指定" in r.json()["detail"] and "输出节点" in r.json()["detail"]
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 2. Feature-less unknown sinks become mappable candidates (gap 2)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_featureless_unknown_node_is_a_candidate_not_a_hard_error(client):
|
||||||
|
body = _analyze(client, _muffin_workflow())
|
||||||
|
entry = next(o for o in body["usage_evidence"]["outputs"] if o["nodeId"] == "15")
|
||||||
|
assert entry["evidence"] == "unknown_node" and entry["kind"] is None
|
||||||
|
assert body["needs_mapping"] is True
|
||||||
|
codes = {(w["level"], w["code"]) for w in body["warnings"]}
|
||||||
|
assert ("warning", "unknown_output_node") in codes
|
||||||
|
assert ("error", "no_output") not in codes
|
||||||
|
|
||||||
|
|
||||||
|
def test_truly_outputless_graph_still_reports_the_chinese_error(client):
|
||||||
|
wf = {
|
||||||
|
"1": {"class_type": "CLIPTextEncode", "inputs": {"text": "p"}},
|
||||||
|
"2": {"class_type": "VAEDecode", "inputs": {"samples": ["1", 0]}},
|
||||||
|
}
|
||||||
|
body = _analyze(client, wf)
|
||||||
|
assert body["usage"] is None and body["needs_mapping"] is False
|
||||||
|
assert "未在图中找到输出节点" in body["usage_problem"]
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 3. Manual mapping → enable → scoped generation (fake ComfyUI round trip)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_manual_mapping_enables_and_extracts_from_the_mapped_node(client, fake_comfy):
|
||||||
|
fake_comfy.outputs_key = "gifs"
|
||||||
|
fake_comfy.out_name = "clip.mp4"
|
||||||
|
fake_comfy.forced_output_node = "12" # the mapped node reports results
|
||||||
|
with _real_run(client, fake_comfy):
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={
|
||||||
|
"name": "映射·视频库",
|
||||||
|
"workflow_json": _vault_workflow(),
|
||||||
|
"usage": "text2video",
|
||||||
|
"usage_source": "user",
|
||||||
|
"output_map": [{"nodeId": "12", "kind": "video"}],
|
||||||
|
"output_map_source": "user",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
|
wf = r.json()
|
||||||
|
assert wf["is_enabled"] is True
|
||||||
|
assert wf["output_map"] == [{"nodeId": "12", "kind": "video"}]
|
||||||
|
assert wf["output_map_source"] == "user"
|
||||||
|
|
||||||
|
r = client.post(
|
||||||
|
"/api/playground/generate",
|
||||||
|
json={"workflow_id": wf["id"], "input_values": {"1": "星空延时"},
|
||||||
|
"source": "studio-video"},
|
||||||
|
)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
|
job = _wait_done(client, r.json()["job"]["id"])
|
||||||
|
assert job["status"] == "done", job.get("error")
|
||||||
|
assert job["output_paths"][0].endswith(".mp4")
|
||||||
|
|
||||||
|
|
||||||
|
def test_mapped_node_returning_nothing_fails_for_real(client, fake_comfy):
|
||||||
|
"""Results that only land on an unmapped node are NOT a completion."""
|
||||||
|
fake_comfy.forced_output_node = "7" # something else reports results
|
||||||
|
with _real_run(client, fake_comfy):
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={
|
||||||
|
"name": "映射·空手而归",
|
||||||
|
"workflow_json": _muffin_workflow(),
|
||||||
|
"usage": "text2image",
|
||||||
|
"usage_source": "user",
|
||||||
|
"output_map": [{"nodeId": "15", "kind": "image"}],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert r.status_code == 200 and r.json()["is_enabled"] is True
|
||||||
|
r = client.post(
|
||||||
|
"/api/playground/generate",
|
||||||
|
json={"workflow_id": r.json()["id"], "input_values": {"1": "x"}},
|
||||||
|
)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
|
job = _wait_done(client, r.json()["job"]["id"])
|
||||||
|
assert job["status"] == "failed"
|
||||||
|
assert "没有返回任何图片或视频" in job["error"]
|
||||||
|
assert "15" in job["error"] # names the node it waited on
|
||||||
|
assert job["output_paths"] == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_media_type_mismatch_fails_for_real(client, fake_comfy):
|
||||||
|
"""A video mapping that only yields a png is a real failure."""
|
||||||
|
fake_comfy.outputs_key = "images"
|
||||||
|
fake_comfy.out_name = "still.png"
|
||||||
|
fake_comfy.forced_output_node = "12"
|
||||||
|
with _real_run(client, fake_comfy):
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={
|
||||||
|
"name": "映射·类型不符",
|
||||||
|
"workflow_json": _vault_workflow(),
|
||||||
|
"usage": "text2video",
|
||||||
|
"usage_source": "user",
|
||||||
|
"output_map": [{"nodeId": "12", "kind": "video"}],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
wid = r.json()["id"]
|
||||||
|
r = client.post(
|
||||||
|
"/api/playground/generate",
|
||||||
|
json={"workflow_id": wid, "input_values": {"1": "x"}},
|
||||||
|
)
|
||||||
|
job = _wait_done(client, r.json()["job"]["id"])
|
||||||
|
assert job["status"] == "failed"
|
||||||
|
assert "媒体类型与映射不符" in job["error"]
|
||||||
|
assert job["output_paths"] == []
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 4. Bad / cancelled mappings
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_invalid_mappings_are_rejected_in_chinese(client):
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "坏映射", "workflow_json": _vault_workflow(),
|
||||||
|
"usage": "text2video",
|
||||||
|
"output_map": [{"nodeId": "999", "kind": "video"}]},
|
||||||
|
)
|
||||||
|
assert r.status_code == 422 and "不存在" in r.json()["detail"]
|
||||||
|
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "坏映射2", "workflow_json": _vault_workflow(),
|
||||||
|
"usage": "text2video",
|
||||||
|
"output_map": [{"nodeId": "12", "kind": "audio"}]},
|
||||||
|
)
|
||||||
|
assert r.status_code == 422 and "媒体类型" in r.json()["detail"]
|
||||||
|
|
||||||
|
# a prompt/parameter node can never be an output
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "坏映射3", "workflow_json": _vault_workflow(),
|
||||||
|
"usage": "text2video",
|
||||||
|
"output_map": [{"nodeId": "1", "kind": "video"}]},
|
||||||
|
)
|
||||||
|
assert r.status_code == 422 and "不能作为输出节点" in r.json()["detail"]
|
||||||
|
|
||||||
|
wid = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "先好后坏", "workflow_json": _vault_workflow(),
|
||||||
|
"usage": "text2video",
|
||||||
|
"output_map": [{"nodeId": "12", "kind": "video"}]},
|
||||||
|
).json()["id"]
|
||||||
|
r = client.patch(
|
||||||
|
f"/api/workflows/{wid}", json={"output_map": [{"nodeId": "42", "kind": "image"}]}
|
||||||
|
)
|
||||||
|
assert r.status_code == 422 and "不存在" in r.json()["detail"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_clearing_the_mapping_resets_to_pending(client):
|
||||||
|
wid = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "映射后清空", "workflow_json": _vault_workflow(),
|
||||||
|
"usage": "text2video",
|
||||||
|
"output_map": [{"nodeId": "12", "kind": "video"}]},
|
||||||
|
).json()["id"]
|
||||||
|
wf = client.get(f"/api/workflows/{wid}").json()
|
||||||
|
assert wf["is_enabled"] is True
|
||||||
|
|
||||||
|
r = client.patch(f"/api/workflows/{wid}", json={"output_map": []})
|
||||||
|
assert r.status_code == 200
|
||||||
|
wf = r.json()
|
||||||
|
assert wf["is_enabled"] is False and not wf["output_map"]
|
||||||
|
assert wf["usage"] == "text2video" # the usage decision survives
|
||||||
|
gen = client.post(
|
||||||
|
"/api/playground/generate",
|
||||||
|
json={"workflow_id": wid, "input_values": {"1": "x"}},
|
||||||
|
)
|
||||||
|
assert gen.status_code == 400
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 5. Saved mappings survive reanalyze / field edits / migration
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_saved_mapping_survives_reanalyze_and_field_edits(client):
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "重分析·保映射", "workflow_json": _vault_workflow(),
|
||||||
|
"usage": "text2video",
|
||||||
|
"output_map": [{"nodeId": "12", "kind": "video"}]},
|
||||||
|
)
|
||||||
|
wid = r.json()["id"]
|
||||||
|
|
||||||
|
r = client.patch(f"/api/workflows/{wid}", json={"name": "改名不影响映射",
|
||||||
|
"description": "编辑其他字段"})
|
||||||
|
wf = r.json()
|
||||||
|
assert wf["output_map"] == [{"nodeId": "12", "kind": "video"}]
|
||||||
|
assert wf["output_map_source"] == "user" and wf["is_enabled"] is True
|
||||||
|
|
||||||
|
r = client.post(f"/api/workflows/{wid}/reanalyze")
|
||||||
|
assert r.status_code == 200
|
||||||
|
wf = r.json()
|
||||||
|
assert wf["output_map"] == [{"nodeId": "12", "kind": "video"}]
|
||||||
|
assert wf["output_map_source"] == "user"
|
||||||
|
assert wf["usage"] == "text2video" and wf["usage_source"] == "user"
|
||||||
|
assert wf["is_enabled"] is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_sql_forced_enabled_row_without_mapping_is_blocked(client):
|
||||||
|
"""Backend-direct generation on an unconfirmed row is refused."""
|
||||||
|
wid = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "强开", "workflow_json": _vault_workflow(),
|
||||||
|
"usage": "text2video"},
|
||||||
|
).json()["id"]
|
||||||
|
conn = get_db(settings.db_path)
|
||||||
|
try:
|
||||||
|
conn.execute("UPDATE workflows SET is_enabled = 1 WHERE id = ?", (wid,))
|
||||||
|
conn.commit()
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
gen = client.post(
|
||||||
|
"/api/playground/generate",
|
||||||
|
json={"workflow_id": wid, "input_values": {"1": "x"}},
|
||||||
|
)
|
||||||
|
assert gen.status_code == 400
|
||||||
|
assert "输出节点" in gen.json()["detail"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_migration_parks_unknown_output_rows_and_keeps_trusted_ones(client):
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
conn = get_db(settings.db_path)
|
||||||
|
try:
|
||||||
|
# Pre-HEL-638 shape: user confirmed a usage on an unknown-output
|
||||||
|
# graph and the old PATCH re-enabled it.
|
||||||
|
conn.execute(
|
||||||
|
"INSERT INTO workflows (name, kind, workflow_json, input_schema,"
|
||||||
|
" output_schema, is_enabled, usage, usage_source)"
|
||||||
|
" VALUES (?, 'video', ?, '[]', '[]', 1, 'text2video', 'user')",
|
||||||
|
("存量·未知输出", json.dumps(_vault_workflow())),
|
||||||
|
)
|
||||||
|
conn.commit()
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
asyncio.run(migrate_db(settings.db_path)) # idempotent re-run
|
||||||
|
|
||||||
|
wfs = {w["name"]: w for w in client.get("/api/workflows").json()}
|
||||||
|
parked = wfs["存量·未知输出"]
|
||||||
|
assert parked["is_enabled"] is False
|
||||||
|
assert parked["usage"] == "text2video" # decision preserved
|
||||||
|
assert not parked["output_map"] and parked["needs_mapping"] is True
|
||||||
|
|
||||||
|
# A trusted five-type import keeps working untouched.
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "存量·可信", "kind": "image",
|
||||||
|
"workflow_json": json.loads(
|
||||||
|
(FIXTURES / "qwen_image_t2i_API.json").read_text(encoding="utf-8")
|
||||||
|
)},
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
trusted = next(w for w in client.get("/api/workflows").json() if w["id"] == r.json()["id"])
|
||||||
|
assert trusted["is_enabled"] is True
|
||||||
|
assert trusted["output_map_source"] == "auto"
|
||||||
|
assert any(e["nodeId"] == "60" and e["kind"] == "image" for e in trusted["output_map"])
|
||||||
@@ -0,0 +1,308 @@
|
|||||||
|
"""HEL-636 A1–A6: the five-usage classifier judges from graph evidence only.
|
||||||
|
|
||||||
|
Every case feeds real (or minimally mutated) ComfyUI API exports — never a
|
||||||
|
file name, model name or fixed node id — and asserts the usage, the media
|
||||||
|
slots it implies, and the failure paths for ambiguous / unknown graphs.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from calliope.comfyui.lint import blocking_problem, workflow_warnings
|
||||||
|
from calliope.comfyui.parser import (
|
||||||
|
classify_usage,
|
||||||
|
detect_untagged_inputs,
|
||||||
|
parse_dynamic_inputs,
|
||||||
|
parse_dynamic_outputs,
|
||||||
|
)
|
||||||
|
from calliope.comfyui.patcher import patch_workflow
|
||||||
|
|
||||||
|
FIXTURES = Path(__file__).parent / "fixtures" / "comfy_native"
|
||||||
|
EXAMPLES = Path(__file__).resolve().parents[2] / "example_ComfyUI_workflows"
|
||||||
|
|
||||||
|
|
||||||
|
def _load(path: Path) -> dict:
|
||||||
|
return json.loads(path.read_text(encoding="utf-8"))
|
||||||
|
|
||||||
|
|
||||||
|
def _rename_everything(wf: dict, id_shift: int = 7) -> dict:
|
||||||
|
"""Change every node id, title and widget value the classifier must not
|
||||||
|
depend on (model file names / prompt texts)."""
|
||||||
|
def new_id(nid: str) -> str:
|
||||||
|
return f"x{int(nid) * id_shift + 3}" if nid.isdigit() else "x" + nid.replace(":", "_")
|
||||||
|
|
||||||
|
out: dict = {}
|
||||||
|
for nid, node in wf.items():
|
||||||
|
out[new_id(nid)] = json.loads(json.dumps(node))
|
||||||
|
for node in out.values():
|
||||||
|
for val in (node.get("inputs") or {}).values():
|
||||||
|
if isinstance(val, list) and len(val) == 2 and str(val[0]).isdigit():
|
||||||
|
val[0] = new_id(str(val[0]))
|
||||||
|
if node.get("_meta", {}).get("title"):
|
||||||
|
node["_meta"]["title"] = f"改·{node['_meta']['title']}"
|
||||||
|
for key, val in list((node.get("inputs") or {}).items()):
|
||||||
|
if isinstance(val, str) and val.endswith((".safetensors", ".gguf")):
|
||||||
|
node["inputs"][key] = "另一个模型_" + val
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def _media(inputs: list[dict]) -> list[dict]:
|
||||||
|
return [
|
||||||
|
i
|
||||||
|
for i in inputs
|
||||||
|
if i["kind"] in ("image", "image_list", "video", "audio")
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# A1 / A2 / A3: the three real shapes, plus id/title/model renames
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_a1_native_t2i_is_text2image_and_form_has_no_image_slot():
|
||||||
|
wf = _load(FIXTURES / "qwen_image_t2i_API.json")
|
||||||
|
c = classify_usage(wf)
|
||||||
|
assert c["usage"] == "text2image"
|
||||||
|
assert c["ambiguous"] is False and c["needs_mapping"] is False
|
||||||
|
assert _media(parse_dynamic_inputs(wf)) == []
|
||||||
|
outs = parse_dynamic_outputs(wf)
|
||||||
|
assert [(o["nodeId"], o["kind"]) for o in outs] == [("60", "image")]
|
||||||
|
|
||||||
|
|
||||||
|
def test_a2_qwen_edit_variant_with_new_ids_titles_and_model_stays_image2image():
|
||||||
|
wf = _rename_everything(_load(FIXTURES / "qwen_image_edit_mask_API.json"))
|
||||||
|
c = classify_usage(wf)
|
||||||
|
assert c["usage"] == "image2image"
|
||||||
|
inputs = parse_dynamic_inputs(wf)
|
||||||
|
img = [i for i in _media(inputs) if i.get("role") == "image"]
|
||||||
|
assert len(img) == 1 and img[0]["required"] is True
|
||||||
|
mask = [i for i in _media(inputs) if i.get("role") == "mask"]
|
||||||
|
assert len(mask) == 1 # mask never counts as an input image
|
||||||
|
|
||||||
|
|
||||||
|
def test_a3_i2v_variant_renamed_still_image2video_first_frame_only():
|
||||||
|
wf = _rename_everything(_load(FIXTURES / "h3_i2v_04_API.json"))
|
||||||
|
c = classify_usage(wf)
|
||||||
|
assert c["usage"] == "image2video"
|
||||||
|
media = _media(parse_dynamic_inputs(wf))
|
||||||
|
assert [i.get("role") for i in media] == ["first_frame"]
|
||||||
|
# A3: no first/last pair → the pair validation must not fire
|
||||||
|
assert blocking_problem(wf) is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_a4_ref2va_variant_with_renamed_class_and_prefix_still_groups():
|
||||||
|
wf = _rename_everything(_load(FIXTURES / "h3_ref2va_05_API.json"))
|
||||||
|
for node in wf.values():
|
||||||
|
if node.get("class_type") == "MiniMaxH3ReferenceToVideo":
|
||||||
|
node["class_type"] = "MyFancyRefToVideo"
|
||||||
|
inputs = node["inputs"]
|
||||||
|
for k in list(inputs):
|
||||||
|
if k.startswith("ref_images.ref_image_"):
|
||||||
|
inputs[k.replace("ref_images.ref_image_", "refs.pic_")] = inputs.pop(k)
|
||||||
|
c = classify_usage(wf)
|
||||||
|
assert c["usage"] == "ref2video"
|
||||||
|
groups = [i for i in detect_untagged_inputs(wf) if i["kind"] == "image_list"]
|
||||||
|
assert len(groups) == 1
|
||||||
|
g = groups[0]
|
||||||
|
assert g["role"] == "reference_image" and (g["min"], g["max"]) == (1, 9)
|
||||||
|
# patch rewires the renamed group in order and refuses a 10th image
|
||||||
|
key = g["nodeId"]
|
||||||
|
node_id = key.split("@")[0]
|
||||||
|
patched = patch_workflow(wf, {key: [f"/u/{i}.png" for i in range(4)]})
|
||||||
|
names = sorted(
|
||||||
|
(k for k in patched[node_id]["inputs"] if k.startswith("refs.pic_")),
|
||||||
|
key=lambda k: int(k.rsplit("_", 1)[-1]) if k.rsplit("_", 1)[-1].isdigit() else int(k[-1]),
|
||||||
|
)
|
||||||
|
assert names == [f"refs.pic_{i}" for i in range(4)]
|
||||||
|
from calliope.comfyui.validate import validate_input_values
|
||||||
|
|
||||||
|
_c, errs = validate_input_values(
|
||||||
|
detect_untagged_inputs(wf), {key: [f"/u/{i}.png" for i in range(10)]}
|
||||||
|
)
|
||||||
|
assert any("最多 9 张" in e for e in errs)
|
||||||
|
|
||||||
|
|
||||||
|
def test_qwen_single_numbered_encoder_input_is_not_mistaken_for_a_group():
|
||||||
|
"""TextEncodeQwenImage21's ``images.image_1`` stays an ordinary input slot."""
|
||||||
|
inputs = parse_dynamic_inputs(_load(FIXTURES / "qwen21_edit_sage_API.json"))
|
||||||
|
assert not any(i["kind"] == "image_list" for i in inputs)
|
||||||
|
assert any(i.get("role") == "image" for i in inputs)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Judgment table rows from the real example library
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_all_real_exports_classify():
|
||||||
|
expect = {
|
||||||
|
"qwen_image_t2i_API.json": "text2image",
|
||||||
|
"qwen_image_edit_mask_API.json": "image2image",
|
||||||
|
"qwen21_edit_sage_API.json": "image2image",
|
||||||
|
"h3_i2v_04_API.json": "image2video",
|
||||||
|
"h3_ref2va_05_API.json": "ref2video",
|
||||||
|
"minimax_h3_t2v_untagged_API.json": "text2video",
|
||||||
|
"wen_sheng_tu_API.json": "text2image",
|
||||||
|
"wen_sheng_shipin_API.json": "text2video",
|
||||||
|
}
|
||||||
|
for name, usage in expect.items():
|
||||||
|
assert classify_usage(_load(FIXTURES / name))["usage"] == usage, name
|
||||||
|
examples = {
|
||||||
|
"Krea2_t2i_20260818_API.json": "text2image",
|
||||||
|
"krea2_T2I_CharSheetV1_API.json": "text2image",
|
||||||
|
"minimax_h3-Turbo_Text2Video_20260813_API.json": "text2video",
|
||||||
|
"minimax_h3-Turbo_Image2Video_20260813_API.json": "text2video",
|
||||||
|
"MiniMax-H3-Turbo-R2V-Extend-2Refs1Vid_API.json": "ref2video",
|
||||||
|
"video_minimax_h3_r2v_2ref_API.json": "ref2video",
|
||||||
|
"video_minimax_h3_r2v_3ref_API.json": "ref2video",
|
||||||
|
"video_minimax_h3_r2v_4ref_API.json": "ref2video",
|
||||||
|
"video_minimax_h3_r2v_5ref_API.json": "ref2video",
|
||||||
|
}
|
||||||
|
for name, usage in examples.items():
|
||||||
|
assert classify_usage(_load(EXAMPLES / name))["usage"] == usage, name
|
||||||
|
|
||||||
|
|
||||||
|
def test_r2v_extend_reports_its_video_input_slot():
|
||||||
|
wf = _load(EXAMPLES / "MiniMax-H3-Turbo-R2V-Extend-2Refs1Vid_API.json")
|
||||||
|
c = classify_usage(wf)
|
||||||
|
assert c["usage"] == "ref2video"
|
||||||
|
assert c["evidence"]["video_slots"], "the reference-video slot must be reported"
|
||||||
|
assert any("视频输入槽" in line for line in c["evidence"]["summary"])
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# A5: ambiguity — single loose image into a video graph; multi-output graph
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def _load_image(nid: str) -> dict:
|
||||||
|
return {
|
||||||
|
"class_type": "LoadImage",
|
||||||
|
"inputs": {"image": "x.png"},
|
||||||
|
"_meta": {"title": f"图 {nid}"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_single_loose_image_with_video_output_is_ambiguous():
|
||||||
|
wf = {
|
||||||
|
"1": {"class_type": "PrimitiveStringMultiline", "inputs": {"value": "p"}},
|
||||||
|
"5": {"class_type": "LoadImage", "inputs": {"image": "x.png"}},
|
||||||
|
"7": {
|
||||||
|
"class_type": "SomeVideoSampler",
|
||||||
|
"inputs": {"prompt": ["1", 0], "image": ["5", 0]},
|
||||||
|
},
|
||||||
|
"9": {"class_type": "SaveVideo", "inputs": {"images": ["7", 0]}},
|
||||||
|
}
|
||||||
|
c = classify_usage(wf)
|
||||||
|
assert c["usage"] is None and c["ambiguous"] is True
|
||||||
|
assert "首帧还是参考图" in c["problem"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_first_frame_role_decides_image2video_without_ambiguity():
|
||||||
|
wf = {
|
||||||
|
"1": {"class_type": "PrimitiveStringMultiline", "inputs": {"value": "p"}},
|
||||||
|
"5": {"class_type": "LoadImage", "inputs": {"image": "x.png"}},
|
||||||
|
"7": {
|
||||||
|
"class_type": "SomeVideoSampler",
|
||||||
|
"inputs": {"prompt": ["1", 0], "first_frame": ["5", 0]},
|
||||||
|
},
|
||||||
|
"9": {"class_type": "SaveVideo", "inputs": {"images": ["7", 0]}},
|
||||||
|
}
|
||||||
|
assert classify_usage(wf)["usage"] == "image2video"
|
||||||
|
|
||||||
|
|
||||||
|
def test_same_graph_both_image_and_video_outputs_is_ambiguous():
|
||||||
|
wf = {
|
||||||
|
"1": {"class_type": "PrimitiveStringMultiline", "inputs": {"value": "p"}},
|
||||||
|
"5": {"class_type": "LoadImage", "inputs": {"image": "x.png"}},
|
||||||
|
"7": {
|
||||||
|
"class_type": "SomeVideoSampler",
|
||||||
|
"inputs": {"prompt": ["1", 0], "image": ["5", 0]},
|
||||||
|
},
|
||||||
|
"9": {"class_type": "SaveVideo", "inputs": {"images": ["7", 0]}},
|
||||||
|
"10": {"class_type": "SaveImage", "inputs": {"images": ["7", 1]}},
|
||||||
|
}
|
||||||
|
c = classify_usage(wf)
|
||||||
|
assert c["usage"] is None and c["ambiguous"] is True
|
||||||
|
assert "同时输出图片和视频" in c["problem"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_two_reference_images_into_a_custom_node_become_a_group_ref2video():
|
||||||
|
wf = {
|
||||||
|
"1": {"class_type": "PrimitiveStringMultiline", "inputs": {"value": "p"}},
|
||||||
|
"5": {"class_type": "LoadImage", "inputs": {"image": "a.png"}},
|
||||||
|
"6": {"class_type": "LoadImage", "inputs": {"image": "b.png"}},
|
||||||
|
"7": {
|
||||||
|
"class_type": "GenericRefToVideo",
|
||||||
|
"inputs": {
|
||||||
|
"prompt": ["1", 0],
|
||||||
|
"refs.pic_1": ["5", 0],
|
||||||
|
"refs.pic_2": ["6", 0],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"9": {"class_type": "SaveVideo", "inputs": {"images": ["7", 0]}},
|
||||||
|
}
|
||||||
|
c = classify_usage(wf)
|
||||||
|
assert c["usage"] == "ref2video"
|
||||||
|
groups = [i for i in detect_untagged_inputs(wf) if i["kind"] == "image_list"]
|
||||||
|
assert [g["nodeId"] for g in groups] == ["7@refs"]
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# A6: failure paths — no output, unknown custom output nodes
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_output_graph_reports_chinese_error_and_blocks():
|
||||||
|
wf = {
|
||||||
|
"1": {"class_type": "CLIPTextEncode", "inputs": {"text": "p"}},
|
||||||
|
"2": {"class_type": "VAEDecode", "inputs": {"samples": ["1", 0]}},
|
||||||
|
}
|
||||||
|
c = classify_usage(wf)
|
||||||
|
assert c["usage"] is None and c["ambiguous"] is False
|
||||||
|
assert "未在图中找到输出节点" in c["problem"]
|
||||||
|
assert blocking_problem(wf) and "未在图中找到输出节点" in blocking_problem(wf)
|
||||||
|
|
||||||
|
|
||||||
|
def test_unknown_custom_save_node_needs_mapping_and_keeps_a_runnable_path():
|
||||||
|
wf = {
|
||||||
|
"1": {"class_type": "PrimitiveStringMultiline", "inputs": {"value": "p"}},
|
||||||
|
"7": {
|
||||||
|
"class_type": "MyCloudExporter",
|
||||||
|
"inputs": {"filename_prefix": "out", "render": ["8", 0]},
|
||||||
|
},
|
||||||
|
"8": {"class_type": "VAEDecode", "inputs": {"samples": ["1", 0]}},
|
||||||
|
}
|
||||||
|
c = classify_usage(wf)
|
||||||
|
assert c["needs_mapping"] is True
|
||||||
|
assert c["usage"] is None and "无法识别" in (c["problem"] or "")
|
||||||
|
# unknown savers are a warning (user maps them at import), not a block —
|
||||||
|
# once the user confirms the usage the job can still run and results are
|
||||||
|
# pulled from ComfyUI history's images/gifs/videos keys.
|
||||||
|
codes = {(w["level"], w["code"]) for w in workflow_warnings(wf)}
|
||||||
|
assert ("warning", "unknown_output_node") in codes
|
||||||
|
assert ("error", "no_output") not in codes
|
||||||
|
|
||||||
|
|
||||||
|
def test_utility_sink_tail_is_not_an_output_and_does_not_break_detection():
|
||||||
|
"""VideoCombine feeding a cache-cleanup tail still counts as the output."""
|
||||||
|
wf = _load(FIXTURES / "minimax_h3_t2v_untagged_API.json")
|
||||||
|
wf["9999"] = {
|
||||||
|
"class_type": "easy cleanGpuUsed",
|
||||||
|
"inputs": {"anything": ["5978", 0]},
|
||||||
|
}
|
||||||
|
c = classify_usage(wf)
|
||||||
|
assert c["usage"] == "text2video"
|
||||||
|
assert c["needs_mapping"] is False
|
||||||
|
assert workflow_warnings(wf) == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_evidence_lists_output_nodes_and_slots():
|
||||||
|
wf = _load(FIXTURES / "h3_ref2va_05_API.json")
|
||||||
|
c = classify_usage(wf)
|
||||||
|
ev = c["evidence"]
|
||||||
|
assert any(o["nodeId"] == "92" and o["kind"] == "video" for o in ev["outputs"])
|
||||||
|
assert any(s["kind"] == "image_list" for s in ev["image_slots"])
|
||||||
|
assert any("输出" in line for line in ev["summary"])
|
||||||
@@ -26,6 +26,15 @@ VIDEO_WORKFLOW = {
|
|||||||
"inputs": {"file": ""},
|
"inputs": {"file": ""},
|
||||||
"_meta": {"title": "Previous Clip (Input:video)"},
|
"_meta": {"title": "Previous Clip (Input:video)"},
|
||||||
},
|
},
|
||||||
|
"30": {
|
||||||
|
"class_type": "VHS_VideoCombine",
|
||||||
|
"inputs": {"images": ["40", 0]},
|
||||||
|
"_meta": {"title": "Video Output (Output:video)"},
|
||||||
|
},
|
||||||
|
"40": {
|
||||||
|
"class_type": "VAEDecode",
|
||||||
|
"inputs": {"samples": ["10", 0]},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
# Same but the video slot is missing entirely — must be rejected at enqueue.
|
# Same but the video slot is missing entirely — must be rejected at enqueue.
|
||||||
@@ -35,6 +44,15 @@ NO_VIDEO_WORKFLOW = {
|
|||||||
"inputs": {"text": ""},
|
"inputs": {"text": ""},
|
||||||
"_meta": {"title": "Main Prompt (Input:prompt)"},
|
"_meta": {"title": "Main Prompt (Input:prompt)"},
|
||||||
},
|
},
|
||||||
|
"30": {
|
||||||
|
"class_type": "VHS_VideoCombine",
|
||||||
|
"inputs": {"images": ["40", 0]},
|
||||||
|
"_meta": {"title": "Video Output (Output:video)"},
|
||||||
|
},
|
||||||
|
"40": {
|
||||||
|
"class_type": "VAEDecode",
|
||||||
|
"inputs": {"samples": ["10", 0]},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -250,12 +268,14 @@ def _scene_ids(pid: int) -> list[int]:
|
|||||||
|
|
||||||
|
|
||||||
async def _fake_history(_client, _prompt_id, *_args):
|
async def _fake_history(_client, _prompt_id, *_args):
|
||||||
"""A successful ComfyUI history with one video output named out.mp4.
|
"""A successful ComfyUI history with one video output named out.mp4,
|
||||||
Extra positional args (job_id) are accepted for the cancel-check wiring."""
|
reported under the workflow's real output node (30 = the tagged
|
||||||
|
VHS_VideoCombine). Extra positional args (job_id) are accepted for the
|
||||||
|
cancel-check wiring."""
|
||||||
return {
|
return {
|
||||||
"status": {"status_str": "success", "completed": True},
|
"status": {"status_str": "success", "completed": True},
|
||||||
"outputs": {
|
"outputs": {
|
||||||
"99": {"videos": [{"filename": "out.mp4", "subfolder": "", "type": "output"}]}
|
"30": {"videos": [{"filename": "out.mp4", "subfolder": "", "type": "output"}]}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,7 +289,11 @@ def _stub_comfy(monkeypatch, captured: dict) -> list[str]:
|
|||||||
prepare_media_inputs handed it; download_image writes out.mp4. Returns
|
prepare_media_inputs handed it; download_image writes out.mp4. Returns
|
||||||
the list that collects uploaded local paths.
|
the list that collects uploaded local paths.
|
||||||
"""
|
"""
|
||||||
queue_manager.paused = True
|
# monkeypatch (not bare assignment): queue_manager is a process-level
|
||||||
|
# singleton — a bare `paused = True` leaks into every later test and
|
||||||
|
# stalls e.g. test_workbench's worker (HEL-619). monkeypatch restores
|
||||||
|
# the previous value at teardown.
|
||||||
|
monkeypatch.setattr(queue_manager, "paused", True)
|
||||||
uploads: list[str] = []
|
uploads: list[str] = []
|
||||||
|
|
||||||
async def fake_upload_video(self, path, subfolder="calliope"):
|
async def fake_upload_video(self, path, subfolder="calliope"):
|
||||||
|
|||||||
@@ -0,0 +1,235 @@
|
|||||||
|
"""HEL-636: the two-step import closes the loop — analyze → confirm → save,
|
||||||
|
user corrections stick (reanalyze never overwrites them), pending workflows
|
||||||
|
cannot generate, and legacy rows migrate losslessly."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from calliope.config import settings
|
||||||
|
from calliope.db import get_db, migrate_db
|
||||||
|
|
||||||
|
FIXTURES = Path(__file__).parent / "fixtures" / "comfy_native"
|
||||||
|
|
||||||
|
|
||||||
|
def _load(name: str) -> dict:
|
||||||
|
return json.loads((FIXTURES / name).read_text(encoding="utf-8"))
|
||||||
|
|
||||||
|
|
||||||
|
AMBIGUOUS = {
|
||||||
|
"1": {"class_type": "PrimitiveStringMultiline", "inputs": {"value": "p"}},
|
||||||
|
"5": {"class_type": "LoadImage", "inputs": {"image": "x.png"}},
|
||||||
|
"7": {
|
||||||
|
"class_type": "SomeVideoSampler",
|
||||||
|
"inputs": {"prompt": ["1", 0], "image": ["5", 0]},
|
||||||
|
},
|
||||||
|
"9": {"class_type": "SaveVideo", "inputs": {"images": ["7", 0]}},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_analyze_returns_usage_evidence_and_problem(client):
|
||||||
|
wf = _load("qwen_image_t2i_API.json")
|
||||||
|
r = client.post("/api/workflows/analyze", json={"workflow_json": wf})
|
||||||
|
assert r.status_code == 200
|
||||||
|
body = r.json()
|
||||||
|
assert body["usage"] == "text2image"
|
||||||
|
assert body["usage_ambiguous"] is False and body["needs_mapping"] is False
|
||||||
|
assert any(o["kind"] == "image" for o in body["usage_evidence"]["outputs"])
|
||||||
|
assert body["usable_usage"] == [
|
||||||
|
"text2image", "image2image", "text2video", "image2video", "ref2video",
|
||||||
|
]
|
||||||
|
|
||||||
|
r = client.post("/api/workflows/analyze", json={"workflow_json": AMBIGUOUS})
|
||||||
|
body = r.json()
|
||||||
|
assert body["usage"] is None and body["usage_ambiguous"] is True
|
||||||
|
assert "首帧还是参考图" in body["usage_problem"]
|
||||||
|
assert body["usage_evidence"]["image_slots"][0]["nodeId"] == "5"
|
||||||
|
|
||||||
|
bare = {"1": {"class_type": "Note", "inputs": {}}}
|
||||||
|
r = client.post("/api/workflows/analyze", json={"workflow_json": bare})
|
||||||
|
body = r.json()
|
||||||
|
assert "未在图中找到输出节点" in body["usage_problem"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_stores_auto_usage_and_kind(client):
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "自动·文生图", "workflow_json": _load("qwen_image_t2i_API.json")},
|
||||||
|
)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
|
wf = r.json()
|
||||||
|
assert wf["usage"] == "text2image" and wf["usage_source"] == "auto"
|
||||||
|
assert wf["kind"] == "image" and wf["is_enabled"] is True
|
||||||
|
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "自动·参考生视频", "workflow_json": _load("h3_ref2va_05_API.json")},
|
||||||
|
)
|
||||||
|
wf = r.json()
|
||||||
|
assert wf["usage"] == "ref2video" and wf["kind"] == "video"
|
||||||
|
|
||||||
|
|
||||||
|
def test_ambiguous_import_stays_pending_and_cannot_generate(client):
|
||||||
|
r = client.post("/api/workflows", json={"name": "歧义", "workflow_json": AMBIGUOUS})
|
||||||
|
assert r.status_code == 200
|
||||||
|
wf = r.json()
|
||||||
|
assert wf["usage"] is None and wf["is_enabled"] is False
|
||||||
|
|
||||||
|
gen = client.post(
|
||||||
|
"/api/playground/generate",
|
||||||
|
json={"workflow_id": wf["id"], "input_values": {"1": "x"}},
|
||||||
|
)
|
||||||
|
assert gen.status_code == 400
|
||||||
|
assert "已停用" in gen.json()["detail"]
|
||||||
|
assert client.get("/api/playground/jobs").json() == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_confirm_page_correction_roundtrip(client):
|
||||||
|
"""analyze → user picks usage + fixes the slot role → create carries both."""
|
||||||
|
analyzed = client.post("/api/workflows/analyze", json={"workflow_json": AMBIGUOUS}).json()
|
||||||
|
assert analyzed["usage"] is None
|
||||||
|
|
||||||
|
slot = analyzed["usage_evidence"]["image_slots"][0]
|
||||||
|
schema = [
|
||||||
|
{**i, "role": "first_frame", "manual": True} if i["nodeId"] == slot["nodeId"] else i
|
||||||
|
for i in analyzed["inputs"]
|
||||||
|
]
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={
|
||||||
|
"name": "确认·图生视频",
|
||||||
|
"workflow_json": AMBIGUOUS,
|
||||||
|
"usage": "image2video",
|
||||||
|
"usage_source": "user",
|
||||||
|
"input_schema": schema,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
|
wf = r.json()
|
||||||
|
assert wf["usage"] == "image2video" and wf["usage_source"] == "user"
|
||||||
|
assert wf["kind"] == "video" and wf["is_enabled"] is True
|
||||||
|
# the manual role sticks on read (and through re-derivation)
|
||||||
|
entry = next(i for i in wf["input_schema"] if i["nodeId"] == slot["nodeId"])
|
||||||
|
assert entry["role"] == "first_frame"
|
||||||
|
|
||||||
|
# reanalyze refreshes the auto schema but never the user's usage
|
||||||
|
r = client.post(f"/api/workflows/{wf['id']}/reanalyze")
|
||||||
|
assert r.status_code == 200
|
||||||
|
fresh = r.json()
|
||||||
|
assert fresh["usage"] == "image2video" and fresh["usage_source"] == "user"
|
||||||
|
entry = next(i for i in fresh["input_schema"] if i["nodeId"] == slot["nodeId"])
|
||||||
|
assert entry["role"] == "first_frame" and entry.get("manual") is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_patch_usage_confirms_pending_workflow(client):
|
||||||
|
r = client.post("/api/workflows", json={"name": "待确认", "workflow_json": AMBIGUOUS})
|
||||||
|
wid = r.json()["id"]
|
||||||
|
assert r.json()["is_enabled"] is False
|
||||||
|
|
||||||
|
r = client.patch(f"/api/workflows/{wid}", json={"usage": "ref2video"})
|
||||||
|
assert r.status_code == 200
|
||||||
|
wf = r.json()
|
||||||
|
assert wf["usage"] == "ref2video" and wf["usage_source"] == "user"
|
||||||
|
assert wf["kind"] == "video" and wf["is_enabled"] is True
|
||||||
|
|
||||||
|
listed = next(w for w in client.get("/api/workflows").json() if w["id"] == wid)
|
||||||
|
assert listed["usage"] == "ref2video"
|
||||||
|
|
||||||
|
|
||||||
|
def test_reanalyze_upgrades_auto_usage_only(client):
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "重分析", "workflow_json": _load("qwen_image_t2i_API.json")},
|
||||||
|
)
|
||||||
|
wid = r.json()["id"]
|
||||||
|
r = client.patch(f"/api/workflows/{wid}", json={"usage": "image2image", "usage_source": "user"})
|
||||||
|
assert r.json()["usage"] == "image2image"
|
||||||
|
|
||||||
|
r = client.post(f"/api/workflows/{wid}/reanalyze")
|
||||||
|
assert r.json()["usage"] == "image2image" # user decision survives
|
||||||
|
assert r.json()["usage_source"] == "user"
|
||||||
|
|
||||||
|
|
||||||
|
def test_legacy_kind_only_callers_still_work(client):
|
||||||
|
"""Old clients post kind without usage — determinate graphs classify, the
|
||||||
|
row is enabled and generation proceeds as before."""
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows",
|
||||||
|
json={"name": "旧调用", "kind": "image", "workflow_json": _load("qwen_image_t2i_API.json")},
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
wf = r.json()
|
||||||
|
assert wf["usage"] == "text2image" and wf["is_enabled"] is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_migration_backfills_usage_and_keeps_history(client):
|
||||||
|
"""A8: pre-HEL-636 rows (direct SQL, no usage) settle on re-migration;
|
||||||
|
determinate ones gain usage, ambiguous ones are parked disabled, and
|
||||||
|
existing jobs/history stay readable with their original kind."""
|
||||||
|
pid = client.post("/api/projects", json={"title": "存量项目", "idea": "x"}).json()["id"]
|
||||||
|
conn = get_db(settings.db_path)
|
||||||
|
try:
|
||||||
|
conn.execute(
|
||||||
|
"INSERT INTO workflows (name, kind, workflow_json, input_schema,"
|
||||||
|
" output_schema, is_enabled) VALUES (?, 'image', ?, '[]', '[]', 1)",
|
||||||
|
("存量·文生图", json.dumps(_load("qwen_image_t2i_API.json"))),
|
||||||
|
)
|
||||||
|
conn.execute(
|
||||||
|
"INSERT INTO workflows (name, kind, workflow_json, input_schema,"
|
||||||
|
" output_schema, is_enabled) VALUES (?, 'video', ?, '[]', '[]', 1)",
|
||||||
|
("存量·歧义", json.dumps(AMBIGUOUS)),
|
||||||
|
)
|
||||||
|
conn.execute(
|
||||||
|
"INSERT INTO jobs (project_id, kind, workflow_id, status, payload_json,"
|
||||||
|
" output_paths_json) VALUES (?, 'image', NULL, 'done', '{}', ?)",
|
||||||
|
(pid, json.dumps(["/old/result.png"])),
|
||||||
|
)
|
||||||
|
conn.commit()
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
asyncio.run(migrate_db(settings.db_path)) # idempotent re-run
|
||||||
|
|
||||||
|
wfs = {w["name"]: w for w in client.get("/api/workflows").json()}
|
||||||
|
assert wfs["存量·文生图"]["usage"] == "text2image"
|
||||||
|
assert wfs["存量·文生图"]["is_enabled"] is True
|
||||||
|
assert wfs["存量·歧义"]["usage"] is None
|
||||||
|
assert wfs["存量·歧义"]["is_enabled"] is False
|
||||||
|
assert wfs["存量·歧义"]["kind"] == "video" # old kind semantics untouched
|
||||||
|
|
||||||
|
jobs = client.get(f"/api/jobs?project_id={pid}").json()
|
||||||
|
assert any(
|
||||||
|
j["status"] == "done" and j["kind"] == "image" and j["output_paths"] == ["/old/result.png"]
|
||||||
|
for j in jobs
|
||||||
|
)
|
||||||
|
|
||||||
|
# a third run changes nothing (idempotent)
|
||||||
|
asyncio.run(migrate_db(settings.db_path))
|
||||||
|
wfs2 = {w["name"]: w for w in client.get("/api/workflows").json()}
|
||||||
|
assert wfs2["存量·文生图"]["usage"] == "text2image"
|
||||||
|
assert wfs2["存量·歧义"]["usage"] is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_broken_qwen_import_stays_blocked_but_recorded(client):
|
||||||
|
"""The damaged Qwen export classifies fine (image2image); its structural
|
||||||
|
lint errors still refuse generation — a broken file case, not a usage case."""
|
||||||
|
wf_json = _load("qwen21_edit_sage_API.json")
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows/analyze", json={"workflow_json": wf_json}
|
||||||
|
)
|
||||||
|
assert r.json()["usage"] == "image2image"
|
||||||
|
r = client.post(
|
||||||
|
"/api/workflows", json={"name": "损坏·Qwen", "kind": "image", "workflow_json": wf_json}
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
wf = r.json()
|
||||||
|
assert wf["usage"] == "image2image" and wf["is_enabled"] is True
|
||||||
|
assert any(w["level"] == "error" for w in wf["warnings"])
|
||||||
|
gen = client.post(
|
||||||
|
"/api/playground/generate",
|
||||||
|
json={"workflow_id": wf["id"], "input_values": {"4@prompt": "x"}},
|
||||||
|
)
|
||||||
|
assert gen.status_code == 400 and "重新导出" in gen.json()["detail"]
|
||||||
@@ -133,8 +133,11 @@ import type {
|
|||||||
SceneVideoSettings,
|
SceneVideoSettings,
|
||||||
Clip,
|
Clip,
|
||||||
Workflow,
|
Workflow,
|
||||||
|
WorkflowUsage,
|
||||||
|
WorkflowAnalyzeResult,
|
||||||
ComfyDynamicInput,
|
ComfyDynamicInput,
|
||||||
ComfyDynamicOutput,
|
ComfyDynamicOutput,
|
||||||
|
WorkflowOutputMapEntry,
|
||||||
} from "./comfy/types";
|
} from "./comfy/types";
|
||||||
export type {
|
export type {
|
||||||
Job,
|
Job,
|
||||||
@@ -142,8 +145,11 @@ export type {
|
|||||||
SceneVideoSettings,
|
SceneVideoSettings,
|
||||||
Clip,
|
Clip,
|
||||||
Workflow,
|
Workflow,
|
||||||
|
WorkflowUsage,
|
||||||
|
WorkflowAnalyzeResult,
|
||||||
ComfyDynamicInput,
|
ComfyDynamicInput,
|
||||||
ComfyDynamicOutput,
|
ComfyDynamicOutput,
|
||||||
|
WorkflowOutputMapEntry,
|
||||||
};
|
};
|
||||||
|
|
||||||
async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
||||||
@@ -453,11 +459,7 @@ export const comfy = {
|
|||||||
export const workflows = {
|
export const workflows = {
|
||||||
list: () => api<Workflow[]>("/api/workflows"),
|
list: () => api<Workflow[]>("/api/workflows"),
|
||||||
analyze: (workflow_json: Record<string, unknown>) =>
|
analyze: (workflow_json: Record<string, unknown>) =>
|
||||||
api<{
|
api<WorkflowAnalyzeResult>("/api/workflows/analyze", {
|
||||||
inputs: ComfyDynamicInput[];
|
|
||||||
outputs: ComfyDynamicOutput[];
|
|
||||||
suggested_profile?: string;
|
|
||||||
}>("/api/workflows/analyze", {
|
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({ workflow_json }),
|
body: JSON.stringify({ workflow_json }),
|
||||||
}),
|
}),
|
||||||
@@ -465,8 +467,13 @@ export const workflows = {
|
|||||||
api<Workflow>(`/api/workflows/${id}/reanalyze`, { method: "POST" }),
|
api<Workflow>(`/api/workflows/${id}/reanalyze`, { method: "POST" }),
|
||||||
create: (payload: {
|
create: (payload: {
|
||||||
name: string;
|
name: string;
|
||||||
kind: "image" | "video";
|
|
||||||
workflow_json: Record<string, unknown>;
|
workflow_json: Record<string, unknown>;
|
||||||
|
kind?: "image" | "video";
|
||||||
|
usage?: WorkflowUsage;
|
||||||
|
usage_source?: "auto" | "user";
|
||||||
|
input_schema?: ComfyDynamicInput[];
|
||||||
|
output_map?: WorkflowOutputMapEntry[];
|
||||||
|
output_map_source?: "auto" | "user";
|
||||||
description?: string;
|
description?: string;
|
||||||
prompt_profile?: string;
|
prompt_profile?: string;
|
||||||
endpoint_id?: string | null;
|
endpoint_id?: string | null;
|
||||||
@@ -484,6 +491,11 @@ export const workflows = {
|
|||||||
description: string;
|
description: string;
|
||||||
prompt_profile: string;
|
prompt_profile: string;
|
||||||
endpoint_id: string | null;
|
endpoint_id: string | null;
|
||||||
|
usage: WorkflowUsage;
|
||||||
|
usage_source: "auto" | "user";
|
||||||
|
input_schema: ComfyDynamicInput[];
|
||||||
|
output_map: WorkflowOutputMapEntry[];
|
||||||
|
output_map_source: "auto" | "user";
|
||||||
}>,
|
}>,
|
||||||
) =>
|
) =>
|
||||||
api<Workflow>(`/api/workflows/${id}`, {
|
api<Workflow>(`/api/workflows/${id}`, {
|
||||||
|
|||||||
@@ -43,9 +43,64 @@ export interface ComfyDynamicInput {
|
|||||||
export interface ComfyDynamicOutput {
|
export interface ComfyDynamicOutput {
|
||||||
nodeId: string;
|
nodeId: string;
|
||||||
label: string;
|
label: string;
|
||||||
/** Role from title tag, e.g. (Output:image) → "image". */
|
/** Role from title tag, e.g. (Output:image). */
|
||||||
role?: string | null;
|
role?: string | null;
|
||||||
kind: ComfyOutputKind;
|
/** Null while an unknown custom node awaits the user's media-type pick. */
|
||||||
|
kind: ComfyOutputKind | null;
|
||||||
|
/** Untagged detection: node class + which rule typed it. */
|
||||||
|
class_type?: string;
|
||||||
|
evidence?: 'registry' | 'class_name_match' | 'unknown_node';
|
||||||
|
/** Form default for unknown candidates — never auto-applied. */
|
||||||
|
suggested_kind?: 'image' | 'video' | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One entry of a workflow's confirmed output mapping (HEL-638). */
|
||||||
|
export interface WorkflowOutputMapEntry {
|
||||||
|
nodeId: string;
|
||||||
|
kind: 'image' | 'video';
|
||||||
|
label?: string;
|
||||||
|
class_type?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The five workflow usages the studio distinguishes (HEL-636). */
|
||||||
|
export type WorkflowUsage =
|
||||||
|
| 'text2image'
|
||||||
|
| 'image2image'
|
||||||
|
| 'text2video'
|
||||||
|
| 'image2video'
|
||||||
|
| 'ref2video';
|
||||||
|
|
||||||
|
export const WORKFLOW_USAGES: WorkflowUsage[] = [
|
||||||
|
'text2image',
|
||||||
|
'image2image',
|
||||||
|
'text2video',
|
||||||
|
'image2video',
|
||||||
|
'ref2video',
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Which usages each generate page serves. */
|
||||||
|
export const USAGE_BY_KIND: Record<'image' | 'video', WorkflowUsage[]> = {
|
||||||
|
image: ['text2image', 'image2image'],
|
||||||
|
video: ['text2video', 'image2video', 'ref2video'],
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Result of POST /api/workflows/analyze (import confirm step 1). */
|
||||||
|
export interface WorkflowAnalyzeResult {
|
||||||
|
inputs: ComfyDynamicInput[];
|
||||||
|
outputs: ComfyDynamicOutput[];
|
||||||
|
suggested_profile?: string;
|
||||||
|
warnings?: WorkflowWarning[];
|
||||||
|
usage: WorkflowUsage | null;
|
||||||
|
usage_ambiguous: boolean;
|
||||||
|
needs_mapping: boolean;
|
||||||
|
usage_problem: string | null;
|
||||||
|
usage_evidence: {
|
||||||
|
outputs: ComfyDynamicOutput[];
|
||||||
|
image_slots: Array<{ nodeId: string; label: string; kind: string; role: string | null }>;
|
||||||
|
video_slots: Array<{ nodeId: string; label: string; kind: string; role: string | null }>;
|
||||||
|
summary: string[];
|
||||||
|
};
|
||||||
|
usable_usage: WorkflowUsage[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WorkflowNode {
|
export interface WorkflowNode {
|
||||||
@@ -58,6 +113,9 @@ export interface Workflow {
|
|||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
kind: 'image' | 'video';
|
kind: 'image' | 'video';
|
||||||
|
/** Five-way usage (HEL-636); null = pending human confirmation. */
|
||||||
|
usage?: WorkflowUsage | null;
|
||||||
|
usage_source?: 'auto' | 'user' | null;
|
||||||
workflow_json: Record<string, WorkflowNode>;
|
workflow_json: Record<string, WorkflowNode>;
|
||||||
input_schema: ComfyDynamicInput[];
|
input_schema: ComfyDynamicInput[];
|
||||||
output_schema: ComfyDynamicOutput[];
|
output_schema: ComfyDynamicOutput[];
|
||||||
@@ -67,6 +125,11 @@ export interface Workflow {
|
|||||||
/** Bound ComfyUI connection id (settings.comfyui_endpoints); null = active. */
|
/** Bound ComfyUI connection id (settings.comfyui_endpoints); null = active. */
|
||||||
endpoint_id?: string | null;
|
endpoint_id?: string | null;
|
||||||
warnings?: WorkflowWarning[];
|
warnings?: WorkflowWarning[];
|
||||||
|
/** HEL-638: confirmed output mapping ({nodeId, kind}); null/empty = pending. */
|
||||||
|
output_map?: WorkflowOutputMapEntry[] | null;
|
||||||
|
output_map_source?: 'auto' | 'user' | null;
|
||||||
|
/** True when the graph has unknown output nodes needing designation. */
|
||||||
|
needs_mapping?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Job {
|
export interface Job {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
type Job,
|
type Job,
|
||||||
} from '$lib/api';
|
} from '$lib/api';
|
||||||
import type { ComfyDynamicInput } from '$lib/comfy/types';
|
import type { ComfyDynamicInput } from '$lib/comfy/types';
|
||||||
|
import { USAGE_BY_KIND, type WorkflowUsage } from '$lib/comfy/types';
|
||||||
import { compactInputValues, isPromptLikeInput } from '$lib/comfy/promptInput';
|
import { compactInputValues, isPromptLikeInput } from '$lib/comfy/promptInput';
|
||||||
import { parseDbTs } from '$lib/dbtime';
|
import { parseDbTs } from '$lib/dbtime';
|
||||||
import { normalizeInputRole } from '$lib/comfy/parser';
|
import { normalizeInputRole } from '$lib/comfy/parser';
|
||||||
@@ -62,9 +63,20 @@
|
|||||||
|
|
||||||
const endpoints = $derived($settingsQuery.data?.comfyui_endpoints ?? []);
|
const endpoints = $derived($settingsQuery.data?.comfyui_endpoints ?? []);
|
||||||
const activeId = $derived($settingsQuery.data?.comfyui_active_id ?? endpoints[0]?.id ?? '');
|
const activeId = $derived($settingsQuery.data?.comfyui_active_id ?? endpoints[0]?.id ?? '');
|
||||||
const kindWorkflows = $derived(
|
// HEL-636: the page serves its usages (image → t2i/i2i, video →
|
||||||
($workflowsQuery.data ?? []).filter((w) => w.kind === kind && w.is_enabled),
|
// t2v/i2v/ref2v); pending workflows (usage = null) never appear.
|
||||||
);
|
// HEL-638: workflows with unconfirmed unknown output nodes are also
|
||||||
|
// hidden — enabled rows carry a settled output mapping, this is a
|
||||||
|
// second guard for stale rows.
|
||||||
|
const kindWorkflows = $derived(
|
||||||
|
($workflowsQuery.data ?? []).filter(
|
||||||
|
(w) =>
|
||||||
|
w.is_enabled &&
|
||||||
|
(w.usage ?? null) !== null &&
|
||||||
|
!w.needs_mapping &&
|
||||||
|
USAGE_BY_KIND[kind].includes(w.usage!),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
const allJobs = $derived.by(() => {
|
const allJobs = $derived.by(() => {
|
||||||
void $jobsQuery.data;
|
void $jobsQuery.data;
|
||||||
@@ -317,8 +329,12 @@
|
|||||||
return out;
|
return out;
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Mode badge from what the workflow really wires (spec §1 table). */
|
/** Mode badge: the stored usage when we have one, else the wiring shape. */
|
||||||
|
function usageLabel(u: WorkflowUsage): string {
|
||||||
|
return t(`usage.${u}`);
|
||||||
|
}
|
||||||
const modeLabel = $derived.by(() => {
|
const modeLabel = $derived.by(() => {
|
||||||
|
if (currentWorkflow?.usage) return usageLabel(currentWorkflow.usage);
|
||||||
if (refGroup) return t('studio.modeRefToVideo');
|
if (refGroup) return t('studio.modeRefToVideo');
|
||||||
if (mediaSlots.some((s) => isFirstFrame(s.inp))) return t('studio.modeImageToVideo');
|
if (mediaSlots.some((s) => isFirstFrame(s.inp))) return t('studio.modeImageToVideo');
|
||||||
if (kind === 'image' && mediaSlots.some((s) => s.mediaKind === 'image' && role(s.inp) !== 'mask'))
|
if (kind === 'image' && mediaSlots.some((s) => s.mediaKind === 'image' && role(s.inp) !== 'mask'))
|
||||||
@@ -550,7 +566,10 @@
|
|||||||
let target = mediaSlots.find((s) => s.mediaKind === 'image' && role(s.inp) !== 'mask')?.inp ?? null;
|
let target = mediaSlots.find((s) => s.mediaKind === 'image' && role(s.inp) !== 'mask')?.inp ?? null;
|
||||||
if (!target) {
|
if (!target) {
|
||||||
const candidate = ($workflowsQuery.data ?? []).find(
|
const candidate = ($workflowsQuery.data ?? []).find(
|
||||||
(w) => w.kind === 'image' && w.is_enabled && (w.input_schema ?? []).some(isMedia),
|
(w) =>
|
||||||
|
w.is_enabled &&
|
||||||
|
w.usage === 'image2image' &&
|
||||||
|
(w.input_schema ?? []).some(isMedia),
|
||||||
);
|
);
|
||||||
if (!candidate) {
|
if (!candidate) {
|
||||||
toast.error(t('studio.noImg2ImgWf'));
|
toast.error(t('studio.noImg2ImgWf'));
|
||||||
@@ -687,6 +706,28 @@
|
|||||||
const selectedEntry = $derived(
|
const selectedEntry = $derived(
|
||||||
doneEntries.find((e) => e.key === selectedKey) ?? doneEntries[0] ?? null,
|
doneEntries.find((e) => e.key === selectedKey) ?? doneEntries[0] ?? null,
|
||||||
);
|
);
|
||||||
|
const selectedJobId = $derived(selectedEntry?.job.id ?? null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clicking a history row: a finished job loads into the preview
|
||||||
|
* (player / image), anything else just reports its live status —
|
||||||
|
* never a silent jump to the newest finished clip.
|
||||||
|
*/
|
||||||
|
function selectFromHistory(job: Job) {
|
||||||
|
const st = jobStatusInfo(job);
|
||||||
|
if (st.tone === 'ok' && job.output_paths.length) {
|
||||||
|
selectedKey = `${job.id}:${job.output_paths[0]}`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toast.info(st.detail && st.detail !== st.label ? `${st.label} · ${st.detail}` : st.label);
|
||||||
|
}
|
||||||
|
|
||||||
|
function histRowKey(e: KeyboardEvent, job: Job) {
|
||||||
|
if (e.key === 'Enter' || e.key === ' ') {
|
||||||
|
e.preventDefault();
|
||||||
|
selectFromHistory(job);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function summaryOf(job: Job): string {
|
function summaryOf(job: Job): string {
|
||||||
const parts: string[] = [];
|
const parts: string[] = [];
|
||||||
@@ -739,6 +780,26 @@
|
|||||||
let curSec = $state(0);
|
let curSec = $state(0);
|
||||||
let durSec = $state(0);
|
let durSec = $state(0);
|
||||||
|
|
||||||
|
// Switching the selected video must stop the old clip and rewind it,
|
||||||
|
// never keep playing the previous audio/progress into the new one.
|
||||||
|
// Runs BEFORE the DOM swaps the src so the reset cannot clobber the
|
||||||
|
// duration/metadata events of the clip being loaded in.
|
||||||
|
$effect.pre(() => {
|
||||||
|
void selectedEntry?.key;
|
||||||
|
const v = videoEl;
|
||||||
|
if (v) {
|
||||||
|
try {
|
||||||
|
v.pause();
|
||||||
|
v.currentTime = 0;
|
||||||
|
} catch {
|
||||||
|
/* no loaded metadata yet — src change already reset it */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
playing = false;
|
||||||
|
curSec = 0;
|
||||||
|
durSec = 0;
|
||||||
|
});
|
||||||
|
|
||||||
function fmtClock(s: number): string {
|
function fmtClock(s: number): string {
|
||||||
if (!Number.isFinite(s)) return '0:00';
|
if (!Number.isFinite(s)) return '0:00';
|
||||||
const m = Math.floor(s / 60);
|
const m = Math.floor(s / 60);
|
||||||
@@ -766,13 +827,16 @@
|
|||||||
else void playerBox?.requestFullscreen();
|
else void playerBox?.requestFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
// First/last frame strip for the selected video job
|
// First/last frame + reference strip for the selected video job.
|
||||||
|
// Ref workflows come in two shapes: an autogrow image_list, or several
|
||||||
|
// plain image inputs — both are shown as reference images.
|
||||||
const selectedFrames = $derived.by(() => {
|
const selectedFrames = $derived.by(() => {
|
||||||
if (kind !== 'video' || !selectedEntry) return [];
|
if (kind !== 'video' || !selectedEntry) return [];
|
||||||
const wf = ($workflowsQuery.data ?? []).find((w) => w.id === selectedEntry.job.workflow_id);
|
const wf = ($workflowsQuery.data ?? []).find((w) => w.id === selectedEntry.job.workflow_id);
|
||||||
if (!wf) return [];
|
if (!wf) return [];
|
||||||
const vals = (selectedEntry.job.payload?.input_values ?? {}) as Record<string, unknown>;
|
const vals = (selectedEntry.job.payload?.input_values ?? {}) as Record<string, unknown>;
|
||||||
const out: Array<{ label: string; path: string; ref?: boolean }> = [];
|
const out: Array<{ label: string; path: string; ref?: boolean }> = [];
|
||||||
|
let refIdx = 0;
|
||||||
for (const inp of wf.input_schema ?? []) {
|
for (const inp of wf.input_schema ?? []) {
|
||||||
const h = `${inp.role ?? ''} ${inp.label}`.toLowerCase();
|
const h = `${inp.role ?? ''} ${inp.label}`.toLowerCase();
|
||||||
const v = vals[inp.nodeId];
|
const v = vals[inp.nodeId];
|
||||||
@@ -786,6 +850,10 @@
|
|||||||
if (typeof v !== 'string' || !v) continue;
|
if (typeof v !== 'string' || !v) continue;
|
||||||
if (/first|start|首帧/.test(h)) out.push({ label: t('studio.slotFirst'), path: v });
|
if (/first|start|首帧/.test(h)) out.push({ label: t('studio.slotFirst'), path: v });
|
||||||
else if (/last|end|尾帧/.test(h)) out.push({ label: t('studio.slotLast'), path: v });
|
else if (/last|end|尾帧/.test(h)) out.push({ label: t('studio.slotLast'), path: v });
|
||||||
|
else if (isMedia(inp) && inp.kind === 'image' && !/mask|遮罩/.test(h)) {
|
||||||
|
refIdx += 1;
|
||||||
|
out.push({ label: t('studio.slotRefN', { n: refIdx }), path: v, ref: true });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
});
|
});
|
||||||
@@ -833,12 +901,31 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const deleteTarget = $derived(kindJobs.find((j) => j.id === deleteJobId) ?? null);
|
const deleteTarget = $derived(kindJobs.find((j) => j.id === deleteJobId) ?? null);
|
||||||
|
// The dialog names the exact job and — when it produced several
|
||||||
|
// outputs — says plainly that ALL of them go away with it (the
|
||||||
|
// backend only deletes whole jobs, never a single output file).
|
||||||
|
const deleteTitle = $derived(
|
||||||
|
deleteTarget ? t('studio.delTitleJob', { name: wfName(deleteTarget) }) : t('studio.delTitle'),
|
||||||
|
);
|
||||||
|
const deleteMessage = $derived.by(() => {
|
||||||
|
const n = deleteTarget?.output_paths?.length ?? 0;
|
||||||
|
return n > 1 ? t('studio.delConfirmMulti', { n }) : t('studio.delConfirm');
|
||||||
|
});
|
||||||
|
|
||||||
|
function askDeleteJob(jobId: number) {
|
||||||
|
deleteJobId = jobId;
|
||||||
|
deleteOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
async function doDelete() {
|
async function doDelete() {
|
||||||
if (!deleteJobId) return;
|
if (!deleteJobId) return;
|
||||||
try {
|
try {
|
||||||
await playgroundApi.deleteJob(deleteJobId);
|
await playgroundApi.deleteJob(deleteJobId);
|
||||||
|
submittedIds.delete(deleteJobId);
|
||||||
if (selectedEntry?.job.id === deleteJobId) selectedKey = null;
|
if (selectedEntry?.job.id === deleteJobId) selectedKey = null;
|
||||||
|
toast.success(t('studio.deletedToast'));
|
||||||
await client.invalidateQueries({ queryKey: ['playground-jobs'] });
|
await client.invalidateQueries({ queryKey: ['playground-jobs'] });
|
||||||
|
await client.invalidateQueries({ queryKey: ['jobs'] });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast.error(err instanceof Error ? err.message : String(err));
|
toast.error(err instanceof Error ? err.message : String(err));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -1483,11 +1570,20 @@
|
|||||||
<Icon name="upload" size={13} />
|
<Icon name="upload" size={13} />
|
||||||
{t('studio.sendToImg2Img')}
|
{t('studio.sendToImg2Img')}
|
||||||
</Button>
|
</Button>
|
||||||
<a class="a-btn secondary sm" href={assetUrl(selectedEntry.path)} download={downloadName(selectedEntry.path)}>
|
<a class="a-btn secondary sm" href={assetUrl(selectedEntry.path)} download={downloadName(selectedEntry.path)}>
|
||||||
<Icon name="download" size={13} />
|
<Icon name="download" size={13} />
|
||||||
{t('studio.download')}
|
{t('studio.download')}
|
||||||
</a>
|
</a>
|
||||||
</span>
|
<Button
|
||||||
|
variant="danger"
|
||||||
|
size="sm"
|
||||||
|
title={t('studio.deleteBtn')}
|
||||||
|
onclick={() => askDeleteJob(selectedEntry!.job.id)}
|
||||||
|
>
|
||||||
|
<Icon name="trash" size={13} />
|
||||||
|
{t('studio.deleteBtn')}
|
||||||
|
</Button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
@@ -1502,7 +1598,8 @@
|
|||||||
<h2>{t('studio.video.resultsTitle')}</h2>
|
<h2>{t('studio.video.resultsTitle')}</h2>
|
||||||
{#if selectedEntry}
|
{#if selectedEntry}
|
||||||
<span class="panel-hint">
|
<span class="panel-hint">
|
||||||
{t('studio.lastDone', {
|
{wfName(selectedEntry.job)} ·
|
||||||
|
{t('studio.doneAt', {
|
||||||
time: fmtTime(parseDbTs(selectedEntry.job.completed_at ?? selectedEntry.job.created_at)),
|
time: fmtTime(parseDbTs(selectedEntry.job.completed_at ?? selectedEntry.job.created_at)),
|
||||||
})}
|
})}
|
||||||
</span>
|
</span>
|
||||||
@@ -1575,11 +1672,20 @@
|
|||||||
<Icon name="retry" size={13} />
|
<Icon name="retry" size={13} />
|
||||||
{t('studio.retryLink')}
|
{t('studio.retryLink')}
|
||||||
</Button>
|
</Button>
|
||||||
<a class="a-btn secondary sm" href={assetUrl(selectedEntry.path)} download={downloadName(selectedEntry.path)}>
|
<a class="a-btn secondary sm" href={assetUrl(selectedEntry.path)} download={downloadName(selectedEntry.path)}>
|
||||||
<Icon name="download" size={13} />
|
<Icon name="download" size={13} />
|
||||||
{t('studio.downloadMp4')}
|
{t('studio.downloadMp4')}
|
||||||
</a>
|
</a>
|
||||||
</span>
|
<Button
|
||||||
|
variant="danger"
|
||||||
|
size="sm"
|
||||||
|
title={t('studio.deleteBtn')}
|
||||||
|
onclick={() => askDeleteJob(selectedEntry!.job.id)}
|
||||||
|
>
|
||||||
|
<Icon name="trash" size={13} />
|
||||||
|
{t('studio.deleteBtn')}
|
||||||
|
</Button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<p class="empty-line">{t('studio.historyEmptyVideo')}</p>
|
<p class="empty-line">{t('studio.historyEmptyVideo')}</p>
|
||||||
@@ -1600,59 +1706,73 @@
|
|||||||
{kind === 'image' ? t('studio.historyEmptyImage') : t('studio.historyEmptyVideo')}
|
{kind === 'image' ? t('studio.historyEmptyImage') : t('studio.historyEmptyVideo')}
|
||||||
</p>
|
</p>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="history-list">
|
<div class="history-list">
|
||||||
{#each kindJobs as job (job.id)}
|
{#each kindJobs as job (job.id)}
|
||||||
{@const st = jobStatusInfo(job)}
|
{@const st = jobStatusInfo(job)}
|
||||||
<div class="hist-row" class:failed={job.status === 'failed'} class:video={kind === 'video'}>
|
<div
|
||||||
<div class="hist-thumb" class:video={kind === 'video'}>
|
class="hist-row"
|
||||||
{#if job.output_paths?.[0]}
|
class:failed={job.status === 'failed'}
|
||||||
{#if kind === 'image'}
|
class:video={kind === 'video'}
|
||||||
<img src={assetUrl(job.output_paths[0])} alt={wfName(job)} loading="lazy" />
|
class:selected={selectedJobId === job.id}
|
||||||
{:else}
|
role="button"
|
||||||
<video
|
tabindex={0}
|
||||||
src={assetUrl(job.output_paths[0])}
|
aria-label={`${wfName(job)} · ${st.label}`}
|
||||||
preload="metadata"
|
aria-current={selectedJobId === job.id ? 'true' : undefined}
|
||||||
muted
|
onclick={() => selectFromHistory(job)}
|
||||||
onloadedmetadata={(e) => noteDuration(job.output_paths![0], e)}
|
onkeydown={(e) => histRowKey(e, job)}
|
||||||
></video>
|
>
|
||||||
{#if durations[job.output_paths[0]]}
|
<div class="hist-thumb" class:video={kind === 'video'}>
|
||||||
<span class="dur mono">{fmtClock(durations[job.output_paths[0]])}</span>
|
{#if job.output_paths?.[0]}
|
||||||
{/if}
|
{#if kind === 'image'}
|
||||||
{/if}
|
<img src={assetUrl(job.output_paths[0])} alt={wfName(job)} loading="lazy" />
|
||||||
{:else if job.status === 'failed'}
|
|
||||||
<span class="thumb-fallback failed"><Icon name="alert" size={14} /></span>
|
|
||||||
{:else}
|
{:else}
|
||||||
<span class="thumb-fallback"><Icon name={kind === 'image' ? 'image' : 'film'} size={14} /></span>
|
<video
|
||||||
{/if}
|
src={assetUrl(job.output_paths[0])}
|
||||||
</div>
|
preload="metadata"
|
||||||
<div class="hist-body">
|
muted
|
||||||
<div class="hist-name" title={wfName(job)}>{wfName(job)}</div>
|
onloadedmetadata={(e) => noteDuration(job.output_paths![0], e)}
|
||||||
<div class="hist-meta mono">{summaryOf(job)}</div>
|
></video>
|
||||||
<div class="hist-status">
|
{#if durations[job.output_paths[0]]}
|
||||||
{#if job.status !== 'failed'}
|
<span class="dur mono">{fmtClock(durations[job.output_paths[0]])}</span>
|
||||||
<span class="st {st.tone}" title={st.detail}>{st.label}</span>
|
|
||||||
{:else}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="st fail-link"
|
|
||||||
disabled={retryingId === job.id}
|
|
||||||
onclick={() => retryJob(job)}
|
|
||||||
>
|
|
||||||
{t('studio.retryLink')}
|
|
||||||
</button>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
{/if}
|
||||||
|
{:else if job.status === 'failed'}
|
||||||
|
<span class="thumb-fallback failed"><Icon name="alert" size={14} /></span>
|
||||||
|
{:else}
|
||||||
|
<span class="thumb-fallback"><Icon name={kind === 'image' ? 'image' : 'film'} size={14} /></span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class="hist-body">
|
||||||
|
<div class="hist-name" title={wfName(job)}>{wfName(job)}</div>
|
||||||
|
<div class="hist-meta mono">{summaryOf(job)}</div>
|
||||||
|
<div class="hist-status">
|
||||||
|
{#if job.status !== 'failed'}
|
||||||
|
<span class="st {st.tone}" title={st.detail}>{st.label}</span>
|
||||||
|
{:else}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="hist-del"
|
class="st fail-link"
|
||||||
title={t('studio.deleteBtn')}
|
disabled={retryingId === job.id}
|
||||||
onclick={() => {
|
onclick={(e) => {
|
||||||
deleteJobId = job.id;
|
e.stopPropagation();
|
||||||
deleteOpen = true;
|
retryJob(job);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon name="trash" size={13} />
|
{t('studio.retryLink')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
{/if}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="hist-del"
|
||||||
|
title={t('studio.deleteBtn')}
|
||||||
|
onclick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
askDeleteJob(job.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon name="trash" size={13} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
{#if job.status === 'failed' && job.error}
|
{#if job.status === 'failed' && job.error}
|
||||||
<div class="hist-error">{job.error}</div>
|
<div class="hist-error">{job.error}</div>
|
||||||
{:else if st.tone === 'fail' || (job.status === 'done' && job.phase === 'dry_run')}
|
{:else if st.tone === 'fail' || (job.status === 'done' && job.phase === 'dry_run')}
|
||||||
@@ -1692,9 +1812,10 @@
|
|||||||
|
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
bind:open={deleteOpen}
|
bind:open={deleteOpen}
|
||||||
title={t('studio.delTitle')}
|
title={deleteTitle}
|
||||||
message={t('studio.delConfirm')}
|
message={deleteMessage}
|
||||||
confirmLabel={t('studio.deleteBtn')}
|
confirmLabel={t('studio.deleteBtn')}
|
||||||
|
cancelLabel={t('common.cancel')}
|
||||||
danger
|
danger
|
||||||
onconfirm={doDelete}
|
onconfirm={doDelete}
|
||||||
oncancel={() => {
|
oncancel={() => {
|
||||||
@@ -2276,10 +2397,23 @@
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
min-height: 44px;
|
min-height: 44px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.hist-row:hover {
|
.hist-row:hover {
|
||||||
background: var(--surface-2);
|
background: var(--surface-2);
|
||||||
}
|
}
|
||||||
|
.hist-row:focus-visible {
|
||||||
|
outline: 1px solid var(--accent);
|
||||||
|
outline-offset: -1px;
|
||||||
|
}
|
||||||
|
/* The row loaded into the preview stays marked, and its delete stays visible. */
|
||||||
|
.hist-row.selected {
|
||||||
|
background: var(--surface-2);
|
||||||
|
box-shadow: inset 2px 0 0 var(--accent);
|
||||||
|
}
|
||||||
|
.hist-row.selected .hist-del {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
.hist-row.failed {
|
.hist-row.failed {
|
||||||
background: var(--error-dim);
|
background: var(--error-dim);
|
||||||
}
|
}
|
||||||
@@ -2405,6 +2539,15 @@
|
|||||||
.hist-row:hover .hist-del {
|
.hist-row:hover .hist-del {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
.hist-del:focus-visible {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
/* Touch devices have no hover to reveal the delete affordance. */
|
||||||
|
@media (hover: none) {
|
||||||
|
.hist-del {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
.hist-del:hover {
|
.hist-del:hover {
|
||||||
color: var(--error);
|
color: var(--error);
|
||||||
background: var(--error-dim);
|
background: var(--error-dim);
|
||||||
|
|||||||
@@ -1400,6 +1400,52 @@ export const de: Dict = {
|
|||||||
'conn.wfDeleted': 'Workflow gelöscht',
|
'conn.wfDeleted': 'Workflow gelöscht',
|
||||||
'conn.wfImportedBroken': 'Imported, but the workflow file is incomplete and must be re-exported before generating: {detail}',
|
'conn.wfImportedBroken': 'Imported, but the workflow file is incomplete and must be re-exported before generating: {detail}',
|
||||||
'conn.wfBrokenBadge': 'Incomplete file — cannot generate',
|
'conn.wfBrokenBadge': 'Incomplete file — cannot generate',
|
||||||
|
// --- Five usages & import confirmation (HEL-636) ---
|
||||||
|
'usage.text2image': 'Text → Image',
|
||||||
|
'usage.image2image': 'Image → Image',
|
||||||
|
'usage.text2video': 'Text → Video',
|
||||||
|
'usage.image2video': 'Image → Video',
|
||||||
|
'usage.ref2video': 'Reference → Video',
|
||||||
|
'usage.pending': 'Usage pending',
|
||||||
|
'wfRole.image': 'Input image',
|
||||||
|
'wfRole.first_frame': 'First frame',
|
||||||
|
'wfRole.last_frame': 'Last frame',
|
||||||
|
'wfRole.reference_image': 'Reference',
|
||||||
|
'wfRole.mask': 'Mask',
|
||||||
|
'conn.wfImportAction': 'Import workflow',
|
||||||
|
'conn.wfConfirmTitle': 'Confirm detection',
|
||||||
|
'conn.wfStepAnalyze': 'Paste & analyze',
|
||||||
|
'conn.wfStepConfirm': 'Confirm & save',
|
||||||
|
'conn.wfChooseFile': 'Choose file',
|
||||||
|
'conn.wfAnalyze': 'Analyze',
|
||||||
|
'conn.wfAnalyzing': 'Analyzing…',
|
||||||
|
'conn.wfConfirmHint': 'Review the evidence, output nodes and image slots; correct the usage or slot roles before saving.',
|
||||||
|
'conn.wfUsageLabel': 'Usage',
|
||||||
|
'conn.wfUsageAuto': 'Auto-detected: {usage}',
|
||||||
|
'conn.wfUsageNeedPick': 'Pick manually',
|
||||||
|
'conn.wfPickUsage': 'Choose a usage first',
|
||||||
|
'conn.wfSlotsLabel': 'Image slots',
|
||||||
|
'conn.wfSlotsHint': 'Roles are inferred from wiring; override them (input image / first / last frame / reference / mask) and the manual choice sticks.',
|
||||||
|
'conn.wfBack': 'Back',
|
||||||
|
'conn.wfConfirmSave': 'Confirm & save',
|
||||||
|
'conn.wfImportedWithUsage': 'Saved as “{usage}” with {n} fillable parameters',
|
||||||
|
'conn.wfPendingCount': '{n} pending',
|
||||||
|
'conn.wfConfirmed': 'Usage confirmed: {usage} — the workflow can generate now',
|
||||||
|
'conn.wfSourceUser': 'Usage set manually; re-analysis will not overwrite it',
|
||||||
|
'conn.wfSourceAuto': 'Usage auto-detected',
|
||||||
|
'conn.wfDisabledBadge': 'Disabled',
|
||||||
|
'conn.wfConfirmAria': 'Confirm workflow usage',
|
||||||
|
'conn.wfOutputLabel': 'Ausgabeknoten',
|
||||||
|
'conn.wfOutputNeedPick': 'Unbekannte benutzerdefinierte Ausgabeknoten — bitte zuordnen',
|
||||||
|
'conn.wfOutputHint': 'Markieren Sie die Knoten, die tatsächlich Ergebnisse liefern, und wählen Sie je den Medientyp; die Generierung sammelt Bilder/Videos nur aus diesen Knoten.',
|
||||||
|
'conn.wfOutputPick': 'Mindestens einen Ausgabeknoten markieren',
|
||||||
|
'conn.wfOutputKindAria': 'Medientyp des Ausgabeknotens',
|
||||||
|
'conn.wfOutputPendingBadge': 'Ausgabe offen',
|
||||||
|
'conn.wfOutputNeedMap': 'Dieser Workflow enthält nicht erkannte Ausgabeknoten; ordnen Sie sie samt Medientyp zu, um ihn zu aktivieren',
|
||||||
|
'conn.wfOutputApply': 'Ausgabezuordnung speichern',
|
||||||
|
'conn.wfMapCancel': 'Abbrechen',
|
||||||
|
'conn.wfOutputApplied': 'Ausgabezuordnung gespeichert: Knoten {nodes}',
|
||||||
|
'conn.wfOutputCleared': 'Ausgabezuordnung gelöscht — der Workflow ist wieder ausstehend',
|
||||||
'conn.missingMaterial': 'Ein dediziertes Qwen Image 2.1-Workflow-JSON fehlt noch im Repo: aus ComfyUI exportieren und hier importieren — der generische Importweg steht bereit.',
|
'conn.missingMaterial': 'Ein dediziertes Qwen Image 2.1-Workflow-JSON fehlt noch im Repo: aus ComfyUI exportieren und hier importieren — der generische Importweg steht bereit.',
|
||||||
|
|
||||||
// --- Eigenständige Bild-/Videogenerierung (a3/a4, HEL-612) ---
|
// --- Eigenständige Bild-/Videogenerierung (a3/a4, HEL-612) ---
|
||||||
@@ -1416,7 +1462,7 @@ export const de: Dict = {
|
|||||||
'studio.image.historyTitle': 'Bildverlauf',
|
'studio.image.historyTitle': 'Bildverlauf',
|
||||||
'studio.video.historyTitle': 'Videoverlauf',
|
'studio.video.historyTitle': 'Videoverlauf',
|
||||||
'studio.historyCount': '{n} gesamt',
|
'studio.historyCount': '{n} gesamt',
|
||||||
'studio.lastDone': 'Zuletzt fertig · {time}',
|
'studio.doneAt': 'Fertiggestellt um {time}',
|
||||||
'studio.kindImageText': 'Bild',
|
'studio.kindImageText': 'Bild',
|
||||||
'studio.kindVideoText': 'Video',
|
'studio.kindVideoText': 'Video',
|
||||||
'studio.loading': 'Lädt…',
|
'studio.loading': 'Lädt…',
|
||||||
@@ -1532,7 +1578,10 @@ export const de: Dict = {
|
|||||||
'studio.cancelToast': 'Abbruch angefordert',
|
'studio.cancelToast': 'Abbruch angefordert',
|
||||||
'studio.deleteBtn': 'Löschen',
|
'studio.deleteBtn': 'Löschen',
|
||||||
'studio.delTitle': 'Aufgabeneintrag löschen',
|
'studio.delTitle': 'Aufgabeneintrag löschen',
|
||||||
'studio.delConfirm': 'Die Ergebnisdateien werden mitgelöscht. Löschen?',
|
'studio.delConfirm': 'Beim Löschen werden auch die Ergebnisdateien dieses Auftrags entfernt; der Verlauf ist nicht wiederherstellbar. Löschen?',
|
||||||
|
'studio.delTitleJob': 'Auftrag „{name}“ löschen',
|
||||||
|
'studio.delConfirmMulti': 'Dieser Auftrag hat {n} Ergebnisse. Beim Löschen werden der gesamte Auftragsdatensatz und alle {n} Ergebnisdateien entfernt; dies ist unwiderruflich. Löschen?',
|
||||||
|
'studio.deletedToast': 'Auftrag und zugehörige Ergebnisdateien gelöscht',
|
||||||
'studio.wfEmptyTitle': 'Noch keine {kind}-Workflows',
|
'studio.wfEmptyTitle': 'Noch keine {kind}-Workflows',
|
||||||
'studio.wfEmptyBody': 'Entwicklermodus in ComfyUI aktivieren, Workflow als API-JSON exportieren und auf der Seite ComfyUI-Verbindungen als {kind} importieren.',
|
'studio.wfEmptyBody': 'Entwicklermodus in ComfyUI aktivieren, Workflow als API-JSON exportieren und auf der Seite ComfyUI-Verbindungen als {kind} importieren.',
|
||||||
'studio.wfEmptyGo': 'In ComfyUI-Verbindungen importieren',
|
'studio.wfEmptyGo': 'In ComfyUI-Verbindungen importieren',
|
||||||
|
|||||||
@@ -1400,6 +1400,52 @@ export const en = {
|
|||||||
'conn.wfDeleted': 'Workflow deleted',
|
'conn.wfDeleted': 'Workflow deleted',
|
||||||
'conn.wfImportedBroken': 'Imported, but the workflow file is incomplete and must be re-exported before generating: {detail}',
|
'conn.wfImportedBroken': 'Imported, but the workflow file is incomplete and must be re-exported before generating: {detail}',
|
||||||
'conn.wfBrokenBadge': 'Incomplete file — cannot generate',
|
'conn.wfBrokenBadge': 'Incomplete file — cannot generate',
|
||||||
|
// --- Five usages & import confirmation (HEL-636) ---
|
||||||
|
'usage.text2image': 'Text → Image',
|
||||||
|
'usage.image2image': 'Image → Image',
|
||||||
|
'usage.text2video': 'Text → Video',
|
||||||
|
'usage.image2video': 'Image → Video',
|
||||||
|
'usage.ref2video': 'Reference → Video',
|
||||||
|
'usage.pending': 'Usage pending',
|
||||||
|
'wfRole.image': 'Input image',
|
||||||
|
'wfRole.first_frame': 'First frame',
|
||||||
|
'wfRole.last_frame': 'Last frame',
|
||||||
|
'wfRole.reference_image': 'Reference',
|
||||||
|
'wfRole.mask': 'Mask',
|
||||||
|
'conn.wfImportAction': 'Import workflow',
|
||||||
|
'conn.wfConfirmTitle': 'Confirm detection',
|
||||||
|
'conn.wfStepAnalyze': 'Paste & analyze',
|
||||||
|
'conn.wfStepConfirm': 'Confirm & save',
|
||||||
|
'conn.wfChooseFile': 'Choose file',
|
||||||
|
'conn.wfAnalyze': 'Analyze',
|
||||||
|
'conn.wfAnalyzing': 'Analyzing…',
|
||||||
|
'conn.wfConfirmHint': 'Review the evidence, output nodes and image slots; correct the usage or slot roles before saving.',
|
||||||
|
'conn.wfUsageLabel': 'Usage',
|
||||||
|
'conn.wfUsageAuto': 'Auto-detected: {usage}',
|
||||||
|
'conn.wfUsageNeedPick': 'Pick manually',
|
||||||
|
'conn.wfPickUsage': 'Choose a usage first',
|
||||||
|
'conn.wfSlotsLabel': 'Image slots',
|
||||||
|
'conn.wfSlotsHint': 'Roles are inferred from wiring; override them (input image / first / last frame / reference / mask) and the manual choice sticks.',
|
||||||
|
'conn.wfBack': 'Back',
|
||||||
|
'conn.wfConfirmSave': 'Confirm & save',
|
||||||
|
'conn.wfImportedWithUsage': 'Saved as “{usage}” with {n} fillable parameters',
|
||||||
|
'conn.wfPendingCount': '{n} pending',
|
||||||
|
'conn.wfConfirmed': 'Usage confirmed: {usage} — the workflow can generate now',
|
||||||
|
'conn.wfSourceUser': 'Usage set manually; re-analysis will not overwrite it',
|
||||||
|
'conn.wfSourceAuto': 'Usage auto-detected',
|
||||||
|
'conn.wfDisabledBadge': 'Disabled',
|
||||||
|
'conn.wfConfirmAria': 'Confirm workflow usage',
|
||||||
|
'conn.wfOutputLabel': 'Output nodes',
|
||||||
|
'conn.wfOutputNeedPick': 'Unrecognized custom output nodes — designate them',
|
||||||
|
'conn.wfOutputHint': 'Check the nodes that actually produce results and pick each one’s media type; generation harvests images/videos only from these nodes.',
|
||||||
|
'conn.wfOutputPick': 'Check at least one output node',
|
||||||
|
'conn.wfOutputKindAria': 'Output node media type',
|
||||||
|
'conn.wfOutputPendingBadge': 'Outputs unset',
|
||||||
|
'conn.wfOutputNeedMap': 'This workflow has unrecognized output nodes; designate them and their media type to enable it',
|
||||||
|
'conn.wfOutputApply': 'Save output mapping',
|
||||||
|
'conn.wfMapCancel': 'Cancel',
|
||||||
|
'conn.wfOutputApplied': 'Output mapping saved: node {nodes}',
|
||||||
|
'conn.wfOutputCleared': 'Output mapping cleared — the workflow is pending again',
|
||||||
'conn.missingMaterial': 'A dedicated Qwen Image 2.1 workflow JSON is not in the repo yet: export it from ComfyUI and import it here — the generic import path is ready.',
|
'conn.missingMaterial': 'A dedicated Qwen Image 2.1 workflow JSON is not in the repo yet: export it from ComfyUI and import it here — the generic import path is ready.',
|
||||||
// --- Standalone image / video generation (a3/a4, HEL-612) ---
|
// --- Standalone image / video generation (a3/a4, HEL-612) ---
|
||||||
'studio.image.title': 'Image',
|
'studio.image.title': 'Image',
|
||||||
@@ -1415,7 +1461,7 @@ export const en = {
|
|||||||
'studio.image.historyTitle': 'Image history',
|
'studio.image.historyTitle': 'Image history',
|
||||||
'studio.video.historyTitle': 'Video history',
|
'studio.video.historyTitle': 'Video history',
|
||||||
'studio.historyCount': '{n} total',
|
'studio.historyCount': '{n} total',
|
||||||
'studio.lastDone': 'Last done · {time}',
|
'studio.doneAt': 'Done at {time}',
|
||||||
'studio.kindImageText': 'image',
|
'studio.kindImageText': 'image',
|
||||||
'studio.kindVideoText': 'video',
|
'studio.kindVideoText': 'video',
|
||||||
'studio.loading': 'Loading…',
|
'studio.loading': 'Loading…',
|
||||||
@@ -1531,7 +1577,10 @@ export const en = {
|
|||||||
'studio.cancelToast': 'Cancel requested',
|
'studio.cancelToast': 'Cancel requested',
|
||||||
'studio.deleteBtn': 'Delete',
|
'studio.deleteBtn': 'Delete',
|
||||||
'studio.delTitle': 'Delete task record',
|
'studio.delTitle': 'Delete task record',
|
||||||
'studio.delConfirm': 'The result files will be removed together with the record. Delete it?',
|
'studio.delConfirm': 'Deleting also removes this job’s result files; the history cannot be restored. Delete?',
|
||||||
|
'studio.delTitleJob': 'Delete job “{name}”',
|
||||||
|
'studio.delConfirmMulti': 'This job produced {n} results. Deleting removes the whole job record and all {n} result files; this cannot be undone. Delete?',
|
||||||
|
'studio.deletedToast': 'Job deleted together with its result files',
|
||||||
'studio.wfEmptyTitle': 'No {kind} workflows yet',
|
'studio.wfEmptyTitle': 'No {kind} workflows yet',
|
||||||
'studio.wfEmptyBody': "Enable ComfyUI's developer mode, export the workflow as API JSON, then import it on the ComfyUI Connections page as {kind}.",
|
'studio.wfEmptyBody': "Enable ComfyUI's developer mode, export the workflow as API JSON, then import it on the ComfyUI Connections page as {kind}.",
|
||||||
'studio.wfEmptyGo': 'Import in ComfyUI Connections',
|
'studio.wfEmptyGo': 'Import in ComfyUI Connections',
|
||||||
|
|||||||
@@ -1400,6 +1400,52 @@ export const es: Dict = {
|
|||||||
'conn.wfDeleted': 'Flujo eliminado',
|
'conn.wfDeleted': 'Flujo eliminado',
|
||||||
'conn.wfImportedBroken': 'Imported, but the workflow file is incomplete and must be re-exported before generating: {detail}',
|
'conn.wfImportedBroken': 'Imported, but the workflow file is incomplete and must be re-exported before generating: {detail}',
|
||||||
'conn.wfBrokenBadge': 'Incomplete file — cannot generate',
|
'conn.wfBrokenBadge': 'Incomplete file — cannot generate',
|
||||||
|
// --- Five usages & import confirmation (HEL-636) ---
|
||||||
|
'usage.text2image': 'Text → Image',
|
||||||
|
'usage.image2image': 'Image → Image',
|
||||||
|
'usage.text2video': 'Text → Video',
|
||||||
|
'usage.image2video': 'Image → Video',
|
||||||
|
'usage.ref2video': 'Reference → Video',
|
||||||
|
'usage.pending': 'Usage pending',
|
||||||
|
'wfRole.image': 'Input image',
|
||||||
|
'wfRole.first_frame': 'First frame',
|
||||||
|
'wfRole.last_frame': 'Last frame',
|
||||||
|
'wfRole.reference_image': 'Reference',
|
||||||
|
'wfRole.mask': 'Mask',
|
||||||
|
'conn.wfImportAction': 'Import workflow',
|
||||||
|
'conn.wfConfirmTitle': 'Confirm detection',
|
||||||
|
'conn.wfStepAnalyze': 'Paste & analyze',
|
||||||
|
'conn.wfStepConfirm': 'Confirm & save',
|
||||||
|
'conn.wfChooseFile': 'Choose file',
|
||||||
|
'conn.wfAnalyze': 'Analyze',
|
||||||
|
'conn.wfAnalyzing': 'Analyzing…',
|
||||||
|
'conn.wfConfirmHint': 'Review the evidence, output nodes and image slots; correct the usage or slot roles before saving.',
|
||||||
|
'conn.wfUsageLabel': 'Usage',
|
||||||
|
'conn.wfUsageAuto': 'Auto-detected: {usage}',
|
||||||
|
'conn.wfUsageNeedPick': 'Pick manually',
|
||||||
|
'conn.wfPickUsage': 'Choose a usage first',
|
||||||
|
'conn.wfSlotsLabel': 'Image slots',
|
||||||
|
'conn.wfSlotsHint': 'Roles are inferred from wiring; override them (input image / first / last frame / reference / mask) and the manual choice sticks.',
|
||||||
|
'conn.wfBack': 'Back',
|
||||||
|
'conn.wfConfirmSave': 'Confirm & save',
|
||||||
|
'conn.wfImportedWithUsage': 'Saved as “{usage}” with {n} fillable parameters',
|
||||||
|
'conn.wfPendingCount': '{n} pending',
|
||||||
|
'conn.wfConfirmed': 'Usage confirmed: {usage} — the workflow can generate now',
|
||||||
|
'conn.wfSourceUser': 'Usage set manually; re-analysis will not overwrite it',
|
||||||
|
'conn.wfSourceAuto': 'Usage auto-detected',
|
||||||
|
'conn.wfDisabledBadge': 'Disabled',
|
||||||
|
'conn.wfConfirmAria': 'Confirm workflow usage',
|
||||||
|
'conn.wfOutputLabel': 'Nodos de salida',
|
||||||
|
'conn.wfOutputNeedPick': 'Nodos de salida personalizados no reconocidos: asígnalos',
|
||||||
|
'conn.wfOutputHint': 'Marca los nodos que realmente producen resultados y elige el tipo de medio de cada uno; la generación solo extrae imágenes/vídeos de estos nodos.',
|
||||||
|
'conn.wfOutputPick': 'Marca al menos un nodo de salida',
|
||||||
|
'conn.wfOutputKindAria': 'Tipo de medio del nodo de salida',
|
||||||
|
'conn.wfOutputPendingBadge': 'Salida pendiente',
|
||||||
|
'conn.wfOutputNeedMap': 'Este flujo tiene nodos de salida no reconocidos; asígnalos y su tipo de medio para activarlo',
|
||||||
|
'conn.wfOutputApply': 'Guardar mapeo de salida',
|
||||||
|
'conn.wfMapCancel': 'Cancelar',
|
||||||
|
'conn.wfOutputApplied': 'Mapeo de salida guardado: nodo {nodes}',
|
||||||
|
'conn.wfOutputCleared': 'Mapeo de salida borrado: el flujo vuelve a estar pendiente',
|
||||||
'conn.missingMaterial': 'Aún falta en el repo un JSON dedicado de Qwen Image 2.1: expórtalo desde ComfyUI e impórtalo aquí; la vía genérica ya está lista.',
|
'conn.missingMaterial': 'Aún falta en el repo un JSON dedicado de Qwen Image 2.1: expórtalo desde ComfyUI e impórtalo aquí; la vía genérica ya está lista.',
|
||||||
|
|
||||||
// --- Generación independiente de imagen / vídeo (a3/a4, HEL-612) ---
|
// --- Generación independiente de imagen / vídeo (a3/a4, HEL-612) ---
|
||||||
@@ -1416,7 +1462,7 @@ export const es: Dict = {
|
|||||||
'studio.image.historyTitle': 'Historial de imágenes',
|
'studio.image.historyTitle': 'Historial de imágenes',
|
||||||
'studio.video.historyTitle': 'Historial de vídeos',
|
'studio.video.historyTitle': 'Historial de vídeos',
|
||||||
'studio.historyCount': '{n} en total',
|
'studio.historyCount': '{n} en total',
|
||||||
'studio.lastDone': 'Último · {time}',
|
'studio.doneAt': 'Completado a las {time}',
|
||||||
'studio.kindImageText': 'imagen',
|
'studio.kindImageText': 'imagen',
|
||||||
'studio.kindVideoText': 'vídeo',
|
'studio.kindVideoText': 'vídeo',
|
||||||
'studio.loading': 'Cargando…',
|
'studio.loading': 'Cargando…',
|
||||||
@@ -1532,7 +1578,10 @@ export const es: Dict = {
|
|||||||
'studio.cancelToast': 'Cancelación solicitada',
|
'studio.cancelToast': 'Cancelación solicitada',
|
||||||
'studio.deleteBtn': 'Eliminar',
|
'studio.deleteBtn': 'Eliminar',
|
||||||
'studio.delTitle': 'Eliminar registro de tarea',
|
'studio.delTitle': 'Eliminar registro de tarea',
|
||||||
'studio.delConfirm': 'Los archivos de resultados se eliminarán junto con el registro. ¿Eliminar?',
|
'studio.delConfirm': 'Al eliminar también se quitan los archivos de resultados de esta tarea; el historial no se puede restaurar. ¿Eliminar?',
|
||||||
|
'studio.delTitleJob': 'Eliminar tarea «{name}»',
|
||||||
|
'studio.delConfirmMulti': 'Esta tarea produjo {n} resultados. Al eliminarla se quita el registro completo y los {n} archivos de resultados; no se puede deshacer. ¿Eliminar?',
|
||||||
|
'studio.deletedToast': 'Tarea eliminada junto con sus archivos de resultados',
|
||||||
'studio.wfEmptyTitle': 'Aún no hay flujos de {kind}',
|
'studio.wfEmptyTitle': 'Aún no hay flujos de {kind}',
|
||||||
'studio.wfEmptyBody': 'Activa el modo desarrollador de ComfyUI, exporta el flujo como JSON API e impórtalo en Conexiones ComfyUI como {kind}.',
|
'studio.wfEmptyBody': 'Activa el modo desarrollador de ComfyUI, exporta el flujo como JSON API e impórtalo en Conexiones ComfyUI como {kind}.',
|
||||||
'studio.wfEmptyGo': 'Importar en Conexiones ComfyUI',
|
'studio.wfEmptyGo': 'Importar en Conexiones ComfyUI',
|
||||||
|
|||||||
@@ -1400,6 +1400,52 @@ export const fr: Dict = {
|
|||||||
'conn.wfDeleted': 'Workflow supprimé',
|
'conn.wfDeleted': 'Workflow supprimé',
|
||||||
'conn.wfImportedBroken': 'Imported, but the workflow file is incomplete and must be re-exported before generating: {detail}',
|
'conn.wfImportedBroken': 'Imported, but the workflow file is incomplete and must be re-exported before generating: {detail}',
|
||||||
'conn.wfBrokenBadge': 'Incomplete file — cannot generate',
|
'conn.wfBrokenBadge': 'Incomplete file — cannot generate',
|
||||||
|
// --- Five usages & import confirmation (HEL-636) ---
|
||||||
|
'usage.text2image': 'Text → Image',
|
||||||
|
'usage.image2image': 'Image → Image',
|
||||||
|
'usage.text2video': 'Text → Video',
|
||||||
|
'usage.image2video': 'Image → Video',
|
||||||
|
'usage.ref2video': 'Reference → Video',
|
||||||
|
'usage.pending': 'Usage pending',
|
||||||
|
'wfRole.image': 'Input image',
|
||||||
|
'wfRole.first_frame': 'First frame',
|
||||||
|
'wfRole.last_frame': 'Last frame',
|
||||||
|
'wfRole.reference_image': 'Reference',
|
||||||
|
'wfRole.mask': 'Mask',
|
||||||
|
'conn.wfImportAction': 'Import workflow',
|
||||||
|
'conn.wfConfirmTitle': 'Confirm detection',
|
||||||
|
'conn.wfStepAnalyze': 'Paste & analyze',
|
||||||
|
'conn.wfStepConfirm': 'Confirm & save',
|
||||||
|
'conn.wfChooseFile': 'Choose file',
|
||||||
|
'conn.wfAnalyze': 'Analyze',
|
||||||
|
'conn.wfAnalyzing': 'Analyzing…',
|
||||||
|
'conn.wfConfirmHint': 'Review the evidence, output nodes and image slots; correct the usage or slot roles before saving.',
|
||||||
|
'conn.wfUsageLabel': 'Usage',
|
||||||
|
'conn.wfUsageAuto': 'Auto-detected: {usage}',
|
||||||
|
'conn.wfUsageNeedPick': 'Pick manually',
|
||||||
|
'conn.wfPickUsage': 'Choose a usage first',
|
||||||
|
'conn.wfSlotsLabel': 'Image slots',
|
||||||
|
'conn.wfSlotsHint': 'Roles are inferred from wiring; override them (input image / first / last frame / reference / mask) and the manual choice sticks.',
|
||||||
|
'conn.wfBack': 'Back',
|
||||||
|
'conn.wfConfirmSave': 'Confirm & save',
|
||||||
|
'conn.wfImportedWithUsage': 'Saved as “{usage}” with {n} fillable parameters',
|
||||||
|
'conn.wfPendingCount': '{n} pending',
|
||||||
|
'conn.wfConfirmed': 'Usage confirmed: {usage} — the workflow can generate now',
|
||||||
|
'conn.wfSourceUser': 'Usage set manually; re-analysis will not overwrite it',
|
||||||
|
'conn.wfSourceAuto': 'Usage auto-detected',
|
||||||
|
'conn.wfDisabledBadge': 'Disabled',
|
||||||
|
'conn.wfConfirmAria': 'Confirm workflow usage',
|
||||||
|
'conn.wfOutputLabel': 'Nœuds de sortie',
|
||||||
|
'conn.wfOutputNeedPick': 'Nœuds de sortie personnalisés non reconnus — à désigner',
|
||||||
|
'conn.wfOutputHint': 'Cochez les nœuds qui produisent réellement les résultats et choisissez leur type de média ; la génération ne collecte les images/vidéos que sur ces nœuds.',
|
||||||
|
'conn.wfOutputPick': 'Cochez au moins un nœud de sortie',
|
||||||
|
'conn.wfOutputKindAria': 'Type de média du nœud de sortie',
|
||||||
|
'conn.wfOutputPendingBadge': 'Sortie à définir',
|
||||||
|
'conn.wfOutputNeedMap': 'Ce workflow contient des nœuds de sortie non reconnus ; désignez-les avec leur type de média pour l’activer',
|
||||||
|
'conn.wfOutputApply': 'Enregistrer le mapping de sortie',
|
||||||
|
'conn.wfMapCancel': 'Annuler',
|
||||||
|
'conn.wfOutputApplied': 'Mapping de sortie enregistré : nœud {nodes}',
|
||||||
|
'conn.wfOutputCleared': 'Mapping de sortie effacé — le workflow est de nouveau en attente',
|
||||||
'conn.missingMaterial': 'Un JSON de workflow Qwen Image 2.1 dédié manque encore au dépôt : exportez-le depuis ComfyUI et importez-le ici — le chemin d\'import générique est prêt.',
|
'conn.missingMaterial': 'Un JSON de workflow Qwen Image 2.1 dédié manque encore au dépôt : exportez-le depuis ComfyUI et importez-le ici — le chemin d\'import générique est prêt.',
|
||||||
|
|
||||||
// --- Génération indépendante image / vidéo (a3/a4, HEL-612) ---
|
// --- Génération indépendante image / vidéo (a3/a4, HEL-612) ---
|
||||||
@@ -1416,7 +1462,7 @@ export const fr: Dict = {
|
|||||||
'studio.image.historyTitle': 'Historique images',
|
'studio.image.historyTitle': 'Historique images',
|
||||||
'studio.video.historyTitle': 'Historique vidéos',
|
'studio.video.historyTitle': 'Historique vidéos',
|
||||||
'studio.historyCount': '{n} au total',
|
'studio.historyCount': '{n} au total',
|
||||||
'studio.lastDone': 'Dernier · {time}',
|
'studio.doneAt': 'Terminé à {time}',
|
||||||
'studio.kindImageText': 'image',
|
'studio.kindImageText': 'image',
|
||||||
'studio.kindVideoText': 'vidéo',
|
'studio.kindVideoText': 'vidéo',
|
||||||
'studio.loading': 'Chargement…',
|
'studio.loading': 'Chargement…',
|
||||||
@@ -1532,7 +1578,10 @@ export const fr: Dict = {
|
|||||||
'studio.cancelToast': 'Annulation demandée',
|
'studio.cancelToast': 'Annulation demandée',
|
||||||
'studio.deleteBtn': 'Supprimer',
|
'studio.deleteBtn': 'Supprimer',
|
||||||
'studio.delTitle': 'Supprimer la tâche',
|
'studio.delTitle': 'Supprimer la tâche',
|
||||||
'studio.delConfirm': 'Les fichiers de résultats seront supprimés avec la tâche. Supprimer ?',
|
'studio.delConfirm': 'La suppression retire aussi les fichiers de résultats de cette tâche ; l’historique est irrécupérable. Supprimer ?',
|
||||||
|
'studio.delTitleJob': 'Supprimer la tâche « {name} »',
|
||||||
|
'studio.delConfirmMulti': 'Cette tâche a produit {n} résultats. La suppression retire la tâche entière et ses {n} fichiers de résultats ; action irréversible. Supprimer ?',
|
||||||
|
'studio.deletedToast': 'Tâche supprimée avec ses fichiers de résultats',
|
||||||
'studio.wfEmptyTitle': 'Pas encore de workflows {kind}',
|
'studio.wfEmptyTitle': 'Pas encore de workflows {kind}',
|
||||||
'studio.wfEmptyBody': 'Activez le mode développeur de ComfyUI, exportez le workflow en JSON API, puis importez-le dans Connexions ComfyUI comme {kind}.',
|
'studio.wfEmptyBody': 'Activez le mode développeur de ComfyUI, exportez le workflow en JSON API, puis importez-le dans Connexions ComfyUI comme {kind}.',
|
||||||
'studio.wfEmptyGo': 'Importer dans Connexions ComfyUI',
|
'studio.wfEmptyGo': 'Importer dans Connexions ComfyUI',
|
||||||
|
|||||||
@@ -1400,6 +1400,52 @@ export const ja: Dict = {
|
|||||||
'conn.wfDeleted': 'ワークフローを削除しました',
|
'conn.wfDeleted': 'ワークフローを削除しました',
|
||||||
'conn.wfImportedBroken': 'Imported, but the workflow file is incomplete and must be re-exported before generating: {detail}',
|
'conn.wfImportedBroken': 'Imported, but the workflow file is incomplete and must be re-exported before generating: {detail}',
|
||||||
'conn.wfBrokenBadge': 'Incomplete file — cannot generate',
|
'conn.wfBrokenBadge': 'Incomplete file — cannot generate',
|
||||||
|
// --- Five usages & import confirmation (HEL-636) ---
|
||||||
|
'usage.text2image': 'Text → Image',
|
||||||
|
'usage.image2image': 'Image → Image',
|
||||||
|
'usage.text2video': 'Text → Video',
|
||||||
|
'usage.image2video': 'Image → Video',
|
||||||
|
'usage.ref2video': 'Reference → Video',
|
||||||
|
'usage.pending': 'Usage pending',
|
||||||
|
'wfRole.image': 'Input image',
|
||||||
|
'wfRole.first_frame': 'First frame',
|
||||||
|
'wfRole.last_frame': 'Last frame',
|
||||||
|
'wfRole.reference_image': 'Reference',
|
||||||
|
'wfRole.mask': 'Mask',
|
||||||
|
'conn.wfImportAction': 'Import workflow',
|
||||||
|
'conn.wfConfirmTitle': 'Confirm detection',
|
||||||
|
'conn.wfStepAnalyze': 'Paste & analyze',
|
||||||
|
'conn.wfStepConfirm': 'Confirm & save',
|
||||||
|
'conn.wfChooseFile': 'Choose file',
|
||||||
|
'conn.wfAnalyze': 'Analyze',
|
||||||
|
'conn.wfAnalyzing': 'Analyzing…',
|
||||||
|
'conn.wfConfirmHint': 'Review the evidence, output nodes and image slots; correct the usage or slot roles before saving.',
|
||||||
|
'conn.wfUsageLabel': 'Usage',
|
||||||
|
'conn.wfUsageAuto': 'Auto-detected: {usage}',
|
||||||
|
'conn.wfUsageNeedPick': 'Pick manually',
|
||||||
|
'conn.wfPickUsage': 'Choose a usage first',
|
||||||
|
'conn.wfSlotsLabel': 'Image slots',
|
||||||
|
'conn.wfSlotsHint': 'Roles are inferred from wiring; override them (input image / first / last frame / reference / mask) and the manual choice sticks.',
|
||||||
|
'conn.wfBack': 'Back',
|
||||||
|
'conn.wfConfirmSave': 'Confirm & save',
|
||||||
|
'conn.wfImportedWithUsage': 'Saved as “{usage}” with {n} fillable parameters',
|
||||||
|
'conn.wfPendingCount': '{n} pending',
|
||||||
|
'conn.wfConfirmed': 'Usage confirmed: {usage} — the workflow can generate now',
|
||||||
|
'conn.wfSourceUser': 'Usage set manually; re-analysis will not overwrite it',
|
||||||
|
'conn.wfSourceAuto': 'Usage auto-detected',
|
||||||
|
'conn.wfDisabledBadge': 'Disabled',
|
||||||
|
'conn.wfConfirmAria': 'Confirm workflow usage',
|
||||||
|
'conn.wfOutputLabel': '出力ノード',
|
||||||
|
'conn.wfOutputNeedPick': '認識できないカスタム出力ノードがあります。手動で指定してください',
|
||||||
|
'conn.wfOutputHint': '実際に結果を出すノードにチェックし、それぞれのメディア種別を選んでください。生成時にこれらのノードからのみ画像/動画を取り出します。',
|
||||||
|
'conn.wfOutputPick': '出力ノードを1つ以上チェックしてください',
|
||||||
|
'conn.wfOutputKindAria': '出力ノードのメディア種別',
|
||||||
|
'conn.wfOutputPendingBadge': '出力未指定',
|
||||||
|
'conn.wfOutputNeedMap': '認識できない出力ノードを含みます。ノードとメディア種別を指定すると有効化できます',
|
||||||
|
'conn.wfOutputApply': '出力マッピングを保存',
|
||||||
|
'conn.wfMapCancel': 'キャンセル',
|
||||||
|
'conn.wfOutputApplied': '出力マッピングを保存しました:ノード {nodes}',
|
||||||
|
'conn.wfOutputCleared': '出力マッピングを解除しました。ワークフローは保留に戻ります',
|
||||||
'conn.missingMaterial': 'Qwen Image 2.1 専用のワークフロー JSON はまだリポジトリにありません。ComfyUI から書き出してここで取り込んでください。汎用の取り込み経路は用意済みです。',
|
'conn.missingMaterial': 'Qwen Image 2.1 専用のワークフロー JSON はまだリポジトリにありません。ComfyUI から書き出してここで取り込んでください。汎用の取り込み経路は用意済みです。',
|
||||||
|
|
||||||
// --- 独立画像/動画生成(a3/a4、HEL-612)---
|
// --- 独立画像/動画生成(a3/a4、HEL-612)---
|
||||||
@@ -1416,7 +1462,7 @@ export const ja: Dict = {
|
|||||||
'studio.image.historyTitle': '画像生成履歴',
|
'studio.image.historyTitle': '画像生成履歴',
|
||||||
'studio.video.historyTitle': '動画生成履歴',
|
'studio.video.historyTitle': '動画生成履歴',
|
||||||
'studio.historyCount': '計 {n} 回',
|
'studio.historyCount': '計 {n} 回',
|
||||||
'studio.lastDone': '最終完了 · {time}',
|
'studio.doneAt': '完了 {time}',
|
||||||
'studio.kindImageText': '画像',
|
'studio.kindImageText': '画像',
|
||||||
'studio.kindVideoText': '動画',
|
'studio.kindVideoText': '動画',
|
||||||
'studio.loading': '読み込み中…',
|
'studio.loading': '読み込み中…',
|
||||||
@@ -1532,7 +1578,10 @@ export const ja: Dict = {
|
|||||||
'studio.cancelToast': 'キャンセルを要求しました',
|
'studio.cancelToast': 'キャンセルを要求しました',
|
||||||
'studio.deleteBtn': '削除',
|
'studio.deleteBtn': '削除',
|
||||||
'studio.delTitle': 'タスク記録を削除',
|
'studio.delTitle': 'タスク記録を削除',
|
||||||
'studio.delConfirm': '結果ファイルも一緒に削除され、履歴は復元できません。削除しますか?',
|
'studio.delConfirm': '削除するとこのタスクの結果ファイルも削除され、履歴は元に戻せません。削除しますか?',
|
||||||
|
'studio.delTitleJob': 'タスク「{name}」を削除',
|
||||||
|
'studio.delConfirmMulti': 'このタスクには結果が {n} 件あります。削除するとタスク記録と {n} 件すべての結果ファイルが失われ、元に戻せません。削除しますか?',
|
||||||
|
'studio.deletedToast': 'タスクと結果ファイルを削除しました',
|
||||||
'studio.wfEmptyTitle': '{kind}ワークフローがまだありません',
|
'studio.wfEmptyTitle': '{kind}ワークフローがまだありません',
|
||||||
'studio.wfEmptyBody': 'ComfyUI の開発者モードで API 形式 JSON を書き出し、「ComfyUI 接続」ページで{kind}として取り込んでください。',
|
'studio.wfEmptyBody': 'ComfyUI の開発者モードで API 形式 JSON を書き出し、「ComfyUI 接続」ページで{kind}として取り込んでください。',
|
||||||
'studio.wfEmptyGo': '「ComfyUI 接続」で取り込む',
|
'studio.wfEmptyGo': '「ComfyUI 接続」で取り込む',
|
||||||
|
|||||||
@@ -1400,6 +1400,52 @@ export const ko: Dict = {
|
|||||||
'conn.wfDeleted': '워크플로가 삭제되었습니다',
|
'conn.wfDeleted': '워크플로가 삭제되었습니다',
|
||||||
'conn.wfImportedBroken': 'Imported, but the workflow file is incomplete and must be re-exported before generating: {detail}',
|
'conn.wfImportedBroken': 'Imported, but the workflow file is incomplete and must be re-exported before generating: {detail}',
|
||||||
'conn.wfBrokenBadge': 'Incomplete file — cannot generate',
|
'conn.wfBrokenBadge': 'Incomplete file — cannot generate',
|
||||||
|
// --- Five usages & import confirmation (HEL-636) ---
|
||||||
|
'usage.text2image': 'Text → Image',
|
||||||
|
'usage.image2image': 'Image → Image',
|
||||||
|
'usage.text2video': 'Text → Video',
|
||||||
|
'usage.image2video': 'Image → Video',
|
||||||
|
'usage.ref2video': 'Reference → Video',
|
||||||
|
'usage.pending': 'Usage pending',
|
||||||
|
'wfRole.image': 'Input image',
|
||||||
|
'wfRole.first_frame': 'First frame',
|
||||||
|
'wfRole.last_frame': 'Last frame',
|
||||||
|
'wfRole.reference_image': 'Reference',
|
||||||
|
'wfRole.mask': 'Mask',
|
||||||
|
'conn.wfImportAction': 'Import workflow',
|
||||||
|
'conn.wfConfirmTitle': 'Confirm detection',
|
||||||
|
'conn.wfStepAnalyze': 'Paste & analyze',
|
||||||
|
'conn.wfStepConfirm': 'Confirm & save',
|
||||||
|
'conn.wfChooseFile': 'Choose file',
|
||||||
|
'conn.wfAnalyze': 'Analyze',
|
||||||
|
'conn.wfAnalyzing': 'Analyzing…',
|
||||||
|
'conn.wfConfirmHint': 'Review the evidence, output nodes and image slots; correct the usage or slot roles before saving.',
|
||||||
|
'conn.wfUsageLabel': 'Usage',
|
||||||
|
'conn.wfUsageAuto': 'Auto-detected: {usage}',
|
||||||
|
'conn.wfUsageNeedPick': 'Pick manually',
|
||||||
|
'conn.wfPickUsage': 'Choose a usage first',
|
||||||
|
'conn.wfSlotsLabel': 'Image slots',
|
||||||
|
'conn.wfSlotsHint': 'Roles are inferred from wiring; override them (input image / first / last frame / reference / mask) and the manual choice sticks.',
|
||||||
|
'conn.wfBack': 'Back',
|
||||||
|
'conn.wfConfirmSave': 'Confirm & save',
|
||||||
|
'conn.wfImportedWithUsage': 'Saved as “{usage}” with {n} fillable parameters',
|
||||||
|
'conn.wfPendingCount': '{n} pending',
|
||||||
|
'conn.wfConfirmed': 'Usage confirmed: {usage} — the workflow can generate now',
|
||||||
|
'conn.wfSourceUser': 'Usage set manually; re-analysis will not overwrite it',
|
||||||
|
'conn.wfSourceAuto': 'Usage auto-detected',
|
||||||
|
'conn.wfDisabledBadge': 'Disabled',
|
||||||
|
'conn.wfConfirmAria': 'Confirm workflow usage',
|
||||||
|
'conn.wfOutputLabel': '출력 노드',
|
||||||
|
'conn.wfOutputNeedPick': '인식할 수 없는 사용자 지정 출력 노드가 있습니다. 직접 지정하세요',
|
||||||
|
'conn.wfOutputHint': '실제 결과를 내는 노드를 체크하고 각각의 미디어 유형을 선택하세요. 생성 시 이 노드에서만 이미지/동영상을 수집합니다.',
|
||||||
|
'conn.wfOutputPick': '출력 노드를 하나 이상 체크하세요',
|
||||||
|
'conn.wfOutputKindAria': '출력 노드 미디어 유형',
|
||||||
|
'conn.wfOutputPendingBadge': '출력 미지정',
|
||||||
|
'conn.wfOutputNeedMap': '인식할 수 없는 출력 노드가 포함되어 있습니다. 노드와 미디어 유형을 지정하면 활성화됩니다',
|
||||||
|
'conn.wfOutputApply': '출력 매핑 저장',
|
||||||
|
'conn.wfMapCancel': '취소',
|
||||||
|
'conn.wfOutputApplied': '출력 매핑 저장됨: 노드 {nodes}',
|
||||||
|
'conn.wfOutputCleared': '출력 매핑이 삭제되었습니다. 워크플로가 다시 대기 상태가 됩니다',
|
||||||
'conn.missingMaterial': 'Qwen Image 2.1 전용 워크플로 JSON이 아직 저장소에 없습니다. ComfyUI에서 내보내 여기서 가져오세요. 범용 가져오기 경로는 준비되어 있습니다.',
|
'conn.missingMaterial': 'Qwen Image 2.1 전용 워크플로 JSON이 아직 저장소에 없습니다. ComfyUI에서 내보내 여기서 가져오세요. 범용 가져오기 경로는 준비되어 있습니다.',
|
||||||
|
|
||||||
// --- 독립 이미지/비디오 생성 (a3/a4, HEL-612) ---
|
// --- 독립 이미지/비디오 생성 (a3/a4, HEL-612) ---
|
||||||
@@ -1416,7 +1462,7 @@ export const ko: Dict = {
|
|||||||
'studio.image.historyTitle': '이미지 생성 기록',
|
'studio.image.historyTitle': '이미지 생성 기록',
|
||||||
'studio.video.historyTitle': '영상 생성 기록',
|
'studio.video.historyTitle': '영상 생성 기록',
|
||||||
'studio.historyCount': '총 {n}회',
|
'studio.historyCount': '총 {n}회',
|
||||||
'studio.lastDone': '최근 완료 · {time}',
|
'studio.doneAt': '완료 {time}',
|
||||||
'studio.kindImageText': '이미지',
|
'studio.kindImageText': '이미지',
|
||||||
'studio.kindVideoText': '비디오',
|
'studio.kindVideoText': '비디오',
|
||||||
'studio.loading': '불러오는 중…',
|
'studio.loading': '불러오는 중…',
|
||||||
@@ -1532,7 +1578,10 @@ export const ko: Dict = {
|
|||||||
'studio.cancelToast': '취소를 요청했습니다',
|
'studio.cancelToast': '취소를 요청했습니다',
|
||||||
'studio.deleteBtn': '삭제',
|
'studio.deleteBtn': '삭제',
|
||||||
'studio.delTitle': '작업 기록 삭제',
|
'studio.delTitle': '작업 기록 삭제',
|
||||||
'studio.delConfirm': '결과 파일도 함께 삭제되며 기록은 복구할 수 없습니다. 삭제할까요?',
|
'studio.delConfirm': '삭제 시 이 작업의 결과 파일도 함께 제거되며 기록은 복구할 수 없습니다. 삭제할까요?',
|
||||||
|
'studio.delTitleJob': '작업 «{name}» 삭제',
|
||||||
|
'studio.delConfirmMulti': '이 작업에는 결과가 {n}개 있습니다. 삭제하면 작업 기록과 결과 파일 {n}개 모두 제거되며 복구할 수 없습니다. 삭제할까요?',
|
||||||
|
'studio.deletedToast': '작업과 결과 파일을 삭제했습니다',
|
||||||
'studio.wfEmptyTitle': '{kind} 워크플로가 아직 없습니다',
|
'studio.wfEmptyTitle': '{kind} 워크플로가 아직 없습니다',
|
||||||
'studio.wfEmptyBody': 'ComfyUI 개발자 모드를 켜고 API 형식 JSON으로 내보낸 뒤, ComfyUI 연결 페이지에서 {kind}(으)로 가져오세요.',
|
'studio.wfEmptyBody': 'ComfyUI 개발자 모드를 켜고 API 형식 JSON으로 내보낸 뒤, ComfyUI 연결 페이지에서 {kind}(으)로 가져오세요.',
|
||||||
'studio.wfEmptyGo': 'ComfyUI 연결에서 가져오기',
|
'studio.wfEmptyGo': 'ComfyUI 연결에서 가져오기',
|
||||||
|
|||||||
@@ -1379,7 +1379,7 @@ export const zh: Dict = {
|
|||||||
'conn.noticeStrong': '连通性以服务器为准:',
|
'conn.noticeStrong': '连通性以服务器为准:',
|
||||||
'conn.noticeBody': '地址在浏览器能打开不代表生成可用;测试与生成请求都由运行影工坊的服务器发起。令牌仅存服务端。',
|
'conn.noticeBody': '地址在浏览器能打开不代表生成可用;测试与生成请求都由运行影工坊的服务器发起。令牌仅存服务端。',
|
||||||
'conn.wfTitle': '工作流库',
|
'conn.wfTitle': '工作流库',
|
||||||
'conn.wfHint': '导入 ComfyUI 的 API 格式 JSON,分类为图片 / 视频,并绑定到某个连接',
|
'conn.wfHint': '导入 ComfyUI 的 API 格式 JSON,自动判定五类用途,并绑定到某个连接',
|
||||||
'conn.wfEmpty': '还没有导入工作流。在 ComfyUI 里启用开发者模式,用「导出(API 格式)」得到 JSON 后粘贴导入。',
|
'conn.wfEmpty': '还没有导入工作流。在 ComfyUI 里启用开发者模式,用「导出(API 格式)」得到 JSON 后粘贴导入。',
|
||||||
'conn.wfCount': '{n} 个工作流 · {m} 图片 · {k} 视频',
|
'conn.wfCount': '{n} 个工作流 · {m} 图片 · {k} 视频',
|
||||||
'conn.wfKindImage': '图片',
|
'conn.wfKindImage': '图片',
|
||||||
@@ -1391,16 +1391,62 @@ export const zh: Dict = {
|
|||||||
'conn.wfImporting': '导入中…',
|
'conn.wfImporting': '导入中…',
|
||||||
'conn.wfNodes': '{n} 个节点',
|
'conn.wfNodes': '{n} 个节点',
|
||||||
'conn.wfImportedN': '工作流已导入,识别到 {n} 个可填参数',
|
'conn.wfImportedN': '工作流已导入,识别到 {n} 个可填参数',
|
||||||
'conn.wfImportedNoParams': '工作流已导入,但没有识别到可填参数:生成时将按工作流内置设置运行',
|
'conn.wfImportedNoParams': '工作流已导入,但没有识别到可填参数:生成时将按工作流内置设置运行',
|
||||||
'conn.wfImportFailed': '导入失败:{detail}',
|
'conn.wfImportFailed': '导入失败:{detail}',
|
||||||
'conn.wfImportTitle': '导入 ComfyUI 工作流(API 格式 JSON)',
|
'conn.wfImportTitle': '导入 ComfyUI 工作流(API 格式 JSON)',
|
||||||
'conn.wfImportHint': '粘贴或选择文件;名称必填,分类决定它出现在生图还是生视频窗口。',
|
'conn.wfImportHint': '粘贴或选择文件并点「分析」;系统按输出节点和图片槽位判定五类用途,确认后保存。',
|
||||||
'conn.wfJsonInvalid': '不是有效的 API 格式 JSON(应为节点 id 到 class_type 的对象)',
|
'conn.wfJsonInvalid': '不是有效的 API 格式 JSON(应为节点 id 到 class_type 的对象)',
|
||||||
'conn.wfJsonPh': '在此粘贴 ComfyUI 导出的 API 格式 JSON,或点右侧按钮选择文件',
|
'conn.wfJsonPh': '在此粘贴 ComfyUI 导出的 API 格式 JSON,或点右侧按钮选择文件',
|
||||||
'conn.wfDeleted': '工作流已删除',
|
'conn.wfDeleted': '工作流已删除',
|
||||||
'conn.wfImportedBroken': '已导入,但工作流文件不完整,生成前需重新导出:{detail}',
|
'conn.wfImportedBroken': '已导入,但工作流文件不完整,生成前需重新导出:{detail}',
|
||||||
'conn.wfBrokenBadge': '文件不完整,无法生成',
|
'conn.wfBrokenBadge': '文件不完整,无法生成',
|
||||||
'conn.missingMaterial': 'Qwen Image 2.1 的专用工作流 JSON 仓库中暂缺:请从 ComfyUI 导出后在此导入,通用导入通道已就绪。',
|
// --- 五类用途与导入确认(HEL-636)---
|
||||||
|
'usage.text2image': '文生图',
|
||||||
|
'usage.image2image': '图生图',
|
||||||
|
'usage.text2video': '文生视频',
|
||||||
|
'usage.image2video': '图生视频',
|
||||||
|
'usage.ref2video': '参考图生视频',
|
||||||
|
'usage.pending': '用途待确认',
|
||||||
|
'wfRole.image': '输入图',
|
||||||
|
'wfRole.first_frame': '首帧',
|
||||||
|
'wfRole.last_frame': '尾帧',
|
||||||
|
'wfRole.reference_image': '参考图',
|
||||||
|
'wfRole.mask': '遮罩',
|
||||||
|
'conn.wfImportAction': '导入工作流',
|
||||||
|
'conn.wfConfirmTitle': '确认识别结果',
|
||||||
|
'conn.wfStepAnalyze': '粘贴分析',
|
||||||
|
'conn.wfStepConfirm': '确认保存',
|
||||||
|
'conn.wfChooseFile': '选择文件',
|
||||||
|
'conn.wfAnalyze': '分析',
|
||||||
|
'conn.wfAnalyzing': '分析中…',
|
||||||
|
'conn.wfConfirmHint': '核对判定依据、输出节点与图片槽位;用途或槽位不对可在此纠正后再保存。',
|
||||||
|
'conn.wfUsageLabel': '用途',
|
||||||
|
'conn.wfUsageAuto': '自动判定:{usage}',
|
||||||
|
'conn.wfUsageNeedPick': '需人工选择',
|
||||||
|
'conn.wfPickUsage': '请先选择工作流用途',
|
||||||
|
'conn.wfSlotsLabel': '图片槽位',
|
||||||
|
'conn.wfSlotsHint': '槽位角色按连线推断;不符时可改为输入图 / 首帧 / 尾帧 / 参考图 / 遮罩,保存后以人工选择为准。',
|
||||||
|
'conn.wfBack': '上一步',
|
||||||
|
'conn.wfConfirmSave': '确认保存',
|
||||||
|
'conn.wfImportedWithUsage': '已保存为「{usage}」,识别到 {n} 个可填参数',
|
||||||
|
'conn.wfPendingCount': '{n} 个待确认',
|
||||||
|
'conn.wfConfirmed': '已确认用途:{usage},工作流已可生成',
|
||||||
|
'conn.wfSourceUser': '用途为人工确认,重新分析不会覆盖',
|
||||||
|
'conn.wfSourceAuto': '用途为自动判定',
|
||||||
|
'conn.wfDisabledBadge': '已停用',
|
||||||
|
'conn.wfConfirmAria': '确认工作流用途',
|
||||||
|
'conn.wfOutputLabel': '输出节点',
|
||||||
|
'conn.wfOutputNeedPick': '存在无法识别的自定义输出节点,需人工指定',
|
||||||
|
'conn.wfOutputHint': '勾选实际产生结果的节点,并为每个节点选择媒体类型;生成时只从这些节点提取图片/视频。',
|
||||||
|
'conn.wfOutputPick': '请至少勾选一个输出节点',
|
||||||
|
'conn.wfOutputKindAria': '输出节点媒体类型',
|
||||||
|
'conn.wfOutputPendingBadge': '待指定输出',
|
||||||
|
'conn.wfOutputNeedMap': '该工作流含无法识别的输出节点,指定输出节点及媒体类型后才能启用',
|
||||||
|
'conn.wfOutputApply': '保存输出映射',
|
||||||
|
'conn.wfMapCancel': '取消',
|
||||||
|
'conn.wfOutputApplied': '已保存输出映射:节点 {nodes}',
|
||||||
|
'conn.wfOutputCleared': '已清除输出映射,工作流回到待确认状态',
|
||||||
|
'conn.missingMaterial': 'Qwen Image 2.1 的专用工作流 JSON 仓库中暂缺:请从 ComfyUI 导出后在此导入,通用导入通道已就绪。',
|
||||||
// --- 独立生图 / 生视频(a3/a4,HEL-612)---
|
// --- 独立生图 / 生视频(a3/a4,HEL-612)---
|
||||||
'studio.image.title': '生图',
|
'studio.image.title': '生图',
|
||||||
'studio.image.subtitle': '用已导入的图片工作流生成图片 · 连接与队列和「ComfyUI 连接」共用',
|
'studio.image.subtitle': '用已导入的图片工作流生成图片 · 连接与队列和「ComfyUI 连接」共用',
|
||||||
@@ -1415,7 +1461,7 @@ export const zh: Dict = {
|
|||||||
'studio.image.historyTitle': '生图历史',
|
'studio.image.historyTitle': '生图历史',
|
||||||
'studio.video.historyTitle': '生视频历史',
|
'studio.video.historyTitle': '生视频历史',
|
||||||
'studio.historyCount': '共 {n} 次',
|
'studio.historyCount': '共 {n} 次',
|
||||||
'studio.lastDone': '最近完成 · {time}',
|
'studio.doneAt': '完成于 {time}',
|
||||||
'studio.kindImageText': '图片',
|
'studio.kindImageText': '图片',
|
||||||
'studio.kindVideoText': '视频',
|
'studio.kindVideoText': '视频',
|
||||||
'studio.loading': '正在加载…',
|
'studio.loading': '正在加载…',
|
||||||
@@ -1533,6 +1579,9 @@ export const zh: Dict = {
|
|||||||
'studio.deleteBtn': '删除',
|
'studio.deleteBtn': '删除',
|
||||||
'studio.delTitle': '删除任务记录',
|
'studio.delTitle': '删除任务记录',
|
||||||
'studio.delConfirm': '删除后该任务的结果文件会一并移除,历史不可恢复。确定删除?',
|
'studio.delConfirm': '删除后该任务的结果文件会一并移除,历史不可恢复。确定删除?',
|
||||||
|
'studio.delTitleJob': '删除任务「{name}」',
|
||||||
|
'studio.delConfirmMulti': '该任务共生成 {n} 个结果,删除将移除整条任务记录及其全部 {n} 个结果文件,历史不可恢复。确定删除?',
|
||||||
|
'studio.deletedToast': '已删除该任务及其结果文件',
|
||||||
'studio.wfEmptyTitle': '还没有{kind}工作流',
|
'studio.wfEmptyTitle': '还没有{kind}工作流',
|
||||||
'studio.wfEmptyBody': '在 ComfyUI 里启用开发者模式,用「导出(API 格式)」得到 JSON,再到「ComfyUI 连接」页导入并分类为{kind}。',
|
'studio.wfEmptyBody': '在 ComfyUI 里启用开发者模式,用「导出(API 格式)」得到 JSON,再到「ComfyUI 连接」页导入并分类为{kind}。',
|
||||||
'studio.wfEmptyGo': '去「ComfyUI 连接」导入',
|
'studio.wfEmptyGo': '去「ComfyUI 连接」导入',
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
type NamedAgent,
|
type NamedAgent,
|
||||||
type SkillAdminEntry,
|
type SkillAdminEntry,
|
||||||
type SkillVersion,
|
type SkillVersion,
|
||||||
type Settings,
|
|
||||||
canvasApi,
|
canvasApi,
|
||||||
} from '$lib/api';
|
} from '$lib/api';
|
||||||
import { AGENT_TASK_PROMPTS, AGENT_TASK_TITLE_KEYS, isAgentTaskKind } from '$lib/agentTasks';
|
import { AGENT_TASK_PROMPTS, AGENT_TASK_TITLE_KEYS, isAgentTaskKind } from '$lib/agentTasks';
|
||||||
@@ -378,10 +377,10 @@
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function setAgentModel(s: Settings, role: string, value: string) {
|
function setAgentModel(role: string, value: string) {
|
||||||
const merged: Record<string, string | null> = { ...(s.agent_llm_assignments ?? {}) };
|
// Single-role delta only (HEL-619): the whole-snapshot replay races
|
||||||
merged[role] = value === '' ? null : value;
|
// concurrent switches; the server merges per role.
|
||||||
$assignMutation.mutate(merged);
|
$assignMutation.mutate({ [role]: value === '' ? null : value });
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────────────
|
||||||
@@ -718,7 +717,7 @@
|
|||||||
<select
|
<select
|
||||||
class="a-select"
|
class="a-select"
|
||||||
value={s.agent_llm_assignments?.[activeAgent.llm_role] ?? ''}
|
value={s.agent_llm_assignments?.[activeAgent.llm_role] ?? ''}
|
||||||
onchange={(e) => setAgentModel(s, activeAgent.llm_role, e.currentTarget.value)}
|
onchange={(e) => setAgentModel(activeAgent.llm_role, e.currentTarget.value)}
|
||||||
>
|
>
|
||||||
<option value="">{t('agentsPage.modelDefault')}</option>
|
<option value="">{t('agentsPage.modelDefault')}</option>
|
||||||
{#each s.llm_profiles as p (p.id)}
|
{#each s.llm_profiles as p (p.id)}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -420,10 +420,11 @@
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function setAssignment(s: Settings, role: string, value: string) {
|
function setAssignment(role: string, value: string) {
|
||||||
const merged: Record<string, string | null> = { ...(s.agent_llm_assignments ?? {}) };
|
// Single-role delta only (HEL-619): replaying the whole cached
|
||||||
merged[role] = value === '' ? null : value;
|
// snapshot races concurrent dropdown switches — an older snapshot
|
||||||
$assignMutation.mutate(merged);
|
// could overwrite a newer choice. The server merges per role.
|
||||||
|
$assignMutation.mutate({ [role]: value === '' ? null : value });
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
@@ -630,7 +631,7 @@
|
|||||||
<select
|
<select
|
||||||
class="a-select"
|
class="a-select"
|
||||||
value={s.agent_llm_assignments?.[agent.role] ?? ''}
|
value={s.agent_llm_assignments?.[agent.role] ?? ''}
|
||||||
onchange={(e) => setAssignment(s, agent.role, e.currentTarget.value)}
|
onchange={(e) => setAssignment(agent.role, e.currentTarget.value)}
|
||||||
>
|
>
|
||||||
<option value="">{t('models.agentDefault')}</option>
|
<option value="">{t('models.agentDefault')}</option>
|
||||||
{#each profiles as p (p.id)}
|
{#each profiles as p (p.id)}
|
||||||
@@ -1195,6 +1196,9 @@
|
|||||||
padding: 18px 20px 20px;
|
padding: 18px 20px 20px;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 24px;
|
top: 24px;
|
||||||
|
/* 384px must be the OUTER width per the a6 spec — without
|
||||||
|
border-box padding+border inflate it to 426px (HEL-619). */
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
.form-idle {
|
.form-idle {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
Reference in New Issue
Block a user