@nekzus/liop runtime layer coordinates network topology detection, dynamic routing across heterogeneous transports, off-thread compute pools, and machine-to-machine (M2M) authentication lifecycles.
It ensures that whether an agent executes in a local development environment, an edge reverse proxy, or a high-security distributed mesh, requests route through the most performant and secure channel available.
Adaptive Network Discovery (TopologyProbe)
Rather than requiring operators to manually configure endpoints, multiaddrs, and OIDC discovery URLs, TopologyProbe implements single-URL auto-discovery conforming to RFC 9728 (OAuth 2.0 Protected Resource Metadata), RFC 8414, and NIST SP 800-207 (Zero Trust Architecture).
Topology Probe Options
TopologyProbeOptions
required
Endpoint descriptors and credentials for network probing.
Mode Resolution Matrix
Per-Tool Hybrid Routing (RoutingTable)
In enterprise architectures, different capabilities have different latency and compliance boundaries. RoutingTable manages per-tool transport mapping, latency telemetry, and automatic circuit breaker isolation.
Circuit Breaker Invariants
To prevent cascading failures across the distributed mesh,RoutingTable maintains active health metrics for every registered route:
recordSuccess(toolName, latencyMs): Resets consecutive failure counters to0and updates latency rolling averages.recordFailure(toolName): Increments consecutive failure count.- Trip Condition (
MAX_FAILURES = 5): When a route reaches 5 consecutive failures, the circuit breaker opens. The runtime logs a warning and instructs dispatchers to try fallback routes or return an explicitErrorCode.CIRCUIT_BREAKER_OPEN. getAllToolDefinitions(): Returns an alphabetically sorted list of active tools, automatically fulfilling the MCPtools/listprotocol requirement.
Off-Thread Concurrency (Piscina Worker Pool)
Cryptographic operations (ML-KEM-768 key exchange, AES-256-GCM decryption) and Abstract Syntax Tree parsing via Acorn are computationally expensive. Executing them directly on the main Node.js thread can cause event loop lag, dropping real-time network packets.
LIOP embeds a tuned Piscina worker pool to isolate heavy computation off the event loop:
Worker Pool Properties
Machine-to-Machine Token Lifecycle (TokenManager)
The TokenManager class handles Machine-to-Machine (M2M) Bearer token lifecycles under OAuth 2.1 (RFC 6749, RFC 8707 Resource Indicators, RFC 9068 JWT Profile).
Preemptive Refresh & Concurrency De-duplication
To survive bursty workloads without transient 401 Unauthorized errors,TokenManager implements two core patterns:
- Preemptive Refresh Buffer (
REFRESH_BUFFER_MS = 30_000): If an active access token has fewer than 30 seconds of remaining validity,TokenManagertriggers a refresh before dispatching the request. This eliminates authentication race conditions during long-running WASI executions. - In-Flight Request Coalescing: When multiple concurrent calls invoke
getToken()on an expired or uninitialized cache,TokenManagerdeduplicates them into a single in-flight HTTP POST promise (pendingPromise). All callers resolve against the single response, avoiding token endpoint rate-limit throttling.