use crate::computer::{
action::{Action, ActionSpec, ExecCtx},
operator::{ActionFut, ActionOutput, Operator, ScreenshotFut},
};
pub struct BrowserOperator {
}
impl BrowserOperator {
pub fn new() -> Self {
Self {}
}
}
impl Default for BrowserOperator {
fn default() -> Self {
Self::new()
}
}
impl Operator for BrowserOperator {
fn name(&self) -> &'static str {
"browser"
}
fn action_spaces(&self) -> Vec<ActionSpec> {
vec![
ActionSpec::new("click(start_box='<box>x1,y1</box>')"),
ActionSpec::with_note("type(content='')", "# Add \\n at end of content to submit"),
ActionSpec::new(
"scroll(start_box='<box>x1,y1</box>', direction='down or up or right or left')",
),
ActionSpec::with_note("wait()", "# Sleep 2s and re-screenshot"),
ActionSpec::with_note("navigate(url='')", "# Navigate to a URL"),
ActionSpec::new("finished(content='xxx')"),
ActionSpec::with_note("call_user()", "# Stuck or need help"),
]
}
fn screenshot(&self) -> ScreenshotFut<'_> {
Box::pin(async move { anyhow::bail!("BrowserOperator::screenshot — not yet implemented") })
}
fn execute<'a>(&'a self, _action: &'a Action, _ctx: &'a ExecCtx) -> ActionFut<'a> {
Box::pin(async move {
Ok(ActionOutput::err(
"BrowserOperator::execute — not yet implemented",
))
})
}
}