@nekzus/liop 2.4.0-alpha.25 → 2.4.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/agent.js +27 -933
- package/dist/bridge.js +1 -5
- package/dist/chunk-2XHSALII.js +3 -0
- package/dist/chunk-2ZYX736J.js +2 -0
- package/dist/chunk-3WRKTVOF.js +2 -0
- package/dist/chunk-6KFKO6ZX.js +2 -0
- package/dist/chunk-6VK2XALI.js +2 -0
- package/dist/chunk-AYDF3IFZ.js +2 -0
- package/dist/chunk-CTTTLCGL.js +31 -0
- package/dist/chunk-ECRS6N33.js +4 -0
- package/dist/chunk-FDJMH4CB.js +2 -0
- package/dist/chunk-FTF6AMF6.js +0 -1
- package/dist/chunk-GWVSCZUS.js +2 -0
- package/dist/chunk-LEXMMIQI.js +15 -0
- package/dist/chunk-LM26HOJ6.js +31 -0
- package/dist/chunk-MQ5SU26J.js +2 -0
- package/dist/chunk-N35BC62H.js +2 -0
- package/dist/chunk-P6IJ3VBD.js +3 -0
- package/dist/chunk-TKLRW52V.js +2 -0
- package/dist/chunk-V35CXJQN.js +2 -0
- package/dist/chunk-WP5ER7RH.js +3 -0
- package/dist/chunk-XLVEDKM6.js +2 -0
- package/dist/chunk-Y675R34Z.js +2 -0
- package/dist/chunk-YD2AF2M6.js +46 -0
- package/dist/chunk-YLCNV764.js +3 -0
- package/dist/chunk-ZZMSFCJP.js +3 -0
- package/dist/client.js +1 -12
- package/dist/gateway.js +1 -13
- package/dist/index.js +4 -320
- package/dist/kyber-PULV7PQX.js +2 -0
- package/dist/mesh.js +1 -5
- package/dist/server.js +1 -10
- package/dist/types.js +1 -3
- package/dist/verifier-J4NQYZX5.js +2 -0
- package/dist/workers/logic-execution.js +1 -355
- package/dist/workers/zk-verifier.js +1 -275
- package/package.json +1 -1
- package/dist/chunk-3664H3CV.js +0 -136
- package/dist/chunk-3QH44NKZ.js +0 -115
- package/dist/chunk-6MYJBM2E.js +0 -818
- package/dist/chunk-7PITYWOV.js +0 -68
- package/dist/chunk-DSOB2JKM.js +0 -1507
- package/dist/chunk-ET6VRUK2.js +0 -58
- package/dist/chunk-FIVRGOA4.js +0 -280
- package/dist/chunk-IHKKWXHJ.js +0 -876
- package/dist/chunk-IK7CGWAZ.js +0 -24
- package/dist/chunk-JPWC6XG6.js +0 -941
- package/dist/chunk-K3DGJLUY.js +0 -106
- package/dist/chunk-KR5UZUEY.js +0 -98
- package/dist/chunk-NXCAFF73.js +0 -59
- package/dist/chunk-Q3FKHJ3B.js +0 -345
- package/dist/chunk-R52TZEIL.js +0 -426
- package/dist/chunk-S3RAZTEM.js +0 -807
- package/dist/chunk-V47P2AQR.js +0 -281
- package/dist/chunk-WXOWJXY6.js +0 -564
- package/dist/chunk-WXYDFCIW.js +0 -293
- package/dist/chunk-Y62GORQF.js +0 -51
- package/dist/chunk-ZP3VVXOI.js +0 -66
- package/dist/chunk-ZU3WVVLC.js +0 -3752
- package/dist/kyber-CGOA7Q6A.js +0 -3
- package/dist/verifier-55HW6AFN.js +0 -6
package/dist/chunk-K3DGJLUY.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
// src/utils/logger.ts
|
|
2
|
-
var LiopLogger = class _LiopLogger {
|
|
3
|
-
static instance;
|
|
4
|
-
level = "info";
|
|
5
|
-
interceptor;
|
|
6
|
-
_isIntercepting = false;
|
|
7
|
-
constructor() {
|
|
8
|
-
this.setLevelFromEnv();
|
|
9
|
-
}
|
|
10
|
-
static getInstance() {
|
|
11
|
-
if (!_LiopLogger.instance) {
|
|
12
|
-
_LiopLogger.instance = new _LiopLogger();
|
|
13
|
-
}
|
|
14
|
-
return _LiopLogger.instance;
|
|
15
|
-
}
|
|
16
|
-
setLevelFromEnv() {
|
|
17
|
-
const envLevel = process.env.LIOP_LOG_LEVEL?.toLowerCase();
|
|
18
|
-
if (envLevel === "silent" || envLevel === "error" || envLevel === "warn" || envLevel === "info" || envLevel === "debug") {
|
|
19
|
-
this.level = envLevel;
|
|
20
|
-
} else {
|
|
21
|
-
this.level = "info";
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
setLevel(level) {
|
|
25
|
-
this.level = level;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Registers a technology-agnostic log interceptor.
|
|
29
|
-
* Pass `undefined` to disable interception (zero overhead).
|
|
30
|
-
*/
|
|
31
|
-
setInterceptor(interceptor) {
|
|
32
|
-
this.interceptor = interceptor;
|
|
33
|
-
}
|
|
34
|
-
shouldLog(targetLevel) {
|
|
35
|
-
const levels = {
|
|
36
|
-
silent: 0,
|
|
37
|
-
error: 1,
|
|
38
|
-
warn: 2,
|
|
39
|
-
info: 3,
|
|
40
|
-
debug: 4
|
|
41
|
-
};
|
|
42
|
-
return levels[this.level] >= levels[targetLevel];
|
|
43
|
-
}
|
|
44
|
-
formatMessage(level, message) {
|
|
45
|
-
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
46
|
-
return `[${ts}] [${level}] ${message}`;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Fire-and-forget async dispatch to the registered interceptor.
|
|
50
|
-
* Recursion guard prevents infinite loops when the interceptor
|
|
51
|
-
* itself triggers logging (directly or transitively).
|
|
52
|
-
*/
|
|
53
|
-
emitToInterceptor(level, formattedMessage, args) {
|
|
54
|
-
if (!this.interceptor || this._isIntercepting) return;
|
|
55
|
-
this._isIntercepting = true;
|
|
56
|
-
const event = Object.freeze({
|
|
57
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
58
|
-
level,
|
|
59
|
-
message: formattedMessage,
|
|
60
|
-
args: Object.freeze([...args])
|
|
61
|
-
});
|
|
62
|
-
try {
|
|
63
|
-
const result = this.interceptor(event);
|
|
64
|
-
if (result && typeof result === "object" && "catch" in result) {
|
|
65
|
-
result.catch(() => {
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
} catch {
|
|
69
|
-
} finally {
|
|
70
|
-
this._isIntercepting = false;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
error(message, ...args) {
|
|
74
|
-
if (this.shouldLog("error")) {
|
|
75
|
-
const formatted = this.formatMessage("ERROR", message);
|
|
76
|
-
console.error(formatted, ...args);
|
|
77
|
-
this.emitToInterceptor("error", formatted, args);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
warn(message, ...args) {
|
|
81
|
-
if (this.shouldLog("warn")) {
|
|
82
|
-
const formatted = this.formatMessage("WARN", message);
|
|
83
|
-
console.error(formatted, ...args);
|
|
84
|
-
this.emitToInterceptor("warn", formatted, args);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
info(message, ...args) {
|
|
88
|
-
if (this.shouldLog("info")) {
|
|
89
|
-
const formatted = this.formatMessage("INFO", message);
|
|
90
|
-
console.error(formatted, ...args);
|
|
91
|
-
this.emitToInterceptor("info", formatted, args);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
debug(message, ...args) {
|
|
95
|
-
if (this.shouldLog("debug")) {
|
|
96
|
-
const formatted = this.formatMessage("DEBUG", message);
|
|
97
|
-
console.error(formatted, ...args);
|
|
98
|
-
this.emitToInterceptor("debug", formatted, args);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
var log = LiopLogger.getInstance();
|
|
103
|
-
|
|
104
|
-
export { LiopLogger, log };
|
|
105
|
-
//# sourceMappingURL=chunk-K3DGJLUY.js.map
|
|
106
|
-
//# sourceMappingURL=chunk-K3DGJLUY.js.map
|
package/dist/chunk-KR5UZUEY.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
// src/types.ts
|
|
4
|
-
|
|
5
|
-
// src/gateway/mcp-compat.ts
|
|
6
|
-
var MCP_LEGACY_SUPPORT_ENABLED = true;
|
|
7
|
-
var MCP_PROTOCOL_VERSION_LEGACY = "2025-11-25";
|
|
8
|
-
function buildLegacyInitializeResponse(serverInfo, id) {
|
|
9
|
-
return {
|
|
10
|
-
jsonrpc: "2.0",
|
|
11
|
-
id: id ?? null,
|
|
12
|
-
result: {
|
|
13
|
-
protocolVersion: MCP_PROTOCOL_VERSION_LEGACY,
|
|
14
|
-
capabilities: {
|
|
15
|
-
tools: { listChanged: true },
|
|
16
|
-
resources: { listChanged: true },
|
|
17
|
-
prompts: { listChanged: true }
|
|
18
|
-
},
|
|
19
|
-
serverInfo
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function isLegacyRequest(request) {
|
|
24
|
-
if (request.method === "initialize" || request.method === "notifications/initialized") {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
const params = request.params;
|
|
28
|
-
const meta = params?._meta;
|
|
29
|
-
const version = meta?.["io.modelcontextprotocol/protocolVersion"];
|
|
30
|
-
if (!version || version === MCP_PROTOCOL_VERSION_LEGACY) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
function adaptResponseForLegacyClient(response) {
|
|
36
|
-
if (!response.result || typeof response.result !== "object") {
|
|
37
|
-
return response;
|
|
38
|
-
}
|
|
39
|
-
const rawResult = { ...response.result };
|
|
40
|
-
delete rawResult.resultType;
|
|
41
|
-
delete rawResult.ttlMs;
|
|
42
|
-
delete rawResult.cacheScope;
|
|
43
|
-
return {
|
|
44
|
-
...response,
|
|
45
|
-
result: rawResult
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
var TOOL_ALIASES = {
|
|
49
|
-
bank_tool: "Analyze_Synthetic_Bank_Transactions",
|
|
50
|
-
bank_tool_XDwd: "Analyze_Synthetic_Bank_Transactions",
|
|
51
|
-
vault_tool: "Analyze_Synthetic_Medical_Records",
|
|
52
|
-
vault_tool_E8wP: "Analyze_Synthetic_Medical_Records",
|
|
53
|
-
oracle_tool: "Analyze_HFT_Market_Data",
|
|
54
|
-
compute_aggregate: "Analyze_Synthetic_Bank_Transactions"
|
|
55
|
-
};
|
|
56
|
-
function normalizeToolArguments(args) {
|
|
57
|
-
if (!args) return {};
|
|
58
|
-
const normalized = { ...args };
|
|
59
|
-
if (normalized.data !== void 0) {
|
|
60
|
-
if (normalized.payload === void 0) {
|
|
61
|
-
normalized.payload = normalized.data;
|
|
62
|
-
}
|
|
63
|
-
if (normalized.envelope === void 0) {
|
|
64
|
-
normalized.envelope = normalized.data;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return normalized;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// src/types.ts
|
|
71
|
-
var MCP_PROTOCOL_VERSION = "2026-07-28";
|
|
72
|
-
var ToolSchema = z.object({
|
|
73
|
-
name: z.string(),
|
|
74
|
-
description: z.string().optional(),
|
|
75
|
-
inputSchema: z.record(z.string(), z.unknown())
|
|
76
|
-
// Represents a JSON Schema
|
|
77
|
-
});
|
|
78
|
-
var ResourceSchema = z.object({
|
|
79
|
-
uri: z.string(),
|
|
80
|
-
name: z.string(),
|
|
81
|
-
description: z.string().optional(),
|
|
82
|
-
mimeType: z.string().optional()
|
|
83
|
-
});
|
|
84
|
-
var PromptSchema = z.object({
|
|
85
|
-
name: z.string(),
|
|
86
|
-
description: z.string().optional(),
|
|
87
|
-
arguments: z.array(
|
|
88
|
-
z.object({
|
|
89
|
-
name: z.string(),
|
|
90
|
-
description: z.string().optional(),
|
|
91
|
-
required: z.boolean().optional()
|
|
92
|
-
})
|
|
93
|
-
).optional()
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
export { MCP_LEGACY_SUPPORT_ENABLED, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_LEGACY, PromptSchema, ResourceSchema, TOOL_ALIASES, ToolSchema, adaptResponseForLegacyClient, buildLegacyInitializeResponse, isLegacyRequest, normalizeToolArguments };
|
|
97
|
-
//# sourceMappingURL=chunk-KR5UZUEY.js.map
|
|
98
|
-
//# sourceMappingURL=chunk-KR5UZUEY.js.map
|
package/dist/chunk-NXCAFF73.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// src/security/rbac.ts
|
|
2
|
-
var SCOPE_MAP = {
|
|
3
|
-
// Protocol lifecycle — unauthenticated (MCP spec compliance)
|
|
4
|
-
initialize: [],
|
|
5
|
-
"notifications/initialized": [],
|
|
6
|
-
"notifications/cancelled": [],
|
|
7
|
-
ping: [],
|
|
8
|
-
"server/discover": [],
|
|
9
|
-
"subscriptions/listen": [],
|
|
10
|
-
// Tool operations — require explicit authorization
|
|
11
|
-
"tools/list": ["liop:tools:list"],
|
|
12
|
-
"tools/call": ["liop:tools:call"],
|
|
13
|
-
// Resource operations — read-level access
|
|
14
|
-
"resources/list": ["liop:resources:read"],
|
|
15
|
-
"resources/read": ["liop:resources:read"],
|
|
16
|
-
"resources/templates/list": ["liop:resources:read"],
|
|
17
|
-
// Prompt/schema operations — schema-level access
|
|
18
|
-
"prompts/list": ["liop:schema:read"],
|
|
19
|
-
"prompts/get": ["liop:schema:read"]
|
|
20
|
-
};
|
|
21
|
-
function authorizeRequest(method, auth, additionalScopes) {
|
|
22
|
-
const methodScopes = SCOPE_MAP[method];
|
|
23
|
-
if (methodScopes !== void 0 && methodScopes.length === 0) {
|
|
24
|
-
return { allowed: true };
|
|
25
|
-
}
|
|
26
|
-
if (!auth) {
|
|
27
|
-
return {
|
|
28
|
-
allowed: false,
|
|
29
|
-
reason: `Authentication required for method: ${method}`
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const needed = [...methodScopes ?? [], ...additionalScopes ?? []];
|
|
33
|
-
if (needed.length === 0) {
|
|
34
|
-
return {
|
|
35
|
-
allowed: false,
|
|
36
|
-
reason: `Unknown method: ${method}. Access denied (fail-closed).`
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
const clientScopes = new Set(auth.scopes);
|
|
40
|
-
const missing = needed.filter((s) => !clientScopes.has(s));
|
|
41
|
-
if (missing.length > 0) {
|
|
42
|
-
return {
|
|
43
|
-
allowed: false,
|
|
44
|
-
reason: `Insufficient scopes for ${method}. Missing: ${missing.join(", ")}`
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return { allowed: true };
|
|
48
|
-
}
|
|
49
|
-
var LIOP_SCOPES = [
|
|
50
|
-
"liop:tools:list",
|
|
51
|
-
"liop:tools:call",
|
|
52
|
-
"liop:resources:read",
|
|
53
|
-
"liop:schema:read",
|
|
54
|
-
"liop:mesh:query"
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
export { LIOP_SCOPES, authorizeRequest };
|
|
58
|
-
//# sourceMappingURL=chunk-NXCAFF73.js.map
|
|
59
|
-
//# sourceMappingURL=chunk-NXCAFF73.js.map
|
package/dist/chunk-Q3FKHJ3B.js
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
// src/observability/metrics.ts
|
|
2
|
-
function formatLabels(labels) {
|
|
3
|
-
if (!labels || Object.keys(labels).length === 0) {
|
|
4
|
-
return "";
|
|
5
|
-
}
|
|
6
|
-
const entries = Object.entries(labels).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}="${String(v).replace(/"/g, '\\"')}"`);
|
|
7
|
-
return `{${entries.join(",")}}`;
|
|
8
|
-
}
|
|
9
|
-
function labelsToKey(labels) {
|
|
10
|
-
if (!labels) return "";
|
|
11
|
-
return Object.entries(labels).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}:${v}`).join("|");
|
|
12
|
-
}
|
|
13
|
-
var Counter = class {
|
|
14
|
-
constructor(name, help) {
|
|
15
|
-
this.name = name;
|
|
16
|
-
this.help = help;
|
|
17
|
-
}
|
|
18
|
-
name;
|
|
19
|
-
help;
|
|
20
|
-
values = /* @__PURE__ */ new Map();
|
|
21
|
-
inc(labels, value = 1) {
|
|
22
|
-
if (value < 0) {
|
|
23
|
-
throw new Error("Counter increments must be non-negative");
|
|
24
|
-
}
|
|
25
|
-
const key = labelsToKey(labels);
|
|
26
|
-
const current = this.values.get(key) || { value: 0, labels };
|
|
27
|
-
current.value += value;
|
|
28
|
-
this.values.set(key, current);
|
|
29
|
-
}
|
|
30
|
-
get(labels) {
|
|
31
|
-
const key = labelsToKey(labels);
|
|
32
|
-
return this.values.get(key)?.value || 0;
|
|
33
|
-
}
|
|
34
|
-
reset() {
|
|
35
|
-
this.values.clear();
|
|
36
|
-
}
|
|
37
|
-
toPrometheus() {
|
|
38
|
-
const lines = [
|
|
39
|
-
`# HELP ${this.name} ${this.help}`,
|
|
40
|
-
`# TYPE ${this.name} counter`
|
|
41
|
-
];
|
|
42
|
-
if (this.values.size === 0) {
|
|
43
|
-
lines.push(`${this.name} 0`);
|
|
44
|
-
return lines;
|
|
45
|
-
}
|
|
46
|
-
for (const entry of this.values.values()) {
|
|
47
|
-
lines.push(`${this.name}${formatLabels(entry.labels)} ${entry.value}`);
|
|
48
|
-
}
|
|
49
|
-
return lines;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var Gauge = class {
|
|
53
|
-
constructor(name, help) {
|
|
54
|
-
this.name = name;
|
|
55
|
-
this.help = help;
|
|
56
|
-
}
|
|
57
|
-
name;
|
|
58
|
-
help;
|
|
59
|
-
values = /* @__PURE__ */ new Map();
|
|
60
|
-
set(labelsOrValue, maybeValue) {
|
|
61
|
-
if (typeof labelsOrValue === "number") {
|
|
62
|
-
this.values.set("", { value: labelsOrValue });
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const labels = labelsOrValue;
|
|
66
|
-
const val = typeof maybeValue === "number" ? maybeValue : 0;
|
|
67
|
-
const key = labelsToKey(labels);
|
|
68
|
-
this.values.set(key, { value: val, labels });
|
|
69
|
-
}
|
|
70
|
-
inc(labels, value = 1) {
|
|
71
|
-
const key = labelsToKey(labels);
|
|
72
|
-
const current = this.values.get(key) || { value: 0, labels };
|
|
73
|
-
current.value += value;
|
|
74
|
-
this.values.set(key, current);
|
|
75
|
-
}
|
|
76
|
-
dec(labels, value = 1) {
|
|
77
|
-
const key = labelsToKey(labels);
|
|
78
|
-
const current = this.values.get(key) || { value: 0, labels };
|
|
79
|
-
current.value -= value;
|
|
80
|
-
this.values.set(key, current);
|
|
81
|
-
}
|
|
82
|
-
get(labels) {
|
|
83
|
-
const key = labelsToKey(labels);
|
|
84
|
-
return this.values.get(key)?.value || 0;
|
|
85
|
-
}
|
|
86
|
-
reset() {
|
|
87
|
-
this.values.clear();
|
|
88
|
-
}
|
|
89
|
-
toPrometheus() {
|
|
90
|
-
const lines = [
|
|
91
|
-
`# HELP ${this.name} ${this.help}`,
|
|
92
|
-
`# TYPE ${this.name} gauge`
|
|
93
|
-
];
|
|
94
|
-
if (this.values.size === 0) {
|
|
95
|
-
lines.push(`${this.name} 0`);
|
|
96
|
-
return lines;
|
|
97
|
-
}
|
|
98
|
-
for (const entry of this.values.values()) {
|
|
99
|
-
lines.push(`${this.name}${formatLabels(entry.labels)} ${entry.value}`);
|
|
100
|
-
}
|
|
101
|
-
return lines;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
var Histogram = class {
|
|
105
|
-
constructor(name, help, buckets = [5, 10, 25, 50, 100, 250, 500, 1e3, 2500, 5e3, 1e4]) {
|
|
106
|
-
this.name = name;
|
|
107
|
-
this.help = help;
|
|
108
|
-
this.buckets = [...buckets].sort((a, b) => a - b);
|
|
109
|
-
}
|
|
110
|
-
name;
|
|
111
|
-
help;
|
|
112
|
-
buckets;
|
|
113
|
-
observations = /* @__PURE__ */ new Map();
|
|
114
|
-
observe(labelsOrValue, maybeValue) {
|
|
115
|
-
let labels;
|
|
116
|
-
let val;
|
|
117
|
-
if (typeof labelsOrValue === "number") {
|
|
118
|
-
val = labelsOrValue;
|
|
119
|
-
} else {
|
|
120
|
-
labels = labelsOrValue;
|
|
121
|
-
val = typeof maybeValue === "number" ? maybeValue : 0;
|
|
122
|
-
}
|
|
123
|
-
const key = labelsToKey(labels);
|
|
124
|
-
let state = this.observations.get(key);
|
|
125
|
-
if (!state) {
|
|
126
|
-
state = {
|
|
127
|
-
count: 0,
|
|
128
|
-
sum: 0,
|
|
129
|
-
bucketCounts: new Map(this.buckets.map((b) => [b, 0])),
|
|
130
|
-
labels
|
|
131
|
-
};
|
|
132
|
-
this.observations.set(key, state);
|
|
133
|
-
}
|
|
134
|
-
state.count += 1;
|
|
135
|
-
state.sum += val;
|
|
136
|
-
for (const bound of this.buckets) {
|
|
137
|
-
if (val <= bound) {
|
|
138
|
-
const cur = state.bucketCounts.get(bound) || 0;
|
|
139
|
-
state.bucketCounts.set(bound, cur + 1);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
reset() {
|
|
144
|
-
this.observations.clear();
|
|
145
|
-
}
|
|
146
|
-
toPrometheus() {
|
|
147
|
-
const lines = [
|
|
148
|
-
`# HELP ${this.name} ${this.help}`,
|
|
149
|
-
`# TYPE ${this.name} histogram`
|
|
150
|
-
];
|
|
151
|
-
if (this.observations.size === 0) {
|
|
152
|
-
lines.push(`${this.name}_count 0`);
|
|
153
|
-
lines.push(`${this.name}_sum 0`);
|
|
154
|
-
return lines;
|
|
155
|
-
}
|
|
156
|
-
for (const state of this.observations.values()) {
|
|
157
|
-
const baseLabels = state.labels || {};
|
|
158
|
-
for (const bound of this.buckets) {
|
|
159
|
-
const bucketLabels = { ...baseLabels, le: String(bound) };
|
|
160
|
-
lines.push(
|
|
161
|
-
`${this.name}_bucket${formatLabels(bucketLabels)} ${state.bucketCounts.get(bound) || 0}`
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
const infLabels = { ...baseLabels, le: "+Inf" };
|
|
165
|
-
lines.push(
|
|
166
|
-
`${this.name}_bucket${formatLabels(infLabels)} ${state.count}`
|
|
167
|
-
);
|
|
168
|
-
lines.push(`${this.name}_sum${formatLabels(baseLabels)} ${state.sum}`);
|
|
169
|
-
lines.push(
|
|
170
|
-
`${this.name}_count${formatLabels(baseLabels)} ${state.count}`
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
return lines;
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
var MetricsRegistry = class {
|
|
177
|
-
counters = /* @__PURE__ */ new Map();
|
|
178
|
-
gauges = /* @__PURE__ */ new Map();
|
|
179
|
-
histograms = /* @__PURE__ */ new Map();
|
|
180
|
-
counter(name, help) {
|
|
181
|
-
let c = this.counters.get(name);
|
|
182
|
-
if (!c) {
|
|
183
|
-
c = new Counter(name, help);
|
|
184
|
-
this.counters.set(name, c);
|
|
185
|
-
}
|
|
186
|
-
return c;
|
|
187
|
-
}
|
|
188
|
-
gauge(name, help) {
|
|
189
|
-
let g = this.gauges.get(name);
|
|
190
|
-
if (!g) {
|
|
191
|
-
g = new Gauge(name, help);
|
|
192
|
-
this.gauges.set(name, g);
|
|
193
|
-
}
|
|
194
|
-
return g;
|
|
195
|
-
}
|
|
196
|
-
histogram(name, help, buckets) {
|
|
197
|
-
let h = this.histograms.get(name);
|
|
198
|
-
if (!h) {
|
|
199
|
-
h = new Histogram(name, help, buckets);
|
|
200
|
-
this.histograms.set(name, h);
|
|
201
|
-
}
|
|
202
|
-
return h;
|
|
203
|
-
}
|
|
204
|
-
collectProcessMetrics() {
|
|
205
|
-
const uptime = this.gauge(
|
|
206
|
-
"liop_process_uptime_seconds",
|
|
207
|
-
"Process uptime in seconds"
|
|
208
|
-
);
|
|
209
|
-
uptime.set(Math.floor(process.uptime()));
|
|
210
|
-
const health = this.gauge(
|
|
211
|
-
"liop_node_health_status",
|
|
212
|
-
"Operational health status of the LIOP node (1 = healthy, 0 = degraded)"
|
|
213
|
-
);
|
|
214
|
-
health.set(1);
|
|
215
|
-
if (typeof process.memoryUsage === "function") {
|
|
216
|
-
const mem = process.memoryUsage();
|
|
217
|
-
const rss = this.gauge(
|
|
218
|
-
"liop_process_memory_rss_bytes",
|
|
219
|
-
"Resident set size memory in bytes"
|
|
220
|
-
);
|
|
221
|
-
rss.set(mem.rss);
|
|
222
|
-
const heapUsed = this.gauge(
|
|
223
|
-
"liop_process_memory_heap_used_bytes",
|
|
224
|
-
"Heap memory used in bytes"
|
|
225
|
-
);
|
|
226
|
-
heapUsed.set(mem.heapUsed);
|
|
227
|
-
const heapTotal = this.gauge(
|
|
228
|
-
"liop_process_memory_heap_total_bytes",
|
|
229
|
-
"Total V8 allocated heap memory in bytes"
|
|
230
|
-
);
|
|
231
|
-
heapTotal.set(mem.heapTotal);
|
|
232
|
-
const external = this.gauge(
|
|
233
|
-
"liop_process_memory_external_bytes",
|
|
234
|
-
"External memory bound to C++ objects and buffers in bytes"
|
|
235
|
-
);
|
|
236
|
-
external.set(mem.external);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
exportPrometheusText() {
|
|
240
|
-
this.collectProcessMetrics();
|
|
241
|
-
const lines = [];
|
|
242
|
-
for (const c of this.counters.values()) {
|
|
243
|
-
lines.push(...c.toPrometheus());
|
|
244
|
-
}
|
|
245
|
-
for (const g of this.gauges.values()) {
|
|
246
|
-
lines.push(...g.toPrometheus());
|
|
247
|
-
}
|
|
248
|
-
for (const h of this.histograms.values()) {
|
|
249
|
-
lines.push(...h.toPrometheus());
|
|
250
|
-
}
|
|
251
|
-
lines.push("");
|
|
252
|
-
return lines.join("\n");
|
|
253
|
-
}
|
|
254
|
-
resetAll() {
|
|
255
|
-
for (const c of this.counters.values()) c.reset();
|
|
256
|
-
for (const g of this.gauges.values()) g.reset();
|
|
257
|
-
for (const h of this.histograms.values()) h.reset();
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
var protocolMetrics = new MetricsRegistry();
|
|
261
|
-
var toolCallsTotal = protocolMetrics.counter(
|
|
262
|
-
"liop_tool_calls_total",
|
|
263
|
-
"Total number of tool logic-injection executions"
|
|
264
|
-
);
|
|
265
|
-
var toolCallErrorsTotal = protocolMetrics.counter(
|
|
266
|
-
"liop_tool_call_errors_total",
|
|
267
|
-
"Total number of failed tool logic-injection executions or policy rejections"
|
|
268
|
-
);
|
|
269
|
-
var fuelConsumed = protocolMetrics.histogram(
|
|
270
|
-
"liop_fuel_consumed_total",
|
|
271
|
-
"Deterministic fuel units consumed by injected logic",
|
|
272
|
-
[100, 500, 1e3, 2500, 5e3, 1e4, 5e4, 1e5]
|
|
273
|
-
);
|
|
274
|
-
var meshPeersConnected = protocolMetrics.gauge(
|
|
275
|
-
"liop_mesh_peers_connected",
|
|
276
|
-
"Active peer connections in the P2P mesh"
|
|
277
|
-
);
|
|
278
|
-
var manifestCacheSize = protocolMetrics.gauge(
|
|
279
|
-
"liop_manifest_cache_size",
|
|
280
|
-
"Number of verified remote tool manifests in cache"
|
|
281
|
-
);
|
|
282
|
-
var egressBlocksTotal = protocolMetrics.counter(
|
|
283
|
-
"liop_egress_blocks_total",
|
|
284
|
-
"Total number of outputs blocked by Egress Shield"
|
|
285
|
-
);
|
|
286
|
-
var zkVerificationDurationMs = protocolMetrics.histogram(
|
|
287
|
-
"liop_zk_verification_duration_ms",
|
|
288
|
-
"Duration of ZK-Receipt and HMAC cryptographic attestation in ms",
|
|
289
|
-
[1, 2, 5, 10, 25, 50, 100, 250, 500]
|
|
290
|
-
);
|
|
291
|
-
var zkVerificationsTotal = protocolMetrics.counter(
|
|
292
|
-
"liop_zk_verifications_total",
|
|
293
|
-
"Total number of ZK-Receipt cryptographic attestation checks"
|
|
294
|
-
);
|
|
295
|
-
var zkProofsByTypeTotal = protocolMetrics.counter(
|
|
296
|
-
"liop_zk_proofs_by_type_total",
|
|
297
|
-
"Total number of verified ZK receipts partitioned by proof type (groth16, hmac)"
|
|
298
|
-
);
|
|
299
|
-
var zkProvingDurationMs = protocolMetrics.histogram(
|
|
300
|
-
"liop_zk_proving_duration_ms",
|
|
301
|
-
"Duration of native ZK proof generation in ms",
|
|
302
|
-
[10, 25, 50, 100, 250, 500, 1e3, 2500]
|
|
303
|
-
);
|
|
304
|
-
var zkVkeyCacheSize = protocolMetrics.gauge(
|
|
305
|
-
"liop_zk_vkey_cache_size",
|
|
306
|
-
"Number of registered verification keys in memory cache"
|
|
307
|
-
);
|
|
308
|
-
var tokensInputTotal = protocolMetrics.counter(
|
|
309
|
-
"liop_tokens_input_total",
|
|
310
|
-
"Total BPE input tokens processed by LIOP"
|
|
311
|
-
);
|
|
312
|
-
var tokensOutputTotal = protocolMetrics.counter(
|
|
313
|
-
"liop_tokens_output_total",
|
|
314
|
-
"Total BPE output tokens emitted by LIOP"
|
|
315
|
-
);
|
|
316
|
-
var tokensSavedTotal = protocolMetrics.counter(
|
|
317
|
-
"liop_tokens_saved_total",
|
|
318
|
-
"Estimated tokens saved compared to MCP context-pulling baseline"
|
|
319
|
-
);
|
|
320
|
-
var operationDurationMs = protocolMetrics.histogram(
|
|
321
|
-
"liop_operation_duration_ms",
|
|
322
|
-
"End-to-end operation duration in ms",
|
|
323
|
-
[5, 15, 30, 50, 100, 250, 500, 1e3, 2500, 5e3]
|
|
324
|
-
);
|
|
325
|
-
var pqcHandshakeDurationMs = protocolMetrics.histogram(
|
|
326
|
-
"liop_pqc_handshake_duration_ms",
|
|
327
|
-
"Duration of ML-KEM-768 post-quantum cryptographic key encapsulation in ms",
|
|
328
|
-
[1, 5, 10, 25, 50, 100, 250, 500]
|
|
329
|
-
);
|
|
330
|
-
var pqcHandshakesTotal = protocolMetrics.counter(
|
|
331
|
-
"liop_pqc_handshakes_total",
|
|
332
|
-
"Total number of ML-KEM-768 key encapsulation operations"
|
|
333
|
-
);
|
|
334
|
-
var wireEgressBytesTotal = protocolMetrics.counter(
|
|
335
|
-
"liop_wire_egress_bytes_total",
|
|
336
|
-
"Total wire egress bytes emitted by logic executions"
|
|
337
|
-
);
|
|
338
|
-
var wireSavedBytesTotal = protocolMetrics.counter(
|
|
339
|
-
"liop_wire_saved_bytes_total",
|
|
340
|
-
"Estimated wire egress bytes saved compared to MCP context extraction baseline"
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
export { Counter, Gauge, Histogram, MetricsRegistry, egressBlocksTotal, fuelConsumed, manifestCacheSize, meshPeersConnected, operationDurationMs, pqcHandshakeDurationMs, pqcHandshakesTotal, protocolMetrics, tokensInputTotal, tokensOutputTotal, tokensSavedTotal, toolCallErrorsTotal, toolCallsTotal, wireEgressBytesTotal, wireSavedBytesTotal, zkProofsByTypeTotal, zkProvingDurationMs, zkVerificationDurationMs, zkVerificationsTotal, zkVkeyCacheSize };
|
|
344
|
-
//# sourceMappingURL=chunk-Q3FKHJ3B.js.map
|
|
345
|
-
//# sourceMappingURL=chunk-Q3FKHJ3B.js.map
|