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>
42 lines
1.0 KiB
Python
42 lines
1.0 KiB
Python
import json
|
|
import os
|
|
import time
|
|
import uuid
|
|
import hashlib
|
|
from pathlib import Path
|
|
from nats.aio.client import Client as NATS
|
|
import asyncio
|
|
|
|
NATS_URL = os.getenv('NATS_URL', 'nats://localhost:4222')
|
|
AUDIT_FILE = os.getenv('AGX_AUDIT_FILE', 'artifacts/audit.log.jsonl')
|
|
|
|
|
|
def _hash(text: str):
|
|
return hashlib.sha256(text.encode()).hexdigest()[:16]
|
|
|
|
|
|
async def _publish_nats(subject: str, payload: dict):
|
|
nc = NATS()
|
|
await nc.connect(servers=[NATS_URL])
|
|
await nc.publish(subject, json.dumps(payload).encode())
|
|
await nc.flush(1)
|
|
await nc.drain()
|
|
|
|
|
|
def audit_event(event: dict):
|
|
Path(AUDIT_FILE).parent.mkdir(parents=True, exist_ok=True)
|
|
with open(AUDIT_FILE, 'a', encoding='utf-8') as f:
|
|
f.write(json.dumps(event, ensure_ascii=False) + '\n')
|
|
try:
|
|
asyncio.run(_publish_nats('agx.audit.delegation', event))
|
|
except Exception:
|
|
pass
|
|
|
|
|
|
def new_trace(user_request: str):
|
|
return {
|
|
'trace_id': str(uuid.uuid4()),
|
|
'user_request_hash': _hash(user_request),
|
|
'ts': int(time.time() * 1000)
|
|
}
|