@nekzus/liop 2.4.0-alpha.24 → 2.4.0-alpha.26

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 (109) hide show
  1. package/README.md +21 -10
  2. package/dist/bin/agent.js +27 -932
  3. package/dist/bridge.d.ts +3 -3
  4. package/dist/bridge.js +1 -5
  5. package/dist/chunk-2XHSALII.js +3 -0
  6. package/dist/chunk-2ZYX736J.js +2 -0
  7. package/dist/chunk-3WRKTVOF.js +2 -0
  8. package/dist/chunk-6KFKO6ZX.js +2 -0
  9. package/dist/chunk-6VK2XALI.js +2 -0
  10. package/dist/chunk-AYDF3IFZ.js +2 -0
  11. package/dist/chunk-CTTTLCGL.js +31 -0
  12. package/dist/chunk-ECRS6N33.js +4 -0
  13. package/dist/chunk-FDJMH4CB.js +2 -0
  14. package/dist/chunk-FTF6AMF6.js +0 -1
  15. package/dist/chunk-GWVSCZUS.js +2 -0
  16. package/dist/chunk-LEXMMIQI.js +15 -0
  17. package/dist/chunk-LM26HOJ6.js +31 -0
  18. package/dist/chunk-MQ5SU26J.js +2 -0
  19. package/dist/chunk-N35BC62H.js +2 -0
  20. package/dist/chunk-P6IJ3VBD.js +3 -0
  21. package/dist/chunk-TKLRW52V.js +2 -0
  22. package/dist/chunk-V35CXJQN.js +2 -0
  23. package/dist/chunk-WP5ER7RH.js +3 -0
  24. package/dist/chunk-XLVEDKM6.js +2 -0
  25. package/dist/chunk-Y675R34Z.js +2 -0
  26. package/dist/chunk-YD2AF2M6.js +46 -0
  27. package/dist/chunk-YLCNV764.js +3 -0
  28. package/dist/chunk-ZZMSFCJP.js +3 -0
  29. package/dist/client.d.ts +4 -4
  30. package/dist/client.js +1 -12
  31. package/dist/gateway.d.ts +5 -5
  32. package/dist/gateway.js +1 -12
  33. package/dist/{hybrid-Cb95yJFg.d.ts → hybrid-BZpCiUaV.d.ts} +3 -3
  34. package/dist/{index-DtovobWb.d.ts → index-BYDtRGue.d.ts} +3 -3
  35. package/dist/{index-D2P6Z_hP.d.ts → index-ByzjpRCk.d.ts} +6 -1
  36. package/dist/index.d.ts +15 -10
  37. package/dist/index.js +4 -319
  38. package/dist/kyber-PULV7PQX.js +2 -0
  39. package/dist/mesh.js +1 -5
  40. package/dist/server.d.ts +3 -3
  41. package/dist/server.js +1 -9
  42. package/dist/{types-rxL19f0l.d.ts → types-29zv9X1V.d.ts} +1 -1
  43. package/dist/types.d.ts +2 -2
  44. package/dist/types.js +1 -3
  45. package/dist/{verifier-EgKmGrh7.d.ts → verifier-DqZ9MQ9l.d.ts} +34 -5
  46. package/dist/verifier-J4NQYZX5.js +2 -0
  47. package/dist/workers/logic-execution.d.ts +2 -1
  48. package/dist/workers/logic-execution.js +1 -326
  49. package/dist/workers/zk-verifier.d.ts +1 -1
  50. package/dist/workers/zk-verifier.js +1 -245
  51. package/dist/{zk-CYImPsa6.d.ts → zk-DzYNWBgo.d.ts} +14 -1
  52. package/package.json +6 -2
  53. package/dist/bin/agent.js.map +0 -1
  54. package/dist/bridge.js.map +0 -1
  55. package/dist/chunk-2VQS2XRH.js +0 -564
  56. package/dist/chunk-2VQS2XRH.js.map +0 -1
  57. package/dist/chunk-3QH44NKZ.js +0 -115
  58. package/dist/chunk-3QH44NKZ.js.map +0 -1
  59. package/dist/chunk-53QKIQNF.js +0 -818
  60. package/dist/chunk-53QKIQNF.js.map +0 -1
  61. package/dist/chunk-7BSCUYUE.js +0 -421
  62. package/dist/chunk-7BSCUYUE.js.map +0 -1
  63. package/dist/chunk-7PITYWOV.js +0 -68
  64. package/dist/chunk-7PITYWOV.js.map +0 -1
  65. package/dist/chunk-FTF6AMF6.js.map +0 -1
  66. package/dist/chunk-GFGSHQN5.js +0 -206884
  67. package/dist/chunk-GFGSHQN5.js.map +0 -1
  68. package/dist/chunk-IDTXJQBH.js +0 -1506
  69. package/dist/chunk-IDTXJQBH.js.map +0 -1
  70. package/dist/chunk-IHKKWXHJ.js +0 -876
  71. package/dist/chunk-IHKKWXHJ.js.map +0 -1
  72. package/dist/chunk-IK7CGWAZ.js +0 -24
  73. package/dist/chunk-IK7CGWAZ.js.map +0 -1
  74. package/dist/chunk-JWFLXXZS.js +0 -3743
  75. package/dist/chunk-JWFLXXZS.js.map +0 -1
  76. package/dist/chunk-K3DGJLUY.js +0 -106
  77. package/dist/chunk-K3DGJLUY.js.map +0 -1
  78. package/dist/chunk-KR5UZUEY.js +0 -98
  79. package/dist/chunk-KR5UZUEY.js.map +0 -1
  80. package/dist/chunk-OHMZZMMC.js +0 -58
  81. package/dist/chunk-OHMZZMMC.js.map +0 -1
  82. package/dist/chunk-P34HDRN5.js +0 -213
  83. package/dist/chunk-P34HDRN5.js.map +0 -1
  84. package/dist/chunk-Q3FKHJ3B.js +0 -345
  85. package/dist/chunk-Q3FKHJ3B.js.map +0 -1
  86. package/dist/chunk-V47P2AQR.js +0 -281
  87. package/dist/chunk-V47P2AQR.js.map +0 -1
  88. package/dist/chunk-WPTOJYN5.js +0 -181
  89. package/dist/chunk-WPTOJYN5.js.map +0 -1
  90. package/dist/chunk-Y62GORQF.js +0 -51
  91. package/dist/chunk-Y62GORQF.js.map +0 -1
  92. package/dist/chunk-ZJGVKM7G.js +0 -803
  93. package/dist/chunk-ZJGVKM7G.js.map +0 -1
  94. package/dist/chunk-ZP3VVXOI.js +0 -66
  95. package/dist/chunk-ZP3VVXOI.js.map +0 -1
  96. package/dist/chunk-ZRWNMP5L.js +0 -165
  97. package/dist/chunk-ZRWNMP5L.js.map +0 -1
  98. package/dist/client.js.map +0 -1
  99. package/dist/gateway.js.map +0 -1
  100. package/dist/index.js.map +0 -1
  101. package/dist/kyber-CGOA7Q6A.js +0 -3
  102. package/dist/kyber-CGOA7Q6A.js.map +0 -1
  103. package/dist/mesh.js.map +0 -1
  104. package/dist/server.js.map +0 -1
  105. package/dist/types.js.map +0 -1
  106. package/dist/verifier-UBJTZQSA.js +0 -6
  107. package/dist/verifier-UBJTZQSA.js.map +0 -1
  108. package/dist/workers/logic-execution.js.map +0 -1
  109. package/dist/workers/zk-verifier.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,147 +1,4 @@
