Persist full GSI payloads to per-match JSONL for later analysis.

Default-on dump keeps every POST body under samples/raw/<matchid>/gsi.jsonl, with CLI overrides to disable when disk use is a concern.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
voson
2026-07-26 12:16:47 +08:00
co-authored by Cursor
parent 2fb298ebf1
commit 7dc3e515e9
7 changed files with 61 additions and 4 deletions
+16
View File
@@ -10,6 +10,7 @@ Notes:
- Frames are saved as PNG at native resolution, named cap_HHMMSS.png.
"""
import json
import sys
import time
from pathlib import Path
@@ -19,6 +20,7 @@ import mss
import numpy as np
RAW_DIR = Path(__file__).parent / "samples" / "raw"
GSI_JSONL = "gsi.jsonl"
def raw_dir_for_match(match_id: str | None = None) -> Path:
@@ -32,6 +34,20 @@ def raw_dir_for_match(match_id: str | None = None) -> Path:
return RAW_DIR / safe
def append_gsi_payload(match_id: str | None, payload: dict) -> Path:
"""Append one full GSI POST body to samples/raw/{match_id}/gsi.jsonl.
Each line is {"t": <unix seconds>, "payload": <original body>}.
"""
out = raw_dir_for_match(match_id)
out.mkdir(parents=True, exist_ok=True)
path = out / GSI_JSONL
record = {"t": time.time(), "payload": payload}
with path.open("a", encoding="utf-8") as f:
f.write(json.dumps(record, ensure_ascii=False) + "\n")
return path
def grab_frame(sct=None) -> np.ndarray:
"""Grab the primary monitor as a BGR image."""
if sct is None: