Files
personal-agent-os/agent-comms/sync-bot/sync-bot.py
T

37 lines
1.1 KiB
Python

# Grok-Leonard Sync Bot - MVP
import os
import json
import time
from datetime import datetime
# Config
INBOX_DIR = 'agent-comms/grok-inbox'
OUTBOX_DIR = 'agent-comms/leonard-outbox'
ARCHIVE_DIR = 'agent-comms/archive'
os.makedirs(ARCHIVE_DIR, exist_ok=True)
print('Grok-Leonard Sync Bot started...')
while True:
# Simple poll for new messages
for filename in os.listdir(INBOX_DIR):
if filename.startswith('grok-to-leonard') or filename.endswith('.md'):
filepath = os.path.join(INBOX_DIR, filename)
try:
with open(filepath, 'r') as f:
content = f.read()
print(f'[{datetime.now()}] Processed message: {filename}')
# TODO: Parse JSON frontmatter, generate response, write to leonard-outbox
# Archive
archive_path = os.path.join(ARCHIVE_DIR, filename)
os.rename(filepath, archive_path)
except Exception as e:
print(f'Error processing {filename}: {e}')
time.sleep(10) # Poll every 10 seconds