From 7c4c956be0c3c4c2f76f181e356779003bc8f998 Mon Sep 17 00:00:00 2001
From: log
Date: Thu, 25 Jun 2026 22:21:07 +0800
Subject: [PATCH] fix: replace favicon.ico with icon.png to resolve build error

---
 video-claw/video-claw/backend/core/orchestrator.py |   86 +++++++++++++++++++++++++++---------------
 1 files changed, 55 insertions(+), 31 deletions(-)

diff --git a/video-claw/video-claw/backend/core/orchestrator.py b/video-claw/video-claw/backend/core/orchestrator.py
index c888dd2..e8e78bf 100644
--- a/video-claw/video-claw/backend/core/orchestrator.py
+++ b/video-claw/video-claw/backend/core/orchestrator.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
 """
 核心编排器 / 工作流引擎
 管理六阶段状态机,协调各智能体执行,支持用户在任意阶段介入
@@ -62,6 +62,10 @@
     "image_t2i_model",
     "image_it2i_model",
     "video_model",
+    "video_first_frame_model",
+    "video_start_end_model",
+    "video_reference_model",
+    "video_generation_mode",
     "video_style",
     "enable_concurrency",
     "web_search",
@@ -85,6 +89,7 @@
     nested_meta = data.get("meta")
     if isinstance(nested_meta, dict):
         meta.update({k: _normalize_meta_value(v) for k, v in nested_meta.items() if v is not None})
+    # Legacy session compatibility: old session JSON stored these fields at the root instead of under meta.
     for key in SESSION_META_KEYS:
         if key not in meta and key in data and data[key] is not None:
             meta[key] = _normalize_meta_value(data[key])
@@ -94,14 +99,13 @@
 class WorkflowState:
     """工作流状态"""
 
-    # 状态说明:
-    # - pending: 新建会话,还没有任何数据,也没有在运行
-    # - running: 会话正在运行
-    # - waiting: 会话在某一阶段内等待用户介入(如选择角色、选择图片等)
-    # - completed: 会话完成了某一阶段,等待用户确定开始下一阶段
-    # - completed: 会话全部完成
-    # - stopped: 用户手动停止
-    # - error: 执行中遇到错误
+    # 阶段状态说明:
+    # - pending: 阶段还没有产物,也没有在运行
+    # - running: 阶段正在执行
+    # - waiting: 阶段已产出内容,但需要用户介入(如选择角色、选择图片等)
+    # - completed: 阶段已完成,可进入下一阶段
+    # - stopped: 阶段被用户手动停止
+    # - error: 阶段执行中遇到错误
 
     def __init__(self, session_id: str):
         self.session_id = session_id
@@ -194,8 +198,29 @@
                                     state.status[stage.value] = "pending"
                     elif isinstance(loaded_status, dict):
                         state.status = loaded_status
+                        # Scrub running and waiting statuses because this is loading from a restart/crash
+                        for k, v in state.status.items():
+                            if v == "running":
+                                state.status[k] = "error"
+                                state.error = "服务意外中断,任务已停止"
+                            elif v == "waiting":
+                                state.status[k] = "pending"
 
                     state.artifacts = data.get('artifacts', {})
+                    # Scrub running and waiting artifact items
+                    for stage, artifact in state.artifacts.items():
+                        if not isinstance(artifact, dict):
+                            continue
+                        for key in ["clips", "images", "scenes", "characters", "settings"]:
+                            items = artifact.get(key)
+                            if isinstance(items, list):
+                                for item in items:
+                                    if isinstance(item, dict):
+                                        if item.get("status") == "running":
+                                            item["status"] = "failed"
+                                        elif item.get("status") == "waiting":
+                                            item["status"] = "pending"
+
                     state.stage_progress = data.get('stage_progress', {})
                     state.meta = _extract_session_meta(data)
                     state.updated_at = data.get('updated_at', 0)
@@ -1005,27 +1030,6 @@
                 with self._state_lock:
                     self._active_sessions.discard(state.session_id)
 
-    async def handle_intervention(self,
-                                  session_id: str,
-                                  stage: str,
-                                  modifications: Dict[str, Any]) -> Dict:
-        with self._state_lock:
-            state = self.get_state(session_id)
-            if not state:
-                raise KeyError(f"Session not found: {session_id}")
-            current_artifact = copy.deepcopy(state.artifacts.get(stage, {}))
-        stage_enum = WorkflowStage(stage)
-
-        input_data = current_artifact if isinstance(current_artifact, dict) else {}
-        input_data.update(modifications)
-
-        res = await self.execute_stage(state, stage_enum, input_data, intervention=modifications)
-        with self._state_lock:
-            # 处理完干预后再次校验状态
-            self._recalculate_all_statuses(state)
-            self.save_session_to_disk(session_id)
-        return res
-
     async def continue_workflow(self, session_id: str) -> Dict:
         with self._state_lock:
             state = self.get_state(session_id)
@@ -1394,7 +1398,7 @@
             if "created_at" not in data:
                 data["created_at"] = time.time()
 
-            # 会话级生成参数统一保存在 meta 中;清理旧版本遗留的根字段。
+            # Legacy session compatibility: clean root-level generation fields left by old session JSON.
             for key in SESSION_META_KEYS:
                 data.pop(key, None)
             
@@ -1467,8 +1471,28 @@
                                 state.status[stage.value] = "pending"
                 elif isinstance(old_status, dict):
                     state.status = old_status
+                    # Scrub running and waiting statuses
+                    for k, v in state.status.items():
+                        if v == "running":
+                            state.status[k] = "error"
+                            state.error = "服务意外中断,任务已停止"
+                        elif v == "waiting":
+                            state.status[k] = "pending"
 
                 state.artifacts = data.get("artifacts", {})
+                # Scrub artifact running/waiting items
+                for stage, artifact in state.artifacts.items():
+                    if not isinstance(artifact, dict):
+                        continue
+                    for key in ["clips", "images", "scenes", "characters", "settings"]:
+                        items = artifact.get(key)
+                        if isinstance(items, list):
+                            for item in items:
+                                if isinstance(item, dict):
+                                    if item.get("status") == "running":
+                                        item["status"] = "failed"
+                                    elif item.get("status") == "waiting":
+                                        item["status"] = "pending"
                 state.stage_progress = data.get("stage_progress", {})
                 state.error = data.get("error")
                 state.updated_at = data.get("updated_at", 0)

--
Gitblit v1.8.0