use crate::error::{BrowserError, Result};
use crate::tools::{Tool, ToolContext, ToolResult};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct CloseParams {}
#[derive(Default)]
pub struct CloseTool;
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct CloseOutput {
pub message: String,
}
impl Tool for CloseTool {
type Params = CloseParams;
type Output = CloseOutput;
fn name(&self) -> &str {
"close"
}
fn execute_typed(&self, _params: CloseParams, context: &mut ToolContext) -> Result<ToolResult> {
context
.session
.close()
.map_err(|e| BrowserError::ToolExecutionFailed {
tool: "close".to_string(),
reason: e.to_string(),
})?;
Ok(ToolResult::success_with(CloseOutput {
message: "Browser closed successfully".to_string(),
}))
}
}