1
- export { WasiSandbox, calculateAstInstructionFuel, getDefaultEnvironment } from './chunk-7BSCUYUE.js';
2
- export { VERIFICATION_LATENCY_BUDGET_MS, deserializeGrothProof, deserializeVKey, serializeGrothProof, serializeVKey, verifyGroth16Proof } from './chunk-OHMZZMMC.js';
3
- export { AesGcmWrapper, LiopClient, LiopRpcClient } from './chunk-ZJGVKM7G.js';
4
- export { LiopMcpBridge, LiopStreamBridge } from './chunk-2VQS2XRH.js';
5
- export { GRPC_WEB_CONSTANTS, InMemoryRateLimiter, LiopHybridGateway, buildProtectedResourceMetadata, decodeFrames, dispatchGrpcWebRequest, encodeDataFrame, encodeTrailerFrame, executeGatewayInterceptor, isGrpcWebRequest } from './chunk-53QKIQNF.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-JWFLXXZS.js';
9
- export { sanitizeOutput } from './chunk-Y62GORQF.js';
10
- export { LiopMcpRouter } from './chunk-IDTXJQBH.js';
11
- export { LiopVerifier } from './chunk-ZRWNMP5L.js';
12
- import './chunk-IK7CGWAZ.js';
13
- export { Kyber768Wrapper } from './chunk-7PITYWOV.js';
14
- export { DILITHIUM65_CONSTANTS, Dilithium65Wrapper, LIOP_SCOPES, authorizeRequest } from './chunk-WPTOJYN5.js';
15
- export { GRPC_CHANNEL_OPTIONS, HeuristicTokenEstimator, LiopOTelBridge, RealTokenEstimator, TokenTelemetryEngine, createChannelCredentials, createServerCredentials, createSyncTokenEstimator, createTokenEstimator } from './chunk-GFGSHQN5.js';
16
- 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';
17
- export { MCP_LEGACY_SUPPORT_ENABLED, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_LEGACY, PromptSchema, ResourceSchema, ToolSchema } from './chunk-KR5UZUEY.js';
18
- export { ProofType, RECEIPT_VERSION_V1, RECEIPT_VERSION_V2, ZK_JOURNAL_V2_SIZE, ZkVerificationError, ZkVerifier, decodeJournalV2, encodeJournalV2, receiptCodec } from './chunk-P34HDRN5.js';
19
- export { SWARM_KEY_BYTE_LENGTH, createSwarmKey, deserializeSwarmKey, loadSwarmKey, parseSwarmKey, saveSwarmKey, serializeSwarmKey } from './chunk-ZP3VVXOI.js';
20
- export { MeshNode } from './chunk-IHKKWXHJ.js';
21
- import { log } from './chunk-K3DGJLUY.js';
22
- export { LiopLogger, log } from './chunk-K3DGJLUY.js';
23
- import * as crypto from 'crypto';
24
- import { EventEmitter } from 'events';
25
- import * as fs from 'fs';
26
-
27
- // src/errors.ts
28
- var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
29
- ErrorCode2["CapabilityViolation"] = "CapabilityViolation";
30
- ErrorCode2["SandboxEscape"] = "SandboxEscape";
31
- ErrorCode2["PiiLeak"] = "PiiLeak";
32
- ErrorCode2["InvalidIntent"] = "InvalidIntent";
33
- ErrorCode2["Throttled"] = "Throttled";
34
- ErrorCode2["ZkVerificationFailed"] = "ZkVerificationFailed";
35
- ErrorCode2["MeshUnavailable"] = "MeshUnavailable";
36
- ErrorCode2["ConnectionFailed"] = "ConnectionFailed";
37
- return ErrorCode2;
38
- })(ErrorCode || {});
39
- var LiopError = class extends Error {
40
- code;
41
- constructor(code, message) {
42
- super(message);
43
- this.name = "LiopError";
44
- this.code = code;
45
- }
46
- };
47
- var TRACEPARENT_REGEX = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/;
48
- var LiopTracer = class _LiopTracer {
49
- static generateTraceId() {
50
- let id;
51
- do {
52
- id = crypto.randomBytes(16).toString("hex");
53
- } while (id === "0".repeat(32));
54
- return id;
55
- }
56
- static generateSpanId() {
57
- let id;
58
- do {
59
- id = crypto.randomBytes(8).toString("hex");
60
- } while (id === "0".repeat(16));
61
- return id;
62
- }
63
- static formatTraceparent(traceId, spanId, sampled = true) {
64
- const flags = sampled ? "01" : "00";
65
- return `00-${traceId}-${spanId}-${flags}`;
66
- }
67
- static parseTraceparent(header) {
68
- if (!header || typeof header !== "string") {
69
- return null;
70
- }
71
- const trimmed = header.trim();
72
- const match = TRACEPARENT_REGEX.exec(trimmed);
73
- if (!match) {
74
- return null;
75
- }
76
- const [, version, traceId, spanId, flags] = match;
77
- if (version === "00") {
78
- if (traceId === "0".repeat(32) || spanId === "0".repeat(16)) {
79
- return null;
80
- }
81
- }
82
- const sampled = (Number.parseInt(flags, 16) & 1) === 1;
83
- return {
84
- traceId,
85
- spanId,
86
- sampled
87
- };
88
- }
89
- static injectTraceparent(carrier, context) {
90
- carrier.traceparent = _LiopTracer.formatTraceparent(
91
- context.traceId,
92
- context.spanId,
93
- context.sampled
94
- );
95
- }
96
- static extractTraceparent(carrier) {
97
- const val = carrier.traceparent || carrier.Traceparent;
98
- if (Array.isArray(val)) {
99
- return _LiopTracer.parseTraceparent(val[0]);
100
- }
101
- return _LiopTracer.parseTraceparent(val);
102
- }
103
- startSpan(name, parent, attributes = {}) {
104
- const traceId = parent?.traceId || _LiopTracer.generateTraceId();
105
- const spanId = _LiopTracer.generateSpanId();
106
- const sampled = parent ? parent.sampled : true;
107
- const context = {
108
- traceId,
109
- spanId,
110
- sampled
111
- };
112
- const span = {
113
- name,
114
- context,
115
- startTime: Date.now(),
116
- attributes: { ...attributes },
117
- status: "OK",
118
- setAttribute(key, value) {
119
- this.attributes[key] = value;
120
- return this;
121
- },
122
- recordException(err) {
123
- this.status = "ERROR";
124
- this.error = typeof err === "string" ? err : err.message;
125
- return this;
126
- },
127
- end() {
128
- this.endTime = Date.now();
129
- }
130
- };
131
- return span;
132
- }
133
- };
134
- var defaultTracer = new LiopTracer();
135
-
136
- // src/prompts/adapters.ts
137
- var PROVIDER_CONFIGS = {
138
- claude: { xmlStandard: true, jsonSchemaPreferred: false },
139
- openai: { xmlStandard: false, jsonSchemaPreferred: true },
140
- gemini: { xmlStandard: false, jsonSchemaPreferred: true }
141
- };
142
- function generateSystemInstructions(provider) {
143
- const config = PROVIDER_CONFIGS[provider];
144
- 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]
145
2
  You are interacting with a Logic-Injection-on-Origin Protocol (LIOP) Mesh Network.
