Commit Graph

40 Commits

Author SHA1 Message Date
Apple
7887f7cbe9 fix: DSML fallback — 3rd LLM call for clean synthesis + think tag stripping
Router (main.py):
- When DSML detected in 2nd LLM response after tool execution,
  make a 3rd LLM call with explicit synthesis prompt instead of
  returning raw tool results to the user
- Falls back to format_tool_calls_for_response only if 3rd call fails

Router (tool_manager.py):
- Added _strip_think_tags() helper for <think>...</think> removal
  from DeepSeek reasoning artifacts

Gateway (http_api.py):
- Strip <think>...</think> tags before sending to Telegram
- Strip DSML/XML-like markup (function_calls, invoke, parameter tags)
- Ensure empty text after stripping gets "..." fallback

Deployed to NODE1 and verified services running.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 10:30:37 -08:00
Apple
0cfd3619ea feat: auto-summarize trigger for agent memory
- Memory Service: POST /agents/{agent_id}/summarize endpoint
  - Fetches recent events by agent_id (new db.list_facts_by_agent)
  - Generates structured summary via DeepSeek LLM
  - Saves summary to PostgreSQL facts + Qdrant vector store
  - Returns structured JSON (summary, goals, decisions, key_facts)

- Gateway memory_client: auto-trigger after 30 turns
  - Turn counter per chat (agent_id:channel_id)
  - 5-minute debounce between summarize calls
  - Fire-and-forget via asyncio.ensure_future (non-blocking)
  - Configurable via SUMMARIZE_TURN_THRESHOLD / SUMMARIZE_DEBOUNCE_SECONDS

- Database: list_facts_by_agent() for agent-level queries without user_id

Tested on NODE1: Helion summarize returns valid Ukrainian summary with 20 events.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 10:15:43 -08:00
Apple
3b924118be fix: quarantine dead brand commands + implement Memory LLM summary
Brand commands (~290 lines):
- Code was trapped inside `if reply_to_message:` block (unreachable)
- Moved to feature flag: ENABLE_BRAND_COMMANDS=true to activate
- Zero re-indentation: 8sp code naturally fits as feature flag body
- Helper functions (_brand_*, _artifact_*) unchanged

Memory LLM Summary:
- Replace placeholder with real DeepSeek API integration
- Structured output: summary, goals, decisions, open_questions, next_steps, key_facts
- Graceful fallback if API key not set or call fails
- Added MEMORY_DEEPSEEK_API_KEY config
- Ukrainian output language

Deployed and verified on NODE1.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 09:42:44 -08:00
Apple
27e66b90bf feat: thread_has_agent_participation + ACK reply linkage
1. thread_has_agent_participation (SOWA Priority 11):
   - New function has_agent_chat_participation() in behavior_policy.py
   - Checks if agent responded to ANY user in this chat within 30min
   - When active + user asks question/imperative → agent responds
   - Different from per-user conversation_context (Priority 12)
   - Wired into both detect_explicit_request() and analyze_message()

2. ACK reply_to_message_id:
   - When SOWA sends ACK ("NUTRA тут"), it now replies to the user's
     message instead of sending a standalone message
   - Better UX: visually linked to what the user wrote
   - Uses allow_sending_without_reply=True for safety

Known issue (not fixed - too risky):
- Lines 1368-1639 in http_api.py are dead code (brand commands /бренд)
  at incorrect indentation level (8 spaces, inside unreachable block)
- These commands never worked on NODE1, fixing 260 lines of indentation
  carries regression risk — deferred to separate cleanup PR

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 09:24:00 -08:00
Apple
1f4472ec18 feat: reply-to-agent detection in Gateway → SOWA Priority 3
When a user replies to an agent's message in Telegram groups,
it is now treated as a direct mention (SOWA FULL response).

Implementation:
- Detect reply_to_message.from.is_bot in Gateway webhook handler
- Verify bot_id matches this agent's token (multi-agent safe)
- Pass is_reply_to_agent=True to detect_explicit_request() and
  analyze_message() (SOWA v2.2)
