File size: 1,176 Bytes
924a755
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Headless decision helper for the human gate (fallback to the dashboard).

Run:  python -m scripts.decide --run <run_id> approve
      python -m scripts.decide --run <run_id> reject
      python -m scripts.decide --run <run_id> change_budget --price 4.00
"""
from __future__ import annotations

import argparse
import json
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parent.parent))

from core.config import traces_dir  # noqa: E402


def main() -> None:
    parser = argparse.ArgumentParser()
    parser.add_argument("--run", required=True)
    parser.add_argument("decision", choices=["approve", "reject", "change_budget"])
    parser.add_argument("--price", type=float, default=None)
    args = parser.parse_args()

    payload = {"decision": args.decision}
    if args.decision == "change_budget":
        if args.price is None:
            parser.error("change_budget requires --price")
        payload["new_max_unit_price"] = args.price

    path = traces_dir() / f"{args.run}.decision.json"
    path.write_text(json.dumps(payload), encoding="utf-8")
    print(f"[decide] wrote {path}")


if __name__ == "__main__":
    main()