146
3
  Unlike standard MCP where you pull context to evaluate it remotely, in LIOP you WRITE code that executes on the data's origin.
147
4
 
@@ -166,9 +23,7 @@ To prevent database reconstruction and inference attacks, numeric query outputs
166
23
  - Poisoned globals: eval, Function, setTimeout, setInterval, Buffer, ArrayBuffer, and TypedArrays are undefined.
167
24
  - Frozen prototypes: Modifications to Object.prototype, Array.prototype, etc., are blocked.
168
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.
169
- `;
170
- if (config.xmlStandard) {
171
- instructions += `
26
+ `;return t.xmlStandard?e+=`
172
27
  ### PAYLOAD FORMATTING (CLAUDE-XML PREFERRED)
173
28
  You must wrap your logic precisely within <liop_logic> tags.
174
29
  Example:
@@ -177,9 +32,7 @@ const records = await liop.readResource("liop://vault/patients");
177
32
  const filtered = records.filter(r => r.disease === "Hypertension");
178
33
  return { alert: "High risk demographic", targetCount: filtered.length };
179
34
  </liop_logic>
180
- `;
181
- } else if (config.jsonSchemaPreferred) {
182
- instructions += `
35
+ `:t.jsonSchemaPreferred&&(e+=`
183
36
  ### PAYLOAD FORMATTING (JSON PARSING PREFERRED)