- Add is_reply_to_agent to Router metadata for analytics

SOWA already had Priority 3 logic for reply_to_agent → FULL,
it was just never wired up (had TODO placeholders with False).

Edge cases handled:
- Only triggers when reply is to THIS agent's bot (not other bots)
- Reply to forwarded messages: won't trigger (from.is_bot would be
  the original sender, not the bot)
- Works alongside existing DM, mention, and training group rules

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 09:16:02 -08:00
Apple
a1599df053 fix: SOWA agent name variants + vision denial prevention
SOWA fixes:
- Add Russian variants for all agents (сэнпай, хелион, друид, etc.)
- Add missing sofiia agent to AGENT_NAME_VARIANTS
- Add /senpai, /sofiia command prefixes

Vision denial fix (all 13 agents):
- Add explicit rule: "Never say you can't see/analyze images"
- Agents have Vision API via Swapper (qwen3-vl-8b)
- When vision model describes a photo, the follow-up text model (DeepSeek)
  must not deny having seen it

Root cause: NUTRA correctly analyzed a photo via vision model, but when
asked a follow-up question, DeepSeek (text model) responded "I cannot
see images" because the system prompt lacked the denial prevention rule.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 08:49:11 -08:00
Apple
ef3473db21 snapshot: NODE1 production state 2026-02-09
Complete snapshot of /opt/microdao-daarion/ from NODE1 (144.76.224.179).
This represents the actual running production code that has diverged
significantly from the previous main branch.

Key changes from old main:
- Gateway (http_api.py): expanded from ~40KB to 164KB with full agent support
- Router: new /v1/agents/{id}/infer endpoint with vision + DeepSeek routing
- Behavior Policy: SOWA v2.2 (3-level: FULL/ACK/SILENT)
- Agent Registry: config/agent_registry.yml as single source of truth
- 13 agents configured (was 3)
- Memory service integration
- CrewAI teams and roles

Excluded from snapshot: venv/, .env, data/, backups, .tgz archives

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 08:46:46 -08:00
Apple
134c044c21 feat: Behavior Policy v1 - Silent-by-default + Short-first + Media-no-comment
NODA1 agents now:
- Don't respond to broadcasts/posters/announcements without direct mention
- Don't respond to media (photo/link) without explicit question
- Keep responses short (1-2 sentences by default)
- No emoji, no "ready to help", no self-promotion

Added:
- behavior_policy.py: detect_directed_to_agent(), detect_broadcast_intent(), should_respond()
- behavior_policy_v1.txt: unified policy block for all prompts
- Pre-LLM check in http_api.py: skip Router call if should_respond=False
- NO_OUTPUT handling: don't send to Telegram if LLM returns empty
- Updated all 9 agent prompts with Behavior Policy v1
- Unit and E2E tests for 5 acceptance cases
2026-02-04 09:03:14 -08:00
Apple
c8698f6a1d feat: add training group support in Gateway
- Added TRAINING_GROUP_IDS constant for Agent Preschool group
- Gateway now adds "[РЕЖИМ НАВЧАННЯ]" prefix for training groups
- Agents will respond to all messages in training groups

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-03 08:03:07 -08:00
Apple
8907fb110c feat: add training mode for Agent Preschool group
All agents now respond to all messages in the training group
"Agent Preschool Daarion.city" without requiring mentions.

