@nekzus/liop 2.1.0 → 2.3.0

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.
Files changed (100) hide show
  1. package/LICENSE +201 -21
  2. package/NOTICE +5 -0
  3. package/README.md +73 -5
  4. package/dist/bin/agent.js +303 -4
  5. package/dist/bin/agent.js.map +1 -1
  6. package/dist/bridge.d.ts +2 -2
  7. package/dist/bridge.js +4 -1
  8. package/dist/chunk-32ADSAJS.js +104 -0
  9. package/dist/chunk-32ADSAJS.js.map +1 -0
  10. package/dist/chunk-4LQPDN3W.js +556 -0
  11. package/dist/chunk-4LQPDN3W.js.map +1 -0
  12. package/dist/chunk-72MNYFR6.js +64 -0
  13. package/dist/chunk-72MNYFR6.js.map +1 -0
  14. package/dist/chunk-74CISO2I.js +853 -0
  15. package/dist/chunk-74CISO2I.js.map +1 -0
  16. package/dist/chunk-CRZBVFDV.js +616 -0
  17. package/dist/chunk-CRZBVFDV.js.map +1 -0
  18. package/dist/chunk-GKV6M2PQ.js +208106 -0
  19. package/dist/chunk-GKV6M2PQ.js.map +1 -0
  20. package/dist/chunk-JIJPZFR2.js +51 -0
  21. package/dist/chunk-JIJPZFR2.js.map +1 -0
  22. package/dist/chunk-OIMJZ64E.js +441 -0
  23. package/dist/chunk-OIMJZ64E.js.map +1 -0
  24. package/dist/chunk-OUUTDSOW.js +24 -0
  25. package/dist/chunk-OUUTDSOW.js.map +1 -0
  26. package/dist/chunk-PYKRQAER.js +77 -0
  27. package/dist/chunk-PYKRQAER.js.map +1 -0
  28. package/dist/chunk-QLCOEP5J.js +68 -0
  29. package/dist/chunk-QLCOEP5J.js.map +1 -0
  30. package/dist/chunk-RWRRBYG4.js +1 -0
  31. package/dist/chunk-SONUORBT.js +421 -0
  32. package/dist/chunk-SONUORBT.js.map +1 -0
  33. package/dist/chunk-UBOQZVV5.js +3508 -0
  34. package/dist/chunk-UBOQZVV5.js.map +1 -0
  35. package/dist/chunk-UCJEK75U.js +714 -0
  36. package/dist/chunk-UCJEK75U.js.map +1 -0
  37. package/dist/chunk-WSW6YJNY.js +168 -0
  38. package/dist/chunk-WSW6YJNY.js.map +1 -0
  39. package/dist/client.d.ts +3 -2
  40. package/dist/client.js +9 -1
  41. package/dist/gateway.d.ts +5 -110
  42. package/dist/gateway.js +10 -1
  43. package/dist/hybrid-CF__0YnC.d.ts +170 -0
  44. package/dist/{index-DO97j6hP.d.ts → index-BW95kAL4.d.ts} +72 -2
  45. package/dist/index-cMV0_yD9.d.ts +200 -0
  46. package/dist/index.d.ts +273 -18
  47. package/dist/index.js +311 -4
  48. package/dist/index.js.map +1 -1
  49. package/dist/kyber-3ULIJSE3.js +3 -0
  50. package/dist/{kyber-NONMBQNH.js.map → kyber-3ULIJSE3.js.map} +1 -1
  51. package/dist/mesh.d.ts +14 -0
  52. package/dist/mesh.js +4 -1
  53. package/dist/server.d.ts +2 -2
  54. package/dist/server.js +7 -1
  55. package/dist/{types-DzEXgi4s.d.ts → types-lJIxBlWF.d.ts} +75 -47
  56. package/dist/types.d.ts +1 -1
  57. package/dist/types.js +2 -1
  58. package/dist/verifier-3FAKCFNN.js +5 -0
  59. package/dist/{verifier-XU2DB56Z.js.map → verifier-3FAKCFNN.js.map} +1 -1
  60. package/dist/workers/logic-execution.d.ts +1 -0
  61. package/dist/workers/logic-execution.js +271 -1
  62. package/dist/workers/logic-execution.js.map +1 -1
  63. package/dist/workers/zk-verifier.js +173 -1
  64. package/dist/workers/zk-verifier.js.map +1 -1
  65. package/package.json +98 -49
  66. package/dist/chunk-2MGFSIXN.js +0 -2
  67. package/dist/chunk-2MGFSIXN.js.map +0 -1
  68. package/dist/chunk-4C666HHU.js +0 -2
  69. package/dist/chunk-4C666HHU.js.map +0 -1
  70. package/dist/chunk-ANFXJGMP.js +0 -2
  71. package/dist/chunk-ANFXJGMP.js.map +0 -1
  72. package/dist/chunk-DBXGYHKY.js +0 -2
  73. package/dist/chunk-DBXGYHKY.js.map +0 -1
  74. package/dist/chunk-DQ6UW6L7.js +0 -2
  75. package/dist/chunk-DQ6UW6L7.js.map +0 -1
  76. package/dist/chunk-GI2LSJYZ.js +0 -13
  77. package/dist/chunk-GI2LSJYZ.js.map +0 -1
  78. package/dist/chunk-GJUZGKZW.js +0 -3
  79. package/dist/chunk-GJUZGKZW.js.map +0 -1
  80. package/dist/chunk-I46YEWND.js +0 -33
  81. package/dist/chunk-I46YEWND.js.map +0 -1
  82. package/dist/chunk-PWCXZWSE.js +0 -2
  83. package/dist/chunk-PWCXZWSE.js.map +0 -1
  84. package/dist/chunk-RYYRR4N5.js +0 -31
  85. package/dist/chunk-RYYRR4N5.js.map +0 -1
  86. package/dist/chunk-S6RJHZV2.js +0 -2
  87. package/dist/chunk-S6RJHZV2.js.map +0 -1
  88. package/dist/chunk-SB5XJXKV.js +0 -2
  89. package/dist/chunk-SB5XJXKV.js.map +0 -1
  90. package/dist/chunk-T3L6OCM3.js +0 -3
  91. package/dist/chunk-T3L6OCM3.js.map +0 -1
  92. package/dist/chunk-TYVG6TXQ.js +0 -2
  93. package/dist/chunk-TYVG6TXQ.js.map +0 -1
  94. package/dist/chunk-UCCGDGHE.js +0 -54
  95. package/dist/chunk-UCCGDGHE.js.map +0 -1
  96. package/dist/chunk-V5MKJT6S.js +0 -2
  97. package/dist/chunk-V5MKJT6S.js.map +0 -1
  98. package/dist/index-Brfvxmdt.d.ts +0 -101
  99. package/dist/kyber-NONMBQNH.js +0 -2
  100. package/dist/verifier-XU2DB56Z.js +0 -2
