Files
BrowserSkill/crates/bsk-protocol/src/tools/window.rs
T
BB-fat 49378d70de feat: support Agent Window sizing (session start --width/--height, window resize) (#52)
- `bsk session start --width <px> --height <px>` opens the Agent Window
  with the given outer size (chrome.windows.create)
- new `bsk window resize --session <id> --width <px> --height <px>`
  resizes the Agent Window at runtime (chrome.windows.update)
- both validated on CLI, daemon and extension sides (100..=7680 CSS px)
- protocol: new tool.window_resize method (BrowserMutation) and
  optional width/height on tool.session_start params; schemas regenerated
2026-08-05 11:19:10 +08:00

63 lines
1.7 KiB
Rust
Executable File

//! Agent Window management tools (`tool.window_*`).
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
// ----- window_resize -----
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct WindowResizeParams {
pub session_id: String,
/// New Agent Window outer width in CSS pixels (100..=7680).
pub width: u32,
/// New Agent Window outer height in CSS pixels (100..=7680).
pub height: u32,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct WindowResizeResult {
pub window_id: i64,
pub width: u32,
pub height: u32,
}
#[cfg(test)]
mod tests {
use super::*;
use serde_json::json;
#[test]
fn window_resize_params_round_trip() {
let params: WindowResizeParams = serde_json::from_value(json!({
"session_id": "ab12",
"width": 1280,
"height": 800,
}))
.unwrap();
assert_eq!(params.session_id, "ab12");
assert_eq!(params.width, 1280);
assert_eq!(params.height, 800);
let encoded = serde_json::to_value(params).unwrap();
assert_eq!(
encoded,
json!({ "session_id": "ab12", "width": 1280, "height": 800 })
);
}
#[test]
fn window_resize_result_round_trip() {
let result: WindowResizeResult = serde_json::from_value(json!({
"window_id": 42,
"width": 1280,
"height": 800,
}))
.unwrap();
assert_eq!(result.window_id, 42);
let encoded = serde_json::to_value(result).unwrap();
assert_eq!(
encoded,
json!({ "window_id": 42, "width": 1280, "height": 800 })
);
}
}