Files
microdao-daarion/packages/agromatrix-tools/agromatrix_tools/tool_event_bus.py
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

33 lines
958 B
Python

import os
import time
from .audit import audit_tool_call
import asyncio
import json
from nats.aio.client import Client as NATS
NATS_URL = os.getenv("NATS_URL", "nats://localhost:4222")
async def publish(subject: str, payload: dict):
_t = time.time()
nc = NATS()
await nc.connect(servers=[NATS_URL])
await nc.publish(subject, json.dumps(payload).encode())
await nc.flush(1)
await nc.drain()
audit_tool_call("tool_event_bus.publish", {"subject": subject}, {"ok": True}, True, int((time.time()-_t)*1000))
async def subscribe(subject: str, handler, duration: float = 5.0):
nc = NATS()
await nc.connect(servers=[NATS_URL])
async def cb(msg):
data = msg.data.decode()
handler(subject, data)
await nc.subscribe(subject, cb=cb)
await asyncio.sleep(duration)
await nc.drain()
audit_tool_call("tool_event_bus.publish", {"subject": subject}, {"ok": True}, True, int((time.time()-_t)*1000))