184
37
  You must provide your logic strictly within a JSON string key called \`"logic_blob"\` inside your tool call parameters.
185
38
  Example:
@@ -187,173 +40,5 @@ Example:
187
40
  "target": "liop://vault/patients",
188
41
  "logic_blob": "const records = await liop.readResource(args.target); return { targetCount: records.filter(r => r.disease === 'Hypertension').length };"
189
42
  }
190
- `;
191
- }
192
- return instructions;
193
- }
194
- var CertManager = class extends EventEmitter {
195
- constructor(options) {
196
- super();
197
- this.options = options;
198
- this.warningDays = options.warningDays ?? 30;
199
- this.debounceMs = options.debounceMs ?? 150;
200
- this.loadCertificates();
201
- if (options.watchFiles !== false) {
202
- this.setupWatchers();
203
- }
204
- }
205
- options;
206
- rootCertBuffer = null;
207
- certChainBuffer = null;
208
- privateKeyBuffer = null;
209
- watchers = [];
210
- reloadDebounceTimer = null;
211
- warningDays;
212
- debounceMs;
213
- /**
214
- * Synchronously loads or reloads certificates from filesystem into memory.
215
- */
216
- loadCertificates() {
217
- try {
218
- if (this.options.rootCertPath && fs.existsSync(this.options.rootCertPath)) {
219
- this.rootCertBuffer = fs.readFileSync(this.options.rootCertPath);
220
- }
221
- if (!fs.existsSync(this.options.certChainPath)) {
222
- throw new Error(
223
- `Certificate chain file not found: ${this.options.certChainPath}`
224
- );
225
- }
226
- if (!fs.existsSync(this.options.privateKeyPath)) {
227
- throw new Error(
228
- `Private key file not found: ${this.options.privateKeyPath}`
229
- );
230
- }
231
- this.certChainBuffer = fs.readFileSync(this.options.certChainPath);
232
- this.privateKeyBuffer = fs.readFileSync(this.options.privateKeyPath);
233
- log.info("[CertManager] Certificates loaded successfully.");
234
- } catch (error) {
235
- log.error(`[CertManager] Failed to load certificates: ${error}`);
236
- throw error;
237
- }
238
- }
239
- /**
240
- * Inspects the loaded server/client certificate chain using Node.js native X509Certificate.
241
- */
242
- inspectCertificate() {
243
- if (!this.certChainBuffer) {
244
- throw new Error("[CertManager] No certificate loaded to inspect.");
245
- }
246
- const x509 = new crypto.X509Certificate(this.certChainBuffer);
247
- const validToDate = new Date(x509.validTo);
248
- const now = /* @__PURE__ */ new Date();
249
- const msRemaining = validToDate.getTime() - now.getTime();
250
- const daysRemaining = Math.max(
251
- 0,
252
- Math.floor(msRemaining / (1e3 * 60 * 60 * 24))
253
- );
254
- const isExpired = msRemaining <= 0;
255
- const isExpiringSoon = daysRemaining <= this.warningDays;
256
- return {
257
- subject: x509.subject,
258
- issuer: x509.issuer,
259
- validFrom: x509.validFrom,
260
- validTo: x509.validTo,
261
- fingerprint256: x509.fingerprint256,
262
- daysRemaining,
263
- isExpired,
264
- isExpiringSoon
265
- };
266
- }
267
- /**
268
- * Sets up non-blocking filesystem watchers to detect certificate renewals
269
- * and trigger hot-reloading without process restarts.
270
- */
271
- setupWatchers() {
272
- const filesToWatch = [
273
- this.options.certChainPath,
274
- this.options.privateKeyPath,
275
- this.options.rootCertPath
276
- ].filter((p) => Boolean(p && fs.existsSync(p)));
277
- for (const filePath of filesToWatch) {
278
- try {
279
- const watcher = fs.watch(filePath, () => {
280
- this.scheduleReload();
281
- });
282
- this.watchers.push(watcher);
283
- } catch (err) {
284
- log.warn(
285
- `[CertManager] Could not watch ${filePath} for hot reloading: ${err}`
286
- );
287
- }
288
- }
289
- }
290
- /**
291
- * Debounces reload events to ensure files have finished writing.
292
- */
293
- scheduleReload() {
294
- if (this.reloadDebounceTimer) {
295
- clearTimeout(this.reloadDebounceTimer);
296
- }
297
- this.reloadDebounceTimer = setTimeout(() => {
298
- try {
299
- this.loadCertificates();
300
- const certInfo = this.inspectCertificate();
301
- log.info(
302
- `[CertManager] Hot reload complete. Certificate expires in ${certInfo.daysRemaining} days.`
303
- );
304
- this.emit("reload", certInfo);
305
- } catch (error) {
306
- log.error(`[CertManager] Hot reload failed: ${error}`);
307
- this.emit("error", error);
308
- }
309
- }, this.debounceMs);
310
- }
311
- /**
312
- * Manually triggers a reload of certificates and emits the 'reload' event.
313
- */
314
- reload() {
315
- this.loadCertificates();
316
- const certInfo = this.inspectCertificate();
317
- log.info(
318
- `[CertManager] Hot reload complete. Certificate expires in ${certInfo.daysRemaining} days.`
319
- );
320
- this.emit("reload", certInfo);
321
- return certInfo;
322
- }
323
- getRootCert() {
324
- return this.rootCertBuffer;
325
- }
326
- getCertChain() {
327
- if (!this.certChainBuffer) {
328
- throw new Error("[CertManager] Certificate chain not loaded.");
329
- }
330
- return this.certChainBuffer;
331
- }
332
- getPrivateKey() {
333
- if (!this.privateKeyBuffer) {
334
- throw new Error("[CertManager] Private key not loaded.");
335
- }
336
- return this.privateKeyBuffer;
337
- }
338
- /**
339
- * Stops all active file watchers and releases resources.
340
- */
341
- dispose() {
342
- if (this.reloadDebounceTimer) {
343
- clearTimeout(this.reloadDebounceTimer);
344
- this.reloadDebounceTimer = null;
345
- }
346
- for (const watcher of this.watchers) {
347
- try {
348
- watcher.close();
349
- } catch {
350
- }
351
- }
352
- this.watchers = [];
353
- this.removeAllListeners();
354
- }
355
- };
356
-
357
- export { CertManager, ErrorCode, LiopError, LiopTracer, defaultTracer, generateSystemInstructions };
358
- //# 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
359
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.d.ts CHANGED
@@ -1,6 +1,6 @@
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-D2P6Z_hP.js';
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-ByzjpRCk.js';
2
2
  import 'zod';
