Luca Sacchi Ricciardi 5aab19626f feat: implement OpenRouter AI integration in n8n workflow
Add 'Call OpenRouter' node to LogWhisperer_Ingest workflow:

New Node Features:
- Model: openai/gpt-4o-mini via OpenRouter API
- System prompt with Metodo Sacchi (Safety First, Little Often, Double Check)
- Timeout: 10 seconds with AbortController
- Log truncation: max 2000 characters
- Required headers: Authorization, HTTP-Referer, X-Title
- Error handling with graceful fallback response
- Output: JSON with ai_analysis, ai_status, ai_timestamp, ai_model

Workflow Flow:
Webhook → HMAC Validation → Data Validation → Store Log → Call OpenRouter → Critical Severity Check → Response

Test Suite (workflows/test_openrouter.js):
- 10 comprehensive tests covering:
  - Input/output structure validation
  - Log truncation logic
  - OpenRouter API payload format
  - Required HTTP headers
  - AI response structure
  - Fallback error handling
  - Timeout configuration
  - Dangerous command patterns
  - System Prompt Metodo Sacchi validation
  - Workflow connections

Environment Variables Required:
- OPENROUTER_API_KEY
- OPENROUTER_SITE_URL (optional, defaults to https://logwhisperer.ai)
- OPENROUTER_APP_NAME (optional, defaults to LogWhispererAI)

Next Steps:
1. Configure environment variables in n8n
2. Import updated workflow to n8n instance
3. Configure PostgreSQL credentials
4. Test with sample log payload

Refs: docs/specs/ai_pipeline.md (section 4.1)
2026-04-02 19:40:42 +02:00
2026-04-02 15:29:41 +02:00

LogWhispererAI 🌌 aka Sacchi's Server Sentinel

UVP: Il DevOps tascabile che traduce i crash del tuo server e ti dice l'esatto comando per risolverli in sicurezza, senza farti perdere ore su StackOverflow.

Tests Version Sprint Status

🎯 Visione del Progetto

LogWhisperer AI trasforma i log di sistema e database spesso incomprensibili in alert azionabili descritti in "plain language". È pensato per piccole web agency e freelance che gestiscono infrastrutture (AWS, DigitalOcean, VPS) senza avere un sistemista senior dedicato.

🚀 Stato di Sviluppo

Feature Stato Sprint
Log Ingestion Script Completato Sprint 1
🔄 AI Processing Pipeline In pianificazione Sprint 2
🔄 Alerting (Telegram/Slack) In pianificazione Sprint 2-3
🔄 Landing Page & Onboarding In pianificazione Sprint 3

Funzionalità MVP

  • Log Ingestion : Script Bash leggero per il monitoraggio (tail -f) di log critici (syslog, nginx, postgres). Invia payload JSON via HTTP POST a webhook.

  • AI Processing Pipeline 🔄: Workflow su n8n che analizza i log tramite LLM (OpenAI/Anthropic) applicando il Metodo Sacchi (Safety first, little often, double check).

  • Alerting Umano 🔄: Notifiche su Telegram/Slack con sintesi del problema, severità e comando esatto per la mitigazione.

🛠️ Stack Tecnologico Core Logic: Python 3.12+ (in venv) Automation: n8n (self-hosted) Database: Supabase / PostgreSQL AI: GPT-4o-mini / Claude 3.5 Sonnet Agentic Dev: OpenCode.ai

🛠️ Setup per lo Sviluppo

Il progetto segue una metodologia Spec-Driven e TDD (Test-Driven Development).

Prerequisiti

  • Python 3.12 o superiore
  • Bash 4.0+
  • curl (GNU coreutils)
  • Node.js 18+ (per i MCP servers)

Clone e setup

# Clone
git clone https://github.com/LucaSacchiNet/LogWhispererAI.git
cd LogWhispererAI

# Ambiente virtuale
python3 -m venv venv
source venv/bin/activate

# Installazione dipendenze
pip install -r requirements.txt

Configurazione MCP (OpenCode.ai)

Il progetto utilizza tre MCP (Model Context Protocol) servers per estendere le capacità dell'agente AI:

  1. sequential-thinking - Problem solving strutturato
  2. context7 - Recupero documentazione contestuale delle librerie
  3. n8n - Integrazione con workflow automation

La configurazione è già presente in .opencode/opencode.json. Per utilizzarla:

# Assicurati di avere npx installato
npm install -g npx

# Avvia OpenCode
opencode

Nota sulla sicurezza: Le credenziali n8n sono configurate nel file .opencode/opencode.json. Non committare mai questo file con credenziali di produzione.

Eseguire i Test

# Attiva l'ambiente virtuale
source venv/bin/activate

# Esegui tutti i test
pytest tests/test_logwhisperer.py -v

# Test con coverage (opzionale)
pytest tests/test_logwhisperer.py -v --tb=short

Usare lo Script di Log Ingestion

# Installazione (interattiva)
./scripts/install.sh

# Verifica configurazione
./scripts/logwhisperer.sh --validate

# Test pattern matching
./scripts/logwhisperer.sh --dry-run --test-line "FATAL: database error"

# Avvio monitoraggio
./scripts/logwhisperer.sh --config /etc/logwhisperer/config.env

🤖 Agenti AI (OpenCode.ai)

Il progetto utilizza uno staff di agenti specializzati definiti in AGENTS.md:

Agente Ruolo
@product-manager Definisce roadmap e valida UVP
@tech-lead Architettura e specifiche tecniche
@python-developer Implementazione Python (TDD)
@bash-expert Script Bash e ottimizzazioni
@security-auditor Vulnerabilità e compliance
@qa-engineer Test suite e coverage
@documentation-agent Docs e changelog

Per avviare una sessione di sviluppo:

opencode

📜 Metodologia e Standard

  • Git: Conventional Commits (feat:, fix:, docs:, test:)
  • Changelog: Common Changelog standard
  • Testing: Pytest per logica Python e test integrazione per script Bash
  • Metodo Sacchi: Safety first, little often, double check

Documentazione

  • docs/prd.md - Product Requirements Document
  • docs/specs/ - Specifiche tecniche per ogni sprint
  • docs/reviews/ - Project Review post-sprint
  • docs/1.setup_procedure/ - Procedure di setup OpenCode.ai
  • docs/sprint1_verification.md - Report verifica sprint

📁 Struttura del Progetto

LogWhispererAI/
├── AGENTS.md                    # Regole agenti e Metodo Sacchi
├── CHANGELOG.md                 # Log modifiche
├── README.md                    # Questo file
├── LICENSE.md                   # Licenza proprietaria
├── requirements.txt             # Dipendenze Python (pytest, requests)
├── docs/
│   ├── prd.md                   # Product Requirements Document
│   ├── specs/
│   │   └── ingestion_script.md  # Specifica tecnica Sprint 1
│   ├── reviews/
│   │   └── sprint1_review.md    # Project Review Sprint 1
│   ├── 1.setup_procedure/       # Setup OpenCode.ai
│   │   ├── setup.md             # Procedura setup
│   │   └── agents.md            # Configurazione agenti
│   └── sprint1_verification.md  # Report verifica
├── scripts/
│   ├── logwhisperer.sh          # Script principale
│   └── install.sh               # Script installazione
├── tests/
│   ├── __init__.py
│   └── test_logwhisperer.py     # Test suite Python
└── .opencode/
    ├── opencode.json            # Configurazione MCP servers
    ├── agents/                  # Configurazioni agenti individuali
    │   ├── tech-lead.md
    │   ├── product-manager.md
    │   ├── python-developer.md
    │   ├── bash-expert.md
    │   ├── security-auditor.md
    │   ├── qa-engineer.md
    │   ├── documentation-agent.md
    │   ├── n8n_specialist_agent.md
    │   └── context_auditor_agent.md
    └── skills/                  # Playbook condivisi
        ├── TDD_Python_Specialist/
        ├── Git_and_Changelog/
        ├── n8n_automation_mastery/
        └── context7_documentation_retrivial/

⚖️ Licenza e Note Legali

Questo software è proprietà riservata di Luca Sacchi Ricciardi.

Tutti i diritti sono riservati. Per ogni controversia derivante dall'uso o dallo sviluppo di questo software, il foro competente in via esclusiva è il Foro di Milano, Italia.

Per i dettagli completi, consultare il file LICENSE.md.

👨‍💻 Autore

Luca Sacchi Ricciardi


LogWhispererAI - "Safety first, little often, double check"

Description
LogWhisperer AI (aka Sacchi's Server Sentinel)
Readme 744 KiB
Languages
TypeScript 31.6%
Shell 22.8%
JavaScript 19.1%
Python 16.4%
HTML 8.1%
Other 2%