@nekzus/liop 2.4.0-alpha.13 → 2.4.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/agent.js +10 -10
- package/dist/bridge.d.ts +2 -2
- package/dist/bridge.js +3 -3
- package/dist/{chunk-NFFBJALJ.js → chunk-2KSO3W4A.js} +2 -2
- package/dist/{chunk-NFFBJALJ.js.map → chunk-2KSO3W4A.js.map} +1 -1
- package/dist/{chunk-PEN3KFLF.js → chunk-2STZHJ24.js} +3 -3
- package/dist/{chunk-PEN3KFLF.js.map → chunk-2STZHJ24.js.map} +1 -1
- package/dist/{chunk-ESRXG36Y.js → chunk-3QH44NKZ.js} +3 -3
- package/dist/{chunk-ESRXG36Y.js.map → chunk-3QH44NKZ.js.map} +1 -1
- package/dist/{chunk-3BJ5QQHK.js → chunk-3UBNOYMH.js} +3 -3
- package/dist/{chunk-3BJ5QQHK.js.map → chunk-3UBNOYMH.js.map} +1 -1
- package/dist/{chunk-NFPQJCWL.js → chunk-FPL5ZKW5.js} +7 -7
- package/dist/{chunk-NFPQJCWL.js.map → chunk-FPL5ZKW5.js.map} +1 -1
- package/dist/{chunk-5SQLODJS.js → chunk-G5HHJVD4.js} +4 -4
- package/dist/{chunk-5SQLODJS.js.map → chunk-G5HHJVD4.js.map} +1 -1
- package/dist/{chunk-DZ2FQGJD.js → chunk-H2SNR7PB.js} +3 -3
- package/dist/{chunk-DZ2FQGJD.js.map → chunk-H2SNR7PB.js.map} +1 -1
- package/dist/chunk-K3DGJLUY.js +106 -0
- package/dist/chunk-K3DGJLUY.js.map +1 -0
- package/dist/{chunk-UWC7OY7K.js → chunk-O37AERO7.js} +27 -5
- package/dist/chunk-O37AERO7.js.map +1 -0
- package/dist/{chunk-UCVP3XAL.js → chunk-PUDETPL4.js} +3 -3
- package/dist/{chunk-UCVP3XAL.js.map → chunk-PUDETPL4.js.map} +1 -1
- package/dist/{chunk-7RXOIDXP.js → chunk-XRDN232O.js} +3 -3
- package/dist/{chunk-7RXOIDXP.js.map → chunk-XRDN232O.js.map} +1 -1
- package/dist/{chunk-PXSXQEXO.js → chunk-Y6YXTITY.js} +9 -9
- package/dist/{chunk-PXSXQEXO.js.map → chunk-Y6YXTITY.js.map} +1 -1
- package/dist/{chunk-OPYSUDSW.js → chunk-ZKKAUQ3E.js} +5 -5
- package/dist/{chunk-OPYSUDSW.js.map → chunk-ZKKAUQ3E.js.map} +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +8 -8
- package/dist/gateway.d.ts +3 -3
- package/dist/gateway.js +7 -7
- package/dist/{hybrid-FFII2lHf.d.ts → hybrid-DO3XTxqT.d.ts} +2 -2
- package/dist/{index-DckIVTsW.d.ts → index-DW1-7ClN.d.ts} +2 -51
- package/dist/{index-BLu6LG_C.d.ts → index-kOdMjin6.d.ts} +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +14 -13
- package/dist/index.js.map +1 -1
- package/dist/mesh.js +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +4 -4
- package/dist/{types-DDiBZWEq.d.ts → types-Bo6hcrS6.d.ts} +138 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/verifier-XFU7ZB2W.js +6 -0
- package/dist/{verifier-HRFXBKT5.js.map → verifier-XFU7ZB2W.js.map} +1 -1
- package/package.json +1 -1
- package/dist/chunk-HA6YZ42O.js +0 -64
- package/dist/chunk-HA6YZ42O.js.map +0 -1
- package/dist/chunk-UWC7OY7K.js.map +0 -1
- package/dist/verifier-HRFXBKT5.js +0 -6
package/dist/gateway.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { LiopHybridGateway } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-
|
|
1
|
+
export { LiopHybridGateway } from './chunk-G5HHJVD4.js';
|
|
2
|
+
import './chunk-FPL5ZKW5.js';
|
|
3
|
+
import './chunk-H2SNR7PB.js';
|
|
4
|
+
import './chunk-2STZHJ24.js';
|
|
5
5
|
import './chunk-IK7CGWAZ.js';
|
|
6
6
|
import './chunk-7PITYWOV.js';
|
|
7
7
|
import './chunk-VH4K4U45.js';
|
|
8
|
-
import './chunk-
|
|
8
|
+
import './chunk-3UBNOYMH.js';
|
|
9
9
|
import './chunk-PAICJCKJ.js';
|
|
10
|
-
import './chunk-
|
|
11
|
-
import './chunk-
|
|
10
|
+
import './chunk-2KSO3W4A.js';
|
|
11
|
+
import './chunk-K3DGJLUY.js';
|
|
12
12
|
//# sourceMappingURL=gateway.js.map
|
|
13
13
|
//# sourceMappingURL=gateway.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as MeshNode } from './node-B0b2vUFS.js';
|
|
2
|
-
import { L as LiopServer } from './index-
|
|
3
|
-
import { b as McpRequest, M as McpEra, A as AuthInfo, c as McpResponse, G as GatewayInterceptorOptions } from './types-
|
|
2
|
+
import { L as LiopServer } from './index-DW1-7ClN.js';
|
|
3
|
+
import { b as McpRequest, M as McpEra, A as AuthInfo, c as McpResponse, G as GatewayInterceptorOptions } from './types-Bo6hcrS6.js';
|
|
4
4
|
import { L as LiopVerifier } from './verifier-COnid_dg.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { M as MeshNodeConfig, a as MeshNode } from './node-B0b2vUFS.js';
|
|
3
|
-
import { J as JwtValidator, S as ServerInfo, a as CallToolResult, P as Prompt,
|
|
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-Bo6hcrS6.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* LIOP OAuth 2.1 Hybrid Auth — Configuration Types
|
|
@@ -100,55 +100,6 @@ declare const AUTH_DEFAULTS: {
|
|
|
100
100
|
readonly signingAlgorithm: "EdDSA";
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
-
type AuditStatus = "SUCCESS" | "BLOCKED_EGRESS" | "ERROR" | "POLICY_VIOLATION";
|
|
104
|
-
interface AuditEntry {
|
|
105
|
-
id: string;
|
|
106
|
-
timestamp: string;
|
|
107
|
-
traceId: string;
|
|
108
|
-
agentDid: string;
|
|
109
|
-
peerId: string;
|
|
110
|
-
toolName: string;
|
|
111
|
-
datasetHash: string;
|
|
112
|
-
fuelConsumed: number;
|
|
113
|
-
outputHash: string;
|
|
114
|
-
zkReceiptSig: string;
|
|
115
|
-
status: AuditStatus;
|
|
116
|
-
prevEntryHash: string;
|
|
117
|
-
entryHash: string;
|
|
118
|
-
}
|
|
119
|
-
interface AuditRecordParams {
|
|
120
|
-
timestamp?: string;
|
|
121
|
-
traceId?: string;
|
|
122
|
-
agentDid: string;
|
|
123
|
-
peerId: string;
|
|
124
|
-
toolName: string;
|
|
125
|
-
datasetHash?: string;
|
|
126
|
-
fuelConsumed: number;
|
|
127
|
-
outputHash?: string;
|
|
128
|
-
zkReceiptSig?: string;
|
|
129
|
-
status: AuditStatus;
|
|
130
|
-
}
|
|
131
|
-
declare const GENESIS_HASH: string;
|
|
132
|
-
declare function computeEntryHash(entryWithoutHash: Omit<AuditEntry, "entryHash">): string;
|
|
133
|
-
declare class AuditLogger {
|
|
134
|
-
private entries;
|
|
135
|
-
private lastEntryHash;
|
|
136
|
-
private filePath?;
|
|
137
|
-
constructor(filePath?: string);
|
|
138
|
-
recordExecution(params: AuditRecordParams): AuditEntry;
|
|
139
|
-
getEntries(): readonly AuditEntry[];
|
|
140
|
-
getEntryCount(): number;
|
|
141
|
-
verifyIntegrity(): {
|
|
142
|
-
valid: boolean;
|
|
143
|
-
totalEntries: number;
|
|
144
|
-
brokenIndex?: number;
|
|
145
|
-
reason?: string;
|
|
146
|
-
};
|
|
147
|
-
exportJsonl(): string;
|
|
148
|
-
private loadFromFile;
|
|
149
|
-
}
|
|
150
|
-
declare const globalAuditLogger: AuditLogger;
|
|
151
|
-
|
|
152
103
|
/** Single named entity detected by the NER scanner. */
|
|
153
104
|
interface NerEntity {
|
|
154
105
|
type: "person" | "place" | "organization";
|
|
@@ -563,4 +514,4 @@ declare class LiopServer {
|
|
|
563
514
|
private applyInMemoryBudget;
|
|
564
515
|
}
|
|
565
516
|
|
|
566
|
-
export { AUTH_DEFAULTS as A,
|
|
517
|
+
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 };
|
|
@@ -2,7 +2,7 @@ import { L as LiopVerifier } from './verifier-COnid_dg.js';
|
|
|
2
2
|
import { M as MeshNodeConfig } from './node-B0b2vUFS.js';
|
|
3
3
|
import * as grpc from '@grpc/grpc-js';
|
|
4
4
|
import { EventEmitter } from 'node:events';
|
|
5
|
-
import { M as McpEra, C as CallToolRequest, a as CallToolResult } from './types-
|
|
5
|
+
import { M as McpEra, C as CallToolRequest, a as CallToolResult } from './types-Bo6hcrS6.js';
|
|
6
6
|
|
|
7
7
|
interface CertManagerOptions {
|
|
8
8
|
/** Path to the root CA certificate (PEM format) */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export { LiopBridgeOptions, LiopMcpBridge, LiopStreamBridge, LiopStreamBridgeOptions } from './bridge.js';
|
|
2
|
-
import { L as LiopTlsOptions } from './index-
|
|
3
|
-
export { C as CertInfo, a as CertManager, b as CertManagerOptions, c as LiopClient, d as createChannelCredentials, e as createServerCredentials } from './index-
|
|
2
|
+
import { L as LiopTlsOptions } from './index-kOdMjin6.js';
|
|
3
|
+
export { C as CertInfo, a as CertManager, b as CertManagerOptions, c as LiopClient, d as createChannelCredentials, e as createServerCredentials } from './index-kOdMjin6.js';
|
|
4
4
|
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-
|
|
6
|
-
import { A as AuthInfo } from './types-
|
|
7
|
-
export {
|
|
5
|
+
export { I as InMemoryRateLimiter, L as LiopHybridGateway, a as LiopMcpRouter, R as RateLimitStatus, b as RateLimiterOptions } from './hybrid-DO3XTxqT.js';
|
|
6
|
+
import { A as AuthInfo } from './types-Bo6hcrS6.js';
|
|
7
|
+
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-Bo6hcrS6.js';
|
|
8
8
|
export { L as LiopManifest, a as MeshNode, M as MeshNodeConfig } from './node-B0b2vUFS.js';
|
|
9
9
|
export { SWARM_KEY_BYTE_LENGTH, createSwarmKey, deserializeSwarmKey, loadSwarmKey, parseSwarmKey, saveSwarmKey, serializeSwarmKey } from './mesh.js';
|
|
10
10
|
import * as grpc from '@grpc/grpc-js';
|
|
11
|
-
export { A as AUTH_DEFAULTS, b as AggregationPolicy, c as
|
|
11
|
+
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-DW1-7ClN.js';
|
|
12
12
|
import * as jose from 'jose';
|
|
13
13
|
import Provider from 'oidc-provider';
|
|
14
14
|
import '@modelcontextprotocol/sdk/server/mcp.js';
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
export { WasiSandbox, calculateAstInstructionFuel, getDefaultEnvironment } from './chunk-7BSCUYUE.js';
|
|
2
|
-
export { AesGcmWrapper, LiopClient, LiopRpcClient } from './chunk-
|
|
3
|
-
export { LiopMcpBridge, LiopStreamBridge } from './chunk-
|
|
4
|
-
export { GRPC_WEB_CONSTANTS, InMemoryRateLimiter, LiopHybridGateway, buildProtectedResourceMetadata, decodeFrames, dispatchGrpcWebRequest, encodeDataFrame, encodeTrailerFrame, executeGatewayInterceptor, isGrpcWebRequest } from './chunk-
|
|
5
|
-
export { RoutingTable, probeTopology } from './chunk-
|
|
6
|
-
export { TokenManager } from './chunk-
|
|
7
|
-
export { AUTH_DEFAULTS, AuditLogger, GENESIS_HASH, JwtValidator, LiopRpcServer, LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner, computeEntryHash, createOAuthServer, globalAuditLogger } from './chunk-
|
|
2
|
+
export { AesGcmWrapper, LiopClient, LiopRpcClient } from './chunk-Y6YXTITY.js';
|
|
3
|
+
export { LiopMcpBridge, LiopStreamBridge } from './chunk-ZKKAUQ3E.js';
|
|
4
|
+
export { GRPC_WEB_CONSTANTS, InMemoryRateLimiter, LiopHybridGateway, buildProtectedResourceMetadata, decodeFrames, dispatchGrpcWebRequest, encodeDataFrame, encodeTrailerFrame, executeGatewayInterceptor, isGrpcWebRequest } from './chunk-G5HHJVD4.js';
|
|
5
|
+
export { RoutingTable, probeTopology } from './chunk-PUDETPL4.js';
|
|
6
|
+
export { TokenManager } from './chunk-3QH44NKZ.js';
|
|
7
|
+
export { AUTH_DEFAULTS, AuditLogger, GENESIS_HASH, JwtValidator, LiopRpcServer, LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner, computeEntryHash, createOAuthServer, globalAuditLogger } from './chunk-O37AERO7.js';
|
|
8
8
|
export { sanitizeOutput } from './chunk-Y62GORQF.js';
|
|
9
|
-
export { LiopMcpRouter } from './chunk-
|
|
10
|
-
export { HeuristicTokenEstimator, LiopOTelBridge, RealTokenEstimator, TokenTelemetryEngine, createSyncTokenEstimator, createTokenEstimator } from './chunk-
|
|
11
|
-
import './chunk-
|
|
9
|
+
export { LiopMcpRouter } from './chunk-FPL5ZKW5.js';
|
|
10
|
+
export { HeuristicTokenEstimator, LiopOTelBridge, RealTokenEstimator, TokenTelemetryEngine, createSyncTokenEstimator, createTokenEstimator } from './chunk-H2SNR7PB.js';
|
|
11
|
+
import './chunk-2STZHJ24.js';
|
|
12
12
|
import './chunk-IK7CGWAZ.js';
|
|
13
13
|
export { Kyber768Wrapper } from './chunk-7PITYWOV.js';
|
|
14
14
|
export { DILITHIUM65_CONSTANTS, Dilithium65Wrapper, LIOP_SCOPES, authorizeRequest } from './chunk-VH4K4U45.js';
|
|
15
|
-
export { GRPC_CHANNEL_OPTIONS, createChannelCredentials, createServerCredentials } from './chunk-
|
|
15
|
+
export { GRPC_CHANNEL_OPTIONS, createChannelCredentials, createServerCredentials } from './chunk-3UBNOYMH.js';
|
|
16
16
|
export { Counter, Gauge, Histogram, MetricsRegistry, egressBlocksTotal, fuelConsumed, manifestCacheSize, meshPeersConnected, operationDurationMs, pqcHandshakeDurationMs, pqcHandshakesTotal, protocolMetrics, tokensInputTotal, tokensOutputTotal, tokensSavedTotal, toolCallErrorsTotal, toolCallsTotal, wireEgressBytesTotal, wireSavedBytesTotal, zkVerificationDurationMs, zkVerificationsTotal } from './chunk-PAICJCKJ.js';
|
|
17
|
-
export { MCP_LEGACY_SUPPORT_ENABLED, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_LEGACY, PromptSchema, ResourceSchema, ToolSchema } from './chunk-
|
|
17
|
+
export { MCP_LEGACY_SUPPORT_ENABLED, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_LEGACY, PromptSchema, ResourceSchema, ToolSchema } from './chunk-2KSO3W4A.js';
|
|
18
18
|
export { SWARM_KEY_BYTE_LENGTH, createSwarmKey, deserializeSwarmKey, loadSwarmKey, parseSwarmKey, saveSwarmKey, serializeSwarmKey } from './chunk-ZP3VVXOI.js';
|
|
19
|
-
export { MeshNode } from './chunk-
|
|
20
|
-
import { log } from './chunk-
|
|
19
|
+
export { MeshNode } from './chunk-XRDN232O.js';
|
|
20
|
+
import { log } from './chunk-K3DGJLUY.js';
|
|
21
|
+
export { LiopLogger, log } from './chunk-K3DGJLUY.js';
|
|
21
22
|
import * as crypto from 'crypto';
|
|
22
23
|
import { EventEmitter } from 'events';
|
|
23
24
|
import * as fs from 'fs';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/observability/tracing.ts","../src/prompts/adapters.ts","../src/security/cert-manager.ts"],"names":["ErrorCode","crypto2"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAK,SAAA,qBAAAA,UAAAA,KAAL;AACN,EAAAA,WAAA,qBAAA,CAAA,GAAsB,qBAAA;AACtB,EAAAA,WAAA,eAAA,CAAA,GAAgB,eAAA;AAChB,EAAAA,WAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,WAAA,eAAA,CAAA,GAAgB,eAAA;AAChB,EAAAA,WAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,WAAA,sBAAA,CAAA,GAAuB,sBAAA;AACvB,EAAAA,WAAA,iBAAA,CAAA,GAAkB,iBAAA;AAClB,EAAAA,WA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,IAAA;AAAA,MACH,CAAA,0DAAA,EAA6D,SAAS,aAAa,CAAA,MAAA;AAAA,KACpF;AACA,IAAA,IAAA,CAAK,IAAA,CAAK,UAAU,QAAQ,CAAA;AAC5B,IAAA,OAAO,QAAA;AAAA,EACR;AAAA,EAEO,WAAA,GAA6B;AACnC,IAAA,OAAO,IAAA,CAAK,cAAA;AAAA,EACb;AAAA,EAEO,YAAA,GAAuB;AAC7B,IAAA,IAAI,CAAC,KAAK,eAAA,EAAiB;AAC1B,MAAA,MAAM,IAAI,MAAM,6CAA6C,CAAA;AAAA,IAC9D;AACA,IAAA,OAAO,IAAA,CAAK,eAAA;AAAA,EACb;AAAA,EAEO,aAAA,GAAwB;AAC9B,IAAA,IAAI,CAAC,KAAK,gBAAA,EAAkB;AAC3B,MAAA,MAAM,IAAI,MAAM,uCAAuC,CAAA;AAAA,IACxD;AACA,IAAA,OAAO,IAAA,CAAK,gBAAA;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKO,OAAA,GAAgB;AACtB,IAAA,IAAI,KAAK,mBAAA,EAAqB;AAC7B,MAAA,YAAA,CAAa,KAAK,mBAAmB,CAAA;AACrC,MAAA,IAAA,CAAK,mBAAA,GAAsB,IAAA;AAAA,IAC5B;AACA,IAAA,KAAA,MAAW,OAAA,IAAW,KAAK,QAAA,EAAU;AACpC,MAAA,IAAI;AACH,QAAA,OAAA,CAAQ,KAAA,EAAM;AAAA,MACf,CAAA,CAAA,MAAQ;AAAA,MAER;AAAA,IACD;AACA,IAAA,IAAA,CAAK,WAAW,EAAC;AACjB,IAAA,IAAA,CAAK,kBAAA,EAAmB;AAAA,EACzB;AACD","file":"index.js","sourcesContent":["// Copyright 2026 Nekzus Solutions and contributors\n// SPDX-License-Identifier: Apache-2.0\n\nexport enum ErrorCode {\n\tCapabilityViolation = \"CapabilityViolation\",\n\tSandboxEscape = \"SandboxEscape\",\n\tPiiLeak = \"PiiLeak\",\n\tInvalidIntent = \"InvalidIntent\",\n\tThrottled = \"Throttled\",\n\tZkVerificationFailed = \"ZkVerificationFailed\",\n\tMeshUnavailable = \"MeshUnavailable\",\n\tConnectionFailed = \"ConnectionFailed\",\n}\n\nexport class LiopError extends Error {\n\tpublic readonly code: ErrorCode;\n\n\tconstructor(code: ErrorCode, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"LiopError\";\n\t\tthis.code = code;\n\t}\n}\n","// Copyright 2026 Nekzus Solutions and contributors\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * LIOP OpenTelemetry Distributed Tracing (Phase Beta-3)\n * W3C TraceContext compliant distributed tracer for gRPC & MCP transports.\n * Spec: https://www.w3.org/TR/trace-context/\n */\n\nimport * as crypto from \"node:crypto\";\n\nexport interface SpanContext {\n\ttraceId: string;\n\tspanId: string;\n\tsampled: boolean;\n}\n\nexport interface LiopSpan {\n\treadonly name: string;\n\treadonly context: SpanContext;\n\treadonly startTime: number;\n\tendTime?: number;\n\tattributes: Record<string, string | number | boolean>;\n\tstatus: \"OK\" | \"ERROR\";\n\terror?: string;\n\tsetAttribute(key: string, value: string | number | boolean): LiopSpan;\n\trecordException(error: Error | string): LiopSpan;\n\tend(): void;\n}\n\nconst TRACEPARENT_REGEX =\n\t/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/;\n\nexport class LiopTracer {\n\tpublic static generateTraceId(): string {\n\t\tlet id: string;\n\t\tdo {\n\t\t\tid = crypto.randomBytes(16).toString(\"hex\");\n\t\t} while (id === \"0\".repeat(32));\n\t\treturn id;\n\t}\n\n\tpublic static generateSpanId(): string {\n\t\tlet id: string;\n\t\tdo {\n\t\t\tid = crypto.randomBytes(8).toString(\"hex\");\n\t\t} while (id === \"0\".repeat(16));\n\t\treturn id;\n\t}\n\n\tpublic static formatTraceparent(\n\t\ttraceId: string,\n\t\tspanId: string,\n\t\tsampled = true,\n\t): string {\n\t\tconst flags = sampled ? \"01\" : \"00\";\n\t\treturn `00-${traceId}-${spanId}-${flags}`;\n\t}\n\n\tpublic static parseTraceparent(header?: string | null): SpanContext | null {\n\t\tif (!header || typeof header !== \"string\") {\n\t\t\treturn null;\n\t\t}\n\t\tconst trimmed = header.trim();\n\t\tconst match = TRACEPARENT_REGEX.exec(trimmed);\n\t\tif (!match) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst [, version, traceId, spanId, flags] = match;\n\t\t// Version 00 cannot have all-zeros traceId or spanId\n\t\tif (version === \"00\") {\n\t\t\tif (traceId === \"0\".repeat(32) || spanId === \"0\".repeat(16)) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tconst sampled = (Number.parseInt(flags, 16) & 0x01) === 1;\n\t\treturn {\n\t\t\ttraceId,\n\t\t\tspanId,\n\t\t\tsampled,\n\t\t};\n\t}\n\n\tpublic static injectTraceparent(\n\t\tcarrier: Record<string, string | string[] | undefined>,\n\t\tcontext: SpanContext,\n\t): void {\n\t\tcarrier.traceparent = LiopTracer.formatTraceparent(\n\t\t\tcontext.traceId,\n\t\t\tcontext.spanId,\n\t\t\tcontext.sampled,\n\t\t);\n\t}\n\n\tpublic static extractTraceparent(\n\t\tcarrier: Record<string, string | string[] | undefined>,\n\t): SpanContext | null {\n\t\tconst val = carrier.traceparent || carrier.Traceparent;\n\t\tif (Array.isArray(val)) {\n\t\t\treturn LiopTracer.parseTraceparent(val[0]);\n\t\t}\n\t\treturn LiopTracer.parseTraceparent(val);\n\t}\n\n\tpublic startSpan(\n\t\tname: string,\n\t\tparent?: SpanContext | null,\n\t\tattributes: Record<string, string | number | boolean> = {},\n\t): LiopSpan {\n\t\tconst traceId = parent?.traceId || LiopTracer.generateTraceId();\n\t\tconst spanId = LiopTracer.generateSpanId();\n\t\tconst sampled = parent ? parent.sampled : true;\n\n\t\tconst context: SpanContext = {\n\t\t\ttraceId,\n\t\t\tspanId,\n\t\t\tsampled,\n\t\t};\n\n\t\tconst span: LiopSpan = {\n\t\t\tname,\n\t\t\tcontext,\n\t\t\tstartTime: Date.now(),\n\t\t\tattributes: { ...attributes },\n\t\t\tstatus: \"OK\",\n\t\t\tsetAttribute(key, value) {\n\t\t\t\tthis.attributes[key] = value;\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\trecordException(err) {\n\t\t\t\tthis.status = \"ERROR\";\n\t\t\t\tthis.error = typeof err === \"string\" ? err : err.message;\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tend() {\n\t\t\t\tthis.endTime = Date.now();\n\t\t\t},\n\t\t};\n\n\t\treturn span;\n\t}\n}\n\nexport const defaultTracer = new LiopTracer();\n","// Copyright 2026 Nekzus Solutions and contributors\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * LIOP Cross-AI Prompt Adapters (Fase 92)\n *\n * Normalizes system instructions for different LLM providers (Claude, OpenAI, Gemini)\n * to ensure they understand how to generate \"Logic-on-Origin\" WASM-compatible payload structures.\n */\n\nexport type AIProvider = \"claude\" | \"openai\" | \"gemini\";\n\nexport interface PromptConfig {\n\txmlStandard: boolean;\n\tjsonSchemaPreferred: boolean;\n}\n\nconst PROVIDER_CONFIGS: Record<AIProvider, PromptConfig> = {\n\tclaude: { xmlStandard: true, jsonSchemaPreferred: false },\n\topenai: { xmlStandard: false, jsonSchemaPreferred: true },\n\tgemini: { xmlStandard: false, jsonSchemaPreferred: true },\n};\n\n/**\n * Generates specific System Prompts optimized for the provided AI.\n * This instructs the LLM on how to bypass Context-Pulling and use Logic-Injection (Zero-Shot).\n */\nexport function generateSystemInstructions(provider: AIProvider): string {\n\tconst config = PROVIDER_CONFIGS[provider];\n\n\tlet instructions = `[LIOP-PROTO-V1: LOGIC-ON-ORIGIN SPECIFICATION]\nYou are interacting with a Logic-Injection-on-Origin Protocol (LIOP) Mesh Network.\nUnlike standard MCP where you pull context to evaluate it remotely, in LIOP you WRITE code that executes on the data's origin.\n\n### CORE PARADIGM\nWhen you call a tool or resource, you MUST provide a payload that represents secure sandboxed logic to be executed on the remote Node.\nThe node will execute your logic securely on the raw secure data, and return only the RESULT, avoiding PII data egress.\n\n### EXECUTION RULES\n1. Provide a self-contained JavaScript syntax block that we will compile to WASM-Sandboxed logic.\n2. Rely only on standard ECMA script features (No Node.js polyfills).\n3. The logic must end by returning the calculated insights, not the raw data.\n\n### DIFFERENTIAL PRIVACY (DP) MECHANISM (Laplace Mechanism)\nTo prevent database reconstruction and inference attacks, numeric query outputs are processed by a Laplace DP engine:\n- COUNT / LENGTH queries: To get EXACT integer values without noise, you MUST name return keys containing 'count', 'length', 'size', 'num', 'positive', 'negative', or starting with 'total_' or 'num_' (e.g. 'total_tx', 'credits_count'). This forces sensitivity=1.0, rounds values, and clamps to non-negative values.\n- AVERAGE queries: Return keys containing 'avg', 'mean', or 'average' scale down noise automatically by dividing global sensitivity by the dataset size (sensitivity / n).\n- SUM / OTHER queries: Return keys without these semantic names receive full Laplace noise based on the global node sensitivity (which can be up to 100,000 in Bank nodes to protect raw balances). Do NOT attempt to bypass this by renaming sum fields to count fields, as it violates protocol integrity.\n\n### SANDBOX RUNTIME RESTRICTIONS & WORKAROUNDS\n- Date is poisoned: The 'Date' class/constructor is undefined (calling 'new Date()', 'Date.now()', or 'Date.parse()' will crash the execution).\n - Workaround: Perform chronological sorting and comparisons lexicographically on ISO 8601 string dates (e.g. record.date >= '2024-01-01').\n- Poisoned globals: eval, Function, setTimeout, setInterval, Buffer, ArrayBuffer, and TypedArrays are undefined.\n- Frozen prototypes: Modifications to Object.prototype, Array.prototype, etc., are blocked.\n- K-Anonymity constraints: Small datasets (< 10 records) limit outputs to max 3 scalar keys with NO nesting. Datasets with >= 10 records limit outputs to max 10 fields.\n`;\n\n\tif (config.xmlStandard) {\n\t\tinstructions += `\n### PAYLOAD FORMATTING (CLAUDE-XML PREFERRED)\nYou must wrap your logic precisely within <liop_logic> tags.\nExample:\n<liop_logic>\nconst records = await liop.readResource(\"liop://vault/patients\");\nconst filtered = records.filter(r => r.disease === \"Hypertension\");\nreturn { alert: \"High risk demographic\", targetCount: filtered.length };\n</liop_logic>\n`;\n\t} else if (config.jsonSchemaPreferred) {\n\t\tinstructions += `\n### PAYLOAD FORMATTING (JSON PARSING PREFERRED)\nYou must provide your logic strictly within a JSON string key called \\`\"logic_blob\"\\` inside your tool call parameters.\nExample:\n{\n \"target\": \"liop://vault/patients\",\n \"logic_blob\": \"const records = await liop.readResource(args.target); return { targetCount: records.filter(r => r.disease === 'Hypertension').length };\"\n}\n`;\n\t}\n\n\treturn instructions;\n}\n","// Copyright 2026 Nekzus Solutions and contributors\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * LIOP Certificate Manager (CertManager)\n * Provides automated certificate monitoring, X.509 validity inspection,\n * and hot-reloading for mutual TLS (mTLS) without node restarts.\n *\n * Compliance:\n * - NIST SP 800-52 Rev. 2: Guidelines for the Selection and Use of TLS\n * - Zero-Trust Architecture (NIST SP 800-207): Continuous cryptographic verification\n */\n\nimport * as crypto from \"node:crypto\";\nimport { EventEmitter } from \"node:events\";\nimport * as fs from \"node:fs\";\nimport { log } from \"../utils/logger.js\";\n\nexport interface CertManagerOptions {\n\t/** Path to the root CA certificate (PEM format) */\n\trootCertPath?: string;\n\t/** Path to the server/client certificate chain (PEM format) */\n\tcertChainPath: string;\n\t/** Path to the private key (PEM format) */\n\tprivateKeyPath: string;\n\t/** Expiration warning threshold in days (default: 30) */\n\twarningDays?: number;\n\t/** Enable file watching for automatic hot-reloading (default: true) */\n\twatchFiles?: boolean;\n\t/** Debounce delay in ms for hot reloading (default: 150) */\n\tdebounceMs?: number;\n}\n\nexport interface CertInfo {\n\tsubject: string;\n\tissuer: string;\n\tvalidFrom: string;\n\tvalidTo: string;\n\tfingerprint256: string;\n\tdaysRemaining: number;\n\tisExpired: boolean;\n\tisExpiringSoon: boolean;\n}\n\nexport class CertManager extends EventEmitter {\n\tprivate rootCertBuffer: Buffer | null = null;\n\tprivate certChainBuffer: Buffer | null = null;\n\tprivate privateKeyBuffer: Buffer | null = null;\n\tprivate watchers: fs.FSWatcher[] = [];\n\tprivate reloadDebounceTimer: NodeJS.Timeout | null = null;\n\tprivate readonly warningDays: number;\n\tprivate readonly debounceMs: number;\n\n\tconstructor(private readonly options: CertManagerOptions) {\n\t\tsuper();\n\t\tthis.warningDays = options.warningDays ?? 30;\n\t\tthis.debounceMs = options.debounceMs ?? 150;\n\t\tthis.loadCertificates();\n\n\t\tif (options.watchFiles !== false) {\n\t\t\tthis.setupWatchers();\n\t\t}\n\t}\n\n\t/**\n\t * Synchronously loads or reloads certificates from filesystem into memory.\n\t */\n\tpublic loadCertificates(): void {\n\t\ttry {\n\t\t\tif (\n\t\t\t\tthis.options.rootCertPath &&\n\t\t\t\tfs.existsSync(this.options.rootCertPath)\n\t\t\t) {\n\t\t\t\tthis.rootCertBuffer = fs.readFileSync(this.options.rootCertPath);\n\t\t\t}\n\n\t\t\tif (!fs.existsSync(this.options.certChainPath)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Certificate chain file not found: ${this.options.certChainPath}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!fs.existsSync(this.options.privateKeyPath)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Private key file not found: ${this.options.privateKeyPath}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.certChainBuffer = fs.readFileSync(this.options.certChainPath);\n\t\t\tthis.privateKeyBuffer = fs.readFileSync(this.options.privateKeyPath);\n\n\t\t\tlog.info(\"[CertManager] Certificates loaded successfully.\");\n\t\t} catch (error) {\n\t\t\tlog.error(`[CertManager] Failed to load certificates: ${error}`);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Inspects the loaded server/client certificate chain using Node.js native X509Certificate.\n\t */\n\tpublic inspectCertificate(): CertInfo {\n\t\tif (!this.certChainBuffer) {\n\t\t\tthrow new Error(\"[CertManager] No certificate loaded to inspect.\");\n\t\t}\n\n\t\tconst x509 = new crypto.X509Certificate(this.certChainBuffer);\n\t\tconst validToDate = new Date(x509.validTo);\n\t\tconst now = new Date();\n\t\tconst msRemaining = validToDate.getTime() - now.getTime();\n\t\tconst daysRemaining = Math.max(\n\t\t\t0,\n\t\t\tMath.floor(msRemaining / (1000 * 60 * 60 * 24)),\n\t\t);\n\t\tconst isExpired = msRemaining <= 0;\n\t\tconst isExpiringSoon = daysRemaining <= this.warningDays;\n\n\t\treturn {\n\t\t\tsubject: x509.subject,\n\t\t\tissuer: x509.issuer,\n\t\t\tvalidFrom: x509.validFrom,\n\t\t\tvalidTo: x509.validTo,\n\t\t\tfingerprint256: x509.fingerprint256,\n\t\t\tdaysRemaining,\n\t\t\tisExpired,\n\t\t\tisExpiringSoon,\n\t\t};\n\t}\n\n\t/**\n\t * Sets up non-blocking filesystem watchers to detect certificate renewals\n\t * and trigger hot-reloading without process restarts.\n\t */\n\tprivate setupWatchers(): void {\n\t\tconst filesToWatch = [\n\t\t\tthis.options.certChainPath,\n\t\t\tthis.options.privateKeyPath,\n\t\t\tthis.options.rootCertPath,\n\t\t].filter((p): p is string => Boolean(p && fs.existsSync(p)));\n\n\t\tfor (const filePath of filesToWatch) {\n\t\t\ttry {\n\t\t\t\tconst watcher = fs.watch(filePath, () => {\n\t\t\t\t\tthis.scheduleReload();\n\t\t\t\t});\n\t\t\t\tthis.watchers.push(watcher);\n\t\t\t} catch (err) {\n\t\t\t\tlog.warn(\n\t\t\t\t\t`[CertManager] Could not watch ${filePath} for hot reloading: ${err}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Debounces reload events to ensure files have finished writing.\n\t */\n\tprivate scheduleReload(): void {\n\t\tif (this.reloadDebounceTimer) {\n\t\t\tclearTimeout(this.reloadDebounceTimer);\n\t\t}\n\n\t\tthis.reloadDebounceTimer = setTimeout(() => {\n\t\t\ttry {\n\t\t\t\tthis.loadCertificates();\n\t\t\t\tconst certInfo = this.inspectCertificate();\n\t\t\t\tlog.info(\n\t\t\t\t\t`[CertManager] Hot reload complete. Certificate expires in ${certInfo.daysRemaining} days.`,\n\t\t\t\t);\n\t\t\t\tthis.emit(\"reload\", certInfo);\n\t\t\t} catch (error) {\n\t\t\t\tlog.error(`[CertManager] Hot reload failed: ${error}`);\n\t\t\t\tthis.emit(\"error\", error);\n\t\t\t}\n\t\t}, this.debounceMs);\n\t}\n\n\t/**\n\t * Manually triggers a reload of certificates and emits the 'reload' event.\n\t */\n\tpublic reload(): CertInfo {\n\t\tthis.loadCertificates();\n\t\tconst certInfo = this.inspectCertificate();\n\t\tlog.info(\n\t\t\t`[CertManager] Hot reload complete. Certificate expires in ${certInfo.daysRemaining} days.`,\n\t\t);\n\t\tthis.emit(\"reload\", certInfo);\n\t\treturn certInfo;\n\t}\n\n\tpublic getRootCert(): Buffer | null {\n\t\treturn this.rootCertBuffer;\n\t}\n\n\tpublic getCertChain(): Buffer {\n\t\tif (!this.certChainBuffer) {\n\t\t\tthrow new Error(\"[CertManager] Certificate chain not loaded.\");\n\t\t}\n\t\treturn this.certChainBuffer;\n\t}\n\n\tpublic getPrivateKey(): Buffer {\n\t\tif (!this.privateKeyBuffer) {\n\t\t\tthrow new Error(\"[CertManager] Private key not loaded.\");\n\t\t}\n\t\treturn this.privateKeyBuffer;\n\t}\n\n\t/**\n\t * Stops all active file watchers and releases resources.\n\t */\n\tpublic dispose(): void {\n\t\tif (this.reloadDebounceTimer) {\n\t\t\tclearTimeout(this.reloadDebounceTimer);\n\t\t\tthis.reloadDebounceTimer = null;\n\t\t}\n\t\tfor (const watcher of this.watchers) {\n\t\t\ttry {\n\t\t\t\twatcher.close();\n\t\t\t} catch {\n\t\t\t\t// Ignore watcher close errors\n\t\t\t}\n\t\t}\n\t\tthis.watchers = [];\n\t\tthis.removeAllListeners();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/observability/tracing.ts","../src/prompts/adapters.ts","../src/security/cert-manager.ts"],"names":["ErrorCode","crypto2"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAK,SAAA,qBAAAA,UAAAA,KAAL;AACN,EAAAA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A,MAER;AAAA,IACD;AACA,IAAA,IAAA,CAAK,WAAW,EAAC;AACjB,IAAA,IAAA,CAAK,kBAAA,EAAmB;AAAA,EACzB;AACD","file":"index.js","sourcesContent":["// Copyright 2026 Nekzus Solutions and contributors\n// SPDX-License-Identifier: Apache-2.0\n\nexport enum ErrorCode {\n\tCapabilityViolation = \"CapabilityViolation\",\n\tSandboxEscape = \"SandboxEscape\",\n\tPiiLeak = \"PiiLeak\",\n\tInvalidIntent = \"InvalidIntent\",\n\tThrottled = \"Throttled\",\n\tZkVerificationFailed = \"ZkVerificationFailed\",\n\tMeshUnavailable = \"MeshUnavailable\",\n\tConnectionFailed = \"ConnectionFailed\",\n}\n\nexport class LiopError extends Error {\n\tpublic readonly code: ErrorCode;\n\n\tconstructor(code: ErrorCode, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"LiopError\";\n\t\tthis.code = code;\n\t}\n}\n","// Copyright 2026 Nekzus Solutions and contributors\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * LIOP OpenTelemetry Distributed Tracing (Phase Beta-3)\n * W3C TraceContext compliant distributed tracer for gRPC & MCP transports.\n * Spec: https://www.w3.org/TR/trace-context/\n */\n\nimport * as crypto from \"node:crypto\";\n\nexport interface SpanContext {\n\ttraceId: string;\n\tspanId: string;\n\tsampled: boolean;\n}\n\nexport interface LiopSpan {\n\treadonly name: string;\n\treadonly context: SpanContext;\n\treadonly startTime: number;\n\tendTime?: number;\n\tattributes: Record<string, string | number | boolean>;\n\tstatus: \"OK\" | \"ERROR\";\n\terror?: string;\n\tsetAttribute(key: string, value: string | number | boolean): LiopSpan;\n\trecordException(error: Error | string): LiopSpan;\n\tend(): void;\n}\n\nconst TRACEPARENT_REGEX =\n\t/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/;\n\nexport class LiopTracer {\n\tpublic static generateTraceId(): string {\n\t\tlet id: string;\n\t\tdo {\n\t\t\tid = crypto.randomBytes(16).toString(\"hex\");\n\t\t} while (id === \"0\".repeat(32));\n\t\treturn id;\n\t}\n\n\tpublic static generateSpanId(): string {\n\t\tlet id: string;\n\t\tdo {\n\t\t\tid = crypto.randomBytes(8).toString(\"hex\");\n\t\t} while (id === \"0\".repeat(16));\n\t\treturn id;\n\t}\n\n\tpublic static formatTraceparent(\n\t\ttraceId: string,\n\t\tspanId: string,\n\t\tsampled = true,\n\t): string {\n\t\tconst flags = sampled ? \"01\" : \"00\";\n\t\treturn `00-${traceId}-${spanId}-${flags}`;\n\t}\n\n\tpublic static parseTraceparent(header?: string | null): SpanContext | null {\n\t\tif (!header || typeof header !== \"string\") {\n\t\t\treturn null;\n\t\t}\n\t\tconst trimmed = header.trim();\n\t\tconst match = TRACEPARENT_REGEX.exec(trimmed);\n\t\tif (!match) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst [, version, traceId, spanId, flags] = match;\n\t\t// Version 00 cannot have all-zeros traceId or spanId\n\t\tif (version === \"00\") {\n\t\t\tif (traceId === \"0\".repeat(32) || spanId === \"0\".repeat(16)) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tconst sampled = (Number.parseInt(flags, 16) & 0x01) === 1;\n\t\treturn {\n\t\t\ttraceId,\n\t\t\tspanId,\n\t\t\tsampled,\n\t\t};\n\t}\n\n\tpublic static injectTraceparent(\n\t\tcarrier: Record<string, string | string[] | undefined>,\n\t\tcontext: SpanContext,\n\t): void {\n\t\tcarrier.traceparent = LiopTracer.formatTraceparent(\n\t\t\tcontext.traceId,\n\t\t\tcontext.spanId,\n\t\t\tcontext.sampled,\n\t\t);\n\t}\n\n\tpublic static extractTraceparent(\n\t\tcarrier: Record<string, string | string[] | undefined>,\n\t): SpanContext | null {\n\t\tconst val = carrier.traceparent || carrier.Traceparent;\n\t\tif (Array.isArray(val)) {\n\t\t\treturn LiopTracer.parseTraceparent(val[0]);\n\t\t}\n\t\treturn LiopTracer.parseTraceparent(val);\n\t}\n\n\tpublic startSpan(\n\t\tname: string,\n\t\tparent?: SpanContext | null,\n\t\tattributes: Record<string, string | number | boolean> = {},\n\t): LiopSpan {\n\t\tconst traceId = parent?.traceId || LiopTracer.generateTraceId();\n\t\tconst spanId = LiopTracer.generateSpanId();\n\t\tconst sampled = parent ? parent.sampled : true;\n\n\t\tconst context: SpanContext = {\n\t\t\ttraceId,\n\t\t\tspanId,\n\t\t\tsampled,\n\t\t};\n\n\t\tconst span: LiopSpan = {\n\t\t\tname,\n\t\t\tcontext,\n\t\t\tstartTime: Date.now(),\n\t\t\tattributes: { ...attributes },\n\t\t\tstatus: \"OK\",\n\t\t\tsetAttribute(key, value) {\n\t\t\t\tthis.attributes[key] = value;\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\trecordException(err) {\n\t\t\t\tthis.status = \"ERROR\";\n\t\t\t\tthis.error = typeof err === \"string\" ? err : err.message;\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tend() {\n\t\t\t\tthis.endTime = Date.now();\n\t\t\t},\n\t\t};\n\n\t\treturn span;\n\t}\n}\n\nexport const defaultTracer = new LiopTracer();\n","// Copyright 2026 Nekzus Solutions and contributors\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * LIOP Cross-AI Prompt Adapters (Fase 92)\n *\n * Normalizes system instructions for different LLM providers (Claude, OpenAI, Gemini)\n * to ensure they understand how to generate \"Logic-on-Origin\" WASM-compatible payload structures.\n */\n\nexport type AIProvider = \"claude\" | \"openai\" | \"gemini\";\n\nexport interface PromptConfig {\n\txmlStandard: boolean;\n\tjsonSchemaPreferred: boolean;\n}\n\nconst PROVIDER_CONFIGS: Record<AIProvider, PromptConfig> = {\n\tclaude: { xmlStandard: true, jsonSchemaPreferred: false },\n\topenai: { xmlStandard: false, jsonSchemaPreferred: true },\n\tgemini: { xmlStandard: false, jsonSchemaPreferred: true },\n};\n\n/**\n * Generates specific System Prompts optimized for the provided AI.\n * This instructs the LLM on how to bypass Context-Pulling and use Logic-Injection (Zero-Shot).\n */\nexport function generateSystemInstructions(provider: AIProvider): string {\n\tconst config = PROVIDER_CONFIGS[provider];\n\n\tlet instructions = `[LIOP-PROTO-V1: LOGIC-ON-ORIGIN SPECIFICATION]\nYou are interacting with a Logic-Injection-on-Origin Protocol (LIOP) Mesh Network.\nUnlike standard MCP where you pull context to evaluate it remotely, in LIOP you WRITE code that executes on the data's origin.\n\n### CORE PARADIGM\nWhen you call a tool or resource, you MUST provide a payload that represents secure sandboxed logic to be executed on the remote Node.\nThe node will execute your logic securely on the raw secure data, and return only the RESULT, avoiding PII data egress.\n\n### EXECUTION RULES\n1. Provide a self-contained JavaScript syntax block that we will compile to WASM-Sandboxed logic.\n2. Rely only on standard ECMA script features (No Node.js polyfills).\n3. The logic must end by returning the calculated insights, not the raw data.\n\n### DIFFERENTIAL PRIVACY (DP) MECHANISM (Laplace Mechanism)\nTo prevent database reconstruction and inference attacks, numeric query outputs are processed by a Laplace DP engine:\n- COUNT / LENGTH queries: To get EXACT integer values without noise, you MUST name return keys containing 'count', 'length', 'size', 'num', 'positive', 'negative', or starting with 'total_' or 'num_' (e.g. 'total_tx', 'credits_count'). This forces sensitivity=1.0, rounds values, and clamps to non-negative values.\n- AVERAGE queries: Return keys containing 'avg', 'mean', or 'average' scale down noise automatically by dividing global sensitivity by the dataset size (sensitivity / n).\n- SUM / OTHER queries: Return keys without these semantic names receive full Laplace noise based on the global node sensitivity (which can be up to 100,000 in Bank nodes to protect raw balances). Do NOT attempt to bypass this by renaming sum fields to count fields, as it violates protocol integrity.\n\n### SANDBOX RUNTIME RESTRICTIONS & WORKAROUNDS\n- Date is poisoned: The 'Date' class/constructor is undefined (calling 'new Date()', 'Date.now()', or 'Date.parse()' will crash the execution).\n - Workaround: Perform chronological sorting and comparisons lexicographically on ISO 8601 string dates (e.g. record.date >= '2024-01-01').\n- Poisoned globals: eval, Function, setTimeout, setInterval, Buffer, ArrayBuffer, and TypedArrays are undefined.\n- Frozen prototypes: Modifications to Object.prototype, Array.prototype, etc., are blocked.\n- K-Anonymity constraints: Small datasets (< 10 records) limit outputs to max 3 scalar keys with NO nesting. Datasets with >= 10 records limit outputs to max 10 fields.\n`;\n\n\tif (config.xmlStandard) {\n\t\tinstructions += `\n### PAYLOAD FORMATTING (CLAUDE-XML PREFERRED)\nYou must wrap your logic precisely within <liop_logic> tags.\nExample:\n<liop_logic>\nconst records = await liop.readResource(\"liop://vault/patients\");\nconst filtered = records.filter(r => r.disease === \"Hypertension\");\nreturn { alert: \"High risk demographic\", targetCount: filtered.length };\n</liop_logic>\n`;\n\t} else if (config.jsonSchemaPreferred) {\n\t\tinstructions += `\n### PAYLOAD FORMATTING (JSON PARSING PREFERRED)\nYou must provide your logic strictly within a JSON string key called \\`\"logic_blob\"\\` inside your tool call parameters.\nExample:\n{\n \"target\": \"liop://vault/patients\",\n \"logic_blob\": \"const records = await liop.readResource(args.target); return { targetCount: records.filter(r => r.disease === 'Hypertension').length };\"\n}\n`;\n\t}\n\n\treturn instructions;\n}\n","// Copyright 2026 Nekzus Solutions and contributors\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * LIOP Certificate Manager (CertManager)\n * Provides automated certificate monitoring, X.509 validity inspection,\n * and hot-reloading for mutual TLS (mTLS) without node restarts.\n *\n * Compliance:\n * - NIST SP 800-52 Rev. 2: Guidelines for the Selection and Use of TLS\n * - Zero-Trust Architecture (NIST SP 800-207): Continuous cryptographic verification\n */\n\nimport * as crypto from \"node:crypto\";\nimport { EventEmitter } from \"node:events\";\nimport * as fs from \"node:fs\";\nimport { log } from \"../utils/logger.js\";\n\nexport interface CertManagerOptions {\n\t/** Path to the root CA certificate (PEM format) */\n\trootCertPath?: string;\n\t/** Path to the server/client certificate chain (PEM format) */\n\tcertChainPath: string;\n\t/** Path to the private key (PEM format) */\n\tprivateKeyPath: string;\n\t/** Expiration warning threshold in days (default: 30) */\n\twarningDays?: number;\n\t/** Enable file watching for automatic hot-reloading (default: true) */\n\twatchFiles?: boolean;\n\t/** Debounce delay in ms for hot reloading (default: 150) */\n\tdebounceMs?: number;\n}\n\nexport interface CertInfo {\n\tsubject: string;\n\tissuer: string;\n\tvalidFrom: string;\n\tvalidTo: string;\n\tfingerprint256: string;\n\tdaysRemaining: number;\n\tisExpired: boolean;\n\tisExpiringSoon: boolean;\n}\n\nexport class CertManager extends EventEmitter {\n\tprivate rootCertBuffer: Buffer | null = null;\n\tprivate certChainBuffer: Buffer | null = null;\n\tprivate privateKeyBuffer: Buffer | null = null;\n\tprivate watchers: fs.FSWatcher[] = [];\n\tprivate reloadDebounceTimer: NodeJS.Timeout | null = null;\n\tprivate readonly warningDays: number;\n\tprivate readonly debounceMs: number;\n\n\tconstructor(private readonly options: CertManagerOptions) {\n\t\tsuper();\n\t\tthis.warningDays = options.warningDays ?? 30;\n\t\tthis.debounceMs = options.debounceMs ?? 150;\n\t\tthis.loadCertificates();\n\n\t\tif (options.watchFiles !== false) {\n\t\t\tthis.setupWatchers();\n\t\t}\n\t}\n\n\t/**\n\t * Synchronously loads or reloads certificates from filesystem into memory.\n\t */\n\tpublic loadCertificates(): void {\n\t\ttry {\n\t\t\tif (\n\t\t\t\tthis.options.rootCertPath &&\n\t\t\t\tfs.existsSync(this.options.rootCertPath)\n\t\t\t) {\n\t\t\t\tthis.rootCertBuffer = fs.readFileSync(this.options.rootCertPath);\n\t\t\t}\n\n\t\t\tif (!fs.existsSync(this.options.certChainPath)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Certificate chain file not found: ${this.options.certChainPath}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!fs.existsSync(this.options.privateKeyPath)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Private key file not found: ${this.options.privateKeyPath}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.certChainBuffer = fs.readFileSync(this.options.certChainPath);\n\t\t\tthis.privateKeyBuffer = fs.readFileSync(this.options.privateKeyPath);\n\n\t\t\tlog.info(\"[CertManager] Certificates loaded successfully.\");\n\t\t} catch (error) {\n\t\t\tlog.error(`[CertManager] Failed to load certificates: ${error}`);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Inspects the loaded server/client certificate chain using Node.js native X509Certificate.\n\t */\n\tpublic inspectCertificate(): CertInfo {\n\t\tif (!this.certChainBuffer) {\n\t\t\tthrow new Error(\"[CertManager] No certificate loaded to inspect.\");\n\t\t}\n\n\t\tconst x509 = new crypto.X509Certificate(this.certChainBuffer);\n\t\tconst validToDate = new Date(x509.validTo);\n\t\tconst now = new Date();\n\t\tconst msRemaining = validToDate.getTime() - now.getTime();\n\t\tconst daysRemaining = Math.max(\n\t\t\t0,\n\t\t\tMath.floor(msRemaining / (1000 * 60 * 60 * 24)),\n\t\t);\n\t\tconst isExpired = msRemaining <= 0;\n\t\tconst isExpiringSoon = daysRemaining <= this.warningDays;\n\n\t\treturn {\n\t\t\tsubject: x509.subject,\n\t\t\tissuer: x509.issuer,\n\t\t\tvalidFrom: x509.validFrom,\n\t\t\tvalidTo: x509.validTo,\n\t\t\tfingerprint256: x509.fingerprint256,\n\t\t\tdaysRemaining,\n\t\t\tisExpired,\n\t\t\tisExpiringSoon,\n\t\t};\n\t}\n\n\t/**\n\t * Sets up non-blocking filesystem watchers to detect certificate renewals\n\t * and trigger hot-reloading without process restarts.\n\t */\n\tprivate setupWatchers(): void {\n\t\tconst filesToWatch = [\n\t\t\tthis.options.certChainPath,\n\t\t\tthis.options.privateKeyPath,\n\t\t\tthis.options.rootCertPath,\n\t\t].filter((p): p is string => Boolean(p && fs.existsSync(p)));\n\n\t\tfor (const filePath of filesToWatch) {\n\t\t\ttry {\n\t\t\t\tconst watcher = fs.watch(filePath, () => {\n\t\t\t\t\tthis.scheduleReload();\n\t\t\t\t});\n\t\t\t\tthis.watchers.push(watcher);\n\t\t\t} catch (err) {\n\t\t\t\tlog.warn(\n\t\t\t\t\t`[CertManager] Could not watch ${filePath} for hot reloading: ${err}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Debounces reload events to ensure files have finished writing.\n\t */\n\tprivate scheduleReload(): void {\n\t\tif (this.reloadDebounceTimer) {\n\t\t\tclearTimeout(this.reloadDebounceTimer);\n\t\t}\n\n\t\tthis.reloadDebounceTimer = setTimeout(() => {\n\t\t\ttry {\n\t\t\t\tthis.loadCertificates();\n\t\t\t\tconst certInfo = this.inspectCertificate();\n\t\t\t\tlog.info(\n\t\t\t\t\t`[CertManager] Hot reload complete. Certificate expires in ${certInfo.daysRemaining} days.`,\n\t\t\t\t);\n\t\t\t\tthis.emit(\"reload\", certInfo);\n\t\t\t} catch (error) {\n\t\t\t\tlog.error(`[CertManager] Hot reload failed: ${error}`);\n\t\t\t\tthis.emit(\"error\", error);\n\t\t\t}\n\t\t}, this.debounceMs);\n\t}\n\n\t/**\n\t * Manually triggers a reload of certificates and emits the 'reload' event.\n\t */\n\tpublic reload(): CertInfo {\n\t\tthis.loadCertificates();\n\t\tconst certInfo = this.inspectCertificate();\n\t\tlog.info(\n\t\t\t`[CertManager] Hot reload complete. Certificate expires in ${certInfo.daysRemaining} days.`,\n\t\t);\n\t\tthis.emit(\"reload\", certInfo);\n\t\treturn certInfo;\n\t}\n\n\tpublic getRootCert(): Buffer | null {\n\t\treturn this.rootCertBuffer;\n\t}\n\n\tpublic getCertChain(): Buffer {\n\t\tif (!this.certChainBuffer) {\n\t\t\tthrow new Error(\"[CertManager] Certificate chain not loaded.\");\n\t\t}\n\t\treturn this.certChainBuffer;\n\t}\n\n\tpublic getPrivateKey(): Buffer {\n\t\tif (!this.privateKeyBuffer) {\n\t\t\tthrow new Error(\"[CertManager] Private key not loaded.\");\n\t\t}\n\t\treturn this.privateKeyBuffer;\n\t}\n\n\t/**\n\t * Stops all active file watchers and releases resources.\n\t */\n\tpublic dispose(): void {\n\t\tif (this.reloadDebounceTimer) {\n\t\t\tclearTimeout(this.reloadDebounceTimer);\n\t\t\tthis.reloadDebounceTimer = null;\n\t\t}\n\t\tfor (const watcher of this.watchers) {\n\t\t\ttry {\n\t\t\t\twatcher.close();\n\t\t\t} catch {\n\t\t\t\t// Ignore watcher close errors\n\t\t\t}\n\t\t}\n\t\tthis.watchers = [];\n\t\tthis.removeAllListeners();\n\t}\n}\n"]}
|
package/dist/mesh.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './chunk-FTF6AMF6.js';
|
|
2
2
|
export { SWARM_KEY_BYTE_LENGTH, createSwarmKey, deserializeSwarmKey, loadSwarmKey, parseSwarmKey, saveSwarmKey, serializeSwarmKey } from './chunk-ZP3VVXOI.js';
|
|
3
|
-
export { MeshNode } from './chunk-
|
|
4
|
-
import './chunk-
|
|
3
|
+
export { MeshNode } from './chunk-XRDN232O.js';
|
|
4
|
+
import './chunk-K3DGJLUY.js';
|
|
5
5
|
//# sourceMappingURL=mesh.js.map
|
|
6
6
|
//# sourceMappingURL=mesh.js.map
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { b as AggregationPolicy, L as LiopServer, a as LiopServerOptions,
|
|
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-DW1-7ClN.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import './node-B0b2vUFS.js';
|
|
4
|
-
import './types-
|
|
4
|
+
import './types-Bo6hcrS6.js';
|
|
5
5
|
import 'jose';
|
package/dist/server.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner } from './chunk-
|
|
1
|
+
export { LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner } from './chunk-O37AERO7.js';
|
|
2
2
|
export { sanitizeOutput } from './chunk-Y62GORQF.js';
|
|
3
3
|
import './chunk-VH4K4U45.js';
|
|
4
|
-
import './chunk-
|
|
4
|
+
import './chunk-3UBNOYMH.js';
|
|
5
5
|
import './chunk-PAICJCKJ.js';
|
|
6
|
-
import './chunk-
|
|
7
|
-
import './chunk-
|
|
6
|
+
import './chunk-XRDN232O.js';
|
|
7
|
+
import './chunk-K3DGJLUY.js';
|
|
8
8
|
//# sourceMappingURL=server.js.map
|
|
9
9
|
//# sourceMappingURL=server.js.map
|
|
@@ -1,6 +1,80 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as jose from 'jose';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Technology-agnostic cryptographic audit interceptor.
|
|
6
|
+
*
|
|
7
|
+
* Fires asynchronously (fire-and-forget) AFTER each AuditEntry
|
|
8
|
+
* has been sealed (hash computed, chain linked, and optionally
|
|
9
|
+
* persisted to JSONL). The interceptor receives a frozen deep-clone
|
|
10
|
+
* of the completed AuditEntry — mutations cannot tamper with the
|
|
11
|
+
* hash chain.
|
|
12
|
+
*
|
|
13
|
+
* Use cases: forward audit entries to TypeSafe Jev for threat
|
|
14
|
+
* pattern detection, stream to SOC 2 SIEM aggregators, trigger
|
|
15
|
+
* PagerDuty alerts on BLOCKED_EGRESS/POLICY_VIOLATION statuses,
|
|
16
|
+
* or feed into compliance dashboards.
|
|
17
|
+
*/
|
|
18
|
+
type AuditInterceptor = (entry: Readonly<AuditEntry>) => void | Promise<void>;
|
|
19
|
+
|
|
20
|
+
type AuditStatus = "SUCCESS" | "BLOCKED_EGRESS" | "ERROR" | "POLICY_VIOLATION";
|
|
21
|
+
interface AuditEntry {
|
|
22
|
+
id: string;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
traceId: string;
|
|
25
|
+
agentDid: string;
|
|
26
|
+
peerId: string;
|
|
27
|
+
toolName: string;
|
|
28
|
+
datasetHash: string;
|
|
29
|
+
fuelConsumed: number;
|
|
30
|
+
outputHash: string;
|
|
31
|
+
zkReceiptSig: string;
|
|
32
|
+
status: AuditStatus;
|
|
33
|
+
prevEntryHash: string;
|
|
34
|
+
entryHash: string;
|
|
35
|
+
}
|
|
36
|
+
interface AuditRecordParams {
|
|
37
|
+
timestamp?: string;
|
|
38
|
+
traceId?: string;
|
|
39
|
+
agentDid: string;
|
|
40
|
+
peerId: string;
|
|
41
|
+
toolName: string;
|
|
42
|
+
datasetHash?: string;
|
|
43
|
+
fuelConsumed: number;
|
|
44
|
+
outputHash?: string;
|
|
45
|
+
zkReceiptSig?: string;
|
|
46
|
+
status: AuditStatus;
|
|
47
|
+
}
|
|
48
|
+
declare const GENESIS_HASH: string;
|
|
49
|
+
declare function computeEntryHash(entryWithoutHash: Omit<AuditEntry, "entryHash">): string;
|
|
50
|
+
declare class AuditLogger {
|
|
51
|
+
private entries;
|
|
52
|
+
private lastEntryHash;
|
|
53
|
+
private filePath?;
|
|
54
|
+
private interceptor?;
|
|
55
|
+
constructor(filePath?: string);
|
|
56
|
+
/**
|
|
57
|
+
* Registers a technology-agnostic audit interceptor.
|
|
58
|
+
* The interceptor fires AFTER the entry is sealed (hash computed)
|
|
59
|
+
* and appended to the chain. It receives a frozen deep-clone
|
|
60
|
+
* that cannot tamper with the hash chain.
|
|
61
|
+
* Pass `undefined` to disable interception (zero overhead).
|
|
62
|
+
*/
|
|
63
|
+
setInterceptor(interceptor: AuditInterceptor | undefined): void;
|
|
64
|
+
recordExecution(params: AuditRecordParams): AuditEntry;
|
|
65
|
+
getEntries(): readonly AuditEntry[];
|
|
66
|
+
getEntryCount(): number;
|
|
67
|
+
verifyIntegrity(): {
|
|
68
|
+
valid: boolean;
|
|
69
|
+
totalEntries: number;
|
|
70
|
+
brokenIndex?: number;
|
|
71
|
+
reason?: string;
|
|
72
|
+
};
|
|
73
|
+
exportJsonl(): string;
|
|
74
|
+
private loadFromFile;
|
|
75
|
+
}
|
|
76
|
+
declare const globalAuditLogger: AuditLogger;
|
|
77
|
+
|
|
4
78
|
/**
|
|
5
79
|
* LIOP JWT Validator — Token Verification Engine
|
|
6
80
|
*
|
|
@@ -156,6 +230,69 @@ interface GatewayInterceptorOptions {
|
|
|
156
230
|
*/
|
|
157
231
|
declare function executeGatewayInterceptor(request: McpRequest, context: Omit<GatewayInterceptorContext, "signal">, options: Required<Pick<GatewayInterceptorOptions, "interceptor">> & GatewayInterceptorOptions): Promise<GatewayAdmissionResult>;
|
|
158
232
|
|
|
233
|
+
type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
234
|
+
/**
|
|
235
|
+
* LiopLogger - Structured Logging Abstraction
|
|
236
|
+
* Configurable via `process.env.LIOP_LOG_LEVEL`.
|
|
237
|
+
* Emits strictly to stderr to comply with MCP stdio protocols.
|
|
238
|
+
*/
|
|
239
|
+
declare class LiopLogger {
|
|
240
|
+
private static instance;
|
|
241
|
+
private level;
|
|
242
|
+
private interceptor?;
|
|
243
|
+
private _isIntercepting;
|
|
244
|
+
private constructor();
|
|
245
|
+
static getInstance(): LiopLogger;
|
|
246
|
+
private setLevelFromEnv;
|
|
247
|
+
setLevel(level: LogLevel): void;
|
|
248
|
+
/**
|
|
249
|
+
* Registers a technology-agnostic log interceptor.
|
|
250
|
+
* Pass `undefined` to disable interception (zero overhead).
|
|
251
|
+
*/
|
|
252
|
+
setInterceptor(interceptor: LogInterceptor | undefined): void;
|
|
253
|
+
private shouldLog;
|
|
254
|
+
private formatMessage;
|
|
255
|
+
/**
|
|
256
|
+
* Fire-and-forget async dispatch to the registered interceptor.
|
|
257
|
+
* Recursion guard prevents infinite loops when the interceptor
|
|
258
|
+
* itself triggers logging (directly or transitively).
|
|
259
|
+
*/
|
|
260
|
+
private emitToInterceptor;
|
|
261
|
+
error(message: string, ...args: unknown[]): void;
|
|
262
|
+
warn(message: string, ...args: unknown[]): void;
|
|
263
|
+
info(message: string, ...args: unknown[]): void;
|
|
264
|
+
debug(message: string, ...args: unknown[]): void;
|
|
265
|
+
}
|
|
266
|
+
declare const log: LiopLogger;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Structured snapshot of an operational log event.
|
|
270
|
+
* Frozen copy — mutations have no effect on the logger.
|
|
271
|
+
*/
|
|
272
|
+
interface LogEvent {
|
|
273
|
+
/** ISO 8601 timestamp of the log emission. */
|
|
274
|
+
timestamp: string;
|
|
275
|
+
/** Severity level that triggered this event. */
|
|
276
|
+
level: LogLevel;
|
|
277
|
+
/** Formatted log message (already interpolated by LiopLogger). */
|
|
278
|
+
message: string;
|
|
279
|
+
/** Additional variadic arguments passed to the log method. */
|
|
280
|
+
args: readonly unknown[];
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Technology-agnostic operational log interceptor.
|
|
284
|
+
*
|
|
285
|
+
* Fires asynchronously (fire-and-forget) after each log emission
|
|
286
|
+
* that passes the current level filter. The interceptor receives
|
|
287
|
+
* a frozen snapshot of the log event. Errors thrown by the
|
|
288
|
+
* interceptor are caught silently and never propagate to the caller.
|
|
289
|
+
*
|
|
290
|
+
* Use cases: forward logs to TypeSafe Jev for anomaly detection,
|
|
291
|
+
* stream to a SIEM (Splunk, Datadog), aggregate in NotebookLM,
|
|
292
|
+
* or persist to a custom observability backend.
|
|
293
|
+
*/
|
|
294
|
+
type LogInterceptor = (event: Readonly<LogEvent>) => void | Promise<void>;
|
|
295
|
+
|
|
159
296
|
/**
|
|
160
297
|
* Protocol Version Identifiers
|
|
161
298
|
*/
|
|
@@ -312,4 +449,4 @@ interface McpResponse {
|
|
|
312
449
|
};
|
|
313
450
|
}
|
|
314
451
|
|
|
315
|
-
export { type AuthInfo as A, type CallToolRequest as C, type DiscoverResult as D, type GatewayInterceptorOptions as G, type InputRequest as I, JwtValidator as J, type McpEra as M, type Prompt as P, type Resource as R, type ServerInfo as S, type Tool as T, type CallToolResult as a, type McpRequest as b, type McpResponse as c,
|
|
452
|
+
export { type AuthInfo as A, ToolSchema as B, type CallToolRequest as C, type DiscoverResult as D, computeEntryHash as E, executeGatewayInterceptor as F, type GatewayInterceptorOptions as G, globalAuditLogger as H, type InputRequest as I, JwtValidator as J, log as K, LiopLogger as L, type McpEra as M, type Prompt as P, type Resource as R, type ServerInfo as S, type Tool as T, type CallToolResult as a, type McpRequest as b, type McpResponse as c, AuditLogger as d, type GetPromptRequest as e, type GetPromptResult as f, type AuditEntry as g, type AuditInterceptor as h, type AuditRecordParams as i, type AuditStatus as j, type CacheableResult as k, GENESIS_HASH as l, type GatewayAdmissionResult as m, type GatewayInterceptor as n, type GatewayInterceptorContext as o, type InputRequiredResult as p, type InputResponse as q, type LogEvent as r, type LogInterceptor as s, type LogLevel as t, MCP_LEGACY_SUPPORT_ENABLED as u, MCP_PROTOCOL_VERSION as v, MCP_PROTOCOL_VERSION_LEGACY as w, type McpRequestMeta as x, PromptSchema as y, ResourceSchema as z };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'zod';
|
|
2
|
-
export { A as AuthInfo,
|
|
2
|
+
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-Bo6hcrS6.js';
|
|
3
3
|
import 'jose';
|
package/dist/types.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { MCP_LEGACY_SUPPORT_ENABLED, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_LEGACY, PromptSchema, ResourceSchema, ToolSchema } from './chunk-
|
|
1
|
+
export { MCP_LEGACY_SUPPORT_ENABLED, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_LEGACY, PromptSchema, ResourceSchema, ToolSchema } from './chunk-2KSO3W4A.js';
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
|
3
3
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"verifier-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"verifier-XFU7ZB2W.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nekzus/liop",
|
|
3
|
-
"version": "2.4.0-alpha.
|
|
3
|
+
"version": "2.4.0-alpha.15",
|
|
4
4
|
"description": "Official SDK for Logic-Injection-on-Origin Protocol (LIOP). Deploy Logic-on-Origin with WebAssembly at gRPC speed and bidirectional MCP compatibility.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/dist/chunk-HA6YZ42O.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// src/utils/logger.ts
|
|
2
|
-
var LiopLogger = class _LiopLogger {
|
|
3
|
-
static instance;
|
|
4
|
-
level = "info";
|
|
5
|
-
constructor() {
|
|
6
|
-
this.setLevelFromEnv();
|
|
7
|
-
}
|
|
8
|
-
static getInstance() {
|
|
9
|
-
if (!_LiopLogger.instance) {
|
|
10
|
-
_LiopLogger.instance = new _LiopLogger();
|
|
11
|
-
}
|
|
12
|
-
return _LiopLogger.instance;
|
|
13
|
-
}
|
|
14
|
-
setLevelFromEnv() {
|
|
15
|
-
const envLevel = process.env.LIOP_LOG_LEVEL?.toLowerCase();
|
|
16
|
-
if (envLevel === "silent" || envLevel === "error" || envLevel === "warn" || envLevel === "info" || envLevel === "debug") {
|
|
17
|
-
this.level = envLevel;
|
|
18
|
-
} else {
|
|
19
|
-
this.level = "info";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
setLevel(level) {
|
|
23
|
-
this.level = level;
|
|
24
|
-
}
|
|
25
|
-
shouldLog(targetLevel) {
|
|
26
|
-
const levels = {
|
|
27
|
-
silent: 0,
|
|
28
|
-
error: 1,
|
|
29
|
-
warn: 2,
|
|
30
|
-
info: 3,
|
|
31
|
-
debug: 4
|
|
32
|
-
};
|
|
33
|
-
return levels[this.level] >= levels[targetLevel];
|
|
34
|
-
}
|
|
35
|
-
formatMessage(level, message) {
|
|
36
|
-
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
37
|
-
return `[${ts}] [${level}] ${message}`;
|
|
38
|
-
}
|
|
39
|
-
error(message, ...args) {
|
|
40
|
-
if (this.shouldLog("error")) {
|
|
41
|
-
console.error(this.formatMessage("ERROR", message), ...args);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
warn(message, ...args) {
|
|
45
|
-
if (this.shouldLog("warn")) {
|
|
46
|
-
console.error(this.formatMessage("WARN", message), ...args);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
info(message, ...args) {
|
|
50
|
-
if (this.shouldLog("info")) {
|
|
51
|
-
console.error(this.formatMessage("INFO", message), ...args);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
debug(message, ...args) {
|
|
55
|
-
if (this.shouldLog("debug")) {
|
|
56
|
-
console.error(this.formatMessage("DEBUG", message), ...args);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var log = LiopLogger.getInstance();
|
|
61
|
-
|
|
62
|
-
export { log };
|
|
63
|
-
//# sourceMappingURL=chunk-HA6YZ42O.js.map
|
|
64
|
-
//# sourceMappingURL=chunk-HA6YZ42O.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/logger.ts"],"names":[],"mappings":";AAUO,IAAM,UAAA,GAAN,MAAM,WAAA,CAAW;AAAA,EACvB,OAAe,QAAA;AAAA,EACP,KAAA,GAAkB,MAAA;AAAA,EAElB,WAAA,GAAc;AACrB,IAAA,IAAA,CAAK,eAAA,EAAg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IAAA,CAAK,SAAA,CAAU,OAAO,CAAA,EAAG;AAC5B,MAAA,OAAA,CAAQ,MAAM,IAAA,CAAK,aAAA,CAAc,SAAS,OAAO,CAAA,EAAG,GAAG,IAAI,CAAA;AAAA,IAC5D;AAAA,EACD;AAAA,EAEO,IAAA,CAAK,YAAoB,IAAA,EAAiB;AAChD,IAAA,IAAI,IAAA,CAAK,SAAA,CAAU,MAAM,CAAA,EAAG;AAC3B,MAAA,OAAA,CAAQ,MAAM,IAAA,CAAK,aAAA,CAAc,QAAQ,OAAO,CAAA,EAAG,GAAG,IAAI,CAAA;AAAA,IAC3D;AAAA,EACD;AAAA,EAEO,IAAA,CAAK,YAAoB,IAAA,EAAiB;AAChD,IAAA,IAAI,IAAA,CAAK,SAAA,CAAU,MAAM,CAAA,EAAG;AAC3B,MAAA,OAAA,CAAQ,MAAM,IAAA,CAAK,aAAA,CAAc,QAAQ,OAAO,CAAA,EAAG,GAAG,IAAI,CAAA;AAAA,IAC3D;AAAA,EACD;AAAA,EAEO,KAAA,CAAM,YAAoB,IAAA,EAAiB;AACjD,IAAA,IAAI,IAAA,CAAK,SAAA,CAAU,OAAO,CAAA,EAAG;AAC5B,MAAA,OAAA,CAAQ,MAAM,IAAA,CAAK,aAAA,CAAc,SAAS,OAAO,CAAA,EAAG,GAAG,IAAI,CAAA;AAAA,IAC5D;AAAA,EACD;AACD,CAAA;AAEO,IAAM,GAAA,GAAM,WAAW,WAAA","file":"chunk-HA6YZ42O.js","sourcesContent":["// Copyright 2026 Nekzus Solutions and contributors\n// SPDX-License-Identifier: Apache-2.0\n\nexport type LogLevel = \"silent\" | \"error\" | \"warn\" | \"info\" | \"debug\";\n\n/**\n * LiopLogger - Structured Logging Abstraction\n * Configurable via `process.env.LIOP_LOG_LEVEL`.\n * Emits strictly to stderr to comply with MCP stdio protocols.\n */\nexport class LiopLogger {\n\tprivate static instance: LiopLogger;\n\tprivate level: LogLevel = \"info\";\n\n\tprivate constructor() {\n\t\tthis.setLevelFromEnv();\n\t}\n\n\tpublic static getInstance(): LiopLogger {\n\t\tif (!LiopLogger.instance) {\n\t\t\tLiopLogger.instance = new LiopLogger();\n\t\t}\n\t\treturn LiopLogger.instance;\n\t}\n\n\tprivate setLevelFromEnv() {\n\t\tconst envLevel = process.env.LIOP_LOG_LEVEL?.toLowerCase();\n\t\tif (\n\t\t\tenvLevel === \"silent\" ||\n\t\t\tenvLevel === \"error\" ||\n\t\t\tenvLevel === \"warn\" ||\n\t\t\tenvLevel === \"info\" ||\n\t\t\tenvLevel === \"debug\"\n\t\t) {\n\t\t\tthis.level = envLevel as LogLevel;\n\t\t} else {\n\t\t\t// Default level: info\n\t\t\tthis.level = \"info\";\n\t\t}\n\t}\n\n\tpublic setLevel(level: LogLevel) {\n\t\tthis.level = level;\n\t}\n\n\tprivate shouldLog(targetLevel: LogLevel): boolean {\n\t\tconst levels: Record<LogLevel, number> = {\n\t\t\tsilent: 0,\n\t\t\terror: 1,\n\t\t\twarn: 2,\n\t\t\tinfo: 3,\n\t\t\tdebug: 4,\n\t\t};\n\t\treturn levels[this.level] >= levels[targetLevel];\n\t}\n\n\tprivate formatMessage(level: string, message: string): string {\n\t\tconst ts = new Date().toISOString();\n\t\treturn `[${ts}] [${level}] ${message}`;\n\t}\n\n\tpublic error(message: string, ...args: unknown[]) {\n\t\tif (this.shouldLog(\"error\")) {\n\t\t\tconsole.error(this.formatMessage(\"ERROR\", message), ...args);\n\t\t}\n\t}\n\n\tpublic warn(message: string, ...args: unknown[]) {\n\t\tif (this.shouldLog(\"warn\")) {\n\t\t\tconsole.error(this.formatMessage(\"WARN\", message), ...args);\n\t\t}\n\t}\n\n\tpublic info(message: string, ...args: unknown[]) {\n\t\tif (this.shouldLog(\"info\")) {\n\t\t\tconsole.error(this.formatMessage(\"INFO\", message), ...args);\n\t\t}\n\t}\n\n\tpublic debug(message: string, ...args: unknown[]) {\n\t\tif (this.shouldLog(\"debug\")) {\n\t\t\tconsole.error(this.formatMessage(\"DEBUG\", message), ...args);\n\t\t}\n\t}\n}\n\nexport const log = LiopLogger.getInstance();\n"]}
|