#!/bin/bash # Source user profile to ensure Letta is in PATH source /home/cameron/.bashrc # Ensure we are in the correct directory cd /home/cameron/void # Log the execution time echo "--- Void Execution Loop Triggered at $(date) ---" # 1. Fetch data locally (cheap API calls) ./.venv/bin/void-cli sync ./.venv/bin/void-cli monitor # 2. Run the heuristic check if ./.venv/bin/python src/void_tools/precheck.py; then echo "Actionable data confirmed. Invoking Letta Agent to draft responses..." export LETTA_API_KEY=$(grep LETTA_API_KEY .env | cut -d '"' -f 2) letta -a agent-c52e371d-cb89-4f99-8634-b606bdc69cad -p "CRITICAL: You are running in a headless CRON environment. You MUST NOT output any conversational text. Your very first action MUST be a tool call to RunShellCommand to read inbox.yaml and then write outbox.yaml. Do not execute the dispatch command yourself. If you output regular text first, the process will terminate and fail." echo "Agent execution complete. Dispatching outbox..." if ./.venv/bin/void-cli dispatch; then # Phase 3: Post-dispatch verification echo "Running post-dispatch verification..." ./.venv/bin/python verify_dispatch.py verify_exit=$? if [ $verify_exit -eq 2 ]; then echo "ALERT: Significant under-dispatch detected. Check recent outbox archives." ./.venv/bin/python alert_admin.py "Significant under-dispatch: actionable items not fully addressed. Check outbox archives." "CRITICAL" elif [ $verify_exit -eq 1 ]; then echo "WARNING: Minor under-dispatch detected." fi else echo "ERROR: Dispatch failed. Check outbox.yaml for issues." ./.venv/bin/python alert_admin.py "void-cli dispatch failed. Check cron_execution.log for details." "CRITICAL" fi else echo "Pre-check negative. Sleeping until next cycle." fi