Updated prompts: helion, daarwizz, greenfood, nutra, agromatrix, druid

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-03 07:56:20 -08:00
Apple
0d30ea0009 fix: add group silence rules for Helion
Helion now only responds in groups when:
- Mentioned by name/username
- Direct question about Energy Union
- Previously was responding to all messages in groups

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-03 07:51:14 -08:00
Apple
a0a89b577d fix: add missing Telegram tokens for DAARWIZZ, DRUID, GREENFOOD
Synced from NODA1 after 2026-02-03 incident fix.
All 9 agents now have tokens configured.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-03 07:26:56 -08:00
Apple
b9b7660930 feat(P1): Add /metrics endpoint to gateway 2026-01-28 07:14:37 -08:00
Apple
a3923cd96f feat(P0/P1/P2): Add E2E agent prober, version pinning, prometheus fixes 2026-01-28 07:06:07 -08:00
Apple
0c8bef82f4 feat: Add Alateya, Clan, Eonarch agents + fix gateway-router connection
## Agents Added
- Alateya: R&D, biotech, innovations
- Clan (Spirit): Community spirit agent
- Eonarch: Consciousness evolution agent

## Changes
- docker-compose.node1.yml: Added tokens for all 3 new agents
- gateway-bot/http_api.py: Added configs and webhook endpoints
- gateway-bot/clan_prompt.txt: New prompt file
- gateway-bot/eonarch_prompt.txt: New prompt file

## Fixes
- Fixed ROUTER_URL from :9102 to :8000 (internal container port)
- All 9 Telegram agents now working

## Documentation
- Created PROJECT-MASTER-INDEX.md - single entry point
- Added various status documents and scripts

Tokens configured:
- Helion, NUTRA, Agromatrix (existing)
- Alateya, Clan, Eonarch (new)
- Druid, GreenFood, DAARWIZZ (configured)
2026-01-28 06:40:34 -08:00
Apple
5290287058 feat: implement TTS, Document processing, and Memory Service /facts API
- TTS: xtts-v2 integration with voice cloning support
- Document: docling integration for PDF/DOCX/PPTX processing
- Memory Service: added /facts/upsert, /facts/{key}, /facts endpoints
- Added required dependencies (TTS, docling)
2026-01-17 08:16:37 -08:00
Apple
3de3c8cb36 feat: Add presence heartbeat for Matrix online status
- matrix-gateway: POST /internal/matrix/presence/online endpoint
- usePresenceHeartbeat hook with activity tracking
- Auto away after 5 min inactivity
- Offline on page close/visibility change
- Integrated in MatrixChatRoom component
2025-11-27 00:19:40 -08:00
Apple
5ce1bf1035 fix: enable multimodal processing by removing early message check
- Commented out early 'if not update.message' validation at line 723
- This was preventing photo and voice messages from being processed
- process_photo() and process_voice() functions are already implemented
- Now photo/voice updates can reach multimodal handlers before text validation
- Fixes issue where bots showed placeholder messages instead of processing media
2025-11-24 02:51:39 -08:00
Apple
7168aaab1e fix: remove Markdown parse_mode from Telegram messages
- Telegram API returns 400 Bad Request with invalid Markdown characters
- Switched to plain text mode (no parse_mode) to prevent errors
- Photo and voice processing now work correctly
- Fixes issue where vision-8b responses couldn't be sent to users
2025-11-24 02:26:07 -08:00
Apple
ccebc2607d feat: gateway complex routing override for DeepSeek
- Add auto_complex logic: if needs_complex_reasoning, set metadata["provider"] = "cloud_deepseek"
- Add context caching in MemoryClient with 5s TTL
- Add GREENFOOD agent configuration
- This enables automatic routing of complex queries to DeepSeek via explicit_provider_override rule
2025-11-24 02:14:30 -08:00
Apple
830d13b5a2 feat: стандартизація обробки повідомлень для всіх агентів
- Створено AgentConfig для уніфікації конфігурації агентів
- Додано універсальні функції: process_photo(), process_document(), process_voice()
- Створено handle_telegram_webhook() для будь-якого агента
- Рефакторинг telegram_webhook() та helion_telegram_webhook()
- Оновлено process_voice() для використання STT Service
- Додано реєстр агентів AGENT_REGISTRY
- Оновлено health endpoint для показу всіх агентів
- Додано інструкції для додавання нових агентів
2025-11-21 01:50:18 -08:00
Apple
28e0103301 fix: прибрано повідомлення 'Обробляю фото' та оновлено обробку фото через Swapper vision-8b 2025-11-21 01:25:14 -08:00
Apple
9ed17ba907 fix: виправлено get_telegram_file_path для підтримки Helion токена 2025-11-21 01:17:02 -08:00
Apple
7572e45d2a feat: додано обробку фото для Helion бота через Swapper vision-8b 2025-11-21 01:16:33 -08:00
Apple
6d58532d68 fix: змінено обробку фото для використання Swapper vision-8b замість Vision Encoder 2025-11-21 00:50:57 -08:00
Apple
7d65aeff21 feat: додано обробку фото через Vision Encoder у gateway-bot 2025-11-21 00:37:10 -08:00
Apple
36c35cab57 fix: Виправити структуру запиту Helion до Router (context на верхньому рівні) 2025-11-17 13:23:41 -08:00
Apple
4601c6fca8 feat: add Vision Encoder service + Vision RAG implementation
- Vision Encoder Service (OpenCLIP ViT-L/14, GPU-accelerated)
  - FastAPI app with text/image embedding endpoints (768-dim)
  - Docker support with NVIDIA GPU runtime
  - Port 8001, health checks, model info API

