@nekzus/liop 1.0.0-alpha.1
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/LICENSE +201 -0
- package/NOTICE +24 -0
- package/README.md +641 -0
- package/dist/bin/agent.d.ts +1 -0
- package/dist/bin/agent.js +897 -0
- package/dist/bin/agent.js.map +1 -0
- package/dist/bridge.d.ts +105 -0
- package/dist/bridge.js +5 -0
- package/dist/bridge.js.map +1 -0
- package/dist/chunk-3L2O2XKG.js +723 -0
- package/dist/chunk-3L2O2XKG.js.map +1 -0
- package/dist/chunk-7BSCUYUE.js +421 -0
- package/dist/chunk-7BSCUYUE.js.map +1 -0
- package/dist/chunk-7PITYWOV.js +68 -0
- package/dist/chunk-7PITYWOV.js.map +1 -0
- package/dist/chunk-7RXOIDXP.js +877 -0
- package/dist/chunk-7RXOIDXP.js.map +1 -0
- package/dist/chunk-BOISQ45Z.js +558 -0
- package/dist/chunk-BOISQ45Z.js.map +1 -0
- package/dist/chunk-DZ2FQGJD.js +206712 -0
- package/dist/chunk-DZ2FQGJD.js.map +1 -0
- package/dist/chunk-EG46XMJT.js +77 -0
- package/dist/chunk-EG46XMJT.js.map +1 -0
- package/dist/chunk-ESRXG36Y.js +115 -0
- package/dist/chunk-ESRXG36Y.js.map +1 -0
- package/dist/chunk-FTF6AMF6.js +3 -0
- package/dist/chunk-FTF6AMF6.js.map +1 -0
- package/dist/chunk-HA6YZ42O.js +64 -0
- package/dist/chunk-HA6YZ42O.js.map +1 -0
- package/dist/chunk-HD2N3IJX.js +3634 -0
- package/dist/chunk-HD2N3IJX.js.map +1 -0
- package/dist/chunk-IK7CGWAZ.js +24 -0
- package/dist/chunk-IK7CGWAZ.js.map +1 -0
- package/dist/chunk-L6J72C5X.js +1477 -0
- package/dist/chunk-L6J72C5X.js.map +1 -0
- package/dist/chunk-PAICJCKJ.js +332 -0
- package/dist/chunk-PAICJCKJ.js.map +1 -0
- package/dist/chunk-PEN3KFLF.js +114 -0
- package/dist/chunk-PEN3KFLF.js.map +1 -0
- package/dist/chunk-T7R5HUFD.js +775 -0
- package/dist/chunk-T7R5HUFD.js.map +1 -0
- package/dist/chunk-TKRX6CFI.js +168 -0
- package/dist/chunk-TKRX6CFI.js.map +1 -0
- package/dist/chunk-UCVP3XAL.js +279 -0
- package/dist/chunk-UCVP3XAL.js.map +1 -0
- package/dist/chunk-VH4K4U45.js +180 -0
- package/dist/chunk-VH4K4U45.js.map +1 -0
- package/dist/chunk-Y62GORQF.js +51 -0
- package/dist/chunk-Y62GORQF.js.map +1 -0
- package/dist/chunk-ZP3VVXOI.js +66 -0
- package/dist/chunk-ZP3VVXOI.js.map +1 -0
- package/dist/client.d.ts +7 -0
- package/dist/client.js +13 -0
- package/dist/client.js.map +1 -0
- package/dist/gateway.d.ts +7 -0
- package/dist/gateway.js +13 -0
- package/dist/gateway.js.map +1 -0
- package/dist/hybrid-CrKB50nh.d.ts +170 -0
- package/dist/index-CX43dvMs.d.ts +170 -0
- package/dist/index-DoW2gzBZ.d.ts +566 -0
- package/dist/index.d.ts +810 -0
- package/dist/index.js +357 -0
- package/dist/index.js.map +1 -0
- package/dist/kyber-CGOA7Q6A.js +3 -0
- package/dist/kyber-CGOA7Q6A.js.map +1 -0
- package/dist/mesh.d.ts +32 -0
- package/dist/mesh.js +6 -0
- package/dist/mesh.js.map +1 -0
- package/dist/node-B0b2vUFS.d.ts +164 -0
- package/dist/protocol/liop_core.proto +47 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.js +9 -0
- package/dist/server.js.map +1 -0
- package/dist/types-lJIxBlWF.d.ts +256 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/verifier-COnid_dg.d.ts +31 -0
- package/dist/verifier-HRFXBKT5.js +6 -0
- package/dist/verifier-HRFXBKT5.js.map +1 -0
- package/dist/workers/logic-execution.d.ts +26 -0
- package/dist/workers/logic-execution.js +272 -0
- package/dist/workers/logic-execution.js.map +1 -0
- package/dist/workers/zk-verifier.d.ts +26 -0
- package/dist/workers/zk-verifier.js +174 -0
- package/dist/workers/zk-verifier.js.map +1 -0
- package/package.json +230 -0
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
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, G as GetPromptRequest, d as GetPromptResult, C as CallToolRequest, T as Tool, R as Resource } from './types-lJIxBlWF.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* LIOP OAuth 2.1 Hybrid Auth — Configuration Types
|
|
7
|
+
*
|
|
8
|
+
* Defines the auth configuration interface consumed by LiopServerOptions.
|
|
9
|
+
* Designed for zero-friction developer experience: most values auto-resolve.
|
|
10
|
+
*
|
|
11
|
+
* Standards: NIST SP 800-207, OWASP API-A07, MCP Spec 2025-11-25
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Role of this node in the LIOP auth hierarchy.
|
|
15
|
+
* - "nexus": Runs the embedded Authorization Server (oidc-provider) + Resource Server.
|
|
16
|
+
* - "node": Resource Server only; validates JWTs issued by the Nexus.
|
|
17
|
+
* - "none": Auth disabled (dev mode, stdio/local transport).
|
|
18
|
+
*/
|
|
19
|
+
type AuthRole = "nexus" | "node" | "none";
|
|
20
|
+
/**
|
|
21
|
+
* OAuth client registration for M2M (Client Credentials) flows.
|
|
22
|
+
* Used exclusively by the Nexus role.
|
|
23
|
+
*/
|
|
24
|
+
interface OAuthClientConfig {
|
|
25
|
+
/** Unique identifier for the OAuth client. */
|
|
26
|
+
client_id: string;
|
|
27
|
+
/** Client secret for authentication (client_secret_post). */
|
|
28
|
+
client_secret: string;
|
|
29
|
+
/** OAuth grant types allowed for this client (e.g., ["client_credentials"]). */
|
|
30
|
+
grant_types: string[];
|
|
31
|
+
/** Space-delimited scopes this client can request. */
|
|
32
|
+
scope: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* LIOP Auth Configuration.
|
|
36
|
+
*
|
|
37
|
+
* Minimal surface for developers:
|
|
38
|
+
* - Nexus node: { role: "nexus" }
|
|
39
|
+
* - Data node: { role: "node" }
|
|
40
|
+
* - Dev/stdio: omit or { role: "none" }
|
|
41
|
+
*
|
|
42
|
+
* All other fields auto-resolve from env, DHT, or secure defaults.
|
|
43
|
+
*/
|
|
44
|
+
interface LiopAuthConfig {
|
|
45
|
+
/** Role of this node in the auth hierarchy. */
|
|
46
|
+
role: AuthRole;
|
|
47
|
+
/**
|
|
48
|
+
* OIDC Issuer URL. Auto-derived:
|
|
49
|
+
* - Nexus: inferred from listen address (e.g., "http://localhost:3000")
|
|
50
|
+
* - Node: resolved from Nexus /health endpoint
|
|
51
|
+
*/
|
|
52
|
+
issuer?: string;
|
|
53
|
+
/**
|
|
54
|
+
* JWT audience claim.
|
|
55
|
+
* Default: "urn:liop:mesh:api"
|
|
56
|
+
*/
|
|
57
|
+
audience?: string;
|
|
58
|
+
/**
|
|
59
|
+
* URL of the Nexus authorization server (node role only).
|
|
60
|
+
* Fallback: env.LIOP_NEXUS_URL → DHT auto-discovery.
|
|
61
|
+
*/
|
|
62
|
+
nexusUrl?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Required scopes for accessing this node's tools.
|
|
65
|
+
* Default: auto-derived from registered tools.
|
|
66
|
+
*/
|
|
67
|
+
requiredScopes?: string[];
|
|
68
|
+
/**
|
|
69
|
+
* Pre-registered OAuth clients (nexus role only).
|
|
70
|
+
* Fallback: auto-detected from env.LIOP_OAUTH_CLIENT_ID + env.LIOP_OAUTH_CLIENT_SECRET.
|
|
71
|
+
*/
|
|
72
|
+
clients?: OAuthClientConfig[];
|
|
73
|
+
/**
|
|
74
|
+
* Path to local token revocation JSON list (Resource Token Revocation List).
|
|
75
|
+
* Saved as an array of SHA-256 hashes of revoked access tokens.
|
|
76
|
+
*/
|
|
77
|
+
revocationPath?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Pre-shared local test token for isolated testing in non-production environments.
|
|
80
|
+
* A token matching this will bypass remote JWKS check only on this specific node.
|
|
81
|
+
*/
|
|
82
|
+
localTestToken?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Secure defaults for the OAuth subsystem.
|
|
86
|
+
* Sources: NIST SP 800-207 §3.1, NIST SP 800-63B, OWASP API-A07
|
|
87
|
+
*/
|
|
88
|
+
declare const AUTH_DEFAULTS: {
|
|
89
|
+
/** JWT audience claim for the LIOP mesh API. */
|
|
90
|
+
readonly audience: "urn:liop:mesh:api";
|
|
91
|
+
/** M2M token time-to-live in seconds (1 hour). */
|
|
92
|
+
readonly tokenTtlSeconds: 3600;
|
|
93
|
+
/** JWKS cache TTL in milliseconds (10 min — jose default). */
|
|
94
|
+
readonly jwksCacheTtlMs: 600000;
|
|
95
|
+
/** Minimum interval between JWKS refetches (30s — jose default). */
|
|
96
|
+
readonly jwksCooldownMs: 30000;
|
|
97
|
+
/** Clock tolerance for JWT expiration checks (mesh clock skew). */
|
|
98
|
+
readonly clockToleranceSec: 5;
|
|
99
|
+
/** JWT signing algorithm (aligned with libp2p Ed25519 PeerID curve). */
|
|
100
|
+
readonly signingAlgorithm: "EdDSA";
|
|
101
|
+
};
|
|
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
|
+
/** Single named entity detected by the NER scanner. */
|
|
153
|
+
interface NerEntity {
|
|
154
|
+
type: "person" | "place" | "organization";
|
|
155
|
+
text: string;
|
|
156
|
+
}
|
|
157
|
+
/** Result of an NER scan operation. */
|
|
158
|
+
interface NerScanResult {
|
|
159
|
+
detected: boolean;
|
|
160
|
+
entities: NerEntity[];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Scans text content for named entities that may represent PII.
|
|
164
|
+
* Uses `compromise/three` for person, place, and organization detection.
|
|
165
|
+
*
|
|
166
|
+
* Designed for egress filtering — optimized for recall over precision
|
|
167
|
+
* to ensure sensitive data does not leak through aliased output keys.
|
|
168
|
+
*/
|
|
169
|
+
declare class NerScanner {
|
|
170
|
+
private static nlp;
|
|
171
|
+
/**
|
|
172
|
+
* Lazy loads the compromise library only when needed.
|
|
173
|
+
*/
|
|
174
|
+
private getNlp;
|
|
175
|
+
/**
|
|
176
|
+
* Scans a single string value for named entities.
|
|
177
|
+
* Returns detected entities if the text contains recognizable PII.
|
|
178
|
+
*/
|
|
179
|
+
scan(text: string): Promise<NerScanResult>;
|
|
180
|
+
/**
|
|
181
|
+
* Recursively scans all string values within an object/array.
|
|
182
|
+
* Stops at the first detection for performance (fail-fast).
|
|
183
|
+
*/
|
|
184
|
+
scanDeep(input: unknown, seen?: WeakSet<object>): Promise<NerScanResult>;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* LIOP Egress Shield Output Sanitizer (NIST SP 800-226 and OWASP DLP 2025 compliant)
|
|
189
|
+
* Recursively sanitizes execution outputs by rounding floating-point numbers
|
|
190
|
+
* and clamping negative values to zero floor where appropriate.
|
|
191
|
+
*
|
|
192
|
+
* Implements absolute immutability, returning a fresh copy of the data.
|
|
193
|
+
*/
|
|
194
|
+
interface OutputSanitizerConfig {
|
|
195
|
+
/** Maximum decimal places for floating-point values (default: 4) */
|
|
196
|
+
maxDecimalPlaces?: number;
|
|
197
|
+
/** Clamp negative values to zero floor (default: true) */
|
|
198
|
+
clampNonNegative?: boolean;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Recursively walks a JSON-like tree, rounding floats and clamping negative values.
|
|
202
|
+
*
|
|
203
|
+
* @param output - The raw or DP-modified output object/value to sanitize
|
|
204
|
+
* @param config - Sanitization parameters (rounding depth, negative clamping)
|
|
205
|
+
* @returns A sanitized deep copy of the output
|
|
206
|
+
*/
|
|
207
|
+
declare function sanitizeOutput(output: unknown, config?: OutputSanitizerConfig): unknown;
|
|
208
|
+
|
|
209
|
+
type PiiRuleDefinition = {
|
|
210
|
+
name: string;
|
|
211
|
+
pattern: string | RegExp;
|
|
212
|
+
validator?: (match: string) => boolean;
|
|
213
|
+
};
|
|
214
|
+
type PiiRule = string | RegExp | PiiRuleDefinition;
|
|
215
|
+
declare const PII_PATTERNS: {
|
|
216
|
+
EMAIL: PiiRuleDefinition;
|
|
217
|
+
CREDIT_CARD: PiiRuleDefinition;
|
|
218
|
+
IP_ADDRESS: PiiRuleDefinition;
|
|
219
|
+
PHONE: PiiRuleDefinition;
|
|
220
|
+
SSN: PiiRuleDefinition;
|
|
221
|
+
IBAN: PiiRuleDefinition;
|
|
222
|
+
PASSPORT_MRZ: PiiRuleDefinition;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Regional and Cultural Security Presets for Out-Of-The-Box compliance.
|
|
226
|
+
* Developers can override, merge, or omit these based on local laws.
|
|
227
|
+
*/
|
|
228
|
+
declare const PII_PRESETS: {
|
|
229
|
+
GLOBAL_STRICT: PiiRuleDefinition[];
|
|
230
|
+
US_COMPLIANT: PiiRuleDefinition[];
|
|
231
|
+
EU_GDPR: PiiRuleDefinition[];
|
|
232
|
+
};
|
|
233
|
+
declare class PiiScanner {
|
|
234
|
+
private patterns;
|
|
235
|
+
private forbiddenKeysSet;
|
|
236
|
+
private nerScanner;
|
|
237
|
+
/**
|
|
238
|
+
* Safelist of keys that contain forbidden substrings but are NOT PII.
|
|
239
|
+
* Prevents false positives from fuzzy matching (e.g., "grid" contains "id").
|
|
240
|
+
*/
|
|
241
|
+
private static readonly KEY_SAFELIST;
|
|
242
|
+
/**
|
|
243
|
+
* Short forbidden tokens (< 4 chars) that require boundary-aware matching.
|
|
244
|
+
* Uses regex boundary detection to avoid false positives.
|
|
245
|
+
*/
|
|
246
|
+
private shortTokenBoundaryPatterns;
|
|
247
|
+
/**
|
|
248
|
+
* Long forbidden tokens (>= 4 chars) that use substring containment.
|
|
249
|
+
*/
|
|
250
|
+
private longForbiddenTokens;
|
|
251
|
+
constructor(patterns?: PiiRule[], forbiddenKeys?: string[], nerScanner?: NerScanner | null);
|
|
252
|
+
/**
|
|
253
|
+
* Scans any input (string, object, array) for PII violations.
|
|
254
|
+
* Returns the pattern/rule name that triggered the violation, or null if safe.
|
|
255
|
+
*
|
|
256
|
+
* Detection pipeline (fail-fast):
|
|
257
|
+
* 1. Exact key match (O(1) Set lookup)
|
|
258
|
+
* 2. Fuzzy key match (boundary detection for short tokens, substring for long)
|
|
259
|
+
* 3. Regex/algorithmic pattern match on string values
|
|
260
|
+
* 4. NER content scan on string values (if enabled)
|
|
261
|
+
*/
|
|
262
|
+
scan(input: unknown, seen?: WeakSet<object>): Promise<string | null>;
|
|
263
|
+
/**
|
|
264
|
+
* Checks a key against fuzzy matching rules.
|
|
265
|
+
* Short tokens use boundary-aware regex; long tokens use substring containment.
|
|
266
|
+
*/
|
|
267
|
+
private checkKeyFuzzy;
|
|
268
|
+
private checkString;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
type ToolHandler<T extends z.ZodRawShape = z.ZodRawShape> = (args: z.infer<z.ZodObject<T>>, extra: {
|
|
272
|
+
signal?: AbortSignal;
|
|
273
|
+
}) => Promise<CallToolResult>;
|
|
274
|
+
interface LiopServerOptions {
|
|
275
|
+
capabilities?: Record<string, unknown>;
|
|
276
|
+
workerPool?: {
|
|
277
|
+
enabled?: boolean;
|
|
278
|
+
minThreads?: number;
|
|
279
|
+
maxThreads?: number;
|
|
280
|
+
idleTimeout?: number;
|
|
281
|
+
/** Max heap memory per worker in MB (default: 64). Prevents heap bomb DoS. */
|
|
282
|
+
maxHeapMb?: number;
|
|
283
|
+
/** Maximum number of tasks allowed in the queue. Default is "auto". */
|
|
284
|
+
maxQueue?: number | "auto";
|
|
285
|
+
};
|
|
286
|
+
security?: {
|
|
287
|
+
piiPatterns?: PiiRule[];
|
|
288
|
+
forbiddenKeys?: string[];
|
|
289
|
+
sensitiveKeys?: string[];
|
|
290
|
+
/** Enable NLP-based Named Entity Recognition scanning on output values. */
|
|
291
|
+
enableNerScanning?: boolean;
|
|
292
|
+
/** Rate limiting configuration for tool calls (OWASP A01). */
|
|
293
|
+
rateLimit?: {
|
|
294
|
+
/** Maximum calls per window per tool (default: 15). */
|
|
295
|
+
maxPerWindow?: number;
|
|
296
|
+
/** Maximum calls per window across ALL tools combined (default: 40). */
|
|
297
|
+
globalMaxPerWindow?: number;
|
|
298
|
+
/** Sliding window duration in milliseconds (default: 60000 = 1 min). */
|
|
299
|
+
windowMs?: number;
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
taxonomy?: {
|
|
303
|
+
domain?: string;
|
|
304
|
+
clearanceTier?: number;
|
|
305
|
+
executionTypes?: string[];
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* OAuth 2.1 Hybrid Auth configuration.
|
|
309
|
+
*
|
|
310
|
+
* Minimal usage:
|
|
311
|
+
* - Nexus (Authorization Server): `{ role: "nexus" }`
|
|
312
|
+
* - Data Node (Resource Server): `{ role: "node" }`
|
|
313
|
+
* - Disabled (dev/stdio): omit or `{ role: "none" }`
|
|
314
|
+
*
|
|
315
|
+
* All other values (issuer, JWKS, audience) auto-resolve from
|
|
316
|
+
* env vars, DHT discovery, or secure defaults.
|
|
317
|
+
*/
|
|
318
|
+
auth?: LiopAuthConfig;
|
|
319
|
+
/**
|
|
320
|
+
* Canonical slug for deterministic token resolution.
|
|
321
|
+
* Agents/clients resolve `LIOP_TOKEN_<tokenSlug>` from environment.
|
|
322
|
+
* Must match SCREAMING_SNAKE_CASE: /^[A-Z][A-Z0-9_]*$/ (e.g., "BANK", "VAULT", "HFT_ORACLE").
|
|
323
|
+
*/
|
|
324
|
+
tokenSlug?: string;
|
|
325
|
+
/**
|
|
326
|
+
* SOC 2 Type II / HIPAA immutable audit logger instance.
|
|
327
|
+
*/
|
|
328
|
+
auditLogger?: AuditLogger;
|
|
329
|
+
/**
|
|
330
|
+
* Path to a shared JSON file for persistent Query Budget tracking across multiple server instances.
|
|
331
|
+
*/
|
|
332
|
+
budgetStorePath?: string;
|
|
333
|
+
}
|
|
334
|
+
interface AggregationPolicy {
|
|
335
|
+
/** Maximum number of object-type array elements allowed (default: 10) */
|
|
336
|
+
maxOutputRows?: number;
|
|
337
|
+
/** Allow arrays containing only primitive values (default: true) */
|
|
338
|
+
allowPrimitiveArrays?: boolean;
|
|
339
|
+
/** Block min/max extraction when dataset size < this value (default: 50) */
|
|
340
|
+
minMaxBlockThreshold?: number;
|
|
341
|
+
}
|
|
342
|
+
interface LogicExecutionPolicy {
|
|
343
|
+
/**
|
|
344
|
+
* Validate the business payload returned by sandbox logic (post-execution).
|
|
345
|
+
* This runs before final egress checks and blocks non-conforming outputs.
|
|
346
|
+
*/
|
|
347
|
+
outputSchema?: z.ZodType<unknown>;
|
|
348
|
+
/**
|
|
349
|
+
* Enforce aggregation-first heuristics (preflight + post-check).
|
|
350
|
+
*/
|
|
351
|
+
enforceAggregationFirst?: boolean | AggregationPolicy;
|
|
352
|
+
/**
|
|
353
|
+
* Optional additional deny patterns checked against extracted logic source.
|
|
354
|
+
*/
|
|
355
|
+
preflightDenyPatterns?: RegExp[];
|
|
356
|
+
/**
|
|
357
|
+
* Differential Privacy epsilon per query (default: 1.0).
|
|
358
|
+
* Lower = stronger privacy + more noise. Standard: Apple iOS uses 1.0.
|
|
359
|
+
*/
|
|
360
|
+
dpEpsilon?: number;
|
|
361
|
+
/**
|
|
362
|
+
* DP sensitivity: max change when one record added/removed (default: 1.0).
|
|
363
|
+
* For SUM queries on a field with range [0, X], set sensitivity = X.
|
|
364
|
+
*/
|
|
365
|
+
dpSensitivity?: number;
|
|
366
|
+
/**
|
|
367
|
+
* Dataset size threshold below which Differential Privacy is active (default: 50).
|
|
368
|
+
*/
|
|
369
|
+
dpSmallDatasetThreshold?: number;
|
|
370
|
+
/**
|
|
371
|
+
* Max queries per numeric field per PQC session (default: 5).
|
|
372
|
+
* Prevents multi-query differencing attacks.
|
|
373
|
+
*/
|
|
374
|
+
queryBudgetPerField?: number;
|
|
375
|
+
/**
|
|
376
|
+
* Domain-specific sensitive keys that fall under the "sensitive" query budget tier.
|
|
377
|
+
*/
|
|
378
|
+
sensitiveKeys?: string[];
|
|
379
|
+
/**
|
|
380
|
+
* Path to a shared JSON file for persistent Query Budget tracking across multiple server instances.
|
|
381
|
+
*/
|
|
382
|
+
budgetStorePath?: string;
|
|
383
|
+
}
|
|
384
|
+
declare class LiopServer {
|
|
385
|
+
private serverInfo;
|
|
386
|
+
private config?;
|
|
387
|
+
private logicCache;
|
|
388
|
+
private connectionStats;
|
|
389
|
+
private readonly CACHE_TTL_MS;
|
|
390
|
+
private readonly THROTTLE_THRESHOLD;
|
|
391
|
+
private readonly THROTTLE_COOLDOWN_MS;
|
|
392
|
+
private toolCallWindows;
|
|
393
|
+
private readonly toolCallMaxPerWindow;
|
|
394
|
+
private readonly toolCallWindowMs;
|
|
395
|
+
private globalCallWindow;
|
|
396
|
+
private readonly globalCallMaxPerWindow;
|
|
397
|
+
private fieldQueryBudget;
|
|
398
|
+
private readonly taintAnalyzer;
|
|
399
|
+
private tools;
|
|
400
|
+
private resources;
|
|
401
|
+
private prompts;
|
|
402
|
+
private activeSchema;
|
|
403
|
+
private sandboxRecords;
|
|
404
|
+
private piiScanner;
|
|
405
|
+
private workerPool;
|
|
406
|
+
private meshNode;
|
|
407
|
+
private rpcServer;
|
|
408
|
+
private boundPort;
|
|
409
|
+
jwtValidator?: JwtValidator;
|
|
410
|
+
oauthProvider?: any;
|
|
411
|
+
private sessions;
|
|
412
|
+
private revokedTokenHashes;
|
|
413
|
+
private lastRevocationLoadTime;
|
|
414
|
+
private pqcKeyPair;
|
|
415
|
+
readonly auditLogger: AuditLogger;
|
|
416
|
+
getDatasetHash(): string;
|
|
417
|
+
private static readonly LIOP_COMPACT_REGEX;
|
|
418
|
+
private extractLogic;
|
|
419
|
+
private parseUnknownJson;
|
|
420
|
+
private runPreflightPolicy;
|
|
421
|
+
private validateOutputPolicy;
|
|
422
|
+
/**
|
|
423
|
+
* Proxied tools stringify a full MCP CallToolResult (`{ content: [...] }`).
|
|
424
|
+
* Aggregation-first heuristics must scan the inner business JSON, not the MCP envelope
|
|
425
|
+
* (otherwise `content` looks like a tabular array of objects and everything blocks).
|
|
426
|
+
*/
|
|
427
|
+
private unwrapForAggregationPolicyScan;
|
|
428
|
+
private violatesAggregationFirstPolicy;
|
|
429
|
+
constructor(serverInfo: ServerInfo, config?: LiopServerOptions | undefined);
|
|
430
|
+
/**
|
|
431
|
+
* Builds the centralized LIOP envelope specification document.
|
|
432
|
+
* Served as a single Resource (liop://protocol/envelope-spec) instead
|
|
433
|
+
* of being duplicated across every tool description.
|
|
434
|
+
*/
|
|
435
|
+
private buildEnvelopeSpec;
|
|
436
|
+
/**
|
|
437
|
+
* Extracts a compact, human-readable field summary from a JSON Schema.
|
|
438
|
+
*
|
|
439
|
+
* Walks the schema structure to find actual data property names and types,
|
|
440
|
+
* rather than returning top-level schema metadata keys (type, items, etc.).
|
|
441
|
+
*
|
|
442
|
+
* Example output for a banking schema:
|
|
443
|
+
* "Array of {id(string), accountHolder(string), balance(number), transactions(array of {date(string), amount(number)})}"
|
|
444
|
+
*/
|
|
445
|
+
private extractSchemaFieldSummary;
|
|
446
|
+
/**
|
|
447
|
+
* Convenience alias for connectToMesh(), matching official documentation.
|
|
448
|
+
*/
|
|
449
|
+
connect(options?: {
|
|
450
|
+
port?: number;
|
|
451
|
+
meshConfig?: MeshNodeConfig;
|
|
452
|
+
}): Promise<void>;
|
|
453
|
+
/**
|
|
454
|
+
* Register a new Tool
|
|
455
|
+
*/
|
|
456
|
+
tool<T extends z.ZodRawShape>(name: string, description: string, shape: T, handler: ToolHandler<T>, policy?: LogicExecutionPolicy): void;
|
|
457
|
+
/**
|
|
458
|
+
* Register a dynamic prompt
|
|
459
|
+
*/
|
|
460
|
+
prompt(name: string, description: string | undefined, args: Prompt["arguments"], handler: (request: GetPromptRequest) => GetPromptResult | Promise<GetPromptResult>): void;
|
|
461
|
+
/**
|
|
462
|
+
* Enables LIOP Zero-Shot Autonomy by registering the Blind Analyst standard prompt.
|
|
463
|
+
*/
|
|
464
|
+
enableZeroShotAutonomy(): void;
|
|
465
|
+
/**
|
|
466
|
+
* Register a dynamic resource
|
|
467
|
+
*/
|
|
468
|
+
resource(name: string, uri: string, description?: string, mimeType?: string, content?: string | (() => Promise<string>)): void;
|
|
469
|
+
/**
|
|
470
|
+
* Builds execution guidelines served as a resource to guide LLM code generation.
|
|
471
|
+
*/
|
|
472
|
+
private buildExecutionGuidelines;
|
|
473
|
+
/**
|
|
474
|
+
* Broadcasts the Data Dictionary to the LLM prior to code injection.
|
|
475
|
+
*/
|
|
476
|
+
dataDictionary(schema: Record<string, unknown>, name?: string, uri?: string, description?: string): void;
|
|
477
|
+
/**
|
|
478
|
+
* Manually invalidates the AST Logic Cache (e.g. for Zero-Day patches).
|
|
479
|
+
*/
|
|
480
|
+
clearAstCache(): void;
|
|
481
|
+
/**
|
|
482
|
+
* Sliding window rate limiter for tool call frequency.
|
|
483
|
+
* Prevents micro-query exfiltration attacks where an attacker
|
|
484
|
+
* makes hundreds of individually-legitimate calls to reconstruct
|
|
485
|
+
* the full dataset field by field. (OWASP A01)
|
|
486
|
+
*/
|
|
487
|
+
private checkToolCallRateLimit;
|
|
488
|
+
/**
|
|
489
|
+
* Global cross-tool rate limiter.
|
|
490
|
+
* Prevents attackers from distributing micro-queries across multiple tools
|
|
491
|
+
* to evade per-tool rate limits. (OWASP A01)
|
|
492
|
+
*/
|
|
493
|
+
private checkGlobalRateLimit;
|
|
494
|
+
/**
|
|
495
|
+
* Emulates calling a tool (used locally or via LIOPMcpBridge)
|
|
496
|
+
*/
|
|
497
|
+
callTool(request: CallToolRequest, clientId?: string): Promise<CallToolResult>;
|
|
498
|
+
/**
|
|
499
|
+
* Retrieves registered tools
|
|
500
|
+
*/
|
|
501
|
+
listTools(): Tool[];
|
|
502
|
+
/**
|
|
503
|
+
* Retrieves registered prompts
|
|
504
|
+
*/
|
|
505
|
+
listPrompts(): Prompt[];
|
|
506
|
+
/**
|
|
507
|
+
* Gets a specific prompt by name
|
|
508
|
+
*/
|
|
509
|
+
getPrompt(request: GetPromptRequest): Promise<GetPromptResult>;
|
|
510
|
+
/**
|
|
511
|
+
* Retrieves registered resources
|
|
512
|
+
*/
|
|
513
|
+
listResources(): Resource[];
|
|
514
|
+
/**
|
|
515
|
+
* Reads a specific resource by URI
|
|
516
|
+
*/
|
|
517
|
+
readResource(uri: string): Promise<{
|
|
518
|
+
contents: Array<{
|
|
519
|
+
uri: string;
|
|
520
|
+
mimeType?: string;
|
|
521
|
+
text: string;
|
|
522
|
+
}>;
|
|
523
|
+
}>;
|
|
524
|
+
getServerInfo(): ServerInfo;
|
|
525
|
+
getMeshNode(): MeshNode | null;
|
|
526
|
+
/**
|
|
527
|
+
* Injects data into the secure sandbox context for Logic-on-Origin tools.
|
|
528
|
+
*/
|
|
529
|
+
setSandboxData(records: Record<string, unknown>[]): void;
|
|
530
|
+
getBoundPort(): number | null;
|
|
531
|
+
/**
|
|
532
|
+
* Connects to the libp2p Kademlia DHT and announces capabilities.
|
|
533
|
+
* Boots the gRPC server for secure Logic-on-Origin.
|
|
534
|
+
*/
|
|
535
|
+
connectToMesh(options?: {
|
|
536
|
+
port?: number;
|
|
537
|
+
meshConfig?: MeshNodeConfig;
|
|
538
|
+
}): Promise<void>;
|
|
539
|
+
/**
|
|
540
|
+
* Internal worker execution with Egress Filtering logic.
|
|
541
|
+
*/
|
|
542
|
+
private executeInWorkerPool;
|
|
543
|
+
/**
|
|
544
|
+
* Safely destroys the worker pool, gRPC server, and Mesh node.
|
|
545
|
+
* Recommended to be called during graceful shutdowns or test teardowns.
|
|
546
|
+
*/
|
|
547
|
+
close(): Promise<void>;
|
|
548
|
+
private loadRevocationList;
|
|
549
|
+
revokeToken(token: string): void;
|
|
550
|
+
revokeTokenHash(hash: string): void;
|
|
551
|
+
/**
|
|
552
|
+
* Resets the query budget for a specific client identity.
|
|
553
|
+
* If toolName is provided, only that tool's budget is cleared.
|
|
554
|
+
* Otherwise, all tool budgets for the client are reset.
|
|
555
|
+
*
|
|
556
|
+
* Operates on both in-memory and persistent (disk) budget stores.
|
|
557
|
+
* Uses file-level locking for safe concurrent access.
|
|
558
|
+
*/
|
|
559
|
+
resetFieldBudget(clientId: string, toolName?: string): void;
|
|
560
|
+
private getPersistentBudget;
|
|
561
|
+
private savePersistentBudget;
|
|
562
|
+
private executeWithBudgetLock;
|
|
563
|
+
private applyInMemoryBudget;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
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 };
|