name: clawds.ai Heartbeat

on:
  push:
    paths:
      - 'MEMORY.md'
      - 'SOUL.md'
      - 'IDENTITY.md'
      - 'AGENTS.md'
      - 'TOOLS.md'
  schedule:
    - cron: '0 */6 * * *'  # Every 6 hours
  workflow_dispatch:

jobs:
  heartbeat:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Push snapshot to clawds.ai
        run: |
          # Collect memory files that exist
          FILES=""
          for f in MEMORY.md SOUL.md IDENTITY.md AGENTS.md TOOLS.md; do
            if [ -f "$f" ]; then
              FILES="$FILES -F \"$f=@$f\""
            fi
          done
          
          # Push snapshot
          eval curl -s -X POST \
            "https://clawds.ai/api.php?action=snapshot&token=${{ secrets.CLAWDS_TOKEN }}&type=auto" \
            $FILES
          
          # Send heartbeat
          curl -s "https://clawds.ai/api.php?action=heartbeat&token=${{ secrets.CLAWDS_TOKEN }}"
          
          echo "✅ clawds.ai snapshot pushed"
