- auth_utils: get_user_role() reads role from auth.json (admin|user, default user) - manage_passwords: new `role` command to promote/demote users (admin-only by convention) - tools/__init__: TOOL_ROLES map, CONFIRM_REQUIRED set, get_tools_for_role(), get_openai_tools_for_role() — both orchestrators now filter tools by caller's role - tools/system: cortex_restart (detached subprocess, 5s delay), cortex_logs (admin-only) - tools/web: http_fetch — direct URL fetch, distinct from web_search - tools/files: file_list (directory listing), file_write (restricted paths, admin-only) - tools/notify: nc_talk_send — proactive outbound via notification.py - orchestrator_engine + openai_orchestrator: user_role param; CONFIRM_REQUIRED tools return a confirmation-request result instead of executing — loop breaks after Claude asks user to confirm in a follow-up message - home/scott/auth.json: role set to admin Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
29 lines
926 B
Python
29 lines
926 B
Python
"""
|
|
Notification tools — proactively send messages to user channels.
|
|
|
|
nc_talk_send routes through notification.py → channels.json.
|
|
Requires notification_channel and notification_room set in the user's channels.json.
|
|
"""
|
|
|
|
import logging
|
|
|
|
from persona import get_user
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
async def nc_talk_send(message: str) -> str:
|
|
"""Send a message to the user via their configured notification channel.
|
|
|
|
Channel is resolved from the user's channels.json (notification_channel key).
|
|
Falls back to Nextcloud Talk if configured. No-op if no channel is set.
|
|
"""
|
|
from notification import notify
|
|
username = get_user()
|
|
try:
|
|
await notify(username, message)
|
|
return f"Message sent to {username}'s notification channel."
|
|
except Exception as e:
|
|
logger.warning("nc_talk_send error for %s: %s", username, e)
|
|
return f"Failed to send notification: {e}"
|