From 120fae8ca9e1c2445e5930c5103c6947f5964d40 Mon Sep 17 00:00:00 2001 From: Prime Backup Bot Date: Wed, 11 Mar 2026 23:51:59 +0000 Subject: [PATCH] feat(chat-v1.2): owner fast-lane and assistant-first conversational execution flow --- docs/PRIME_BOOTSTRAP.md | 5 +++++ prime_core/risk.py | 6 ++++++ prime_core/telegram_control.py | 21 ++++++++++++++++----- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/docs/PRIME_BOOTSTRAP.md b/docs/PRIME_BOOTSTRAP.md index 9aa6077..d37c17a 100644 --- a/docs/PRIME_BOOTSTRAP.md +++ b/docs/PRIME_BOOTSTRAP.md @@ -110,3 +110,8 @@ Behavior: - Interprets intent via OpenAI/Codex (`prime_core/chat_mode.py`) - For action requests: proposes plan and asks for explicit approval (`approve`) when strict/confirm needed - Keeps pending user action context in `state/pending-actions.json` + +## 14) Chat Mode v1.2 (assistant-first behavior) +- Owner fast-lane for conversational planning/research requests +- Hard blocks only for tier4 destructive/external asks +- Softer plan/confirm messaging for normal requests diff --git a/prime_core/risk.py b/prime_core/risk.py index f40d389..fbbdea3 100644 --- a/prime_core/risk.py +++ b/prime_core/risk.py @@ -5,6 +5,10 @@ TIERS = { 'tier2_safe_write': ['queue add', 'queue approve', 'queue deny', 'goals add', 'mode autonomous'], } +LOW_RISK_INTENT_KEYWORDS = [ + 'look into', 'investigate', 'research', 'come up with', 'figure out', 'plan', 'analyze', 'summarize' +] + HIGH_RISK_KEYWORDS = [ 'delete', 'destroy', 'drop', 'shutdown', 'reboot', 'rm -rf', 'passwd', 'userdel', 'mkfs', 'iptables', 'ufw deny', 'curl http', 'wget http' @@ -17,6 +21,8 @@ def classify(text: str) -> str: return 'tier1_read' if any(t.startswith(cmd) for cmd in TIERS['tier2_safe_write']): return 'tier2_safe_write' + if any(k in t for k in LOW_RISK_INTENT_KEYWORDS): + return 'tier1_read' if any(k in t for k in HIGH_RISK_KEYWORDS): return 'tier4_destructive_or_external' return 'tier3_modify' diff --git a/prime_core/telegram_control.py b/prime_core/telegram_control.py index 05824fa..daad952 100644 --- a/prime_core/telegram_control.py +++ b/prime_core/telegram_control.py @@ -153,9 +153,12 @@ def parse_and_handle(chat_id: int, msg_id: int, text: str) -> str: raw = text.strip() normalized = raw.lstrip('/').strip() risk = classify(normalized) - log_event({'event':'telegram_command','chat_id':chat_id,'msg_id':msg_id,'text':raw,'risk':risk}) - if needs_approval(normalized) and not normalized.lower().startswith('queue add'): - return f"Command blocked pending explicit queue workflow. Risk={risk}. Use queue add ... then approve." + owner = str(chat_id) == owner_id() + log_event({'event':'telegram_command','chat_id':chat_id,'msg_id':msg_id,'text':raw,'risk':risk,'owner':owner}) + # hard block only truly destructive/external commands unless explicitly queued + if risk == 'tier4_destructive_or_external' and not normalized.lower().startswith('queue add'): + return ("I can do that, but it is high risk. " + "Please use queue add ... and then approve so we have an audit trail.") if raw.startswith('/start'): return "Prime online. " + help_text() if raw.startswith('/help') or raw == 'help': @@ -289,6 +292,7 @@ def parse_and_handle(chat_id: int, msg_id: int, text: str) -> str: mode = load_mode() if mode.get('chat_enabled', True): uid = str(chat_id) + owner = str(chat_id) == owner_id() interp = interpret_text(raw) intent = (interp.get('intent') or 'unknown').lower() @@ -303,11 +307,18 @@ def parse_and_handle(chat_id: int, msg_id: int, text: str) -> str: task_type = interp.get('task_type') or 'planning' task = interp.get('task') or raw strict = bool(mode.get('strict_mode', False)) + # owner fast-lane: planning/analysis can auto-queue unless strict mode is on + if owner and task_type in {'planning','other'} and not strict: + code, out = run_prime(['queue','add', 'planning', task]) + return f"Got it — I'll work on that.\nQueued planning task:\n{out[:2800]}" + if strict or bool(interp.get('needs_confirmation', True)): set_pending(uid, task_type, task) - return f"Plan: I can execute this as {task_type}.\nTask: {task}\nReply 'approve' to proceed or 'deny' to cancel." + return (f"Got it. Proposed plan type: {task_type}.\n" + f"Task: {task}\n" + "Reply 'approve' to execute or 'deny' to cancel.") code, out = run_prime(['queue','add', task_type, task]) - return f"Queued.\n{out[:3000]}" + return f"Queued and moving.\n{out[:3000]}" if intent in {'chat','ask','unknown'}: return interp.get('reply') or "I'm here. What would you like to do next?"