#!/usr/bin/env python3 """Generate agent bearer token and SQL to insert into agent_tokens.""" import hashlib import secrets import sys def main() -> None: name = sys.argv[1] if len(sys.argv) > 1 else "GPO-Production" token = secrets.token_urlsafe(32) token_hash = hashlib.sha256(token.encode()).hexdigest() print(f"Token (simpan aman, hanya ditampilkan sekali):\n{token}\n") print("SQL insert:") print( f"INSERT INTO agent_tokens (name, token_hash, is_active) " f"VALUES ('{name}', '{token_hash}', true);" ) print("\n.env:") print(f"AGENT_BEARER_TOKEN={token}") if __name__ == "__main__": main()