@nekzus/liop 2.5.0-beta.1 → 2.5.0-beta.3

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 (104) hide show
  1. package/NOTICE +19 -0
  2. package/README.md +148 -69
  3. package/dist/bin/agent.js +27 -303
  4. package/dist/bridge.d.ts +4 -3
  5. package/dist/bridge.js +1 -4
  6. package/dist/chunk-2XHSALII.js +3 -0
  7. package/dist/chunk-2ZYX736J.js +2 -0
  8. package/dist/chunk-3WRKTVOF.js +2 -0
  9. package/dist/chunk-6KFKO6ZX.js +2 -0
  10. package/dist/chunk-6VK2XALI.js +2 -0
  11. package/dist/chunk-AYDF3IFZ.js +2 -0
  12. package/dist/chunk-CTTTLCGL.js +31 -0
  13. package/dist/chunk-ECRS6N33.js +4 -0
  14. package/dist/chunk-FDJMH4CB.js +2 -0
  15. package/dist/chunk-FTF6AMF6.js +2 -0
  16. package/dist/chunk-GWVSCZUS.js +2 -0
  17. package/dist/chunk-LEXMMIQI.js +15 -0
  18. package/dist/chunk-LM26HOJ6.js +31 -0
  19. package/dist/chunk-MQ5SU26J.js +2 -0
  20. package/dist/chunk-N35BC62H.js +2 -0
  21. package/dist/chunk-P6IJ3VBD.js +3 -0
  22. package/dist/chunk-TKLRW52V.js +2 -0
  23. package/dist/chunk-V35CXJQN.js +2 -0
  24. package/dist/chunk-WP5ER7RH.js +3 -0
  25. package/dist/chunk-XLVEDKM6.js +2 -0
  26. package/dist/chunk-Y675R34Z.js +2 -0
  27. package/dist/chunk-YD2AF2M6.js +46 -0
  28. package/dist/chunk-YLCNV764.js +3 -0
  29. package/dist/chunk-ZZMSFCJP.js +3 -0
  30. package/dist/client.d.ts +6 -4
  31. package/dist/client.js +1 -9
  32. package/dist/gateway.d.ts +6 -5
  33. package/dist/gateway.js +1 -10
  34. package/dist/{hybrid-CF__0YnC.d.ts → hybrid-BZpCiUaV.d.ts} +6 -5
  35. package/dist/{index-cMV0_yD9.d.ts → index-BYDtRGue.d.ts} +45 -36
  36. package/dist/{index-BW95kAL4.d.ts → index-ByzjpRCk.d.ts} +37 -72
  37. package/dist/index.d.ts +221 -50
  38. package/dist/index.js +4 -312
  39. package/dist/kyber-PULV7PQX.js +2 -0
  40. package/dist/mesh.d.ts +27 -143
  41. package/dist/mesh.js +1 -4
  42. package/dist/node-Djzm6UYd.d.ts +172 -0
  43. package/dist/protocol/liop_core.proto +25 -6
  44. package/dist/server.d.ts +4 -3
  45. package/dist/server.js +1 -7
  46. package/dist/types-29zv9X1V.d.ts +455 -0
  47. package/dist/types.d.ts +2 -1
  48. package/dist/types.js +1 -2
  49. package/dist/verifier-DqZ9MQ9l.d.ts +82 -0
  50. package/dist/verifier-J4NQYZX5.js +2 -0
  51. package/dist/workers/logic-execution.d.ts +7 -0
  52. package/dist/workers/logic-execution.js +1 -271
  53. package/dist/workers/zk-verifier.d.ts +9 -0
  54. package/dist/workers/zk-verifier.js +1 -173
  55. package/dist/zk-DzYNWBgo.d.ts +104 -0
  56. package/package.json +56 -45
  57. package/dist/bin/agent.js.map +0 -1
  58. package/dist/bridge.js.map +0 -1
  59. package/dist/chunk-32ADSAJS.js +0 -104
  60. package/dist/chunk-32ADSAJS.js.map +0 -1
  61. package/dist/chunk-547TYL27.js +0 -208109
  62. package/dist/chunk-547TYL27.js.map +0 -1
  63. package/dist/chunk-72MNYFR6.js +0 -64
  64. package/dist/chunk-72MNYFR6.js.map +0 -1
  65. package/dist/chunk-74CISO2I.js +0 -853
  66. package/dist/chunk-74CISO2I.js.map +0 -1
  67. package/dist/chunk-CRZBVFDV.js +0 -616
  68. package/dist/chunk-CRZBVFDV.js.map +0 -1
  69. package/dist/chunk-GA3Q2S7O.js +0 -558
  70. package/dist/chunk-GA3Q2S7O.js.map +0 -1
  71. package/dist/chunk-JIJPZFR2.js +0 -51
  72. package/dist/chunk-JIJPZFR2.js.map +0 -1
  73. package/dist/chunk-OUUTDSOW.js +0 -24
  74. package/dist/chunk-OUUTDSOW.js.map +0 -1
  75. package/dist/chunk-PYKRQAER.js +0 -77
  76. package/dist/chunk-PYKRQAER.js.map +0 -1
  77. package/dist/chunk-QLCOEP5J.js +0 -68
  78. package/dist/chunk-QLCOEP5J.js.map +0 -1
  79. package/dist/chunk-RWRRBYG4.js +0 -3
  80. package/dist/chunk-RWRRBYG4.js.map +0 -1
  81. package/dist/chunk-SONUORBT.js +0 -421
  82. package/dist/chunk-SONUORBT.js.map +0 -1
  83. package/dist/chunk-T5IUZF47.js +0 -716
  84. package/dist/chunk-T5IUZF47.js.map +0 -1
  85. package/dist/chunk-U5BZ66VX.js +0 -447
  86. package/dist/chunk-U5BZ66VX.js.map +0 -1
  87. package/dist/chunk-WCCGE4QR.js +0 -3520
  88. package/dist/chunk-WCCGE4QR.js.map +0 -1
  89. package/dist/chunk-WSW6YJNY.js +0 -168
  90. package/dist/chunk-WSW6YJNY.js.map +0 -1
  91. package/dist/client.js.map +0 -1
  92. package/dist/gateway.js.map +0 -1
  93. package/dist/index.js.map +0 -1
  94. package/dist/kyber-3ULIJSE3.js +0 -3
  95. package/dist/kyber-3ULIJSE3.js.map +0 -1
  96. package/dist/mesh.js.map +0 -1
  97. package/dist/server.js.map +0 -1
  98. package/dist/types-lJIxBlWF.d.ts +0 -256
  99. package/dist/types.js.map +0 -1
  100. package/dist/verifier-3FAKCFNN.js +0 -5
  101. package/dist/verifier-3FAKCFNN.js.map +0 -1
  102. package/dist/verifier-COnid_dg.d.ts +0 -31
  103. package/dist/workers/logic-execution.js.map +0 -1
  104. package/dist/workers/zk-verifier.js.map +0 -1
