(
*,
task: str | None = None,
task_id: str | None = None,
start_url: str | None = None,
config_spec: list[str] | None = None,
output_dir: Path | None = None,
resolved_output_dir: Path | None = None,
debug: bool = False,
snapshot_config: bool = True,
)
| 29 | |
| 30 | |
| 31 | def run_one( |
| 32 | *, |
| 33 | task: str | None = None, |
| 34 | task_id: str | None = None, |
| 35 | start_url: str | None = None, |
| 36 | config_spec: list[str] | None = None, |
| 37 | output_dir: Path | None = None, |
| 38 | resolved_output_dir: Path | None = None, |
| 39 | debug: bool = False, |
| 40 | snapshot_config: bool = True, |
| 41 | ) -> Any: |
| 42 | config_spec = config_spec or DEFAULT_CONFIGS |
| 43 | configs = [get_config_from_spec(spec) for spec in config_spec] |
| 44 | config = recursive_merge(*configs) |
| 45 | |
| 46 | run_config = config.get("run", {}) |
| 47 | resolved_task_id = task_id or run_config.get("task_id") |
| 48 | resolved_task = task or run_config.get("task") |
| 49 | resolved_start_url = start_url or run_config.get("start_url") |
| 50 | |
| 51 | if not resolved_task: |
| 52 | raise ValueError("A task is required. Use --task.") |
| 53 | |
| 54 | resolved_output_dir = resolved_output_dir or _timestamped_output_dir( |
| 55 | output_dir or config.get("environment", {}).get("output_dir") or "outputs", |
| 56 | resolved_task_id, |
| 57 | ) |
| 58 | if snapshot_config: |
| 59 | snapshot_config_specs(config_spec, resolved_output_dir, merged_config=config) |
| 60 | |
| 61 | config = recursive_merge( |
| 62 | config, |
| 63 | { |
| 64 | "run": { |
| 65 | "task": resolved_task, |
| 66 | "task_id": resolved_task_id or UNSET, |
| 67 | "start_url": resolved_start_url or UNSET, |
| 68 | }, |
| 69 | "environment": { |
| 70 | "output_dir": str(resolved_output_dir), |
| 71 | "start_url": resolved_start_url or UNSET, |
| 72 | "headless": False if debug else UNSET, |
| 73 | "devtools": True if debug else UNSET, |
| 74 | "keep_open_on_exit": True if debug else UNSET, |
| 75 | "prompt_before_close": True if debug else UNSET, |
| 76 | "slow_mo_ms": 250 if debug else UNSET, |
| 77 | }, |
| 78 | "model": { |
| 79 | "error_log_path": str(resolved_output_dir / "runtime_errors.jsonl"), |
| 80 | }, |
| 81 | "agent": { |
| 82 | "output_path": str(resolved_output_dir / "trajectory.json"), |
| 83 | }, |
| 84 | }, |
| 85 | ) |
| 86 | |
| 87 | model = get_model(config.get("model", {})) |
| 88 | env = get_environment(config.get("environment", {})) |
no test coverage detected