feat: add batch command for multi-step workflows (#865)

Add `batch` command that reads a JSON array of commands from stdin
and executes them sequentially against the daemon. This avoids
per-command process startup overhead when AI agents run multi-step
browser workflows.

Supports --bail to stop on first error (default: continue all)
and --json for structured output as an array of results.

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt Van Horn
2026-03-17 08:48:50 -05:00
committed by GitHub
co-authored by Matt Van Horn Claude Opus 4.6
parent a865dd56e0
commit 7734bb2702
5 changed files with 234 additions and 1 deletions
+22
View File
@@ -1317,6 +1317,12 @@ pub fn parse_command(args: &[String], flags: &Flags) -> Result<Value, ParseError
"diff" => parse_diff(&rest, &id, flags),
// === Batch ===
"batch" => {
let bail = rest.contains(&"--bail");
Ok(json!({ "id": id, "action": "batch", "bail": bail }))
}
_ => Err(ParseError::UnknownCommand {
command: cmd.to_string(),
}),
@@ -3961,4 +3967,20 @@ mod tests {
let cmd = parse_command(&args("get cdp-url"), &default_flags()).unwrap();
assert_eq!(cmd["action"], "cdp_url");
}
// === Batch Tests ===
#[test]
fn test_batch_default() {
let cmd = parse_command(&args("batch"), &default_flags()).unwrap();
assert_eq!(cmd["action"], "batch");
assert_eq!(cmd["bail"], false);
}
#[test]
fn test_batch_with_bail() {
let cmd = parse_command(&args("batch --bail"), &default_flags()).unwrap();
assert_eq!(cmd["action"], "batch");
assert_eq!(cmd["bail"], true);
}
}