@nekzus/liop 2.0.1-beta.1 → 2.1.0-alpha.2
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/README.md +39 -11
- package/dist/bin/agent.js +1 -1
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +1 -1
- package/dist/{chunk-L5A64CNT.js → chunk-CXMVL5IW.js} +18 -18
- package/dist/chunk-CXMVL5IW.js.map +1 -0
- package/dist/{chunk-YZVCAJJO.js → chunk-GI2LSJYZ.js} +3 -3
- package/dist/{chunk-YZVCAJJO.js.map → chunk-GI2LSJYZ.js.map} +1 -1
- package/dist/{chunk-VGXNGTIC.js → chunk-I46YEWND.js} +7 -7
- package/dist/chunk-I46YEWND.js.map +1 -0
- package/dist/{chunk-W2QGWRTT.js → chunk-I7OTWNFM.js} +3 -3
- package/dist/{chunk-W2QGWRTT.js.map → chunk-I7OTWNFM.js.map} +1 -1
- package/dist/chunk-PWCXZWSE.js +2 -0
- package/dist/chunk-PWCXZWSE.js.map +1 -0
- package/dist/{chunk-N6FGTZ6A.js → chunk-T3L6OCM3.js} +3 -3
- package/dist/chunk-T3L6OCM3.js.map +1 -0
- package/dist/{chunk-2MGFSIXN.js → chunk-VQUSWD4U.js} +2 -2
- package/dist/chunk-VQUSWD4U.js.map +1 -0
- package/dist/chunk-XOITNPU3.js +2 -0
- package/dist/{chunk-TYVG6TXQ.js.map → chunk-XOITNPU3.js.map} +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -1
- package/dist/gateway.d.ts +2 -2
- package/dist/gateway.js +1 -1
- package/dist/{index-B_Vbrb_I.d.ts → index-Brfvxmdt.d.ts} +1 -1
- package/dist/{index-CL8m1L1d.d.ts → index-DO97j6hP.d.ts} +14 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/types.js +1 -1
- package/dist/{verifier-DTCD9imJ.d.ts → verifier-COnid_dg.d.ts} +1 -1
- package/dist/verifier-XU2DB56Z.js +2 -0
- package/dist/{verifier-Z26UC7M4.js.map → verifier-XU2DB56Z.js.map} +1 -1
- package/dist/workers/zk-verifier.d.ts +2 -0
- package/dist/workers/zk-verifier.js +1 -1
- package/dist/workers/zk-verifier.js.map +1 -1
- package/package.json +43 -43
- package/dist/chunk-2MGFSIXN.js.map +0 -1
- package/dist/chunk-L5A64CNT.js.map +0 -1
- package/dist/chunk-N6FGTZ6A.js.map +0 -1
- package/dist/chunk-SW53FNSN.js +0 -2
- package/dist/chunk-SW53FNSN.js.map +0 -1
- package/dist/chunk-TYVG6TXQ.js +0 -2
- package/dist/chunk-VGXNGTIC.js.map +0 -1
- package/dist/verifier-Z26UC7M4.js +0 -2
package/README.md
CHANGED
|
@@ -35,11 +35,11 @@ This fundamentally solves the data privacy, bandwidth, and latency challenges of
|
|
|
35
35
|
| **Logic-Injection-on-Origin** | LLMs send code, not queries. Data never leaves the origin server. |
|
|
36
36
|
| **MCP Drop-in Replacement** | `LiopServer` mirrors the Anthropic MCP `Server` API — tools, resources, and prompts with `Zod` schemas. |
|
|
37
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
|
|
39
|
-
| **PII Shield** | Multi-layer egress filter with Regional Presets
|
|
40
|
-
| **ZK-Receipts** | Cryptographic proof
|
|
41
|
-
| **Worker Pool** | Heavy computation (crypto, sandboxing) dispatched to OS threads via `piscina
|
|
42
|
-
| **Cross-AI Adapters** | Zero-Shot system prompts automatically adapt instructions for Claude (XML-heavy) vs OpenAI/Gemini (JSON-schema).
|
|
38
|
+
| **WASI Sandbox** | JavaScript payloads execute inside V8 isolates with CPU fuel limits, no Node.js globals, and safe environment isolation (`allowEnv`). |
|
|
39
|
+
| **PII Shield** | Multi-layer egress filter with Regional Presets, custom keys, and recursive floats sanitization (`sanitizeOutput`). |
|
|
40
|
+
| **ZK-Receipts** | Cryptographic proof with `output_hash` cross-verification (Replay Mitigation) and balanced-brace proxy extraction. |
|
|
41
|
+
| **Worker Pool** | Heavy computation (crypto, sandboxing) dispatched to OS threads via `piscina` with background async warmup. |
|
|
42
|
+
| **Cross-AI Adapters** | Zero-Shot system prompts automatically adapt instructions for Claude (XML-heavy) vs OpenAI/Gemini (JSON-schema). |
|
|
43
43
|
| **MCP Bridge** | `LiopMcpBridge` adapts any `LiopServer` to the JSON-RPC 2.0 / stdio protocol used by Claude Desktop, Cursor, etc. |
|
|
44
44
|
| **Post-Quantum Ready** | ML-KEM-768 (Kyber) handshake + AES-256-GCM symmetric encryption for transport-layer security. |
|
|
45
45
|
| **P2P Mesh** | Kademlia DHT discovery via `libp2p` with TCP + WebSocket + Yamux multiplexing and Noise encryption. |
|
|
@@ -245,6 +245,7 @@ new LiopServer(
|
|
|
245
245
|
};
|
|
246
246
|
auth?: LiopAuthConfig; // OAuth 2.1 Hybrid authentication config
|
|
247
247
|
tokenSlug?: string; // Deterministic token resolution slug (e.g., "BANK", "VAULT")
|
|
248
|
+
allowEnv?: boolean; // Enable safe host environment propagation (default: false)
|
|
248
249
|
}
|
|
249
250
|
)
|
|
250
251
|
```
|
|
@@ -300,11 +301,11 @@ await bridge.connect();
|
|
|
300
301
|
│ Layer 1: Guardian AST (Zero-Time Static Analysis) │
|
|
301
302
|
│ 14-function WASI allowlist • 128 import cap • Blocks │
|
|
302
303
|
│ require, import(), fs, eval, fetch, __proto__ │
|
|
303
|
-
|
|
304
|
+
├───────────────────────────────────────────────────────────┐
|
|
304
305
|
│ Layer 2: WASI Sandbox (V8 Isolate) │
|
|
305
306
|
│ 25 poisoned globals (incl. Date, TypedArrays) • │
|
|
306
307
|
│ CPU Fuel limits • 5s timeout • maxHeapMb (64MB default) │
|
|
307
|
-
│ Object.freeze() on 11 core prototypes
|
|
308
|
+
│ Object.freeze() on 11 core prototypes • allowEnv allowlist │
|
|
308
309
|
├───────────────────────────────────────────────────────────┤
|
|
309
310
|
│ Layer 3: Taint Analyzer (IFC — Static) │
|
|
310
311
|
│ Acorn AST 3-pass analysis blocks PII side-channels: │
|
|
@@ -312,15 +313,16 @@ await bridge.connect();
|
|
|
312
313
|
├───────────────────────────────────────────────────────────┤
|
|
313
314
|
│ Layer 4: PII Shield (Egress Filter) │
|
|
314
315
|
│ 4-stage pipeline: exact key → fuzzy key → pattern │
|
|
315
|
-
│ validators (Luhn, IBAN Mod-97) → NER (compromise)
|
|
316
|
+
│ validators (Luhn, IBAN Mod-97) → NER (compromise) • │
|
|
317
|
+
│ Recursive In-Memory Numerical Sanitization (4 decimals) │
|
|
316
318
|
├───────────────────────────────────────────────────────────┤
|
|
317
319
|
│ Layer 5: Aggregation-First Policy │
|
|
318
320
|
│ Blocks raw row export • maxOutputRows (default: 10) • │
|
|
319
321
|
│ Conditional error: detailed (dev) vs opaque (production) │
|
|
320
322
|
├───────────────────────────────────────────────────────────┤
|
|
321
|
-
│ Layer 6: ZK-Receipt (Integrity
|
|
322
|
-
│ SHA-256 ImageID + HMAC-SHA256 Seal (Kyber768-derived)
|
|
323
|
-
│
|
|
323
|
+
│ Layer 6: ZK-Receipt (Integrity & Replay Mitigation) │
|
|
324
|
+
│ SHA-256 ImageID + HMAC-SHA256 Seal (Kyber768-derived) • │
|
|
325
|
+
│ output_hash cross-verification • Balanced-brace extractor │
|
|
324
326
|
└───────────────────────────────────────────────────────────┘
|
|
325
327
|
```
|
|
326
328
|
|
|
@@ -386,6 +388,32 @@ For maximum host security, the WASI sandbox enforces a poisoned environment that
|
|
|
386
388
|
- **Poisoned/Disabled**: `Date` (Date.now, parse, etc. throw an exception to prevent timing analysis), `eval`, `Function`, `setTimeout`, `setInterval`, `Buffer`, `ArrayBuffer`, and all `TypedArrays`.
|
|
387
389
|
- **Date Workaround**: To perform date checks, use lexicographical string comparison on ISO 8601 strings (e.g., `record.date >= "2026-01-01"`).
|
|
388
390
|
|
|
391
|
+
### 🧹 Recursive In-Memory Numerical Sanitization
|
|
392
|
+
|
|
393
|
+
To mitigate timing channels, statistical differentiation, and floats side-channels, the SDK executes a recursive sanitization pipeline before the PII scanner runs:
|
|
394
|
+
- Positive floating-point numbers are recursively rounded to exactly **4 decimal places**.
|
|
395
|
+
- Negative values are safely clamped to **0** (via `sanitizeOutput()`).
|
|
396
|
+
- This operation runs entirely in-memory and recursively on all fields, preserving data structure immutability without expensive and fragile serialization-deserialization cycles.
|
|
397
|
+
|
|
398
|
+
### 🌐 Environment Isolation & allowEnv Allowlist
|
|
399
|
+
|
|
400
|
+
For robust sandboxing, the WASI execution path isolates host environment variables. Propagation can be enabled explicitly:
|
|
401
|
+
```typescript
|
|
402
|
+
const server = new LiopServer(info, {
|
|
403
|
+
allowEnv: true
|
|
404
|
+
});
|
|
405
|
+
```
|
|
406
|
+
To block arbitrary command execution (e.g., Shellshock) and prevent exposure of host credentials, the SDK filters environment variables through a **strict system allowlist** (`getDefaultEnvironment()`):
|
|
407
|
+
- **Windows Allowlist**: `APPDATA`, `HOMEDRIVE`, `HOMEPATH`, `LOCALAPPDATA`, `PATH`, `PROCESSOR_ARCHITECTURE`, `SYSTEMDRIVE`, `SYSTEMROOT`, `TEMP`, `USERNAME`, `USERPROFILE`, `PROGRAMFILES`.
|
|
408
|
+
- **Unix/Linux Allowlist**: `HOME`, `LOGNAME`, `PATH`, `SHELL`, `TERM`, `USER`.
|
|
409
|
+
Variables starting with shell functions `()` are dropped.
|
|
410
|
+
|
|
411
|
+
### 🔒 ZK-Receipt Replay & Tampering Mitigation
|
|
412
|
+
|
|
413
|
+
LIOP ZK-Receipts provide cryptographic evidence that a computation was executed honestly under zero-trust bounds. To defeat **Man-in-the-Middle (MITM) reply tampering and replay attacks** (re-using old signatures on new query data):
|
|
414
|
+
- The verification pipeline computes the SHA-256 hash of the received business output (`expectedOutput`) and strictly asserts its equivalence with `Journal.output_hash` signed inside the ZK-Receipt (via `verifyZkReceipt`).
|
|
415
|
+
- **Balanced-Brace Proxy Extractor**: If the tool call was delegated to a proxied tool (`__liop_proxy_tool`), the verifier invokes an in-process balanced-brace state machine to safely isolate proxy arguments from the response metadata, preventing false validation failures.
|
|
416
|
+
|
|
389
417
|
---
|
|
390
418
|
|
|
391
419
|
## Logic-Injection-on-Origin Flow
|
package/dist/bin/agent.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {j}from'../chunk-
|
|
2
|
+
import {j}from'../chunk-CXMVL5IW.js';import'../chunk-VQUSWD4U.js';import {g}from'../chunk-I46YEWND.js';import'../chunk-PWCXZWSE.js';import'../chunk-ANFXJGMP.js';import'../chunk-DBXGYHKY.js';import'../chunk-SB5XJXKV.js';import'../chunk-V5MKJT6S.js';import'../chunk-RWRRBYG4.js';import {a as a$1}from'../chunk-DQ6UW6L7.js';import {a}from'../chunk-S6RJHZV2.js';import'../chunk-4C666HHU.js';import*as l from'fs';import*as w from'os';import*as u from'path';import {multiaddr}from'@multiformats/multiaddr';async function x(t){try{let o=t.endsWith("/health")?t:`${t}/health`,d=await fetch(o,{headers:{Accept:"application/json"},signal:AbortSignal.timeout(1e4)});if(!d.ok)return null;let e=await d.json();if(!e.mesh?.multiaddrs?.length||!e.mesh?.peerId)return null;let p=e.mesh.multiaddrs.find(c=>c.includes("/tcp/")&&!c.includes("/ws")&&!c.includes("/ip4/127.0.0.1/"));if(!p)return null;let r=E()?R(p):p;if(!r||r===p){let c=new URL(t).hostname;r=p.replace(/\/ip4\/[^/]+/,`/ip4/${c}`);}return r?(r+=r.includes("/p2p/")?"":`/p2p/${e.mesh.peerId}`,r):null}catch{return null}}function L(t){let o=t.trim(),d=/\/ip4\/172\.(1[6-9]|2[0-9]|3[0-1])\.[0-9]{1,3}\.[0-9]{1,3}/,e=/\/ip4\/127\.0\.0\.1/,p=/\/ip4\/192\.168\.[0-9]{1,3}\.[0-9]{1,3}/;if(d.test(o)||e.test(o)||p.test(o)){let r="127.0.0.1",c=o.replace(d,`/ip4/${r}`).replace(e,`/ip4/${r}`).replace(p,`/ip4/${r}`);return c!==o&&a.info(`[LIOP-Agent] \u{1F504} Local Routing Hack \u2192 Forced 127.0.0.1: ${c}`),c}return o}function R(t){return t.includes("/ip4/172.20.0.10")?t.replace(/\/ip4\/172\.20\.0\.10\/tcp\/[0-9]+/,"/ip4/127.0.0.1/tcp/13001"):t.includes("/ip4/172.20.0.11")?t.replace(/\/ip4\/172\.20\.0\.11\/tcp\/[0-9]+/,"/ip4/127.0.0.1/tcp/13003"):t.includes("/ip4/172.20.0.12")?t.replace(/\/ip4\/172\.20\.0\.12\/tcp\/[0-9]+/,"/ip4/127.0.0.1/tcp/13004"):t.includes("/ip4/172.20.0.13")?t.replace(/\/ip4\/172\.20\.0\.13\/tcp\/[0-9]+/,"/ip4/127.0.0.1/tcp/13005"):t.includes("/ip4/127.0.0.1/tcp/4000")||t.includes("/ip4/127.0.0.1/tcp/3000")?null:t}function D(t){try{let o=new URL(t);return (o.hostname==="127.0.0.1"||o.hostname==="localhost")&&(o.port==="13000"||o.port==="13001")}catch{return false}}function E(){return process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test"||process.env.LIOP_DOCKER_MAP==="true"||process.env.LIOP_DEV_MODE==="true"||!!process.env.LIOP_NEXUS_URL&&D(process.env.LIOP_NEXUS_URL)}async function M(){if((process.platform==="win32"||process.platform==="darwin")&&!process.execArgv.includes("--use-system-ca")&&!(process.env.NODE_OPTIONS??"").includes("--use-system-ca")){let{spawn:s}=await import('child_process'),n=s(process.execPath,["--use-system-ca",...process.argv.slice(1)],{stdio:"inherit",env:process.env});n.on("exit",a=>process.exit(a??1)),n.on("error",()=>process.exit(1)),await new Promise(()=>{});return}let t=new Date().toISOString();a.info(`[LIOP-Agent] \u{1F680} Version 1.2.0-alpha.9 | Build: ${t}`);let o=u.join(w.homedir(),".liop"),d=u.join(o,"identity.json");l.existsSync(o)||l.mkdirSync(o,{recursive:true});let e=[],p=process.argv.slice(2);if(p.length>0&&(e=p.filter(s=>s.startsWith("/"))),e.length===0){let s=[];if(process.env.LIOP_BOOTSTRAP_FILE){a.warn("LIOP_BOOTSTRAP_FILE is deprecated and will be removed in the next major version. Use LIOP_NEXUS_URL for Auto-Discovery instead.");let n=u.resolve(process.env.LIOP_BOOTSTRAP_FILE);if(l.existsSync(n)){let a=l.readFileSync(n,"utf8").trim();a&&e.push(L(a));}}s.push(process.cwd(),u.join(process.cwd(),"tests/infra/nexus-data"),o,u.join(u.dirname(new URL(import.meta.url).pathname).replace(/^\/([A-Z]:)/,"$1"),"../../tests/infra/nexus-data"));for(let n of s)try{if(l.existsSync(n)){let h=l.readdirSync(n).filter(g=>g.endsWith(".multiaddr"));for(let g of h){let $=u.join(n,g),v=l.readFileSync($,"utf8").trim();if(v){let S=L(v);e.includes(S)||(e.push(S),a.info(`[LIOP-Agent] \u2705 Loaded beacon: ${g} from ${n}`));}}if(e.length>0)break}}catch{}}if(process.env.LIOP_NEXUS_URL){let s=process.env.LIOP_NEXUS_URL;a.info(`[LIOP-Agent] \u{1F310} Running parallel discovery from: ${s} (Sources Found: ${e.length})`);let n=await x(s);if(n){let a$1=L(n);e.includes(a$1)||(e.push(a$1),a.info(`[LIOP-Agent] \u2705 Added bootstrap from URL discovery: ${a$1}`));}}e.length===0&&process.env.LIOP_BOOTSTRAP&&e.push(process.env.LIOP_BOOTSTRAP.trim()),e.length===0&&e.push("/ip4/127.0.0.1/tcp/13001/p2p/12D3KooWD8FUFdnLQzzLFNdicsaTknM5cpD7os9sK9NWVSVABJMD"),e=e.filter(s=>{try{return multiaddr(s),!0}catch{return a.warn(`[LIOP-Agent] Ignoring invalid bootstrap multiaddr: ${s}`),false}}),e.length===0&&(a.info("[LIOP-Agent] No bootstrap nodes configured. Operating in standalone mode."),a.info("[LIOP-Agent] Pass a multiaddr as argument or create 'nexus.multiaddr' file."));let r=new j({name:"@nekzus/liop",version:"1.0.0"});r.enableZeroShotAutonomy();let c=new a$1({identityPath:d,bootstrapNodes:e,addressMapper:E()?R:void 0});await c.start();let f=new g(r,c);f.onToolsChanged=()=>{process.stdout.write(`{"jsonrpc":"2.0","method":"notifications/tools/list_changed"}
|
|
3
3
|
`),process.stdout.write(`{"jsonrpc":"2.0","method":"notifications/resources/list_changed"}
|
|
4
4
|
`);},setTimeout(()=>{let s=c.getRoutingTableSize?.()||0;a.info(`[LIOP-Agent] Warm-up complete. Routing Table size: ${s}`),f.refreshManifestCache(true).catch(()=>{});},2e3);let O=1e4,T=12e4,m=O,P=()=>{setTimeout(async()=>{let s=f.getCacheSize();await f.refreshManifestCache(true).catch(()=>{});let n=f.getCacheSize();n!==s?(m=O,a.info(`[LIOP-Agent] Topology change detected (${s} \u2192 ${n}). Resetting poll to ${O/1e3}s.`)):m=Math.min(Math.round(m*1.5),T),P();},m);};P();let I=(await import('readline')).createInterface({input:process.stdin,terminal:false});process.stdout.on("error",s=>{s.code==="EPIPE"&&process.exit(0);}),I.on("line",async s=>{let n=s.trim();if(n)try{let a=JSON.parse(n);if(a.method){let h=await f.dispatch(a);h&&process.stdout.write(`${JSON.stringify(h)}
|
|
5
5
|
`);}}catch{}}),I.on("close",()=>{process.exit(0);}),a.info("[LIOP-Agent] Guarding Claude Desktop via STDIO."),a.info(`[LIOP-Agent] P2P Mesh: Joined (${e.length} bootstraps)`),a.info("[LIOP-Agent] Tool discovery: Dynamic via /liop/manifest/1.0.0"),process.on("SIGINT",async()=>{await c.stop(),process.exit(0);});}M().catch(t=>{a.error(`[LIOP-Agent] Fatal Error: ${t.message}`),process.exit(1);});//# sourceMappingURL=agent.js.map
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { L as LiopServer, a as LiopServerOptions } from './index-
|
|
2
|
+
import { L as LiopServer, a as LiopServerOptions } from './index-DO97j6hP.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import './mesh.js';
|
|
5
5
|
import './types-DzEXgi4s.js';
|
package/dist/bridge.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{b as LiopMcpBridge,a as LiopStreamBridge}from'./chunk-
|
|
1
|
+
export{b as LiopMcpBridge,a as LiopStreamBridge}from'./chunk-I7OTWNFM.js';import'./chunk-S6RJHZV2.js';import'./chunk-4C666HHU.js';//# sourceMappingURL=bridge.js.map
|
|
2
2
|
//# sourceMappingURL=bridge.js.map
|