context.dev autoreg: agent claim flow, chrome CDP signup, bank shim
This commit is contained in:
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python
|
||||
"""Verify every ctx key: live + credits. Rewrites bank.jsonl with fresh credits/dead flags."""
|
||||
import json, os, time, requests
|
||||
|
||||
BASE = os.path.dirname(os.path.abspath(__file__))
|
||||
BANK = os.path.join(BASE, "bank.jsonl")
|
||||
rows = [json.loads(l) for l in open(BANK) if l.strip()]
|
||||
seen, out = set(), []
|
||||
total = 0
|
||||
for r in rows:
|
||||
k = r.get("key")
|
||||
if not k or k in seen:
|
||||
continue
|
||||
seen.add(k)
|
||||
try:
|
||||
x = requests.get("https://api.context.dev/v1/org/logs",
|
||||
headers={"Authorization": "Bearer " + k}, timeout=45)
|
||||
if x.status_code == 200:
|
||||
cr = x.json().get("key_metadata", {}).get("credits_remaining")
|
||||
r["credits"], r["dead"] = cr, False
|
||||
total += cr or 0
|
||||
print("OK %-28s credits=%s" % (r.get("email"), cr))
|
||||
else:
|
||||
r["dead"] = True
|
||||
print("DEAD %-28s %s %s" % (r.get("email"), x.status_code, x.text[:80]))
|
||||
except Exception as e:
|
||||
r["dead"] = None
|
||||
print("ERR %-28s %s" % (r.get("email"), str(e)[:60]))
|
||||
out.append(r)
|
||||
|
||||
with open(BANK, "w") as f:
|
||||
for r in out:
|
||||
f.write(json.dumps(r, ensure_ascii=False) + "\n")
|
||||
live = [r for r in out if r.get("dead") is False]
|
||||
print("\nkeys=%d live=%d credits_total=%d" % (len(out), len(live), total))
|
||||
Reference in New Issue
Block a user