Skip to content

利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.

fix(skill): accept the WaveSpeed video source in the agent helper

c0206275ac2b5d979ad
diff --git a/docs/skill/SKILL.md b/docs/skill/SKILL.md
index a07ba9e6..b7c26631 100644
--- a/docs/skill/SKILL.md
+++ b/docs/skill/SKILL.md
@@ -118,6 +118,11 @@ When `SEEDANCE_CHARGE_CONFIRMATION_REQUIRED` is present, explain that every
generated Seedance clip creates a paid Ark task. Only after the user explicitly
confirms, rerun with `--confirm-seedance-charge`; never add this flag silently.
+When `WAVESPEED_CHARGE_CONFIRMATION_REQUIRED` is present, explain that every
+generated WaveSpeed clip is billed per request by WaveSpeed. Only after the user
+explicitly confirms, rerun with `--confirm-wavespeed-charge`; never add this
+flag silently.
+
When `OFOX_CHARGE_CONFIRMATION_REQUIRED` is present, explain that every
generated OFox clip creates a paid task. Only after the user explicitly
confirms, rerun with `--confirm-ofox-charge`; never add this flag silently.
diff --git a/docs/skill/mpt_agent.py b/docs/skill/mpt_agent.py
index ac05ae57..f22bb067 100644
--- a/docs/skill/mpt_agent.py
+++ b/docs/skill/mpt_agent.py
@@ -29,6 +29,7 @@ SUPPORTED_SOURCES = {
"pexels",
"pixabay",
"coverr",
+ "wavespeed",
"volcengine_seedance",
"ofox",
"metaso_minimax",
@@ -369,6 +370,15 @@ def missing_config(config_path: Path, cli_args: list[str]) -> tuple[str, list[st
missing.append("volcengine_seedance_api_key")
if not has_cli_option(cli_args, "--confirm-seedance-charge"):
missing.append("confirm_seedance_charge")
+ elif source == "wavespeed":
+ # WaveSpeed 的运行时凭据只来自 wavespeed_api_keys,没有环境变量回退,
+ # 这里保持同一口径。按次计费的生成源还必须显式确认收费。
+ if not _has_configured_value(
+ _plain_config_value(text, "wavespeed_api_keys")
+ ):
+ missing.append("wavespeed_api_keys")
+ if not has_cli_option(cli_args, "--confirm-wavespeed-charge"):
+ missing.append("confirm_wavespeed_charge")
elif source == "ofox":
# 与运行时 Provider 保持完全一致的凭据优先级:配置键优先,其次是
# 语义明确的 OFOX_API_KEY 环境变量。
@@ -447,6 +457,8 @@ def report_missing_config(provider: str, missing: list[str]) -> int:
print("VOLCENGINE_ARK_API_KEY_ENV=MPT_VOLCENGINE_ARK_API_KEY")
if "confirm_seedance_charge" in missing:
print("SEEDANCE_CHARGE_CONFIRMATION_REQUIRED=--confirm-seedance-charge")
+ if "confirm_wavespeed_charge" in missing:
+ print("WAVESPEED_CHARGE_CONFIRMATION_REQUIRED=--confirm-wavespeed-charge")
if "ofox_api_key" in missing:
print(f"OFOX_API_KEY_URL={OFOX_API_KEY_URL}")
print("OFOX_API_KEY_ENV=MPT_OFOX_API_KEY")
diff --git a/test/services/test_mpt_agent_skill.py b/test/services/test_mpt_agent_skill.py
index 5df548bb..f653bd67 100644
--- a/test/services/test_mpt_agent_skill.py
+++ b/test/services/test_mpt_agent_skill.py
@@ -1,3 +1,4 @@
+import ast
import importlib.util
import io
import json
@@ -287,6 +288,78 @@ class TestMptAgentSkill(unittest.TestCase):
)
self.assertNotIn("LLM_PROVIDER_OPTIONS_BEGIN", text)
+ def test_wavespeed_source_requires_its_own_key_and_charge_confirmation(self):
+ with tempfile.TemporaryDirectory() as temp_dir:
+ config_path = Path(temp_dir) / "config.toml"
+ config_text = MINIMAL_CONFIG.replace(
+ 'moonshot_api_key = ""', 'moonshot_api_key = "configured"'
+ ).replace(
+ "pexels_api_keys = []",
+ "pexels_api_keys = []\nwavespeed_api_keys = []",
+ )
+ config_path.write_text(config_text, encoding="utf-8")
+
+ with patch.dict(os.environ, {}, clear=True):
+ _, missing = mpt_agent.missing_config(
+ config_path, ["--video-source", "wavespeed"]
+ )
+ self.assertEqual(
+ missing, ["wavespeed_api_keys", "confirm_wavespeed_charge"]
+ )
+
+ config_path.write_text(
+ config_text.replace(
+ "wavespeed_api_keys = []", 'wavespeed_api_keys = ["configured"]'
+ ),
+ encoding="utf-8",
+ )
+ with patch.dict(os.environ, {}, clear=True):
+ _, confirmed_missing = mpt_agent.missing_config(
+ config_path,
+ ["--video-source", "wavespeed", "--confirm-wavespeed-charge"],
+ )
+ self.assertEqual(confirmed_missing, [])
+
+ def test_missing_wavespeed_inputs_report_the_charge_flag(self):
+ output = io.StringIO()
+ with redirect_stdout(output):
+ code = mpt_agent.report_missing_config(
+ "moonshot",
+ ["wavespeed_api_keys", "confirm_wavespeed_charge"],
+ )
+
+ text = output.getvalue()
+ self.assertEqual(code, mpt_agent.NEEDS_INPUT_EXIT_CODE)
+ self.assertIn(
+ "WAVESPEED_CHARGE_CONFIRMATION_REQUIRED=--confirm-wavespeed-charge",
+ text,
+ )
+ self.assertNotIn("LLM_PROVIDER_OPTIONS_BEGIN", text)
+
+ def test_supported_sources_match_the_cli_video_source_list(self):
+ """helper 的来源白名单必须与 cli.py 的 _CLI_VIDEO_SOURCES 同一集合。
+
+ 脚本里手抄的这份清单曾经漏掉 wavespeed:CLI 接受该来源,helper 却报
+ "unsupported video source"。期望值从权威常量推导,新增来源时会先失败。
+ """
+ tree = ast.parse(
+ (SKILL_SCRIPT.parents[2] / "cli.py").read_text(encoding="utf-8")
+ )
+ cli_sources = None
+ for node in tree.body:
+ if not isinstance(node, ast.Assign):
+ continue
+ if any(
+ isinstance(target, ast.Name)
+ and target.id == "_CLI_VIDEO_SOURCES"
+ for target in node.targets
+ ):
+ cli_sources = set(ast.literal_eval(node.value))
+ break
+
+ self.assertIsNotNone(cli_sources)
+ self.assertEqual(set(mpt_agent.SUPPORTED_SOURCES), cli_sources)
+
def test_seedance_source_requires_key_and_explicit_charge_confirmation(self):
with tempfile.TemporaryDirectory() as temp_dir:
config_path = Path(temp_dir) / "config.toml"