@nekzus/liop 1.2.0-alpha.10
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/LICENSE +21 -0
- package/README.md +413 -0
- package/dist/bin/agent.d.ts +2 -0
- package/dist/bin/agent.js +307 -0
- package/dist/bridge/index.d.ts +37 -0
- package/dist/bridge/index.js +249 -0
- package/dist/bridge/stream.d.ts +62 -0
- package/dist/bridge/stream.js +202 -0
- package/dist/client/index.d.ts +60 -0
- package/dist/client/index.js +275 -0
- package/dist/crypto/logic-image-id.d.ts +3 -0
- package/dist/crypto/logic-image-id.js +27 -0
- package/dist/crypto/verifier.d.ts +29 -0
- package/dist/crypto/verifier.js +96 -0
- package/dist/economy/estimator.d.ts +53 -0
- package/dist/economy/estimator.js +69 -0
- package/dist/economy/index.d.ts +5 -0
- package/dist/economy/index.js +3 -0
- package/dist/economy/otel.d.ts +38 -0
- package/dist/economy/otel.js +100 -0
- package/dist/economy/telemetry.d.ts +77 -0
- package/dist/economy/telemetry.js +224 -0
- package/dist/gateway/hybrid.d.ts +23 -0
- package/dist/gateway/hybrid.js +199 -0
- package/dist/gateway/router.d.ts +69 -0
- package/dist/gateway/router.js +1036 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +11 -0
- package/dist/mesh/index.d.ts +1 -0
- package/dist/mesh/index.js +1 -0
- package/dist/mesh/node.d.ts +129 -0
- package/dist/mesh/node.js +853 -0
- package/dist/prompts/adapters.d.ts +16 -0
- package/dist/prompts/adapters.js +55 -0
- package/dist/protocol/liop_core.proto +44 -0
- package/dist/rpc/client.d.ts +22 -0
- package/dist/rpc/client.js +40 -0
- package/dist/rpc/codec/lpm.d.ts +20 -0
- package/dist/rpc/codec/lpm.js +36 -0
- package/dist/rpc/crypto/aes.d.ts +22 -0
- package/dist/rpc/crypto/aes.js +47 -0
- package/dist/rpc/crypto/kyber.d.ts +27 -0
- package/dist/rpc/crypto/kyber.js +70 -0
- package/dist/rpc/proto.d.ts +2 -0
- package/dist/rpc/proto.js +33 -0
- package/dist/rpc/server.d.ts +13 -0
- package/dist/rpc/server.js +50 -0
- package/dist/rpc/tls.d.ts +26 -0
- package/dist/rpc/tls.js +54 -0
- package/dist/rpc/types.d.ts +28 -0
- package/dist/rpc/types.js +5 -0
- package/dist/sandbox/guardian.d.ts +18 -0
- package/dist/sandbox/guardian.js +35 -0
- package/dist/sandbox/wasi.d.ts +36 -0
- package/dist/sandbox/wasi.js +179 -0
- package/dist/security/guardian.d.ts +22 -0
- package/dist/security/guardian.js +52 -0
- package/dist/security/zk.d.ts +37 -0
- package/dist/security/zk.js +66 -0
- package/dist/server/index.d.ts +184 -0
- package/dist/server/index.js +933 -0
- package/dist/server/pii.d.ts +40 -0
- package/dist/server/pii.js +266 -0
- package/dist/types.d.ts +145 -0
- package/dist/types.js +26 -0
- package/dist/utils/logger.d.ts +21 -0
- package/dist/utils/logger.js +70 -0
- package/dist/utils/mcpCompact.d.ts +11 -0
- package/dist/utils/mcpCompact.js +29 -0
- package/dist/workers/logic-execution.d.ts +17 -0
- package/dist/workers/logic-execution.js +121 -0
- package/dist/workers/zk-verifier.d.ts +20 -0
- package/dist/workers/zk-verifier.js +84 -0
- package/package.json +147 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nekzus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://res.cloudinary.com/dsvsl0b0b/image/upload/v1774702621/Neural-Mesh-Protocol/qaqsa28yrtpnxnbclv3p.svg?v=20260328">
|
|
4
|
+
<img alt="Logic-Injection-on-Origin Protocol Logo" src="https://res.cloudinary.com/dsvsl0b0b/image/upload/v1774702621/Neural-Mesh-Protocol/hoanw0m6tybpz5fbl12n.svg?v=20260328" width="700">
|
|
5
|
+
</picture>
|
|
6
|
+
|
|
7
|
+
<h1>Logic-Injection-on-Origin Protocol (LIOP) — TypeScript SDK</h1>
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://github.com/Nekzus/Neural-Mesh-Protocol/actions/workflows/ci.yml"><img src="https://github.com/Nekzus/Neural-Mesh-Protocol/actions/workflows/ci.yml/badge.svg?event=push" alt="Github Workflow"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@nekzus/liop"><img src="https://img.shields.io/npm/v/@nekzus/liop.svg" alt="npm version"></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@nekzus/liop"><img src="https://img.shields.io/npm/dm/@nekzus/liop.svg" alt="npm-month"></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/@nekzus/liop"><img src="https://img.shields.io/npm/dt/@nekzus/liop.svg?style=flat" alt="npm-total"></a>
|
|
13
|
+
<a href="https://github.com/Nekzus/Neural-Mesh-Protocol/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Nekzus/LIOP.svg" alt="License"></a>
|
|
14
|
+
<a href="https://liop.mintlify.app/"><img src="https://img.shields.io/badge/docs-mintlify-0D9373?style=flat" alt="Docs"></a>
|
|
15
|
+
<a href="https://deepwiki.com/Nekzus/LIOP"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
|
|
16
|
+
<a href="https://paypal.me/maseortega"><img src="https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square" alt="Donate"></a>
|
|
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>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Overview
|
|
26
|
+
|
|
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 — never the raw data — is returned.
|
|
28
|
+
|
|
29
|
+
This fundamentally solves the data privacy, bandwidth, and latency challenges of AI-powered data analysis at scale.
|
|
30
|
+
|
|
31
|
+
### Key Capabilities
|
|
32
|
+
|
|
33
|
+
| Feature | Description |
|
|
34
|
+
|:--|:--|
|
|
35
|
+
| **Logic-Injection-on-Origin** | LLMs send code, not queries. Data never leaves the origin server. |
|
|
36
|
+
| **MCP Drop-in Replacement** | `LiopServer` mirrors the Anthropic MCP `Server` API — tools, resources, and prompts with `Zod` schemas. |
|
|
37
|
+
| **Guardian AST** | Zero-time heuristic inspection blocks sandbox escapes (`require`, `fs`, `eval`, `fetch`, prototype pollution). |
|
|
38
|
+
| **WASI Sandbox** | JavaScript payloads execute inside V8 isolates with CPU fuel limits and no access to Node.js globals. |
|
|
39
|
+
| **PII Shield** | Multi-layer egress filter with Regional Presets (Email, Credit Card with Luhn, IP, Phone, SSN, IBAN Mod-97, Passport MRZ) and custom keys. |
|
|
40
|
+
| **ZK-Receipts** | Cryptographic proof (SHA-256 + SHA-512 seal) that the returned result was computed honestly from the injected logic. |
|
|
41
|
+
| **Worker Pool** | Heavy computation (crypto, sandboxing) dispatched to OS threads via `piscina`, unblocking the V8 event loop. |
|
|
42
|
+
| **Cross-AI Adapters**| Zero-Shot system prompts automatically adapt instructions for Claude (XML-heavy) vs OpenAI/Gemini (JSON-schema). |
|
|
43
|
+
| **MCP Bridge** | `LiopMcpBridge` adapts any `LiopServer` to the JSON-RPC 2.0 / stdio protocol used by Claude Desktop, Cursor, etc. |
|
|
44
|
+
| **Post-Quantum Ready** | ML-KEM-768 (Kyber) handshake + AES-256-GCM symmetric encryption for transport-layer security. |
|
|
45
|
+
| **P2P Mesh** | Kademlia DHT discovery via `libp2p` with TCP + WebSocket + Yamux multiplexing and Noise encryption. |
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install @nekzus/liop
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
> **Requirements:** Node.js ≥ 20.0. The SDK uses `node:crypto`, `node:vm`, and `piscina` (worker threads) internally.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## LIOP Agent (CLI)
|
|
60
|
+
|
|
61
|
+
The SDK includes a zero-config agent (`liop-agent`) designed to bridge the Logic-Injection-on-Origin Protocol with local AI clients like **Claude Desktop**.
|
|
62
|
+
|
|
63
|
+
### Installation & Run
|
|
64
|
+
|
|
65
|
+
You can run the agent directly using `npx` (recommended) or install it globally:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Run instantly
|
|
69
|
+
npx @nekzus/liop
|
|
70
|
+
|
|
71
|
+
# Or install globally
|
|
72
|
+
npm install -g @nekzus/liop
|
|
73
|
+
liop-agent
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 🤖 Claude Desktop Configuration
|
|
77
|
+
|
|
78
|
+
To use the Neural Mesh inside Claude Desktop, update your `claude_desktop_config.json` (typically found in `%APPDATA%\Claude\claude_desktop_config.json` on Windows):
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"liop-agent": {
|
|
84
|
+
"command": "npx",
|
|
85
|
+
"args": ["-y", "@nekzus/liop"]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Persistence & Identity
|
|
92
|
+
|
|
93
|
+
The agent automatically manages your P2P identity:
|
|
94
|
+
- **Identity Path**: `~/.liop/identity.json`. This file contains your unique PeerID. Keep it safe if you want to maintain a consistent identity in the mesh.
|
|
95
|
+
- **Bootstrap Nodes**: By default, the agent connects to the **LIOP Alpha Nexus**. You can provide custom bootstrap addresses as CLI arguments:
|
|
96
|
+
```bash
|
|
97
|
+
npx @nekzus/liop /ip4/1.2.3.4/tcp/4001/p2p/PEER_ID
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Quick Start
|
|
103
|
+
|
|
104
|
+
### 1. Create a Server
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { LiopServer, PII_PATTERNS } from "@nekzus/liop/server";
|
|
108
|
+
import { z } from "zod";
|
|
109
|
+
|
|
110
|
+
const server = new LiopServer(
|
|
111
|
+
{ name: "MyDataNode", version: "1.0.0" },
|
|
112
|
+
{
|
|
113
|
+
capabilities: { tools: { listChanged: true } },
|
|
114
|
+
security: {
|
|
115
|
+
// Built-in PII detection (Email, Credit Card, IP, Phone)
|
|
116
|
+
piiPatterns: [PII_PATTERNS.EMAIL, PII_PATTERNS.CREDIT_CARD],
|
|
117
|
+
// Keys that will be stripped from any outgoing response
|
|
118
|
+
forbiddenKeys: ["id", "ssn", "password", "email", "name"],
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 2. Register a Tool
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
server.tool(
|
|
128
|
+
"analyze_logs",
|
|
129
|
+
"Analyzes local log files without sending raw data to the LLM.",
|
|
130
|
+
{ target_error: z.string().describe("The error pattern to search for") },
|
|
131
|
+
async ({ target_error }) => {
|
|
132
|
+
// This logic runs at origin — data never leaves the server
|
|
133
|
+
return {
|
|
134
|
+
content: [{ type: "text", text: `Found 51 occurrences of ${target_error}` }],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 3. Connect to Claude Desktop / Cursor (MCP Bridge)
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import { LiopMcpBridge } from "@nekzus/liop/bridge";
|
|
144
|
+
|
|
145
|
+
const bridge = new LiopMcpBridge(server);
|
|
146
|
+
await bridge.connect(); // Listens on stdio (JSON-RPC 2.0)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Claude Desktop config** (`claude_desktop_config.json`):
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"mcpServers": {
|
|
154
|
+
"my-data-node": {
|
|
155
|
+
"command": "npx",
|
|
156
|
+
"args": ["tsx", "src/server.ts"]
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Module Exports
|
|
165
|
+
|
|
166
|
+
The package exposes targeted entry points to minimize bundle size:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
import { LiopServer, PII_PATTERNS } from "@nekzus/liop/server";
|
|
170
|
+
import { LiopMcpBridge } from "@nekzus/liop/bridge";
|
|
171
|
+
import { LiopClient } from "@nekzus/liop/client";
|
|
172
|
+
import type { Tool, Resource, Prompt, CallToolRequest, CallToolResult } from "@nekzus/liop/types";
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## API Reference
|
|
178
|
+
|
|
179
|
+
### `LiopServer`
|
|
180
|
+
|
|
181
|
+
The core class for declaring data nodes. API-compatible with Anthropic's MCP `Server`.
|
|
182
|
+
|
|
183
|
+
#### Constructor
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
new LiopServer(
|
|
187
|
+
serverInfo: { name: string; version: string },
|
|
188
|
+
config?: {
|
|
189
|
+
capabilities?: Record<string, unknown>;
|
|
190
|
+
security?: {
|
|
191
|
+
piiPatterns?: PiiRule[]; // Regex/validator rules for PII detection
|
|
192
|
+
forbiddenKeys?: string[]; // Keys stripped from outgoing responses
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### Methods
|
|
199
|
+
|
|
200
|
+
| Method | Signature | Description |
|
|
201
|
+
|:--|:--|:--|
|
|
202
|
+
| `tool()` | `(name, description, zodSchema, handler)` | Registers a callable tool with Zod input validation. |
|
|
203
|
+
| `prompt()` | `(name, description, args, handler)` | Registers a dynamic prompt template. |
|
|
204
|
+
| `resource()` | `(name, uri, description?, mimeType?, content?)` | Registers a readable resource. |
|
|
205
|
+
| `dataDictionary()` | `(schema, name?, uri?, description?)` | Broadcasts a data schema so LLMs can write accurate Logic-Injection-on-Origin code. |
|
|
206
|
+
| `setSandboxData()` | `(records: Record[])` | Injects data into the sandbox as `env.records` for Logic-on-Origin tools. |
|
|
207
|
+
| `enableZeroShotAutonomy()` | `()` | Registers the "Blind Analyst" prompt for autonomous code generation. |
|
|
208
|
+
| `callTool()` | `(request: CallToolRequest)` | Invokes a registered tool (used locally or via MCP Bridge). |
|
|
209
|
+
| `listTools()` | `()` | Returns all registered tools. |
|
|
210
|
+
| `listPrompts()` | `()` | Returns all registered prompts. |
|
|
211
|
+
| `getPrompt()` | `(request: GetPromptRequest)` | Returns a specific prompt by name. |
|
|
212
|
+
| `listResources()` | `()` | Returns all registered resources. |
|
|
213
|
+
| `readResource()` | `(uri: string)` | Reads a resource by URI. |
|
|
214
|
+
| `getServerInfo()` | `()` | Returns the server's name and version. |
|
|
215
|
+
| `connectToMesh()` | `()` | Connects to the libp2p Kademlia DHT. |
|
|
216
|
+
| `clearAstCache()` | `()` | Invalidates the Guardian AST logic cache. |
|
|
217
|
+
| `close()` | `()` | Destroys the worker pool and releases threads. |
|
|
218
|
+
|
|
219
|
+
### `LiopMcpBridge`
|
|
220
|
+
|
|
221
|
+
Adapter that connects any `LiopServer` to MCP-compatible clients via JSON-RPC 2.0 over stdio.
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
const bridge = new LiopMcpBridge(server);
|
|
225
|
+
await bridge.connect();
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Supported JSON-RPC methods:**
|
|
229
|
+
- `initialize` — Returns server capabilities and info
|
|
230
|
+
- `tools/list` — Lists available tools
|
|
231
|
+
- `tools/call` — Calls a tool (with ZK-Receipt verification)
|
|
232
|
+
- `resources/list` — Lists available resources
|
|
233
|
+
- `resources/read` — Reads a resource
|
|
234
|
+
- `prompts/list` — Lists available prompts
|
|
235
|
+
- `prompts/get` — Gets a specific prompt
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Security Architecture
|
|
240
|
+
|
|
241
|
+
### The Shield — Multi-Layer Defense
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
┌─────────────────────────────────────────────────────┐
|
|
245
|
+
│ Layer 1: Guardian AST (Zero-Time Static Analysis) │
|
|
246
|
+
│ Blocks: require, import(), fs, eval, fetch, │
|
|
247
|
+
│ process, global, __proto__, XMLHttpRequest │
|
|
248
|
+
├─────────────────────────────────────────────────────┤
|
|
249
|
+
│ Layer 2: WASI Sandbox (V8 Isolate) │
|
|
250
|
+
│ No Node.js globals • CPU Fuel limits • 3s timeout │
|
|
251
|
+
├─────────────────────────────────────────────────────┤
|
|
252
|
+
│ Layer 3: PII Shield (Egress Filter) │
|
|
253
|
+
│ Scans output for Email, SSN, Credit Card, IP │
|
|
254
|
+
│ Strips forbidden keys from response objects │
|
|
255
|
+
├─────────────────────────────────────────────────────┤
|
|
256
|
+
│ Layer 4: ZK-Receipt (Integrity Verification) │
|
|
257
|
+
│ SHA-256 ImageID + SHA-512 RISC0-style Seal │
|
|
258
|
+
│ LiopMcpBridge verifies before forwarding to LLM │
|
|
259
|
+
└─────────────────────────────────────────────────────┘
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### PII Patterns
|
|
263
|
+
|
|
264
|
+
Built-in patterns with multi-layer verification:
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
import { PII_PATTERNS, PII_PRESETS } from "@nekzus/liop/server";
|
|
268
|
+
|
|
269
|
+
// Available patterns:
|
|
270
|
+
PII_PATTERNS.EMAIL // RFC 5322 compliant, excludes @example.com/@test.com
|
|
271
|
+
PII_PATTERNS.CREDIT_CARD // Visa/MC/Amex + Luhn algorithm validation
|
|
272
|
+
PII_PATTERNS.IP_ADDRESS // IPv4 with octet range validation (excludes localhost)
|
|
273
|
+
PII_PATTERNS.PHONE // International phone formats with digit-length validation
|
|
274
|
+
PII_PATTERNS.SSN // USA Social Security Number rules (blocks 000 segments)
|
|
275
|
+
PII_PATTERNS.IBAN // ISO 7064 Modulo 97-10 algorithm precision via BigInt
|
|
276
|
+
PII_PATTERNS.PASSPORT_MRZ // Strict 44-character TD3 international passport MRZ string
|
|
277
|
+
|
|
278
|
+
// Pre-built Regional Presets ready to drop-in via LiopServer(options):
|
|
279
|
+
PII_PRESETS.GLOBAL_STRICT
|
|
280
|
+
PII_PRESETS.US_COMPLIANT
|
|
281
|
+
PII_PRESETS.EU_GDPR
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Forbidden Keys
|
|
285
|
+
|
|
286
|
+
The PII Shield automatically strips any key from outgoing responses that matches your configured list:
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
const server = new LiopServer(info, {
|
|
290
|
+
security: {
|
|
291
|
+
forbiddenKeys: ["id", "ssn", "password", "token", "secret", "email", "name"],
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
// Any response containing these keys → instantly blocked with "Egress Security Violation"
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Logic-Injection-on-Origin Flow
|
|
300
|
+
|
|
301
|
+
The following shows a complete Logic-Injection-on-Origin execution cycle (handled internally by the SDK):
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
1. LLM generates JavaScript analysis code wrapped in ---BEGIN_LOGIC--- / ---END_LOGIC--- boundaries
|
|
305
|
+
2. LiopServer receives the payload via tools/call (JSON-RPC or direct)
|
|
306
|
+
3. Guardian AST inspects for sandbox escapes (zero-time heuristic analysis)
|
|
307
|
+
4. Code executes inside a V8 isolate with CPU fuel limits (no Node.js globals)
|
|
308
|
+
5. PII Shield scans output for forbidden data and keys
|
|
309
|
+
6. ZK-Receipt generated (SHA-256 logic hash + SHA-512 seal)
|
|
310
|
+
7. Result + receipt returned to the LLM (raw data never exposed)
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Data Dictionary & Zero-Shot Autonomy
|
|
314
|
+
|
|
315
|
+
The Data Dictionary tells the LLM exactly what fields exist in `env.records`, enabling accurate code generation without seeing the actual data:
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
server.dataDictionary({
|
|
319
|
+
id: "string (Anonymized patient identifier, strictly PII)",
|
|
320
|
+
age: "number (Patient age in years)",
|
|
321
|
+
condition: "string (Healthy, Hypertension, Diabetes Type 1, Diabetes Type 2, Heart Disease, Asthma)",
|
|
322
|
+
riskScore: "number (Float 0.0 to 1.0)",
|
|
323
|
+
lastVisit: "string (ISO 8601 date)",
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
server.enableZeroShotAutonomy(); // Registers the "Blind Analyst" prompt
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## Worker Pool (Multi-Core Scaling)
|
|
332
|
+
|
|
333
|
+
Node.js is single-threaded. Heavy operations like Kyber768 decryption, AES-GCM authentication, AST validation, and V8 sandbox instantiation would block the event loop in a standard setup.
|
|
334
|
+
|
|
335
|
+
This SDK dispatches all heavy computation to OS-level threads via [`piscina`](https://github.com/piscinajs/piscina), achieving Rust-like concurrency:
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
// Automatic — no configuration needed
|
|
339
|
+
// When a Logic-Injection-on-Origin payload is received:
|
|
340
|
+
// 1. Main thread receives JSON-RPC request
|
|
341
|
+
// 2. Worker thread: AST inspection + PQC decryption + Sandbox execution
|
|
342
|
+
// 3. Main thread: Returns result (non-blocking)
|
|
343
|
+
|
|
344
|
+
// Cleanup on shutdown:
|
|
345
|
+
await server.close();
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## Post-Quantum Cryptography
|
|
351
|
+
|
|
352
|
+
Transport-layer security using ML-KEM-768 (Kyber) for key encapsulation and AES-256-GCM for symmetric encryption:
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
import { LiopClient } from "@nekzus/liop/client";
|
|
356
|
+
|
|
357
|
+
const client = new LiopClient();
|
|
358
|
+
await client.connect();
|
|
359
|
+
|
|
360
|
+
// Discover remote tools via Kademlia DHT
|
|
361
|
+
const tools = await client.discoverTools();
|
|
362
|
+
|
|
363
|
+
// Call a tool with PQC-encrypted WASM payload
|
|
364
|
+
// Kyber768 key encapsulation + AES-256-GCM happens automatically
|
|
365
|
+
const result = await client.callTool(request, wasmPayload, serverPublicKey);
|
|
366
|
+
|
|
367
|
+
// Verify the ZK-Receipt from the remote server
|
|
368
|
+
const isValid = await client.verifyZkReceipt(payload, imageId, receipt);
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## P2P Mesh Network
|
|
374
|
+
|
|
375
|
+
Decentralized tool discovery via Kademlia DHT:
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
await server.connectToMesh();
|
|
379
|
+
// Server is now discoverable on the libp2p network
|
|
380
|
+
// Transports: TCP + WebSocket
|
|
381
|
+
// Multiplexing: Yamux
|
|
382
|
+
// Encryption: Noise Protocol
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Testing & Quality
|
|
388
|
+
|
|
389
|
+
This package is continuously tested across multiple platforms and Node.js versions via CI/CD:
|
|
390
|
+
|
|
391
|
+
- **51+ tests** spanning unit, integration, and conformance suites
|
|
392
|
+
- **Multi-OS matrix:** Ubuntu, Windows, macOS
|
|
393
|
+
- **Node.js versions:** 22.x, 24.x
|
|
394
|
+
- **Code quality:** Enforced by [Biome.js](https://biomejs.dev/) (linting + formatting)
|
|
395
|
+
|
|
396
|
+
> To run tests locally or contribute, clone the [repository](https://github.com/Nekzus/Neural-Mesh-Protocol) and follow the [Contributing Guide](https://github.com/Nekzus/Neural-Mesh-Protocol/blob/main/CONTRIBUTING.md).
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
## Related
|
|
401
|
+
|
|
402
|
+
- [LIOP Documentation](https://liop.mintlify.app/) — Full conceptual and API documentation
|
|
403
|
+
- [LIOP Specification](https://github.com/Nekzus/Neural-Mesh-Protocol/blob/main/protocol/SPECIFICATION.md) — Technical specification
|
|
404
|
+
- [LIOP Manifesto](https://github.com/Nekzus/Neural-Mesh-Protocol/blob/main/MANIFESTO.md) — Project philosophy
|
|
405
|
+
- [Contributing Guide](https://github.com/Nekzus/Neural-Mesh-Protocol/blob/main/CONTRIBUTING.md) — How to contribute
|
|
406
|
+
- [Rust Mesh Node](https://github.com/Nekzus/Neural-Mesh-Protocol/tree/main/servers/liop-node) — Native high-performance backend
|
|
407
|
+
- [LIOP CLI](https://github.com/Nekzus/Neural-Mesh-Protocol/tree/main/tools/liop-cli) — Developer diagnostics
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
## License
|
|
412
|
+
|
|
413
|
+
[MIT](https://github.com/Nekzus/Neural-Mesh-Protocol/blob/main/LICENSE) © [Nekzus](https://github.com/Nekzus)
|