@nekzus/liop 2.4.0-alpha.25 → 2.4.0-alpha.27

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 (61) hide show
  1. package/dist/bin/agent.js +27 -933
  2. package/dist/bridge.js +1 -5
  3. package/dist/chunk-2XHSALII.js +3 -0
  4. package/dist/chunk-2ZYX736J.js +2 -0
  5. package/dist/chunk-3WRKTVOF.js +2 -0
  6. package/dist/chunk-6KFKO6ZX.js +2 -0
  7. package/dist/chunk-6VK2XALI.js +2 -0
  8. package/dist/chunk-AYDF3IFZ.js +2 -0
  9. package/dist/chunk-CTTTLCGL.js +31 -0
  10. package/dist/chunk-ECRS6N33.js +4 -0
  11. package/dist/chunk-FDJMH4CB.js +2 -0
  12. package/dist/chunk-FTF6AMF6.js +0 -1
  13. package/dist/chunk-GWVSCZUS.js +2 -0
  14. package/dist/chunk-LEXMMIQI.js +15 -0
  15. package/dist/chunk-LM26HOJ6.js +31 -0
  16. package/dist/chunk-MQ5SU26J.js +2 -0
  17. package/dist/chunk-N35BC62H.js +2 -0
  18. package/dist/chunk-P6IJ3VBD.js +3 -0
  19. package/dist/chunk-TKLRW52V.js +2 -0
  20. package/dist/chunk-V35CXJQN.js +2 -0
  21. package/dist/chunk-WP5ER7RH.js +3 -0
  22. package/dist/chunk-XLVEDKM6.js +2 -0
  23. package/dist/chunk-Y675R34Z.js +2 -0
  24. package/dist/chunk-YD2AF2M6.js +46 -0
  25. package/dist/chunk-YLCNV764.js +3 -0
  26. package/dist/chunk-ZZMSFCJP.js +3 -0
  27. package/dist/client.js +1 -12
  28. package/dist/gateway.js +1 -13
  29. package/dist/index.js +4 -320
  30. package/dist/kyber-PULV7PQX.js +2 -0
  31. package/dist/mesh.js +1 -5
  32. package/dist/server.js +1 -10
  33. package/dist/types.js +1 -3
  34. package/dist/verifier-J4NQYZX5.js +2 -0
  35. package/dist/workers/logic-execution.js +1 -355
  36. package/dist/workers/zk-verifier.js +1 -275
  37. package/package.json +1 -1
  38. package/dist/chunk-3664H3CV.js +0 -136
  39. package/dist/chunk-3QH44NKZ.js +0 -115
  40. package/dist/chunk-6MYJBM2E.js +0 -818
  41. package/dist/chunk-7PITYWOV.js +0 -68
  42. package/dist/chunk-DSOB2JKM.js +0 -1507
  43. package/dist/chunk-ET6VRUK2.js +0 -58
  44. package/dist/chunk-FIVRGOA4.js +0 -280
  45. package/dist/chunk-IHKKWXHJ.js +0 -876
  46. package/dist/chunk-IK7CGWAZ.js +0 -24
  47. package/dist/chunk-JPWC6XG6.js +0 -941
  48. package/dist/chunk-K3DGJLUY.js +0 -106
  49. package/dist/chunk-KR5UZUEY.js +0 -98
  50. package/dist/chunk-NXCAFF73.js +0 -59
  51. package/dist/chunk-Q3FKHJ3B.js +0 -345
  52. package/dist/chunk-R52TZEIL.js +0 -426
  53. package/dist/chunk-S3RAZTEM.js +0 -807
  54. package/dist/chunk-V47P2AQR.js +0 -281
  55. package/dist/chunk-WXOWJXY6.js +0 -564
  56. package/dist/chunk-WXYDFCIW.js +0 -293
  57. package/dist/chunk-Y62GORQF.js +0 -51
  58. package/dist/chunk-ZP3VVXOI.js +0 -66
  59. package/dist/chunk-ZU3WVVLC.js +0 -3752
  60. package/dist/kyber-CGOA7Q6A.js +0 -3
  61. package/dist/verifier-55HW6AFN.js +0 -6
