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>
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
import os
|
|
import time
|
|
from .audit import audit_tool_call
|
|
import requests
|
|
|
|
THINGSBOARD_BASE_URL = os.getenv("THINGSBOARD_BASE_URL", "http://localhost:8081")
|
|
THINGSBOARD_TOKEN = os.getenv("THINGSBOARD_TOKEN", "")
|
|
|
|
|
|
def _headers():
|
|
if THINGSBOARD_TOKEN:
|
|
return {"X-Authorization": f"Bearer {THINGSBOARD_TOKEN}"}
|
|
return {}
|
|
|
|
|
|
def get_latest_telemetry(device_id: str, metric: str, window: int = 3600):
|
|
_t = time.time()
|
|
# Using deviceId with JWT token (admin). If using device token, adapt externally.
|
|
url = f"{THINGSBOARD_BASE_URL}/api/plugins/telemetry/DEVICE/{device_id}/values/timeseries"
|
|
params = {"keys": metric, "startTs": "", "endTs": ""}
|
|
r = requests.get(url, headers=_headers(), params=params, timeout=20)
|
|
r.raise_for_status()
|
|
out = r.json()
|
|
audit_tool_call("tool_thingsboard_read.get_latest_telemetry", {"device_id": device_id, "metric": metric}, {"ok": True}, True, int((time.time()-_t)*1000))
|
|
return out
|
|
|
|
|
|
def get_device_status(device_id: str):
|
|
_t = time.time()
|
|
url = f"{THINGSBOARD_BASE_URL}/api/device/info/{device_id}"
|
|
r = requests.get(url, headers=_headers(), timeout=20)
|
|
r.raise_for_status()
|
|
out = r.json()
|
|
audit_tool_call("tool_thingsboard_read.get_latest_telemetry", {"device_id": device_id, "metric": metric}, {"ok": True}, True, int((time.time()-_t)*1000))
|
|
return out
|