diff --git a/prime_core/telegram_control.py b/prime_core/telegram_control.py index 1d7ca53..ecc767b 100644 --- a/prime_core/telegram_control.py +++ b/prime_core/telegram_control.py @@ -135,10 +135,37 @@ def _chat_answer(text: str) -> str: pass return "Got it — I can help with that." + + +def _format_status_human(out: str) -> str: + import json + try: + obj = json.loads(out) + codex = obj.get('codex_login', {}).get('code', 1) == 0 + claude = obj.get('claude_login', {}).get('code', 1) == 0 + return ("Prime status: healthy.\n" + f"OpenAI/Codex: {'connected' if codex else 'not connected'}\n" + f"Claude: {'connected' if claude else 'not connected'}") + except Exception: + return out[:3000] + + +def _format_queue_add_human(out: str) -> str: + import json + try: + obj = json.loads(out) + return ("Queued ✅\n" + f"Task ID: {obj.get('id')}\n" + f"Type: {obj.get('task_type')}\n" + f"Task: {obj.get('task')}\n" + "I’ll work on this and report back.") + except Exception: + return out[:3000] + def help_text() -> str: return ( "Prime control commands:\n" - "- status\n" + "- status [raw]\n" "- queue list\n" "- blocked\n" "- queue add \n" @@ -245,7 +272,9 @@ def parse_and_handle(chat_id: int, msg_id: int, text: str) -> str: if norm[0] == 'status': code, out = run_prime(['status']) - return f"status (code={code})\n{out[:3500]}" + if len(norm) > 1 and norm[1] == 'raw': + return f"status (code={code})\n{out[:3500]}" + return _format_status_human(out) if norm[:2] == ['queue', 'list']: code, out = run_prime(['queue', 'list']) @@ -257,7 +286,7 @@ def parse_and_handle(chat_id: int, msg_id: int, text: str) -> str: task_type = parts[2] task = ' '.join(parts[3:]) code, out = run_prime(['queue', 'add', task_type, task]) - return f"queue add (code={code})\n{out[:3500]}" + return _format_queue_add_human(out) if norm[:2] == ['queue', 'approve']: if len(parts) != 3: