node2: fix Sofiia routing determinism + Node Capabilities Service

Bug fixes:
- Bug A: GROK_API_KEY env mismatch — router expected GROK_API_KEY but only
  XAI_API_KEY was present. Added GROK_API_KEY=${XAI_API_KEY} alias in compose.
- Bug B: 'grok' profile missing in router-config.node2.yml — added cloud_grok
  profile (provider: grok, model: grok-2-1212). Sofiia now has
  default_llm=cloud_grok with fallback_llm=local_default_coder.
- Bug C: Router silently defaulted to cloud DeepSeek when profile was unknown.
  Now falls back to agent.fallback_llm or local_default_coder with WARNING log.
  Hardcoded Ollama URL (172.18.0.1) replaced with config-driven base_url.

New service: Node Capabilities Service (NCS)
- services/node-capabilities/ — FastAPI microservice exposing live model
  inventory from Ollama, Swapper, and llama-server.
- GET /capabilities — canonical JSON with served_models[] and inventory_only[]
- GET /capabilities/models — flat list of served models
- POST /capabilities/refresh — force cache refresh
- Cache TTL 15s, bound to 127.0.0.1:8099
- services/router/capabilities_client.py — async client with TTL cache

Artifacts:
- ops/node2_models_audit.md — 3-layer model view (served/disk/cloud)
- ops/node2_models_audit.yml — machine-readable audit
- ops/node2_capabilities_example.json — sample NCS output (14 served models)

Made-with: Cursor
This commit is contained in:
Apple
2026-02-27 02:07:40 -08:00
parent 3965f68fac
commit e2a3ae342a
10 changed files with 867 additions and 33 deletions

View File

@@ -23,6 +23,10 @@ services:
- PIECES_OS_URL=http://host.docker.internal:39300
- NOTION_API_KEY=${NOTION_API_KEY:-}
- XAI_API_KEY=${XAI_API_KEY}
- GROK_API_KEY=${XAI_API_KEY}
- DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY:-}
# ── Node Capabilities ─────────────────────────────────────────────────
- NODE_CAPABILITIES_URL=http://node-capabilities:8099/capabilities
# ── Persistence backends ──────────────────────────────────────────────
- ALERT_BACKEND=postgres
- ALERT_DATABASE_URL=${ALERT_DATABASE_URL:-${DATABASE_URL}}
@@ -39,6 +43,7 @@ services:
- "daarion-city-service:host-gateway"
depends_on:
- dagi-nats
- node-capabilities
networks:
- dagi-network
- dagi-memory-network
@@ -103,6 +108,27 @@ services:
- dagi-network
restart: unless-stopped
node-capabilities:
build:
context: ./services/node-capabilities
dockerfile: Dockerfile
container_name: node-capabilities-node2
ports:
- "127.0.0.1:8099:8099"
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
- NODE_ID=NODA2
- OLLAMA_BASE_URL=http://host.docker.internal:11434
- SWAPPER_URL=http://swapper-service:8890
- LLAMA_SERVER_URL=http://host.docker.internal:11435
- CACHE_TTL_SEC=15
depends_on:
- swapper-service
networks:
- dagi-network
restart: unless-stopped
sofiia-console:
build:
context: ./services/sofiia-console