diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tool_bridge.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tool_bridge.rs index fefb925df..bfff40a20 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tool_bridge.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tool_bridge.rs @@ -203,6 +203,16 @@ pub(crate) enum DirectResourceGenerationKind { } impl DirectResourceGenerationKind { + /// 全部受支持的 kind,顺序与 `parse`/`as_str` 一致;需要把清单讲给模型听的文案从这里取, + /// 免得新增 kind 时留下第二份会漂移的字符串白名单。 + pub(crate) const ALL: [Self; 5] = [ + Self::Image, + Self::Video, + Self::CharacterAnimation, + Self::SoundEffect, + Self::BackgroundMusic, + ]; + pub(crate) fn parse(value: &str) -> Result { match value { "image" => Ok(Self::Image), diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/tool/create_or_derive_resource/error.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/tool/create_or_derive_resource/error.rs index 9b2597b51..8b4e27c87 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/tool/create_or_derive_resource/error.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/tool/create_or_derive_resource/error.rs @@ -141,9 +141,14 @@ impl ToolFailure for CreateOrDeriveResourceError { Self::KindNotText { got } => format!( "生成或派生资源失败:kind 必须是字符串,当前是「{got}」。" ), - Self::KindUnsupported { got } => format!( - "生成或派生资源失败:kind「{got}」不是受支持的媒体资源类型,只允许 image、video、character-animation、sound-effect、background-music。" - ), + Self::KindUnsupported { got } => { + let allowed = DirectResourceGenerationKind::ALL + .into_iter() + .map(DirectResourceGenerationKind::as_str) + .collect::>() + .join("、"); + format!("生成或派生资源失败:kind「{got}」不是受支持的媒体资源类型,只允许 {allowed}。") + } Self::ModeEmpty => "生成或派生资源失败:mode 不能为空。".to_string(), Self::ModeTooLong { got_chars,