package/dist/index.js CHANGED
@@ -1,148 +1,4 @@
1
- export { WasiSandbox, calculateAstInstructionFuel, getDefaultEnvironment } from './chunk-R52TZEIL.js';
2
- export { VERIFICATION_LATENCY_BUDGET_MS, deserializeGrothProof, deserializeVKey, serializeGrothProof, serializeVKey, verifyGroth16Proof } from './chunk-ET6VRUK2.js';
3
- export { AesGcmWrapper, LiopClient, LiopRpcClient } from './chunk-S3RAZTEM.js';
4
- export { LiopMcpBridge, LiopStreamBridge } from './chunk-WXOWJXY6.js';
5
- export { GRPC_WEB_CONSTANTS, InMemoryRateLimiter, LiopHybridGateway, buildProtectedResourceMetadata, decodeFrames, dispatchGrpcWebRequest, encodeDataFrame, encodeTrailerFrame, executeGatewayInterceptor, isGrpcWebRequest } from './chunk-6MYJBM2E.js';
6
- export { RoutingTable, probeTopology } from './chunk-V47P2AQR.js';
7
- export { TokenManager } from './chunk-3QH44NKZ.js';
8
- export { AUTH_DEFAULTS, AuditLogger, GENESIS_HASH, JwtValidator, LiopRpcServer, LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner, computeEntryHash, createOAuthServer, globalAuditLogger } from './chunk-ZU3WVVLC.js';
9
- export { sanitizeOutput } from './chunk-Y62GORQF.js';
10
- export { LiopMcpRouter } from './chunk-DSOB2JKM.js';
11
- export { LiopVerifier } from './chunk-WXYDFCIW.js';
12
- import './chunk-IK7CGWAZ.js';
13
- export { Kyber768Wrapper } from './chunk-7PITYWOV.js';
14
- export { LIOP_SCOPES, authorizeRequest } from './chunk-NXCAFF73.js';
15
- export { DILITHIUM65_CONSTANTS, Dilithium65Wrapper } from './chunk-3664H3CV.js';
16
- export { GRPC_CHANNEL_OPTIONS, HeuristicTokenEstimator, LiopOTelBridge, RealTokenEstimator, TokenTelemetryEngine, createChannelCredentials, createServerCredentials, createSyncTokenEstimator, createTokenEstimator } from './chunk-JPWC6XG6.js';
17
- export { Counter, Gauge, Histogram, MetricsRegistry, egressBlocksTotal, fuelConsumed, manifestCacheSize, meshPeersConnected, operationDurationMs, pqcHandshakeDurationMs, pqcHandshakesTotal, protocolMetrics, tokensInputTotal, tokensOutputTotal, tokensSavedTotal, toolCallErrorsTotal, toolCallsTotal, wireEgressBytesTotal, wireSavedBytesTotal, zkProofsByTypeTotal, zkProvingDurationMs, zkVerificationDurationMs, zkVerificationsTotal, zkVkeyCacheSize } from './chunk-Q3FKHJ3B.js';
18
- export { MCP_LEGACY_SUPPORT_ENABLED, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_LEGACY, PromptSchema, ResourceSchema, ToolSchema } from './chunk-KR5UZUEY.js';
19
- export { ProofType, RECEIPT_VERSION_V1, RECEIPT_VERSION_V2, ZK_JOURNAL_V2_SIZE, ZkVerificationError, ZkVerifier, decodeJournalV2, encodeJournalV2, receiptCodec } from './chunk-FIVRGOA4.js';
20
- export { SWARM_KEY_BYTE_LENGTH, createSwarmKey, deserializeSwarmKey, loadSwarmKey, parseSwarmKey, saveSwarmKey, serializeSwarmKey } from './chunk-ZP3VVXOI.js';
21
- export { MeshNode } from './chunk-IHKKWXHJ.js';
22
- import { log } from './chunk-K3DGJLUY.js';
23
- export { LiopLogger, log } from './chunk-K3DGJLUY.js';
24
- import * as crypto from 'crypto';
25
- import { EventEmitter } from 'events';
26
- import * as fs from 'fs';
27
-
28
- // src/errors.ts
29
- var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
30
- ErrorCode2["CapabilityViolation"] = "CapabilityViolation";
31
- ErrorCode2["SandboxEscape"] = "SandboxEscape";
32
- ErrorCode2["PiiLeak"] = "PiiLeak";
33
- ErrorCode2["InvalidIntent"] = "InvalidIntent";
34
- ErrorCode2["Throttled"] = "Throttled";
35
- ErrorCode2["ZkVerificationFailed"] = "ZkVerificationFailed";
36
- ErrorCode2["MeshUnavailable"] = "MeshUnavailable";
37
- ErrorCode2["ConnectionFailed"] = "ConnectionFailed";
38
- return ErrorCode2;
39
- })(ErrorCode || {});
40
- var LiopError = class extends Error {
41
- code;
42
- constructor(code, message) {
43
- super(message);
44
- this.name = "LiopError";
45
- this.code = code;
46
- }
47
- };
48
- var TRACEPARENT_REGEX = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/;
49
- var LiopTracer = class _LiopTracer {
50
- static generateTraceId() {
51
- let id;
52
- do {
53
- id = crypto.randomBytes(16).toString("hex");
54
- } while (id === "0".repeat(32));
55
- return id;
56
- }
57
- static generateSpanId() {
58
- let id;
59
- do {
60
- id = crypto.randomBytes(8).toString("hex");
61
- } while (id === "0".repeat(16));
62
- return id;
63
- }
64
- static formatTraceparent(traceId, spanId, sampled = true) {
65
- const flags = sampled ? "01" : "00";
66
- return `00-${traceId}-${spanId}-${flags}`;
67
- }
68
- static parseTraceparent(header) {
69
- if (!header || typeof header !== "string") {
70
- return null;
71
- }
72
- const trimmed = header.trim();
73
- const match = TRACEPARENT_REGEX.exec(trimmed);
74
- if (!match) {
75
- return null;
76
- }
77
- const [, version, traceId, spanId, flags] = match;
78
- if (version === "00") {
79
- if (traceId === "0".repeat(32) || spanId === "0".repeat(16)) {
80
- return null;
81
- }
82
- }
83
- const sampled = (Number.parseInt(flags, 16) & 1) === 1;
84
- return {
85
- traceId,
86
- spanId,
87
- sampled
88
- };
89
- }
90
- static injectTraceparent(carrier, context) {
91
- carrier.traceparent = _LiopTracer.formatTraceparent(
92
- context.traceId,
93
- context.spanId,
94
- context.sampled
95
- );
96
- }
97
- static extractTraceparent(carrier) {
98
- const val = carrier.traceparent || carrier.Traceparent;
99
- if (Array.isArray(val)) {
100
- return _LiopTracer.parseTraceparent(val[0]);
101
- }
102
- return _LiopTracer.parseTraceparent(val);
103
- }
104
- startSpan(name, parent, attributes = {}) {
105
- const traceId = parent?.traceId || _LiopTracer.generateTraceId();
106
- const spanId = _LiopTracer.generateSpanId();
107
- const sampled = parent ? parent.sampled : true;
108
- const context = {
109
- traceId,
110
- spanId,
111
- sampled
112
- };
113
- const span = {
114
- name,
115
- context,
116
- startTime: Date.now(),
117
- attributes: { ...attributes },
118
- status: "OK",
119
- setAttribute(key, value) {
120
- this.attributes[key] = value;
121
- return this;
122
- },
123
- recordException(err) {
124
- this.status = "ERROR";
125
- this.error = typeof err === "string" ? err : err.message;
126
- return this;
127
- },
128
- end() {
129
- this.endTime = Date.now();
130
- }
131
- };
132
- return span;
133
- }
134
- };
135
- var defaultTracer = new LiopTracer();
136
-
137
- // src/prompts/adapters.ts
138
- var PROVIDER_CONFIGS = {
139
- claude: { xmlStandard: true, jsonSchemaPreferred: false },
140
- openai: { xmlStandard: false, jsonSchemaPreferred: true },
141
- gemini: { xmlStandard: false, jsonSchemaPreferred: true }
142
- };
143
- function generateSystemInstructions(provider) {
144
- const config = PROVIDER_CONFIGS[provider];
145
- let instructions = `[LIOP-PROTO-V1: LOGIC-ON-ORIGIN SPECIFICATION]
1
+ export{d as WasiSandbox,c as calculateAstInstructionFuel,b as getDefaultEnvironment}from'./chunk-CTTTLCGL.js';export{a as VERIFICATION_LATENCY_BUDGET_MS,f as deserializeGrothProof,d as deserializeVKey,e as serializeGrothProof,c as serializeVKey,b as verifyGroth16Proof}from'./chunk-FDJMH4CB.js';export{b as AesGcmWrapper,c as LiopClient,a as LiopRpcClient}from'./chunk-WP5ER7RH.js';export{b as LiopMcpBridge,a as LiopStreamBridge}from'./chunk-P6IJ3VBD.js';export{a as GRPC_WEB_CONSTANTS,i as InMemoryRateLimiter,j as LiopHybridGateway,g as buildProtectedResourceMetadata,e as decodeFrames,f as dispatchGrpcWebRequest,c as encodeDataFrame,d as encodeTrailerFrame,h as executeGatewayInterceptor,b as isGrpcWebRequest}from'./chunk-LEXMMIQI.js';export{a as RoutingTable,b as probeTopology}from'./chunk-2XHSALII.js';export{a as TokenManager}from'./chunk-N35BC62H.js';export{f as AUTH_DEFAULTS,d as AuditLogger,b as GENESIS_HASH,g as JwtValidator,a as LiopRpcServer,m as LiopServer,i as NerScanner,j as PII_PATTERNS,k as PII_PRESETS,l as PiiScanner,c as computeEntryHash,h as createOAuthServer,e as globalAuditLogger}from'./chunk-YD2AF2M6.js';export{a as sanitizeOutput}from'./chunk-MQ5SU26J.js';export{a as LiopMcpRouter}from'./chunk-LM26HOJ6.js';export{a as LiopVerifier}from'./chunk-6KFKO6ZX.js';import'./chunk-TKLRW52V.js';export{a as Kyber768Wrapper}from'./chunk-Y675R34Z.js';export{b as LIOP_SCOPES,a as authorizeRequest}from'./chunk-XLVEDKM6.js';export{a as DILITHIUM65_CONSTANTS,b as Dilithium65Wrapper}from'./chunk-2ZYX736J.js';export{j as GRPC_CHANNEL_OPTIONS,b as HeuristicTokenEstimator,e as LiopOTelBridge,a as RealTokenEstimator,f as TokenTelemetryEngine,i as createChannelCredentials,h as createServerCredentials,d as createSyncTokenEstimator,c as createTokenEstimator}from'./chunk-ECRS6N33.js';export{a as Counter,b as Gauge,c as Histogram,d as MetricsRegistry,k as egressBlocksTotal,h as fuelConsumed,j as manifestCacheSize,i as meshPeersConnected,t as operationDurationMs,u as pqcHandshakeDurationMs,v as pqcHandshakesTotal,e as protocolMetrics,q as tokensInputTotal,r as tokensOutputTotal,s as tokensSavedTotal,g as toolCallErrorsTotal,f as toolCallsTotal,w as wireEgressBytesTotal,x as wireSavedBytesTotal,n as zkProofsByTypeTotal,o as zkProvingDurationMs,l as zkVerificationDurationMs,m as zkVerificationsTotal,p as zkVkeyCacheSize}from'./chunk-ZZMSFCJP.js';export{a as MCP_LEGACY_SUPPORT_ENABLED,h as MCP_PROTOCOL_VERSION,b as MCP_PROTOCOL_VERSION_LEGACY,k as PromptSchema,j as ResourceSchema,i as ToolSchema}from'./chunk-GWVSCZUS.js';export{a as ProofType,b as RECEIPT_VERSION_V1,c as RECEIPT_VERSION_V2,d as ZK_JOURNAL_V2_SIZE,e as ZkVerificationError,i as ZkVerifier,g as decodeJournalV2,f as encodeJournalV2,h as receiptCodec}from'./chunk-6VK2XALI.js';export{a as SWARM_KEY_BYTE_LENGTH,b as createSwarmKey,d as deserializeSwarmKey,g as loadSwarmKey,e as parseSwarmKey,f as saveSwarmKey,c as serializeSwarmKey}from'./chunk-YLCNV764.js';export{a as MeshNode}from'./chunk-V35CXJQN.js';import {b}from'./chunk-3WRKTVOF.js';export{a as LiopLogger,b as log}from'./chunk-3WRKTVOF.js';import {a}from'./chunk-AYDF3IFZ.js';import*as h from'crypto';import {EventEmitter}from'events';import*as i from'fs';var A=(o=>(o.CapabilityViolation="CapabilityViolation",o.SandboxEscape="SandboxEscape",o.PiiLeak="PiiLeak",o.InvalidIntent="InvalidIntent",o.Throttled="Throttled",o.ZkVerificationFailed="ZkVerificationFailed",o.MeshUnavailable="MeshUnavailable",o.ConnectionFailed="ConnectionFailed",o))(A||{}),y=class extends Error{static{a(this,"LiopError");}code;constructor(t,e){super(e),this.name="LiopError",this.code=t;}};var D=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/,g=class n{static{a(this,"LiopTracer");}static generateTraceId(){let t;do t=h.randomBytes(16).toString("hex");while(t==="0".repeat(32));return t}static generateSpanId(){let t;do t=h.randomBytes(8).toString("hex");while(t==="0".repeat(16));return t}static formatTraceparent(t,e,r=true){return `00-${t}-${e}-${r?"01":"00"}`}static parseTraceparent(t){if(!t||typeof t!="string")return null;let e=t.trim(),r=D.exec(e);if(!r)return null;let[,a,c,l,m]=r;if(a==="00"&&(c==="0".repeat(32)||l==="0".repeat(16)))return null;let o=(Number.parseInt(m,16)&1)===1;return {traceId:c,spanId:l,sampled:o}}static injectTraceparent(t,e){t.traceparent=n.formatTraceparent(e.traceId,e.spanId,e.sampled);}static extractTraceparent(t){let e=t.traceparent||t.Traceparent;return Array.isArray(e)?n.parseTraceparent(e[0]):n.parseTraceparent(e)}startSpan(t,e,r={}){let a=e?.traceId||n.generateTraceId(),c=n.generateSpanId(),l=e?e.sampled:true;return {name:t,context:{traceId:a,spanId:c,sampled:l},startTime:Date.now(),attributes:{...r},status:"OK",setAttribute(d,T){return this.attributes[d]=T,this},recordException(d){return this.status="ERROR",this.error=typeof d=="string"?d:d.message,this},end(){this.endTime=Date.now();}}}},Mt=new g;var k={claude:{xmlStandard:true,jsonSchemaPreferred:false},openai:{xmlStandard:false,jsonSchemaPreferred:true},gemini:{xmlStandard:false,jsonSchemaPreferred:true}};function Bt(n){let t=k[n],e=`[LIOP-PROTO-V1: LOGIC-ON-ORIGIN SPECIFICATION]
146
2
  You are interacting with a Logic-Injection-on-Origin Protocol (LIOP) Mesh Network.
147
3
  Unlike standard MCP where you pull context to evaluate it remotely, in LIOP you WRITE code that executes on the data's origin.
148
4
 
@@ -167,9 +23,7 @@ To prevent database reconstruction and inference attacks, numeric query outputs
167
23
  - Poisoned globals: eval, Function, setTimeout, setInterval, Buffer, ArrayBuffer, and TypedArrays are undefined.
168
24
  - Frozen prototypes: Modifications to Object.prototype, Array.prototype, etc., are blocked.
169
25
  - 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.
170
- `;
171
- if (config.xmlStandard) {
172
- instructions += `
26
+ `;return t.xmlStandard?e+=`
173
27
  ### PAYLOAD FORMATTING (CLAUDE-XML PREFERRED)
174
28
  You must wrap your logic precisely within <liop_logic> tags.
175
29
  Example:
@@ -178,9 +32,7 @@ const records = await liop.readResource("liop://vault/patients");
178
32
  const filtered = records.filter(r => r.disease === "Hypertension");
179
33
  return { alert: "High risk demographic", targetCount: filtered.length };
180
34
  </liop_logic>
181
- `;
182
- } else if (config.jsonSchemaPreferred) {
183
- instructions += `
35
+ `:t.jsonSchemaPreferred&&(e+=`
184
36
  ### PAYLOAD FORMATTING (JSON PARSING PREFERRED)
185
37
  You must provide your logic strictly within a JSON string key called \`"logic_blob"\` inside your tool call parameters.
186
38
  Example:
@@ -188,173 +40,5 @@ Example:
188
40
  "target": "liop://vault/patients",
189
41
  "logic_blob": "const records = await liop.readResource(args.target); return { targetCount: records.filter(r => r.disease === 'Hypertension').length };"
190
42
  }
191
- `;
192
- }
193
- return instructions;
194
- }
195
- var CertManager = class extends EventEmitter {
196
- constructor(options) {
197
- super();
198
- this.options = options;
199
- this.warningDays = options.warningDays ?? 30;
200
- this.debounceMs = options.debounceMs ?? 150;
201
- this.loadCertificates();
202
- if (options.watchFiles !== false) {
203
- this.setupWatchers();
204
- }
205
- }
206
- options;
207
- rootCertBuffer = null;
208
- certChainBuffer = null;
209
- privateKeyBuffer = null;
210
- watchers = [];
211
- reloadDebounceTimer = null;
212
- warningDays;
213
- debounceMs;
214
- /**
215
- * Synchronously loads or reloads certificates from filesystem into memory.
216
- */
217
- loadCertificates() {
218
- try {
219
- if (this.options.rootCertPath && fs.existsSync(this.options.rootCertPath)) {
220
- this.rootCertBuffer = fs.readFileSync(this.options.rootCertPath);
221
- }
222
- if (!fs.existsSync(this.options.certChainPath)) {
223
- throw new Error(
224
- `Certificate chain file not found: ${this.options.certChainPath}`
225
- );
226
- }
227
- if (!fs.existsSync(this.options.privateKeyPath)) {
228
- throw new Error(
229
- `Private key file not found: ${this.options.privateKeyPath}`
230
- );
231
- }
232
- this.certChainBuffer = fs.readFileSync(this.options.certChainPath);
233
- this.privateKeyBuffer = fs.readFileSync(this.options.privateKeyPath);
234
- log.info("[CertManager] Certificates loaded successfully.");
235
- } catch (error) {
236
- log.error(`[CertManager] Failed to load certificates: ${error}`);
237
- throw error;
238
- }
239
- }
240
- /**
241
- * Inspects the loaded server/client certificate chain using Node.js native X509Certificate.
242
- */
243
- inspectCertificate() {
244
- if (!this.certChainBuffer) {
245
- throw new Error("[CertManager] No certificate loaded to inspect.");
246
- }
247
- const x509 = new crypto.X509Certificate(this.certChainBuffer);
248
- const validToDate = new Date(x509.validTo);
249
- const now = /* @__PURE__ */ new Date();
250
- const msRemaining = validToDate.getTime() - now.getTime();
251
- const daysRemaining = Math.max(
252
- 0,
253
- Math.floor(msRemaining / (1e3 * 60 * 60 * 24))
254
- );
255
- const isExpired = msRemaining <= 0;
256
- const isExpiringSoon = daysRemaining <= this.warningDays;
257
- return {
258
- subject: x509.subject,
259
- issuer: x509.issuer,
260
- validFrom: x509.validFrom,
261
- validTo: x509.validTo,
262
- fingerprint256: x509.fingerprint256,
263
- daysRemaining,
264
- isExpired,
265
- isExpiringSoon
266
- };
267
- }
268
- /**
269
- * Sets up non-blocking filesystem watchers to detect certificate renewals
270
- * and trigger hot-reloading without process restarts.
271
- */
272
- setupWatchers() {
273
- const filesToWatch = [
274
- this.options.certChainPath,
275
- this.options.privateKeyPath,
276
- this.options.rootCertPath
277
- ].filter((p) => Boolean(p && fs.existsSync(p)));
278
- for (const filePath of filesToWatch) {
279
- try {
280
- const watcher = fs.watch(filePath, () => {
281
- this.scheduleReload();
282
- });
283
- this.watchers.push(watcher);
284
- } catch (err) {
285
- log.warn(
286
- `[CertManager] Could not watch ${filePath} for hot reloading: ${err}`
287
- );
288
- }
289
- }
290
- }
291
- /**
292
- * Debounces reload events to ensure files have finished writing.
293
- */
294
- scheduleReload() {
295
- if (this.reloadDebounceTimer) {
296
- clearTimeout(this.reloadDebounceTimer);
297
- }
298
- this.reloadDebounceTimer = setTimeout(() => {
299
- try {
300
- this.loadCertificates();
301
- const certInfo = this.inspectCertificate();
302
- log.info(
303
- `[CertManager] Hot reload complete. Certificate expires in ${certInfo.daysRemaining} days.`
304
- );
305
- this.emit("reload", certInfo);
306
- } catch (error) {
307
- log.error(`[CertManager] Hot reload failed: ${error}`);
308
- this.emit("error", error);
309
- }
310
- }, this.debounceMs);
311
- }
312
- /**
313
- * Manually triggers a reload of certificates and emits the 'reload' event.
314
- */
315
- reload() {
316
- this.loadCertificates();
317
- const certInfo = this.inspectCertificate();
318
- log.info(
319
- `[CertManager] Hot reload complete. Certificate expires in ${certInfo.daysRemaining} days.`
320
- );
321
- this.emit("reload", certInfo);
322
- return certInfo;
323
- }
324
- getRootCert() {
325
- return this.rootCertBuffer;
326
- }
327
- getCertChain() {
328
- if (!this.certChainBuffer) {
329
- throw new Error("[CertManager] Certificate chain not loaded.");
330
- }
331
- return this.certChainBuffer;
332
- }
333
- getPrivateKey() {
334
- if (!this.privateKeyBuffer) {
335
- throw new Error("[CertManager] Private key not loaded.");
336
- }
337
- return this.privateKeyBuffer;
338
- }
339
- /**
340
- * Stops all active file watchers and releases resources.
341
- */
342
- dispose() {
343
- if (this.reloadDebounceTimer) {
344
- clearTimeout(this.reloadDebounceTimer);
345
- this.reloadDebounceTimer = null;
346
- }
347
- for (const watcher of this.watchers) {
348
- try {
349
- watcher.close();
350
- } catch {
351
- }
352
- }
353
- this.watchers = [];
354
- this.removeAllListeners();
355
- }
356
- };
357
-
358
- export { CertManager, ErrorCode, LiopError, LiopTracer, defaultTracer, generateSystemInstructions };
359
- //# sourceMappingURL=index.js.map
43
+ `),e}a(Bt,"generateSystemInstructions");var x=class extends EventEmitter{constructor(e){super();this.options=e;this.warningDays=e.warningDays??30,this.debounceMs=e.debounceMs??150,this.loadCertificates(),e.watchFiles!==false&&this.setupWatchers();}options;static{a(this,"CertManager");}rootCertBuffer=null;certChainBuffer=null;privateKeyBuffer=null;watchers=[];reloadDebounceTimer=null;warningDays;debounceMs;loadCertificates(){try{if(this.options.rootCertPath&&i.existsSync(this.options.rootCertPath)&&(this.rootCertBuffer=i.readFileSync(this.options.rootCertPath)),!i.existsSync(this.options.certChainPath))throw new Error(`Certificate chain file not found: ${this.options.certChainPath}`);if(!i.existsSync(this.options.privateKeyPath))throw new Error(`Private key file not found: ${this.options.privateKeyPath}`);this.certChainBuffer=i.readFileSync(this.options.certChainPath),this.privateKeyBuffer=i.readFileSync(this.options.privateKeyPath),b.info("[CertManager] Certificates loaded successfully.");}catch(e){throw b.error(`[CertManager] Failed to load certificates: ${e}`),e}}inspectCertificate(){if(!this.certChainBuffer)throw new Error("[CertManager] No certificate loaded to inspect.");let e=new h.X509Certificate(this.certChainBuffer),r=new Date(e.validTo),a=new Date,c=r.getTime()-a.getTime(),l=Math.max(0,Math.floor(c/(1e3*60*60*24))),m=c<=0,o=l<=this.warningDays;return {subject:e.subject,issuer:e.issuer,validFrom:e.validFrom,validTo:e.validTo,fingerprint256:e.fingerprint256,daysRemaining:l,isExpired:m,isExpiringSoon:o}}setupWatchers(){let e=[this.options.certChainPath,this.options.privateKeyPath,this.options.rootCertPath].filter(r=>!!(r&&i.existsSync(r)));for(let r of e)try{let a=i.watch(r,()=>{this.scheduleReload();});this.watchers.push(a);}catch(a){b.warn(`[CertManager] Could not watch ${r} for hot reloading: ${a}`);}}scheduleReload(){this.reloadDebounceTimer&&clearTimeout(this.reloadDebounceTimer),this.reloadDebounceTimer=setTimeout(()=>{try{this.loadCertificates();let e=this.inspectCertificate();b.info(`[CertManager] Hot reload complete. Certificate expires in ${e.daysRemaining} days.`),this.emit("reload",e);}catch(e){b.error(`[CertManager] Hot reload failed: ${e}`),this.emit("error",e);}},this.debounceMs);}reload(){this.loadCertificates();let e=this.inspectCertificate();return b.info(`[CertManager] Hot reload complete. Certificate expires in ${e.daysRemaining} days.`),this.emit("reload",e),e}getRootCert(){return this.rootCertBuffer}getCertChain(){if(!this.certChainBuffer)throw new Error("[CertManager] Certificate chain not loaded.");return this.certChainBuffer}getPrivateKey(){if(!this.privateKeyBuffer)throw new Error("[CertManager] Private key not loaded.");return this.privateKeyBuffer}dispose(){this.reloadDebounceTimer&&(clearTimeout(this.reloadDebounceTimer),this.reloadDebounceTimer=null);for(let e of this.watchers)try{e.close();}catch{}this.watchers=[],this.removeAllListeners();}};export{x as CertManager,A as ErrorCode,y as LiopError,g as LiopTracer,Mt as defaultTracer,Bt as generateSystemInstructions};//# sourceMappingURL=index.js.map
360
44
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export{a as Kyber768Wrapper}from'./chunk-Y675R34Z.js';import'./chunk-AYDF3IFZ.js';//# sourceMappingURL=kyber-PULV7PQX.js.map
2
+ //# sourceMappingURL=kyber-PULV7PQX.js.map
package/dist/mesh.js CHANGED
@@ -1,6 +1,2 @@
1
- import './chunk-FTF6AMF6.js';
2
- export { SWARM_KEY_BYTE_LENGTH, createSwarmKey, deserializeSwarmKey, loadSwarmKey, parseSwarmKey, saveSwarmKey, serializeSwarmKey } from './chunk-ZP3VVXOI.js';
3
- export { MeshNode } from './chunk-IHKKWXHJ.js';
4
- import './chunk-K3DGJLUY.js';
5
- //# sourceMappingURL=mesh.js.map
1
+ import'./chunk-FTF6AMF6.js';export{a as SWARM_KEY_BYTE_LENGTH,b as createSwarmKey,d as deserializeSwarmKey,g as loadSwarmKey,e as parseSwarmKey,f as saveSwarmKey,c as serializeSwarmKey}from'./chunk-YLCNV764.js';export{a as MeshNode}from'./chunk-V35CXJQN.js';import'./chunk-3WRKTVOF.js';import'./chunk-AYDF3IFZ.js';//# sourceMappingURL=mesh.js.map
6
2
  //# sourceMappingURL=mesh.js.map
package/dist/server.js CHANGED
@@ -1,11 +1,2 @@
1
- export { LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner } from './chunk-ZU3WVVLC.js';
2
- export { sanitizeOutput } from './chunk-Y62GORQF.js';
3
- import './chunk-NXCAFF73.js';
4
- import './chunk-3664H3CV.js';
5
- import './chunk-JPWC6XG6.js';
6
- import './chunk-Q3FKHJ3B.js';
7
- import './chunk-FIVRGOA4.js';
8
- import './chunk-IHKKWXHJ.js';
9
- import './chunk-K3DGJLUY.js';
10
- //# sourceMappingURL=server.js.map
1
+ export{m as LiopServer,i as NerScanner,j as PII_PATTERNS,k as PII_PRESETS,l as PiiScanner}from'./chunk-YD2AF2M6.js';export{a as sanitizeOutput}from'./chunk-MQ5SU26J.js';import'./chunk-XLVEDKM6.js';import'./chunk-2ZYX736J.js';import'./chunk-ECRS6N33.js';import'./chunk-ZZMSFCJP.js';import'./chunk-6VK2XALI.js';import'./chunk-V35CXJQN.js';import'./chunk-3WRKTVOF.js';import'./chunk-AYDF3IFZ.js';//# sourceMappingURL=server.js.map
11
2
  //# sourceMappingURL=server.js.map
package/dist/types.js CHANGED
@@ -1,4 +1,2 @@
1
- export { MCP_LEGACY_SUPPORT_ENABLED, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_LEGACY, PromptSchema, ResourceSchema, ToolSchema } from './chunk-KR5UZUEY.js';
2
- export { ProofType, RECEIPT_VERSION_V1, RECEIPT_VERSION_V2, ZK_JOURNAL_V2_SIZE } from './chunk-FIVRGOA4.js';
3
- //# sourceMappingURL=types.js.map
1
+ export{a as MCP_LEGACY_SUPPORT_ENABLED,h as MCP_PROTOCOL_VERSION,b as MCP_PROTOCOL_VERSION_LEGACY,k as PromptSchema,j as ResourceSchema,i as ToolSchema}from'./chunk-GWVSCZUS.js';export{a as ProofType,b as RECEIPT_VERSION_V1,c as RECEIPT_VERSION_V2,d as ZK_JOURNAL_V2_SIZE}from'./chunk-6VK2XALI.js';import'./chunk-AYDF3IFZ.js';//# sourceMappingURL=types.js.map
4
2
  //# sourceMappingURL=types.js.map
@@ -0,0 +1,2 @@
1
+ export{a as LiopVerifier}from'./chunk-6KFKO6ZX.js';import'./chunk-TKLRW52V.js';import'./chunk-ZZMSFCJP.js';import'./chunk-3WRKTVOF.js';import'./chunk-AYDF3IFZ.js';//# sourceMappingURL=verifier-J4NQYZX5.js.map
2
+ //# sourceMappingURL=verifier-J4NQYZX5.js.map