@nekzus/liop 1.3.0-alpha.1 → 2.0.0-alpha.2
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/README.md +41 -17
- package/dist/bin/agent.d.ts +0 -1
- package/dist/bin/agent.js +5 -306
- package/dist/bin/agent.js.map +1 -0
- package/dist/{bridge/stream.d.ts → bridge.d.ts} +44 -3
- package/dist/bridge.js +2 -0
- package/dist/bridge.js.map +1 -0
- package/dist/chunk-4ABAFG44.js +33 -0
- package/dist/chunk-4ABAFG44.js.map +1 -0
- package/dist/chunk-ANFXJGMP.js +2 -0
- package/dist/chunk-ANFXJGMP.js.map +1 -0
- package/dist/chunk-DBXGYHKY.js +2 -0
- package/dist/chunk-DBXGYHKY.js.map +1 -0
- package/dist/chunk-HM77MWB6.js +2 -0
- package/dist/chunk-HM77MWB6.js.map +1 -0
- package/dist/chunk-HNDVAKEK.js +24 -0
- package/dist/chunk-HNDVAKEK.js.map +1 -0
- package/dist/chunk-HQZHZM6U.js +2 -0
- package/dist/chunk-HQZHZM6U.js.map +1 -0
- package/dist/chunk-P52IE4L6.js +2 -0
- package/dist/chunk-P52IE4L6.js.map +1 -0
- package/dist/chunk-PIBCW4BD.js +13 -0
- package/dist/chunk-PIBCW4BD.js.map +1 -0
- package/dist/chunk-PPCOS2NU.js +2 -0
- package/dist/chunk-PPCOS2NU.js.map +1 -0
- package/dist/chunk-RWRRBYG4.js +2 -0
- package/dist/chunk-RWRRBYG4.js.map +1 -0
- package/dist/chunk-S6RJHZV2.js +2 -0
- package/dist/chunk-S6RJHZV2.js.map +1 -0
- package/dist/chunk-UVTEJYHN.js +2 -0
- package/dist/chunk-UVTEJYHN.js.map +1 -0
- package/dist/chunk-X6FJATUE.js +29 -0
- package/dist/chunk-X6FJATUE.js.map +1 -0
- package/dist/chunk-XLVRRGOX.js +3 -0
- package/dist/chunk-XLVRRGOX.js.map +1 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -0
- package/dist/{gateway/router.d.ts → gateway.d.ts} +37 -5
- package/dist/gateway.js +2 -0
- package/dist/gateway.js.map +1 -0
- package/dist/{client/index.d.ts → index-CyxNLlz7.d.ts} +24 -5
- package/dist/index.d.ts +313 -12
- package/dist/index.js +31 -12
- package/dist/index.js.map +1 -0
- package/dist/kyber-2WDOTUQX.js +2 -0
- package/dist/kyber-2WDOTUQX.js.map +1 -0
- package/dist/{mesh/node.d.ts → mesh.d.ts} +5 -3
- package/dist/mesh.js +2 -0
- package/dist/mesh.js.map +1 -0
- package/dist/{server/index.d.ts → server.d.ts} +145 -10
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +17 -14
- package/dist/types.js +2 -26
- package/dist/types.js.map +1 -0
- package/dist/{crypto/verifier.d.ts → verifier-DTCD9imJ.d.ts} +3 -1
- package/dist/verifier-RQRYXA4C.js +2 -0
- package/dist/verifier-RQRYXA4C.js.map +1 -0
- package/dist/workers/logic-execution.d.ts +4 -2
- package/dist/workers/logic-execution.js +2 -123
- package/dist/workers/logic-execution.js.map +1 -0
- package/dist/workers/zk-verifier.d.ts +4 -2
- package/dist/workers/zk-verifier.js +2 -98
- package/dist/workers/zk-verifier.js.map +1 -0
- package/package.json +31 -17
- package/dist/bridge/index.d.ts +0 -37
- package/dist/bridge/index.js +0 -249
- package/dist/bridge/stream.js +0 -210
- package/dist/client/index.js +0 -275
- package/dist/crypto/logic-image-id.d.ts +0 -3
- package/dist/crypto/logic-image-id.js +0 -27
- package/dist/crypto/verifier.js +0 -97
- package/dist/economy/estimator.d.ts +0 -53
- package/dist/economy/estimator.js +0 -69
- package/dist/economy/index.d.ts +0 -5
- package/dist/economy/index.js +0 -3
- package/dist/economy/otel.d.ts +0 -38
- package/dist/economy/otel.js +0 -100
- package/dist/economy/telemetry.d.ts +0 -77
- package/dist/economy/telemetry.js +0 -224
- package/dist/errors.d.ts +0 -14
- package/dist/errors.js +0 -19
- package/dist/gateway/hybrid.d.ts +0 -23
- package/dist/gateway/hybrid.js +0 -199
- package/dist/gateway/router.js +0 -1036
- package/dist/mesh/index.d.ts +0 -1
- package/dist/mesh/index.js +0 -1
- package/dist/mesh/node.js +0 -853
- package/dist/prompts/adapters.d.ts +0 -16
- package/dist/prompts/adapters.js +0 -55
- package/dist/rpc/client.d.ts +0 -22
- package/dist/rpc/client.js +0 -40
- package/dist/rpc/codec/lpm.d.ts +0 -20
- package/dist/rpc/codec/lpm.js +0 -36
- package/dist/rpc/crypto/aes.d.ts +0 -22
- package/dist/rpc/crypto/aes.js +0 -47
- package/dist/rpc/crypto/kyber.d.ts +0 -27
- package/dist/rpc/crypto/kyber.js +0 -70
- package/dist/rpc/proto.d.ts +0 -2
- package/dist/rpc/proto.js +0 -33
- package/dist/rpc/server.d.ts +0 -13
- package/dist/rpc/server.js +0 -50
- package/dist/rpc/tls.d.ts +0 -26
- package/dist/rpc/tls.js +0 -54
- package/dist/rpc/types.d.ts +0 -28
- package/dist/rpc/types.js +0 -5
- package/dist/sandbox/guardian.d.ts +0 -18
- package/dist/sandbox/guardian.js +0 -58
- package/dist/sandbox/wasi.d.ts +0 -36
- package/dist/sandbox/wasi.js +0 -209
- package/dist/security/guardian.d.ts +0 -22
- package/dist/security/guardian.js +0 -52
- package/dist/security/zk.d.ts +0 -37
- package/dist/security/zk.js +0 -76
- package/dist/server/index.js +0 -937
- package/dist/server/pii.d.ts +0 -40
- package/dist/server/pii.js +0 -266
- package/dist/utils/logger.d.ts +0 -21
- package/dist/utils/logger.js +0 -70
- package/dist/utils/mcpCompact.d.ts +0 -11
- package/dist/utils/mcpCompact.js +0 -29
package/dist/server/pii.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LIOP Professional PII Engine (The Shield V2 - Tier-1 Military Edition)
|
|
3
|
-
* Implements high-fidelity detection based on NIST and OWASP standards.
|
|
4
|
-
* Features Multi-Layer Verification (Regex + Algorithmic Validators).
|
|
5
|
-
*/
|
|
6
|
-
export type PiiRuleDefinition = {
|
|
7
|
-
name: string;
|
|
8
|
-
pattern: string | RegExp;
|
|
9
|
-
validator?: (match: string) => boolean;
|
|
10
|
-
};
|
|
11
|
-
export type PiiRule = string | RegExp | PiiRuleDefinition;
|
|
12
|
-
export declare const PII_PATTERNS: {
|
|
13
|
-
EMAIL: PiiRuleDefinition;
|
|
14
|
-
CREDIT_CARD: PiiRuleDefinition;
|
|
15
|
-
IP_ADDRESS: PiiRuleDefinition;
|
|
16
|
-
PHONE: PiiRuleDefinition;
|
|
17
|
-
SSN: PiiRuleDefinition;
|
|
18
|
-
IBAN: PiiRuleDefinition;
|
|
19
|
-
PASSPORT_MRZ: PiiRuleDefinition;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Regional and Cultural Security Presets for Out-Of-The-Box compliance.
|
|
23
|
-
* Developers can override, merge, or omit these based on local laws.
|
|
24
|
-
*/
|
|
25
|
-
export declare const PII_PRESETS: {
|
|
26
|
-
GLOBAL_STRICT: PiiRuleDefinition[];
|
|
27
|
-
US_COMPLIANT: PiiRuleDefinition[];
|
|
28
|
-
EU_GDPR: PiiRuleDefinition[];
|
|
29
|
-
};
|
|
30
|
-
export declare class PiiScanner {
|
|
31
|
-
private patterns;
|
|
32
|
-
private forbiddenKeysSet;
|
|
33
|
-
constructor(patterns?: PiiRule[], forbiddenKeys?: string[]);
|
|
34
|
-
/**
|
|
35
|
-
* Scans any input (string, object, array) for PII violations.
|
|
36
|
-
* Returns the pattern/rule name that triggered the violation, or null if safe.
|
|
37
|
-
*/
|
|
38
|
-
scan(input: unknown, seen?: WeakSet<object>): string | null;
|
|
39
|
-
private checkString;
|
|
40
|
-
}
|
package/dist/server/pii.js
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LIOP Professional PII Engine (The Shield V2 - Tier-1 Military Edition)
|
|
3
|
-
* Implements high-fidelity detection based on NIST and OWASP standards.
|
|
4
|
-
* Features Multi-Layer Verification (Regex + Algorithmic Validators).
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Validates a credit card number using the Luhn algorithm.
|
|
8
|
-
* Prevents false positives from random 16-digit IDs.
|
|
9
|
-
*/
|
|
10
|
-
function isLuhnValid(cardNumber) {
|
|
11
|
-
const digits = cardNumber.replace(/\D/g, "");
|
|
12
|
-
if (digits.length < 13 || digits.length > 19)
|
|
13
|
-
return false;
|
|
14
|
-
let sum = 0;
|
|
15
|
-
let isEven = false;
|
|
16
|
-
for (let i = digits.length - 1; i >= 0; i--) {
|
|
17
|
-
let digit = parseInt(digits.charAt(i), 10);
|
|
18
|
-
if (isEven) {
|
|
19
|
-
digit *= 2;
|
|
20
|
-
if (digit > 9) {
|
|
21
|
-
digit -= 9;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
sum += digit;
|
|
25
|
-
isEven = !isEven;
|
|
26
|
-
}
|
|
27
|
-
return sum % 10 === 0;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Validates an International Bank Account Number (IBAN) using ISO 7064 Modulo 97.
|
|
31
|
-
* Uses BigInt algebra to avoid JS floating point truncation with 30-digit numbers.
|
|
32
|
-
*/
|
|
33
|
-
function isIbanValid(iban) {
|
|
34
|
-
const sanitized = iban.replace(/\s+/g, "").toUpperCase();
|
|
35
|
-
if (!/^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$/.test(sanitized))
|
|
36
|
-
return false;
|
|
37
|
-
const rearranged = sanitized.substring(4) + sanitized.substring(0, 4);
|
|
38
|
-
let numericString = "";
|
|
39
|
-
for (let i = 0; i < rearranged.length; i++) {
|
|
40
|
-
const charCode = rearranged.charCodeAt(i);
|
|
41
|
-
if (charCode >= 65 && charCode <= 90) {
|
|
42
|
-
numericString += (charCode - 55).toString();
|
|
43
|
-
}
|
|
44
|
-
else if (charCode >= 48 && charCode <= 57) {
|
|
45
|
-
numericString += rearranged.charAt(i);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
return BigInt(numericString) % 97n === 1n;
|
|
53
|
-
}
|
|
54
|
-
catch (_e) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
export const PII_PATTERNS = {
|
|
59
|
-
EMAIL: {
|
|
60
|
-
name: "EMAIL",
|
|
61
|
-
pattern: /\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\b/gi,
|
|
62
|
-
validator: (match) => !match.endsWith("@example.com") && !match.endsWith("@test.com"),
|
|
63
|
-
},
|
|
64
|
-
CREDIT_CARD: {
|
|
65
|
-
name: "CREDIT_CARD",
|
|
66
|
-
pattern: /\b(?:\d[ -]*?){13,16}\b/g,
|
|
67
|
-
validator: isLuhnValid,
|
|
68
|
-
},
|
|
69
|
-
IP_ADDRESS: {
|
|
70
|
-
name: "IP_ADDRESS",
|
|
71
|
-
pattern: /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g,
|
|
72
|
-
validator: (match) => {
|
|
73
|
-
const safeIps = ["127.0.0.1", "0.0.0.0", "255.255.255.255"];
|
|
74
|
-
if (safeIps.includes(match))
|
|
75
|
-
return false;
|
|
76
|
-
// Validate valid IPv4 ranges
|
|
77
|
-
const parts = match.split(".").map(Number);
|
|
78
|
-
return parts.every((p) => p >= 0 && p <= 255);
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
PHONE: {
|
|
82
|
-
name: "PHONE",
|
|
83
|
-
// Strict boundary to avoid matching long numeric IDs wrapped in symbols
|
|
84
|
-
pattern: /(?:(?:\+?\d{1,3}[-. ]?)?\(?\d{3}\)?[-. ]?\d{3}[-. ]?\d{4})\b/g,
|
|
85
|
-
validator: (match) => {
|
|
86
|
-
const digits = match.replace(/\D/g, "");
|
|
87
|
-
if (digits.length < 7 || digits.length > 15)
|
|
88
|
-
return false;
|
|
89
|
-
// Reject fake test numbers like 0000000000 or 1234567890
|
|
90
|
-
if (/^(\d)\1+$/.test(digits))
|
|
91
|
-
return false;
|
|
92
|
-
if (digits === "1234567890")
|
|
93
|
-
return false;
|
|
94
|
-
return true;
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
SSN: {
|
|
98
|
-
name: "SSN",
|
|
99
|
-
pattern: /\b\d{3}[- ]?\d{2}[- ]?\d{4}\b/g,
|
|
100
|
-
validator: (match) => {
|
|
101
|
-
const digits = match.replace(/\D/g, "");
|
|
102
|
-
if (digits.length !== 9)
|
|
103
|
-
return false;
|
|
104
|
-
const area = parseInt(digits.substring(0, 3), 10);
|
|
105
|
-
if (area === 0 || area === 666 || area >= 900)
|
|
106
|
-
return false;
|
|
107
|
-
const group = parseInt(digits.substring(3, 5), 10);
|
|
108
|
-
if (group === 0)
|
|
109
|
-
return false;
|
|
110
|
-
const serial = parseInt(digits.substring(5, 9), 10);
|
|
111
|
-
if (serial === 0)
|
|
112
|
-
return false;
|
|
113
|
-
if (/^(\d)\1+$/.test(digits) || digits === "123456789")
|
|
114
|
-
return false;
|
|
115
|
-
return true;
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
IBAN: {
|
|
119
|
-
name: "IBAN",
|
|
120
|
-
pattern: /\b[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}\b/gi,
|
|
121
|
-
validator: isIbanValid,
|
|
122
|
-
},
|
|
123
|
-
PASSPORT_MRZ: {
|
|
124
|
-
name: "PASSPORT_MRZ",
|
|
125
|
-
// Machina Readable Zone line match for standard international passports
|
|
126
|
-
pattern: /\bP[A-Z<][A-Z<]{3}[A-Z0-9<]{39}(?:\b|\s|$)/g,
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Regional and Cultural Security Presets for Out-Of-The-Box compliance.
|
|
131
|
-
* Developers can override, merge, or omit these based on local laws.
|
|
132
|
-
*/
|
|
133
|
-
export const PII_PRESETS = {
|
|
134
|
-
GLOBAL_STRICT: [
|
|
135
|
-
PII_PATTERNS.EMAIL,
|
|
136
|
-
PII_PATTERNS.CREDIT_CARD,
|
|
137
|
-
PII_PATTERNS.IP_ADDRESS,
|
|
138
|
-
PII_PATTERNS.PHONE,
|
|
139
|
-
PII_PATTERNS.PASSPORT_MRZ,
|
|
140
|
-
PII_PATTERNS.IBAN,
|
|
141
|
-
],
|
|
142
|
-
US_COMPLIANT: [
|
|
143
|
-
PII_PATTERNS.EMAIL,
|
|
144
|
-
PII_PATTERNS.CREDIT_CARD,
|
|
145
|
-
PII_PATTERNS.IP_ADDRESS,
|
|
146
|
-
PII_PATTERNS.PHONE,
|
|
147
|
-
PII_PATTERNS.SSN,
|
|
148
|
-
PII_PATTERNS.PASSPORT_MRZ,
|
|
149
|
-
],
|
|
150
|
-
EU_GDPR: [
|
|
151
|
-
PII_PATTERNS.EMAIL,
|
|
152
|
-
PII_PATTERNS.CREDIT_CARD,
|
|
153
|
-
PII_PATTERNS.IP_ADDRESS,
|
|
154
|
-
PII_PATTERNS.PHONE,
|
|
155
|
-
PII_PATTERNS.IBAN,
|
|
156
|
-
PII_PATTERNS.PASSPORT_MRZ,
|
|
157
|
-
],
|
|
158
|
-
};
|
|
159
|
-
export class PiiScanner {
|
|
160
|
-
patterns;
|
|
161
|
-
forbiddenKeysSet;
|
|
162
|
-
constructor(patterns = [], forbiddenKeys = []) {
|
|
163
|
-
this.patterns = patterns;
|
|
164
|
-
// Optimizes large recursive evaluations using O(1) continuous key lookup
|
|
165
|
-
this.forbiddenKeysSet = new Set(forbiddenKeys.map((k) => k.toLowerCase()));
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Scans any input (string, object, array) for PII violations.
|
|
169
|
-
* Returns the pattern/rule name that triggered the violation, or null if safe.
|
|
170
|
-
*/
|
|
171
|
-
scan(input, seen = new WeakSet()) {
|
|
172
|
-
if (input === null || input === undefined)
|
|
173
|
-
return null;
|
|
174
|
-
// 1. String Scan (Direct Regex/String/Definition check)
|
|
175
|
-
if (typeof input === "string") {
|
|
176
|
-
// SECURITY PATCH: JSON Deep-Parsing Recursion (Fortification V2)
|
|
177
|
-
// Defeats Double JSON Encoding bypasses by forcefully parsing stringified JSON back into objects.
|
|
178
|
-
const trimmed = input.trim();
|
|
179
|
-
if ((trimmed.startsWith("{") && trimmed.endsWith("}")) ||
|
|
180
|
-
(trimmed.startsWith("[") && trimmed.endsWith("]"))) {
|
|
181
|
-
try {
|
|
182
|
-
const parsed = JSON.parse(trimmed);
|
|
183
|
-
// Successfully parsed JSON string. Recursively scan the unescaped object.
|
|
184
|
-
const violation = this.scan(parsed, seen);
|
|
185
|
-
if (violation)
|
|
186
|
-
return violation;
|
|
187
|
-
}
|
|
188
|
-
catch (_e) {
|
|
189
|
-
// Silent fallback: It looked like JSON but wasn't valid. Proceed with raw string check.
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
// Fallback: Check the raw string
|
|
193
|
-
return this.checkString(input);
|
|
194
|
-
}
|
|
195
|
-
// 2. Recursive Objects/Arrays Scan
|
|
196
|
-
if (typeof input === "object") {
|
|
197
|
-
// Protection against circular references
|
|
198
|
-
if (seen.has(input))
|
|
199
|
-
return null;
|
|
200
|
-
seen.add(input);
|
|
201
|
-
if (Array.isArray(input)) {
|
|
202
|
-
for (const element of input) {
|
|
203
|
-
const violation = this.scan(element, seen);
|
|
204
|
-
if (violation)
|
|
205
|
-
return violation;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
for (const [key, value] of Object.entries(input)) {
|
|
210
|
-
// Check Keys using O(1) Constant Time Memory Evaluation
|
|
211
|
-
if (this.forbiddenKeysSet.has(key.toLowerCase())) {
|
|
212
|
-
return `Forbidden Key: ${key}`;
|
|
213
|
-
}
|
|
214
|
-
// Recurse into values
|
|
215
|
-
const violation = this.scan(value, seen);
|
|
216
|
-
if (violation)
|
|
217
|
-
return violation;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
checkString(text) {
|
|
224
|
-
for (const rule of this.patterns) {
|
|
225
|
-
if (typeof rule === "string") {
|
|
226
|
-
if (text.toLowerCase().includes(rule.toLowerCase())) {
|
|
227
|
-
return rule;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
else if (rule instanceof RegExp) {
|
|
231
|
-
if (rule.global)
|
|
232
|
-
rule.lastIndex = 0;
|
|
233
|
-
if (rule.test(text)) {
|
|
234
|
-
return rule.source;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
else if (typeof rule === "object" && rule !== null) {
|
|
238
|
-
// PiiRuleDefinition (Military Grade Multi-layer)
|
|
239
|
-
const def = rule;
|
|
240
|
-
if (typeof def.pattern === "string") {
|
|
241
|
-
if (text.toLowerCase().includes(def.pattern.toLowerCase())) {
|
|
242
|
-
if (!def.validator || def.validator(def.pattern)) {
|
|
243
|
-
return def.name;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
else if (def.pattern instanceof RegExp) {
|
|
248
|
-
if (def.pattern.global)
|
|
249
|
-
def.pattern.lastIndex = 0;
|
|
250
|
-
// Use matchAll or exec to get the specific match for the validator
|
|
251
|
-
let match = def.pattern.exec(text);
|
|
252
|
-
while (match !== null) {
|
|
253
|
-
const matchedText = match[0];
|
|
254
|
-
if (!def.validator || def.validator(matchedText)) {
|
|
255
|
-
return def.name;
|
|
256
|
-
}
|
|
257
|
-
if (!def.pattern.global)
|
|
258
|
-
break; // Break if not global
|
|
259
|
-
match = def.pattern.exec(text);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
return null;
|
|
265
|
-
}
|
|
266
|
-
}
|
package/dist/utils/logger.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
2
|
-
/**
|
|
3
|
-
* LiopLogger - Structured Logging Abstraction
|
|
4
|
-
* Configurable via `process.env.LIOP_LOG_LEVEL`.
|
|
5
|
-
* Emits strictly to stderr to comply with MCP stdio protocols.
|
|
6
|
-
*/
|
|
7
|
-
export declare class LiopLogger {
|
|
8
|
-
private static instance;
|
|
9
|
-
private level;
|
|
10
|
-
private constructor();
|
|
11
|
-
static getInstance(): LiopLogger;
|
|
12
|
-
private setLevelFromEnv;
|
|
13
|
-
setLevel(level: LogLevel): void;
|
|
14
|
-
private shouldLog;
|
|
15
|
-
private formatMessage;
|
|
16
|
-
error(message: string, ...args: unknown[]): void;
|
|
17
|
-
warn(message: string, ...args: unknown[]): void;
|
|
18
|
-
info(message: string, ...args: unknown[]): void;
|
|
19
|
-
debug(message: string, ...args: unknown[]): void;
|
|
20
|
-
}
|
|
21
|
-
export declare const log: LiopLogger;
|
package/dist/utils/logger.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LiopLogger - Structured Logging Abstraction
|
|
3
|
-
* Configurable via `process.env.LIOP_LOG_LEVEL`.
|
|
4
|
-
* Emits strictly to stderr to comply with MCP stdio protocols.
|
|
5
|
-
*/
|
|
6
|
-
export class LiopLogger {
|
|
7
|
-
static instance;
|
|
8
|
-
level = "info";
|
|
9
|
-
constructor() {
|
|
10
|
-
this.setLevelFromEnv();
|
|
11
|
-
}
|
|
12
|
-
static getInstance() {
|
|
13
|
-
if (!LiopLogger.instance) {
|
|
14
|
-
LiopLogger.instance = new LiopLogger();
|
|
15
|
-
}
|
|
16
|
-
return LiopLogger.instance;
|
|
17
|
-
}
|
|
18
|
-
setLevelFromEnv() {
|
|
19
|
-
const envLevel = process.env.LIOP_LOG_LEVEL?.toLowerCase();
|
|
20
|
-
if (envLevel === "silent" ||
|
|
21
|
-
envLevel === "error" ||
|
|
22
|
-
envLevel === "warn" ||
|
|
23
|
-
envLevel === "info" ||
|
|
24
|
-
envLevel === "debug") {
|
|
25
|
-
this.level = envLevel;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
// Default level: info
|
|
29
|
-
this.level = "info";
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
setLevel(level) {
|
|
33
|
-
this.level = level;
|
|
34
|
-
}
|
|
35
|
-
shouldLog(targetLevel) {
|
|
36
|
-
const levels = {
|
|
37
|
-
silent: 0,
|
|
38
|
-
error: 1,
|
|
39
|
-
warn: 2,
|
|
40
|
-
info: 3,
|
|
41
|
-
debug: 4,
|
|
42
|
-
};
|
|
43
|
-
return levels[this.level] >= levels[targetLevel];
|
|
44
|
-
}
|
|
45
|
-
formatMessage(level, message) {
|
|
46
|
-
const ts = new Date().toISOString();
|
|
47
|
-
return `[${ts}] [${level}] ${message}`;
|
|
48
|
-
}
|
|
49
|
-
error(message, ...args) {
|
|
50
|
-
if (this.shouldLog("error")) {
|
|
51
|
-
console.error(this.formatMessage("ERROR", message), ...args);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
warn(message, ...args) {
|
|
55
|
-
if (this.shouldLog("warn")) {
|
|
56
|
-
console.error(this.formatMessage("WARN", message), ...args);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
info(message, ...args) {
|
|
60
|
-
if (this.shouldLog("info")) {
|
|
61
|
-
console.error(this.formatMessage("INFO", message), ...args);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
debug(message, ...args) {
|
|
65
|
-
if (this.shouldLog("debug")) {
|
|
66
|
-
console.error(this.formatMessage("DEBUG", message), ...args);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
export const log = LiopLogger.getInstance();
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP UX: optional compact tool descriptions for clients (e.g. cloud models)
|
|
3
|
-
* that over-trigger on long "envelope / injection" wording in tools/list.
|
|
4
|
-
*
|
|
5
|
-
* Full LIOP payload format remains in prompts/get → liop_blind_analyst.
|
|
6
|
-
*/
|
|
7
|
-
export declare function mcpCompactToolDescriptions(): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Removes SDK-appended LIOP specification blocks from a registered tool description.
|
|
10
|
-
*/
|
|
11
|
-
export declare function stripVerboseLiopToolDescription(description: string): string;
|
package/dist/utils/mcpCompact.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP UX: optional compact tool descriptions for clients (e.g. cloud models)
|
|
3
|
-
* that over-trigger on long "envelope / injection" wording in tools/list.
|
|
4
|
-
*
|
|
5
|
-
* Full LIOP payload format remains in prompts/get → liop_blind_analyst.
|
|
6
|
-
*/
|
|
7
|
-
export function mcpCompactToolDescriptions() {
|
|
8
|
-
const v = process.env.LIOP_MCP_COMPACT_TOOL_DESCRIPTIONS?.toLowerCase().trim();
|
|
9
|
-
return v === "1" || v === "true" || v === "yes";
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Removes SDK-appended LIOP specification blocks from a registered tool description.
|
|
13
|
-
*/
|
|
14
|
-
export function stripVerboseLiopToolDescription(description) {
|
|
15
|
-
let d = description;
|
|
16
|
-
const markers = [
|
|
17
|
-
"\n\n[LIOP-PROTO-V1:",
|
|
18
|
-
"\r\n\r\n[LIOP-PROTO-V1:",
|
|
19
|
-
"\n[LIOP-PROTO-V1:", // rare
|
|
20
|
-
];
|
|
21
|
-
for (const m of markers) {
|
|
22
|
-
const i = d.indexOf(m);
|
|
23
|
-
if (i !== -1) {
|
|
24
|
-
d = d.slice(0, i);
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return d.trimEnd();
|
|
29
|
-
}
|