The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(line,simplex): table-drive setup wizards
Tekniume839edd25fb3
diff --git a/plugins/platforms/line/adapter.py b/plugins/platforms/line/adapter.pyindex b1324d8c8bc..c55018c03e4 100644--- a/plugins/platforms/line/adapter.py+++ b/plugins/platforms/line/adapter.py@@ -870,10 +870,8 @@ def _env_enablement() -> Optional[Dict[str, Any]]:return Noneseeded: Dict[str, Any] = {}if os.getenv("LINE_PORT"):- try:+ with contextlib.suppress(ValueError):seeded["port"] = int(os.environ["LINE_PORT"])- except ValueError:- passfor env, key in (("LINE_HOST", "host"), ("LINE_PUBLIC_URL", "public_url"), ("LINE_HOME_CHANNEL", "home_channel")):if os.getenv(env):seeded[key] = os.environ[env]@@ -901,19 +899,25 @@ async def _standalone_send(return {"error": str(exc)}+_SETUP_PROMPTS = ( # (env var, prompt, masked)+ ("LINE_CHANNEL_ACCESS_TOKEN", "Channel access token", True),+ ("LINE_CHANNEL_SECRET", "Channel secret", True),+ ("LINE_PUBLIC_URL", "Public HTTPS base URL (optional, e.g. https://my-tunnel.example.com)", False),+ ("LINE_ALLOWED_USERS", "Allowed user IDs (comma-separated; blank=skip)", False),+)++def interactive_setup() -> None:"""Minimal stdin wizard for ``hermes setup line`` (writes ``~/.hermes/.env``)."""- print(- "\nLINE Messaging API setup\n------------------------\n"- "Create a Messaging API channel at https://developers.line.biz/console/\nthen copy the values below.\n"- )+ print("\nLINE Messaging API setup\n------------------------\n"+ "Create a Messaging API channel at https://developers.line.biz/console/\nthen copy the values below.\n")try:from hermes_cli.config import get_env_value as _get_env, save_env_value as _set_envexcept ImportError:print("hermes_cli.config not available; set LINE_* vars manually in ~/.hermes/.env")return- def _prompt(var: str, prompt: str, *, secret: bool = False) -> None:+ for var, prompt, secret in _SETUP_PROMPTS:existing = _get_env(var) if callable(_get_env) else Nonesuffix = " [keep current]" if existing else ""try:@@ -924,14 +928,9 @@ def interactive_setup() -> None:value = input(f"{prompt}{suffix}: ").strip()except (EOFError, KeyboardInterrupt):print()- return+ continueif value:_set_env(var, value)-- _prompt("LINE_CHANNEL_ACCESS_TOKEN", "Channel access token", secret=True)- _prompt("LINE_CHANNEL_SECRET", "Channel secret", secret=True)- _prompt("LINE_PUBLIC_URL", "Public HTTPS base URL (optional, e.g. https://my-tunnel.example.com)")- _prompt("LINE_ALLOWED_USERS", "Allowed user IDs (comma-separated; blank=skip)")print("Done. Set the webhook URL in the LINE console to <your-public-url>/line/webhook and enable 'Use webhook'.")diff --git a/plugins/platforms/simplex/adapter.py b/plugins/platforms/simplex/adapter.pyindex 2e14f7de32b..740705af1c6 100644--- a/plugins/platforms/simplex/adapter.py+++ b/plugins/platforms/simplex/adapter.py@@ -650,6 +650,15 @@ async def _standalone_send(return {"error": f"SimpleX send failed: {e}"}+_SETUP_PROMPTS = (+ ("SIMPLEX_WS_URL", "Daemon WebSocket URL (default ws://127.0.0.1:5225)"),+ ("SIMPLEX_ALLOWED_USERS", "Allowed contactIds or display names (comma-separated; blank=skip)"),+ ("SIMPLEX_GROUP_ALLOWED", "Allowed group IDs (comma-separated, or '*' for any; blank=disable groups)"),+ ("SIMPLEX_AUTO_ACCEPT", "Auto-accept incoming contact requests? (true/false, default true)"),+ ("SIMPLEX_HOME_CHANNEL", "Home channel contact/group ID (or empty)"),+)++def interactive_setup() -> None:"""Minimal stdin wizard for ``hermes setup gateway`` → SimpleX; writes ``~/.hermes/.env``."""print(@@ -662,22 +671,16 @@ def interactive_setup() -> None:print("hermes_cli.config not available; set SIMPLEX_* vars manually in ~/.hermes/.env")return- def _prompt(var: str, prompt: str) -> None:+ for var, prompt in _SETUP_PROMPTS:existing = get_env_value(var) if callable(get_env_value) else Nonesuffix = " [keep current]" if existing else ""try:value = input(f"{prompt}{suffix}: ").strip()except (EOFError, KeyboardInterrupt):print()- return+ continueif value:save_env_value(var, value)-- _prompt("SIMPLEX_WS_URL", "Daemon WebSocket URL (default ws://127.0.0.1:5225)")- _prompt("SIMPLEX_ALLOWED_USERS", "Allowed contactIds or display names (comma-separated; blank=skip)")- _prompt("SIMPLEX_GROUP_ALLOWED", "Allowed group IDs (comma-separated, or '*' for any; blank=disable groups)")- _prompt("SIMPLEX_AUTO_ACCEPT", "Auto-accept incoming contact requests? (true/false, default true)")- _prompt("SIMPLEX_HOME_CHANNEL", "Home channel contact/group ID (or empty)")print("Done. Make sure the simplex-chat daemon is running before starting the gateway.")