diff --git a/README.md b/README.md index 940b33e..a62ee90 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,12 @@ Один аккаунт = **65 Theos** (обновляются каждые 24 часа) + **11 моделей без расхода Theos вообще**. +> **Правило выдачи Theos (замер на 103 аккаунтах): 5 аккаунтов на один egress-IP.** +> Шестой и следующие с того же IP получают `granted=0.00000` до следующего `refresh_at` (сутки), +> и это не лечится ни визитом страницы, ни `X-DeepAI-Code-Check-In` с nonce, ни сменой machine-id. +> Проверено: 6 разных IP по 5 аккаунтов = **5/5 грантов на каждом** (1834 Theos за 30 аккаунтов), +> те же аккаунты с домашнего IP — нули. Фарм — `farm_grant.py perfetch 5`. + ## Как это работает ``` diff --git a/bd_probe.py b/bd_probe.py new file mode 100644 index 0000000..ed207e9 --- /dev/null +++ b/bd_probe.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +"""Проверка Bright Data как источника egress-IP для фарма Theos. + +Читает token из C:/Users/User/tmp/bd_token.json, тянет пароли зон, +проверяет каждый порт/зону через api.ipify.org. Печатает только IP (без кредов). +""" +import json +import os +import subprocess + +TOK = "C:/Users/User/tmp/bd_token.json" +CUST = "hl_a6a307bf" + + +def token(): + d = json.load(open(TOK, encoding="utf-8")) + for k in ("token", "api_token", "access_token"): + if d.get(k): + return d[k] + for v in d.values(): + if isinstance(v, str) and len(v) > 20: + return v + return "" + + +def zone_pw(tok, zone): + try: + r = subprocess.run(["curl", "-s", "-m", "15", "-H", "Authorization: Bearer " + tok, + "https://api.brightdata.com/zone/passwords?zone=" + zone], + capture_output=True, text=True, timeout=25) + d = json.loads(r.stdout or "{}") + return d.get("passwords") or d.get("password") or [] + except Exception: + return [] + + +def ip_of(url): + try: + r = subprocess.run(["curl", "-s", "-m", "20", "-x", url, "https://api.ipify.org"], + capture_output=True, text=True, timeout=30) + ip = (r.stdout or "").strip() + return ip if ip.count(".") == 3 else "" + except Exception: + return "" + + +def main(): + tok = token() + print("token_len", len(tok)) + good = [] + for zone in ("serp", "browser_api", "unlocker", "residential"): + pws = zone_pw(tok, zone) + if not pws: + print(zone, "нет пароля") + continue + pw = pws[0] + for port in ("33335", "22225"): + url = "http://brd-customer-%s-zone-%s:%s@brd.superproxy.io:%s" % (CUST, zone, pw, port) + ip = ip_of(url) + print("%-12s :%s -> %s" % (zone, port, ip or "FAIL"), flush=True) + if ip: + good.append(url) + open("px_bd.txt", "w", encoding="utf-8").write("\n".join(good) + "\n") + print("good", len(good)) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/build_proxies.py b/build_proxies.py new file mode 100644 index 0000000..a8a7e23 --- /dev/null +++ b/build_proxies.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- +"""Собирает egress-пул для фарма Theos из локальных источников и проверяет IP. + +Пишет proxies_all.txt (только рабочие), печатает маску + egress-IP (без кредов). +python build_proxies.py +""" +import json +import os +import subprocess +import sys + +OUT = "proxies_all.txt" +CAND = [] + + +def add(url): + if url and url not in CAND: + CAND.append(url) + + +# 1. VDSok DE (жёсткие порты) +for hp in ("31.77.251.116:8894", "31.77.251.116:8895", "31.77.251.116:8896", + "31.77.251.116:8897", "31.77.251.110:8897", "31.77.251.110:8898"): + add("http://nst:Nst6Rot9x@%s" % hp) + +# 2. Decodo (free DC) +dp = "C:/Users/User/tmp/decodo_autoreg/data/accounts.jsonl" +if os.path.exists(dp): + for line in open(dp, encoding="utf-8"): + line = line.strip() + if not line: + continue + r = json.loads(line) + if r.get("status") != "active": + continue + h, p = r.get("proxy_host"), r.get("proxy_port") + u, pw = r.get("proxy_username"), r.get("proxy_password") + if h and p and u and pw: + add("http://%s:%s@%s:%s" % (u, pw, h, p)) + +# 3. Webshare (пул живых host:port) +for path in ("C:/Users/User/tmp/ws/proxies.json", "C:/Users/User/tmp/ws/ws505.json", + "C:/Users/User/tmp/ws/ws506.json"): + if not os.path.exists(path): + continue + try: + data = json.load(open(path, encoding="utf-8")) + except Exception: + continue + rows = data if isinstance(data, list) else data.get("proxies") or data.get("results") or [] + for r in rows: + if isinstance(r, dict) and r.get("url"): + add(r["url"]) + + +def ip_of(url): + try: + r = subprocess.run(["curl", "-s", "-m", "8", "-x", url, "https://api.ipify.org"], + capture_output=True, text=True, timeout=15) + ip = (r.stdout or "").strip() + return ip if ip.count(".") == 3 else "" + except Exception: + return "" + + +def main(): + good, seen = [], {} + for url in CAND: + ip = ip_of(url) + mask = url.split("@")[-1] if "@" in url else url + if not ip: + print("%-42s DEAD" % mask, flush=True) + continue + if ip in seen: + print("%-42s %-16s dup с %s" % (mask, ip, seen[ip]), flush=True) + continue + seen[ip] = mask + good.append(url) + print("%-42s %-16s NEW" % (mask, ip), flush=True) + open(OUT, "w", encoding="utf-8").write("\n".join(good) + "\n") + print("\nunique_egress=%d -> %s" % (len(good), OUT)) + + +if __name__ == "__main__": + sys.exit(main()) \ No newline at end of file diff --git a/build_px.log b/build_px.log new file mode 100644 index 0000000..f8bfb2b --- /dev/null +++ b/build_px.log @@ -0,0 +1,179 @@ +31.77.251.116:8894 31.77.251.109 NEW +31.77.251.116:8895 2.27.98.7 NEW +31.77.251.116:8896 2.27.98.2 NEW +31.77.251.116:8897 31.77.251.116 NEW +31.77.251.110:8897 31.77.251.110 NEW +31.77.251.110:8898 150.241.69.179 NEW +dc.decodo.com:10000 192.177.126.96 NEW +dc.decodo.com:10000 192.177.8.244 NEW +dc.decodo.com:10000 192.177.124.24 NEW +dc.decodo.com:10000 192.177.124.121 NEW +45.38.107.97:6014 DEAD +64.137.96.74:6641 DEAD +198.23.243.226:6361 DEAD +38.154.185.97:6370 DEAD +84.247.60.125:6095 DEAD +191.96.254.138:6185 DEAD +198.46.161.42:5092 DEAD +64.137.10.153:5803 DEAD +104.164.49.38:7693 DEAD +23.26.71.145:5628 DEAD +45.38.107.97:6014 DEAD +64.137.96.74:6641 DEAD +198.23.243.226:6361 DEAD +38.154.185.97:6370 DEAD +84.247.60.125:6095 DEAD +191.96.254.138:6185 DEAD +198.46.161.42:5092 DEAD +64.137.10.153:5803 DEAD +104.164.49.38:7693 DEAD +23.26.71.145:5628 DEAD +45.38.107.97:6014 45.38.107.97 NEW +64.137.96.74:6641 64.137.96.74 NEW +198.23.243.226:6361 198.23.243.226 NEW +38.154.185.97:6370 38.154.185.97 NEW +84.247.60.125:6095 84.247.60.125 NEW +191.96.254.138:6185 191.96.254.138 NEW +198.46.161.42:5092 198.46.161.42 NEW +64.137.10.153:5803 64.137.10.153 NEW +104.164.49.38:7693 104.164.49.38 NEW +23.26.71.145:5628 23.26.71.145 NEW +45.38.107.97:6014 45.38.107.97 dup с 45.38.107.97:6014 +64.137.96.74:6641 64.137.96.74 dup с 64.137.96.74:6641 +198.23.243.226:6361 198.23.243.226 dup с 198.23.243.226:6361 +38.154.185.97:6370 38.154.185.97 dup с 38.154.185.97:6370 +84.247.60.125:6095 84.247.60.125 dup с 84.247.60.125:6095 +191.96.254.138:6185 191.96.254.138 dup с 191.96.254.138:6185 +198.46.161.42:5092 198.46.161.42 dup с 198.46.161.42:5092 +64.137.10.153:5803 64.137.10.153 dup с 64.137.10.153:5803 +104.164.49.38:7693 104.164.49.38 dup с 104.164.49.38:7693 +23.26.71.145:5628 23.26.71.145 dup с 23.26.71.145:5628 +198.23.243.226:10000 DEAD +45.38.107.97:10001 DEAD +104.164.49.38:10002 DEAD +191.96.254.138:10003 DEAD +84.247.60.125:10004 DEAD +23.26.71.145:10005 DEAD +38.154.185.97:10006 DEAD +64.137.10.153:10007 DEAD +198.46.161.42:10008 DEAD +64.137.96.74:10009 DEAD +45.38.107.97:6014 DEAD +64.137.96.74:6641 DEAD +198.23.243.226:6361 DEAD +38.154.185.97:6370 DEAD +84.247.60.125:6095 DEAD +191.96.254.138:6185 DEAD +198.46.161.42:5092 DEAD +64.137.10.153:5803 DEAD +104.164.49.38:7693 DEAD +23.26.71.145:5628 DEAD +198.23.243.226:10000 DEAD +45.38.107.97:10001 DEAD +104.164.49.38:10002 DEAD +191.96.254.138:10003 DEAD +84.247.60.125:10004 DEAD +23.26.71.145:10005 DEAD +38.154.185.97:10006 DEAD +64.137.10.153:10007 DEAD +198.46.161.42:10008 DEAD +64.137.96.74:10009 DEAD +45.38.107.97:6014 45.38.107.97 dup с 45.38.107.97:6014 +64.137.96.74:6641 64.137.96.74 dup с 64.137.96.74:6641 +198.23.243.226:6361 198.23.243.226 dup с 198.23.243.226:6361 +38.154.185.97:6370 38.154.185.97 dup с 38.154.185.97:6370 +84.247.60.125:6095 84.247.60.125 dup с 84.247.60.125:6095 +191.96.254.138:6185 191.96.254.138 dup с 191.96.254.138:6185 +198.46.161.42:5092 198.46.161.42 dup с 198.46.161.42:5092 +64.137.10.153:5803 64.137.10.153 dup с 64.137.10.153:5803 +104.164.49.38:7693 104.164.49.38 dup с 104.164.49.38:7693 +23.26.71.145:5628 23.26.71.145 dup с 23.26.71.145:5628 +198.23.243.226:10000 DEAD +45.38.107.97:10001 DEAD +104.164.49.38:10002 DEAD +191.96.254.138:10003 DEAD +84.247.60.125:10004 DEAD +23.26.71.145:10005 DEAD +38.154.185.97:10006 DEAD +64.137.10.153:10007 DEAD +198.46.161.42:10008 DEAD +64.137.96.74:10009 DEAD +45.38.107.97:6014 45.38.107.97 dup с 45.38.107.97:6014 +64.137.96.74:6641 64.137.96.74 dup с 64.137.96.74:6641 +198.23.243.226:6361 198.23.243.226 dup с 198.23.243.226:6361 +38.154.185.97:6370 38.154.185.97 dup с 38.154.185.97:6370 +84.247.60.125:6095 84.247.60.125 dup с 84.247.60.125:6095 +191.96.254.138:6185 191.96.254.138 dup с 191.96.254.138:6185 +198.46.161.42:5092 198.46.161.42 dup с 198.46.161.42:5092 +64.137.10.153:5803 64.137.10.153 dup с 64.137.10.153:5803 +104.164.49.38:7693 104.164.49.38 dup с 104.164.49.38:7693 +23.26.71.145:5628 23.26.71.145 dup с 23.26.71.145:5628 +198.23.243.226:10000 DEAD +45.38.107.97:10001 DEAD +104.164.49.38:10002 DEAD +191.96.254.138:10003 DEAD +84.247.60.125:10004 DEAD +23.26.71.145:10005 DEAD +38.154.185.97:10006 DEAD +64.137.10.153:10007 DEAD +198.46.161.42:10008 DEAD +64.137.96.74:10009 DEAD +45.38.107.97:6014 45.38.107.97 dup с 45.38.107.97:6014 +64.137.96.74:6641 64.137.96.74 dup с 64.137.96.74:6641 +198.23.243.226:6361 198.23.243.226 dup с 198.23.243.226:6361 +38.154.185.97:6370 38.154.185.97 dup с 38.154.185.97:6370 +84.247.60.125:6095 84.247.60.125 dup с 84.247.60.125:6095 +191.96.254.138:6185 191.96.254.138 dup с 191.96.254.138:6185 +198.46.161.42:5092 198.46.161.42 dup с 198.46.161.42:5092 +64.137.10.153:5803 64.137.10.153 dup с 64.137.10.153:5803 +104.164.49.38:7693 104.164.49.38 dup с 104.164.49.38:7693 +23.26.71.145:5628 23.26.71.145 dup с 23.26.71.145:5628 +198.23.243.226:10000 DEAD +45.38.107.97:10001 DEAD +104.164.49.38:10002 DEAD +191.96.254.138:10003 DEAD +84.247.60.125:10004 DEAD +23.26.71.145:10005 DEAD +38.154.185.97:10006 DEAD +64.137.10.153:10007 DEAD +198.46.161.42:10008 DEAD +64.137.96.74:10009 DEAD +45.38.107.97:6014 45.38.107.97 dup с 45.38.107.97:6014 +64.137.96.74:6641 64.137.96.74 dup с 64.137.96.74:6641 +198.23.243.226:6361 198.23.243.226 dup с 198.23.243.226:6361 +38.154.185.97:6370 38.154.185.97 dup с 38.154.185.97:6370 +84.247.60.125:6095 84.247.60.125 dup с 84.247.60.125:6095 +191.96.254.138:6185 191.96.254.138 dup с 191.96.254.138:6185 +198.46.161.42:5092 198.46.161.42 dup с 198.46.161.42:5092 +64.137.10.153:5803 64.137.10.153 dup с 64.137.10.153:5803 +104.164.49.38:7693 104.164.49.38 dup с 104.164.49.38:7693 +23.26.71.145:5628 23.26.71.145 dup с 23.26.71.145:5628 +198.23.243.226:10000 DEAD +45.38.107.97:10001 DEAD +104.164.49.38:10002 DEAD +191.96.254.138:10003 DEAD +84.247.60.125:10004 DEAD +23.26.71.145:10005 DEAD +38.154.185.97:10006 DEAD +64.137.10.153:10007 DEAD +198.46.161.42:10008 DEAD +64.137.96.74:10009 DEAD +45.38.107.97:6014 45.38.107.97 dup с 45.38.107.97:6014 +64.137.96.74:6641 64.137.96.74 dup с 64.137.96.74:6641 +198.23.243.226:6361 198.23.243.226 dup с 198.23.243.226:6361 +38.154.185.97:6370 38.154.185.97 dup с 38.154.185.97:6370 +84.247.60.125:6095 84.247.60.125 dup с 84.247.60.125:6095 +191.96.254.138:6185 191.96.254.138 dup с 191.96.254.138:6185 +198.46.161.42:5092 198.46.161.42 dup с 198.46.161.42:5092 +64.137.10.153:5803 64.137.10.153 dup с 64.137.10.153:5803 +104.164.49.38:7693 104.164.49.38 dup с 104.164.49.38:7693 +23.26.71.145:5628 23.26.71.145 dup с 23.26.71.145:5628 +198.23.243.226:10000 DEAD +45.38.107.97:10001 DEAD +104.164.49.38:10002 DEAD +191.96.254.138:10003 DEAD +84.247.60.125:10004 DEAD +23.26.71.145:10005 DEAD +38.154.185.97:10006 DEAD +64.137.10.153:10007 DEAD +198.46.161.42:10008 DEAD diff --git a/checkin_probe.py b/checkin_probe.py new file mode 100644 index 0000000..a5f85ac --- /dev/null +++ b/checkin_probe.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +"""Проверка механики check-in: шлём X-DeepAI-Code-Check-In с nonce из ответа /theos +и замеряем, начисляются ли Theos. + +python checkin_probe.py [n_accounts] +""" +import json +import sys +import time + +import dpcode as D + +API = D.API + + +def hdrs(machine, nonce=None, up=120, pi=1): + h = {"X-DeepAI-Code-Theos": "4", + "X-DeepAI-Code-Instance": __import__("secrets").token_hex(16), + "X-DeepAI-Code-Machine": machine, + "X-DeepAI-Code-Beacon": "v=1.3.0;up=%d;pi=%d;focus=1" % (up, pi)} + if nonce: + h["X-DeepAI-Code-Check-In"] = nonce + return h + + +def get_theos(s, machine, nonce=None, up=120, pi=1): + r = s.get(API + "/deepai_code/theos", headers=hdrs(machine, nonce, up, pi), timeout=30) + try: + return r.status_code, r.json() + except Exception: + return r.status_code, {"raw": r.text[:150]} + + +def rows(n): + recs = {} + for line in open(D.BANK, encoding="utf-8"): + line = line.strip() + if not line: + continue + r = json.loads(line) + if r.get("cookies"): + recs[r["email"]] = r + zero = [r for r in recs.values() + if float(((r.get("theos") or {}).get("granted")) or 0) == 0] + return zero[:n] + + +def main(): + rounds = int(sys.argv[1]) if len(sys.argv) > 1 else 3 + n = int(sys.argv[2]) if len(sys.argv) > 2 else 2 + for rec in rows(n): + email = rec["email"] + machine = rec.get("machine") or D.machine_header(salt=email) + s = D.session_from(rec) + st, d = get_theos(s, machine) + nonce = (d.get("check_in") or {}).get("nonce") + print("%s start bal=%s granted=%s nonce=%s" % (email, d.get("balance"), d.get("granted"), + (nonce or "")[:8]), flush=True) + for i in range(rounds): + time.sleep(5) + st, d = get_theos(s, machine, nonce=nonce, up=120 + i * 5) + new_nonce = (d.get("check_in") or {}).get("nonce") + print(" r%d http=%s bal=%s granted=%s refresh=%s nonce=%s" + % (i, st, d.get("balance"), d.get("granted"), d.get("refresh_at"), + (new_nonce or "")[:8]), flush=True) + if new_nonce: + nonce = new_nonce + rec["theos"] = d + D.append_bank(rec) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/farm_grabbed.log b/farm_grabbed.log new file mode 100644 index 0000000..82c1be6 --- /dev/null +++ b/farm_grabbed.log @@ -0,0 +1,143 @@ +zero=48 proxies=18 per_ip=5 + RonicaBondukvoc@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + GladysBondwn43p@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + ShanaPersonr7cfx@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + AnniceStokeslidjq@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + KareWiseyztf6@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://102.244.78.61:8083 granted=0/5 misses=5 sum=0.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + RonicaBondukvoc@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + GladysBondwn43p@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + ShanaPersonr7cfx@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + AnniceStokeslidjq@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + KareWiseyztf6@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://103.39.70.68:1452 granted=0/5 misses=5 sum=0.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + RonicaBondukvoc@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + GladysBondwn43p@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + ShanaPersonr7cfx@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + AnniceStokeslidjq@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + KareWiseyztf6@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://103.97.140.64:8080 granted=0/5 misses=5 sum=0.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + RonicaBondukvoc@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + GladysBondwn43p@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + ShanaPersonr7cfx@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + AnniceStokeslidjq@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + KareWiseyztf6@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://134.209.29.120:3128 granted=0/5 misses=5 sum=0.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + RonicaBondukvoc@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + GladysBondwn43p@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + ShanaPersonr7cfx@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + AnniceStokeslidjq@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + KareWiseyztf6@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://138.68.60.8:3128 granted=0/5 misses=5 sum=0.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + RonicaBondukvoc@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + GladysBondwn43p@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + ShanaPersonr7cfx@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + AnniceStokeslidjq@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + KareWiseyztf6@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://139.162.78.109:8080 granted=0/5 misses=5 sum=0.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + RonicaBondukvoc@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + GladysBondwn43p@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + ShanaPersonr7cfx@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + AnniceStokeslidjq@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + KareWiseyztf6@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://139.59.1.14:3128 granted=0/5 misses=5 sum=0.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + RonicaBondukvoc@ecolu.us +67.00 (ip_ok=1) + GladysBondwn43p@ecolu.us +71.00 (ip_ok=2) + ShanaPersonr7cfx@ecolu.us zero + AnniceStokeslidjq@ecolu.us ERR ('Connection aborted.', RemoteDisconnected('Remote + KareWiseyztf6@ecolu.us zero +IP http://144.124.251.24:10122 granted=2/5 misses=3 sum=138.00 + DaniceBlodgett1uzkt@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + DrusillaEstradaoy5wn@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + RhetaColesf1owt@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + NicolleCuevas0umcv@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + LucianaMaciasawb7c@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://15.217.107.97:7014 granted=0/5 misses=5 sum=138.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + DaniceBlodgett1uzkt@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + DrusillaEstradaoy5wn@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + RhetaColesf1owt@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + NicolleCuevas0umcv@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + LucianaMaciasawb7c@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://159.203.61.169:8080 granted=0/5 misses=5 sum=138.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + DaniceBlodgett1uzkt@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + DrusillaEstradaoy5wn@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + RhetaColesf1owt@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + NicolleCuevas0umcv@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + LucianaMaciasawb7c@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://161.35.70.249:80 granted=0/5 misses=5 sum=138.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + DaniceBlodgett1uzkt@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + DrusillaEstradaoy5wn@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + RhetaColesf1owt@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + NicolleCuevas0umcv@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + LucianaMaciasawb7c@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://185.195.254.72:5432 granted=0/5 misses=5 sum=138.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + DaniceBlodgett1uzkt@ecolu.us +74.00 (ip_ok=1) + DrusillaEstradaoy5wn@ecolu.us +47.00 (ip_ok=2) + RhetaColesf1owt@ecolu.us +75.00 (ip_ok=3) + NicolleCuevas0umcv@ecolu.us zero + LucianaMaciasawb7c@ecolu.us zero +IP http://188.166.178.163:3129 granted=3/5 misses=2 sum=334.00 + DannaHoyt9bcnd@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + KarylDaviwaj7q@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + JuliettaPalmernthk4@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + PerleVogeld9c2s@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + EttyCowartyecrp@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://209.97.150.167:3128 granted=0/5 misses=5 sum=334.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + DannaHoyt9bcnd@ecolu.us +199.00 (ip_ok=1) + KarylDaviwaj7q@ecolu.us zero + JuliettaPalmernthk4@ecolu.us zero + PerleVogeld9c2s@ecolu.us zero + EttyCowartyecrp@ecolu.us zero +IP http://216.152.149.246:80 granted=1/5 misses=4 sum=533.00 + KatheBautistasj6un@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + GaleHendrixolfqb@ecolu.us http=403 +403 Forbidden + +< + RaquelaTylerrr5dd@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + CharleanMichaelku8ly@ecolu.us http=403 +403 Forbidden + +< + DanilaVangb2f32@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://45.43.60.220:8080 granted=0/5 misses=5 sum=533.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + KatheBautistasj6un@ecolu.us http=403 +403 Forbidden + +< + GaleHendrixolfqb@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + RaquelaTylerrr5dd@ecolu.us http=403 +403 Forbidden + +< + CharleanMichaelku8ly@ecolu.us http=403 +403 Forbidden + +< + DanilaVangb2f32@ecolu.us http=403 +403 Forbidden + +< +IP http://85.132.108.42:3128 granted=0/5 misses=5 sum=533.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) + KatheBautistasj6un@ecolu.us ERR ('Connection aborted.', ConnectionResetError(10054 + GaleHendrixolfqb@ecolu.us ERR ('Connection aborted.', ConnectionResetError(10054 + RaquelaTylerrr5dd@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + CharleanMichaelku8ly@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 + DanilaVangb2f32@ecolu.us ERR HTTPSConnectionPool(host='api.deepai.org', port=44 +IP http://89.144.53.75:3128 granted=0/5 misses=5 sum=533.00 + ^ вернул 5 аккаунтов в очередь (IP не дал гранта) +TOTAL tried=90 granted_sum=533.00 diff --git a/farm_grant.py b/farm_grant.py new file mode 100644 index 0000000..0f120f8 --- /dev/null +++ b/farm_grant.py @@ -0,0 +1,122 @@ +# -*- coding: utf-8 -*- +"""Фарм Theos: по 5 аккаунтов на каждый egress (лимит гранта = 5 аккаунтов/IP). + +Использование: + python farm_grant.py perfetch [per_ip] + python farm_grant.py status + +proxies.txt: по одному URL прокси в строке (http://user:pass@host:port); строка DIRECT = прямое соединение. +""" +import json +import sys + +import dpcode as D + +PER_IP_DEFAULT = 5 + + +def load_bank(): + recs = {} + for line in open(D.BANK, encoding="utf-8"): + line = line.strip() + if not line: + continue + r = json.loads(line) + if r.get("cookies"): + recs[r["email"]] = r + return recs + + +def zero_accounts(recs): + out = [] + for r in recs.values(): + t = r.get("theos") or {} + try: + g = float(t.get("granted") or 0) + b = float(t.get("balance") or 0) + except Exception: + g = b = 0.0 + if g <= 0 and b <= 0: + out.append(r) + out.sort(key=lambda r: r.get("ts") or 0) + return out + + +def status(): + recs = load_bank() + pos = [(r["email"], float((r.get("theos") or {}).get("balance") or 0)) for r in recs.values()] + have = [(e, b) for e, b in pos if b > 0] + print("accounts=%d with_balance=%d total=%.2f zero=%d" + % (len(recs), len(have), sum(b for _, b in have), len(zero_accounts(recs)))) + + +def perfetch(path, per_ip): + recs = load_bank() + todo = zero_accounts(recs) + proxies = [x.strip() for x in open(path, encoding="utf-8") if x.strip()] + print("zero=%d proxies=%d per_ip=%d" % (len(todo), len(proxies), per_ip), flush=True) + idx = 0 + got = 0.0 + tried = 0 + for px in proxies: + if idx >= len(todo): + break + ok_here = 0 + misses = 0 + batch = [] + while batch.__len__() < per_ip and idx < len(todo): + batch.append(todo[idx]) + idx += 1 + for rec in batch: + tried += 1 + email = rec["email"] + machine = rec.get("machine") or D.machine_header(salt=email) + s = D.session_from(rec) + if px.upper() != "DIRECT": + s.proxies.update({"http": px, "https": px}) + try: + st, d = D.theos(s, machine) + except Exception as e: + misses += 1 + print(" %-40s ERR %s" % (email, str(e)[:50]), flush=True) + continue + if not isinstance(d, dict): + misses += 1 + print(" %-40s http=%s %s" % (email, st, str(d)[:60]), flush=True) + continue + try: + bal = float(d.get("balance") or 0) + except Exception: + bal = 0.0 + rec["theos"] = d + D.append_bank(rec) + if bal > 0: + ok_here += 1 + got += bal + print(" %-40s +%.2f (ip_ok=%d)" % (email, bal, ok_here), flush=True) + else: + misses += 1 + print(" %-40s zero" % email, flush=True) + print("IP %-42s granted=%d/%.0f misses=%d sum=%.2f" % (px[-42:], ok_here, float(per_ip), misses, got), + flush=True) + if ok_here == 0 and misses >= per_ip: + # прокси мёртв или IP уже выжжен — аккаунты не тратим, вернуть в очередь + idx -= len(batch) + print(" ^ вернул %d аккаунтов в очередь (IP не дал гранта)" % len(batch), flush=True) + print("TOTAL tried=%d granted_sum=%.2f" % (tried, got), flush=True) + + +def main(): + cmd = sys.argv[1] if len(sys.argv) > 1 else "status" + if cmd == "status": + status() + elif cmd == "perfetch": + path = sys.argv[2] + per_ip = int(sys.argv[3]) if len(sys.argv) > 3 else PER_IP_DEFAULT + perfetch(path, per_ip) + else: + print("unknown command") + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/ip_probe.py b/ip_probe.py new file mode 100644 index 0000000..bceb464 --- /dev/null +++ b/ip_probe.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +"""Проверка IP-гипотезы: чекаем нулевые аккаунты через ДРУГОЙ egress (прокси). + +python ip_probe.py [n] +""" +import json +import sys + +import dpcode as D + + +def rows(n): + recs = {} + for line in open(D.BANK, encoding="utf-8"): + line = line.strip() + if not line: + continue + r = json.loads(line) + if r.get("cookies"): + recs[r["email"]] = r + zero = [r for r in recs.values() + if float(((r.get("theos") or {}).get("granted")) or 0) == 0] + return zero[:n] + + +def main(): + px = sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:8899" + n = int(sys.argv[2]) if len(sys.argv) > 2 else 4 + proxies = {"http": px, "https": px} + for rec in rows(n): + email = rec["email"] + machine = rec.get("machine") or D.machine_header(salt=email) + s = D.session_from(rec) + s.proxies.update(proxies) + try: + st, d = D.theos(s, machine) + except Exception as e: + print("%-42s ERR %s" % (email, str(e)[:60]), flush=True) + continue + if isinstance(d, dict): + print("%-42s http=%s bal=%s granted=%s refresh=%s" + % (email, st, d.get("balance"), d.get("granted"), d.get("refresh_at")), flush=True) + if float(d.get("balance") or 0) > 0 or float(d.get("granted") or 0) > 0: + rec["theos"] = d + D.append_bank(rec) + else: + print("%-42s http=%s %s" % (email, st, str(d)[:80]), flush=True) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/proxies.txt b/proxies.txt new file mode 100644 index 0000000..a6cbcba --- /dev/null +++ b/proxies.txt @@ -0,0 +1,6 @@ +http://nst:Nst6Rot9x@31.77.251.116:8894 +http://nst:Nst6Rot9x@31.77.251.116:8895 +http://nst:Nst6Rot9x@31.77.251.116:8896 +http://nst:Nst6Rot9x@31.77.251.116:8897 +http://nst:Nst6Rot9x@31.77.251.110:8897 +http://nst:Nst6Rot9x@31.77.251.110:8898 diff --git a/px_93.txt b/px_93.txt new file mode 100644 index 0000000..b67c50f --- /dev/null +++ b/px_93.txt @@ -0,0 +1 @@ +http://127.0.0.1:18896 diff --git a/px_bd.txt b/px_bd.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/px_bd.txt @@ -0,0 +1 @@ + diff --git a/px_grabbed.txt b/px_grabbed.txt new file mode 100644 index 0000000..be6eddf --- /dev/null +++ b/px_grabbed.txt @@ -0,0 +1,18 @@ +http://102.244.78.61:8083 +http://103.39.70.68:1452 +http://103.97.140.64:8080 +http://134.209.29.120:3128 +http://138.68.60.8:3128 +http://139.162.78.109:8080 +http://139.59.1.14:3128 +http://144.124.251.24:10122 +http://15.217.107.97:7014 +http://159.203.61.169:8080 +http://161.35.70.249:80 +http://185.195.254.72:5432 +http://188.166.178.163:3129 +http://209.97.150.167:3128 +http://216.152.149.246:80 +http://45.43.60.220:8080 +http://85.132.108.42:3128 +http://89.144.53.75:3128 diff --git a/rotate_farm.log b/rotate_farm.log new file mode 100644 index 0000000..abcc193 --- /dev/null +++ b/rotate_farm.log @@ -0,0 +1,42 @@ +round 0: zero=58, egress before=89.209.39.60 + CorissMcguireb7edy@ecolu.us zero + OlympiaGentry9gd3r@ecolu.us zero + OlimpiaChase241sx@ecolu.us zero + AlikaPage409ky@ecolu.us zero + ReetaWesleyjcas4@ecolu.us zero +ip 89.209.39.60 -> granted 0/5, sum +0.00 (total 0.00) +DONE total_granted=0.00 +round 0: zero=58, egress before=89.209.138.135 + CorissMcguireb7edy@ecolu.us +82.00 + OlympiaGentry9gd3r@ecolu.us +56.00 + OlimpiaChase241sx@ecolu.us +67.00 + AlikaPage409ky@ecolu.us +48.00 + ReetaWesleyjcas4@ecolu.us +39.00 +ip 89.209.138.135 -> granted 5/5, sum +292.00 (total 292.00) +round 1: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 2: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 3: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 4: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 5: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 6: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 7: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 8: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 9: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 10: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 11: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 12: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 13: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +DONE total_granted=292.00 diff --git a/rotate_farm.py b/rotate_farm.py new file mode 100644 index 0000000..c4bfc78 --- /dev/null +++ b/rotate_farm.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +"""Ротация ZTE-мобильного + фарм Theos: 5 аккаунтов на каждый новый egress. + +python rotate_farm.py [max_rounds] [per_ip] +""" +import json +import subprocess +import sys +import time + +import dpcode as D + +ROT = r"C:/Users/User/tmp/zte_rotate3.py" +PY = r"C:/Users/User/AppData/Local/Programs/Python/Python311/python.exe" +ZTE = "http://127.0.0.1:8899" +LOG = open("rotate_farm.log", "a", encoding="utf-8") + + +def log(*a): + s = " ".join(str(x) for x in a) + print(s, flush=True) + LOG.write(s + "\n") + LOG.flush() + + +def egress(px=ZTE, tries=3): + for _ in range(tries): + try: + r = subprocess.run(["curl", "-s", "-m", "10", "-x", px, "https://api.ipify.org"], + capture_output=True, text=True, timeout=20) + ip = (r.stdout or "").strip() + if ip.count(".") == 3: + return ip + except Exception: + pass + time.sleep(2) + return "" + + +def rotate(): + try: + subprocess.run([PY, ROT], capture_output=True, text=True, timeout=120, + encoding="utf-8", errors="replace", + env={"PATH": "C:/Windows/System32;/c/Windows", "PYTHONIOENCODING": "utf-8"}) + return True + except Exception as e: + log("rotate err", str(e)[:80]) + return False + + +def zero(): + recs = {} + for line in open(D.BANK, encoding="utf-8"): + line = line.strip() + if not line: + continue + r = json.loads(line) + if r.get("cookies"): + recs[r["email"]] = r + out = [] + for r in recs.values(): + t = r.get("theos") or {} + try: + if float(t.get("balance") or 0) <= 0 and float(t.get("granted") or 0) <= 0: + out.append(r) + except Exception: + pass + out.sort(key=lambda r: r.get("ts") or 0) + return out + + +def grant_batch(px, batch): + got = 0.0 + ok = 0 + for rec in batch: + email = rec["email"] + machine = rec.get("machine") or D.machine_header(salt=email) + s = D.session_from(rec) + s.proxies.update({"http": px, "https": px}) + try: + st, d = D.theos(s, machine) + except Exception as e: + log(" %-38s ERR %s" % (email, str(e)[:50])) + continue + if not isinstance(d, dict): + log(" %-38s http=%s %s" % (email, st, str(d)[:50])) + continue + try: + bal = float(d.get("balance") or 0) + except Exception: + bal = 0.0 + rec["theos"] = d + D.append_bank(rec) + if bal > 0: + ok += 1 + got += bal + log(" %-38s +%.2f" % (email, bal)) + else: + log(" %-38s zero" % email) + return ok, got + + +def main(): + rounds = int(sys.argv[1]) if len(sys.argv) > 1 else 12 + per_ip = int(sys.argv[2]) if len(sys.argv) > 2 else 5 + seen = set() + total = 0.0 + for i in range(rounds): + todo = zero() + if not todo: + log("нулевых не осталось — стоп") + break + log("round %d: zero=%d, egress before=%s" % (i, len(todo), egress())) + rotate() + time.sleep(35) + ip = egress(ZTE, tries=6) + if not ip: + log(" нет egress — пропуск") + continue + if ip in seen: + log(" ip %s уже использован — ещё ротация" % ip) + continue + seen.add(ip) + batch = todo[:per_ip] + ok, got = grant_batch(ZTE, batch) + total += got + log("ip %s -> granted %d/%d, sum +%.2f (total %.2f)" % (ip, ok, len(batch), got, total)) + log("DONE total_granted=%.2f" % total) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/rotfarm2.log b/rotfarm2.log new file mode 100644 index 0000000..ec357ed --- /dev/null +++ b/rotfarm2.log @@ -0,0 +1,24 @@ +round 0: zero=43, egress before=89.209.22.114 + ShanaPersonr7cfx@ecolu.us +57.00 + AnniceStokeslidjq@ecolu.us +66.00 + KareWiseyztf6@ecolu.us +46.00 + NicolleCuevas0umcv@ecolu.us +80.00 + LucianaMaciasawb7c@ecolu.us +50.00 +ip 89.209.22.114 -> granted 5/5, sum +299.00 (total 299.00) +round 1: zero=37, egress before=89.209.22.114 + ip 89.209.22.114 уже использован — ещё ротация +round 2: zero=37, egress before=89.209.22.114 + ip 89.209.22.114 уже использован — ещё ротация +round 3: zero=37, egress before=89.209.22.114 + ip 89.209.22.114 уже использован — ещё ротация +round 4: zero=37, egress before=89.209.22.114 + ip 89.209.22.114 уже использован — ещё ротация +round 5: zero=37, egress before=89.209.22.114 + ip 89.209.22.114 уже использован — ещё ротация +round 6: zero=37, egress before=89.209.22.114 + ip 89.209.22.114 уже использован — ещё ротация +round 7: zero=37, egress before=89.209.22.114 + ip 89.209.22.114 уже использован — ещё ротация +round 8: zero=37, egress before=89.209.22.114 + ip 89.209.22.114 уже использован — ещё ротация +round 9: zero=37, egress before=89.209.22.114 diff --git a/rotfarm_run.log b/rotfarm_run.log new file mode 100644 index 0000000..65c717c --- /dev/null +++ b/rotfarm_run.log @@ -0,0 +1,34 @@ +round 0: zero=58, egress before=89.209.138.135 + CorissMcguireb7edy@ecolu.us +82.00 + OlympiaGentry9gd3r@ecolu.us +56.00 + OlimpiaChase241sx@ecolu.us +67.00 + AlikaPage409ky@ecolu.us +48.00 + ReetaWesleyjcas4@ecolu.us +39.00 +ip 89.209.138.135 -> granted 5/5, sum +292.00 (total 292.00) +round 1: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 2: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 3: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 4: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 5: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 6: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 7: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 8: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 9: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 10: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 11: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 12: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +round 13: zero=53, egress before=89.209.138.135 + ip 89.209.138.135 уже использован — ещё ротация +DONE total_granted=292.00 diff --git a/theo_grant_probe.py b/theo_grant_probe.py new file mode 100644 index 0000000..3f2a927 --- /dev/null +++ b/theo_grant_probe.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- +"""Гипотеза: грант Theos начисляется при заходе в веб-чат, а не по API-чеку. + +Берёт N аккаунтов с granted=0, открывает страницу /chat/ai-code браузерными +заголовками, затем читает /deepai_code/theos и печатает до/после. + +python theo_grant_probe.py [N] +""" +import json +import sys +import time + +import dpcode as D + +UA_BROWSER = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " + "(KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36") + + +def rows(n): + recs = {} + for line in open(D.BANK, encoding="utf-8"): + line = line.strip() + if not line: + continue + r = json.loads(line) + if r.get("cookies"): + recs[r["email"]] = r + zero = [r for r in recs.values() + if float(((r.get("theos") or {}).get("granted")) or 0) == 0] + return zero[:n] + + +def bal(s, machine): + st, d = D.theos(s, machine) + if isinstance(d, dict): + return st, d.get("balance"), d.get("granted"), d.get("refresh_at") + return st, None, None, None + + +def visit(s): + h = {"User-Agent": UA_BROWSER, "Accept": "text/html,application/xhtml+xml,*/*;q=0.8", + "Accept-Language": "en-US,en;q=0.9", "Referer": "https://deepai.org/"} + out = [] + for url in ("https://deepai.org/chat/ai-code", "https://deepai.org/dashboard"): + try: + r = s.get(url, headers=h, timeout=45) + out.append("%s %s" % (url.rsplit("/", 1)[-1], r.status_code)) + except Exception as e: + out.append("%s ERR %s" % (url.rsplit("/", 1)[-1], str(e)[:40])) + time.sleep(1.0) + return ",".join(out) + + +def main(): + n = int(sys.argv[1]) if len(sys.argv) > 1 else 5 + for rec in rows(n): + email = rec["email"] + machine = rec.get("machine") or D.machine_header(salt=email) + s = D.session_from(rec) + before = bal(s, machine) + v = visit(s) + time.sleep(1.5) + after = bal(s, machine) + print("%-42s visit[%s] before=%s/%s after=%s/%s refresh=%s" + % (email, v, before[1], before[2], after[1], after[2], after[3]), flush=True) + if float(after[1] or 0) > 0: + rec["theos"] = {"balance": after[1], "granted": after[2], "refresh_at": after[3]} + D.append_bank(rec) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/tooluse_shim.sh b/tooluse_shim.sh new file mode 100644 index 0000000..e817e96 --- /dev/null +++ b/tooluse_shim.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# tool-use тест НАПРЯМУЮ в шим (без ретрай-цепочки new-api) +BODY='{"model":"MODEL","messages":[{"role":"user","content":"Weather in Paris? Use the tool."}],"tools":[{"type":"function","function":{"name":"get_weather","description":"Get weather","parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}}],"tool_choice":"auto","max_tokens":300}' +for m in claude-opus-5-5 gemini-4-argon gpt-6.1-sol kimi-k3.1-pro glm-5.3-flash deepseek-v4.1-flash gpt-6-luna; do + b="${BODY/MODEL/$m}" + printf "%-20s " "$m" + out=$(curl -s -m 90 -X POST 127.0.0.1:8840/v1/chat/completions \ + -H "Content-Type: application/json" -H "Authorization: Bearer none" -d "$b") + echo "$out" | python3 -c " +import json,sys +t=sys.stdin.read() +try: + d=json.loads(t) +except Exception: + print('RAW', t[:80]); raise SystemExit +ch=(d.get('choices') or [{}])[0] +msg=ch.get('message') or {} +tc=msg.get('tool_calls') or [] +if tc: + fn=tc[0].get('function') or {} + print('TOOL_CALLS', fn.get('name'), fn.get('arguments')) +else: + print('NO_TOOL finish=%s content=%r' % (ch.get('finish_reason'), (msg.get('content') or '')[:40])) +" +done \ No newline at end of file diff --git a/tushim.py b/tushim.py new file mode 100644 index 0000000..1b4f295 --- /dev/null +++ b/tushim.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +"""tool use + round-trip против локального шима: python3 tushim.py [models...]""" +import json +import sys +import urllib.request + +BASE = sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:8840/v1/chat/completions" +MODELS = sys.argv[2:] or ["claude-opus-5-5", "glm-5.3-flash"] + +TOOLS = [{"type": "function", "function": { + "name": "get_weather", "description": "Get weather for a city", + "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}}] + + +def post(body, timeout=120): + req = urllib.request.Request(BASE, data=json.dumps(body).encode(), + headers={"Content-Type": "application/json", + "Authorization": "Bearer none"}) + with urllib.request.urlopen(req, timeout=timeout) as r: + return json.loads(r.read().decode()) + + +for m in MODELS: + base = {"model": m, "tools": TOOLS, "tool_choice": "auto", "max_tokens": 300, + "messages": [{"role": "user", "content": "Weather in Paris? Use the tool."}]} + try: + d = post(base) + except Exception as e: + print("%-20s ERR %s" % (m, str(e)[:70]), flush=True) + continue + ch = (d.get("choices") or [{}])[0] + msg = ch.get("message") or {} + tc = msg.get("tool_calls") or [] + if not tc: + print("%-20s NO_TOOL finish=%s" % (m, ch.get("finish_reason")), flush=True) + continue + fn = tc[0].get("function") or {} + rt = "rt_fail" + try: + body2 = dict(base) + body2.pop("tools") + body2.pop("tool_choice") + body2["messages"] = base["messages"] + [ + {"role": "assistant", "content": None, "tool_calls": tc}, + {"role": "tool", "tool_call_id": tc[0].get("id") or "call_1", + "content": json.dumps({"temp_c": 11, "sky": "cloudy"})}] + d2 = post(body2) + txt = ((d2.get("choices") or [{}])[0].get("message") or {}).get("content") or "" + rt = "rt_ok:%r" % txt[:50] + except Exception as e: + rt = "rt_err %s" % str(e)[:50] + print("%-20s TOOL %s(%s) %s" % (m, fn.get("name"), fn.get("arguments"), rt), flush=True) \ No newline at end of file