Files
microdao-daarion/docs/tasks/TASK_PHASE_NODE_AGENT_CABINETS_INTEGRATION_v1.md
Apple bca81dc719 feat: Node Self-Healing, DAGI Audit, Agent Prompts, Infra Invariants
### Backend (city-service)
- Node Registry + Self-Healing API (migration 039)
- Improved get_all_nodes() with robust fallback for node_registry/node_cache
- Agent Prompts Runtime API for DAGI Router integration
- DAGI Router Audit endpoints (phantom/stale detection)
- Node Agents API (Guardian/Steward)
- Node metrics extended (CPU/GPU/RAM/Disk)

### Frontend (apps/web)
- Node Directory with improved error handling
- Node Cabinet with metrics cards
- DAGI Router Card component
- Node Metrics Card component
- useDAGIAudit hook

### Scripts
- check-invariants.py - deploy verification
- node-bootstrap.sh - node self-registration
- node-guardian-loop.py - continuous self-healing
- dagi_agent_audit.py - DAGI audit utility

### Migrations
- 034: Agent prompts seed
- 035: Agent DAGI audit
- 036: Node metrics extended
- 037: Node agents complete
- 038: Agent prompts full coverage
- 039: Node registry self-healing

### Tests
- test_infra_smoke.py
- test_agent_prompts_runtime.py
- test_dagi_router_api.py

### Documentation
- DEPLOY_CHECKLIST_2024_11_30.md
- Multiple TASK_PHASE docs
2025-11-30 13:52:01 -08:00

4.5 KiB
Raw Blame History

TASK_PHASE_NODE_AGENT_CABINETS_INTEGRATION_v1

Проєкт

DAARION.city — Node Cabinet / Agents / DAGI Router

Мета

Зробити єдиний, послідовний шар відображення агентів ноди:

  • DAGI Router → показує фактичних агентів ноди
  • Кабінет Ноди → показує тих самих агентів у секціях "Node Guardian & Steward"
  • Кабінет Агента (/agents/:slug) + System Prompts працюють для всіх активних агентів

Виконано

1. Database Migration (037)

Файл: migrations/037_node_agents_complete.sql

Створено/оновлено:

  • Node Guardian агентів для NODE1 та NODE2
  • Node Steward агентів для NODE1 та NODE2
  • Прив'язки guardian_agent_id та steward_agent_id в node_cache
  • System Prompts для всіх Node Agents
  • Синхронізація ключових агентів з router-config.yml

2. Backend API

Новий endpoint: GET /internal/node/{node_id}/agents

{
  "node_id": "node-2-macbook-m4max",
  "total": 4,
  "guardian": {
    "id": "monitor-node2",
    "name": "Node Guardian (НОДА2)",
    "slug": "monitor-node2",
    "kind": "node_guardian",
    "status": "online",
    "is_guardian": true
  },
  "steward": {
    "id": "node-steward-node2",
    "name": "Node Steward (НОДА2)",
    "slug": "node-steward-node2",
    "kind": "node_steward",
    "status": "online",
    "is_steward": true
  },
  "agents": [...]
}

Оновлення:

  • repo_city.get_agent_by_id() — тепер шукає по id АБО public_slug
  • repo_city.get_node_agents() — новий метод для отримання агентів ноди

3. Frontend

Оновлені файли:

  • apps/web/src/hooks/useDAGIAudit.ts — додано useNodeAgents hook
  • apps/web/src/app/nodes/[nodeId]/page.tsx — інтеграція з useNodeAgents
  • apps/web/src/components/nodes/NodeGuardianCard.tsx — посилання на /agents/{slug}

Зміни:

  • NodeGuardianCard використовує slug для посилань замість id
  • Node Cabinet отримує Guardian/Steward через новий API
  • Fallback на nodeProfile якщо API не повернув дані

4. Node Agents Seed Data

Agent Node Kind Slug
Node Guardian (НОДА1) node-1-hetzner-gex44 node_guardian monitor-node1
Node Guardian (НОДА2) node-2-macbook-m4max node_guardian monitor-node2
Node Steward (НОДА1) node-1-hetzner-gex44 node_steward node-steward-node1
Node Steward (НОДА2) node-2-macbook-m4max node_steward node-steward-node2

5. System Prompts для Node Agents

  • NODE1 Guardian — core + safety prompts
  • NODE2 Guardian — core prompt
  • NODE1 Steward — core prompt
  • NODE2 Steward — core prompt

Застосування на сервері

# 1. Застосувати міграцію
docker exec -i dagi-postgres psql -U postgres -d daarion < migrations/037_node_agents_complete.sql

# 2. Перезапустити city-service
docker-compose restart daarion-city-service

# 3. Зібрати frontend
cd apps/web && npm run build

Перевірка

# 1. Перевірити Node Agents API
curl http://localhost:7001/city/internal/node/node-2-macbook-m4max/agents | jq

# 2. Перевірити що агенти мають public_slug
psql -U postgres -d daarion -c "SELECT id, display_name, public_slug, kind FROM agents WHERE kind LIKE 'node_%'"

# 3. Перевірити agent dashboard API
curl http://localhost:7001/city/agents/monitor-node2/dashboard | jq '.profile.display_name'

Результат

Після застосування:

  1. Node Cabinet (/nodes/[nodeId]):

    • Секція "Node Guardian & Steward" показує реальних агентів
    • Кнопки "Кабінет" ведуть на робочі сторінки /agents/[slug]
  2. Agent Cabinet (/agents/[slug]):

    • Працює для Node Guardian та Node Steward
    • System Prompts заповнені
  3. DAGI Router Card:

    • Active агенти мають робочі посилання в Кабінет
    • Phantom агенти можна синхронізувати

Залежності

  • Migration 036 (node_metrics_extended)
  • Migration 035 (agent_dagi_audit)
  • Migration 030 (node_guardian_steward)