refactor: editor agent extract common tool prompt

This commit is contained in:
2026-07-22 11:14:39 +08:00
parent a871b5f8c4
commit 8c85b2f8be
8 changed files with 14 additions and 12 deletions
@@ -0,0 +1,2 @@
pub const TOOL_CALL_PENDING_MESSAGE: &'static str =
"this tool call is pending user confirmation. if all is pending, just end this turn";
@@ -1,4 +1,5 @@
use crate::agent::asset::ImageId;
use crate::agent::tools::common::TOOL_CALL_PENDING_MESSAGE;
use crate::agent::tools::context::EditorToolContext;
use crate::framework::tool::{Tool, ToolFailure, ToolFailureKind};
use platform_image::GPT_IMAGE_2_MODEL;
@@ -6,7 +7,6 @@ use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use std::error::Error;
use std::fmt::Display;
use crate::agent::tools::common::TOOL_CALL_PENDING_MESSAGE;
pub struct EditImageTool {
pub context: EditorToolContext,
@@ -1,11 +1,11 @@
use crate::agent::tools::common::TOOL_CALL_PENDING_MESSAGE;
use crate::framework::tool::{Tool, ToolFailure};
use platform_audio::SUNO_DEFAULT_MODEL;
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use serde_json::{Value, json};
use shared_contracts::assets::EditorAudioGenerateResponse;
use std::error::Error;
use std::fmt::Display;
use crate::agent::tools::common::TOOL_CALL_PENDING_MESSAGE;
pub struct GenerateBackgroundMusicTool;
@@ -1,4 +1,5 @@
use crate::agent::asset::ImageId;
use crate::agent::tools::common::TOOL_CALL_PENDING_MESSAGE;
use crate::agent::tools::context::EditorToolContext;
use crate::agent::tools::generate_image::{
EditorImageGenerationResult, GenerateImageError, GenerateImageToolOutput,
@@ -12,7 +13,6 @@ use crate::framework::tool::ToolFailureKind;
use crate::framework::tool::{Tool, ToolFailure};
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use crate::agent::tools::common::TOOL_CALL_PENDING_MESSAGE;
pub struct GenerateCharacterTool {
pub context: EditorToolContext,
@@ -64,7 +64,7 @@ impl Tool for GenerateCharacterTool {
async move {
self.validate_args(&args)?;
Ok(GenerateImageToolOutput {
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
})
}
}
@@ -1,4 +1,5 @@
use crate::agent::asset::ImageId;
use crate::agent::tools::common::TOOL_CALL_PENDING_MESSAGE;
use crate::agent::tools::context::EditorToolContext;
use crate::agent::tools::image_generation_options::{
ImageGenerationOptionsError, default_image_aspect_ratio, default_image_model,
@@ -11,7 +12,6 @@ use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use std::error::Error;
use std::fmt::Display;
use crate::agent::tools::common::TOOL_CALL_PENDING_MESSAGE;
pub struct GenerateIconSpritesheetTool {
pub context: EditorToolContext,
@@ -144,7 +144,7 @@ impl Tool for GenerateIconSpritesheetTool {
async move {
self.validate_args(&args)?;
Ok(GenerateIconSpritesheetToolOutput {
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
})
}
}
@@ -1,4 +1,5 @@
use crate::agent::asset::ImageId;
use crate::agent::tools::common::TOOL_CALL_PENDING_MESSAGE;
use crate::agent::tools::context::EditorToolContext;
use crate::agent::tools::image_generation_options::{
ImageGenerationOptionsError, default_image_aspect_ratio, default_image_model,
@@ -11,7 +12,6 @@ use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use std::error::Error;
use std::fmt::Display;
use crate::agent::tools::common::TOOL_CALL_PENDING_MESSAGE;
pub struct GenerateImageTool {
pub context: EditorToolContext,
@@ -124,7 +124,7 @@ impl Tool for GenerateImageTool {
async move {
self.validate_args(&args)?;
Ok(GenerateImageToolOutput {
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
})
}
}
@@ -1,3 +1,4 @@
use crate::agent::tools::common::TOOL_CALL_PENDING_MESSAGE;
use crate::framework::tool::{Tool, ToolFailure};
use platform_audio::VIDU_AUDIO_MODEL;
use serde::{Deserialize, Serialize};
@@ -5,7 +6,6 @@ use serde_json::{Value, json};
use shared_contracts::assets::EditorAudioGenerateResponse;
use std::error::Error;
use std::fmt::Display;
use crate::agent::tools::common::TOOL_CALL_PENDING_MESSAGE;
pub struct GenerateSoundEffectTool;
@@ -91,7 +91,7 @@ impl Tool for GenerateSoundEffectTool {
async move {
self.validate_args(&args)?;
Ok(GenerateSoundEffectToolOutput {
message:TOOL_CALL_PENDING_MESSAGE.to_string(),
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
})
}
}
@@ -1,3 +1,4 @@
mod common;
pub mod context;
pub mod edit_image;
pub mod generate_background_music;
@@ -8,7 +9,6 @@ pub mod generate_sound_effect;
pub mod generate_ui_design;
pub mod generate_video;
pub mod image_generation_options;
mod common;
#[cfg(test)]
mod tests {