@nekzus/liop 2.1.0 → 2.2.0
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 +12 -0
- package/dist/bin/agent.js +301 -4
- package/dist/bin/agent.js.map +1 -1
- package/dist/bridge.d.ts +2 -2
- package/dist/bridge.js +3 -1
- package/dist/chunk-2JLG4DET.js +3354 -0
- package/dist/chunk-2JLG4DET.js.map +1 -0
- package/dist/chunk-32ADSAJS.js +104 -0
- package/dist/chunk-32ADSAJS.js.map +1 -0
- package/dist/chunk-72MNYFR6.js +64 -0
- package/dist/chunk-72MNYFR6.js.map +1 -0
- package/dist/chunk-CT6NHSYP.js +30 -0
- package/dist/chunk-CT6NHSYP.js.map +1 -0
- package/dist/chunk-E5QBDD5E.js +469 -0
- package/dist/chunk-E5QBDD5E.js.map +1 -0
- package/dist/chunk-HB5DXX3Q.js +1976 -0
- package/dist/chunk-HB5DXX3Q.js.map +1 -0
- package/dist/chunk-IJHTRIZC.js +56 -0
- package/dist/chunk-IJHTRIZC.js.map +1 -0
- package/dist/chunk-J3WPBMJ5.js +332 -0
- package/dist/chunk-J3WPBMJ5.js.map +1 -0
- package/dist/chunk-NJRSFFD7.js +815 -0
- package/dist/chunk-NJRSFFD7.js.map +1 -0
- package/dist/chunk-OUUTDSOW.js +24 -0
- package/dist/chunk-OUUTDSOW.js.map +1 -0
- package/dist/chunk-PHTWUTY7.js +300 -0
- package/dist/chunk-PHTWUTY7.js.map +1 -0
- package/dist/chunk-QLCOEP5J.js +68 -0
- package/dist/chunk-QLCOEP5J.js.map +1 -0
- package/dist/chunk-RDWCGZ2A.js +87 -0
- package/dist/chunk-RDWCGZ2A.js.map +1 -0
- package/dist/chunk-RWRRBYG4.js +1 -0
- package/dist/chunk-UVO7DII3.js +463 -0
- package/dist/chunk-UVO7DII3.js.map +1 -0
- package/dist/client.d.ts +2 -2
- package/dist/client.js +8 -1
- package/dist/gateway.d.ts +2 -2
- package/dist/gateway.js +9 -1
- package/dist/{index-DO97j6hP.d.ts → index-BlGc0iym.d.ts} +10 -1
- package/dist/{index-Brfvxmdt.d.ts → index-qM8ZH8sC.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +58 -4
- package/dist/index.js.map +1 -1
- package/dist/kyber-3ULIJSE3.js +3 -0
- package/dist/{kyber-NONMBQNH.js.map → kyber-3ULIJSE3.js.map} +1 -1
- package/dist/mesh.js +4 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +6 -1
- package/dist/{types-DzEXgi4s.d.ts → types-sKeUxuky.d.ts} +4 -46
- package/dist/types.d.ts +1 -1
- package/dist/types.js +2 -1
- package/dist/verifier-3FAKCFNN.js +5 -0
- package/dist/{verifier-XU2DB56Z.js.map → verifier-3FAKCFNN.js.map} +1 -1
- package/dist/workers/logic-execution.js +255 -1
- package/dist/workers/logic-execution.js.map +1 -1
- package/dist/workers/zk-verifier.js +173 -1
- package/dist/workers/zk-verifier.js.map +1 -1
- package/package.json +74 -45
- package/dist/chunk-2MGFSIXN.js +0 -2
- package/dist/chunk-2MGFSIXN.js.map +0 -1
- package/dist/chunk-4C666HHU.js +0 -2
- package/dist/chunk-4C666HHU.js.map +0 -1
- package/dist/chunk-ANFXJGMP.js +0 -2
- package/dist/chunk-ANFXJGMP.js.map +0 -1
- package/dist/chunk-DBXGYHKY.js +0 -2
- package/dist/chunk-DBXGYHKY.js.map +0 -1
- package/dist/chunk-DQ6UW6L7.js +0 -2
- package/dist/chunk-DQ6UW6L7.js.map +0 -1
- package/dist/chunk-GI2LSJYZ.js +0 -13
- package/dist/chunk-GI2LSJYZ.js.map +0 -1
- package/dist/chunk-GJUZGKZW.js +0 -3
- package/dist/chunk-GJUZGKZW.js.map +0 -1
- package/dist/chunk-I46YEWND.js +0 -33
- package/dist/chunk-I46YEWND.js.map +0 -1
- package/dist/chunk-PWCXZWSE.js +0 -2
- package/dist/chunk-PWCXZWSE.js.map +0 -1
- package/dist/chunk-RYYRR4N5.js +0 -31
- package/dist/chunk-RYYRR4N5.js.map +0 -1
- package/dist/chunk-S6RJHZV2.js +0 -2
- package/dist/chunk-S6RJHZV2.js.map +0 -1
- package/dist/chunk-SB5XJXKV.js +0 -2
- package/dist/chunk-SB5XJXKV.js.map +0 -1
- package/dist/chunk-T3L6OCM3.js +0 -3
- package/dist/chunk-T3L6OCM3.js.map +0 -1
- package/dist/chunk-TYVG6TXQ.js +0 -2
- package/dist/chunk-TYVG6TXQ.js.map +0 -1
- package/dist/chunk-UCCGDGHE.js +0 -54
- package/dist/chunk-UCCGDGHE.js.map +0 -1
- package/dist/chunk-V5MKJT6S.js +0 -2
- package/dist/chunk-V5MKJT6S.js.map +0 -1
- package/dist/kyber-NONMBQNH.js +0 -2
- package/dist/verifier-XU2DB56Z.js +0 -2
package/dist/client.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export { LiopClient } from './chunk-E5QBDD5E.js';
|
|
2
|
+
import './chunk-32ADSAJS.js';
|
|
3
|
+
import './chunk-OUUTDSOW.js';
|
|
4
|
+
import './chunk-QLCOEP5J.js';
|
|
5
|
+
import './chunk-RDWCGZ2A.js';
|
|
6
|
+
import './chunk-NJRSFFD7.js';
|
|
7
|
+
import './chunk-72MNYFR6.js';
|
|
8
|
+
//# sourceMappingURL=client.js.map
|
|
2
9
|
//# sourceMappingURL=client.js.map
|
package/dist/gateway.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MeshNode } from './mesh.js';
|
|
2
|
-
import { L as LiopServer } from './index-
|
|
2
|
+
import { L as LiopServer } from './index-BlGc0iym.js';
|
|
3
3
|
import { L as LiopVerifier } from './verifier-COnid_dg.js';
|
|
4
|
-
import { M as McpRequest, A as AuthInfo, b as McpResponse } from './types-
|
|
4
|
+
import { M as McpRequest, A as AuthInfo, b as McpResponse } from './types-sKeUxuky.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'jose';
|
|
7
7
|
|
package/dist/gateway.js
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export { LiopHybridGateway } from './chunk-PHTWUTY7.js';
|
|
2
|
+
import './chunk-HB5DXX3Q.js';
|
|
3
|
+
import './chunk-32ADSAJS.js';
|
|
4
|
+
import './chunk-OUUTDSOW.js';
|
|
5
|
+
import './chunk-QLCOEP5J.js';
|
|
6
|
+
import './chunk-IJHTRIZC.js';
|
|
7
|
+
import './chunk-RDWCGZ2A.js';
|
|
8
|
+
import './chunk-72MNYFR6.js';
|
|
9
|
+
//# sourceMappingURL=gateway.js.map
|
|
2
10
|
//# sourceMappingURL=gateway.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { MeshNode } from './mesh.js';
|
|
3
|
-
import { J as JwtValidator, S as ServerInfo, a as CallToolResult, P as Prompt, G as GetPromptRequest, c as GetPromptResult, C as CallToolRequest, T as Tool, R as Resource } from './types-
|
|
3
|
+
import { J as JwtValidator, S as ServerInfo, a as CallToolResult, P as Prompt, G as GetPromptRequest, c as GetPromptResult, C as CallToolRequest, T as Tool, R as Resource } from './types-sKeUxuky.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* LIOP OAuth 2.1 Hybrid Auth — Configuration Types
|
|
@@ -505,6 +505,15 @@ declare class LiopServer {
|
|
|
505
505
|
private loadRevocationList;
|
|
506
506
|
revokeToken(token: string): void;
|
|
507
507
|
revokeTokenHash(hash: string): void;
|
|
508
|
+
/**
|
|
509
|
+
* Resets the query budget for a specific client identity.
|
|
510
|
+
* If toolName is provided, only that tool's budget is cleared.
|
|
511
|
+
* Otherwise, all tool budgets for the client are reset.
|
|
512
|
+
*
|
|
513
|
+
* Operates on both in-memory and persistent (disk) budget stores.
|
|
514
|
+
* Uses file-level locking for safe concurrent access.
|
|
515
|
+
*/
|
|
516
|
+
resetFieldBudget(clientId: string, toolName?: string): void;
|
|
508
517
|
private getPersistentBudget;
|
|
509
518
|
private savePersistentBudget;
|
|
510
519
|
private executeWithBudgetLock;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { L as LiopVerifier } from './verifier-COnid_dg.js';
|
|
2
2
|
import { MeshNodeConfig } from './mesh.js';
|
|
3
|
-
import { C as CallToolRequest, a as CallToolResult } from './types-
|
|
3
|
+
import { C as CallToolRequest, a as CallToolResult } from './types-sKeUxuky.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* LIOP TLS Configuration
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { LiopBridgeOptions, LiopMcpBridge, LiopStreamBridge, LiopStreamBridgeOptions } from './bridge.js';
|
|
2
|
-
import { L as LiopTlsOptions } from './index-
|
|
3
|
-
export { a as LiopClient } from './index-
|
|
2
|
+
import { L as LiopTlsOptions } from './index-qM8ZH8sC.js';
|
|
3
|
+
export { a as LiopClient } from './index-qM8ZH8sC.js';
|
|
4
4
|
export { LiopHybridGateway } from './gateway.js';
|
|
5
5
|
export { LiopManifest, MeshNode, MeshNodeConfig } from './mesh.js';
|
|
6
6
|
import * as grpc from '@grpc/grpc-js';
|
|
7
|
-
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-
|
|
8
|
-
import { A as AuthInfo } from './types-
|
|
9
|
-
export { C as CallToolRequest, a as CallToolResult, G as GetPromptRequest, c as GetPromptResult, J as JwtValidator, M as McpRequest, b as McpResponse, P as Prompt, d as PromptSchema, R as Resource, e as ResourceSchema, S as ServerInfo, T as Tool, f as ToolSchema } from './types-
|
|
7
|
+
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-BlGc0iym.js';
|
|
8
|
+
import { A as AuthInfo } from './types-sKeUxuky.js';
|
|
9
|
+
export { C as CallToolRequest, a as CallToolResult, G as GetPromptRequest, c as GetPromptResult, J as JwtValidator, M as McpRequest, b as McpResponse, P as Prompt, d as PromptSchema, R as Resource, e as ResourceSchema, S as ServerInfo, T as Tool, f as ToolSchema } from './types-sKeUxuky.js';
|
|
10
10
|
import * as jose from 'jose';
|
|
11
11
|
import Provider from 'oidc-provider';
|
|
12
12
|
import '@modelcontextprotocol/sdk/server/mcp.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,48 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export { WasiSandbox, getDefaultEnvironment } from './chunk-J3WPBMJ5.js';
|
|
2
|
+
export { LiopClient, LiopRpcClient } from './chunk-E5QBDD5E.js';
|
|
3
|
+
export { PromptSchema, ResourceSchema, ToolSchema } from './chunk-CT6NHSYP.js';
|
|
4
|
+
export { LiopMcpBridge, LiopStreamBridge } from './chunk-UVO7DII3.js';
|
|
5
|
+
export { LiopHybridGateway, buildProtectedResourceMetadata } from './chunk-PHTWUTY7.js';
|
|
6
|
+
export { AUTH_DEFAULTS, JwtValidator, LiopRpcServer, LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner, createOAuthServer, sanitizeOutput } from './chunk-2JLG4DET.js';
|
|
7
|
+
export { HeuristicTokenEstimator, LiopOTelBridge, RealTokenEstimator, TokenTelemetryEngine, createSyncTokenEstimator, createTokenEstimator } from './chunk-HB5DXX3Q.js';
|
|
8
|
+
import './chunk-32ADSAJS.js';
|
|
9
|
+
import './chunk-OUUTDSOW.js';
|
|
10
|
+
import './chunk-QLCOEP5J.js';
|
|
11
|
+
export { LIOP_SCOPES, authorizeRequest } from './chunk-IJHTRIZC.js';
|
|
12
|
+
import './chunk-RDWCGZ2A.js';
|
|
13
|
+
export { MeshNode } from './chunk-NJRSFFD7.js';
|
|
14
|
+
import './chunk-72MNYFR6.js';
|
|
15
|
+
|
|
16
|
+
// src/errors.ts
|
|
17
|
+
var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
18
|
+
ErrorCode2["CapabilityViolation"] = "CapabilityViolation";
|
|
19
|
+
ErrorCode2["SandboxEscape"] = "SandboxEscape";
|
|
20
|
+
ErrorCode2["PiiLeak"] = "PiiLeak";
|
|
21
|
+
ErrorCode2["InvalidIntent"] = "InvalidIntent";
|
|
22
|
+
ErrorCode2["Throttled"] = "Throttled";
|
|
23
|
+
ErrorCode2["ZkVerificationFailed"] = "ZkVerificationFailed";
|
|
24
|
+
ErrorCode2["MeshUnavailable"] = "MeshUnavailable";
|
|
25
|
+
ErrorCode2["ConnectionFailed"] = "ConnectionFailed";
|
|
26
|
+
return ErrorCode2;
|
|
27
|
+
})(ErrorCode || {});
|
|
28
|
+
var LiopError = class extends Error {
|
|
29
|
+
code;
|
|
30
|
+
constructor(code, message) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "LiopError";
|
|
33
|
+
this.code = code;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/prompts/adapters.ts
|
|
38
|
+
var PROVIDER_CONFIGS = {
|
|
39
|
+
claude: { xmlStandard: true, jsonSchemaPreferred: false },
|
|
40
|
+
openai: { xmlStandard: false, jsonSchemaPreferred: true },
|
|
41
|
+
gemini: { xmlStandard: false, jsonSchemaPreferred: true }
|
|
42
|
+
};
|
|
43
|
+
function generateSystemInstructions(provider) {
|
|
44
|
+
const config = PROVIDER_CONFIGS[provider];
|
|
45
|
+
let instructions = `[LIOP-PROTO-V1: LOGIC-ON-ORIGIN SPECIFICATION]
|
|
2
46
|
You are interacting with a Logic-Injection-on-Origin Protocol (LIOP) Mesh Network.
|
|
3
47
|
Unlike standard MCP where you pull context to evaluate it remotely, in LIOP you WRITE code that executes on the data's origin.
|
|
4
48
|
|
|
@@ -23,7 +67,9 @@ To prevent database reconstruction and inference attacks, numeric query outputs
|
|
|
23
67
|
- Poisoned globals: eval, Function, setTimeout, setInterval, Buffer, ArrayBuffer, and TypedArrays are undefined.
|
|
24
68
|
- Frozen prototypes: Modifications to Object.prototype, Array.prototype, etc., are blocked.
|
|
25
69
|
- 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.
|
|
26
|
-
`;
|
|
70
|
+
`;
|
|
71
|
+
if (config.xmlStandard) {
|
|
72
|
+
instructions += `
|
|
27
73
|
### PAYLOAD FORMATTING (CLAUDE-XML PREFERRED)
|
|
28
74
|
You must wrap your logic precisely within <liop_logic> tags.
|
|
29
75
|
Example:
|
|
@@ -32,7 +78,9 @@ const records = await liop.readResource("liop://vault/patients");
|
|
|
32
78
|
const filtered = records.filter(r => r.disease === "Hypertension");
|
|
33
79
|
return { alert: "High risk demographic", targetCount: filtered.length };
|
|
34
80
|
</liop_logic>
|
|
35
|
-
|
|
81
|
+
`;
|
|
82
|
+
} else if (config.jsonSchemaPreferred) {
|
|
83
|
+
instructions += `
|
|
36
84
|
### PAYLOAD FORMATTING (JSON PARSING PREFERRED)
|
|
37
85
|
You must provide your logic strictly within a JSON string key called \`"logic_blob"\` inside your tool call parameters.
|
|
38
86
|
Example:
|
|
@@ -40,5 +88,11 @@ Example:
|
|
|
40
88
|
"target": "liop://vault/patients",
|
|
41
89
|
"logic_blob": "const records = await liop.readResource(args.target); return { targetCount: records.filter(r => r.disease === 'Hypertension').length };"
|
|
42
90
|
}
|
|
43
|
-
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
return instructions;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { ErrorCode, LiopError, generateSystemInstructions };
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
|
44
98
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/prompts/adapters.ts"],"names":["ErrorCode","
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/prompts/adapters.ts"],"names":["ErrorCode"],"mappings":";;;;;;;;;;;;;;;;AAAO,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,WAAA,kBAAA,CAAA,GAAmB,kBAAA;AARR,EAAA,OAAAA,UAAAA;AAAA,CAAA,EAAA,SAAA,IAAA,EAAA;AAWL,IAAM,SAAA,GAAN,cAAwB,KAAA,CAAM;AAAA,EACpB,IAAA;AAAA,EAEhB,WAAA,CAAY,MAAiB,OAAA,EAAiB;AAC7C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,WAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACb;AACD;;;ACLA,IAAM,gBAAA,GAAqD;AAAA,EAC1D,MAAA,EAAQ,EAAE,WAAA,EAAa,IAAA,EAAM,qBAAqB,KAAA,EAAM;AAAA,EACxD,MAAA,EAAQ,EAAE,WAAA,EAAa,KAAA,EAAO,qBAAqB,IAAA,EAAK;AAAA,EACxD,MAAA,EAAQ,EAAE,WAAA,EAAa,KAAA,EAAO,qBAAqB,IAAA;AACpD,CAAA;AAMO,SAAS,2BAA2B,QAAA,EAA8B;AACxE,EAAA,MAAM,MAAA,GAAS,iBAAiB,QAAQ,CAAA;AAExC,EAAA,IAAI,YAAA,GAAe,CAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AA2BnB,EAAA,IAAI,OAAO,WAAA,EAAa;AACvB,IAAA,YAAA,IAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA,EAUjB,CAAA,MAAA,IAAW,OAAO,mBAAA,EAAqB;AACtC,IAAA,YAAA,IAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAAA,EASjB;AAEA,EAAA,OAAO,YAAA;AACR","file":"index.js","sourcesContent":["export 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","/**\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"kyber-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"kyber-3ULIJSE3.js"}
|
package/dist/mesh.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import'./chunk-RWRRBYG4.js';
|
|
1
|
+
import './chunk-RWRRBYG4.js';
|
|
2
|
+
export { MeshNode } from './chunk-NJRSFFD7.js';
|
|
3
|
+
import './chunk-72MNYFR6.js';
|
|
4
|
+
//# sourceMappingURL=mesh.js.map
|
|
2
5
|
//# 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, 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-
|
|
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-BlGc0iym.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import './mesh.js';
|
|
4
|
-
import './types-
|
|
4
|
+
import './types-sKeUxuky.js';
|
|
5
5
|
import 'jose';
|
package/dist/server.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export { LiopServer, NerScanner, PII_PATTERNS, PII_PRESETS, PiiScanner, sanitizeOutput } from './chunk-2JLG4DET.js';
|
|
2
|
+
import './chunk-IJHTRIZC.js';
|
|
3
|
+
import './chunk-RDWCGZ2A.js';
|
|
4
|
+
import './chunk-NJRSFFD7.js';
|
|
5
|
+
import './chunk-72MNYFR6.js';
|
|
6
|
+
//# sourceMappingURL=server.js.map
|
|
2
7
|
//# sourceMappingURL=server.js.map
|
|
@@ -87,32 +87,14 @@ declare const ToolSchema: z.ZodObject<{
|
|
|
87
87
|
name: z.ZodString;
|
|
88
88
|
description: z.ZodOptional<z.ZodString>;
|
|
89
89
|
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
90
|
-
},
|
|
91
|
-
name: string;
|
|
92
|
-
inputSchema: Record<string, unknown>;
|
|
93
|
-
description?: string | undefined;
|
|
94
|
-
}, {
|
|
95
|
-
name: string;
|
|
96
|
-
inputSchema: Record<string, unknown>;
|
|
97
|
-
description?: string | undefined;
|
|
98
|
-
}>;
|
|
90
|
+
}, z.core.$strip>;
|
|
99
91
|
type Tool = z.infer<typeof ToolSchema>;
|
|
100
92
|
declare const ResourceSchema: z.ZodObject<{
|
|
101
93
|
uri: z.ZodString;
|
|
102
94
|
name: z.ZodString;
|
|
103
95
|
description: z.ZodOptional<z.ZodString>;
|
|
104
96
|
mimeType: z.ZodOptional<z.ZodString>;
|
|
105
|
-
},
|
|
106
|
-
name: string;
|
|
107
|
-
uri: string;
|
|
108
|
-
description?: string | undefined;
|
|
109
|
-
mimeType?: string | undefined;
|
|
110
|
-
}, {
|
|
111
|
-
name: string;
|
|
112
|
-
uri: string;
|
|
113
|
-
description?: string | undefined;
|
|
114
|
-
mimeType?: string | undefined;
|
|
115
|
-
}>;
|
|
97
|
+
}, z.core.$strip>;
|
|
116
98
|
type Resource = z.infer<typeof ResourceSchema>;
|
|
117
99
|
declare const PromptSchema: z.ZodObject<{
|
|
118
100
|
name: z.ZodString;
|
|
@@ -121,32 +103,8 @@ declare const PromptSchema: z.ZodObject<{
|
|
|
121
103
|
name: z.ZodString;
|
|
122
104
|
description: z.ZodOptional<z.ZodString>;
|
|
123
105
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
description?: string | undefined;
|
|
127
|
-
required?: boolean | undefined;
|
|
128
|
-
}, {
|
|
129
|
-
name: string;
|
|
130
|
-
description?: string | undefined;
|
|
131
|
-
required?: boolean | undefined;
|
|
132
|
-
}>, "many">>;
|
|
133
|
-
}, "strip", z.ZodTypeAny, {
|
|
134
|
-
name: string;
|
|
135
|
-
description?: string | undefined;
|
|
136
|
-
arguments?: {
|
|
137
|
-
name: string;
|
|
138
|
-
description?: string | undefined;
|
|
139
|
-
required?: boolean | undefined;
|
|
140
|
-
}[] | undefined;
|
|
141
|
-
}, {
|
|
142
|
-
name: string;
|
|
143
|
-
description?: string | undefined;
|
|
144
|
-
arguments?: {
|
|
145
|
-
name: string;
|
|
146
|
-
description?: string | undefined;
|
|
147
|
-
required?: boolean | undefined;
|
|
148
|
-
}[] | undefined;
|
|
149
|
-
}>;
|
|
106
|
+
}, z.core.$strip>>>;
|
|
107
|
+
}, z.core.$strip>;
|
|
150
108
|
type Prompt = z.infer<typeof PromptSchema>;
|
|
151
109
|
interface CallToolRequest {
|
|
152
110
|
name: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'zod';
|
|
2
|
-
export { A as AuthInfo, C as CallToolRequest, a as CallToolResult, G as GetPromptRequest, c as GetPromptResult, M as McpRequest, b as McpResponse, P as Prompt, d as PromptSchema, R as Resource, e as ResourceSchema, S as ServerInfo, T as Tool, f as ToolSchema } from './types-
|
|
2
|
+
export { A as AuthInfo, C as CallToolRequest, a as CallToolResult, G as GetPromptRequest, c as GetPromptResult, M as McpRequest, b as McpResponse, P as Prompt, d as PromptSchema, R as Resource, e as ResourceSchema, S as ServerInfo, T as Tool, f as ToolSchema } from './types-sKeUxuky.js';
|
|
3
3
|
import 'jose';
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export { PromptSchema, ResourceSchema, ToolSchema } from './chunk-CT6NHSYP.js';
|
|
2
|
+
//# sourceMappingURL=types.js.map
|
|
2
3
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"verifier-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"verifier-3FAKCFNN.js"}
|
|
@@ -1,2 +1,256 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ASTGuardian, WasiSandbox } from '../chunk-J3WPBMJ5.js';
|
|
2
|
+
import { normalizeLogicSource, deriveLogicImageDigest } from '../chunk-OUUTDSOW.js';
|
|
3
|
+
import { Buffer } from 'buffer';
|
|
4
|
+
import crypto2 from 'crypto';
|
|
5
|
+
import { createMlKem768 } from 'mlkem';
|
|
6
|
+
|
|
7
|
+
var DEFAULT_DP_CONFIG = {
|
|
8
|
+
epsilon: 1,
|
|
9
|
+
sensitivity: 1,
|
|
10
|
+
smallDatasetThreshold: 50
|
|
11
|
+
};
|
|
12
|
+
var EPSILON_FLOOR = 1;
|
|
13
|
+
var EPSILON_FLOOR_THRESHOLD = 10;
|
|
14
|
+
function laplaceSample(scale, prngState) {
|
|
15
|
+
let u;
|
|
16
|
+
do {
|
|
17
|
+
if (prngState) {
|
|
18
|
+
const hash = crypto2.createHash("sha256").update(`${prngState.seed}:${prngState.counter++}`).digest();
|
|
19
|
+
u = hash.readUInt32BE(0) / 4294967296 - 0.5;
|
|
20
|
+
} else {
|
|
21
|
+
const buf = crypto2.randomBytes(4);
|
|
22
|
+
const rawVal = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
|
|
23
|
+
const cleanVal = Number.parseInt(rawVal.toString(10), 10);
|
|
24
|
+
u = cleanVal / 4294967296;
|
|
25
|
+
}
|
|
26
|
+
} while (u === 0 || u === -0.5);
|
|
27
|
+
return -scale * Math.sign(u) * Math.log(1 - 2 * Math.abs(u));
|
|
28
|
+
}
|
|
29
|
+
function addLaplaceNoise(value, config = {}, prngState) {
|
|
30
|
+
const merged = { ...DEFAULT_DP_CONFIG, ...config };
|
|
31
|
+
const scale = merged.sensitivity / merged.epsilon;
|
|
32
|
+
const noisyValue = value + laplaceSample(scale, prngState);
|
|
33
|
+
return Math.round(noisyValue * 1e4) / 1e4;
|
|
34
|
+
}
|
|
35
|
+
function deriveFieldSensitivity(key, globalSensitivity, recordCount) {
|
|
36
|
+
if (!key) return globalSensitivity;
|
|
37
|
+
const lk = key.toLowerCase();
|
|
38
|
+
const isCountWord = /count|length|size|num|gainer|loser|positive|negative|nan_|null_|empty_|finite_|non_finite_|instruments|tickers|users|records/i.test(
|
|
39
|
+
lk
|
|
40
|
+
);
|
|
41
|
+
const isTotalCount = lk === "total" || lk === "n" || lk === "total_records" || lk.startsWith("total_") || // Catch total_tickers, total_users
|
|
42
|
+
lk.startsWith("num_") || // Catch num_records, num_ticks
|
|
43
|
+
/total.*(count|items|entries|rows|records|tickers)/i.test(lk);
|
|
44
|
+
if (isCountWord || isTotalCount) return 1;
|
|
45
|
+
if (/avg|mean|average|var|variance|std|stddev|ratio|bps|drift|pct|percent|imbalance/i.test(
|
|
46
|
+
lk
|
|
47
|
+
) && recordCount > 0) {
|
|
48
|
+
return globalSensitivity / recordCount;
|
|
49
|
+
}
|
|
50
|
+
return globalSensitivity;
|
|
51
|
+
}
|
|
52
|
+
function applyDpToOutput(output, config = {}, recordCount) {
|
|
53
|
+
const merged = { ...DEFAULT_DP_CONFIG, ...config };
|
|
54
|
+
if (recordCount >= merged.smallDatasetThreshold) {
|
|
55
|
+
return output;
|
|
56
|
+
}
|
|
57
|
+
if (recordCount < EPSILON_FLOOR_THRESHOLD && merged.epsilon < EPSILON_FLOOR) {
|
|
58
|
+
merged.epsilon = EPSILON_FLOOR;
|
|
59
|
+
}
|
|
60
|
+
let prngState;
|
|
61
|
+
if (merged.seed) {
|
|
62
|
+
prngState = { seed: merged.seed, counter: 0 };
|
|
63
|
+
}
|
|
64
|
+
return walkAndNoise(output, merged, recordCount, void 0, prngState);
|
|
65
|
+
}
|
|
66
|
+
function walkAndNoise(node, config, recordCount, currentKey, prngState) {
|
|
67
|
+
if (typeof node === "number" && Number.isFinite(node)) {
|
|
68
|
+
const fieldSensitivity = deriveFieldSensitivity(
|
|
69
|
+
currentKey,
|
|
70
|
+
config.sensitivity,
|
|
71
|
+
recordCount
|
|
72
|
+
);
|
|
73
|
+
let noisyValue = addLaplaceNoise(
|
|
74
|
+
node,
|
|
75
|
+
{
|
|
76
|
+
...config,
|
|
77
|
+
sensitivity: fieldSensitivity
|
|
78
|
+
},
|
|
79
|
+
prngState
|
|
80
|
+
);
|
|
81
|
+
const isCountKey = currentKey != null && deriveFieldSensitivity(currentKey, config.sensitivity, recordCount) === 1;
|
|
82
|
+
if (Number.isInteger(node) || isCountKey) {
|
|
83
|
+
noisyValue = Math.round(noisyValue);
|
|
84
|
+
}
|
|
85
|
+
if (node >= 0) {
|
|
86
|
+
noisyValue = Math.max(0, noisyValue);
|
|
87
|
+
}
|
|
88
|
+
return noisyValue;
|
|
89
|
+
}
|
|
90
|
+
if (Array.isArray(node)) {
|
|
91
|
+
return node.map(
|
|
92
|
+
(item) => walkAndNoise(item, config, recordCount, currentKey, prngState)
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
if (node !== null && typeof node === "object") {
|
|
96
|
+
const result = {};
|
|
97
|
+
for (const [key, value] of Object.entries(
|
|
98
|
+
node
|
|
99
|
+
)) {
|
|
100
|
+
result[key] = walkAndNoise(value, config, recordCount, key, prngState);
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
return node;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/workers/logic-execution.ts
|
|
108
|
+
async function processLogicExecution(data) {
|
|
109
|
+
if (typeof Object.prototype === "object" && !Object.isFrozen(Object.prototype)) {
|
|
110
|
+
Object.freeze(Object.prototype);
|
|
111
|
+
Object.freeze(Array.prototype);
|
|
112
|
+
Object.freeze(String.prototype);
|
|
113
|
+
Object.freeze(Number.prototype);
|
|
114
|
+
Object.freeze(Boolean.prototype);
|
|
115
|
+
Object.freeze(RegExp.prototype);
|
|
116
|
+
Object.freeze(Map.prototype);
|
|
117
|
+
Object.freeze(Set.prototype);
|
|
118
|
+
Object.freeze(Promise.prototype);
|
|
119
|
+
Object.freeze(Error.prototype);
|
|
120
|
+
}
|
|
121
|
+
if (data.isWarmup) {
|
|
122
|
+
return {
|
|
123
|
+
image_id: "",
|
|
124
|
+
output: "warm",
|
|
125
|
+
fuel_consumed: 0
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const {
|
|
129
|
+
ciphertext,
|
|
130
|
+
secretKeyObj,
|
|
131
|
+
wasmBinary,
|
|
132
|
+
inputs,
|
|
133
|
+
aesNonce,
|
|
134
|
+
records,
|
|
135
|
+
isEncrypted = true,
|
|
136
|
+
dpConfig
|
|
137
|
+
} = data;
|
|
138
|
+
let decryptedPayload;
|
|
139
|
+
const decryptedInputs = {};
|
|
140
|
+
let sessionSecret = Buffer.alloc(32);
|
|
141
|
+
if (isEncrypted) {
|
|
142
|
+
const sk = new Uint8Array(secretKeyObj);
|
|
143
|
+
const ct = new Uint8Array(ciphertext);
|
|
144
|
+
const kem = await createMlKem768();
|
|
145
|
+
const sharedSecret = kem.decap(ct, sk);
|
|
146
|
+
const aesKey = Buffer.from(sharedSecret);
|
|
147
|
+
sessionSecret = aesKey;
|
|
148
|
+
const wasmBuffer = Buffer.from(wasmBinary);
|
|
149
|
+
const authTag = wasmBuffer.subarray(-16);
|
|
150
|
+
const encryptedData = wasmBuffer.subarray(0, -16);
|
|
151
|
+
const decipher = crypto2.createDecipheriv(
|
|
152
|
+
"aes-256-gcm",
|
|
153
|
+
aesKey,
|
|
154
|
+
Buffer.from(aesNonce || new Uint8Array(12))
|
|
155
|
+
);
|
|
156
|
+
decipher.setAuthTag(authTag);
|
|
157
|
+
let decrypted = decipher.update(encryptedData);
|
|
158
|
+
decrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
159
|
+
decryptedPayload = decrypted;
|
|
160
|
+
for (const [key, encValue] of Object.entries(inputs || {})) {
|
|
161
|
+
const valBuffer = Buffer.from(encValue);
|
|
162
|
+
const inputNonce = valBuffer.subarray(0, 12);
|
|
163
|
+
const valTag = valBuffer.subarray(-16);
|
|
164
|
+
const valData = valBuffer.subarray(12, -16);
|
|
165
|
+
const valDecipher = crypto2.createDecipheriv(
|
|
166
|
+
"aes-256-gcm",
|
|
167
|
+
aesKey,
|
|
168
|
+
inputNonce
|
|
169
|
+
);
|
|
170
|
+
valDecipher.setAuthTag(valTag);
|
|
171
|
+
let valDecrypted = valDecipher.update(valData);
|
|
172
|
+
valDecrypted = Buffer.concat([valDecrypted, valDecipher.final()]);
|
|
173
|
+
decryptedInputs[key] = JSON.parse(valDecrypted.toString("utf-8"));
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
if (wasmBinary[0] === 0 && wasmBinary[1] === 97 && wasmBinary[2] === 115 && wasmBinary[3] === 109) {
|
|
177
|
+
decryptedPayload = Buffer.from(wasmBinary);
|
|
178
|
+
} else {
|
|
179
|
+
decryptedPayload = Buffer.from(wasmBinary).toString("utf-8");
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const isWasm = decryptedPayload[0] === 0 && decryptedPayload[1] === 97 && decryptedPayload[2] === 115 && decryptedPayload[3] === 109;
|
|
183
|
+
if (decryptedPayload instanceof Buffer && isWasm) {
|
|
184
|
+
const wasmBytes = new Uint8Array(decryptedPayload);
|
|
185
|
+
const compiledModule = await WebAssembly.compile(wasmBytes);
|
|
186
|
+
ASTGuardian.analyze(compiledModule);
|
|
187
|
+
} else if (decryptedPayload instanceof Buffer && !isWasm) {
|
|
188
|
+
decryptedPayload = decryptedPayload.toString("utf-8");
|
|
189
|
+
}
|
|
190
|
+
if (typeof decryptedPayload === "string") {
|
|
191
|
+
decryptedPayload = normalizeLogicSource(decryptedPayload);
|
|
192
|
+
}
|
|
193
|
+
const sandbox = new WasiSandbox();
|
|
194
|
+
await sandbox.init();
|
|
195
|
+
try {
|
|
196
|
+
const result = await sandbox.execute(
|
|
197
|
+
decryptedPayload,
|
|
198
|
+
records,
|
|
199
|
+
decryptedInputs
|
|
200
|
+
);
|
|
201
|
+
let finalOutput = result.output;
|
|
202
|
+
let logicBytes;
|
|
203
|
+
if (typeof decryptedPayload === "string") {
|
|
204
|
+
logicBytes = Buffer.from(decryptedPayload, "utf-8");
|
|
205
|
+
} else {
|
|
206
|
+
logicBytes = new Uint8Array(decryptedPayload);
|
|
207
|
+
}
|
|
208
|
+
const imageId = deriveLogicImageDigest(logicBytes).toString("hex");
|
|
209
|
+
const datasetHash = crypto2.createHash("sha256").update(JSON.stringify(records || [])).digest("hex");
|
|
210
|
+
if (dpConfig) {
|
|
211
|
+
finalOutput = applyDpToOutput(
|
|
212
|
+
finalOutput,
|
|
213
|
+
{
|
|
214
|
+
...dpConfig,
|
|
215
|
+
seed: `${datasetHash}:${imageId}`
|
|
216
|
+
},
|
|
217
|
+
records?.length || 0
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
const journal = Buffer.from(
|
|
221
|
+
JSON.stringify({
|
|
222
|
+
image_id: imageId,
|
|
223
|
+
dataset_hash: datasetHash,
|
|
224
|
+
output_hash: crypto2.createHash("sha256").update(
|
|
225
|
+
typeof finalOutput === "string" ? finalOutput : finalOutput === void 0 ? "undefined" : JSON.stringify(finalOutput)
|
|
226
|
+
).digest("hex"),
|
|
227
|
+
fuel: result.fuelConsumed,
|
|
228
|
+
ts: Date.now()
|
|
229
|
+
})
|
|
230
|
+
);
|
|
231
|
+
const seal = crypto2.createHmac("sha256", sessionSecret).update(journal).digest();
|
|
232
|
+
const journalLen = Buffer.alloc(2);
|
|
233
|
+
journalLen.writeUInt16BE(journal.length);
|
|
234
|
+
const receiptBuf = Buffer.concat([
|
|
235
|
+
Buffer.from([1]),
|
|
236
|
+
// Receipt format v1
|
|
237
|
+
journalLen,
|
|
238
|
+
journal,
|
|
239
|
+
seal
|
|
240
|
+
// 32 bytes HMAC
|
|
241
|
+
]);
|
|
242
|
+
const zkReceipt = receiptBuf.toString("base64");
|
|
243
|
+
return {
|
|
244
|
+
image_id: imageId,
|
|
245
|
+
zk_receipt: zkReceipt,
|
|
246
|
+
output: finalOutput,
|
|
247
|
+
fuel_consumed: result.fuelConsumed
|
|
248
|
+
};
|
|
249
|
+
} finally {
|
|
250
|
+
await sandbox.teardown();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export { processLogicExecution as default };
|
|
255
|
+
//# sourceMappingURL=logic-execution.js.map
|
|
2
256
|
//# sourceMappingURL=logic-execution.js.map
|