3
3
  import './node-Djzm6UYd.js';
4
- import './types-rxL19f0l.js';
5
- import './zk-CYImPsa6.js';
4
+ import './types-29zv9X1V.js';
5
+ import './zk-DzYNWBgo.js';
6
6
  import 'jose';
package/dist/server.js CHANGED
@@ -1,10 +1,2 @@
1
- export { LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner } from './chunk-JWFLXXZS.js';
2
- export { sanitizeOutput } from './chunk-Y62GORQF.js';
3
- import './chunk-WPTOJYN5.js';
4
- import './chunk-GFGSHQN5.js';
5
- import './chunk-Q3FKHJ3B.js';
6
- import './chunk-P34HDRN5.js';
7
- import './chunk-IHKKWXHJ.js';
8
- import './chunk-K3DGJLUY.js';
9
- //# 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
10
2
  //# sourceMappingURL=server.js.map
@@ -1,4 +1,4 @@
1
- import { P as ProofType } from './zk-CYImPsa6.js';
1
+ import { P as ProofType } from './zk-DzYNWBgo.js';
2
2
  import { z } from 'zod';
3
3
  import * as jose from 'jose';
4
4
 
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { P as ProofType, R as RECEIPT_VERSION_V1, a as RECEIPT_VERSION_V2, b as ZK_JOURNAL_V2_SIZE, c as ZkJournalV2, Z as ZkPolicy, d as ZkReceipt } from './zk-CYImPsa6.js';
1
+ export { P as ProofType, R as RECEIPT_VERSION_V1, a as RECEIPT_VERSION_V2, b as ZK_JOURNAL_V2_SIZE, c as ZkJournalV2, Z as ZkPolicy, d as ZkReceipt } from './zk-DzYNWBgo.js';
2
2
  import 'zod';
