use crate::{error::Result, tools::{Tool, ToolContext, ToolResult}}; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize, schemars::JsonSchema)] pub struct GetCookiesParams { /// Optional list of URLs to filter cookies by pub urls: Option>, } #[derive(Debug, Serialize, Deserialize, schemars::JsonSchema)] pub struct CookieParam { pub name: String, pub value: String, pub domain: Option, pub path: Option, pub secure: Option, pub http_only: Option, pub same_site: Option, pub expires: Option, pub url: Option, } #[derive(Debug, Serialize, Deserialize, schemars::JsonSchema)] pub struct SetCookiesParams { pub cookies: Vec, } #[derive(Default)] pub struct GetCookiesTool; impl Tool for GetCookiesTool { type Params = GetCookiesParams; fn name(&self) -> &str { "get_cookies" } fn execute_typed(&self, _params: Self::Params, context: &mut ToolContext) -> Result { let cookies = context.session.get_cookies()?; Ok(ToolResult::success_with(cookies)) } } #[derive(Default)] pub struct SetCookiesTool; impl Tool for SetCookiesTool { type Params = SetCookiesParams; fn name(&self) -> &str { "set_cookies" } fn execute_typed(&self, params: Self::Params, context: &mut ToolContext) -> Result { context.session.set_cookies(params.cookies)?; Ok(ToolResult::success(None)) } }