qac-cli-commands #26
|
|
@ -23,6 +23,7 @@ import sys
|
|||
from . import config as _config
|
||||
from .hardware import available_devices
|
||||
from .legacy_executor import main as _legacy_main
|
||||
from .namegen import generate_agent_name
|
||||
|
||||
_LEGACY_ALIASES = {"--hub", "--key", "--name", "--device", "--insecure", "--log-level", "--config"}
|
||||
|
||||
|
|
@ -42,7 +43,8 @@ def _cmd_register(args: argparse.Namespace) -> int:
|
|||
|
||||
hub_url = args.hub.rstrip("/")
|
||||
url = f"{hub_url}/screens/agents/register"
|
||||
body = json.dumps({"name": args.name or ""}).encode()
|
||||
name = args.name or generate_agent_name()
|
||||
body = json.dumps({"name": name}).encode()
|
||||
req = urllib.request.Request(
|
||||
url,
|
||||
data=body,
|
||||
|
|
@ -66,8 +68,7 @@ def _cmd_register(args: argparse.Namespace) -> int:
|
|||
cfg.agent_id = agent_id
|
||||
cfg.token = token
|
||||
cfg.api_key = args.api_key
|
||||
if args.name:
|
||||
cfg.name = args.name
|
||||
cfg.name = name
|
||||
cfg.insecure = bool(args.insecure)
|
||||
cfg.tx_enabled = bool(getattr(args, "allow_tx", False))
|
||||
if (v := getattr(args, "tx_max_gain_db", None)) is not None:
|
||||
|
|
|
|||
147
src/ria_toolkit_oss/agent/namegen.py
Normal file
147
src/ria_toolkit_oss/agent/namegen.py
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
"""Generate random human-readable agent names.
|
||||
|
||||
Produces names in the form ``adjective-colour-animal``, e.g.
|
||||
``swift-teal-falcon`` or ``brave-coral-otter``. All words are chosen
|
||||
to be friendly and inoffensive.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import random
|
||||
|
||||
ADJECTIVES: list[str] = [
|
||||
"brave",
|
||||
"bright",
|
||||
"calm",
|
||||
"clever",
|
||||
"cool",
|
||||
"daring",
|
||||
"eager",
|
||||
"fair",
|
||||
"fancy",
|
||||
"fast",
|
||||
"fierce",
|
||||
"gentle",
|
||||
"grand",
|
||||
"happy",
|
||||
"jolly",
|
||||
"keen",
|
||||
"kind",
|
||||
"lively",
|
||||
"lucky",
|
||||
"mighty",
|
||||
"noble",
|
||||
"plucky",
|
||||
"proud",
|
||||
"quick",
|
||||
"quiet",
|
||||
"sharp",
|
||||
"shiny",
|
||||
"sleek",
|
||||
"smart",
|
||||
"steady",
|
||||
"stellar",
|
||||
"strong",
|
||||
"sturdy",
|
||||
"sunny",
|
||||
"sure",
|
||||
"swift",
|
||||
"tall",
|
||||
"vivid",
|
||||
"warm",
|
||||
"wise",
|
||||
]
|
||||
|
||||
COLOURS: list[str] = [
|
||||
"amber",
|
||||
"aqua",
|
||||
"azure",
|
||||
"beige",
|
||||
"blue",
|
||||
"bronze",
|
||||
"coral",
|
||||
"copper",
|
||||
"crimson",
|
||||
"cyan",
|
||||
"denim",
|
||||
"gold",
|
||||
"green",
|
||||
"grey",
|
||||
"indigo",
|
||||
"ivory",
|
||||
"jade",
|
||||
"lemon",
|
||||
"lilac",
|
||||
"lime",
|
||||
"maroon",
|
||||
"mint",
|
||||
"navy",
|
||||
"olive",
|
||||
"onyx",
|
||||
"peach",
|
||||
"pearl",
|
||||
"plum",
|
||||
"red",
|
||||
"rose",
|
||||
"ruby",
|
||||
"rust",
|
||||
"sage",
|
||||
"sand",
|
||||
"scarlet",
|
||||
"silver",
|
||||
"slate",
|
||||
"steel",
|
||||
"teal",
|
||||
"violet",
|
||||
]
|
||||
|
||||
ANIMALS: list[str] = [
|
||||
"badger",
|
||||
"bear",
|
||||
"bison",
|
||||
"crane",
|
||||
"deer",
|
||||
"dolphin",
|
||||
"eagle",
|
||||
"elk",
|
||||
"falcon",
|
||||
"finch",
|
||||
"fox",
|
||||
"gecko",
|
||||
"hawk",
|
||||
"heron",
|
||||
"horse",
|
||||
"ibis",
|
||||
"jaguar",
|
||||
"jay",
|
||||
"kite",
|
||||
"koala",
|
||||
"lark",
|
||||
"lion",
|
||||
"lynx",
|
||||
"marten",
|
||||
"moose",
|
||||
"newt",
|
||||
"orca",
|
||||
"osprey",
|
||||
"otter",
|
||||
"owl",
|
||||
"panda",
|
||||
"puma",
|
||||
"raven",
|
||||
"robin",
|
||||
"salmon",
|
||||
"seal",
|
||||
"shark",
|
||||
"stork",
|
||||
"swift",
|
||||
"wolf",
|
||||
]
|
||||
|
||||
|
||||
def generate_agent_name() -> str:
|
||||
"""Return a random ``adjective-colour-animal`` name."""
|
||||
adj = random.choice(ADJECTIVES)
|
||||
col = random.choice(COLOURS)
|
||||
ani = random.choice(ANIMALS)
|
||||
return f"{adj}-{col}-{ani}"
|
||||
Loading…
Reference in New Issue
Block a user