feat(intent): conversational filesystem intents + humanized queue replies

This commit is contained in:
Prime Backup Bot
2026-03-12 00:52:27 +00:00
parent 521cc9d39a
commit ea21f0ff5d
2 changed files with 118 additions and 5 deletions
+12 -5
View File
@@ -11,6 +11,7 @@ from pathlib import Path
from .queue import list_blocked
from .guardrails import get_cfg, set_cfg
from .chat_mode import load_mode, save_mode, interpret_text, set_pending, pop_pending
from .intent_actions import interpret_conversation, filesystem_action
from .risk import classify, needs_approval
from .audit import log_event
@@ -179,6 +180,7 @@ def help_text() -> str:
"- goals add <text>\n"
"- guardrails show\n"
"- guardrails set max_tasks_per_hour <n>\n"
"- (conversational filesystem intent: check/read/list/search files)\n"
"- help"
)
@@ -372,6 +374,12 @@ def parse_and_handle(chat_id: int, msg_id: int, text: str) -> str:
if mode.get('chat_enabled', True):
uid = str(chat_id)
owner = str(chat_id) == owner_id()
# conversational filesystem/file-intent handling
ci = interpret_conversation(raw)
if (ci.get('intent') or '').lower() == 'filesystem':
return filesystem_action(ci.get('action',''), ci.get('path','.'), ci.get('query',''))
interp = interpret_text(raw)
intent = (interp.get('intent') or 'unknown').lower()
@@ -379,17 +387,16 @@ def parse_and_handle(chat_id: int, msg_id: int, text: str) -> str:
pending = pop_pending(uid)
if pending:
code, out = run_prime(['queue','add', pending.get('task_type','planning'), pending.get('task','')])
return f"Approved. Queued action.\n{out[:3000]}"
return _format_queue_add_human(out)
return 'No pending action to approve.'
if intent == 'action-request':
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
# 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]}"
return _format_queue_add_human(out)
if strict or bool(interp.get('needs_confirmation', True)):
set_pending(uid, task_type, task)
@@ -397,7 +404,7 @@ def parse_and_handle(chat_id: int, msg_id: int, text: str) -> str:
f"Task: {task}\n"
"Reply 'approve' to execute or 'deny' to cancel.")
code, out = run_prime(['queue','add', task_type, task])
return f"Queued and moving.\n{out[:3000]}"
return _format_queue_add_human(out)
if intent in {'chat','ask','unknown'}:
r = (interp.get('reply') or '').strip()