From 7ab615901a16b84bf46b9d7e817a5aa7e3c1e3af Mon Sep 17 00:00:00 2001 From: operator Date: Sat, 3 Oct 2026 17:15:53 +0000 Subject: [PATCH] muse-chat-api.py: unified agent naming (muse, pip) --- bin/muse-chat-api.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/bin/muse-chat-api.py b/bin/muse-chat-api.py index 3885ee5..4e370da 100755 --- a/bin/muse-chat-api.py +++ b/bin/muse-chat-api.py @@ -1,26 +1,30 @@ #!/usr/bin/env python3 """ -Multi-account muse.ai chat API. +Multi-account muse.ai chat API. Unified naming. Usage: - muse-chat-api.py --account send "message" - muse-chat-api.py --account messages [n] - muse-chat-api.py --account wait [timeout] + muse-chat-api.py --account send "message" + muse-chat-api.py --account messages [n] + muse-chat-api.py --account wait [timeout] -Accounts (configured on bl): - muse-agent : CDP 9410 (smoke node) - ltd.pixels.ltd@gmail.com - pip : CDP 9420 (phone-test node) - piparada (phone OTP) - 646 : (not currently logged in - needs OTP) +The name matches the NetVM node, chrome-box profile, and +the `agent` column in ACCOUNTS.md. No translation. -The account maps to a CDP endpoint. The browser must be running -with the account logged in. +Accounts: + muse : CDP 9410 - ltd.pixels.ltd@gmail.com (email_otp) - ACTIVE + pip : CDP 9420 - piparada (phone_otp) - PENDING (needs re-auth) + 646 : (not set up yet) + +See ACCOUNTS.md for the full registry. """ import json, urllib.request, websocket, time, sys, argparse +# Maps agent name -> CDP URL. The agent name IS the node name. +# TODO: Rename smoke node to 'muse', phone-test to 'pip' for full unification. +# For now, map the unified names to the existing node CDP ports. ACCOUNTS = { - "muse-agent": "http://127.0.0.1:9410/json/list", - "pip": "http://127.0.0.1:9420/json/list", - # "646": "http://127.0.0.1:9430/json/list", # TODO: set up 646 node + "muse": "http://127.0.0.1:9410/json/list", # node: smoke (TODO: rename to muse) + "pip": "http://127.0.0.1:9420/json/list", # node: phone-test (TODO: rename to pip) } def get_page(cdp_url): @@ -41,7 +45,6 @@ def ev(ws, expr, await_p=False): return resp.get('result', {}).get('result', {}).get('value') def cmd_send(ws, message): - # Escape for JS msg_esc = message.replace('\\', '\\\\').replace('`', '\\`').replace('$', '\\$') result = ev(ws, f"""(async()=>{{ const input = document.querySelector('[contenteditable="true"]') || @@ -70,14 +73,13 @@ def cmd_messages(ws, n=5): def cmd_wait(ws, timeout=30): print(f"Waiting {timeout}s for response...") - # Simple: wait and then get messages time.sleep(timeout) cmd_messages(ws, 2) def main(): p = argparse.ArgumentParser() p.add_argument('--account', required=True, choices=list(ACCOUNTS.keys()), - help='Account to use') + help='Agent name (matches node, profile, ACCOUNTS.md)') p.add_argument('command', choices=['send', 'messages', 'wait']) p.add_argument('arg', nargs='?', default=None) args = p.parse_args()