3
- export { h as AuditInterceptor, A as AuthInfo, k as CacheableResult, C as CallToolRequest, a as CallToolResult, D as DiscoverResult, m as GatewayAdmissionResult, n as GatewayInterceptor, o as GatewayInterceptorContext, G as GatewayInterceptorOptions, e as GetPromptRequest, f as GetPromptResult, I as InputRequest, p as InputRequiredResult, q as InputResponse, r as LogEvent, s as LogInterceptor, u as MCP_LEGACY_SUPPORT_ENABLED, v as MCP_PROTOCOL_VERSION, w as MCP_PROTOCOL_VERSION_LEGACY, M as McpEra, b as McpRequest, x as McpRequestMeta, c as McpResponse, P as Prompt, y as PromptSchema, R as Resource, z as ResourceSchema, S as ServerInfo, T as Tool, B as ToolSchema } from './types-rxL19f0l.js';
3
+ export { h as AuditInterceptor, A as AuthInfo, k as CacheableResult, C as CallToolRequest, a as CallToolResult, D as DiscoverResult, m as GatewayAdmissionResult, n as GatewayInterceptor, o as GatewayInterceptorContext, G as GatewayInterceptorOptions, e as GetPromptRequest, f as GetPromptResult, I as InputRequest, p as InputRequiredResult, q as InputResponse, r as LogEvent, s as LogInterceptor, u as MCP_LEGACY_SUPPORT_ENABLED, v as MCP_PROTOCOL_VERSION, w as MCP_PROTOCOL_VERSION_LEGACY, M as McpEra, b as McpRequest, x as McpRequestMeta, c as McpResponse, P as Prompt, y as PromptSchema, R as Resource, z as ResourceSchema, S as ServerInfo, T as Tool, B as ToolSchema } from './types-29zv9X1V.js';
4
4
  import 'jose';
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-P34HDRN5.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
@@ -1,5 +1,28 @@
1
- import { Z as ZkPolicy } from './zk-CYImPsa6.js';
1
+ import { Z as ZkPolicy } from './zk-DzYNWBgo.js';
2
2
 