- Qdrant Vector Database integration
  - Port 6333/6334 (HTTP/gRPC)
  - Image embeddings storage (768-dim, Cosine distance)
  - Auto collection creation

- Vision RAG implementation
  - VisionEncoderClient (Python client for API)
  - Image Search module (text-to-image, image-to-image)
  - Vision RAG routing in DAGI Router (mode: image_search)
  - VisionEncoderProvider integration

- Documentation (5000+ lines)
  - SYSTEM-INVENTORY.md - Complete system inventory
  - VISION-ENCODER-STATUS.md - Service status
  - VISION-RAG-IMPLEMENTATION.md - Implementation details
  - vision_encoder_deployment_task.md - Deployment checklist
  - services/vision-encoder/README.md - Deployment guide
  - Updated WARP.md, INFRASTRUCTURE.md, Jupyter Notebook

- Testing
  - test-vision-encoder.sh - Smoke tests (6 tests)
  - Unit tests for client, image search, routing

- Services: 17 total (added Vision Encoder + Qdrant)
- AI Models: 3 (qwen3:8b, OpenCLIP ViT-L/14, BAAI/bge-m3)
- GPU Services: 2 (Vision Encoder, Ollama)
- VRAM Usage: ~10 GB (concurrent)

Status: Production Ready 
2025-11-17 05:24:36 -08:00
Ivan Tytar
6dc35500e5 Fix Helion system_prompt: correct payload.context structure
Changed from nested 'payload': {'context': {
to proper 'payload': { 'context': { structure
so Router can extract system_prompt correctly
2025-11-17 00:30:18 +01:00
Ivan Tytar
d110d42195 Fix: separate Telegram bot tokens for DAARWIZZ and Helion
- Modified send_telegram_message() to accept bot_token parameter
- DAARWIZZ webhook now uses DAARWIZZ_TELEGRAM_BOT_TOKEN
- Helion webhook now uses HELION_TELEGRAM_BOT_TOKEN
- Fixes issue where DAARWIZZ messages were sent via Helion bot
2025-11-17 00:22:20 +01:00
Ivan Tytar
e90409e2e9 Simplify Cursor task: only fix indent in router_request 2025-11-17 00:07:49 +01:00
Apple
66f19cf499 feat: Add Helion AI agent for Energy Union
- Add Helion system prompt with 9 user modes
- Add /helion/telegram/webhook endpoint
- Add Helion configuration to docker-compose.yml
- Add HELION-QUICKSTART.md documentation
- Update .env.example with Helion variables

Helion provides technical support for EcoMiner/BioMiner, tokenomics (ENERGY, 1T, kWt), and DAO governance with RAG verification and 4-level compliance.
2025-11-16 09:30:09 -08:00
Apple
65e33add81 feat: add STT service for voice message recognition
- Add STT service with Whisper support (faster-whisper, whisper CLI, OpenAI API)
- Update Gateway to handle Telegram voice/audio/video_note messages
- Add STT service to docker-compose.yml
- Gateway now converts voice → text → DAGI Router → text response
2025-11-15 12:43:41 -08:00
Apple
c78542c5ef feat: add dialog_summaries creation and fix memory integration
- Add create_dialog_summary() method to MemoryClient
- Fix syntax error in http_api.py (extra comma)
- Add CloudFlare tunnel setup instructions
- Gateway now logs conversations to Memory Service
2025-11-15 12:40:46 -08:00
Ivan Tytar
7b360fc360 fix: Gateway response extraction and GPU optimization
- Fixed Gateway to extract response from data.text field
- GPU working: RTX 4000 Ada, response time 7-10s (was 30-40s)
- DAARWIZZ now responds correctly with full personality
- Started Memory Service structure
2025-11-15 18:55:09 +01:00
Ivan Tytar
03d3d6ecc4 fix: increase LLM timeout 30s→60s, fix Gateway request format, add Ollama optimization guide
- Fixed Gateway: 'prompt' → 'message' field name
- Increased LLM provider timeout from 30s to 60s
- Added OLLAMA-OPTIMIZATION.md with performance tips
- DAARWIZZ now responds (slowly but works)
2025-11-15 17:46:35 +01:00
Ivan Tytar
36770c5c92 feat: DAARWIZZ v3 - production persona with full profile and system prompt
- Updated gateway-bot/daarwizz_prompt.txt with v3 system prompt
- Created docs/daarwizz/PROFILE.md with complete agent profile
- Defines DAARWIZZ as digital mayor and MoE coordinator
- Specifies communication style, roles, security policies
- Integration with full DAGI Stack (Router, DevTools, CrewAI, RBAC)
- Knowledge base references to official DAARION.city docs
2025-11-15 17:02:38 +01:00
Ivan Tytar
df0055bb03 fix: Docker deployment - fix Dockerfiles, registry.py f-strings, Gateway app structure 2025-11-15 15:59:42 +01:00
Ivan Tytar
be95bbad9c feat: Add DAARWIZZ agent with personality
DAARWIZZ - Official AI agent for DAARION.city ecosystem

Changes:
- gateway-bot/daarwizz_prompt.txt: System prompt defining DAARWIZZ personality
- gateway-bot/http_api.py: Load and inject DAARWIZZ context into Router requests
- gateway-bot/Dockerfile: Copy DAARWIZZ prompt file to container
- providers/llm_provider.py: Support context.system_prompt from Gateway

Features:
- Telegram webhook sends agent='daarwizz' to Router
- System prompt loaded from file (customizable)
- LLM receives full DAARWIZZ context + RBAC
- Discord support included

Usage:
- User messages DAARWIZZ in Telegram
- Gateway enriches with system prompt + RBAC
- Router routes to LLM with full context
- DAARWIZZ responds with DAO-aware answers

Next: Set TELEGRAM_BOT_TOKEN and test first dialog
2025-11-15 15:31:58 +01:00
Ivan Tytar
3cacf67cf5 feat: Initial commit - DAGI Stack v0.2.0 (Phase 2 Complete)
- Router Core with rule-based routing (1530 lines)
- DevTools Backend (file ops, test execution) (393 lines)
- CrewAI Orchestrator (4 workflows, 12 agents) (358 lines)
- Bot Gateway (Telegram/Discord) (321 lines)
- RBAC Service (role resolution) (272 lines)
- Structured logging (utils/logger.py)
- Docker deployment (docker-compose.yml)
- Comprehensive documentation (57KB)
- Test suites (41 tests, 95% coverage)
- Phase 4 roadmap & ecosystem integration plans

Production-ready infrastructure for DAARION microDAOs.
2025-11-15 14:35:24 +01:00