@nekzus/liop 2.1.0-alpha.1 → 2.1.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/README.md +30 -1
- package/dist/bin/agent.js +303 -4
- package/dist/bin/agent.js.map +1 -1
- package/dist/bridge.d.ts +2 -2
- package/dist/bridge.js +4 -1
- package/dist/chunk-32ADSAJS.js +104 -0
- package/dist/chunk-32ADSAJS.js.map +1 -0
- package/dist/chunk-72MNYFR6.js +64 -0
- package/dist/chunk-72MNYFR6.js.map +1 -0
- package/dist/chunk-E5QBDD5E.js +469 -0
- package/dist/chunk-E5QBDD5E.js.map +1 -0
- package/dist/chunk-EEYEVHO2.js +9329 -0
- package/dist/chunk-EEYEVHO2.js.map +1 -0
- package/dist/chunk-F5YNYL5L.js +14512 -0
- package/dist/chunk-F5YNYL5L.js.map +1 -0
- package/dist/chunk-HB5DXX3Q.js +1976 -0
- package/dist/chunk-HB5DXX3Q.js.map +1 -0
- package/dist/chunk-IJHTRIZC.js +56 -0
- package/dist/chunk-IJHTRIZC.js.map +1 -0
- package/dist/chunk-IMPCCZ2Y.js +463 -0
- package/dist/chunk-IMPCCZ2Y.js.map +1 -0
- package/dist/chunk-J3WPBMJ5.js +332 -0
- package/dist/chunk-J3WPBMJ5.js.map +1 -0
- package/dist/chunk-MCXMS5ZI.js +30 -0
- package/dist/chunk-MCXMS5ZI.js.map +1 -0
- package/dist/chunk-NJRSFFD7.js +815 -0
- package/dist/chunk-NJRSFFD7.js.map +1 -0
- package/dist/chunk-OUUTDSOW.js +24 -0
- package/dist/chunk-OUUTDSOW.js.map +1 -0
- package/dist/chunk-PHTWUTY7.js +300 -0
- package/dist/chunk-PHTWUTY7.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/{chunk-4C666HHU.js.map → chunk-PZ5AY32C.js.map} +1 -1
- package/dist/chunk-QLCOEP5J.js +68 -0
- package/dist/chunk-QLCOEP5J.js.map +1 -0
- package/dist/chunk-RDWCGZ2A.js +87 -0
- package/dist/chunk-RDWCGZ2A.js.map +1 -0
- package/dist/chunk-RWRRBYG4.js +1 -0
- package/dist/client.d.ts +2 -2
- package/dist/client.js +9 -1
- package/dist/gateway.d.ts +2 -2
- package/dist/gateway.js +10 -1
- package/dist/{index-BcuTJtQX.d.ts → index-BlGc0iym.d.ts} +22 -1
- package/dist/{index-Brfvxmdt.d.ts → index-qM8ZH8sC.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +60 -4
- package/dist/index.js.map +1 -1
- package/dist/kyber-FCVPX6CE.js +4 -0
- package/dist/{kyber-NONMBQNH.js.map → kyber-FCVPX6CE.js.map} +1 -1
- package/dist/mesh.js +5 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +8 -1
- package/dist/{types-DzEXgi4s.d.ts → types-sKeUxuky.d.ts} +4 -46
- package/dist/types.d.ts +1 -1
- package/dist/types.js +4 -1
- package/dist/verifier-GCZDNZK7.js +6 -0
- package/dist/{verifier-XU2DB56Z.js.map → verifier-GCZDNZK7.js.map} +1 -1
- package/dist/workers/logic-execution.js +256 -1
- package/dist/workers/logic-execution.js.map +1 -1
- package/dist/workers/zk-verifier.js +174 -1
- package/dist/workers/zk-verifier.js.map +1 -1
- package/package.json +43 -44
- package/dist/chunk-2MGFSIXN.js +0 -2
- package/dist/chunk-2MGFSIXN.js.map +0 -1
- package/dist/chunk-4C666HHU.js +0 -2
- package/dist/chunk-7L5ODML2.js +0 -3
- package/dist/chunk-7L5ODML2.js.map +0 -1
- package/dist/chunk-ANFXJGMP.js +0 -2
- package/dist/chunk-ANFXJGMP.js.map +0 -1
- package/dist/chunk-DBXGYHKY.js +0 -2
- package/dist/chunk-DBXGYHKY.js.map +0 -1
- package/dist/chunk-DQ6UW6L7.js +0 -2
- package/dist/chunk-DQ6UW6L7.js.map +0 -1
- package/dist/chunk-GI2LSJYZ.js +0 -13
- package/dist/chunk-GI2LSJYZ.js.map +0 -1
- package/dist/chunk-I46YEWND.js +0 -33
- package/dist/chunk-I46YEWND.js.map +0 -1
- package/dist/chunk-KQ5BDO2M.js +0 -54
- package/dist/chunk-KQ5BDO2M.js.map +0 -1
- package/dist/chunk-PWCXZWSE.js +0 -2
- package/dist/chunk-PWCXZWSE.js.map +0 -1
- package/dist/chunk-RYYRR4N5.js +0 -31
- package/dist/chunk-RYYRR4N5.js.map +0 -1
- package/dist/chunk-S6RJHZV2.js +0 -2
- package/dist/chunk-S6RJHZV2.js.map +0 -1
- package/dist/chunk-SB5XJXKV.js +0 -2
- package/dist/chunk-SB5XJXKV.js.map +0 -1
- package/dist/chunk-T3L6OCM3.js +0 -3
- package/dist/chunk-T3L6OCM3.js.map +0 -1
- package/dist/chunk-TYVG6TXQ.js +0 -2
- package/dist/chunk-TYVG6TXQ.js.map +0 -1
- package/dist/chunk-V5MKJT6S.js +0 -2
- package/dist/chunk-V5MKJT6S.js.map +0 -1
- package/dist/kyber-NONMBQNH.js +0 -2
- package/dist/verifier-XU2DB56Z.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/rpc/crypto/kyber.ts"],"names":[],"mappings":";;;AAcA,IAAI,WAAA,GAAiE,IAAA;AAErE,eAAe,cAAA,GAAiB;AAC/B,EAAA,IAAI,CAAC,WAAA,EAAa;AACjB,IAAA,WAAA,GAAc,MAAM,cAAA,EAAe;AAAA,EACpC;AACA,EAAA,OAAO,WAAA;AACR;AAEO,IAAM,eAAA,GAAkB;AAAA;AAAA;AAAA;AAAA;AAAA,EAK9B,gBAAgB,MAAA,EAAgC;AAC/C,IAAA,IAAI,MAAA,CAAO,WAAW,IAAA,EAAM;AAC3B,MAAA,MAAM,IAAI,KAAA;AAAA,QACT,CAAA,0DAAA,EAA6D,OAAO,MAAM,CAAA,CAAA;AAAA,OAC3E;AAAA,IACD;AACA,IAAA,OAAO,MAAA;AAAA,EACR,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,sBAAsB,SAAA,EAGzB;AACF,IAAA,IAAI;AACH,MAAA,IAAI,SAAA,CAAU,WAAW,IAAA,EAAM;AAC9B,QAAA,MAAM,IAAI,MAAM,iDAAiD,CAAA;AAAA,MAClE;AAEA,MAAA,MAAM,GAAA,GAAM,MAAM,cAAA,EAAe;AACjC,MAAA,MAAM,CAAC,EAAA,EAAI,EAAE,CAAA,GAAI,GAAA,CAAI,MAAM,SAAS,CAAA;AAEpC,MAAA,OAAO;AAAA,QACN,UAAA,EAAY,EAAA;AAAA,QACZ,YAAA,EAAc;AAAA,OACf;AAAA,IACD,SAAS,KAAA,EAAO;AACf,MAAA,MAAM,IAAI,KAAA;AAAA,QACT,CAAA,qCAAA,EAAyC,MAAgB,OAAO,CAAA;AAAA,OACjE;AAAA,IACD;AAAA,EACD,CAAA;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,eAAA,GAGH;AACF,IAAA,MAAM,GAAA,GAAM,MAAM,cAAA,EAAe;AACjC,IAAA,MAAM,CAAC,EAAA,EAAI,EAAE,CAAA,GAAI,IAAI,eAAA,EAAgB;AACrC,IAAA,OAAO;AAAA,MACN,SAAA,EAAW,EAAA;AAAA,MACX,SAAA,EAAW;AAAA,KACZ;AAAA,EACD,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,oBAAA,CACL,UAAA,EACA,SAAA,EACsB;AACtB,IAAA,MAAM,GAAA,GAAM,MAAM,cAAA,EAAe;AACjC,IAAA,OAAO,GAAA,CAAI,KAAA,CAAM,UAAA,EAAY,SAAS,CAAA;AAAA,EACvC;AACD","file":"chunk-QLCOEP5J.js","sourcesContent":["import { createMlKem768 } from \"mlkem\";\n\n/**\n * LIOP Post-Quantum Cryptography Wrapper\n * Implements ML-KEM-768 (NIST FIPS 203) for Zero-Trust secure key encapsulation\n * directly compatible with `pqcrypto-kyber` on the Mesh-Node Backend.\n *\n * Uses the `mlkem` package which provides:\n * - FIPS 203 compliance (ML-KEM standard)\n * - Constant-time validation (KyberSlash patched)\n * - ~3.5x performance improvement over legacy crystals-kyber\n */\n\n/** Lazy-initialized singleton for the ML-KEM-768 engine */\nlet kemInstance: Awaited<ReturnType<typeof createMlKem768>> | null = null;\n\nasync function getKemInstance() {\n\tif (!kemInstance) {\n\t\tkemInstance = await createMlKem768();\n\t}\n\treturn kemInstance;\n}\n\nexport const Kyber768Wrapper = {\n\t/**\n\t * Extracts and validates the 1184-byte Public Key from the Rust LIOP Data Node\n\t * @param buffer Raw buffer sent via gRPC IntentResponse\n\t */\n\timportPublicKey(buffer: Uint8Array): Uint8Array {\n\t\tif (buffer.length !== 1184) {\n\t\t\tthrow new Error(\n\t\t\t\t`Kyber768 Public Key must be exactly 1184 bytes (Received: ${buffer.length})`,\n\t\t\t);\n\t\t}\n\t\treturn buffer;\n\t},\n\n\t/**\n\t * Encapsulates a shared secret using the server's public key.\n\t * Returns the 1088-byte ciphertext to be sent back, and the 32-byte shared AES secret.\n\t */\n\tasync encapsulateAsymmetric(publicKey: Uint8Array): Promise<{\n\t\tciphertext: Uint8Array;\n\t\tsharedSecret: Uint8Array;\n\t}> {\n\t\ttry {\n\t\t\tif (publicKey.length !== 1184) {\n\t\t\t\tthrow new Error(\"Kyber768 Public Key must be exactly 1184 bytes.\");\n\t\t\t}\n\n\t\t\tconst kem = await getKemInstance();\n\t\t\tconst [ct, ss] = kem.encap(publicKey);\n\n\t\t\treturn {\n\t\t\t\tciphertext: ct,\n\t\t\t\tsharedSecret: ss,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to perform PQC encapsulation: ${(error as Error).message}`,\n\t\t\t);\n\t\t}\n\t},\n\n\t/**\n\t * Generates a Kyber768 KeyPair for the server to accept intents.\n\t */\n\tasync generateKeyPair(): Promise<{\n\t\tpublicKey: Uint8Array;\n\t\tsecretKey: Uint8Array;\n\t}> {\n\t\tconst kem = await getKemInstance();\n\t\tconst [pk, sk] = kem.generateKeyPair();\n\t\treturn {\n\t\t\tpublicKey: pk,\n\t\t\tsecretKey: sk,\n\t\t};\n\t},\n\n\t/**\n\t * Decapsulates the shared secret using the server's secret key.\n\t * Zero-fills the shared secret buffer after extraction for side-channel protection.\n\t */\n\tasync decapsulateSymmetric(\n\t\tciphertext: Uint8Array,\n\t\tsecretKey: Uint8Array,\n\t): Promise<Uint8Array> {\n\t\tconst kem = await getKemInstance();\n\t\treturn kem.decap(ciphertext, secretKey);\n\t},\n};\n"]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { log } from './chunk-72MNYFR6.js';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import * as grpc2 from '@grpc/grpc-js';
|
|
5
|
+
import * as protoLoader from '@grpc/proto-loader';
|
|
6
|
+
import * as fs2 from 'fs';
|
|
7
|
+
|
|
8
|
+
var __filename$1 = fileURLToPath(import.meta.url);
|
|
9
|
+
var __dirname$1 = path.dirname(__filename$1);
|
|
10
|
+
var PROD_PATHS = [
|
|
11
|
+
path.resolve(__dirname$1, "./protocol/liop_core.proto"),
|
|
12
|
+
// Flat dist/ (tsup)
|
|
13
|
+
path.resolve(__dirname$1, "../protocol/liop_core.proto")
|
|
14
|
+
// dist/rpc/ (tsc)
|
|
15
|
+
];
|
|
16
|
+
var DEV_PROTO_PATH = path.resolve(
|
|
17
|
+
__dirname$1,
|
|
18
|
+
"../../../../protocol/proto/liop_core.proto"
|
|
19
|
+
);
|
|
20
|
+
var PROTO_PATH = PROD_PATHS.find((p) => fs2.existsSync(p)) || DEV_PROTO_PATH;
|
|
21
|
+
if (!fs2.existsSync(PROTO_PATH)) {
|
|
22
|
+
log.error(`[LIOP-Proto] CRITICAL: Proto file not found at ${PROTO_PATH}`);
|
|
23
|
+
}
|
|
24
|
+
var packageDefinition = protoLoader.loadSync(PROTO_PATH, {
|
|
25
|
+
keepCase: true,
|
|
26
|
+
longs: String,
|
|
27
|
+
enums: String,
|
|
28
|
+
defaults: true,
|
|
29
|
+
oneofs: true
|
|
30
|
+
});
|
|
31
|
+
var liopProto = grpc2.loadPackageDefinition(packageDefinition);
|
|
32
|
+
var liopV1 = liopProto.liop.v1;
|
|
33
|
+
var isProduction = () => process.env.NODE_ENV === "production";
|
|
34
|
+
function createServerCredentials(tls) {
|
|
35
|
+
if (!tls?.certChain || !tls?.privateKey) {
|
|
36
|
+
log.warn(
|
|
37
|
+
"[LIOP-TLS] No TLS certificates configured \u2014 using insecure server credentials"
|
|
38
|
+
);
|
|
39
|
+
return grpc2.ServerCredentials.createInsecure();
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const rootCert = tls.rootCert ? fs2.readFileSync(tls.rootCert) : null;
|
|
43
|
+
const certChain = fs2.readFileSync(tls.certChain);
|
|
44
|
+
const privateKey = fs2.readFileSync(tls.privateKey);
|
|
45
|
+
return grpc2.ServerCredentials.createSsl(rootCert, [
|
|
46
|
+
{ cert_chain: certChain, private_key: privateKey }
|
|
47
|
+
]);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (isProduction()) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`[LIOP-TLS] FATAL: Server certificate loading failed in production mode. Refusing insecure fallback to prevent MITM/eavesdropping: ${error}`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
log.warn(
|
|
55
|
+
`[LIOP-TLS] Server certificate loading failed, falling back to insecure (dev mode): ${error}`
|
|
56
|
+
);
|
|
57
|
+
return grpc2.ServerCredentials.createInsecure();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function createChannelCredentials(tls) {
|
|
61
|
+
if (!tls?.rootCert) {
|
|
62
|
+
log.warn(
|
|
63
|
+
"[LIOP-TLS] No TLS root certificate configured \u2014 using insecure channel credentials"
|
|
64
|
+
);
|
|
65
|
+
return grpc2.credentials.createInsecure();
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const rootCert = fs2.readFileSync(tls.rootCert);
|
|
69
|
+
const certChain = tls.certChain ? fs2.readFileSync(tls.certChain) : void 0;
|
|
70
|
+
const privateKey = tls.privateKey ? fs2.readFileSync(tls.privateKey) : void 0;
|
|
71
|
+
return grpc2.credentials.createSsl(rootCert, privateKey, certChain);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
if (isProduction()) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`[LIOP-TLS] FATAL: Channel certificate loading failed in production mode. Refusing insecure fallback to prevent MITM/eavesdropping: ${error}`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
log.warn(
|
|
79
|
+
`[LIOP-TLS] Channel certificate loading failed, falling back to insecure (dev mode): ${error}`
|
|
80
|
+
);
|
|
81
|
+
return grpc2.credentials.createInsecure();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { createChannelCredentials, createServerCredentials, liopV1 };
|
|
86
|
+
//# sourceMappingURL=chunk-RDWCGZ2A.js.map
|
|
87
|
+
//# sourceMappingURL=chunk-RDWCGZ2A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/rpc/proto.ts","../src/rpc/tls.ts"],"names":["__filename","__dirname","fs","grpc"],"mappings":"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","file":"chunk-RDWCGZ2A.js","sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport * as grpc from \"@grpc/grpc-js\";\nimport * as protoLoader from \"@grpc/proto-loader\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nimport * as fs from \"node:fs\";\nimport { log } from \"../utils/logger.js\";\n\n// Selection logic: support both flat dist/ and original src/ structure\nconst PROD_PATHS = [\n\tpath.resolve(__dirname, \"./protocol/liop_core.proto\"), // Flat dist/ (tsup)\n\tpath.resolve(__dirname, \"../protocol/liop_core.proto\"), // dist/rpc/ (tsc)\n];\n\nconst DEV_PROTO_PATH = path.resolve(\n\t__dirname,\n\t\"../../../../protocol/proto/liop_core.proto\",\n);\n\n// Selection logic\nconst PROTO_PATH = PROD_PATHS.find((p) => fs.existsSync(p)) || DEV_PROTO_PATH;\n\nif (!fs.existsSync(PROTO_PATH)) {\n\tlog.error(`[LIOP-Proto] CRITICAL: Proto file not found at ${PROTO_PATH}`);\n}\n\n/**\n * LIOP Proto Loader\n * Loads the core gRPC definitions for the Logic-Injection-on-Origin Protocol.\n */\nconst packageDefinition = protoLoader.loadSync(PROTO_PATH, {\n\tkeepCase: true,\n\tlongs: String,\n\tenums: String,\n\tdefaults: true,\n\toneofs: true,\n});\n\n// biome-ignore lint/suspicious/noExplicitAny: gRPC dynamic loading requires any for the service definition map\nexport const liopProto = grpc.loadPackageDefinition(packageDefinition) as any;\nexport const liopV1 = liopProto.liop.v1;\n","/**\n * LIOP TLS Configuration\n *\n * Provides conditional TLS credential factories for gRPC connections.\n * When TLS options are provided, connections are secured with mutual TLS.\n * Otherwise, falls back to insecure credentials (alpha/development mode).\n *\n * Production Hardening (Phase 128):\n * - When NODE_ENV=production and TLS is configured but certificate loading\n * fails, the system throws a fatal error instead of silently degrading\n * to insecure credentials. This prevents MITM/eavesdropping attacks\n * caused by misconfigured certificate paths going unnoticed.\n * - Reference: gRPC-node official docs — \"Using insecure credentials in\n * production poses significant security risks including eavesdropping,\n * MITM attacks, and lack of authentication.\"\n */\n\nimport * as fs from \"node:fs\";\nimport * as grpc from \"@grpc/grpc-js\";\nimport { log } from \"../utils/logger.js\";\n\nexport interface LiopTlsOptions {\n\t/** Path to the root CA certificate (PEM format) */\n\trootCert?: string;\n\t/** Path to the server/client certificate (PEM format) */\n\tcertChain?: string;\n\t/** Path to the private key (PEM format) */\n\tprivateKey?: string;\n}\n\nconst isProduction = () => process.env.NODE_ENV === \"production\";\n\n/**\n * Creates gRPC server credentials from TLS options.\n * In production, refuses to fall back to insecure if TLS loading fails.\n */\nexport function createServerCredentials(\n\ttls?: LiopTlsOptions,\n): grpc.ServerCredentials {\n\tif (!tls?.certChain || !tls?.privateKey) {\n\t\tlog.warn(\n\t\t\t\"[LIOP-TLS] No TLS certificates configured — using insecure server credentials\",\n\t\t);\n\t\treturn grpc.ServerCredentials.createInsecure();\n\t}\n\n\ttry {\n\t\tconst rootCert = tls.rootCert ? fs.readFileSync(tls.rootCert) : null;\n\t\tconst certChain = fs.readFileSync(tls.certChain);\n\t\tconst privateKey = fs.readFileSync(tls.privateKey);\n\n\t\treturn grpc.ServerCredentials.createSsl(rootCert, [\n\t\t\t{ cert_chain: certChain, private_key: privateKey },\n\t\t]);\n\t} catch (error) {\n\t\tif (isProduction()) {\n\t\t\tthrow new Error(\n\t\t\t\t`[LIOP-TLS] FATAL: Server certificate loading failed in production mode. ` +\n\t\t\t\t\t`Refusing insecure fallback to prevent MITM/eavesdropping: ${error}`,\n\t\t\t);\n\t\t}\n\t\tlog.warn(\n\t\t\t`[LIOP-TLS] Server certificate loading failed, falling back to insecure (dev mode): ${error}`,\n\t\t);\n\t\treturn grpc.ServerCredentials.createInsecure();\n\t}\n}\n\n/**\n * Creates gRPC channel credentials from TLS options.\n * In production, refuses to fall back to insecure if TLS loading fails.\n */\nexport function createChannelCredentials(\n\ttls?: LiopTlsOptions,\n): grpc.ChannelCredentials {\n\tif (!tls?.rootCert) {\n\t\tlog.warn(\n\t\t\t\"[LIOP-TLS] No TLS root certificate configured — using insecure channel credentials\",\n\t\t);\n\t\treturn grpc.credentials.createInsecure();\n\t}\n\n\ttry {\n\t\tconst rootCert = fs.readFileSync(tls.rootCert);\n\t\tconst certChain = tls.certChain\n\t\t\t? fs.readFileSync(tls.certChain)\n\t\t\t: undefined;\n\t\tconst privateKey = tls.privateKey\n\t\t\t? fs.readFileSync(tls.privateKey)\n\t\t\t: undefined;\n\n\t\treturn grpc.credentials.createSsl(rootCert, privateKey, certChain);\n\t} catch (error) {\n\t\tif (isProduction()) {\n\t\t\tthrow new Error(\n\t\t\t\t`[LIOP-TLS] FATAL: Channel certificate loading failed in production mode. ` +\n\t\t\t\t\t`Refusing insecure fallback to prevent MITM/eavesdropping: ${error}`,\n\t\t\t);\n\t\t}\n\t\tlog.warn(\n\t\t\t`[LIOP-TLS] Channel certificate loading failed, falling back to insecure (dev mode): ${error}`,\n\t\t);\n\t\treturn grpc.credentials.createInsecure();\n\t}\n}\n"]}
|
package/dist/chunk-RWRRBYG4.js
CHANGED
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export { LiopClient } from './chunk-E5QBDD5E.js';
|
|
2
|
+
import './chunk-32ADSAJS.js';
|
|
3
|
+
import './chunk-OUUTDSOW.js';
|
|
4
|
+
import './chunk-QLCOEP5J.js';
|
|
5
|
+
import './chunk-RDWCGZ2A.js';
|
|
6
|
+
import './chunk-NJRSFFD7.js';
|
|
7
|
+
import './chunk-72MNYFR6.js';
|
|
8
|
+
import './chunk-PZ5AY32C.js';
|
|
9
|
+
//# sourceMappingURL=client.js.map
|
|
2
10
|
//# sourceMappingURL=client.js.map
|
package/dist/gateway.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MeshNode } from './mesh.js';
|
|
2
|
-
import { L as LiopServer } from './index-
|
|
2
|
+
import { L as LiopServer } from './index-BlGc0iym.js';
|
|
3
3
|
import { L as LiopVerifier } from './verifier-COnid_dg.js';
|
|
4
|
-
import { M as McpRequest, A as AuthInfo, b as McpResponse } from './types-
|
|
4
|
+
import { M as McpRequest, A as AuthInfo, b as McpResponse } from './types-sKeUxuky.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'jose';
|
|
7
7
|
|
package/dist/gateway.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export { LiopHybridGateway } from './chunk-PHTWUTY7.js';
|
|
2
|
+
import './chunk-HB5DXX3Q.js';
|
|
3
|
+
import './chunk-32ADSAJS.js';
|
|
4
|
+
import './chunk-OUUTDSOW.js';
|
|
5
|
+
import './chunk-QLCOEP5J.js';
|
|
6
|
+
import './chunk-IJHTRIZC.js';
|
|
7
|
+
import './chunk-RDWCGZ2A.js';
|
|
8
|
+
import './chunk-72MNYFR6.js';
|
|
9
|
+
import './chunk-PZ5AY32C.js';
|
|
10
|
+
//# sourceMappingURL=gateway.js.map
|
|
2
11
|
//# sourceMappingURL=gateway.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { MeshNode } from './mesh.js';
|
|
3
|
-
import { J as JwtValidator, S as ServerInfo, a as CallToolResult, P as Prompt, G as GetPromptRequest, c as GetPromptResult, C as CallToolRequest, T as Tool, R as Resource } from './types-
|
|
3
|
+
import { J as JwtValidator, S as ServerInfo, a as CallToolResult, P as Prompt, G as GetPromptRequest, c as GetPromptResult, C as CallToolRequest, T as Tool, R as Resource } from './types-sKeUxuky.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* LIOP OAuth 2.1 Hybrid Auth — Configuration Types
|
|
@@ -278,6 +278,10 @@ interface LiopServerOptions {
|
|
|
278
278
|
* Must match SCREAMING_SNAKE_CASE: /^[A-Z][A-Z0-9_]*$/ (e.g., "BANK", "VAULT", "HFT_ORACLE").
|
|
279
279
|
*/
|
|
280
280
|
tokenSlug?: string;
|
|
281
|
+
/**
|
|
282
|
+
* Path to a shared JSON file for persistent Query Budget tracking across multiple server instances.
|
|
283
|
+
*/
|
|
284
|
+
budgetStorePath?: string;
|
|
281
285
|
}
|
|
282
286
|
interface AggregationPolicy {
|
|
283
287
|
/** Maximum number of object-type array elements allowed (default: 10) */
|
|
@@ -324,6 +328,10 @@ interface LogicExecutionPolicy {
|
|
|
324
328
|
* Domain-specific sensitive keys that fall under the "sensitive" query budget tier.
|
|
325
329
|
*/
|
|
326
330
|
sensitiveKeys?: string[];
|
|
331
|
+
/**
|
|
332
|
+
* Path to a shared JSON file for persistent Query Budget tracking across multiple server instances.
|
|
333
|
+
*/
|
|
334
|
+
budgetStorePath?: string;
|
|
327
335
|
}
|
|
328
336
|
declare class LiopServer {
|
|
329
337
|
private serverInfo;
|
|
@@ -497,6 +505,19 @@ declare class LiopServer {
|
|
|
497
505
|
private loadRevocationList;
|
|
498
506
|
revokeToken(token: string): void;
|
|
499
507
|
revokeTokenHash(hash: string): void;
|
|
508
|
+
/**
|
|
509
|
+
* Resets the query budget for a specific client identity.
|
|
510
|
+
* If toolName is provided, only that tool's budget is cleared.
|
|
511
|
+
* Otherwise, all tool budgets for the client are reset.
|
|
512
|
+
*
|
|
513
|
+
* Operates on both in-memory and persistent (disk) budget stores.
|
|
514
|
+
* Uses file-level locking for safe concurrent access.
|
|
515
|
+
*/
|
|
516
|
+
resetFieldBudget(clientId: string, toolName?: string): void;
|
|
517
|
+
private getPersistentBudget;
|
|
518
|
+
private savePersistentBudget;
|
|
519
|
+
private executeWithBudgetLock;
|
|
520
|
+
private applyInMemoryBudget;
|
|
500
521
|
}
|
|
501
522
|
|
|
502
523
|
export { AUTH_DEFAULTS as A, LiopServer as L, NerScanner as N, type OAuthClientConfig as O, PII_PATTERNS as P, type ToolHandler as T, type LiopServerOptions as a, type AggregationPolicy as b, type AuthRole as c, type LiopAuthConfig as d, type LogicExecutionPolicy as e, type OutputSanitizerConfig as f, PII_PRESETS as g, type PiiRule as h, PiiScanner as i, sanitizeOutput as s };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { L as LiopVerifier } from './verifier-COnid_dg.js';
|
|
2
2
|
import { MeshNodeConfig } from './mesh.js';
|
|
3
|
-
import { C as CallToolRequest, a as CallToolResult } from './types-
|
|
3
|
+
import { C as CallToolRequest, a as CallToolResult } from './types-sKeUxuky.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* LIOP TLS Configuration
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { LiopBridgeOptions, LiopMcpBridge, LiopStreamBridge, LiopStreamBridgeOptions } from './bridge.js';
|
|
2
|
-
import { L as LiopTlsOptions } from './index-
|
|
3
|
-
export { a as LiopClient } from './index-
|
|
2
|
+
import { L as LiopTlsOptions } from './index-qM8ZH8sC.js';
|
|
3
|
+
export { a as LiopClient } from './index-qM8ZH8sC.js';
|
|
4
4
|
export { LiopHybridGateway } from './gateway.js';
|
|
5
5
|
export { LiopManifest, MeshNode, MeshNodeConfig } from './mesh.js';
|
|
6
6
|
import * as grpc from '@grpc/grpc-js';
|
|
7
|
-
export { A as AUTH_DEFAULTS, b as AggregationPolicy, c as AuthRole, d as LiopAuthConfig, L as LiopServer, a as LiopServerOptions, e as LogicExecutionPolicy, N as NerScanner, O as OAuthClientConfig, f as OutputSanitizerConfig, P as PII_PATTERNS, g as PII_PRESETS, h as PiiRule, i as PiiScanner, T as ToolHandler, s as sanitizeOutput } from './index-
|
|
8
|
-
import { A as AuthInfo } from './types-
|
|
9
|
-
export { C as CallToolRequest, a as CallToolResult, G as GetPromptRequest, c as GetPromptResult, J as JwtValidator, M as McpRequest, b as McpResponse, P as Prompt, d as PromptSchema, R as Resource, e as ResourceSchema, S as ServerInfo, T as Tool, f as ToolSchema } from './types-
|
|
7
|
+
export { A as AUTH_DEFAULTS, b as AggregationPolicy, c as AuthRole, d as LiopAuthConfig, L as LiopServer, a as LiopServerOptions, e as LogicExecutionPolicy, N as NerScanner, O as OAuthClientConfig, f as OutputSanitizerConfig, P as PII_PATTERNS, g as PII_PRESETS, h as PiiRule, i as PiiScanner, T as ToolHandler, s as sanitizeOutput } from './index-BlGc0iym.js';
|
|
8
|
+
import { A as AuthInfo } from './types-sKeUxuky.js';
|
|
9
|
+
export { C as CallToolRequest, a as CallToolResult, G as GetPromptRequest, c as GetPromptResult, J as JwtValidator, M as McpRequest, b as McpResponse, P as Prompt, d as PromptSchema, R as Resource, e as ResourceSchema, S as ServerInfo, T as Tool, f as ToolSchema } from './types-sKeUxuky.js';
|
|
10
10
|
import * as jose from 'jose';
|
|
11
11
|
import Provider from 'oidc-provider';
|
|
12
12
|
import '@modelcontextprotocol/sdk/server/mcp.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,50 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export { WasiSandbox, getDefaultEnvironment } from './chunk-J3WPBMJ5.js';
|
|
2
|
+
export { LiopClient, LiopRpcClient } from './chunk-E5QBDD5E.js';
|
|
3
|
+
export { PromptSchema, ResourceSchema, ToolSchema } from './chunk-MCXMS5ZI.js';
|
|
4
|
+
export { LiopMcpBridge, LiopStreamBridge } from './chunk-IMPCCZ2Y.js';
|
|
5
|
+
export { LiopHybridGateway, buildProtectedResourceMetadata } from './chunk-PHTWUTY7.js';
|
|
6
|
+
export { AUTH_DEFAULTS, JwtValidator, LiopRpcServer, LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner, createOAuthServer, sanitizeOutput } from './chunk-EEYEVHO2.js';
|
|
7
|
+
import './chunk-F5YNYL5L.js';
|
|
8
|
+
export { HeuristicTokenEstimator, LiopOTelBridge, RealTokenEstimator, TokenTelemetryEngine, createSyncTokenEstimator, createTokenEstimator } from './chunk-HB5DXX3Q.js';
|
|
9
|
+
import './chunk-32ADSAJS.js';
|
|
10
|
+
import './chunk-OUUTDSOW.js';
|
|
11
|
+
import './chunk-QLCOEP5J.js';
|
|
12
|
+
export { LIOP_SCOPES, authorizeRequest } from './chunk-IJHTRIZC.js';
|
|
13
|
+
import './chunk-RDWCGZ2A.js';
|
|
14
|
+
export { MeshNode } from './chunk-NJRSFFD7.js';
|
|
15
|
+
import './chunk-72MNYFR6.js';
|
|
16
|
+
import './chunk-PZ5AY32C.js';
|
|
17
|
+
|
|
18
|
+
// src/errors.ts
|
|
19
|
+
var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
20
|
+
ErrorCode2["CapabilityViolation"] = "CapabilityViolation";
|
|
21
|
+
ErrorCode2["SandboxEscape"] = "SandboxEscape";
|
|
22
|
+
ErrorCode2["PiiLeak"] = "PiiLeak";
|
|
23
|
+
ErrorCode2["InvalidIntent"] = "InvalidIntent";
|
|
24
|
+
ErrorCode2["Throttled"] = "Throttled";
|
|
25
|
+
ErrorCode2["ZkVerificationFailed"] = "ZkVerificationFailed";
|
|
26
|
+
ErrorCode2["MeshUnavailable"] = "MeshUnavailable";
|
|
27
|
+
ErrorCode2["ConnectionFailed"] = "ConnectionFailed";
|
|
28
|
+
return ErrorCode2;
|
|
29
|
+
})(ErrorCode || {});
|
|
30
|
+
var LiopError = class extends Error {
|
|
31
|
+
code;
|
|
32
|
+
constructor(code, message) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = "LiopError";
|
|
35
|
+
this.code = code;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/prompts/adapters.ts
|
|
40
|
+
var PROVIDER_CONFIGS = {
|
|
41
|
+
claude: { xmlStandard: true, jsonSchemaPreferred: false },
|
|
42
|
+
openai: { xmlStandard: false, jsonSchemaPreferred: true },
|
|
43
|
+
gemini: { xmlStandard: false, jsonSchemaPreferred: true }
|
|
44
|
+
};
|
|
45
|
+
function generateSystemInstructions(provider) {
|
|
46
|
+
const config = PROVIDER_CONFIGS[provider];
|
|
47
|
+
let instructions = `[LIOP-PROTO-V1: LOGIC-ON-ORIGIN SPECIFICATION]
|
|
2
48
|
You are interacting with a Logic-Injection-on-Origin Protocol (LIOP) Mesh Network.
|
|
3
49
|
Unlike standard MCP where you pull context to evaluate it remotely, in LIOP you WRITE code that executes on the data's origin.
|
|
4
50
|
|
|
@@ -23,7 +69,9 @@ To prevent database reconstruction and inference attacks, numeric query outputs
|
|
|
23
69
|
- Poisoned globals: eval, Function, setTimeout, setInterval, Buffer, ArrayBuffer, and TypedArrays are undefined.
|
|
24
70
|
- Frozen prototypes: Modifications to Object.prototype, Array.prototype, etc., are blocked.
|
|
25
71
|
- K-Anonymity constraints: Small datasets (< 10 records) limit outputs to max 3 scalar keys with NO nesting. Datasets with >= 10 records limit outputs to max 10 fields.
|
|
26
|
-
`;
|
|
72
|
+
`;
|
|
73
|
+
if (config.xmlStandard) {
|
|
74
|
+
instructions += `
|
|
27
75
|
### PAYLOAD FORMATTING (CLAUDE-XML PREFERRED)
|
|
28
76
|
You must wrap your logic precisely within <liop_logic> tags.
|
|
29
77
|
Example:
|
|
@@ -32,7 +80,9 @@ const records = await liop.readResource("liop://vault/patients");
|
|
|
32
80
|
const filtered = records.filter(r => r.disease === "Hypertension");
|
|
33
81
|
return { alert: "High risk demographic", targetCount: filtered.length };
|
|
34
82
|
</liop_logic>
|
|
35
|
-
|
|
83
|
+
`;
|
|
84
|
+
} else if (config.jsonSchemaPreferred) {
|
|
85
|
+
instructions += `
|
|
36
86
|
### PAYLOAD FORMATTING (JSON PARSING PREFERRED)
|
|
37
87
|
You must provide your logic strictly within a JSON string key called \`"logic_blob"\` inside your tool call parameters.
|
|
38
88
|
Example:
|
|
@@ -40,5 +90,11 @@ Example:
|
|
|
40
90
|
"target": "liop://vault/patients",
|
|
41
91
|
"logic_blob": "const records = await liop.readResource(args.target); return { targetCount: records.filter(r => r.disease === 'Hypertension').length };"
|
|
42
92
|
}
|
|
43
|
-
|
|
93
|
+
`;
|
|
94
|
+
}
|
|
95
|
+
return instructions;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { ErrorCode, LiopError, generateSystemInstructions };
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
44
100
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/prompts/adapters.ts"],"names":["ErrorCode","
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/prompts/adapters.ts"],"names":["ErrorCode"],"mappings":";;;;;;;;;;;;;;;;;;AAAO,IAAK,SAAA,qBAAAA,UAAAA,KAAL;AACN,EAAAA,WAAA,qBAAA,CAAA,GAAsB,qBAAA;AACtB,EAAAA,WAAA,eAAA,CAAA,GAAgB,eAAA;AAChB,EAAAA,WAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,WAAA,eAAA,CAAA,GAAgB,eAAA;AAChB,EAAAA,WAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,WAAA,sBAAA,CAAA,GAAuB,sBAAA;AACvB,EAAAA,WAAA,iBAAA,CAAA,GAAkB,iBAAA;AAClB,EAAAA,WAAA,kBAAA,CAAA,GAAmB,kBAAA;AARR,EAAA,OAAAA,UAAAA;AAAA,CAAA,EAAA,SAAA,IAAA,EAAA;AAWL,IAAM,SAAA,GAAN,cAAwB,KAAA,CAAM;AAAA,EACpB,IAAA;AAAA,EAEhB,WAAA,CAAY,MAAiB,OAAA,EAAiB;AAC7C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,WAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACb;AACD;;;ACLA,IAAM,gBAAA,GAAqD;AAAA,EAC1D,MAAA,EAAQ,EAAE,WAAA,EAAa,IAAA,EAAM,qBAAqB,KAAA,EAAM;AAAA,EACxD,MAAA,EAAQ,EAAE,WAAA,EAAa,KAAA,EAAO,qBAAqB,IAAA,EAAK;AAAA,EACxD,MAAA,EAAQ,EAAE,WAAA,EAAa,KAAA,EAAO,qBAAqB,IAAA;AACpD,CAAA;AAMO,SAAS,2BAA2B,QAAA,EAA8B;AACxE,EAAA,MAAM,MAAA,GAAS,iBAAiB,QAAQ,CAAA;AAExC,EAAA,IAAI,YAAA,GAAe,CAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AA2BnB,EAAA,IAAI,OAAO,WAAA,EAAa;AACvB,IAAA,YAAA,IAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA,EAUjB,CAAA,MAAA,IAAW,OAAO,mBAAA,EAAqB;AACtC,IAAA,YAAA,IAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA,EASjB;AAEA,EAAA,OAAO,YAAA;AACR","file":"index.js","sourcesContent":["export enum ErrorCode {\n\tCapabilityViolation = \"CapabilityViolation\",\n\tSandboxEscape = \"SandboxEscape\",\n\tPiiLeak = \"PiiLeak\",\n\tInvalidIntent = \"InvalidIntent\",\n\tThrottled = \"Throttled\",\n\tZkVerificationFailed = \"ZkVerificationFailed\",\n\tMeshUnavailable = \"MeshUnavailable\",\n\tConnectionFailed = \"ConnectionFailed\",\n}\n\nexport class LiopError extends Error {\n\tpublic readonly code: ErrorCode;\n\n\tconstructor(code: ErrorCode, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"LiopError\";\n\t\tthis.code = code;\n\t}\n}\n","/**\n * LIOP Cross-AI Prompt Adapters (Fase 92)\n *\n * Normalizes system instructions for different LLM providers (Claude, OpenAI, Gemini)\n * to ensure they understand how to generate \"Logic-on-Origin\" WASM-compatible payload structures.\n */\n\nexport type AIProvider = \"claude\" | \"openai\" | \"gemini\";\n\nexport interface PromptConfig {\n\txmlStandard: boolean;\n\tjsonSchemaPreferred: boolean;\n}\n\nconst PROVIDER_CONFIGS: Record<AIProvider, PromptConfig> = {\n\tclaude: { xmlStandard: true, jsonSchemaPreferred: false },\n\topenai: { xmlStandard: false, jsonSchemaPreferred: true },\n\tgemini: { xmlStandard: false, jsonSchemaPreferred: true },\n};\n\n/**\n * Generates specific System Prompts optimized for the provided AI.\n * This instructs the LLM on how to bypass Context-Pulling and use Logic-Injection (Zero-Shot).\n */\nexport function generateSystemInstructions(provider: AIProvider): string {\n\tconst config = PROVIDER_CONFIGS[provider];\n\n\tlet instructions = `[LIOP-PROTO-V1: LOGIC-ON-ORIGIN SPECIFICATION]\nYou are interacting with a Logic-Injection-on-Origin Protocol (LIOP) Mesh Network.\nUnlike standard MCP where you pull context to evaluate it remotely, in LIOP you WRITE code that executes on the data's origin.\n\n### CORE PARADIGM\nWhen you call a tool or resource, you MUST provide a payload that represents secure sandboxed logic to be executed on the remote Node.\nThe node will execute your logic securely on the raw secure data, and return only the RESULT, avoiding PII data egress.\n\n### EXECUTION RULES\n1. Provide a self-contained JavaScript syntax block that we will compile to WASM-Sandboxed logic.\n2. Rely only on standard ECMA script features (No Node.js polyfills).\n3. The logic must end by returning the calculated insights, not the raw data.\n\n### DIFFERENTIAL PRIVACY (DP) MECHANISM (Laplace Mechanism)\nTo prevent database reconstruction and inference attacks, numeric query outputs are processed by a Laplace DP engine:\n- COUNT / LENGTH queries: To get EXACT integer values without noise, you MUST name return keys containing 'count', 'length', 'size', 'num', 'positive', 'negative', or starting with 'total_' or 'num_' (e.g. 'total_tx', 'credits_count'). This forces sensitivity=1.0, rounds values, and clamps to non-negative values.\n- AVERAGE queries: Return keys containing 'avg', 'mean', or 'average' scale down noise automatically by dividing global sensitivity by the dataset size (sensitivity / n).\n- SUM / OTHER queries: Return keys without these semantic names receive full Laplace noise based on the global node sensitivity (which can be up to 100,000 in Bank nodes to protect raw balances). Do NOT attempt to bypass this by renaming sum fields to count fields, as it violates protocol integrity.\n\n### SANDBOX RUNTIME RESTRICTIONS & WORKAROUNDS\n- Date is poisoned: The 'Date' class/constructor is undefined (calling 'new Date()', 'Date.now()', or 'Date.parse()' will crash the execution).\n - Workaround: Perform chronological sorting and comparisons lexicographically on ISO 8601 string dates (e.g. record.date >= '2024-01-01').\n- Poisoned globals: eval, Function, setTimeout, setInterval, Buffer, ArrayBuffer, and TypedArrays are undefined.\n- Frozen prototypes: Modifications to Object.prototype, Array.prototype, etc., are blocked.\n- K-Anonymity constraints: Small datasets (< 10 records) limit outputs to max 3 scalar keys with NO nesting. Datasets with >= 10 records limit outputs to max 10 fields.\n`;\n\n\tif (config.xmlStandard) {\n\t\tinstructions += `\n### PAYLOAD FORMATTING (CLAUDE-XML PREFERRED)\nYou must wrap your logic precisely within <liop_logic> tags.\nExample:\n<liop_logic>\nconst records = await liop.readResource(\"liop://vault/patients\");\nconst filtered = records.filter(r => r.disease === \"Hypertension\");\nreturn { alert: \"High risk demographic\", targetCount: filtered.length };\n</liop_logic>\n`;\n\t} else if (config.jsonSchemaPreferred) {\n\t\tinstructions += `\n### PAYLOAD FORMATTING (JSON PARSING PREFERRED)\nYou must provide your logic strictly within a JSON string key called \\`\"logic_blob\"\\` inside your tool call parameters.\nExample:\n{\n \"target\": \"liop://vault/patients\",\n \"logic_blob\": \"const records = await liop.readResource(args.target); return { targetCount: records.filter(r => r.disease === 'Hypertension').length };\"\n}\n`;\n\t}\n\n\treturn instructions;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"kyber-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"kyber-FCVPX6CE.js"}
|
package/dist/mesh.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import'./chunk-RWRRBYG4.js';
|
|
1
|
+
import './chunk-RWRRBYG4.js';
|
|
2
|
+
export { MeshNode } from './chunk-NJRSFFD7.js';
|
|
3
|
+
import './chunk-72MNYFR6.js';
|
|
4
|
+
import './chunk-PZ5AY32C.js';
|
|
5
|
+
//# sourceMappingURL=mesh.js.map
|
|
2
6
|
//# sourceMappingURL=mesh.js.map
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { b as AggregationPolicy, L as LiopServer, a as LiopServerOptions, e as LogicExecutionPolicy, N as NerScanner, f as OutputSanitizerConfig, P as PII_PATTERNS, g as PII_PRESETS, h as PiiRule, i as PiiScanner, T as ToolHandler, s as sanitizeOutput } from './index-
|
|
1
|
+
export { b as AggregationPolicy, L as LiopServer, a as LiopServerOptions, e as LogicExecutionPolicy, N as NerScanner, f as OutputSanitizerConfig, P as PII_PATTERNS, g as PII_PRESETS, h as PiiRule, i as PiiScanner, T as ToolHandler, s as sanitizeOutput } from './index-BlGc0iym.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import './mesh.js';
|
|
4
|
-
import './types-
|
|
4
|
+
import './types-sKeUxuky.js';
|
|
5
5
|
import 'jose';
|
package/dist/server.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export { LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner, sanitizeOutput } from './chunk-EEYEVHO2.js';
|
|
2
|
+
import './chunk-F5YNYL5L.js';
|
|
3
|
+
import './chunk-IJHTRIZC.js';
|
|
4
|
+
import './chunk-RDWCGZ2A.js';
|
|
5
|
+
import './chunk-NJRSFFD7.js';
|
|
6
|
+
import './chunk-72MNYFR6.js';
|
|
7
|
+
import './chunk-PZ5AY32C.js';
|
|
8
|
+
//# sourceMappingURL=server.js.map
|
|
2
9
|
//# sourceMappingURL=server.js.map
|
|
@@ -87,32 +87,14 @@ declare const ToolSchema: z.ZodObject<{
|
|
|
87
87
|
name: z.ZodString;
|
|
88
88
|
description: z.ZodOptional<z.ZodString>;
|
|
89
89
|
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
90
|
-
},
|
|
91
|
-
name: string;
|
|
92
|
-
inputSchema: Record<string, unknown>;
|
|
93
|
-
description?: string | undefined;
|
|
94
|
-
}, {
|
|
95
|
-
name: string;
|
|
96
|
-
inputSchema: Record<string, unknown>;
|
|
97
|
-
description?: string | undefined;
|
|
98
|
-
}>;
|
|
90
|
+
}, z.core.$strip>;
|
|
99
91
|
type Tool = z.infer<typeof ToolSchema>;
|
|
100
92
|
declare const ResourceSchema: z.ZodObject<{
|
|
101
93
|
uri: z.ZodString;
|
|
102
94
|
name: z.ZodString;
|
|
103
95
|
description: z.ZodOptional<z.ZodString>;
|
|
104
96
|
mimeType: z.ZodOptional<z.ZodString>;
|
|
105
|
-
},
|
|
106
|
-
name: string;
|
|
107
|
-
uri: string;
|
|
108
|
-
description?: string | undefined;
|
|
109
|
-
mimeType?: string | undefined;
|
|
110
|
-
}, {
|
|
111
|
-
name: string;
|
|
112
|
-
uri: string;
|
|
113
|
-
description?: string | undefined;
|
|
114
|
-
mimeType?: string | undefined;
|
|
115
|
-
}>;
|
|
97
|
+
}, z.core.$strip>;
|
|
116
98
|
type Resource = z.infer<typeof ResourceSchema>;
|
|
117
99
|
declare const PromptSchema: z.ZodObject<{
|
|
118
100
|
name: z.ZodString;
|
|
@@ -121,32 +103,8 @@ declare const PromptSchema: z.ZodObject<{
|
|
|
121
103
|
name: z.ZodString;
|
|
122
104
|
description: z.ZodOptional<z.ZodString>;
|
|
123
105
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
description?: string | undefined;
|
|
127
|
-
required?: boolean | undefined;
|
|
128
|
-
}, {
|
|
129
|
-
name: string;
|
|
130
|
-
description?: string | undefined;
|
|
131
|
-
required?: boolean | undefined;
|
|
132
|
-
}>, "many">>;
|
|
133
|
-
}, "strip", z.ZodTypeAny, {
|
|
134
|
-
name: string;
|
|
135
|
-
description?: string | undefined;
|
|
136
|
-
arguments?: {
|
|
137
|
-
name: string;
|
|
138
|
-
description?: string | undefined;
|
|
139
|
-
required?: boolean | undefined;
|
|
140
|
-
}[] | undefined;
|
|
141
|
-
}, {
|
|
142
|
-
name: string;
|
|
143
|
-
description?: string | undefined;
|
|
144
|
-
arguments?: {
|
|
145
|
-
name: string;
|
|
146
|
-
description?: string | undefined;
|
|
147
|
-
required?: boolean | undefined;
|
|
148
|
-
}[] | undefined;
|
|
149
|
-
}>;
|
|
106
|
+
}, z.core.$strip>>>;
|
|
107
|
+
}, z.core.$strip>;
|
|
150
108
|
type Prompt = z.infer<typeof PromptSchema>;
|
|
151
109
|
interface CallToolRequest {
|
|
152
110
|
name: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'zod';
|
|
2
|
-
export { A as AuthInfo, C as CallToolRequest, a as CallToolResult, G as GetPromptRequest, c as GetPromptResult, M as McpRequest, b as McpResponse, P as Prompt, d as PromptSchema, R as Resource, e as ResourceSchema, S as ServerInfo, T as Tool, f as ToolSchema } from './types-
|
|
2
|
+
export { A as AuthInfo, C as CallToolRequest, a as CallToolResult, G as GetPromptRequest, c as GetPromptResult, M as McpRequest, b as McpResponse, P as Prompt, d as PromptSchema, R as Resource, e as ResourceSchema, S as ServerInfo, T as Tool, f as ToolSchema } from './types-sKeUxuky.js';
|
|
3
3
|
import 'jose';
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export { PromptSchema, ResourceSchema, ToolSchema } from './chunk-MCXMS5ZI.js';
|
|
2
|
+
import './chunk-F5YNYL5L.js';
|
|
3
|
+
import './chunk-PZ5AY32C.js';
|
|
4
|
+
//# sourceMappingURL=types.js.map
|
|
2
5
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"verifier-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"verifier-GCZDNZK7.js"}
|