@nekzus/liop 2.5.0-beta.1 → 2.5.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +19 -0
- package/README.md +148 -69
- package/dist/bin/agent.js +27 -303
- package/dist/bridge.d.ts +4 -3
- package/dist/bridge.js +1 -4
- package/dist/chunk-2XHSALII.js +3 -0
- package/dist/chunk-2ZYX736J.js +2 -0
- package/dist/chunk-3WRKTVOF.js +2 -0
- package/dist/chunk-6KFKO6ZX.js +2 -0
- package/dist/chunk-6VK2XALI.js +2 -0
- package/dist/chunk-AYDF3IFZ.js +2 -0
- package/dist/chunk-CTTTLCGL.js +31 -0
- package/dist/chunk-ECRS6N33.js +4 -0
- package/dist/chunk-FDJMH4CB.js +2 -0
- package/dist/chunk-FTF6AMF6.js +2 -0
- package/dist/chunk-GWVSCZUS.js +2 -0
- package/dist/chunk-LEXMMIQI.js +15 -0
- package/dist/chunk-LM26HOJ6.js +31 -0
- package/dist/chunk-MQ5SU26J.js +2 -0
- package/dist/chunk-N35BC62H.js +2 -0
- package/dist/chunk-P6IJ3VBD.js +3 -0
- package/dist/chunk-TKLRW52V.js +2 -0
- package/dist/chunk-V35CXJQN.js +2 -0
- package/dist/chunk-WP5ER7RH.js +3 -0
- package/dist/chunk-XLVEDKM6.js +2 -0
- package/dist/chunk-Y675R34Z.js +2 -0
- package/dist/chunk-YD2AF2M6.js +46 -0
- package/dist/chunk-YLCNV764.js +3 -0
- package/dist/chunk-ZZMSFCJP.js +3 -0
- package/dist/client.d.ts +6 -4
- package/dist/client.js +1 -9
- package/dist/gateway.d.ts +6 -5
- package/dist/gateway.js +1 -10
- package/dist/{hybrid-CF__0YnC.d.ts → hybrid-BZpCiUaV.d.ts} +6 -5
- package/dist/{index-cMV0_yD9.d.ts → index-BYDtRGue.d.ts} +45 -36
- package/dist/{index-BW95kAL4.d.ts → index-ByzjpRCk.d.ts} +37 -72
- package/dist/index.d.ts +221 -50
- package/dist/index.js +4 -312
- package/dist/kyber-PULV7PQX.js +2 -0
- package/dist/mesh.d.ts +27 -143
- package/dist/mesh.js +1 -4
- package/dist/node-Djzm6UYd.d.ts +172 -0
- package/dist/protocol/liop_core.proto +25 -6
- package/dist/server.d.ts +4 -3
- package/dist/server.js +1 -7
- package/dist/types-29zv9X1V.d.ts +455 -0
- package/dist/types.d.ts +2 -1
- package/dist/types.js +1 -2
- package/dist/verifier-DqZ9MQ9l.d.ts +82 -0
- package/dist/verifier-J4NQYZX5.js +2 -0
- package/dist/workers/logic-execution.d.ts +7 -0
- package/dist/workers/logic-execution.js +1 -271
- package/dist/workers/zk-verifier.d.ts +9 -0
- package/dist/workers/zk-verifier.js +1 -173
- package/dist/zk-DzYNWBgo.d.ts +104 -0
- package/package.json +56 -45
- package/dist/bin/agent.js.map +0 -1
- package/dist/bridge.js.map +0 -1
- package/dist/chunk-32ADSAJS.js +0 -104
- package/dist/chunk-32ADSAJS.js.map +0 -1
- package/dist/chunk-547TYL27.js +0 -208109
- package/dist/chunk-547TYL27.js.map +0 -1
- package/dist/chunk-72MNYFR6.js +0 -64
- package/dist/chunk-72MNYFR6.js.map +0 -1
- package/dist/chunk-74CISO2I.js +0 -853
- package/dist/chunk-74CISO2I.js.map +0 -1
- package/dist/chunk-CRZBVFDV.js +0 -616
- package/dist/chunk-CRZBVFDV.js.map +0 -1
- package/dist/chunk-GA3Q2S7O.js +0 -558
- package/dist/chunk-GA3Q2S7O.js.map +0 -1
- package/dist/chunk-JIJPZFR2.js +0 -51
- package/dist/chunk-JIJPZFR2.js.map +0 -1
- package/dist/chunk-OUUTDSOW.js +0 -24
- package/dist/chunk-OUUTDSOW.js.map +0 -1
- package/dist/chunk-PYKRQAER.js +0 -77
- package/dist/chunk-PYKRQAER.js.map +0 -1
- package/dist/chunk-QLCOEP5J.js +0 -68
- package/dist/chunk-QLCOEP5J.js.map +0 -1
- package/dist/chunk-RWRRBYG4.js +0 -3
- package/dist/chunk-RWRRBYG4.js.map +0 -1
- package/dist/chunk-SONUORBT.js +0 -421
- package/dist/chunk-SONUORBT.js.map +0 -1
- package/dist/chunk-T5IUZF47.js +0 -716
- package/dist/chunk-T5IUZF47.js.map +0 -1
- package/dist/chunk-U5BZ66VX.js +0 -447
- package/dist/chunk-U5BZ66VX.js.map +0 -1
- package/dist/chunk-WCCGE4QR.js +0 -3520
- package/dist/chunk-WCCGE4QR.js.map +0 -1
- package/dist/chunk-WSW6YJNY.js +0 -168
- package/dist/chunk-WSW6YJNY.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/gateway.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/kyber-3ULIJSE3.js +0 -3
- package/dist/kyber-3ULIJSE3.js.map +0 -1
- package/dist/mesh.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/types-lJIxBlWF.d.ts +0 -256
- package/dist/types.js.map +0 -1
- package/dist/verifier-3FAKCFNN.js +0 -5
- package/dist/verifier-3FAKCFNN.js.map +0 -1
- package/dist/verifier-COnid_dg.d.ts +0 -31
- package/dist/workers/logic-execution.js.map +0 -1
- package/dist/workers/zk-verifier.js.map +0 -1
package/NOTICE
CHANGED
|
@@ -3,3 +3,22 @@ Copyright 2026 Nekzus Solutions and contributors
|
|
|
3
3
|
|
|
4
4
|
This product includes software developed by
|
|
5
5
|
Nekzus Solutions (https://github.com/Nekzus/LIOP).
|
|
6
|
+
|
|
7
|
+
========================================================================
|
|
8
|
+
Third-Party Bundled Dependencies and Acknowledgments
|
|
9
|
+
========================================================================
|
|
10
|
+
|
|
11
|
+
This SDK statically bundles or adapts software from third parties:
|
|
12
|
+
|
|
13
|
+
1. gpt-tokenizer (https://github.com/niieani/gpt-tokenizer)
|
|
14
|
+
Copyright (c) 2023-2024 Bazyli Brzoska
|
|
15
|
+
Licensed under the MIT License.
|
|
16
|
+
|
|
17
|
+
2. OpenTelemetry JS API (@opentelemetry/api) (https://github.com/open-telemetry/opentelemetry-js)
|
|
18
|
+
Copyright The OpenTelemetry Authors
|
|
19
|
+
Licensed under the Apache License, Version 2.0.
|
|
20
|
+
|
|
21
|
+
3. Model Context Protocol (MCP) (https://modelcontextprotocol.io)
|
|
22
|
+
Protocol schemas and interoperability semantics adapted for backward compatibility.
|
|
23
|
+
Copyright Anthropic, PBC and contributors.
|
|
24
|
+
Licensed under the MIT License.
|
package/README.md
CHANGED
|
@@ -1,49 +1,70 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<picture>
|
|
3
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://
|
|
4
|
-
<img alt="Logic-Injection-on-Origin Protocol Logo" src="https://
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Nekzus/LIOP/main/docs/logo/dark.svg">
|
|
4
|
+
<img alt="Logic-Injection-on-Origin Protocol Logo" src="https://raw.githubusercontent.com/Nekzus/LIOP/main/docs/logo/light.svg" width="700">
|
|
5
5
|
</picture>
|
|
6
6
|
|
|
7
|
-
<h1>Logic-Injection-on-Origin Protocol (LIOP)
|
|
8
|
-
<p
|
|
9
|
-
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
</p>
|
|
18
|
-
|
|
19
|
-
<p><strong>The official TypeScript SDK for the Logic-Injection-on-Origin Protocol.</strong></p>
|
|
20
|
-
<p>Deploy Logic-on-Origin with WebAssembly sandboxing, gRPC-speed execution, and full MCP backward compatibility.</p>
|
|
7
|
+
<h1>Logic-Injection-on-Origin Protocol (LIOP), TypeScript SDK</h1>
|
|
8
|
+
<p><strong>The official TypeScript SDK and MCP Bridge for the Logic-Injection-on-Origin Protocol.</strong></p>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://github.com/Nekzus/LIOP/actions/workflows/ci.yml"><img src="https://github.com/Nekzus/LIOP/actions/workflows/ci.yml/badge.svg?event=push" alt="Github Workflow"></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/@nekzus/liop"><img src="https://img.shields.io/npm/v/@nekzus/liop.svg" alt="npm version"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@nekzus/liop"><img src="https://img.shields.io/npm/dm/@nekzus/liop.svg" alt="npm downloads"></a>
|
|
14
|
+
<a href="https://github.com/Nekzus/LIOP/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="License"></a>
|
|
15
|
+
<a href="https://nekzus-32.mintlify.app/typescript-sdk/overview"><img src="https://img.shields.io/badge/docs-mintlify-0D9373?style=flat" alt="Docs"></a>
|
|
16
|
+
<a href="https://deepwiki.com/Nekzus/LIOP"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
|
|
17
|
+
</p>
|
|
21
18
|
</div>
|
|
22
19
|
|
|
23
20
|
---
|
|
24
21
|
|
|
22
|
+
## Official Documentation
|
|
23
|
+
|
|
24
|
+
Comprehensive interactive guides, architectural deep dives, and API specifications are hosted on our official portal:
|
|
25
|
+
|
|
26
|
+
| Documentation Section | Focus Area | Canonical Guide |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| **Overview & Setup** | Package architecture, core exports, and installation modes | [SDK Overview](https://nekzus-32.mintlify.app/typescript-sdk/overview) |
|
|
29
|
+
| **LiopClient API** | Discovery, intent negotiation, gRPC channels, and error catalog | [LiopClient Reference](https://nekzus-32.mintlify.app/typescript-sdk/client) |
|
|
30
|
+
| **LiopServer API** | Capability hosting, Zod schemas, and V8 sandboxing boundaries | [LiopServer Reference](https://nekzus-32.mintlify.app/typescript-sdk/server) |
|
|
31
|
+
| **LiopMcpBridge** | Zero-trust wrapping of `@modelcontextprotocol/sdk` servers | [Bridge Documentation](https://nekzus-32.mintlify.app/typescript-sdk/bridge) |
|
|
32
|
+
| **Runtime & Discovery** | `TopologyProbe`, `RoutingTable` circuit breaker, and `TokenManager` | [Runtime Architecture](https://nekzus-32.mintlify.app/typescript-sdk/runtime) |
|
|
33
|
+
| **Security Architecture** | 6-Layer defense-in-depth, AST Guardian, and Egress PII Shield | [Security Guide](https://nekzus-32.mintlify.app/typescript-sdk/security) |
|
|
34
|
+
| **Observability & SRE** | Prometheus metrics catalog and 26-panel Grafana master dashboard | [Observability Runbook](https://nekzus-32.mintlify.app/operations/observability-runbook) |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
25
38
|
## Overview
|
|
26
39
|
|
|
27
|
-
`@nekzus/liop` is an SDK that implements the **Logic-Injection-on-Origin (LIO)** paradigm: instead of extracting raw data from a server and sending it to an LLM, the LLM injects a micro-module of logic to be executed *at the data source*, inside a secure sandbox. The result
|
|
40
|
+
`@nekzus/liop` is an SDK that implements the **Logic-Injection-on-Origin (LIO)** paradigm: instead of extracting raw data from a server and sending it to an LLM, the LLM injects a micro-module of logic to be executed *at the data source*, inside a secure sandbox. The result, and never the raw data, is returned.
|
|
28
41
|
|
|
29
|
-
This
|
|
42
|
+
This addresses the data privacy, bandwidth, and latency bottlenecks of distributed agent data analysis.
|
|
30
43
|
|
|
31
44
|
### Key Capabilities
|
|
32
45
|
|
|
33
46
|
| Feature | Description |
|
|
34
47
|
| :---------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
35
48
|
| **Logic-Injection-on-Origin** | LLMs send code, not queries. Data never leaves the origin server. |
|
|
36
|
-
| **Dual-Era MCP Compliance** |
|
|
49
|
+
| **Dual-Era MCP Compliance** | Dual-era compatibility supporting modern stateless MCP v2 (2026-07-28) and legacy MCP (2025-11-25) clients (Claude Desktop, Cursor). |
|
|
37
50
|
| **Token Economy Engine** | Inlined BPE `o200k_base` tokenizer with zero runtime dependencies (16.5MB footprint reduction) and OpenTelemetry `gen_ai.*` bridge. |
|
|
38
|
-
| **Interactive Playground UI** | Real-time Web UI (`:14000`) with
|
|
39
|
-
| **
|
|
40
|
-
| **
|
|
51
|
+
| **Interactive Playground UI** | Real-time Web UI (`:16000` prod / `:14000` dev) with 4-tab modular architecture (`Output`, `Debug`, `Telemetry`, `Export`), code generation (TS/cURL/Python), and dual OLED/Slate themes. |
|
|
52
|
+
| **Multi-Tier Sovereign Enclaves** | Physical socket isolation via `@libp2p/pnet` (256-bit Swarm Key PSK) and Border LIO Gateway (`blg`) with OAuth 2.1 authentication. |
|
|
53
|
+
| **AST Fuel Metering** | Deterministic AST instruction fuel scoring with 100-bucket quantization for NIST SP 800-53 timing side-channel elimination (`stddev = 0`).|
|
|
54
|
+
| **Differential Privacy Engine** | NIST SP 800-226 Laplace mechanism with CSPRNG entropy, query-aware sensitivity, and deterministic ZK-Receipt auditing (`DpEngine`). |
|
|
55
|
+
| **MCP Drop-in Replacement** | `LiopServer` mirrors the Anthropic MCP `Server` API (tools, resources, and prompts with `Zod` schemas). |
|
|
56
|
+
| **Guardian AST** | Pre-execution heuristic inspection blocks sandbox escapes (`require`, `fs`, `eval`, `fetch`, prototype pollution). |
|
|
57
|
+
| **IFC Taint Analyzer** | 5-pass Acorn AST information flow control tracking collection aliases, correlation guards, and extrema gates at preflight. |
|
|
41
58
|
| **WASI Sandbox** | JavaScript payloads execute inside V8 isolates with CPU fuel limits, no Node.js globals, and safe environment isolation (`allowEnv`). |
|
|
42
|
-
| **
|
|
43
|
-
| **
|
|
59
|
+
| **Adaptive Network Discovery**| Single-URL RFC 9728 Protected Resource Metadata probe and adaptive execution mode resolution (`TopologyProbe`). |
|
|
60
|
+
| **Resilient Hybrid Routing** | Deterministic per-tool multiplexing across `http-gateway`, `p2p-grpc`, and `local` with 5-failure circuit breaker (`RoutingTable`).|
|
|
61
|
+
| **OAuth 2.1 M2M Lifecycle** | Concurrency in-flight de-duplication, 30-second preemptive refresh buffer, and reactive invalidation (`TokenManager`). |
|
|
62
|
+
| **Sliding-Window Rate Limiter**| In-memory OWASP API4:2023 rate limiting with background cleanup unreferenced intervals (`InMemoryRateLimiter`). |
|
|
63
|
+
| **ZK-Receipts** | Tri-modal Zero-Knowledge proofs: HMAC-SHA256 (v1), Groth16 BN254 with 144-byte binary journal (v2), and dual-layer ML-DSA-65 post-quantum hybrid receipts (v2.1). Enforces `ZK_BLOCKING` on Tier 1 Enclaves. |
|
|
64
|
+
| **Hardware TEE Attestation** | Pre-flight validation of confidential hardware root-of-trust evidence for AMD SEV-SNP (1,184-byte report) and AWS Nitro Enclaves (`verifyTeeAttestationDetailed`). |
|
|
44
65
|
| **Worker Pool** | Heavy computation (crypto, sandboxing) dispatched to OS threads via `piscina` with background async warmup. |
|
|
45
66
|
| **Post-Quantum Ready** | ML-KEM-768 (Kyber) + ML-DSA-65 (Dilithium) with 1-hour session lifetime and AES-256-GCM encryption. |
|
|
46
|
-
| **Enterprise Observability** | Immutable SOC 2 Hash-Chain audit log (`AuditLogger`), Prometheus metrics (`/metrics`), and
|
|
67
|
+
| **Enterprise Observability** | Immutable SOC 2 Hash-Chain audit log (`AuditLogger`), physical wire egress tracking, Prometheus metrics (`/metrics`), and K8s probes. |
|
|
47
68
|
| **P2P Mesh** | Kademlia DHT discovery via `libp2p` with TCP + WebSocket + Yamux multiplexing and Noise encryption. |
|
|
48
69
|
|
|
49
70
|
---
|
|
@@ -64,7 +85,7 @@ npm install @nekzus/liop@beta
|
|
|
64
85
|
|
|
65
86
|
### Zero-Bloat & Micro-Deployments (Opt-Out)
|
|
66
87
|
|
|
67
|
-
By default, the SDK provides
|
|
88
|
+
By default, the SDK provides backward compatibility with MCP (`LiopMcpBridge`) by declaring `@modelcontextprotocol/sdk` as an optional dependency (which is automatically resolved by standard installations of NPM, PNPM, or Yarn).
|
|
68
89
|
|
|
69
90
|
For constrained production environments (e.g., Docker, AWS Lambda, Edge/IoT) where every megabyte counts, you can perform a **pure, zero-bloat LIOP installation** by opting out of the optional dependencies:
|
|
70
91
|
|
|
@@ -100,7 +121,7 @@ npm install -g @nekzus/liop@latest
|
|
|
100
121
|
liop
|
|
101
122
|
```
|
|
102
123
|
|
|
103
|
-
###
|
|
124
|
+
### Claude Desktop Configuration
|
|
104
125
|
|
|
105
126
|
To integrate LIOP into Claude Desktop, update your `claude_desktop_config.json` (typically found in `%APPDATA%\Claude\claude_desktop_config.json` on Windows):
|
|
106
127
|
|
|
@@ -111,7 +132,7 @@ To integrate LIOP into Claude Desktop, update your `claude_desktop_config.json`
|
|
|
111
132
|
"command": "npx",
|
|
112
133
|
"args": ["-y", "@nekzus/liop@latest"],
|
|
113
134
|
"env": {
|
|
114
|
-
"LIOP_NEXUS_URL": "http://your-nexus-host:
|
|
135
|
+
"LIOP_NEXUS_URL": "http://your-nexus-host:15000",
|
|
115
136
|
"LIOP_LOG_LEVEL": "info",
|
|
116
137
|
"LIOP_TOKEN_BANK": "your-secure-bank-token",
|
|
117
138
|
"LIOP_TOKEN_VAULT": "your-secure-vault-token",
|
|
@@ -164,7 +185,7 @@ server.tool(
|
|
|
164
185
|
"Analyzes local log files without sending raw data to the LLM.",
|
|
165
186
|
{ target_error: z.string().describe("The error pattern to search for") },
|
|
166
187
|
async ({ target_error }) => {
|
|
167
|
-
// This logic runs at origin
|
|
188
|
+
// This logic runs at origin, data never leaves the server
|
|
168
189
|
return {
|
|
169
190
|
content: [{ type: "text", text: `Found 51 occurrences of ${target_error}` }],
|
|
170
191
|
};
|
|
@@ -303,32 +324,32 @@ await bridge.connect();
|
|
|
303
324
|
|
|
304
325
|
**Supported JSON-RPC methods:**
|
|
305
326
|
|
|
306
|
-
- `initialize
|
|
307
|
-
- `tools/list
|
|
308
|
-
- `tools/call
|
|
309
|
-
- `resources/list
|
|
310
|
-
- `resources/read
|
|
311
|
-
- `prompts/list
|
|
312
|
-
- `prompts/get
|
|
327
|
+
- `initialize`: Returns server capabilities and info
|
|
328
|
+
- `tools/list`: Lists available tools
|
|
329
|
+
- `tools/call`: Calls a tool (with ZK-Receipt verification)
|
|
330
|
+
- `resources/list`: Lists available resources
|
|
331
|
+
- `resources/read`: Reads a resource
|
|
332
|
+
- `prompts/list`: Lists available prompts
|
|
333
|
+
- `prompts/get`: Gets a specific prompt
|
|
313
334
|
|
|
314
335
|
---
|
|
315
336
|
|
|
316
337
|
## Security Architecture
|
|
317
338
|
|
|
318
|
-
###
|
|
339
|
+
### Defense-in-Depth Architecture
|
|
319
340
|
|
|
320
341
|
```
|
|
321
342
|
┌───────────────────────────────────────────────────────────┐
|
|
322
|
-
│ Layer 1: Guardian AST (
|
|
343
|
+
│ Layer 1: Guardian AST (Pre-Execution Static Analysis) │
|
|
323
344
|
│ 14-function WASI allowlist • 128 import cap • Blocks │
|
|
324
345
|
│ require, import(), fs, eval, fetch, __proto__ │
|
|
325
|
-
|
|
346
|
+
├───────────────────────────────────────────────────────────┤
|
|
326
347
|
│ Layer 2: WASI Sandbox (V8 Isolate) │
|
|
327
348
|
│ 25 poisoned globals (incl. Date, TypedArrays) • │
|
|
328
349
|
│ CPU Fuel limits • 5s timeout • maxHeapMb (64MB default) │
|
|
329
350
|
│ Object.freeze() on 11 core prototypes • allowEnv allowlist │
|
|
330
351
|
├───────────────────────────────────────────────────────────┤
|
|
331
|
-
│ Layer 3: Taint Analyzer (IFC
|
|
352
|
+
│ Layer 3: Taint Analyzer (IFC, Static) │
|
|
332
353
|
│ Acorn AST 3-pass analysis blocks PII side-channels: │
|
|
333
354
|
│ charCodeAt, boolean inference, arithmetic derivation │
|
|
334
355
|
├───────────────────────────────────────────────────────────┤
|
|
@@ -341,8 +362,9 @@ await bridge.connect();
|
|
|
341
362
|
│ Blocks raw row export • maxOutputRows (default: 10) • │
|
|
342
363
|
│ Conditional error: detailed (dev) vs opaque (production) │
|
|
343
364
|
├───────────────────────────────────────────────────────────┤
|
|
344
|
-
│ Layer 6: ZK-Receipt (
|
|
345
|
-
│
|
|
365
|
+
│ Layer 6: ZK-Receipt (Groth16 BN254 & Replay Mitigation) │
|
|
366
|
+
│ Version 2: 144-byte binary journal + Groth16 curve points │
|
|
367
|
+
│ Version 1: HMAC-SHA256 session commitment (Kyber768) │
|
|
346
368
|
│ output_hash cross-verification • Balanced-brace extractor │
|
|
347
369
|
└───────────────────────────────────────────────────────────┘
|
|
348
370
|
```
|
|
@@ -386,7 +408,7 @@ const server = new LiopServer(info, {
|
|
|
386
408
|
|
|
387
409
|
To avoid false positive triggers caused by HMAC-SHA256 ZK-Receipt signatures or transport wrapper frames (such as `{ content: [{ type: "text", text: "..." }] }`), the PII Shield and Aggregation-First engines scan only the unwrapped business data (via `unwrapForAggregationPolicyScan`). Cryptographic seals and protocol routing structures are isolated and excluded from compliance scans.
|
|
388
410
|
|
|
389
|
-
###
|
|
411
|
+
### 3-Tier Query Budget (NIST SP 800-226)
|
|
390
412
|
|
|
391
413
|
To prevent advanced statistical differentiation or database reconstruction attacks, the SDK implements a tiered, session-based budget engine:
|
|
392
414
|
|
|
@@ -396,27 +418,27 @@ To prevent advanced statistical differentiation or database reconstruction attac
|
|
|
396
418
|
|
|
397
419
|
If an injected payload queries a field beyond its budget limit, the preflight static analysis immediately blocks execution.
|
|
398
420
|
|
|
399
|
-
###
|
|
421
|
+
### K-Anonymity on Small Datasets
|
|
400
422
|
|
|
401
423
|
When operating on high-privacy datasets, if the source records count is **less than 10**, the SDK forces a strict K-Anonymity restriction:
|
|
402
424
|
- Rejects any output that contains nested objects or arrays.
|
|
403
425
|
- Restricts the returned structure to a maximum of **3 scalar keys** (e.g., simple aggregate counts or statistics).
|
|
404
426
|
- Prevents structural data leakage in low-entropy datasets.
|
|
405
427
|
|
|
406
|
-
###
|
|
428
|
+
### Sandbox Poisoned Globals & Date Workaround
|
|
407
429
|
|
|
408
430
|
For maximum host security, the WASI sandbox enforces a poisoned environment that strips dangerous globals and prevents timing side-channels:
|
|
409
431
|
- **Poisoned/Disabled**: `Date` (Date.now, parse, etc. throw an exception to prevent timing analysis), `eval`, `Function`, `setTimeout`, `setInterval`, `Buffer`, `ArrayBuffer`, and all `TypedArrays`.
|
|
410
432
|
- **Date Workaround**: To perform date checks, use lexicographical string comparison on ISO 8601 strings (e.g., `record.date >= "2026-01-01"`).
|
|
411
433
|
|
|
412
|
-
###
|
|
434
|
+
### Recursive In-Memory Numerical Sanitization
|
|
413
435
|
|
|
414
436
|
To mitigate timing channels, statistical differentiation, and floats side-channels, the SDK executes a recursive sanitization pipeline before the PII scanner runs:
|
|
415
437
|
- Positive floating-point numbers are recursively rounded to exactly **4 decimal places**.
|
|
416
438
|
- Negative values are safely clamped to **0** (via `sanitizeOutput()`).
|
|
417
439
|
- This operation runs entirely in-memory and recursively on all fields, preserving data structure immutability without expensive and fragile serialization-deserialization cycles.
|
|
418
440
|
|
|
419
|
-
###
|
|
441
|
+
### Environment Isolation & allowEnv Allowlist
|
|
420
442
|
|
|
421
443
|
For robust sandboxing, the WASI execution path isolates host environment variables. Propagation can be enabled explicitly:
|
|
422
444
|
```typescript
|
|
@@ -429,11 +451,57 @@ To block arbitrary command execution (e.g., Shellshock) and prevent exposure of
|
|
|
429
451
|
- **Unix/Linux Allowlist**: `HOME`, `LOGNAME`, `PATH`, `SHELL`, `TERM`, `USER`.
|
|
430
452
|
Variables starting with shell functions `()` are dropped.
|
|
431
453
|
|
|
432
|
-
###
|
|
454
|
+
### Sovereign Tri-Modal ZK-Receipts & Hardware Attestation
|
|
455
|
+
|
|
456
|
+
LIOP ZK-Receipts provide cryptographic evidence that a computation was executed honestly under zero-trust bounds. The protocol implements three complementary cryptographic modes:
|
|
457
|
+
- **Mode 0 (`HMAC_LEGACY`, v1)**: Session commitments sealed with the ML-KEM-768 quantum-resistant shared key.
|
|
458
|
+
- **Mode 2 (`GROTH16`, v2)**: Compact Zero-Knowledge SNARK proofs over the BN254 pairing-friendly elliptic curve packing a 144-byte binary journal (~252 bytes total).
|
|
459
|
+
- **Mode 3 (`GROTH16_PQC_HYBRID`, v2.1)**: Dual-layer receipts combining Groth16 BN254 mathematical proofs with an ML-DSA-65 post-quantum digital signature conforming to NIST FIPS 204 (~5.6 KB total).
|
|
460
|
+
|
|
461
|
+
- **144-Byte Binary Journal Layout**:
|
|
462
|
+
- `guest_image_id` (32 bytes): Sovereign enclave guest runtime image identifier
|
|
463
|
+
- `logic_digest` (32 bytes): SHA-256 fingerprint of the executed JavaScript/WASM logic
|
|
464
|
+
- `dataset_digest` (32 bytes): SHA-256 fingerprint of the origin dataset at execution time
|
|
465
|
+
- `output_digest` (32 bytes): SHA-256 fingerprint of the sanitized computation result
|
|
466
|
+
- `fuel_consumed` (8 bytes uint64 BE): Quantized instruction-level AST fuel units consumed
|
|
467
|
+
- `execution_timestamp` (8 bytes uint64 BE): Epoch timestamp in milliseconds
|
|
468
|
+
- **Tampering & Replay Mitigation**: The client computes the local SHA-256 hash of the received output and asserts strict equality with `journal.outputDigest`. Any modified bit in either the journal, curve proof, or post-quantum signature causes immediate rejection.
|
|
469
|
+
- **Enclave Policy Invariant (`ZK_BLOCKING`)**: Tier 1 Sovereign Enclaves configure `zkMode: "required"`, rejecting queries if a valid Groth16 proof cannot be synthesized or if mock proofs are supplied. When `pqcSign: true` is configured, the enclave emits a Version 2.1 hybrid receipt co-signed with ML-DSA-65.
|
|
470
|
+
|
|
471
|
+
```typescript
|
|
472
|
+
import { LiopServer } from "@nekzus/liop/server";
|
|
473
|
+
import { LiopVerifier, verifyTeeAttestationDetailed } from "@nekzus/liop";
|
|
474
|
+
|
|
475
|
+
// 1. Enclave configuration with ZK_BLOCKING and PQC signing
|
|
476
|
+
const server = new LiopServer({ name: "bank-enclave", version: "1.0.0" });
|
|
477
|
+
server.tool(
|
|
478
|
+
"calculate_payroll_aggregate",
|
|
479
|
+
"Aggregates payroll without egressing employee identities",
|
|
480
|
+
{ payload: z.string() },
|
|
481
|
+
async () => ({ content: [{ type: "text", text: "ok" }] }),
|
|
482
|
+
{
|
|
483
|
+
zkMode: "required", // Enforces Groth16 proof generation (ZK_BLOCKING)
|
|
484
|
+
pqcSign: true, // Enables ML-DSA-65 digital signature (Receipt v2.1)
|
|
485
|
+
circuitName: "sum",
|
|
486
|
+
}
|
|
487
|
+
);
|
|
433
488
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
489
|
+
// 2. Client verification via LiopVerifier
|
|
490
|
+
const verifier = new LiopVerifier();
|
|
491
|
+
const isValid = await verifier.verifyZkReceipt(
|
|
492
|
+
Buffer.from(logicPayload),
|
|
493
|
+
remoteImageIdHex,
|
|
494
|
+
rawReceiptBuffer,
|
|
495
|
+
{ zkPolicy: "required" }
|
|
496
|
+
);
|
|
497
|
+
|
|
498
|
+
// 3. Pre-flight Hardware TEE Attestation (AMD SEV-SNP / AWS Nitro Enclaves)
|
|
499
|
+
const teeStatus = await verifyTeeAttestationDetailed(
|
|
500
|
+
attestationBytes,
|
|
501
|
+
expectedNonce,
|
|
502
|
+
{ requireHardwareSigned: true }
|
|
503
|
+
);
|
|
504
|
+
```
|
|
437
505
|
|
|
438
506
|
---
|
|
439
507
|
|
|
@@ -444,11 +512,11 @@ The following shows a complete Logic-Injection-on-Origin execution cycle (handle
|
|
|
444
512
|
```
|
|
445
513
|
1. LLM generates JavaScript analysis code wrapped in @LIOP / @END boundaries
|
|
446
514
|
2. LiopServer receives the payload via tools/call (JSON-RPC or direct)
|
|
447
|
-
3. Guardian AST inspects for sandbox escapes (
|
|
515
|
+
3. Guardian AST inspects for sandbox escapes (pre-execution heuristic analysis)
|
|
448
516
|
4. Code executes inside a V8 isolate with CPU fuel limits (no Node.js globals)
|
|
449
517
|
5. Taint Analyzer blocks PII side-channel derivation (charCodeAt, boolean inference)
|
|
450
518
|
6. PII Shield scans output for forbidden data and keys
|
|
451
|
-
7. ZK-Receipt generated (
|
|
519
|
+
7. ZK-Receipt generated (Tri-modal: HMAC v1, Groth16 v2, or Groth16 + ML-DSA-65 v2.1)
|
|
452
520
|
8. Result + receipt returned to the LLM (raw data never exposed)
|
|
453
521
|
```
|
|
454
522
|
|
|
@@ -477,7 +545,7 @@ Node.js is single-threaded. Heavy operations like Kyber768 decryption, AES-GCM a
|
|
|
477
545
|
This SDK dispatches all heavy computation to OS-level threads via [`piscina`](https://github.com/piscinajs/piscina), achieving Rust-like concurrency. On server or verifier initialization, background warmup tasks are automatically dispatched to pre-warm the pool workers, eliminating V8/WASI cold-start overhead (~820k fuel units) for subsequent calls:
|
|
478
546
|
|
|
479
547
|
```typescript
|
|
480
|
-
// Automatic
|
|
548
|
+
// Automatic, no configuration needed
|
|
481
549
|
// When a Logic-Injection-on-Origin payload is received:
|
|
482
550
|
// 1. Main thread receives JSON-RPC request
|
|
483
551
|
// 2. Worker thread: AST inspection + PQC decryption + Sandbox execution
|
|
@@ -528,21 +596,32 @@ await server.connectToMesh();
|
|
|
528
596
|
|
|
529
597
|
---
|
|
530
598
|
|
|
531
|
-
## Interactive Web Playground (`:14000`)
|
|
599
|
+
## Interactive Web Playground (`:16000` prod / `:14000` dev)
|
|
532
600
|
|
|
533
|
-
The SDK includes
|
|
601
|
+
The SDK includes a real-time developer interface to test Logic-Injection-on-Origin, trace post-quantum handshakes, evaluate AST fuel consumption, and inspect cryptographic proofs:
|
|
534
602
|
|
|
535
603
|
```bash
|
|
536
|
-
# Launch the full
|
|
604
|
+
# 1. Launch the full 10-node production audit mesh with traffic shaping (http://localhost:16000)
|
|
605
|
+
pnpm run audit:prod:start
|
|
606
|
+
|
|
607
|
+
# Run the 12-suite automated production audit against the mesh (64 tests)
|
|
608
|
+
pnpm run audit:prod:run
|
|
609
|
+
|
|
610
|
+
# Teardown and cleanup production containers
|
|
611
|
+
pnpm run audit:prod:clean
|
|
612
|
+
|
|
613
|
+
# 2. Alternatively, launch the lightweight 5-node demo (http://localhost:14000)
|
|
537
614
|
pnpm run demo:start
|
|
538
615
|
```
|
|
539
616
|
|
|
540
|
-
Navigate to **`http://localhost:
|
|
617
|
+
Navigate to **`http://localhost:16000`** in your browser:
|
|
541
618
|
|
|
542
619
|
* **Live 7-Phase Streaming:** Visualizes Bootstrap, DHT Discovery, ML-KEM-768 Handshake, AES-256-GCM Sealing, WASI Sandbox Execution, ZK-Receipt Verification, and Output Aggregation via real-time Server-Sent Events (SSE).
|
|
543
|
-
* **
|
|
544
|
-
* **
|
|
545
|
-
* **
|
|
620
|
+
* **Tri-Tab Results Panel:** Switch between `Aggregated Output` (sanitized JSON), `Fuel & Telemetry` (WASI fuel metering, token economy comparison banner), and `Crypto Proofs` (ImageID, Dataset Hash, and HMAC-SHA256 signature with instant copy).
|
|
621
|
+
* **Token Economy Dashboard:** Live comparison showing **98.9% to 99.6% token reduction** and **99.6% network bandwidth savings** over traditional MCP context-pulling.
|
|
622
|
+
* **REST Telemetry Endpoint:** Query session analytics programmatically at `GET http://localhost:16000/api/telemetry`.
|
|
623
|
+
* **Built-in Scenario Presets:** Ready-to-run micro-modules for High-Frequency Trading (HFT Level 2 order books), Banking transaction analysis, Medical Vault HIPAA records, and Edge IoT industrial sensor telemetry.
|
|
624
|
+
* **Dual Dark Modes:** Toggle between Obsidian OLED (`#000000`) and Slate Navy (`#0f172a`) interfaces.
|
|
546
625
|
|
|
547
626
|
---
|
|
548
627
|
|
|
@@ -586,7 +665,7 @@ This package is continuously tested across multiple platforms and Node.js versio
|
|
|
586
665
|
- **Multi-OS matrix:** Ubuntu, Windows, macOS
|
|
587
666
|
- **Node.js versions:** 20.x, 22.x
|
|
588
667
|
- **Code quality:** Enforced by [Biome.js](https://biomejs.dev/) (linting + formatting)
|
|
589
|
-
- **Security:** Verified 6-layer defense-in-depth architecture
|
|
668
|
+
- **Security:** Verified 6-layer defense-in-depth architecture (see [Security Architecture](https://nekzus-32.mintlify.app/typescript-sdk/security))
|
|
590
669
|
|
|
591
670
|
> To run tests locally or contribute, clone the [repository](https://github.com/Nekzus/LIOP) and follow the [Contributing Guide](https://github.com/Nekzus/LIOP/blob/main/CONTRIBUTING.md).
|
|
592
671
|
|
|
@@ -600,18 +679,18 @@ You can run security audits and check package health scores directly from the mo
|
|
|
600
679
|
- **Check SDK Security Score:** `pnpm socket:score` (shows the detailed package score for the SDK in Markdown format)
|
|
601
680
|
- **Fix Vulnerabilities:** `pnpm socket:fix` (automatically remediates known CVEs in package.json)
|
|
602
681
|
|
|
603
|
-
The codebase undergoes regular dependencies audits. As of June 2026, the SDK is verified to be 100% free of orphan packages and dead dependencies, ensuring
|
|
682
|
+
The codebase undergoes regular dependencies audits. As of June 2026, the SDK is verified to be 100% free of orphan packages and dead dependencies, ensuring a minimal deployment footprint.
|
|
604
683
|
|
|
605
684
|
---
|
|
606
685
|
|
|
607
686
|
## Related
|
|
608
687
|
|
|
609
|
-
- [LIOP Documentation](https://nekzus-32.mintlify.app/)
|
|
610
|
-
- [LIOP Specification](https://github.com/Nekzus/LIOP/blob/main/protocol/SPECIFICATION.md)
|
|
611
|
-
- [LIOP Manifesto](https://github.com/Nekzus/LIOP/blob/main/MANIFESTO.md)
|
|
612
|
-
- [Contributing Guide](https://github.com/Nekzus/LIOP/blob/main/CONTRIBUTING.md)
|
|
613
|
-
- [Rust Mesh Node](https://github.com/Nekzus/LIOP/tree/main/servers/liop-node)
|
|
614
|
-
- [LIOP CLI](https://github.com/Nekzus/LIOP/tree/main/tools/liop-cli)
|
|
688
|
+
- [LIOP Documentation](https://nekzus-32.mintlify.app/): Full conceptual and API documentation
|
|
689
|
+
- [LIOP Specification](https://github.com/Nekzus/LIOP/blob/main/protocol/SPECIFICATION.md): Technical specification
|
|
690
|
+
- [LIOP Manifesto](https://github.com/Nekzus/LIOP/blob/main/MANIFESTO.md): Project philosophy
|
|
691
|
+
- [Contributing Guide](https://github.com/Nekzus/LIOP/blob/main/CONTRIBUTING.md): How to contribute
|
|
692
|
+
- [Rust Mesh Node](https://github.com/Nekzus/LIOP/tree/main/servers/liop-node): Native high-performance backend
|
|
693
|
+
- [LIOP CLI](https://github.com/Nekzus/LIOP/tree/main/tools/liop-cli): Developer diagnostics
|
|
615
694
|
|
|
616
695
|
---
|
|
617
696
|
|