import os, uuid, json, urllib.request
endpoint = os.environ["VISIONX_AGENT_ENDPOINT"]
key = os.environ["VISIONX_AGENT_KEY"]  # Server-side only
def report(op, payload):
    request = urllib.request.Request(endpoint, data=json.dumps({"op": op, "payload": payload}).encode(), headers={"Authorization": "Bearer " + key, "Content-Type": "application/json"}, method="POST")
    with urllib.request.urlopen(request, timeout=20) as response:
        return json.load(response)
registration = report("register", {"external_id": "claims-worker-v1", "name": "Claims worker", "type": "workflow", "framework": "LangGraph"})
agent_id = registration["agents"][0]["id"]
correlation_id = str(uuid.uuid4())
report("tool_start", {"agent_id": agent_id, "correlation_id": correlation_id, "tool_name": "documents.read"})
# Your tool authorization stays independent. Never report arguments or results.
report("tool_finish", {"agent_id": agent_id, "correlation_id": correlation_id, "tool_name": "documents.read", "outcome": "success"})
report("heartbeat", {"agent_id": agent_id})