@@ -1,17 +1,9 @@
1
- import { L as LiopVerifier } from './verifier-COnid_dg.js';
2
- import { MeshNodeConfig } from './mesh.js';
1
+ import { L as LiopVerifier } from './verifier-DqZ9MQ9l.js';
2
+ import { M as MeshNodeConfig } from './node-Djzm6UYd.js';
3
+ import * as grpc from '@grpc/grpc-js';
3
4
  import { EventEmitter } from 'node:events';
4
- import { M as McpEra, C as CallToolRequest, a as CallToolResult } from './types-lJIxBlWF.js';
5
-
6
- /**
7
- * LIOP Certificate Manager (CertManager)
8
- * Provides automated certificate monitoring, X.509 validity inspection,
9
- * and hot-reloading for mutual TLS (mTLS) without node restarts.
10
- *
11
- * Compliance:
12
- * - NIST SP 800-52 Rev. 2: Guidelines for the Selection and Use of TLS
13
- * - Zero-Trust Architecture (NIST SP 800-207): Continuous cryptographic verification
14
- */
5
+ import { Z as ZkPolicy } from './zk-DzYNWBgo.js';
6
+ import { M as McpEra, C as CallToolRequest, a as CallToolResult } from './types-29zv9X1V.js';
15
7
 
16
8
  interface CertManagerOptions {
17
9
  /** Path to the root CA certificate (PEM format) */
@@ -77,23 +69,6 @@ declare class CertManager extends EventEmitter {
77
69
  dispose(): void;
78
70
  }
79
71
 
80
- /**
81
- * LIOP TLS Configuration
82
- *
83
- * Provides conditional TLS credential factories for gRPC connections.
84
- * When TLS options are provided, connections are secured with mutual TLS.
85
- * Otherwise, falls back to insecure credentials (alpha/development mode).
86
- *
87
- * Production Hardening (Phase 128):
88
- * - When NODE_ENV=production and TLS is configured but certificate loading
89
- * fails, the system throws a fatal error instead of silently degrading
90
- * to insecure credentials. This prevents MITM/eavesdropping attacks
91
- * caused by misconfigured certificate paths going unnoticed.
92
- * - Reference: gRPC-node official docs — "Using insecure credentials in
93
- * production poses significant security risks including eavesdropping,
94
- * MITM attacks, and lack of authentication."
95
- */
96
-
97
72
  interface LiopTlsOptions {
98
73
  /** Path to the root CA certificate (PEM format) */
99
74
  rootCert?: string;
@@ -105,7 +80,28 @@ interface LiopTlsOptions {
105
80
  mutualTls?: boolean;
106
81
  /** Optional CertManager instance for automated certificate management and hot reloading */
107
82
  certManager?: CertManager;
83
+ /**
84
+ * Explicitly permit unencrypted (insecure) credentials for local development,
85
+ * Docker testbeds, or tooling harnesses without emitting console warnings.
86
+ * Ignored if isTlsEnforced() is true (production/enforced mode always throws).
87
+ */
88
+ insecure?: boolean;
89
+ /**
90
+ * Explicitly suppress the fallback warning when insecure credentials are created.
91
+ */
92
+ suppressWarning?: boolean;
108
93
  }
94
+ /**
95
+ * Creates gRPC server credentials from TLS options.
96
+ * In production or when LIOP_ENFORCE_TLS=true, refuses to fall back to insecure.
97
+ * When mutualTls=true, enforces client certificate authentication against root CA.
98
+ */
99
+ declare function createServerCredentials(tls?: LiopTlsOptions): grpc.ServerCredentials;
100
+ /**
101
+ * Creates gRPC channel credentials from TLS options.
102
+ * In production or when LIOP_ENFORCE_TLS=true, refuses to fall back to insecure.
103
+ */
104
+ declare function createChannelCredentials(tls?: LiopTlsOptions): grpc.ChannelCredentials;
109
105
 
110
106
  /**
111
107
  * LIOP Client
@@ -119,15 +115,12 @@ declare class LiopClient {
119
115
  private serverInfo?;
120
116
  verifier: LiopVerifier;
121
117
  private oauthToken?;
118
+ private tokenManager?;
122
119
  /** Protocol negotiation era */
123
120
  era: McpEra;
124
121
  /** Negotiated protocol version */
125
122
  protocolVersion: string;
126
123
  constructor(tls?: LiopTlsOptions);
127
- /**
128
- * Requests an M2M access token from the Nexus Authorization Server using Client Credentials.
129
- */
130
- private acquireM2MToken;
131
124
  /**
132
125
  * Discovers and connects to the target server or mesh capability.
133
126
  * If address is omitted, it sets up the MeshNode to act purely dynamically.
@@ -174,7 +167,10 @@ declare class LiopClient {
174
167
  /**
175
168
  * Invokes a tool.
176
169
  */
177
- callTool(request: CallToolRequest, _wasmPayload?: Buffer): Promise<CallToolResult>;
170
+ callTool(request: CallToolRequest, _wasmPayload?: Buffer, options?: {
171
+ zkPolicy?: ZkPolicy;
172
+ circuitName?: string;
173
+ }): Promise<CallToolResult>;
178
174
  private getOrCreateRpcClient;
179
175
  /**
180
176
  * Reads a specific resource by URI.
@@ -187,6 +183,19 @@ declare class LiopClient {
187
183
  text: string;
188
184
  }>;
189
185
  }>;
186
+ /**
187
+ * Returns the local PeerId string if the mesh node is active, null otherwise.
188
+ * PeerIds are public identifiers by libp2p protocol design (Ed25519 public key hash).
189
+ */
190
+ get peerId(): string | null;
191
+ /**
192
+ * Returns true if the mesh node is initialized and running.
193
+ */
194
+ get isMeshActive(): boolean;
195
+ /**
196
+ * Returns the number of active P2P connections, or 0 if the mesh is inactive.
197
+ */
198
+ get connectionCount(): number;
190
199
  getServerInfo(): {
191
200
  name: string;
192
201
  version: string;
@@ -197,4 +206,4 @@ declare class LiopClient {
197
206
  close(): Promise<void>;
198
207
  }
199
208
 
200
- export { type CertInfo as C, type LiopTlsOptions as L, CertManager as a, type CertManagerOptions as b, LiopClient as c };
209
+ export { type CertInfo as C, type LiopTlsOptions as L, CertManager as a, type CertManagerOptions as b, LiopClient as c, createChannelCredentials as d, createServerCredentials as e };
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { MeshNode } from './mesh.js';
3
- import { J as JwtValidator, S as ServerInfo, a as CallToolResult, P as Prompt, G as GetPromptRequest, d as GetPromptResult, C as CallToolRequest, T as Tool, R as Resource } from './types-lJIxBlWF.js';
2
+ import { M as MeshNodeConfig, a as MeshNode } from './node-Djzm6UYd.js';
3
+ import { d as AuditLogger, J as JwtValidator, S as ServerInfo, a as CallToolResult, P as Prompt, e as GetPromptRequest, f as GetPromptResult, C as CallToolRequest, T as Tool, R as Resource } from './types-29zv9X1V.js';
4
4
 
5
5
  /**
6
6
  * LIOP OAuth 2.1 Hybrid Auth — Configuration Types
@@ -100,60 +100,6 @@ declare const AUTH_DEFAULTS: {
100
100
  readonly signingAlgorithm: "EdDSA";
101
101
  };
102
102
 
103
- /**
104
- * LIOP Immutable Audit Logger (Phase Beta-3)
105
- * SOC 2 Type II & HIPAA compliant audit trail with cryptographic Hash-Chain.
106
- * Guarantees tamper-evidence and non-repudiation for all Logic-on-Origin executions.
107
- */
108
- type AuditStatus = "SUCCESS" | "BLOCKED_EGRESS" | "ERROR" | "POLICY_VIOLATION";
109
- interface AuditEntry {
110
- id: string;
111
- timestamp: string;
112
- traceId: string;
113
- agentDid: string;
114
- peerId: string;
115
- toolName: string;
116
- datasetHash: string;
117
- fuelConsumed: number;
118
- outputHash: string;
119
- zkReceiptSig: string;
120
- status: AuditStatus;
121
- prevEntryHash: string;
122
- entryHash: string;
123
- }
124
- interface AuditRecordParams {
125
- timestamp?: string;
126
- traceId?: string;
127
- agentDid: string;
128
- peerId: string;
129
- toolName: string;
130
- datasetHash?: string;
131
- fuelConsumed: number;
132
- outputHash?: string;
133
- zkReceiptSig?: string;
134
- status: AuditStatus;
135
- }
136
- declare const GENESIS_HASH: string;
137
- declare function computeEntryHash(entryWithoutHash: Omit<AuditEntry, "entryHash">): string;
138
- declare class AuditLogger {
139
- private entries;
140
- private lastEntryHash;
141
- private filePath?;
142
- constructor(filePath?: string);
143
- recordExecution(params: AuditRecordParams): AuditEntry;
144
- getEntries(): readonly AuditEntry[];
145
- getEntryCount(): number;
146
- verifyIntegrity(): {
147
- valid: boolean;
148
- totalEntries: number;
149
- brokenIndex?: number;
150
- reason?: string;
151
- };
152
- exportJsonl(): string;
153
- private loadFromFile;
154
- }
155
- declare const globalAuditLogger: AuditLogger;
156
-
157
103
  /** Single named entity detected by the NER scanner. */
158
104
  interface NerEntity {
159
105
  type: "person" | "place" | "organization";
@@ -211,11 +157,6 @@ interface OutputSanitizerConfig {
211
157
  */
212
158
  declare function sanitizeOutput(output: unknown, config?: OutputSanitizerConfig): unknown;
213
159
 
214
- /**
215
- * LIOP Professional PII Engine (The Shield V2 - Tier-1 Military Edition)
216
- * Implements high-fidelity detection based on NIST and OWASP standards.
217
- * Features Multi-Layer Verification (Regex + Algorithmic Validators).
218
- */
219
160
  type PiiRuleDefinition = {
220
161
  name: string;
221
162
  pattern: string | RegExp;
@@ -340,6 +281,10 @@ interface LiopServerOptions {
340
281
  * Path to a shared JSON file for persistent Query Budget tracking across multiple server instances.
341
282
  */
342
283
  budgetStorePath?: string;
284
+ /** Expected guest image identifier hash for sovereign enclaves (Hex) */
285
+ guestImageId?: string;
286
+ /** Static verification key mappings for fast-path analytical circuits */
287
+ zkVkeys?: Record<string, unknown>;
343
288
  }
344
289
  interface AggregationPolicy {
345
290
  /** Maximum number of object-type array elements allowed (default: 10) */
@@ -390,6 +335,29 @@ interface LogicExecutionPolicy {
390
335
  * Path to a shared JSON file for persistent Query Budget tracking across multiple server instances.
391
336
  */
392
337
  budgetStorePath?: string;
338
+ /**
339
+ * Zero-Knowledge proof mode required for this tool capability.
340
+ * - "none": standard HMAC-SHA256 session commitment
341
+ * - "optimistic": Groth16 v2 receipt generated if prover available, otherwise fallback
342
+ * - "required": strictly enforces Groth16 v2 proof generation; rejects if unavailable
343
+ */
344
+ zkMode?: "none" | "optimistic" | "required";
345
+ /**
346
+ * Optional custom guest image identifier hash for this capability.
347
+ */
348
+ guestImageId?: string;
349
+ /**
350
+ * Name of the designated R1CS circuit (e.g. "sum", "count", "average", "filter").
351
+ */
352
+ circuitName?: string;
353
+ /**
354
+ * Static verification key JSON structure for this capability.
355
+ */
356
+ vkey?: Record<string, unknown>;
357
+ /**
358
+ * Whether to co-sign the Groth16 receipt with an ML-DSA-65 post-quantum digital signature (FIPS 204).
359
+ */
360
+ pqcSign?: boolean;
393
361
  }
394
362
  declare class LiopServer {
395
363
  private serverInfo;
@@ -416,6 +384,7 @@ declare class LiopServer {
416
384
  private meshNode;
417
385
  private rpcServer;
418
386
  private boundPort;
387
+ private enclavePqcKeypair?;
419
388
  jwtValidator?: JwtValidator;
420
389
  oauthProvider?: any;
421
390
  private sessions;
@@ -458,11 +427,7 @@ declare class LiopServer {
458
427
  */
459
428
  connect(options?: {
460
429
  port?: number;
461
- meshConfig?: {
462
- listenAddresses?: string[];
463
- bootstrapNodes?: string[];
464
- identityPath?: string;
465
- };
430
+ meshConfig?: MeshNodeConfig;
466
431
  }): Promise<void>;
467
432
  /**
468
433
  * Register a new Tool
@@ -541,6 +506,10 @@ declare class LiopServer {
541
506
  * Injects data into the secure sandbox context for Logic-on-Origin tools.
542
507
  */
543
508
  setSandboxData(records: Record<string, unknown>[]): void;
509
+ /**
510
+ * Returns the read-only sandbox records registered in the enclave.
511
+ */
512
+ getSandboxData(): readonly Record<string, unknown>[];
544
513
  getBoundPort(): number | null;
545
514
  /**
546
515
  * Connects to the libp2p Kademlia DHT and announces capabilities.
@@ -548,11 +517,7 @@ declare class LiopServer {
548
517
  */
549
518
  connectToMesh(options?: {
550
519
  port?: number;
551
- meshConfig?: {
552
- listenAddresses?: string[];
553
- bootstrapNodes?: string[];
554
- identityPath?: string;
555
- };
520
+ meshConfig?: MeshNodeConfig;
556
521
  }): Promise<void>;
557
522
  /**
558
523
  * Internal worker execution with Egress Filtering logic.
@@ -581,4 +546,4 @@ declare class LiopServer {
581
546
  private applyInMemoryBudget;
582
547
  }
583
548
 
584
- export { AUTH_DEFAULTS as A, GENESIS_HASH as G, LiopServer as L, NerScanner as N, type OAuthClientConfig as O, PII_PATTERNS as P, type ToolHandler as T, type LiopServerOptions as a, type AggregationPolicy as b, type AuditEntry as c, AuditLogger as d, type AuditRecordParams as e, type AuditStatus as f, type AuthRole as g, type LiopAuthConfig as h, type LogicExecutionPolicy as i, type OutputSanitizerConfig as j, PII_PRESETS as k, type PiiRule as l, PiiScanner as m, computeEntryHash as n, globalAuditLogger as o, sanitizeOutput as s };
549
+ export { AUTH_DEFAULTS as A, LiopServer as L, NerScanner as N, type OAuthClientConfig as O, PII_PATTERNS as P, type ToolHandler as T, type LiopServerOptions as a, type AggregationPolicy as b, type AuthRole as c, type LiopAuthConfig as d, type LogicExecutionPolicy as e, type OutputSanitizerConfig as f, PII_PRESETS as g, type PiiRule as h, PiiScanner as i, sanitizeOutput as s };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,48 @@
1
1
  export { LiopBridgeOptions, LiopMcpBridge, LiopStreamBridge, LiopStreamBridgeOptions } from './bridge.js';
2
- import { L as LiopTlsOptions } from './index-cMV0_yD9.js';
3
- export { C as CertInfo, a as CertManager, b as CertManagerOptions, c as LiopClient } from './index-cMV0_yD9.js';
2
+ import { L as LiopTlsOptions } from './index-BYDtRGue.js';
3
+ export { C as CertInfo, a as CertManager, b as CertManagerOptions, c as LiopClient, d as createChannelCredentials, e as createServerCredentials } from './index-BYDtRGue.js';
4
+ import { ProofWithSignals, VerificationKey } from 'micro-zk-proofs';
5
+ export { ProofWithSignals, VerificationKey } from 'micro-zk-proofs';
6
+ export { L as LiopVerifier, T as TeePolicy, a as TeeVerificationOptions, b as TeeVerificationResult, V as VerifyZkOptions } from './verifier-DqZ9MQ9l.js';
4
7
  import * as http from 'node:http';
5
- export { I as InMemoryRateLimiter, L as LiopHybridGateway, a as LiopMcpRouter, R as RateLimitStatus, b as RateLimiterOptions } from './hybrid-CF__0YnC.js';
6
- export { LiopManifest, MeshNode, MeshNodeConfig } from './mesh.js';
8
+ export { I as InMemoryRateLimiter, L as LiopHybridGateway, a as LiopMcpRouter, R as RateLimitStatus, b as RateLimiterOptions } from './hybrid-BZpCiUaV.js';
9
+ import { A as AuthInfo } from './types-29zv9X1V.js';
10
+ export { g as AuditEntry, h as AuditInterceptor, d as AuditLogger, i as AuditRecordParams, j as AuditStatus, k as CacheableResult, C as CallToolRequest, a as CallToolResult, D as DiscoverResult, l as GENESIS_HASH, 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, J as JwtValidator, L as LiopLogger, r as LogEvent, s as LogInterceptor, t as LogLevel, 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, E as computeEntryHash, F as executeGatewayInterceptor, H as globalAuditLogger, K as log } from './types-29zv9X1V.js';
11
+ export { L as LiopManifest, a as MeshNode, M as MeshNodeConfig } from './node-Djzm6UYd.js';
12
+ export { SWARM_KEY_BYTE_LENGTH, createSwarmKey, deserializeSwarmKey, loadSwarmKey, parseSwarmKey, saveSwarmKey, serializeSwarmKey } from './mesh.js';
7
13
  import * as grpc from '@grpc/grpc-js';
8
- export { A as AUTH_DEFAULTS, b as AggregationPolicy, c as AuditEntry, d as AuditLogger, e as AuditRecordParams, f as AuditStatus, g as AuthRole, G as GENESIS_HASH, h as LiopAuthConfig, L as LiopServer, a as LiopServerOptions, i as LogicExecutionPolicy, N as NerScanner, O as OAuthClientConfig, j as OutputSanitizerConfig, P as PII_PATTERNS, k as PII_PRESETS, l as PiiRule, m as PiiScanner, T as ToolHandler, n as computeEntryHash, o as globalAuditLogger, s as sanitizeOutput } from './index-BW95kAL4.js';
9
- import { A as AuthInfo } from './types-lJIxBlWF.js';
10
- export { 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, J as JwtValidator, 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';
14
+ export { A as AUTH_DEFAULTS, b as AggregationPolicy, c as AuthRole, d as LiopAuthConfig, L as LiopServer, a as LiopServerOptions, e as LogicExecutionPolicy, N as NerScanner, O as OAuthClientConfig, f as OutputSanitizerConfig, P as PII_PATTERNS, g as PII_PRESETS, h as PiiRule, i as PiiScanner, T as ToolHandler, s as sanitizeOutput } from './index-ByzjpRCk.js';
11
15
  import * as jose from 'jose';
12
16
  import Provider from 'oidc-provider';
17
+ export { D as DecodedReceipt, 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, e as ZkVerificationError, f as ZkVerifier, g as decodeJournalV2, h as encodeJournalV2, r as receiptCodec } from './zk-DzYNWBgo.js';
13
18
  import '@modelcontextprotocol/sdk/server/mcp.js';
14
19
  import 'zod';
15
- import './verifier-COnid_dg.js';
16
20
  import 'node:events';
17
21
 
22
+ declare const VERIFICATION_LATENCY_BUDGET_MS = 250;
23
+
24
+ /**
25
+ * Verifies a Groth16 Zero-Knowledge proof against a verification key.
26
+ * Traps curve validation errors gracefully to ensure safe verification.
27
+ */
28
+ declare function verifyGroth16Proof(vkey: VerificationKey, proofWithSignals: ProofWithSignals): boolean;
29
+ /**
30
+ * Serializes a VerificationKey into a Buffer.
31
+ */
32
+ declare function serializeVKey(vkey: VerificationKey): Buffer;
33
+ /**
34
+ * Deserializes a Buffer into a typed VerificationKey.
35
+ */
36
+ declare function deserializeVKey(buf: Buffer): VerificationKey;
37
+ /**
38
+ * Serializes a ProofWithSignals into a Buffer.
39
+ */
40
+ declare function serializeGrothProof(proofWithSignals: ProofWithSignals): Buffer;
41
+ /**
42
+ * Deserializes a Buffer into a typed ProofWithSignals.
43
+ */
44
+ declare function deserializeGrothProof(buf: Buffer): ProofWithSignals;
45
+
18
46
  /**
19
47
  * TokenEstimator — Pluggable strategy for counting tokens in text content.
20
48
  *
@@ -36,7 +64,7 @@ interface TokenEstimator {
36
64
  *
37
65
  * - Synchronous: safe for hot-path usage without async overhead
38
66
  * - Merge cache reduced to 10K entries for long-running server processes
39
- * - Inlined at build-time: zero external runtime dependencies in node_modules
67
+ * - External dependency: resolved from gpt-tokenizer in node_modules at runtime
40
68
  */
41
69
  declare class RealTokenEstimator implements TokenEstimator {
42
70
  readonly name = "o200k_base";
@@ -113,6 +141,7 @@ interface TokenOperationMetric {
113
141
  readonly toolName?: string;
114
142
  readonly peerId?: string;
115
143
  readonly durationMs?: number;
144
+ readonly originDatasetTokens?: number;
116
145
  }
117
146
  /** Session-level aggregate report */
118
147
  interface TokenSessionReport {
@@ -313,17 +342,25 @@ declare class MetricsRegistry {
313
342
  }
314
343
  declare const protocolMetrics: MetricsRegistry;
315
344
  declare const toolCallsTotal: Counter;
345
+ declare const toolCallErrorsTotal: Counter;
316
346
  declare const fuelConsumed: Histogram;
317
347
  declare const meshPeersConnected: Gauge;
318
348
  declare const manifestCacheSize: Gauge;
319
349
  declare const egressBlocksTotal: Counter;
320
350
  declare const zkVerificationDurationMs: Histogram;
351
+ declare const zkVerificationsTotal: Counter;
352
+ declare const zkProofsByTypeTotal: Counter;
353
+ declare const zkProvingDurationMs: Histogram;
354
+ declare const zkVkeyCacheSize: Gauge;
355
+ declare const tokensInputTotal: Counter;
356
+ declare const tokensOutputTotal: Counter;
357
+ declare const tokensSavedTotal: Counter;
358
+ declare const operationDurationMs: Histogram;
359
+ declare const pqcHandshakeDurationMs: Histogram;
360
+ declare const pqcHandshakesTotal: Counter;
361
+ declare const wireEgressBytesTotal: Counter;
362
+ declare const wireSavedBytesTotal: Counter;
321
363
 
322
- /**
323
- * LIOP OpenTelemetry Distributed Tracing (Phase Beta-3)
324
- * W3C TraceContext compliant distributed tracer for gRPC & MCP transports.
325
- * Spec: https://www.w3.org/TR/trace-context/
326
- */
327
364
  interface SpanContext {
328
365
  traceId: string;
329
366
  spanId: string;
@@ -382,6 +419,16 @@ declare const GRPC_CHANNEL_OPTIONS: Readonly<Record<string, string | number>>;
382
419
  * TypeScript interfaces reflecting liop_core.proto (LIOP v1)
383
420
  * Optimized for logic-on-origin and high-performance serialization.
384
421
  */
422
+ declare enum ProofMode {
423
+ PROOF_MODE_LEGACY_HMAC = 0,
424
+ PROOF_MODE_ZK_OPTIMISTIC = 1,
425
+ PROOF_MODE_ZK_BLOCKING = 2
426
+ }
427
+ declare enum ProofType {
428
+ PROOF_TYPE_HMAC_LEGACY = 0,
429
+ PROOF_TYPE_GROTH16 = 2,
430
+ PROOF_TYPE_GROTH16_PQC_HYBRID = 3
431
+ }
385
432
  interface IntentRequest {
386
433
  agent_did: string;
387
434
  capability_hash: string;
@@ -399,14 +446,18 @@ interface LogicRequest {
399
446
  inputs: Record<string, Uint8Array>;
400
447
  pqc_ciphertext: Uint8Array;
401
448
  aes_nonce: Uint8Array;
449
+ requested_proof_mode?: ProofMode;
402
450
  }
403
451
  interface LogicResponse {
404
452
  semantic_evidence: string;
405
453
  cryptographic_proof: Uint8Array;
406
454
  zk_receipt: Uint8Array;
407
455
  is_error: boolean;
456
+ proof_type?: ProofType;
457
+ guest_image_id?: Uint8Array;
408
458
  }
409
459
 
460
+ type TokenProvider = string | (() => Promise<string | undefined> | string | undefined);
410
461
  /**
411
462
  * LIOP gRPC Client Implementation
412
463
  * Provides a high-level interface for secure intent negotiation and logic execution.
@@ -414,8 +465,11 @@ interface LogicResponse {
414
465
  declare class LiopRpcClient {
415
466
  private client;
416
467
  private token?;
468
+ private lastResolvedToken?;
417
469
  readonly address: string;
418
- constructor(address: string, tls?: LiopTlsOptions, token?: string);
470
+ constructor(address: string, tls?: LiopTlsOptions, token?: TokenProvider);
471
+ setToken(token?: TokenProvider): void;
472
+ private resolveToken;
419
473
  /**
420
474
  * Negotiates intent with the remote host.
421
475
  * Returns the ephemeral Kyber public key for payload encryption.
@@ -430,17 +484,28 @@ declare class LiopRpcClient {
430
484
  }
431
485
 
432
486
  /**
433
- * LIOP Post-Quantum Digital Signature Wrapper
434
- * Implements ML-DSA-65 (CRYSTALS-Dilithium, NIST FIPS 204) for quantum-resistant
435
- * manifest attestation, node revocation receipts, and cryptographic integrity.
436
- *
437
- * Characteristics:
438
- * - Security Category: NIST Level 3 (~AES-192 equivalent quantum resistance)
439
- * - Public Key Length: 1952 bytes
440
- * - Secret Key Length: 4032 bytes
441
- * - Signature Length: 3309 bytes
442
- * - Implementation: Pure TypeScript/JS via @noble/post-quantum
487
+ * LIOP Symmetric Payload Encryption Wrapper
488
+ * Uses AES-256-GCM to secure WASM Code transport over Zero-Trust networks.
489
+ * Fully compatible with the `aes-gcm` Rust crate used by Wasmtime.
443
490
  */
491
+ declare const AesGcmWrapper: {
492
+ /**
493
+ * Encrypts a raw WASM payload using the shared secret negotiated via Kyber768.
494
+ *
495
+ * @param payload Raw incoming WASM byte array or string.
496
+ * @param sharedSecret A perfectly derived 32-byte (256-bit) shared secret array
497
+ * @returns The encrypted buffer to push to the GRPc stream, along with the 12-byte initialization vector natively generated.
498
+ */
499
+ encryptPayload(payload: Uint8Array | Buffer, sharedSecret: Uint8Array): {
500
+ ciphertext: Buffer;
501
+ nonce: Buffer;
502
+ };
503
+ /**
504
+ * Decrypts a remote Zero-Knowledge receipt using AES-256-GCM.
505
+ */
506
+ decryptPayload(ciphertextBuffer: Buffer, nonce: Buffer, sharedSecret: Uint8Array): Buffer;
507
+ };
508
+
444
509
  declare const DILITHIUM65_CONSTANTS: {
445
510
  readonly PUBLIC_KEY_BYTES: 1952;
446
511
  readonly SECRET_KEY_BYTES: 4032;
@@ -460,6 +525,10 @@ declare const Dilithium65Wrapper: {
460
525
  publicKey: Uint8Array;
461
526
  secretKey: Uint8Array;
462
527
  };
528
+ /**
529
+ * Derives the ML-DSA-65 public key from a given secret key.
530
+ */
531
+ getPublicKey(secretKey: Uint8Array): Uint8Array;
463
532
  /**
464
533
  * Validates and imports a raw ML-DSA-65 public key.
465
534
  */
@@ -527,6 +596,132 @@ declare class LiopRpcServer {
527
596
  stop(): Promise<void>;
528
597
  }
529
598
 
599
+ type TransportProvider = "http-gateway" | "p2p-grpc" | "local";
600
+ interface ToolDefinition {
601
+ name: string;
602
+ description?: string;
603
+ inputSchema?: Record<string, unknown>;
604
+ }
605
+ interface ToolRoute {
606
+ name: string;
607
+ provider: TransportProvider;
608
+ endpoint: string;
609
+ description?: string;
610
+ inputSchema?: Record<string, unknown>;
611
+ latencyMs: number;
612
+ failCount: number;
613
+ lastSuccess: number;
614
+ authRequired?: boolean;
615
+ }
616
+ declare class RoutingTable {
617
+ private routes;
618
+ private static readonly MAX_FAILURES;
619
+ /**
620
+ * Registers or updates a collection of tools exposed via an HTTP Gateway.
621
+ */
622
+ registerGatewayTools(tools: ToolDefinition[], mcpEndpoint: string, authRequired?: boolean): void;
623
+ /**
624
+ * Registers tools discovered directly over the P2P Mesh (gRPC).
625
+ */
626
+ registerMeshTools(tools: ToolDefinition[], grpcTarget: string, authRequired?: boolean): void;
627
+ /**
628
+ * Registers an in-process local tool (e.g. LiopMeshStatus).
629
+ */
630
+ registerLocalTool(tool: ToolDefinition): void;
631
+ /**
632
+ * Resolves the optimal route for a specific tool.
633
+ */
634
+ resolve(toolName: string): ToolRoute | undefined;
635
+ /**
636
+ * Records a successful invocation on a route, resetting failures and updating latency.
637
+ */
638
+ recordSuccess(toolName: string, latencyMs: number): void;
639
+ /**
640
+ * Records a failed invocation on a route.
641
+ */
642
+ recordFailure(toolName: string): void;
643
+ /**
644
+ * Lists all registered tools in sorted format for tools/list.
645
+ */
646
+ getAllToolDefinitions(): ToolDefinition[];
647
+ getRoute(toolName: string): ToolRoute | undefined;
648
+ size(): number;
649
+ clear(): void;
650
+ }
651
+
652
+ interface TokenManagerOptions {
653
+ tokenEndpoint: string;
654
+ clientId: string;
655
+ clientSecret: string;
656
+ audience?: string;
657
+ scopes?: string | string[];
658
+ staticToken?: string;
659
+ }
660
+ declare class TokenManager {
661
+ private cachedToken;
662
+ private expiresAt;
663
+ private pendingPromise;
664
+ private readonly tokenEndpoint;
665
+ private readonly clientId;
666
+ private readonly clientSecret;
667
+ private readonly audience;
668
+ private readonly scope;
669
+ private staticToken?;
670
+ private static readonly REFRESH_BUFFER_MS;
671
+ constructor(options: TokenManagerOptions);
672
+ /**
673
+ * Returns a valid OAuth 2.1 access token.
674
+ * Automatically performs preemptive refresh if the token is close to expiry.
675
+ */
676
+ getToken(): Promise<string>;
677
+ /**
678
+ * Force-invalidates cached token, e.g. after receiving a 401 Unauthorized response.
679
+ */
680
+ invalidate(): void;
681
+ /**
682
+ * Returns true if the token is absent or has passed the refresh threshold.
683
+ */
684
+ isExpired(): boolean;
685
+ getExpiresAt(): number;
686
+ private fetchNewToken;
687
+ }
688
+
689
+ interface GatewayTopologyInfo {
690
+ baseUrl: string;
691
+ mcpEndpoint: string;
692
+ healthEndpoint: string;
693
+ tokenEndpoint: string;
694
+ issuer: string;
695
+ audience: string;
696
+ scopes: string[];
697
+ tools: string[];
698
+ tier: number;
699
+ }
700
+ interface MeshTopologyInfo {
701
+ bootstrapNodes: string[];
702
+ identityPath?: string;
703
+ }
704
+ interface TopologyProbeResult {
705
+ mode: "gateway" | "mesh" | "hybrid";
706
+ gateway?: GatewayTopologyInfo;
707
+ mesh?: MeshTopologyInfo;
708
+ }
709
+ interface TopologyProbeOptions {
710
+ blgUrl?: string;
711
+ nexusUrl?: string;
712
+ clientId?: string;
713
+ clientSecret?: string;
714
+ audience?: string;
715
+ staticToken?: string;
716
+ bootstrapNodes?: string[];
717
+ identityPath?: string;
718
+ autoProbeLocal?: boolean;
719
+ }
720
+ /**
721
+ * Probes the runtime environment and determines the optimal architecture mode.
722
+ */
723
+ declare function probeTopology(options?: TopologyProbeOptions): Promise<TopologyProbeResult>;
724
+
530
725
  /**
531
726
  * Returns a filtered environment object containing only safe system variables,
532
727
  * preventing exposure of sensitive credentials and shell function injection.
@@ -574,21 +769,6 @@ declare class WasiSandbox {
574
769
  teardown(): Promise<void>;
575
770
  }
576
771
 
577
- /**
578
- * LIOP Embedded OAuth 2.1 Authorization Server
579
- *
580
- * Implements a lightweight, high-performance OAuth 2.1 / OIDC Authorization Server
581
- * for the Nexus node using `panva/node-oidc-provider`.
582
- *
583
- * Security Hardening:
584
- * - M2M (Machine-to-Machine) Client Credentials Grant ONLY (Zero human interaction interface).
585
- * - Algorithmic whitelist: EdDSA (Ed25519) for token signing.
586
- * - JWT Access Tokens: Allows stateless, cryptographically-secure validation on data nodes (NIST SP 800-207).
587
- * - Interaction Lockout: Throws exception on any interactive flow attempt to prevent hijack attacks (OWASP).
588
- *
589
- * Standards: OAuth 2.1, RFC 6749, RFC 7519, NIST SP 800-63B
590
- */
591
-
592
772
  interface OAuthServerClientConfig {
593
773
  client_id: string;
594
774
  client_secret: string;
@@ -610,15 +790,6 @@ interface OAuthServerResult {
610
790
  */
611
791
  declare function createOAuthServer(config: OAuthServerConfig): OAuthServerResult;
612
792
 
613
- /**
614
- * LIOP Protected Resource Metadata — RFC 9728
615
- *
616
- * Builds the JSON document served at /.well-known/oauth-protected-resource.
617
- * This enables MCP clients to discover the authorization server and
618
- * required scopes for accessing LIOP tools and resources.
619
- *
620
- * Standards: RFC 9728, MCP Spec 2025-11-25
621
- */
622
793
  /**
623
794
  * RFC 9728 Protected Resource Metadata response.
624
795
  *
@@ -683,4 +854,4 @@ declare function authorizeRequest(method: string, auth: AuthInfo | null, additio
683
854
  declare const LIOP_SCOPES: readonly ["liop:tools:list", "liop:tools:call", "liop:resources:read", "liop:schema:read", "liop:mesh:query"];
684
855
  type LiopScope = (typeof LIOP_SCOPES)[number];
685
856
 
686
- export { type AIProvider, AuthInfo, Counter, DILITHIUM65_CONSTANTS, Dilithium65Wrapper, ErrorCode, GRPC_CHANNEL_OPTIONS, GRPC_WEB_CONSTANTS, Gauge, type GrpcWebFrame, HeuristicTokenEstimator, Histogram, Kyber768Wrapper, LIOP_SCOPES, LiopError, LiopOTelBridge, LiopRpcClient, LiopRpcServer, type LiopScope, type LiopSpan, LiopTracer, type MetricDefinition, type MetricLabels, MetricsRegistry, type PromptConfig, RealTokenEstimator, type SandboxConfig, type SpanContext, type TokenEstimator, type TokenOperationMetric, type TokenSessionReport, TokenTelemetryEngine, type ToolTokenBreakdown, WasiSandbox, authorizeRequest, buildProtectedResourceMetadata, calculateAstInstructionFuel, createOAuthServer, createSyncTokenEstimator, createTokenEstimator, decodeFrames, defaultTracer, dispatchGrpcWebRequest, egressBlocksTotal, encodeDataFrame, encodeTrailerFrame, fuelConsumed, generateSystemInstructions, getDefaultEnvironment, isGrpcWebRequest, manifestCacheSize, meshPeersConnected, protocolMetrics, toolCallsTotal, zkVerificationDurationMs };
857
+ export { type AIProvider, AesGcmWrapper, AuthInfo, Counter, DILITHIUM65_CONSTANTS, Dilithium65Wrapper, ErrorCode, GRPC_CHANNEL_OPTIONS, GRPC_WEB_CONSTANTS, type GatewayTopologyInfo, Gauge, type GrpcWebFrame, HeuristicTokenEstimator, Histogram, Kyber768Wrapper, LIOP_SCOPES, LiopError, LiopOTelBridge, LiopRpcClient, LiopRpcServer, type LiopScope, type LiopSpan, LiopTlsOptions, LiopTracer, type MeshTopologyInfo, type MetricDefinition, type MetricLabels, MetricsRegistry, type PromptConfig, RealTokenEstimator, RoutingTable, type SandboxConfig, type SpanContext, type TokenEstimator, TokenManager, type TokenManagerOptions, type TokenOperationMetric, type TokenProvider, type TokenSessionReport, TokenTelemetryEngine, type ToolDefinition, type ToolRoute, type ToolTokenBreakdown, type TopologyProbeOptions, type TopologyProbeResult, type TransportProvider, VERIFICATION_LATENCY_BUDGET_MS, WasiSandbox, authorizeRequest, buildProtectedResourceMetadata, calculateAstInstructionFuel, createOAuthServer, createSyncTokenEstimator, createTokenEstimator, decodeFrames, defaultTracer, deserializeGrothProof, deserializeVKey, dispatchGrpcWebRequest, egressBlocksTotal, encodeDataFrame, encodeTrailerFrame, fuelConsumed, generateSystemInstructions, getDefaultEnvironment, isGrpcWebRequest, manifestCacheSize, meshPeersConnected, operationDurationMs, pqcHandshakeDurationMs, pqcHandshakesTotal, probeTopology, protocolMetrics, serializeGrothProof, serializeVKey, tokensInputTotal, tokensOutputTotal, tokensSavedTotal, toolCallErrorsTotal, toolCallsTotal, verifyGroth16Proof, wireEgressBytesTotal, wireSavedBytesTotal, zkProofsByTypeTotal, zkProvingDurationMs, zkVerificationDurationMs, zkVerificationsTotal, zkVkeyCacheSize };