Commit graph

46 commits

Author SHA1 Message Date
eric
5c75ad575d Add fullscreen file editor for email templates, project docs and agent files 2026-02-23 10:23:02 +00:00
eric
7844e82c95 Fix delete JSON error: API routes return 401 JSON instead of HTML redirect, robust fetch error handling 2026-02-23 08:58:18 +00:00
eric
58fcddbff1 Fix mixed content: ProxyFix for HTTPS behind nginx, set PREFERRED_URL_SCHEME=https 2026-02-23 08:56:50 +00:00
eric
04eaac3094 Fix sent emails: use data-attributes for read modal, fix delete route collision with /emails/<email_id> 2026-02-23 08:54:00 +00:00
eric
7a9a69c86d Sent emails log: add read (eye) and delete buttons matching files page style 2026-02-23 08:52:00 +00:00
eric
d31af062ed Add sent emails log to /emails page with full body preview modal 2026-02-23 08:43:13 +00:00
eric
639f093175 Security: harden against prompt injection - remove Bash tool, isolate user input, restrict dangerous commands to orchestrator only 2026-02-23 08:13:07 +00:00
eric
558c2d46f0 Fix Telegram double-message: skip TaskBeat reply if agent already sent via <send_telegram>, strip command blocks from response 2026-02-23 08:03:09 +00:00
eric
be1f375071 Fix Telegram prompt: send only message text to orchestrator, not duplicate title 2026-02-23 07:59:51 +00:00
eric
ab21363032 Fix Telegram: handle None message text and include reply context for bot message replies 2026-02-23 07:57:03 +00:00
eric
86dc556c4e Add daily standup toggle slider and clear-all-tasks button to dashboard 2026-02-22 09:56:12 +00:00
eric
c82ecdd5f1 Fix duplicate Telegram: orchestrator prompt must not send messages during standup (team already contacted directly) 2026-02-21 20:39:35 +00:00
eric
0868a2c71f Fix standup race condition: lock + daily guard + remove standup from TaskBeat whitelist
- _standup_lock: threading.Lock prevents concurrent standup runs
- DB check: if a standup task already exists for today, abort
- TaskBeat whitelist: remove 'standup' type so TaskBeat never re-runs standup tasks
  (standup is always driven by trigger_daily_standup(), not TaskBeat)
2026-02-21 20:28:22 +00:00
eric
8780c2b176 Fix task ordering (FIFO) + Telegram standup reply matching
- get_tasks(): ORDER BY id ASC (oldest first) for TaskBeat FIFO processing
- UI calls use order='desc' so display stays newest-first
- trigger_daily_standup(): standup sub-tasks now stored as type='standup_reply'
  with telegram_chat_id set correctly so replies can be matched
- telegram_message_handler: checks for open standup_reply task from same
  chat_id before creating new task - if found, marks standup complete and
  creates orchestrator follow-up task with full context to process the reply
- tasks.html: badge for standup_reply type
2026-02-21 20:22:39 +00:00
eric
01858b5fc6 Fix TaskBeat: add agent_subtask/standup/broadcast to processing whitelist 2026-02-21 19:53:11 +00:00
eric
003e591a04 Add daily standup + knowledge broadcast system
- DailyStandupBeat thread fires at 09:00 every day
- trigger_daily_standup(): messages all team members, orchestrator updates KB + agent reminders
- broadcast_knowledge_update(): distributes any new info to all agents immediately
- parse_agent_commands(): add <update_knowledge> and <update_agent_reminder> XML handlers
- /api/standup/trigger and /api/broadcast routes for manual triggering
- orchestrator systemprompt: standup + broadcast instructions with examples
- tasks.html: badges for standup / broadcast / action_knowledge task types
2026-02-21 19:46:42 +00:00
eric
7fe1365ebc Fix get_field(): support multiline values in key-value format (email body was truncated to first line) 2026-02-21 19:35:34 +00:00
eric
46a77c7800 Fix /api/agent-stream: use build_agent_prompt, accumulate response_text, call parse_agent_commands 2026-02-21 19:29:20 +00:00
eric
c6ce8a873c fix: Switch agent commands from @-syntax to XML tags — Claude Code refuses to output @-directives
Root cause: opencode/Claude Code recognizes the Frankenbot repo context from CLAUDE.md
and refuses to output @CREATE_SUBTASK, @SEND_EMAIL etc. as they look like 'system
directives'. XML tags (<create_task>, <send_email>, etc.) work reliably.

