refactor: editor agent extract common tool prompt

This commit is contained in:
2026-07-22 11:10:48 +08:00
parent 93c872907b
commit a871b5f8c4
9 changed files with 22 additions and 9 deletions
@@ -6,6 +6,7 @@ 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,
@@ -108,7 +109,7 @@ impl Tool for EditImageTool {
return Err(error);
}
Ok(EditImageToolOutput {
message: "this tool call is pending user confirmation. if all is pending, just end this turn".to_string(),
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
})
}
}
@@ -1,10 +1,11 @@
use crate::framework::tool::{Tool, ToolFailure};
use platform_audio::SUNO_DEFAULT_MODEL;
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use serde_json::{json, Value};
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;
@@ -64,7 +65,7 @@ impl Tool for GenerateBackgroundMusicTool {
async move {
self.validate_args(&args)?;
Ok(GenerateBackgroundMusicToolOutput {
message: "this tool call is pending user confirmation. if all is pending, just end this turn".to_string(),
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
})
}
}
@@ -12,6 +12,7 @@ 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,
@@ -62,7 +63,9 @@ impl Tool for GenerateCharacterTool {
) -> impl Future<Output = Result<Self::Output, Self::Error>> + Send {
async move {
self.validate_args(&args)?;
Ok(GenerateImageToolOutput { message: "this tool call is pending user confirmation. if all is pending, just end this turn".to_string() })
Ok(GenerateImageToolOutput {
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
})
}
}
@@ -11,6 +11,7 @@ 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,
@@ -143,7 +144,7 @@ impl Tool for GenerateIconSpritesheetTool {
async move {
self.validate_args(&args)?;
Ok(GenerateIconSpritesheetToolOutput {
message: "this tool call is pending user confirmation. if all is pending, just end this turn".to_string(),
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
})
}
}
@@ -11,6 +11,7 @@ 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,
@@ -123,7 +124,7 @@ impl Tool for GenerateImageTool {
async move {
self.validate_args(&args)?;
Ok(GenerateImageToolOutput {
message: "this tool call is pending user confirmation.".to_string(),
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
})
}
}
@@ -5,6 +5,7 @@ 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;
@@ -90,7 +91,7 @@ impl Tool for GenerateSoundEffectTool {
async move {
self.validate_args(&args)?;
Ok(GenerateSoundEffectToolOutput {
message: "this tool call is pending user confirmation. if all is pending, just end this turn".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::generate_image::{
EditorImageGenerationResult, GenerateImageError, GenerateImageToolOutput,
@@ -70,7 +71,9 @@ impl Tool for GenerateUiDesignTool {
) -> impl Future<Output = Result<Self::Output, Self::Error>> + Send {
async move {
self.validate_args(&args)?;
Ok(GenerateImageToolOutput { message: "this tool call is pending user confirmation. if all is pending, just end this turn".to_string() })
Ok(GenerateImageToolOutput {
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::framework::tool::{Tool, ToolFailure, ToolFailureKind};
use serde::{Deserialize, Serialize};
@@ -151,7 +152,7 @@ impl Tool for GenerateVideoTool {
async move {
self.validate_args(&args)?;
Ok(GenerateVideoToolOutput {
message: "this tool call is pending user confirmation. if all is pending, just end this turn".to_string(),
message: TOOL_CALL_PENDING_MESSAGE.to_string(),
})
}
}
@@ -8,6 +8,7 @@ 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 {