"""验证:`ask_user` 弹窗**不限时**(用户要求"AI 询问界面不要限时")。 ## 怎么验 以前是 120 秒到点自己消失。所以要证明"改了",必须**跨过 120 秒那条线**: 调一次 ask_user,然后在 5 秒 / 130 秒两个时刻截图: · 5 秒:弹窗在(说明调通了) · 130 秒:**弹窗还在**(说明真的不限时了。旧版这时候已经没了) · 再点一下选项:请求返回,`timeout` 是 false、`choice` 是点的那个 ★ 这个脚本会**阻塞到用户点为止**(那正是它要测的东西),所以必须后台跑。 用法: adb forward tcp:15199 tcp:5199 python scripts/probe-ask-user-forever.py """ import json import sys import time import urllib.request try: sys.stdout.reconfigure(encoding="utf-8", errors="replace") except Exception: pass URL = "http://127.0.0.1:15199" def call(path, payload=None, method="POST", timeout=900): data = json.dumps(payload, ensure_ascii=False).encode("utf-8") if payload is not None else None req = urllib.request.Request( URL + path, data=data, method=method, headers={"Content-Type": "application/json; charset=utf-8"}, ) with urllib.request.urlopen(req, timeout=timeout) as r: return json.loads(r.read().decode("utf-8")) def main(): print("调 ask_user —— 这个请求会一直挂着,直到有人在弹窗上点一下", flush=True) t0 = time.time() try: r = call("/api/tools/run", { "name": "ask_user", "args": { "question": "不限时测试:随便点一个(我不催你)", "options": [ {"label": "选项 A", "value": "A"}, {"label": "选项 B", "value": "B"}, {"label": "选项 C", "value": "C"}, ], }, }, timeout=900) except Exception as exc: # noqa: BLE001 print(f"!! 请求失败({time.time() - t0:.1f} 秒后):{exc}", flush=True) return 1 dt = time.time() - t0 print(f"\n等了 {dt:.1f} 秒才返回(旧版 120 秒就会 timeout)", flush=True) print(json.dumps(r, ensure_ascii=False)[:500], flush=True) if dt > 125 and not (r.get("result") or {}).get("timeout"): print("\n✅ 不限时生效:超过 120 秒仍然等到了用户的选择", flush=True) return 0 print("\n? 结果需要人工看一眼(可能点得太快,或 timeout 语义不对)", flush=True) return 0 if __name__ == "__main__": sys.exit(main())