3
+ type TeePolicy = "required" | "preferred" | "none";
4
+ interface TeeVerificationOptions {
5
+ /** Enforcement policy for TEE attestation */
6
+ policy?: TeePolicy;
7
+ /** Expected cryptographic nonce used during negotiateIntent handshake */
8
+ expectedNonce?: Buffer | Uint8Array;
9
+ /** Expected enclave public key (e.g. ML-KEM-768 public key) */
10
+ expectedPublicKey?: Buffer | Uint8Array;
11
+ /** Expected platform configuration registers (PCRs) */
12
+ expectedPcrs?: Record<number, string>;
13
+ /** Allow synthetic / mesh PSK proofs in non-hardware environments */
14
+ allowSynthetic?: boolean;
15
+ }
16
+ interface TeeVerificationResult {
17
+ verified: boolean;
18
+ platform: "amd-sev-snp" | "aws-nitro" | "intel-tdx" | "synthetic" | "none";
19
+ message: string;
20
+ measurements?: {
21
+ reportDataHex?: string;
22
+ measurementHex?: string;
23
+ chipIdHex?: string;
24
+ };
25
+ }
3
26
  interface VerifyZkOptions {
4
27
  sessionSecret?: Buffer;
5
28
  expectedOutput?: unknown;
@@ -39,15 +62,21 @@ declare class LiopVerifier {
39
62
  */
40
63
  verifyZkReceipt(logicPayload: Buffer, remoteImageIdHex: string, zkReceipt: Buffer, sessionSecretOrOptions?: Buffer | VerifyZkOptions, expectedOutput?: unknown): Promise<boolean>;
41
64
  /**
42
- * Verifies if a node is running inside an authenticated TEE (e.g. AWS Nitro).
65
+ * Detailed hardware attestation verification supporting AMD SEV-SNP, AWS Nitro Enclaves,
66
+ * and synthetic mesh verification.
67
+ */
68
+ verifyTeeAttestationDetailed(attestationReport: Buffer, options?: TeeVerificationOptions): Promise<TeeVerificationResult>;
69
+ /**
70
+ * Verifies if a node is running inside an authenticated TEE (e.g. AMD SEV-SNP or AWS Nitro).
43
71
  *
44
- * @param attestationReport The COSE-signed attestation document from the hardware.
72
+ * @param attestationReport The attestation document from the hardware.
73
+ * @param options Verification policy and binding options.
45
74
  */
46
- verifyTeeAttestation(attestationReport: Buffer): Promise<boolean>;
75
+ verifyTeeAttestation(attestationReport: Buffer, options?: TeeVerificationOptions): Promise<boolean>;
47
76
  /**
48
77
  * Derives the ImageID of a logic payload following the LIOP v1 Standard.
49
78
  */
50
79
  deriveImageId(logicPayload: Buffer): Buffer;
51
80
  }
52
81
 
53
- export { LiopVerifier as L, type VerifyZkOptions as V };
82
+ export { LiopVerifier as L, type TeePolicy as T, type VerifyZkOptions as V, type TeeVerificationOptions as a, type TeeVerificationResult as b };
@@ -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
@@ -1,4 +1,4 @@
1
- import { P as ProofType } from '../zk-CYImPsa6.js';
1
+ import { P as ProofType } from '../zk-DzYNWBgo.js';
2
2
 
3
3
  interface WorkerData {
4
4
  isWarmup?: boolean;
@@ -14,6 +14,7 @@ interface WorkerData {
14
14
  aesNonce?: Uint8Array;
15
15
  proofMode?: number;
16
16
  guestImageId?: string;
17
+ pqcSigningKey?: Uint8Array;
17
18
  dpConfig?: {
18
19
  epsilon: number;
19
20
  sensitivity: number;