- parse_agent_commands(): full rewrite with XML tag parser, supports both
  XML child tags and key: value fields within blocks
- build_agent_prompt(): command docs updated to XML format with code examples
- orchestrator/systemprompt.md: rewritten with XML action examples
- ar_manager/systemprompt.md: @ASK_ORCHESTRATOR -> <ask_orchestrator>
2026-02-21 19:21:01 +00:00
eric
d3800ac792 feat: Log all agent actions (@SEND_EMAIL, @SEND_TELEGRAM, @ADD/UPDATE_TEAM_MEMBER) as tasks
Every parsed agent command now creates a task entry with type action_email /
action_telegram / action_team, parent_task_id pointing to the originating task,
and status completed/error reflecting the actual outcome.

Tasks UI gets matching badges for all new types plus a parent-task indicator
(↳ #N) so the full chain from trigger to action is visible at a glance.
2026-02-21 19:06:33 +00:00
eric
f13860f38d fix: Chat streaming uses same full prompt as execute_agent_task
The /chat/send SSE stream was building a stripped-down system prompt
without any Frankenbot command documentation (@CREATE_SUBTASK, @SEND_EMAIL,
@SEND_TELEGRAM etc.), so agents never knew to emit these commands during
web chat sessions — tasks were never created, emails never sent.

Extract build_agent_prompt() as shared function used by both
execute_agent_task() and the streaming chat generator.
2026-02-21 19:04:03 +00:00
eric
eaccbe770a fix: Correct all agent command parsers and document Claude Code tools in system prompt
- @SEND_TELEGRAM: fix regex To: -> TelegramID:, fix DB lookup telegram_chat_id -> telegram_id,
  use send_telegram_message() (sync HTTP) instead of asyncio.run(), support direct numeric IDs
- @ADD_TEAM_MEMBER: fix field order in regex (Name/Role/Responsibilities/Email) to match prompt
- System prompt: document all Claude Code built-in tools (WebFetch, Read, Write, Edit,
  Glob, Grep, Bash) so agents know what is available, clean up command documentation
2026-02-21 18:56:52 +00:00
eric
f6ad727bf0 feat: Persist outbound emails, fix @UPDATE_TEAM_MEMBER parser, add per-entry delete
- Add sent_emails table to DB for persistent outbox logging
- send_email() now writes every outgoing mail (incl. errors) to sent_emails
- parse_agent_commands() passes agent_key/task_id as triggered_by metadata
- Fix @UPDATE_TEAM_MEMBER parser: now matches Identifier/TelegramID/Role/etc.
  format from system prompt (was expecting Email/Field/Value — never matched)
- update_team_member() called correctly via **kwargs (was positional args bug)
- Set Piotr telegram_id=1578034974 directly in DB
- email_log.html: two-tab UI (Inbox Journal + Outbox), click-to-expand body
- emails.html: per-message delete button in inbox list
- New routes: DELETE inbox (IMAP expunge), journal entry, sent entry
2026-02-21 18:43:21 +00:00
eric
99df910497 feat: Add Telegram bot integration and task detail/delete UI
- Wire up Telegram bot with token, allowed users and username from .env
- Fix TaskBeat to handle direct tasks (Telegram/email) without sub_tasks
- Fix send_telegram_message to use run_coroutine_threadsafe (avoid event loop clash)
- Add TaskBeat watchdog thread for auto-restart on crash
- Reset stuck in_progress tasks on startup
- Add task detail page (/tasks/<id>) with full response/log view and auto-refresh
- Add task delete route (/tasks/delete/<id>) with confirmation
- Include agent sender info in Telegram task prompts
- Orchestrator self-updated knowledge base with Telegram contact info
2026-02-21 18:14:43 +00:00
eric
5b4b698064 feat: Add webhook endpoint for auto-deploy on git push
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 17:38:00 +00:00
eric
83b1842392 feat: Add password login system and upgrade agent models
- App-level password auth via Flask session (APP_PASSWORD in .env)
- login_required decorator on all routes
- Login page, logout button in navbar, 7-day session lifetime
- Upgrade musik_rechte_advisor and negotiator from Opus 4.0 to Opus 4.6
- Fix orchestrator session cookie overflow (kb/prompts no longer stored in session)
- Change app port from 5000 to 5050 (5000 occupied by Zou/Kitsu)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 17:26:10 +00:00
7ee66397e1 feat: Enhanced Orchestrator Chat with notifications and better UX
- Add task creation notifications in Orchestrator Chat
- New messages appear at top (newest first)
- Add Clear Chat button with confirmation
- Improve timestamps: DD.MM.YYYY HH:MM:SS format
- Support for system notifications (task created, sub-agent responses)
- Add add_orchestrator_notification() helper function
- Auto-notify when agents create sub-tasks
- Clear Chat route: POST /orchestrator/clear
- Better visual distinction between messages and notifications
2026-02-21 18:02:01 +01:00
98ff812a82 fix: Centralize all agent work to their work directories
- Move knowledge base from root to agents/orchestrator/knowledge/
- Move orphaned files (AKM, Event-Plan) to orchestrator/work/
- Update all kb_file paths to new location
- Change orchestrator stream to use work_dir instead of root
- Now ALL agents (including orchestrator) work in their own folders
- No more files created in project root
- Consistent work directory behavior across all agents
2026-02-21 17:48:30 +01:00
4c03663418 fix: Reload AGENTS dict when agent is deleted
- Add global AGENTS reload after agent deletion
- Ensures agent immediately disappears from all dropdowns/UIs
- Matches agent creation behavior (which already reloads)
- Fixes issue where deleted agents still appeared in chat/task forms
2026-02-21 17:42:54 +01:00
e2a853ffde feat: Add live streaming to Chat page
- Replace blocking execute_agent_task() with live subprocess streaming
- Use Popen() to read opencode output line-by-line in real-time
- Send 'chunk' events to frontend as agent thinks
- Frontend appends chunks incrementally for live response
- Matches Orchestrator's streaming UX
- No more waiting for complete response before seeing output
2026-02-21 17:32:37 +01:00
2a9941f35f feat: Material Icons, customizable app name & dark/light mode toggle
- Add Google Material Icons integration with smart_toy robot icon
- Implement app_settings database table for persistent configuration
- Add App Name customization in Settings (changes navigation & title)
- Add Dark/Light Mode theme switcher
  - Dark Mode: Lightened black (#0f0f0f) with blue accents (#0a84ff)
  - Light Mode: Clean white/gray with red accents (#ef4444)
- Create context_processor for global app_settings injection
- Redesign Settings page with new App Design section
- Optimize CSS: 724 additions, reduced complexity
- Remove outdated agent reminders (70 lines cleanup)
2026-02-21 16:59:18 +01:00
d48537b1fd fix: Handle orchestrated tasks without sub_tasks
Problem:
- Task #1 was stuck in 'in_progress' status
- TaskBeat expects 'sub_tasks' array for orchestrated tasks
- Tasks created via old API didn't have sub_tasks defined
- TaskBeat only processes 'pending' tasks, so in_progress tasks stay stuck

Solution:
- Added validation: if orchestrated task has no sub_tasks, mark as completed with error message
- Prevents infinite loop with stuck tasks
- Manually completed Task #1 in database

Note: This handles legacy tasks from deprecated /api/orchestrate endpoint.
2026-02-21 15:44:00 +01:00
50c1a0315b feat: UX Cleanup & Critical TaskBeat Fix
UX Improvements:
- Tasks page: Remove 'Create new task' form (orchestrator handles all)
- Orchestrator: Simplified to single 'Prompt' section, removed 'Tasks verteilen'
- Orchestrator: Removed 'Klassisch senden' button (live-only responses)
- Orchestrator: Removed 'Aktive Agenten' display (redundant with dashboard)

Critical Fix:
- TaskBeat now reads pending tasks from DATABASE instead of in-memory array
- All status updates (pending→in_progress→completed) now persist to DB
- Fixes issue where tasks created via API/UI were not being processed
- Agent_key updates also synced to DB

This fixes the bug where Task #1 was stuck in pending status.
2026-02-21 15:04:22 +01:00
1970abf487 fix: Correct url_for endpoint for file deletion routes
Changed all 'files_page' to 'files' in redirect calls:
- delete_agent_file() - 4 occurrences
- delete_project_file() - 4 occurrences

Fixes Internal Server Error (500) when deleting files.
Error was: BuildError: Could not build url for endpoint 'files_page'
2026-02-21 14:38:01 +01:00
57a6ffc046 fix: Update init_default_team_members() to match correct DB data
Corrected team member roles and responsibilities:
- Eric Fischer: Programmer → Funktionserweiterung
- Georg Tschare: CEO → Personalmanagement, Kundenkommunikation, Kommunikation mit Behörden
- Piotr Dyderski: Tech, 3D Art, RnD → Technische Infrastruktur, AI-Agenten, Automatisierung, 3D Avatare, Research and Development

DB data is the source of truth, code now matches.
2026-02-21 14:27:20 +01:00
4ca5132391 feat: Add edit functionality for team members
- Edit modal with Bootstrap for inline editing
- Update name, email, role, responsibilities, telegram_id
- Form validation and error handling
- Success/error flash messages
- Team member data passed to frontend via JSON
2026-02-21 14:22:38 +01:00
0e02611c87 feat: Add Team-Members management page
- New /team route to view all team members
- Add/activate/deactivate team members via UI
- Display name, role, email, responsibilities, telegram_id
- Integrated into main navigation
- Self-learning system info displayed
2026-02-21 14:20:07 +01:00
320a1d4d87 feat: Complete DB migration - Command parsing & task persistence
- Add command parsing for @SEND_EMAIL, @SEND_TELEGRAM, @UPDATE_TEAM_MEMBER, @ADD_TEAM_MEMBER
- Migrate all tasks.append() calls (13 occurrences) to use create_task() for DB persistence
- Update task routes to read from database instead of in-memory array
- Orchestrator beat now executes parsed commands (email/telegram notifications)
- Maintain legacy task_queue compatibility for email processing
- All tasks now persist across app restarts
2026-02-21 14:13:24 +01:00
632a6c253a feat: Team-Member Lernsystem & Automatische Vorstellung
Team-Member Updates:
- Korrigierte Rollen und Verantwortlichkeiten:
  * Eric Fischer: Lead Programming & Tech
  * Georg Tschare: CEO & Kundenkommunikation
  * Piotr Dyderski: SysAdmin, TechLead, 3D Artist & R&D

Neue Funktionen:
- update_team_member() - Aktualisiert Team-Member-Daten per Email/Name
- is_known_team_member() - Prüft ob Email in Team-DB existiert
- @UPDATE_TEAM_MEMBER Kommando für Orchestrator
- @ADD_TEAM_MEMBER Kommando für Orchestrator

Intelligentes Lernsystem:
- Erkennt neue Email-Absender automatisch
- Leitet unbekannte Absender automatisch an Orchestrator
- Orchestrator bittet um Vorstellung (Name, Rolle, Aufgaben)
- Informationen werden in Team-DB gespeichert
- Verbessert zukünftige Koordination

Email-Workflow für neue Absender:
1. Email von unbekanntem @diversityball.at kommt an
2. System erkennt: "Nicht in Team-DB"
3. Orchestrator übernimmt automatisch
4. Fragt freundlich nach Vorstellung
5. Beantwortet auch die eigentliche Anfrage
6. Speichert Infos mit @ADD_TEAM_MEMBER

Vorteile:
✓ Orchestrator baut automatisch Wissensdatenbank auf
✓ Bessere Koordination durch bekannte Verantwortlichkeiten
✓ Keine manuellen Team-Member Einträge nötig
✓ Freundlicher, professioneller Erstkontakt
✓ Lernfähiges System das besser wird

Context-Weiterleitung:
- extra_context aus Tasks wird jetzt durchgereicht
- Kombiniert Email-Kontext + Team-Member-Status
- Agents haben volle Informationen über Absender
2026-02-21 14:01:41 +01:00
5b0cf6e640 feat: Task-Persistierung, Team-Members & Orchestrator Beat
Database:
- Tasks-Tabelle für persistente Task-Speicherung
- Team-Members-Tabelle für reale Mitarbeiter
- Auto-Cleanup: Löscht completed Tasks älter als 7 Tage
- Helper-Funktionen: get_tasks(), create_task(), update_task_db(), delete_task()

Team-Management:
- Standard Team-Members (Eric, Georg, Piotr) beim Start initialisiert
- get_team_members() - Lädt aktive Team-Members
- add_team_member() - Fügt Team-Member hinzu
- get_team_member_summary() - Zusammenfassung für Orchestrator

Orchestrator Beat:
- Läuft alle 30 Minuten automatisch
- Prüft Tasks ohne Fortschritt (>2h pending)
- Prüft blockierte Tasks (>4h in_progress)
- Fragt Orchestrator bei Problemen
- Orchestrator kann Team-Members kontaktieren

Neue Kommandos für Orchestrator:
- @SEND_EMAIL - Email an Team-Member senden
- @SEND_TELEGRAM - Telegram-Nachricht an Team-Member

Integration:
- Team-Member-Info wird in Orchestrator-Systemprompt eingefügt
- Orchestrator kennt jetzt reale Verantwortlichkeiten
- Kann bei Bedarf echte Menschen kontaktieren

Background Threads:
- EmailPoller (alle 2 Min)
- TaskWorker (on-demand)
- TaskBeat (alle 10 Sek)
- OrchestratorBeat (alle 30 Min)  NEU
- TelegramBot (wenn konfiguriert)

TODO:
- Tasks-UI auf DB umstellen
- Delete-Button für Tasks
- Team-Members Verwaltungs-UI
2026-02-21 13:53:51 +01:00
11352d2ca5 feat: Files-Seite verbessert - View, Download & Delete für alle Dateitypen
UI Improvements:
- Agent Work Files: View-, Download- und Delete-Buttons hinzugefügt
- Projektdokumente: Download- und Delete-Buttons hinzugefügt
- Konsistentes UI über alle Datei-Kategorien
- View-Modal für Agent-Dateien (wie Projektdokumente)

Backend:
- /files/agent/<agent_key>/view/<filename> - Agent-Datei anzeigen
- /files/agent/<agent_key>/delete/<filename> - Agent-Datei löschen
- /files/agent/<agent_key>/<filename>?download=1 - Force Download
- /files/project/<filename>?download=1 - Projektdatei Download
- /files/project/delete/<filename> - Projektdatei löschen

Security:
- Path traversal protection für alle Routes
- Whitelist-basierte Dateityp-Validierung
- Agent-Zugriff nur auf eigene work-Verzeichnisse

Features:
- 👁 View: Datei im Modal anzeigen (Markdown, TXT)
- ↓ Download: Force download statt Browser-Ansicht
- ✕ Delete: Datei löschen mit Bestätigung
2026-02-21 13:25:37 +01:00
73c36785e2 feat: Telegram Bot Integration mit QR-Code
Features:
- Telegram Bot mit python-telegram-bot Library
- Bidirektionale Kommunikation (Anfragen → Tasks → Antworten)
- QR-Code auf Settings-Seite für einfache Bot-Verbindung
- User-ID Whitelist für Sicherheit
- Automatische Task-Erstellung aus Telegram-Nachrichten
- Agent-Antworten werden zurück zu Telegram gesendet

Implementation:
- Neue Telegram-Handler in app.py (start, message)
- QR-Code Generator mit qrcode Library
- Settings-Seite erweitert mit Telegram-Konfiguration
- .env.example mit Telegram-Setup-Anleitung
- Background Thread für Telegram Polling
- Integration mit bestehendem Task-System

Configuration:
- TELEGRAM_BOT_TOKEN: Bot Token von @BotFather
- TELEGRAM_BOT_USERNAME: Bot Username für QR-Code
- TELEGRAM_ALLOWED_USERS: Komma-getrennte User-IDs

Usage:
1. Bot via @BotFather erstellen
2. Token + User-IDs in .env eintragen
3. App starten
4. QR-Code auf /settings scannen
5. /start im Bot senden
2026-02-21 13:17:04 +01:00
ca820d20db fix: Code-Quality und Security-Verbesserungen
Security Fixes:
- Fix XSS vulnerability in orchestrator.html (escapeHtml für user input)
- Verbesserte Error-Handling: 4 bare except clauses mit spezifischen Exception-Typen

Code Quality:
- Logging für alle Exception-Handler hinzugefügt
- Timeout für Agent-Tasks von 300s auf 600s erhöht (10 Min)
- Bessere Kommentare für Exception-Handling

Performance:
- Wissensdatenbank aus Systemprompt entfernt
- Agents nutzen @READ_KNOWLEDGE für on-demand Zugriff
- Reduziert Prompt-Größe um ~15KB pro Task

UI Improvements (aus vorherigem Work):
- Tasks: Auto-Refresh Info statt Toggle
- Tasks: Status-Anzeigen statt manuelle Buttons
- Konsistentes Auto-Refresh (15s) wenn Tasks aktiv
2026-02-21 12:36:24 +01:00
93eb8c6d47 feat: Dynamische KI-Modelle, verbessertes Memory-System und Chat-Überarbeitung
🎯 KI-Modellverwaltung
- Dynamisches Laden verfügbarer Modelle via opencode models
- 29 Modelle verfügbar (opencode, anthropic, ollama)
- Gruppierung nach Anbieter in UI
- Cache-Mechanismus (1h TTL) für Performance
- API-Endpoint /api/models für Modellabfrage

🧠 Memory-System komplett überarbeitet
- JSON-basierte strukturierte Erinnerungen statt Markdown-Chaos
- Separate Memory-Typen: tasks.json, notes.json, research.json
- Automatische Memory-Zusammenfassung im Systemprompt
- Limitierung auf letzte 100 Einträge pro Typ
- Vollständige Task-Ergebnisse statt abgeschnittener Texte

📁 Agenten-Ordnerstruktur
- work/ Verzeichnis für Agent-Dateien
- memory/ Verzeichnis für strukturierte Erinnerungen
- Agenten arbeiten nur in eigenem work-Verzeichnis
- Absolute Pfade werden übergeben
- Dateien-UI zeigt Agent-Work-Folders

💬 Chat-System überarbeitet
- Echte Agent-Ausführung statt Mock-Responses
- Server-Sent Events für Live-Streaming
- Session-basierte Chat-History
- Loading-Spinner und Status-Anzeigen
- Automatisches Speichern in Session

🎭 Personality Integration
- personality.md wird jetzt geladen
- Persönlichkeit vor Systemprompt eingefügt
- Gilt für alle: Chat, Tasks, Orchestrator, Email-Poller

 Weitere Verbesserungen
- Alle Agenten nutzen execute_agent_task() zentral
- Memory-Speicherung nach jedem Task
- Work-Files in Datei-Verwaltung sichtbar
- System-Dateien ausgeblendet
- API-Route für Agent-Work-Dateien
2026-02-21 11:44:06 +01:00
84b2fe3dd7 Add agent reminders, model selection, task distribution and delete functionality 2026-02-20 22:37:58 +01:00
Pjot
56d9bc2c76 feat: initial commit – Frankenbot Multi-Agent Orchestration System
- Flask Web-App mit Dashboard, Chat, Orchestrator, Tasks, Dateien, Emails, Agenten, Settings
- Email-Poller (IMAP) mit SQLite-Journal als Failsafe (kein Emailverlust bei Absturz)
- Failsafe-Fenster und Poll-Intervall zur Laufzeit via /settings konfigurierbar
- TaskWorker: IMAP Seen-Flag erst nach erfolgreichem Task-Abschluss
- Whitelist-Filter: eric.fischer, p.dyderski, georg.tschare (gmail + signtime.media), *@diversityball.at
- 9 Agenten: researcher, tax_advisor, document_editor, location_manager, program_manager,
  catering_manager, musik_rechte_advisor, zusammenfasser, orchestration_ui
- Diversity Ball Wien 2026 – Wissensdatenbank, Sponsoringverträge, Email-Vorlagen
2026-02-20 17:31:16 +01:00