""" Example: Pulse & Brain with ONLY YOUR chosen checks. By default, pulse_brain.py includes example checks. This shows how to start with a CLEAN SLATE and only add what YOU want. """ import time from pathlib import Path from agent import Agent from pulse_brain import BrainTask, CheckType, PulseCheck, PulseBrain def check_my_file() -> dict: """Check if the important data file exists.""" file = Path("important_data.json") return { "status": "ok" if file.exists() else "error", "message": f"File exists: {file.exists()}", } def main() -> None: agent = Agent(provider="claude", enable_heartbeat=False) # Create Pulse & Brain with NO automatic checks pb = PulseBrain(agent, pulse_interval=60) # Remove all default checks (start clean) pb.pulse_checks = [] pb.brain_tasks = [] print( "Starting with ZERO checks. " "You have complete control.\n" ) # Add ONLY the checks you want pb.pulse_checks.append( PulseCheck( "my-file", check_my_file, interval_seconds=300, ), ) pb.brain_tasks.append( BrainTask( name="file-recovery", check_type=CheckType.CONDITIONAL, prompt_template=( "The file important_data.json is missing. " "What should I do to recover it?" ), condition_func=lambda data: ( data.get("status") == "error" ), ), ) print("Added 1 pulse check: my-file") print("Added 1 brain task: file-recovery") print("\nThe agent will ONLY:") print( " 1. Check if important_data.json exists " "(every 5 min, zero cost)" ) print( " 2. Ask for recovery help IF it's missing " "(costs tokens)" ) print("\nNothing else. You have complete control.\n") pb.start() try: print("Running... Press Ctrl+C to stop\n") while True: time.sleep(1) except KeyboardInterrupt: pb.stop() if __name__ == "__main__": main()