package/dist/index.js CHANGED
@@ -1,4 +1,140 @@
1
- export{c as WasiSandbox,b as getDefaultEnvironment}from'./chunk-RYYRR4N5.js';export{b as LiopClient,a as LiopRpcClient}from'./chunk-T3L6OCM3.js';export{c as PromptSchema,b as ResourceSchema,a as ToolSchema}from'./chunk-TYVG6TXQ.js';export{b as LiopMcpBridge,a as LiopStreamBridge}from'./chunk-GJUZGKZW.js';export{b as LiopHybridGateway,a as buildProtectedResourceMetadata}from'./chunk-GI2LSJYZ.js';export{b as AUTH_DEFAULTS,c as JwtValidator,a as LiopRpcServer,j as LiopServer,e as NerScanner,g as PII_PATTERNS,h as PII_PRESETS,i as PiiScanner,d as createOAuthServer,f as sanitizeOutput}from'./chunk-UCCGDGHE.js';import'./chunk-2MGFSIXN.js';export{b as HeuristicTokenEstimator,e as LiopOTelBridge,a as RealTokenEstimator,f as TokenTelemetryEngine,d as createSyncTokenEstimator,c as createTokenEstimator}from'./chunk-I46YEWND.js';import'./chunk-PWCXZWSE.js';import'./chunk-ANFXJGMP.js';import'./chunk-DBXGYHKY.js';export{b as LIOP_SCOPES,a as authorizeRequest}from'./chunk-SB5XJXKV.js';import'./chunk-V5MKJT6S.js';export{a as MeshNode}from'./chunk-DQ6UW6L7.js';import'./chunk-S6RJHZV2.js';import'./chunk-4C666HHU.js';var h=(e=>(e.CapabilityViolation="CapabilityViolation",e.SandboxEscape="SandboxEscape",e.PiiLeak="PiiLeak",e.InvalidIntent="InvalidIntent",e.Throttled="Throttled",e.ZkVerificationFailed="ZkVerificationFailed",e.MeshUnavailable="MeshUnavailable",e.ConnectionFailed="ConnectionFailed",e))(h||{}),n=class extends Error{code;constructor(o,t){super(t),this.name="LiopError",this.code=o;}};var x={claude:{xmlStandard:true,jsonSchemaPreferred:false},openai:{xmlStandard:false,jsonSchemaPreferred:true},gemini:{xmlStandard:false,jsonSchemaPreferred:true}};function W(i){let o=x[i],t=`[LIOP-PROTO-V1: LOGIC-ON-ORIGIN SPECIFICATION]
1
+ export { WasiSandbox, calculateAstInstructionFuel, getDefaultEnvironment } from './chunk-SONUORBT.js';
2
+ export { LiopClient, LiopRpcClient } from './chunk-CRZBVFDV.js';
3
+ export { LiopMcpBridge, LiopStreamBridge } from './chunk-4LQPDN3W.js';
4
+ export { GRPC_WEB_CONSTANTS, InMemoryRateLimiter, LiopHybridGateway, buildProtectedResourceMetadata, decodeFrames, dispatchGrpcWebRequest, encodeDataFrame, encodeTrailerFrame, isGrpcWebRequest } from './chunk-UCJEK75U.js';
5
+ export { AUTH_DEFAULTS, AuditLogger, GENESIS_HASH, JwtValidator, LiopRpcServer, LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner, computeEntryHash, createOAuthServer, globalAuditLogger } from './chunk-UBOQZVV5.js';
6
+ export { sanitizeOutput } from './chunk-JIJPZFR2.js';
7
+ export { HeuristicTokenEstimator, LiopMcpRouter, LiopOTelBridge, RealTokenEstimator, TokenTelemetryEngine, createSyncTokenEstimator, createTokenEstimator } from './chunk-GKV6M2PQ.js';
8
+ import './chunk-32ADSAJS.js';
9
+ import './chunk-OUUTDSOW.js';
10
+ export { Kyber768Wrapper } from './chunk-QLCOEP5J.js';
11
+ export { Counter, DILITHIUM65_CONSTANTS, Dilithium65Wrapper, Gauge, Histogram, LIOP_SCOPES, MetricsRegistry, authorizeRequest, egressBlocksTotal, fuelConsumed, manifestCacheSize, meshPeersConnected, protocolMetrics, toolCallsTotal, zkVerificationDurationMs } from './chunk-OIMJZ64E.js';
12
+ export { GRPC_CHANNEL_OPTIONS } from './chunk-WSW6YJNY.js';
13
+ export { MCP_LEGACY_SUPPORT_ENABLED, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_LEGACY, PromptSchema, ResourceSchema, ToolSchema } from './chunk-PYKRQAER.js';
14
+ export { MeshNode } from './chunk-74CISO2I.js';
15
+ import { log } from './chunk-72MNYFR6.js';
16
+ import * as crypto from 'crypto';
17
+ import { EventEmitter } from 'events';
18
+ import * as fs from 'fs';
19
+
20
+ // src/errors.ts
21
+ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
22
+ ErrorCode2["CapabilityViolation"] = "CapabilityViolation";
23
+ ErrorCode2["SandboxEscape"] = "SandboxEscape";
24
+ ErrorCode2["PiiLeak"] = "PiiLeak";
25
+ ErrorCode2["InvalidIntent"] = "InvalidIntent";
26
+ ErrorCode2["Throttled"] = "Throttled";
27
+ ErrorCode2["ZkVerificationFailed"] = "ZkVerificationFailed";
28
+ ErrorCode2["MeshUnavailable"] = "MeshUnavailable";
29
+ ErrorCode2["ConnectionFailed"] = "ConnectionFailed";
30
+ return ErrorCode2;
31
+ })(ErrorCode || {});
32
+ var LiopError = class extends Error {
33
+ code;
34
+ constructor(code, message) {
35
+ super(message);
36
+ this.name = "LiopError";
37
+ this.code = code;
38
+ }
39
+ };
40
+ var TRACEPARENT_REGEX = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/;
41
+ var LiopTracer = class _LiopTracer {
42
+ static generateTraceId() {
43
+ let id;
44
+ do {
45
+ id = crypto.randomBytes(16).toString("hex");
46
+ } while (id === "0".repeat(32));
47
+ return id;
48
+ }
49
+ static generateSpanId() {
50
+ let id;
51
+ do {
52
+ id = crypto.randomBytes(8).toString("hex");
53
+ } while (id === "0".repeat(16));
54
+ return id;
55
+ }
56
+ static formatTraceparent(traceId, spanId, sampled = true) {
57
+ const flags = sampled ? "01" : "00";
58
+ return `00-${traceId}-${spanId}-${flags}`;
59
+ }
60
+ static parseTraceparent(header) {
61
+ if (!header || typeof header !== "string") {
62
+ return null;
63
+ }
64
+ const trimmed = header.trim();
65
+ const match = TRACEPARENT_REGEX.exec(trimmed);
66
+ if (!match) {
67
+ return null;
68
+ }
69
+ const [, version, traceId, spanId, flags] = match;
70
+ if (version === "00") {
71
+ if (traceId === "0".repeat(32) || spanId === "0".repeat(16)) {
72
+ return null;
73
+ }
74
+ }
75
+ const sampled = (Number.parseInt(flags, 16) & 1) === 1;
76
+ return {
77
+ traceId,
78
+ spanId,
79
+ sampled
80
+ };
81
+ }
82
+ static injectTraceparent(carrier, context) {
83
+ carrier.traceparent = _LiopTracer.formatTraceparent(
84
+ context.traceId,
85
+ context.spanId,
86
+ context.sampled
87
+ );
88
+ }
89
+ static extractTraceparent(carrier) {
90
+ const val = carrier.traceparent || carrier.Traceparent;
91
+ if (Array.isArray(val)) {
92
+ return _LiopTracer.parseTraceparent(val[0]);
93
+ }
94
+ return _LiopTracer.parseTraceparent(val);
95
+ }
96
+ startSpan(name, parent, attributes = {}) {
97
+ const traceId = parent?.traceId || _LiopTracer.generateTraceId();
98
+ const spanId = _LiopTracer.generateSpanId();
99
+ const sampled = parent ? parent.sampled : true;
100
+ const context = {
101
+ traceId,
102
+ spanId,
103
+ sampled
104
+ };
105
+ const span = {
106
+ name,
107
+ context,
108
+ startTime: Date.now(),
109
+ attributes: { ...attributes },
110
+ status: "OK",
111
+ setAttribute(key, value) {
112
+ this.attributes[key] = value;
113
+ return this;
114
+ },
115
+ recordException(err) {
116
+ this.status = "ERROR";
117
+ this.error = typeof err === "string" ? err : err.message;
118
+ return this;
119
+ },
120
+ end() {
121
+ this.endTime = Date.now();
122
+ }
123
+ };
124
+ return span;
125
+ }
126
+ };
127
+ var defaultTracer = new LiopTracer();
128
+
129
+ // src/prompts/adapters.ts
130
+ var PROVIDER_CONFIGS = {
131
+ claude: { xmlStandard: true, jsonSchemaPreferred: false },
132
+ openai: { xmlStandard: false, jsonSchemaPreferred: true },
133
+ gemini: { xmlStandard: false, jsonSchemaPreferred: true }
134
+ };
135
+ function generateSystemInstructions(provider) {
136
+ const config = PROVIDER_CONFIGS[provider];
137
+ let instructions = `[LIOP-PROTO-V1: LOGIC-ON-ORIGIN SPECIFICATION]
2
138
  You are interacting with a Logic-Injection-on-Origin Protocol (LIOP) Mesh Network.
3
139
  Unlike standard MCP where you pull context to evaluate it remotely, in LIOP you WRITE code that executes on the data's origin.
4
140
 
@@ -23,7 +159,9 @@ To prevent database reconstruction and inference attacks, numeric query outputs
23
159
  - Poisoned globals: eval, Function, setTimeout, setInterval, Buffer, ArrayBuffer, and TypedArrays are undefined.
24
160
  - Frozen prototypes: Modifications to Object.prototype, Array.prototype, etc., are blocked.
25
161
  - 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
- `;return o.xmlStandard?t+=`
162
+ `;
163
+ if (config.xmlStandard) {
164
+ instructions += `
27
165
  ### PAYLOAD FORMATTING (CLAUDE-XML PREFERRED)
28
166
  You must wrap your logic precisely within <liop_logic> tags.
29
167
  Example:
@@ -32,7 +170,9 @@ const records = await liop.readResource("liop://vault/patients");
32
170
  const filtered = records.filter(r => r.disease === "Hypertension");
33
171
  return { alert: "High risk demographic", targetCount: filtered.length };
34
172
  </liop_logic>
35
- `:o.jsonSchemaPreferred&&(t+=`
173
+ `;
174
+ } else if (config.jsonSchemaPreferred) {
175
+ instructions += `
36
176
  ### PAYLOAD FORMATTING (JSON PARSING PREFERRED)
37
177
  You must provide your logic strictly within a JSON string key called \`"logic_blob"\` inside your tool call parameters.
38
178
  Example:
@@ -40,5 +180,172 @@ Example:
40
180
  "target": "liop://vault/patients",
41
181
  "logic_blob": "const records = await liop.readResource(args.target); return { targetCount: records.filter(r => r.disease === 'Hypertension').length };"
42
182
  }
43
- `),t}export{h as ErrorCode,n as LiopError,W as generateSystemInstructions};//# sourceMappingURL=index.js.map
183
+ `;
184
+ }
185
+ return instructions;
186
+ }
187
+ var CertManager = class extends EventEmitter {
188
+ constructor(options) {
189
+ super();
190
+ this.options = options;
191
+ this.warningDays = options.warningDays ?? 30;
192
+ this.debounceMs = options.debounceMs ?? 150;
193
+ this.loadCertificates();
194
+ if (options.watchFiles !== false) {
195
+ this.setupWatchers();
196
+ }
197
+ }
198
+ rootCertBuffer = null;
199
+ certChainBuffer = null;
200
+ privateKeyBuffer = null;
201
+ watchers = [];
202
+ reloadDebounceTimer = null;
203
+ warningDays;
204
+ debounceMs;
205
+ /**
206
+ * Synchronously loads or reloads certificates from filesystem into memory.
207
+ */
208
+ loadCertificates() {
209
+ try {
210
+ if (this.options.rootCertPath && fs.existsSync(this.options.rootCertPath)) {
211
+ this.rootCertBuffer = fs.readFileSync(this.options.rootCertPath);
212
+ }
213
+ if (!fs.existsSync(this.options.certChainPath)) {
214
+ throw new Error(
215
+ `Certificate chain file not found: ${this.options.certChainPath}`
216
+ );
217
+ }
218
+ if (!fs.existsSync(this.options.privateKeyPath)) {
219
+ throw new Error(
220
+ `Private key file not found: ${this.options.privateKeyPath}`
221
+ );
222
+ }
223
+ this.certChainBuffer = fs.readFileSync(this.options.certChainPath);
224
+ this.privateKeyBuffer = fs.readFileSync(this.options.privateKeyPath);
225
+ log.info("[CertManager] Certificates loaded successfully.");
226
+ } catch (error) {
227
+ log.error(`[CertManager] Failed to load certificates: ${error}`);
228
+ throw error;
229
+ }
230
+ }
231
+ /**
232
+ * Inspects the loaded server/client certificate chain using Node.js native X509Certificate.
233
+ */
234
+ inspectCertificate() {
235
+ if (!this.certChainBuffer) {
236
+ throw new Error("[CertManager] No certificate loaded to inspect.");
237
+ }
238
+ const x509 = new crypto.X509Certificate(this.certChainBuffer);
239
+ const validToDate = new Date(x509.validTo);
240
+ const now = /* @__PURE__ */ new Date();
241
+ const msRemaining = validToDate.getTime() - now.getTime();
242
+ const daysRemaining = Math.max(
243
+ 0,
244
+ Math.floor(msRemaining / (1e3 * 60 * 60 * 24))
245
+ );
246
+ const isExpired = msRemaining <= 0;
247
+ const isExpiringSoon = daysRemaining <= this.warningDays;
248
+ return {
249
+ subject: x509.subject,
250
+ issuer: x509.issuer,
251
+ validFrom: x509.validFrom,
252
+ validTo: x509.validTo,
253
+ fingerprint256: x509.fingerprint256,
254
+ daysRemaining,
255
+ isExpired,
256
+ isExpiringSoon
257
+ };
258
+ }
259
+ /**
260
+ * Sets up non-blocking filesystem watchers to detect certificate renewals
261
+ * and trigger hot-reloading without process restarts.
262
+ */
263
+ setupWatchers() {
264
+ const filesToWatch = [
265
+ this.options.certChainPath,
266
+ this.options.privateKeyPath,
267
+ this.options.rootCertPath
268
+ ].filter((p) => Boolean(p && fs.existsSync(p)));
269
+ for (const filePath of filesToWatch) {
270
+ try {
271
+ const watcher = fs.watch(filePath, () => {
272
+ this.scheduleReload();
273
+ });
274
+ this.watchers.push(watcher);
275
+ } catch (err) {
276
+ log.warn(
277
+ `[CertManager] Could not watch ${filePath} for hot reloading: ${err}`
278
+ );
279
+ }
280
+ }
281
+ }
282
+ /**
283
+ * Debounces reload events to ensure files have finished writing.
284
+ */
285
+ scheduleReload() {
286
+ if (this.reloadDebounceTimer) {
287
+ clearTimeout(this.reloadDebounceTimer);
288
+ }
289
+ this.reloadDebounceTimer = setTimeout(() => {
290
+ try {
291
+ this.loadCertificates();
292
+ const certInfo = this.inspectCertificate();
293
+ log.info(
294
+ `[CertManager] Hot reload complete. Certificate expires in ${certInfo.daysRemaining} days.`
295
+ );
296
+ this.emit("reload", certInfo);
297
+ } catch (error) {
298
+ log.error(`[CertManager] Hot reload failed: ${error}`);
299
+ this.emit("error", error);
300
+ }
301
+ }, this.debounceMs);
302
+ }
303
+ /**
304
+ * Manually triggers a reload of certificates and emits the 'reload' event.
305
+ */
306
+ reload() {
307
+ this.loadCertificates();
308
+ const certInfo = this.inspectCertificate();
309
+ log.info(
310
+ `[CertManager] Hot reload complete. Certificate expires in ${certInfo.daysRemaining} days.`
311
+ );
312
+ this.emit("reload", certInfo);
313
+ return certInfo;
314
+ }
315
+ getRootCert() {
316
+ return this.rootCertBuffer;
317
+ }
318
+ getCertChain() {
319
+ if (!this.certChainBuffer) {
320
+ throw new Error("[CertManager] Certificate chain not loaded.");
321
+ }
322
+ return this.certChainBuffer;
323
+ }
324
+ getPrivateKey() {
325
+ if (!this.privateKeyBuffer) {
326
+ throw new Error("[CertManager] Private key not loaded.");
327
+ }
328
+ return this.privateKeyBuffer;
329
+ }
330
+ /**
331
+ * Stops all active file watchers and releases resources.
332
+ */
333
+ dispose() {
334
+ if (this.reloadDebounceTimer) {
335
+ clearTimeout(this.reloadDebounceTimer);
336
+ this.reloadDebounceTimer = null;
337
+ }
338
+ for (const watcher of this.watchers) {
339
+ try {
340
+ watcher.close();
341
+ } catch {
342
+ }
343
+ }
344
+ this.watchers = [];
345
+ this.removeAllListeners();
346
+ }
347
+ };
348
+
349
+ export { CertManager, ErrorCode, LiopError, LiopTracer, defaultTracer, generateSystemInstructions };
350
+ //# sourceMappingURL=index.js.map
44
351
  //# 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","LiopError","code","message","PROVIDER_CONFIGS","generateSystemInstructions","provider","config","instructions"],"mappings":"4lCAAO,IAAKA,OACXA,CAAAA,CAAA,mBAAA,CAAsB,qBAAA,CACtBA,CAAAA,CAAA,cAAgB,eAAA,CAChBA,CAAAA,CAAA,OAAA,CAAU,SAAA,CACVA,EAAA,aAAA,CAAgB,eAAA,CAChBA,EAAA,SAAA,CAAY,WAAA,CACZA,EAAA,oBAAA,CAAuB,sBAAA,CACvBA,CAAAA,CAAA,eAAA,CAAkB,kBAClBA,CAAAA,CAAA,gBAAA,CAAmB,kBAAA,CARRA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,IAWCC,CAAAA,CAAN,cAAwB,KAAM,CACpB,KAEhB,WAAA,CAAYC,CAAAA,CAAiBC,EAAiB,CAC7C,KAAA,CAAMA,CAAO,CAAA,CACb,IAAA,CAAK,IAAA,CAAO,WAAA,CACZ,KAAK,IAAA,CAAOD,EACb,CACD,ECLA,IAAME,CAAAA,CAAqD,CAC1D,MAAA,CAAQ,CAAE,YAAa,IAAA,CAAM,mBAAA,CAAqB,KAAM,CAAA,CACxD,MAAA,CAAQ,CAAE,WAAA,CAAa,KAAA,CAAO,mBAAA,CAAqB,IAAK,EACxD,MAAA,CAAQ,CAAE,YAAa,KAAA,CAAO,mBAAA,CAAqB,IAAK,CACzD,CAAA,CAMO,SAASC,CAAAA,CAA2BC,EAA8B,CACxE,IAAMC,EAASH,CAAAA,CAAiBE,CAAQ,EAEpCE,CAAAA,CAAe,CAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CA2BnB,OAAID,CAAAA,CAAO,WAAA,CACVC,CAAAA,EAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAUND,CAAAA,CAAO,sBACjBC,CAAAA,EAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAAA,CAWVA,CACR","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
+ {"version":3,"sources":["../src/errors.ts","../src/observability/tracing.ts","../src/prompts/adapters.ts","../src/security/cert-manager.ts"],"names":["ErrorCode","crypto2"],"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,C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AA,IAAI,CAAC,KAAK,eAAA,EAAiB;AAC1B,MAAA,MAAM,IAAI,MAAM,6CAA6C,CAAA;AAAA,IAC9D;AACA,IAAA,OAAO,IAAA,CAAK,eAAA;AAAA,EACb;AAAA,EAEO,aAAA,GAAwB;AAC9B,IAAA,IAAI,CAAC,KAAK,gBAAA,EAAkB;AAC3B,MAAA,MAAM,IAAI,MAAM,uCAAuC,CAAA;AAAA,IACxD;AACA,IAAA,OAAO,IAAA,CAAK,gBAAA;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKO,OAAA,GAAgB;AACtB,IAAA,IAAI,KAAK,mBAAA,EAAqB;AAC7B,MAAA,YAAA,CAAa,KAAK,mBAAmB,CAAA;AACrC,MAAA,IAAA,CAAK,mBAAA,GAAsB,IAAA;AAAA,IAC5B;AACA,IAAA,KAAA,MAAW,OAAA,IAAW,KAAK,QAAA,EAAU;AACpC,MAAA,IAAI;AACH,QAAA,OAAA,CAAQ,KAAA,EAAM;AAAA,MACf,CAAA,CAAA,MAAQ;AAAA,MAER;AAAA,IACD;AACA,IAAA,IAAA,CAAK,WAAW,EAAC;AACjB,IAAA,IAAA,CAAK,kBAAA,EAAmB;AAAA,EACzB;AACD","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 OpenTelemetry Distributed Tracing (Phase Beta-3)\n * W3C TraceContext compliant distributed tracer for gRPC & MCP transports.\n * Spec: https://www.w3.org/TR/trace-context/\n */\n\nimport * as crypto from \"node:crypto\";\n\nexport interface SpanContext {\n\ttraceId: string;\n\tspanId: string;\n\tsampled: boolean;\n}\n\nexport interface LiopSpan {\n\treadonly name: string;\n\treadonly context: SpanContext;\n\treadonly startTime: number;\n\tendTime?: number;\n\tattributes: Record<string, string | number | boolean>;\n\tstatus: \"OK\" | \"ERROR\";\n\terror?: string;\n\tsetAttribute(key: string, value: string | number | boolean): LiopSpan;\n\trecordException(error: Error | string): LiopSpan;\n\tend(): void;\n}\n\nconst TRACEPARENT_REGEX =\n\t/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/;\n\nexport class LiopTracer {\n\tpublic static generateTraceId(): string {\n\t\tlet id: string;\n\t\tdo {\n\t\t\tid = crypto.randomBytes(16).toString(\"hex\");\n\t\t} while (id === \"0\".repeat(32));\n\t\treturn id;\n\t}\n\n\tpublic static generateSpanId(): string {\n\t\tlet id: string;\n\t\tdo {\n\t\t\tid = crypto.randomBytes(8).toString(\"hex\");\n\t\t} while (id === \"0\".repeat(16));\n\t\treturn id;\n\t}\n\n\tpublic static formatTraceparent(\n\t\ttraceId: string,\n\t\tspanId: string,\n\t\tsampled = true,\n\t): string {\n\t\tconst flags = sampled ? \"01\" : \"00\";\n\t\treturn `00-${traceId}-${spanId}-${flags}`;\n\t}\n\n\tpublic static parseTraceparent(header?: string | null): SpanContext | null {\n\t\tif (!header || typeof header !== \"string\") {\n\t\t\treturn null;\n\t\t}\n\t\tconst trimmed = header.trim();\n\t\tconst match = TRACEPARENT_REGEX.exec(trimmed);\n\t\tif (!match) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst [, version, traceId, spanId, flags] = match;\n\t\t// Version 00 cannot have all-zeros traceId or spanId\n\t\tif (version === \"00\") {\n\t\t\tif (traceId === \"0\".repeat(32) || spanId === \"0\".repeat(16)) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tconst sampled = (Number.parseInt(flags, 16) & 0x01) === 1;\n\t\treturn {\n\t\t\ttraceId,\n\t\t\tspanId,\n\t\t\tsampled,\n\t\t};\n\t}\n\n\tpublic static injectTraceparent(\n\t\tcarrier: Record<string, string | string[] | undefined>,\n\t\tcontext: SpanContext,\n\t): void {\n\t\tcarrier.traceparent = LiopTracer.formatTraceparent(\n\t\t\tcontext.traceId,\n\t\t\tcontext.spanId,\n\t\t\tcontext.sampled,\n\t\t);\n\t}\n\n\tpublic static extractTraceparent(\n\t\tcarrier: Record<string, string | string[] | undefined>,\n\t): SpanContext | null {\n\t\tconst val = carrier.traceparent || carrier.Traceparent;\n\t\tif (Array.isArray(val)) {\n\t\t\treturn LiopTracer.parseTraceparent(val[0]);\n\t\t}\n\t\treturn LiopTracer.parseTraceparent(val);\n\t}\n\n\tpublic startSpan(\n\t\tname: string,\n\t\tparent?: SpanContext | null,\n\t\tattributes: Record<string, string | number | boolean> = {},\n\t): LiopSpan {\n\t\tconst traceId = parent?.traceId || LiopTracer.generateTraceId();\n\t\tconst spanId = LiopTracer.generateSpanId();\n\t\tconst sampled = parent ? parent.sampled : true;\n\n\t\tconst context: SpanContext = {\n\t\t\ttraceId,\n\t\t\tspanId,\n\t\t\tsampled,\n\t\t};\n\n\t\tconst span: LiopSpan = {\n\t\t\tname,\n\t\t\tcontext,\n\t\t\tstartTime: Date.now(),\n\t\t\tattributes: { ...attributes },\n\t\t\tstatus: \"OK\",\n\t\t\tsetAttribute(key, value) {\n\t\t\t\tthis.attributes[key] = value;\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\trecordException(err) {\n\t\t\t\tthis.status = \"ERROR\";\n\t\t\t\tthis.error = typeof err === \"string\" ? err : err.message;\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tend() {\n\t\t\t\tthis.endTime = Date.now();\n\t\t\t},\n\t\t};\n\n\t\treturn span;\n\t}\n}\n\nexport const defaultTracer = new LiopTracer();\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","/**\n * LIOP Certificate Manager (CertManager)\n * Provides automated certificate monitoring, X.509 validity inspection,\n * and hot-reloading for mutual TLS (mTLS) without node restarts.\n *\n * Compliance:\n * - NIST SP 800-52 Rev. 2: Guidelines for the Selection and Use of TLS\n * - Zero-Trust Architecture (NIST SP 800-207): Continuous cryptographic verification\n */\n\nimport * as crypto from \"node:crypto\";\nimport { EventEmitter } from \"node:events\";\nimport * as fs from \"node:fs\";\nimport { log } from \"../utils/logger.js\";\n\nexport interface CertManagerOptions {\n\t/** Path to the root CA certificate (PEM format) */\n\trootCertPath?: string;\n\t/** Path to the server/client certificate chain (PEM format) */\n\tcertChainPath: string;\n\t/** Path to the private key (PEM format) */\n\tprivateKeyPath: string;\n\t/** Expiration warning threshold in days (default: 30) */\n\twarningDays?: number;\n\t/** Enable file watching for automatic hot-reloading (default: true) */\n\twatchFiles?: boolean;\n\t/** Debounce delay in ms for hot reloading (default: 150) */\n\tdebounceMs?: number;\n}\n\nexport interface CertInfo {\n\tsubject: string;\n\tissuer: string;\n\tvalidFrom: string;\n\tvalidTo: string;\n\tfingerprint256: string;\n\tdaysRemaining: number;\n\tisExpired: boolean;\n\tisExpiringSoon: boolean;\n}\n\nexport class CertManager extends EventEmitter {\n\tprivate rootCertBuffer: Buffer | null = null;\n\tprivate certChainBuffer: Buffer | null = null;\n\tprivate privateKeyBuffer: Buffer | null = null;\n\tprivate watchers: fs.FSWatcher[] = [];\n\tprivate reloadDebounceTimer: NodeJS.Timeout | null = null;\n\tprivate readonly warningDays: number;\n\tprivate readonly debounceMs: number;\n\n\tconstructor(private readonly options: CertManagerOptions) {\n\t\tsuper();\n\t\tthis.warningDays = options.warningDays ?? 30;\n\t\tthis.debounceMs = options.debounceMs ?? 150;\n\t\tthis.loadCertificates();\n\n\t\tif (options.watchFiles !== false) {\n\t\t\tthis.setupWatchers();\n\t\t}\n\t}\n\n\t/**\n\t * Synchronously loads or reloads certificates from filesystem into memory.\n\t */\n\tpublic loadCertificates(): void {\n\t\ttry {\n\t\t\tif (\n\t\t\t\tthis.options.rootCertPath &&\n\t\t\t\tfs.existsSync(this.options.rootCertPath)\n\t\t\t) {\n\t\t\t\tthis.rootCertBuffer = fs.readFileSync(this.options.rootCertPath);\n\t\t\t}\n\n\t\t\tif (!fs.existsSync(this.options.certChainPath)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Certificate chain file not found: ${this.options.certChainPath}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!fs.existsSync(this.options.privateKeyPath)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Private key file not found: ${this.options.privateKeyPath}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.certChainBuffer = fs.readFileSync(this.options.certChainPath);\n\t\t\tthis.privateKeyBuffer = fs.readFileSync(this.options.privateKeyPath);\n\n\t\t\tlog.info(\"[CertManager] Certificates loaded successfully.\");\n\t\t} catch (error) {\n\t\t\tlog.error(`[CertManager] Failed to load certificates: ${error}`);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Inspects the loaded server/client certificate chain using Node.js native X509Certificate.\n\t */\n\tpublic inspectCertificate(): CertInfo {\n\t\tif (!this.certChainBuffer) {\n\t\t\tthrow new Error(\"[CertManager] No certificate loaded to inspect.\");\n\t\t}\n\n\t\tconst x509 = new crypto.X509Certificate(this.certChainBuffer);\n\t\tconst validToDate = new Date(x509.validTo);\n\t\tconst now = new Date();\n\t\tconst msRemaining = validToDate.getTime() - now.getTime();\n\t\tconst daysRemaining = Math.max(\n\t\t\t0,\n\t\t\tMath.floor(msRemaining / (1000 * 60 * 60 * 24)),\n\t\t);\n\t\tconst isExpired = msRemaining <= 0;\n\t\tconst isExpiringSoon = daysRemaining <= this.warningDays;\n\n\t\treturn {\n\t\t\tsubject: x509.subject,\n\t\t\tissuer: x509.issuer,\n\t\t\tvalidFrom: x509.validFrom,\n\t\t\tvalidTo: x509.validTo,\n\t\t\tfingerprint256: x509.fingerprint256,\n\t\t\tdaysRemaining,\n\t\t\tisExpired,\n\t\t\tisExpiringSoon,\n\t\t};\n\t}\n\n\t/**\n\t * Sets up non-blocking filesystem watchers to detect certificate renewals\n\t * and trigger hot-reloading without process restarts.\n\t */\n\tprivate setupWatchers(): void {\n\t\tconst filesToWatch = [\n\t\t\tthis.options.certChainPath,\n\t\t\tthis.options.privateKeyPath,\n\t\t\tthis.options.rootCertPath,\n\t\t].filter((p): p is string => Boolean(p && fs.existsSync(p)));\n\n\t\tfor (const filePath of filesToWatch) {\n\t\t\ttry {\n\t\t\t\tconst watcher = fs.watch(filePath, () => {\n\t\t\t\t\tthis.scheduleReload();\n\t\t\t\t});\n\t\t\t\tthis.watchers.push(watcher);\n\t\t\t} catch (err) {\n\t\t\t\tlog.warn(\n\t\t\t\t\t`[CertManager] Could not watch ${filePath} for hot reloading: ${err}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Debounces reload events to ensure files have finished writing.\n\t */\n\tprivate scheduleReload(): void {\n\t\tif (this.reloadDebounceTimer) {\n\t\t\tclearTimeout(this.reloadDebounceTimer);\n\t\t}\n\n\t\tthis.reloadDebounceTimer = setTimeout(() => {\n\t\t\ttry {\n\t\t\t\tthis.loadCertificates();\n\t\t\t\tconst certInfo = this.inspectCertificate();\n\t\t\t\tlog.info(\n\t\t\t\t\t`[CertManager] Hot reload complete. Certificate expires in ${certInfo.daysRemaining} days.`,\n\t\t\t\t);\n\t\t\t\tthis.emit(\"reload\", certInfo);\n\t\t\t} catch (error) {\n\t\t\t\tlog.error(`[CertManager] Hot reload failed: ${error}`);\n\t\t\t\tthis.emit(\"error\", error);\n\t\t\t}\n\t\t}, this.debounceMs);\n\t}\n\n\t/**\n\t * Manually triggers a reload of certificates and emits the 'reload' event.\n\t */\n\tpublic reload(): CertInfo {\n\t\tthis.loadCertificates();\n\t\tconst certInfo = this.inspectCertificate();\n\t\tlog.info(\n\t\t\t`[CertManager] Hot reload complete. Certificate expires in ${certInfo.daysRemaining} days.`,\n\t\t);\n\t\tthis.emit(\"reload\", certInfo);\n\t\treturn certInfo;\n\t}\n\n\tpublic getRootCert(): Buffer | null {\n\t\treturn this.rootCertBuffer;\n\t}\n\n\tpublic getCertChain(): Buffer {\n\t\tif (!this.certChainBuffer) {\n\t\t\tthrow new Error(\"[CertManager] Certificate chain not loaded.\");\n\t\t}\n\t\treturn this.certChainBuffer;\n\t}\n\n\tpublic getPrivateKey(): Buffer {\n\t\tif (!this.privateKeyBuffer) {\n\t\t\tthrow new Error(\"[CertManager] Private key not loaded.\");\n\t\t}\n\t\treturn this.privateKeyBuffer;\n\t}\n\n\t/**\n\t * Stops all active file watchers and releases resources.\n\t */\n\tpublic dispose(): void {\n\t\tif (this.reloadDebounceTimer) {\n\t\t\tclearTimeout(this.reloadDebounceTimer);\n\t\t\tthis.reloadDebounceTimer = null;\n\t\t}\n\t\tfor (const watcher of this.watchers) {\n\t\t\ttry {\n\t\t\t\twatcher.close();\n\t\t\t} catch {\n\t\t\t\t// Ignore watcher close errors\n\t\t\t}\n\t\t}\n\t\tthis.watchers = [];\n\t\tthis.removeAllListeners();\n\t}\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export { Kyber768Wrapper } from './chunk-QLCOEP5J.js';
2
+ //# sourceMappingURL=kyber-3ULIJSE3.js.map
3
+ //# sourceMappingURL=kyber-3ULIJSE3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"kyber-NONMBQNH.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"kyber-3ULIJSE3.js"}
package/dist/mesh.d.ts CHANGED
@@ -29,6 +29,10 @@ interface LiopManifest {
29
29
  authRequired?: boolean;
30
30
  /** Canonical slug for deterministic token resolution. Agents resolve LIOP_TOKEN_<tokenSlug>. Must match /^[A-Z][A-Z0-9_]*$/. */
31
31
  tokenSlug?: string;
32
+ /** ML-DSA-65 (FIPS 204) Post-Quantum Digital Signature for Manifest Attestation (Base64) */
33
+ pqcSignature?: string;
34
+ /** ML-DSA-65 (FIPS 204) Post-Quantum Public Key (Base64) */
35
+ pqcPublicKey?: string;
32
36
  }
33
37
  interface MeshNodeConfig {
34
38
  listenAddresses?: string[];
@@ -38,6 +42,14 @@ interface MeshNodeConfig {
38
42
  dhtStoragePath?: string;
39
43
  /** Optional function to translate multiaddrs (e.g. for Docker NAT traversal). Return null to drop an address. */
40
44
  addressMapper?: (addr: string) => string | null;
45
+ /** Enable AutoNAT reachability detection (default: true) */
46
+ enableAutoNAT?: boolean;
47
+ /** Enable Circuit Relay v2 transport & server for NAT traversal (default: true) */
48
+ enableRelay?: boolean;
49
+ /** Enable DCUtR decentralized hole punching (default: true) */
50
+ enableDcutr?: boolean;
51
+ /** Enable mDNS peer discovery for local networks (default: false in WAN, true in LAN) */
52
+ enableMdns?: boolean;
41
53
  }
42
54
  /**
43
55
  * P2P Mesh Node backed by libp2p + Kademlia DHT.
@@ -129,6 +141,8 @@ declare class MeshNode {
129
141
  announceCapability(hash: string): Promise<void>;
130
142
  findProviders(hash: string): Promise<string[]>;
131
143
  resolvePeer(peerIdStr: string): Promise<string[]>;
144
+ isStarted(): boolean;
145
+ getPeers(): string[];
132
146
  }
133
147
 
134
148
  export { type LiopManifest, MeshNode, type MeshNodeConfig };
package/dist/mesh.js CHANGED
@@ -1,2 +1,5 @@
1
- import'./chunk-RWRRBYG4.js';export{a as MeshNode}from'./chunk-DQ6UW6L7.js';import'./chunk-S6RJHZV2.js';import'./chunk-4C666HHU.js';//# sourceMappingURL=mesh.js.map
1
+ import './chunk-RWRRBYG4.js';
2
+ export { MeshNode } from './chunk-74CISO2I.js';
3
+ import './chunk-72MNYFR6.js';
4
+ //# sourceMappingURL=mesh.js.map
2
5
  //# 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-DO97j6hP.js';
1
+ export { b as AggregationPolicy, L as LiopServer, a as LiopServerOptions, i as LogicExecutionPolicy, N as NerScanner, j as OutputSanitizerConfig, P as PII_PATTERNS, k as PII_PRESETS, l as PiiRule, m as PiiScanner, T as ToolHandler, s as sanitizeOutput } from './index-BW95kAL4.js';
2
2
  import 'zod';
3
3
  import './mesh.js';
4
- import './types-DzEXgi4s.js';
4
+ import './types-lJIxBlWF.js';
5
5
  import 'jose';
package/dist/server.js CHANGED
@@ -1,2 +1,8 @@
1
- export{j as LiopServer,e as NerScanner,g as PII_PATTERNS,h as PII_PRESETS,i as PiiScanner,f as sanitizeOutput}from'./chunk-UCCGDGHE.js';import'./chunk-2MGFSIXN.js';import'./chunk-SB5XJXKV.js';import'./chunk-V5MKJT6S.js';import'./chunk-DQ6UW6L7.js';import'./chunk-S6RJHZV2.js';import'./chunk-4C666HHU.js';//# sourceMappingURL=server.js.map
1
+ export { LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner } from './chunk-UBOQZVV5.js';
2
+ export { sanitizeOutput } from './chunk-JIJPZFR2.js';
3
+ import './chunk-OIMJZ64E.js';
4
+ import './chunk-WSW6YJNY.js';
5
+ import './chunk-74CISO2I.js';
6
+ import './chunk-72MNYFR6.js';
7
+ //# sourceMappingURL=server.js.map
2
8
  //# sourceMappingURL=server.js.map
@@ -80,6 +80,68 @@ declare class JwtValidator {
80
80
  getAudience(): string;
81
81
  }
82
82
 
83
+ /**
84
+ * @mcp-legacy ENTIRE FILE — MCP 2025-era backward compatibility layer.
85
+ * Remove this file when MCP v1 (2025-11-25) reaches EOL.
86
+ *
87
+ * SUNSET INSTRUCTION: Delete this file, then grep for "@mcp-legacy" in the
88
+ * codebase to find and remove all remaining legacy seams.
89
+ */
90
+ /**
91
+ * @mcp-legacy Master kill switch for MCP 2025-era backward compatibility.
92
+ * Set to `false` when MCP v1 reaches End-of-Life (EOL) to disable all legacy seams.
93
+ */
94
+ declare const MCP_LEGACY_SUPPORT_ENABLED = true;
95
+ /**
96
+ * @mcp-legacy Legacy protocol version constant.
97
+ */
98
+ declare const MCP_PROTOCOL_VERSION_LEGACY: "2025-11-25";
99
+
100
+ /**
101
+ * Protocol Version Identifiers
102
+ */
103
+ declare const MCP_PROTOCOL_VERSION: "2026-07-28";
104
+
105
+ /**
106
+ * Protocol Era Classification
107
+ */
108
+ type McpEra = "legacy" | "modern";
109
+ /**
110
+ * Caching Hints for MCP 2026-07-28 Spec
111
+ */
112
+ interface CacheableResult {
113
+ ttlMs?: number;
114
+ cacheScope?: "public" | "private";
115
+ }
116
+ /**
117
+ * Multi-Round-Trip Requests (MRTR) Specification Types
118
+ */
119
+ interface InputRequest {
120
+ id: string;
121
+ message: string;
122
+ schema?: Record<string, unknown>;
123
+ }
124
+ interface InputResponse {
125
+ id: string;
126
+ value: unknown;
127
+ }
128
+ interface InputRequiredResult {
129
+ resultType: "input_required";
130
+ inputRequests: InputRequest[];
131
+ requestState?: string;
132
+ }
133
+ /**
134
+ * Modern Envelope Metadata (_meta)
135
+ */
136
+ interface McpRequestMeta {
137
+ "io.modelcontextprotocol/protocolVersion"?: string;
138
+ "io.modelcontextprotocol/clientInfo"?: {
139
+ name: string;
140
+ version: string;
141
+ };
142
+ "io.modelcontextprotocol/clientCapabilities"?: Record<string, unknown>;
143
+ [key: string]: unknown;
144
+ }
83
145
  /**
84
146
  * Base Protocol Types representing parity with Model Context Protocol
85
147
  */
@@ -87,32 +149,14 @@ declare const ToolSchema: z.ZodObject<{
87
149
  name: z.ZodString;
88
150
  description: z.ZodOptional<z.ZodString>;
89
151
  inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
90
- }, "strip", z.ZodTypeAny, {
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
- }>;
152
+ }, z.core.$strip>;
99
153
  type Tool = z.infer<typeof ToolSchema>;
100
154
  declare const ResourceSchema: z.ZodObject<{
101
155
  uri: z.ZodString;
102
156
  name: z.ZodString;
103
157
  description: z.ZodOptional<z.ZodString>;
104
158
  mimeType: z.ZodOptional<z.ZodString>;
105
- }, "strip", z.ZodTypeAny, {
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
- }>;
159
+ }, z.core.$strip>;
116
160
  type Resource = z.infer<typeof ResourceSchema>;
117
161
  declare const PromptSchema: z.ZodObject<{
118
162
  name: z.ZodString;
@@ -121,32 +165,8 @@ declare const PromptSchema: z.ZodObject<{
121
165
  name: z.ZodString;
122
166
  description: z.ZodOptional<z.ZodString>;
123
167
  required: z.ZodOptional<z.ZodBoolean>;
124
- }, "strip", z.ZodTypeAny, {
125
- name: string;
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
- }>;
168
+ }, z.core.$strip>>>;
169
+ }, z.core.$strip>;
150
170
  type Prompt = z.infer<typeof PromptSchema>;
151
171
  interface CallToolRequest {
152
172
  name: string;
@@ -205,9 +225,17 @@ interface ServerInfo {
205
225
  tools?: {
206
226
  listChanged?: boolean;
207
227
  };
228
+ /** @mcp-legacy @deprecated Deprecated in MCP 2026-07-28 spec */
208
229
  logging?: Record<string, unknown>;
209
230
  };
210
231
  }
232
+ interface DiscoverResult {
233
+ resultType: "complete";
234
+ supportedVersions: string[];
235
+ capabilities: ServerInfo["capabilities"];
236
+ serverInfo: ServerInfo;
237
+ instructions?: string;
238
+ }
211
239
  interface McpRequest {
212
240
  method: string;
213
241
  params?: unknown;
@@ -225,4 +253,4 @@ interface McpResponse {
225
253
  };
226
254
  }
227
255
 
228
- export { type AuthInfo as A, type CallToolRequest as C, type GetPromptRequest as G, JwtValidator as J, type McpRequest as M, type Prompt as P, type Resource as R, type ServerInfo as S, type Tool as T, type CallToolResult as a, type McpResponse as b, type GetPromptResult as c, PromptSchema as d, ResourceSchema as e, ToolSchema as f };
256
+ export { type AuthInfo as A, type CallToolRequest as C, type DiscoverResult as D, type GetPromptRequest as G, type InputRequest as I, JwtValidator as J, type McpEra as M, type Prompt as P, type Resource as R, type ServerInfo as S, type Tool as T, type CallToolResult as a, type McpRequest as b, type McpResponse as c, type GetPromptResult as d, type CacheableResult as e, type InputRequiredResult as f, type InputResponse as g, MCP_LEGACY_SUPPORT_ENABLED as h, MCP_PROTOCOL_VERSION as i, MCP_PROTOCOL_VERSION_LEGACY as j, type McpRequestMeta as k, PromptSchema as l, ResourceSchema as m, ToolSchema as n };
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-DzEXgi4s.js';
2
+ export { A as AuthInfo, e as CacheableResult, C as CallToolRequest, a as CallToolResult, D as DiscoverResult, G as GetPromptRequest, d as GetPromptResult, I as InputRequest, f as InputRequiredResult, g as InputResponse, h as MCP_LEGACY_SUPPORT_ENABLED, i as MCP_PROTOCOL_VERSION, j as MCP_PROTOCOL_VERSION_LEGACY, M as McpEra, b as McpRequest, k as McpRequestMeta, c as McpResponse, P as Prompt, l as PromptSchema, R as Resource, m as ResourceSchema, S as ServerInfo, T as Tool, n as ToolSchema } from './types-lJIxBlWF.js';
3
3
  import 'jose';
package/dist/types.js CHANGED
@@ -1,2 +1,3 @@
1
- export{c as PromptSchema,b as ResourceSchema,a as ToolSchema}from'./chunk-TYVG6TXQ.js';import'./chunk-2MGFSIXN.js';import'./chunk-4C666HHU.js';//# sourceMappingURL=types.js.map
1
+ export { MCP_LEGACY_SUPPORT_ENABLED, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_LEGACY, PromptSchema, ResourceSchema, ToolSchema } from './chunk-PYKRQAER.js';
2
+ //# sourceMappingURL=types.js.map
2
3
  //# sourceMappingURL=types.js.map
@@ -0,0 +1,5 @@
1
+ export { LiopVerifier } from './chunk-32ADSAJS.js';
2
+ import './chunk-OUUTDSOW.js';
3
+ import './chunk-72MNYFR6.js';
4
+ //# sourceMappingURL=verifier-3FAKCFNN.js.map
5
+ //# sourceMappingURL=verifier-3FAKCFNN.js.map