"""Printed only, outside the sealed rule, written after its verdict was read. Nine NO_URL cards name an endpoint
in a way urls_of does not take: a relative path, or serverUrl, or transports[]. This gives those the same handshake
and the same retry, so the entry can say what they answer. It cannot move the verdict.
Run: python -B other_keys.py out.json"""
import json
import sys
import time

import probe
import rule

URLS = {
    "rohlik.cz": ["https://mcp.rohlik.cz/mcp"],
    "tatum.io": ["https://ai.tatum.io/api/mcp-tools"],
    "dupe.com": ["https://mcp.dupe.com/mcp"],
    "forter.com": ["https://www.forter.com/mcp", "https://mcp.forter.com/mcp"],
    "mamamia.com.au": ["https://mamamia.com.au/mcp/sse"],
    "3saf.com": ["https://3saf.com/mcp"],
    "salla.cloud": ["https://salla.cloud/mcp"],
    "themefisher.com": ["https://themefisher.com/api/mcp/mcp"],
    "xrpl.org": ["https://xrpl.org/mcp"],
}
RANK = {"NOTHING": 0, "LOCKED": 1, "SPEAKS": 2}
out = {d: {u: probe.ask(u) for u in us} for d, us in URLS.items()}
json.dump(out, open(sys.argv[1], "w"), indent=1)
time.sleep(rule.RETRY_MIN * 60)
for d, us in out.items():
    for u, a in us.items():
        if a[0] == "NOTHING":
            again = probe.ask(u)
            if RANK[again[0]] > RANK[a[0]]:
                us[u] = again
json.dump(out, open(sys.argv[1], "w"), indent=1)
print("done", file=sys.stderr)
