@fhestate/mcp-server 1.0.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/LICENSE +21 -0
- package/README.md +432 -0
- package/SECURITY.md +158 -0
- package/data/agents.json +81 -0
- package/dist/blind-step.d.ts +43 -0
- package/dist/blind-step.d.ts.map +1 -0
- package/dist/blind-step.js +59 -0
- package/dist/blind-step.js.map +1 -0
- package/dist/cli-bridge.d.ts +62 -0
- package/dist/cli-bridge.d.ts.map +1 -0
- package/dist/cli-bridge.js +224 -0
- package/dist/cli-bridge.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +37 -0
- package/dist/config.js.map +1 -0
- package/dist/content/overview.d.ts +3 -0
- package/dist/content/overview.d.ts.map +1 -0
- package/dist/content/overview.js +30 -0
- package/dist/content/overview.js.map +1 -0
- package/dist/content/tweets.d.ts +3 -0
- package/dist/content/tweets.d.ts.map +1 -0
- package/dist/content/tweets.js +23 -0
- package/dist/content/tweets.js.map +1 -0
- package/dist/data/agents.json +81 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/redact.d.ts +23 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/redact.js +36 -0
- package/dist/redact.js.map +1 -0
- package/dist/resources.d.ts +6 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +12 -0
- package/dist/resources.js.map +1 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +124 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/agents.d.ts +44 -0
- package/dist/tools/agents.d.ts.map +1 -0
- package/dist/tools/agents.js +91 -0
- package/dist/tools/agents.js.map +1 -0
- package/dist/tools/devnet.d.ts +43 -0
- package/dist/tools/devnet.d.ts.map +1 -0
- package/dist/tools/devnet.js +119 -0
- package/dist/tools/devnet.js.map +1 -0
- package/dist/tools/fhe.d.ts +7 -0
- package/dist/tools/fhe.d.ts.map +1 -0
- package/dist/tools/fhe.js +22 -0
- package/dist/tools/fhe.js.map +1 -0
- package/dist/tools/knowledge.d.ts +19 -0
- package/dist/tools/knowledge.d.ts.map +1 -0
- package/dist/tools/knowledge.js +15 -0
- package/dist/tools/knowledge.js.map +1 -0
- package/dist/tools/social.d.ts +14 -0
- package/dist/tools/social.d.ts.map +1 -0
- package/dist/tools/social.js +10 -0
- package/dist/tools/social.js.map +1 -0
- package/dist/tools/verification.d.ts +7 -0
- package/dist/tools/verification.d.ts.map +1 -0
- package/dist/tools/verification.js +6 -0
- package/dist/tools/verification.js.map +1 -0
- package/package.json +58 -0
package/data/agents.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"demoOrders": [
|
|
3
|
+
"Sentinel Secret Vote (2 min, best for CT)",
|
|
4
|
+
"Sentinel → Auditor Compliance Scan → Auditor Seal Record",
|
|
5
|
+
"Sentinel Market Signal → Coordinator Route Intent"
|
|
6
|
+
],
|
|
7
|
+
"agents": [
|
|
8
|
+
{
|
|
9
|
+
"id": "sentinel",
|
|
10
|
+
"sdkId": "fhestate-sentinel-v1",
|
|
11
|
+
"name": "Sentinel",
|
|
12
|
+
"role": "Confidential operations",
|
|
13
|
+
"strategy": "Signal · Vote · Policy",
|
|
14
|
+
"prerequisites": "None — run any Sentinel mission first",
|
|
15
|
+
"missions": [
|
|
16
|
+
{
|
|
17
|
+
"id": "signal",
|
|
18
|
+
"label": "Market Signal",
|
|
19
|
+
"inputKind": "signal",
|
|
20
|
+
"valueHint": "uint32 signal level",
|
|
21
|
+
"prerequisites": null
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "vote",
|
|
25
|
+
"label": "Secret Vote",
|
|
26
|
+
"inputKind": "vote",
|
|
27
|
+
"valueHint": "1 = YES, 0 = NO",
|
|
28
|
+
"prerequisites": null
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "threshold",
|
|
32
|
+
"label": "Policy Gate",
|
|
33
|
+
"inputKind": "threshold",
|
|
34
|
+
"valueHint": "uint32 policy threshold",
|
|
35
|
+
"prerequisites": null
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "auditor",
|
|
41
|
+
"sdkId": "fhestate-auditor-v1",
|
|
42
|
+
"name": "Auditor",
|
|
43
|
+
"role": "Compliance attestation",
|
|
44
|
+
"strategy": "Verify · Attest · Log",
|
|
45
|
+
"prerequisites": "Seal Record requires prior Auditor memory",
|
|
46
|
+
"missions": [
|
|
47
|
+
{
|
|
48
|
+
"id": "audit-scan",
|
|
49
|
+
"label": "Compliance Scan",
|
|
50
|
+
"inputKind": "checkpoint",
|
|
51
|
+
"valueHint": "checkpoint code 1–255",
|
|
52
|
+
"prerequisites": null
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"id": "audit-seal",
|
|
56
|
+
"label": "Seal Record",
|
|
57
|
+
"inputKind": "seal",
|
|
58
|
+
"valueHint": "seal nonce 1–9999",
|
|
59
|
+
"prerequisites": "Run Compliance Scan first"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"id": "coordinator",
|
|
65
|
+
"sdkId": "fhestate-coordinator-v1",
|
|
66
|
+
"name": "Coordinator",
|
|
67
|
+
"role": "Multi-party routing",
|
|
68
|
+
"strategy": "Route · Sync · Commit",
|
|
69
|
+
"prerequisites": "Route Intent requires at least one Sentinel memory slot",
|
|
70
|
+
"missions": [
|
|
71
|
+
{
|
|
72
|
+
"id": "route-intent",
|
|
73
|
+
"label": "Route Intent",
|
|
74
|
+
"inputKind": "route",
|
|
75
|
+
"valueHint": "route channel id 1–100",
|
|
76
|
+
"prerequisites": "Run any Sentinel mission first"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type MemorySlot = {
|
|
2
|
+
slot: number;
|
|
3
|
+
intentHash: string;
|
|
4
|
+
stepHash: string;
|
|
5
|
+
commitmentUri: string;
|
|
6
|
+
recordedAt: string;
|
|
7
|
+
};
|
|
8
|
+
export type StepResult = {
|
|
9
|
+
agentId: string;
|
|
10
|
+
missionId: string;
|
|
11
|
+
stepIndex: number;
|
|
12
|
+
intentHash: string;
|
|
13
|
+
stepHash: string;
|
|
14
|
+
commitmentUri: string;
|
|
15
|
+
previousStepHash: string | null;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Zero-Knowledge Volatile Memory.
|
|
19
|
+
* An ephemeral memory class that exclusively stores SHA-256 state commitments.
|
|
20
|
+
* At no point does this class hold plaintext values or private keys.
|
|
21
|
+
* It functions as a local, localized blockchain to track the agent's workflow state.
|
|
22
|
+
*/
|
|
23
|
+
export declare class LocalMemory {
|
|
24
|
+
private slots;
|
|
25
|
+
list(): MemorySlot[];
|
|
26
|
+
latestStepHash(): string | null;
|
|
27
|
+
record(slot: MemorySlot): void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Executes a "Blind State" transition.
|
|
31
|
+
* Takes a newly generated FHE ciphertext hash (intentHash) and cryptographically links it
|
|
32
|
+
* to the agent's historical hash chain (`previousStepHash`). This creates an immutable
|
|
33
|
+
* local execution trail that can be audited homomorphically without ever revealing the
|
|
34
|
+
* underlying plaintext operations to the host memory.
|
|
35
|
+
*
|
|
36
|
+
* @param agentId The identifier of the active agent (e.g. sentinel, auditor).
|
|
37
|
+
* @param missionId The specific registered workflow mission.
|
|
38
|
+
* @param intentHash The SHA-256 hash of the generated `ciphertext.bin`.
|
|
39
|
+
* @param memory The agent's Zero-Knowledge volatile memory instance.
|
|
40
|
+
* @returns The resulting cryptographic step commitment.
|
|
41
|
+
*/
|
|
42
|
+
export declare function runBlindStep(agentId: string, missionId: string, intentHash: string, memory: LocalMemory): StepResult;
|
|
43
|
+
//# sourceMappingURL=blind-step.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blind-step.d.ts","sourceRoot":"","sources":["../src/blind-step.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,CAAC;AAMF;;;;;GAKG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,KAAK,CAAoB;IAEjC,IAAI,IAAI,UAAU,EAAE;IAIpB,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/B,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;CAG/B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,WAAW,GAClB,UAAU,CAwBZ"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
function sha256Hex(text) {
|
|
3
|
+
return createHash("sha256").update(text, "utf8").digest("hex");
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Zero-Knowledge Volatile Memory.
|
|
7
|
+
* An ephemeral memory class that exclusively stores SHA-256 state commitments.
|
|
8
|
+
* At no point does this class hold plaintext values or private keys.
|
|
9
|
+
* It functions as a local, localized blockchain to track the agent's workflow state.
|
|
10
|
+
*/
|
|
11
|
+
export class LocalMemory {
|
|
12
|
+
slots = [];
|
|
13
|
+
list() {
|
|
14
|
+
return [...this.slots];
|
|
15
|
+
}
|
|
16
|
+
latestStepHash() {
|
|
17
|
+
return this.slots[this.slots.length - 1]?.stepHash ?? null;
|
|
18
|
+
}
|
|
19
|
+
record(slot) {
|
|
20
|
+
this.slots.push(slot);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Executes a "Blind State" transition.
|
|
25
|
+
* Takes a newly generated FHE ciphertext hash (intentHash) and cryptographically links it
|
|
26
|
+
* to the agent's historical hash chain (`previousStepHash`). This creates an immutable
|
|
27
|
+
* local execution trail that can be audited homomorphically without ever revealing the
|
|
28
|
+
* underlying plaintext operations to the host memory.
|
|
29
|
+
*
|
|
30
|
+
* @param agentId The identifier of the active agent (e.g. sentinel, auditor).
|
|
31
|
+
* @param missionId The specific registered workflow mission.
|
|
32
|
+
* @param intentHash The SHA-256 hash of the generated `ciphertext.bin`.
|
|
33
|
+
* @param memory The agent's Zero-Knowledge volatile memory instance.
|
|
34
|
+
* @returns The resulting cryptographic step commitment.
|
|
35
|
+
*/
|
|
36
|
+
export function runBlindStep(agentId, missionId, intentHash, memory) {
|
|
37
|
+
const previousStepHash = memory.latestStepHash();
|
|
38
|
+
const stepIndex = memory.list().length + 1;
|
|
39
|
+
const payload = `${agentId}|${missionId}|${intentHash}|${stepIndex}|${previousStepHash ?? "genesis"}`;
|
|
40
|
+
const stepHash = sha256Hex(payload);
|
|
41
|
+
const commitmentUri = `local://${missionId}/${intentHash}`;
|
|
42
|
+
memory.record({
|
|
43
|
+
slot: stepIndex,
|
|
44
|
+
intentHash,
|
|
45
|
+
stepHash,
|
|
46
|
+
commitmentUri,
|
|
47
|
+
recordedAt: new Date().toISOString(),
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
agentId,
|
|
51
|
+
missionId,
|
|
52
|
+
stepIndex,
|
|
53
|
+
intentHash,
|
|
54
|
+
stepHash,
|
|
55
|
+
commitmentUri,
|
|
56
|
+
previousStepHash,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=blind-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blind-step.js","sourceRoot":"","sources":["../src/blind-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAoBzC,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IACd,KAAK,GAAiB,EAAE,CAAC;IAEjC,IAAI;QACF,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,QAAQ,IAAI,IAAI,CAAC;IAC7D,CAAC;IAED,MAAM,CAAC,IAAgB;QACrB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;CACF;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAe,EACf,SAAiB,EACjB,UAAkB,EAClB,MAAmB;IAEnB,MAAM,gBAAgB,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IACjD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,GAAG,OAAO,IAAI,SAAS,IAAI,UAAU,IAAI,SAAS,IAAI,gBAAgB,IAAI,SAAS,EAAE,CAAC;IACtG,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,aAAa,GAAG,WAAW,SAAS,IAAI,UAAU,EAAE,CAAC;IAE3D,MAAM,CAAC,MAAM,CAAC;QACZ,IAAI,EAAE,SAAS;QACf,UAAU;QACV,QAAQ;QACR,aAAa;QACb,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACrC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,SAAS;QACT,SAAS;QACT,UAAU;QACV,QAAQ;QACR,aAAa;QACb,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cryptographic boundary constraint: Enforces rigorous parameter type checking.
|
|
3
|
+
* Rejects floating point approximations or negative bounds hallucinogenically generated by LLMs.
|
|
4
|
+
* @param value The raw numeric input to validate.
|
|
5
|
+
* @throws {RangeError} If the value exceeds the 32-bit unsigned integer mathematical bound.
|
|
6
|
+
*/
|
|
7
|
+
export declare function assertUint32(value: number): void;
|
|
8
|
+
/**
|
|
9
|
+
* IPC Argument Sanitization Layer.
|
|
10
|
+
* Intercepts LLM-generated arguments before they hit the child_process.spawn boundary.
|
|
11
|
+
* Strictly prevents path traversal (e.g. `../`) and memory exhaustion via massive array spamming.
|
|
12
|
+
* @param subcommand The target execution command for the Rust binary.
|
|
13
|
+
* @param args The parameter array generated by the AI agent.
|
|
14
|
+
* @returns A safe, normalized string array or a strict rejection error.
|
|
15
|
+
*/
|
|
16
|
+
export declare function sanitizeCliArgs(subcommand: string, args: string[]): {
|
|
17
|
+
ok: true;
|
|
18
|
+
args: string[];
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
error: string;
|
|
22
|
+
};
|
|
23
|
+
export type CliRunResult = {
|
|
24
|
+
ok: boolean;
|
|
25
|
+
exitCode: number | null;
|
|
26
|
+
stdout: string;
|
|
27
|
+
stderr: string;
|
|
28
|
+
parsed?: Record<string, string>;
|
|
29
|
+
sha256?: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function getCliPath(): string;
|
|
32
|
+
export declare function cliInstallHint(): string;
|
|
33
|
+
export declare function parseCliKvOutput(stdout: string): Record<string, string>;
|
|
34
|
+
export declare function extractSha256(stdout: string): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Core Coprocessor Execution Bridge (Zero-Trust).
|
|
37
|
+
* Spawns the deterministic `fhe-cli` Rust binary using `shell: false` to fundamentally
|
|
38
|
+
* prevent Remote Code Execution (RCE) via shell interpolation. Includes rigid 60-second
|
|
39
|
+
* buffer timeouts and 512KB memory capping to prevent LLM-induced host exhaustion.
|
|
40
|
+
* @param subcommand The pre-approved FHE operation to execute.
|
|
41
|
+
* @param args The sanitized argument vector.
|
|
42
|
+
* @returns The fully redacted, standardized CLI result object containing stdout/stderr streams.
|
|
43
|
+
*/
|
|
44
|
+
export declare function runFheCli(subcommand: string, args?: string[]): Promise<CliRunResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Temporal Encryption Orchestrator.
|
|
47
|
+
* Spawns a highly volatile, ephemeral temporal directory in the host OS to securely store
|
|
48
|
+
* the intermediate `ciphertext.bin`. Executes the Rust lattice encryption, extracts the
|
|
49
|
+
* final `SHA-256` commitment hash, and immolates the temporal directory to guarantee
|
|
50
|
+
* zero plaintext leakage.
|
|
51
|
+
* @param value The strictly validated unsigned 32-bit integer to encrypt.
|
|
52
|
+
* @returns The resulting cryptographic hash and Solana commitment URI.
|
|
53
|
+
*/
|
|
54
|
+
export declare function encryptValueViaCli(value: number): Promise<{
|
|
55
|
+
ok: boolean;
|
|
56
|
+
sha256?: string;
|
|
57
|
+
commitmentUri?: string;
|
|
58
|
+
stdout: string;
|
|
59
|
+
stderr: string;
|
|
60
|
+
error?: string;
|
|
61
|
+
}>;
|
|
62
|
+
//# sourceMappingURL=cli-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli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ACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAyBD"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { redact } from "./redact.js";
|
|
6
|
+
const ALLOWED = new Set([
|
|
7
|
+
"doctor",
|
|
8
|
+
"status",
|
|
9
|
+
"config-init",
|
|
10
|
+
"setup",
|
|
11
|
+
"submit",
|
|
12
|
+
"submit-input",
|
|
13
|
+
"submit-file",
|
|
14
|
+
"init-state",
|
|
15
|
+
"reveal",
|
|
16
|
+
"encrypt",
|
|
17
|
+
"keygen",
|
|
18
|
+
"wallet",
|
|
19
|
+
"balance",
|
|
20
|
+
"airdrop",
|
|
21
|
+
"history",
|
|
22
|
+
"cache",
|
|
23
|
+
"watch",
|
|
24
|
+
"flow",
|
|
25
|
+
]);
|
|
26
|
+
const TIMEOUT_MS = 60_000;
|
|
27
|
+
const MAX_OUTPUT = 512 * 1024;
|
|
28
|
+
const MAX_CLI_ARGS = 32;
|
|
29
|
+
const MAX_ARG_LEN = 4096;
|
|
30
|
+
const UINT32_MAX = 0xffffffff;
|
|
31
|
+
/**
|
|
32
|
+
* Cryptographic boundary constraint: Enforces rigorous parameter type checking.
|
|
33
|
+
* Rejects floating point approximations or negative bounds hallucinogenically generated by LLMs.
|
|
34
|
+
* @param value The raw numeric input to validate.
|
|
35
|
+
* @throws {RangeError} If the value exceeds the 32-bit unsigned integer mathematical bound.
|
|
36
|
+
*/
|
|
37
|
+
export function assertUint32(value) {
|
|
38
|
+
if (!Number.isInteger(value) || value < 0 || value > UINT32_MAX) {
|
|
39
|
+
throw new RangeError("value must be an integer from 0 to 4294967295 (uint32)");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* IPC Argument Sanitization Layer.
|
|
44
|
+
* Intercepts LLM-generated arguments before they hit the child_process.spawn boundary.
|
|
45
|
+
* Strictly prevents path traversal (e.g. `../`) and memory exhaustion via massive array spamming.
|
|
46
|
+
* @param subcommand The target execution command for the Rust binary.
|
|
47
|
+
* @param args The parameter array generated by the AI agent.
|
|
48
|
+
* @returns A safe, normalized string array or a strict rejection error.
|
|
49
|
+
*/
|
|
50
|
+
export function sanitizeCliArgs(subcommand, args) {
|
|
51
|
+
const cmd = subcommand.split(/\s+/)[0].toLowerCase();
|
|
52
|
+
if (args.length > MAX_CLI_ARGS) {
|
|
53
|
+
return { ok: false, error: `Too many CLI arguments (max ${MAX_CLI_ARGS})` };
|
|
54
|
+
}
|
|
55
|
+
for (const arg of args) {
|
|
56
|
+
if (arg.length > MAX_ARG_LEN)
|
|
57
|
+
return { ok: false, error: "CLI argument too long" };
|
|
58
|
+
if (/[\0\r\n]/.test(arg))
|
|
59
|
+
return { ok: false, error: "Invalid CLI argument" };
|
|
60
|
+
if (cmd === "encrypt" && (arg === "--out" || arg.startsWith("--out="))) {
|
|
61
|
+
return {
|
|
62
|
+
ok: false,
|
|
63
|
+
error: "Use fhe_encrypt for encrypt; --out is not allowed via fhe_cli_run",
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (/\.\.(\/|\\)/.test(arg)) {
|
|
67
|
+
return { ok: false, error: "Path traversal in CLI argument is not allowed" };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { ok: true, args };
|
|
71
|
+
}
|
|
72
|
+
export function getCliPath() {
|
|
73
|
+
return process.env.FHESTATE_CLI_PATH ?? "fhe-cli";
|
|
74
|
+
}
|
|
75
|
+
export function cliInstallHint() {
|
|
76
|
+
return ("fhe-cli not found. Build from fhestate-rs: cargo build --release -p fhe-cli, " +
|
|
77
|
+
"then set FHESTATE_CLI_PATH or add target/release to PATH.");
|
|
78
|
+
}
|
|
79
|
+
export function parseCliKvOutput(stdout) {
|
|
80
|
+
const parsed = {};
|
|
81
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
82
|
+
const m = line.match(/^\s*([^:]+):\s*(.+)\s*$/);
|
|
83
|
+
if (m)
|
|
84
|
+
parsed[m[1].trim().toLowerCase()] = m[2].trim();
|
|
85
|
+
}
|
|
86
|
+
return parsed;
|
|
87
|
+
}
|
|
88
|
+
export function extractSha256(stdout) {
|
|
89
|
+
const parsed = parseCliKvOutput(stdout);
|
|
90
|
+
const fromKv = parsed["sha-256"] ?? parsed["sha256"];
|
|
91
|
+
if (fromKv && /^[a-f0-9]{64}$/i.test(fromKv))
|
|
92
|
+
return fromKv.toLowerCase();
|
|
93
|
+
const m = stdout.match(/SHA-256:\s*([a-f0-9]{64})/i);
|
|
94
|
+
return m?.[1]?.toLowerCase();
|
|
95
|
+
}
|
|
96
|
+
function toClapArgs(subcommand, args) {
|
|
97
|
+
const base = subcommand.toLowerCase();
|
|
98
|
+
if (base === "config-init")
|
|
99
|
+
return ["config-init", ...args];
|
|
100
|
+
if (base === "submit-input")
|
|
101
|
+
return ["submit-input", ...args];
|
|
102
|
+
if (base === "submit-file")
|
|
103
|
+
return ["submit-file", ...args];
|
|
104
|
+
if (base === "init-state")
|
|
105
|
+
return ["init-state", ...args];
|
|
106
|
+
if (base === "cache" && args[0] === "list")
|
|
107
|
+
return ["cache", "list"];
|
|
108
|
+
if (base === "cache" && args[0] === "show")
|
|
109
|
+
return ["cache", "show", ...args.slice(1)];
|
|
110
|
+
if (base === "wallet" && args[0] === "new")
|
|
111
|
+
return ["wallet", "new", ...args.slice(1)];
|
|
112
|
+
if (base === "flow" && args[0] === "counter")
|
|
113
|
+
return ["flow", "counter", ...args.slice(1)];
|
|
114
|
+
return [base, ...args];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Core Coprocessor Execution Bridge (Zero-Trust).
|
|
118
|
+
* Spawns the deterministic `fhe-cli` Rust binary using `shell: false` to fundamentally
|
|
119
|
+
* prevent Remote Code Execution (RCE) via shell interpolation. Includes rigid 60-second
|
|
120
|
+
* buffer timeouts and 512KB memory capping to prevent LLM-induced host exhaustion.
|
|
121
|
+
* @param subcommand The pre-approved FHE operation to execute.
|
|
122
|
+
* @param args The sanitized argument vector.
|
|
123
|
+
* @returns The fully redacted, standardized CLI result object containing stdout/stderr streams.
|
|
124
|
+
*/
|
|
125
|
+
export async function runFheCli(subcommand, args = []) {
|
|
126
|
+
const cmd = subcommand.split(/\s+/)[0].toLowerCase();
|
|
127
|
+
if (!ALLOWED.has(cmd)) {
|
|
128
|
+
return {
|
|
129
|
+
ok: false,
|
|
130
|
+
exitCode: 1,
|
|
131
|
+
stdout: "",
|
|
132
|
+
stderr: `Subcommand not allowed: ${subcommand}. Allowed: ${[...ALLOWED].join(", ")}`,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const cli = getCliPath();
|
|
136
|
+
const argv = toClapArgs(subcommand, args);
|
|
137
|
+
const env = { ...process.env };
|
|
138
|
+
if (process.env.FHESTATE_RPC)
|
|
139
|
+
env.FHESTATE_RPC = process.env.FHESTATE_RPC;
|
|
140
|
+
if (process.env.FHESTATE_WALLET_PATH)
|
|
141
|
+
env.FHESTATE_WALLET_PATH = process.env.FHESTATE_WALLET_PATH;
|
|
142
|
+
if (process.env.FHESTATE_PROGRAM_ID)
|
|
143
|
+
env.FHESTATE_PROGRAM_ID = process.env.FHESTATE_PROGRAM_ID;
|
|
144
|
+
return new Promise((resolvePromise) => {
|
|
145
|
+
let stdout = "";
|
|
146
|
+
let stderr = "";
|
|
147
|
+
// Important: do not use `shell:true` for native binaries.
|
|
148
|
+
// Under MCP/Node, `shell:true` can cause hangs on Windows when stdout is piped.
|
|
149
|
+
const child = spawn(cli, argv, { env, shell: false, windowsHide: true });
|
|
150
|
+
const timer = setTimeout(() => {
|
|
151
|
+
child.kill("SIGTERM");
|
|
152
|
+
stderr += "\n[timeout after 60s]";
|
|
153
|
+
}, TIMEOUT_MS);
|
|
154
|
+
child.stdout?.on("data", (chunk) => {
|
|
155
|
+
stdout += chunk.toString();
|
|
156
|
+
if (stdout.length > MAX_OUTPUT)
|
|
157
|
+
stdout = stdout.slice(0, MAX_OUTPUT) + "\n[truncated]";
|
|
158
|
+
});
|
|
159
|
+
child.stderr?.on("data", (chunk) => {
|
|
160
|
+
stderr += chunk.toString();
|
|
161
|
+
if (stderr.length > MAX_OUTPUT)
|
|
162
|
+
stderr = stderr.slice(0, MAX_OUTPUT) + "\n[truncated]";
|
|
163
|
+
});
|
|
164
|
+
child.on("error", (err) => {
|
|
165
|
+
clearTimeout(timer);
|
|
166
|
+
resolvePromise({
|
|
167
|
+
ok: false,
|
|
168
|
+
exitCode: null,
|
|
169
|
+
stdout: redact(stdout),
|
|
170
|
+
stderr: redact(err.message.includes("ENOENT") ? cliInstallHint() : err.message),
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
child.on("close", (code) => {
|
|
174
|
+
clearTimeout(timer);
|
|
175
|
+
const parsed = parseCliKvOutput(stdout);
|
|
176
|
+
const sha256 = extractSha256(stdout);
|
|
177
|
+
resolvePromise({
|
|
178
|
+
ok: code === 0,
|
|
179
|
+
exitCode: code,
|
|
180
|
+
stdout: redact(stdout),
|
|
181
|
+
stderr: redact(stderr),
|
|
182
|
+
parsed,
|
|
183
|
+
sha256,
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Temporal Encryption Orchestrator.
|
|
190
|
+
* Spawns a highly volatile, ephemeral temporal directory in the host OS to securely store
|
|
191
|
+
* the intermediate `ciphertext.bin`. Executes the Rust lattice encryption, extracts the
|
|
192
|
+
* final `SHA-256` commitment hash, and immolates the temporal directory to guarantee
|
|
193
|
+
* zero plaintext leakage.
|
|
194
|
+
* @param value The strictly validated unsigned 32-bit integer to encrypt.
|
|
195
|
+
* @returns The resulting cryptographic hash and Solana commitment URI.
|
|
196
|
+
*/
|
|
197
|
+
export async function encryptValueViaCli(value) {
|
|
198
|
+
assertUint32(value);
|
|
199
|
+
const dir = await mkdtemp(join(tmpdir(), "fhestate-mcp-"));
|
|
200
|
+
const outFile = join(dir, "ciphertext.bin");
|
|
201
|
+
try {
|
|
202
|
+
const result = await runFheCli("encrypt", ["--value", String(value), "--out", outFile]);
|
|
203
|
+
if (!result.ok || !result.sha256) {
|
|
204
|
+
return {
|
|
205
|
+
ok: false,
|
|
206
|
+
stdout: result.stdout,
|
|
207
|
+
stderr: result.stderr,
|
|
208
|
+
error: result.stderr || cliInstallHint(),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
const uri = result.parsed?.["cache uri"];
|
|
212
|
+
return {
|
|
213
|
+
ok: true,
|
|
214
|
+
sha256: result.sha256,
|
|
215
|
+
commitmentUri: uri ? `local://${result.sha256}` : `local://${result.sha256}`,
|
|
216
|
+
stdout: result.stdout,
|
|
217
|
+
stderr: result.stderr,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
await rm(dir, { recursive: true, force: true });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=cli-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-bridge.js","sourceRoot":"","sources":["../src/cli-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC;IAEtB,QAAQ;IACR,QAAQ;IACR,aAAa;IACb,OAAO;IACP,QAAQ;IACR,cAAc;IACd,aAAa;IACb,Y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,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,WAAW,CAAC,CAAC;QACzC,OAAO;YACL,EAAE,EAAE,IAAI;YACR,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,MAAM,EAAE;YAC5E,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function getPackageRoot(): string;
|
|
2
|
+
export declare function getRpcUrl(): string;
|
|
3
|
+
export declare function getWalletPath(): string | undefined;
|
|
4
|
+
export declare function isReadOnly(): boolean;
|
|
5
|
+
export declare function getAgentsJsonPath(): string;
|
|
6
|
+
export declare function getMcpConfigState(): {
|
|
7
|
+
FHESTATE_CLI_PATH: string;
|
|
8
|
+
FHESTATE_WALLET_PATH: string;
|
|
9
|
+
FHESTATE_MCP_READ_ONLY: string;
|
|
10
|
+
FHESTATE_RPC: string;
|
|
11
|
+
AGENTS_REGISTRY_PATH: string;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAYA,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAElD;AAED,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAI1C;AAED,wBAAgB,iBAAiB;;;;;;EAQhC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Configuration Manager.
|
|
3
|
+
* Handles strict resolution of environmental variables required for the MCP Server.
|
|
4
|
+
* Enforces the isolation between local file systems, Solana RPC nodes, and
|
|
5
|
+
* read-only operation modes.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync } from "node:fs";
|
|
8
|
+
import { dirname, join } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
11
|
+
export function getPackageRoot() {
|
|
12
|
+
return packageRoot;
|
|
13
|
+
}
|
|
14
|
+
export function getRpcUrl() {
|
|
15
|
+
return process.env.FHESTATE_RPC ?? "https://api.devnet.solana.com";
|
|
16
|
+
}
|
|
17
|
+
export function getWalletPath() {
|
|
18
|
+
return process.env.FHESTATE_WALLET_PATH;
|
|
19
|
+
}
|
|
20
|
+
export function isReadOnly() {
|
|
21
|
+
return process.env.FHESTATE_MCP_READ_ONLY === "1";
|
|
22
|
+
}
|
|
23
|
+
export function getAgentsJsonPath() {
|
|
24
|
+
const distPath = join(packageRoot, "dist", "data", "agents.json");
|
|
25
|
+
const dataPath = join(packageRoot, "data", "agents.json");
|
|
26
|
+
return existsSync(distPath) ? distPath : dataPath;
|
|
27
|
+
}
|
|
28
|
+
export function getMcpConfigState() {
|
|
29
|
+
return {
|
|
30
|
+
FHESTATE_CLI_PATH: process.env.FHESTATE_CLI_PATH ? "[CONFIGURED]" : "[MISSING]",
|
|
31
|
+
FHESTATE_WALLET_PATH: process.env.FHESTATE_WALLET_PATH ? "[CONFIGURED]" : "[MISSING]",
|
|
32
|
+
FHESTATE_MCP_READ_ONLY: isReadOnly() ? "ENABLED" : "DISABLED",
|
|
33
|
+
FHESTATE_RPC: getRpcUrl(),
|
|
34
|
+
AGENTS_RE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AAC,cAAc,CAAC,CAAC,CAAC,WAAW;QAC/E,oBAAoB,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,WAAW;QACrF,sBAAsB,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;QAC7D,YAAY,EAAE,SAAS,EAAE;QACzB,oBAAoB,EAAE,iBAAiB,EAAE;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const EXECUTION_PROTOCOL_SCRIPT = "Execution Protocol \u2014 Sentinel Secret Vote (MCP Lifecycle):\n\n1. INITIALIZE IPC BRIDGE: Ensure the Rust Coprocessor is compiled and accessible via FHESTATE_CLI_PATH.\n2. AUTHENTICATE COPROCESSOR: Invoke `devnet_wallet_status` to verify Solana Devnet RPC and keypair linkage.\n3. INJECT PAYLOAD: Dispatch primitive value (e.g., 1) to `agent_run_blind_step` with agentId: \"sentinel\", missionId: \"vote\".\n4. HOMOMORPHIC EVALUATION: Coprocessor executes TFHE-rs lattice encryption. Plaintext is immediately destroyed from host memory.\n5. BLIND STATE COMMIT: The resulting SHA-256 hash commitment is pushed to the local Zero-Knowledge Hash Chain.\n6. PUBLIC SETTLEMENT: Invoke `devnet_submit_memo` to permanently anchor the ciphertext hash to the Solana ledger.\n7. VERIFICATION: Retrieve the Solscan signature via `devnet_history` and verify that the blockchain payload strictly contains the `local://<hash>` URI.\n\nRouting Directive: Once anchored, the Sentinel's state commitment can be independently evaluated by the Auditor Agent.";
|
|
2
|
+
export declare const LIVE_PROOF_CHECKLIST = "Architectural Proof Checklist:\n\nPre-Flight Verification:\n- Devnet RPC Endpoint is responding.\n- Host machine has a funded, isolated Devnet wallet.\n- fhe-cli Coprocessor is compiled via --release for maximum polynomial multiplication efficiency.\n\nLifecycle Verification:\n1. Sentinel Agent executes Secret Vote payload.\n2. Verify local lattice ciphertext generation completes without memory exhaustion.\n3. Validate Proof state \u2014 verify hash-chain generation without revealing plaintext.\n4. Solscan Verification \u2014 confirm transaction memo contains strictly local:// hash commitments.\n5. Blind Step Memory Verification \u2014 confirm slot assignment strictly matches execution sequence.\n\nArchitectural Guarantees:\n- Execution is strictly bounded to the Solana Devnet.\n- Security relies on deterministic TFHE-rs Coprocessor Hash Commitments.\n- AI Agents operate exclusively as permissionless logic routers bounded by strict Zod schemas.";
|
|
3
|
+
//# sourceMappingURL=overview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overview.d.ts","sourceRoot":"","sources":["../../src/content/overview.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,shCAUiF,CAAC;AAExH,eAAO,MAAM,oBAAoB,m8BAiB8D,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const EXECUTION_PROTOCOL_SCRIPT = `Execution Protocol — Sentinel Secret Vote (MCP Lifecycle):
|
|
2
|
+
|
|
3
|
+
1. INITIALIZE IPC BRIDGE: Ensure the Rust Coprocessor is compiled and accessible via FHESTATE_CLI_PATH.
|
|
4
|
+
2. AUTHENTICATE COPROCESSOR: Invoke \`devnet_wallet_status\` to verify Solana Devnet RPC and keypair linkage.
|
|
5
|
+
3. INJECT PAYLOAD: Dispatch primitive value (e.g., 1) to \`agent_run_blind_step\` with agentId: "sentinel", missionId: "vote".
|
|
6
|
+
4. HOMOMORPHIC EVALUATION: Coprocessor executes TFHE-rs lattice encryption. Plaintext is immediately destroyed from host memory.
|
|
7
|
+
5. BLIND STATE COMMIT: The resulting SHA-256 hash commitment is pushed to the local Zero-Knowledge Hash Chain.
|
|
8
|
+
6. PUBLIC SETTLEMENT: Invoke \`devnet_submit_memo\` to permanently anchor the ciphertext hash to the Solana ledger.
|
|
9
|
+
7. VERIFICATION: Retrieve the Solscan signature via \`devnet_history\` and verify that the blockchain payload strictly contains the \`local://<hash>\` URI.
|
|
10
|
+
|
|
11
|
+
Routing Directive: Once anchored, the Sentinel's state commitment can be independently evaluated by the Auditor Agent.`;
|
|
12
|
+
export const LIVE_PROOF_CHECKLIST = `Architectural Proof Checklist:
|
|
13
|
+
|
|
14
|
+
Pre-Flight Verification:
|
|
15
|
+
- Devnet RPC Endpoint is responding.
|
|
16
|
+
- Host machine has a funded, isolated Devnet wallet.
|
|
17
|
+
- fhe-cli Coprocessor is compiled via --release for maximum polynomial multiplication efficiency.
|
|
18
|
+
|
|
19
|
+
Lifecycle Verification:
|
|
20
|
+
1. Sentinel Agent executes Secret Vote payload.
|
|
21
|
+
2. Verify local lattice ciphertext generation completes without memory exhaustion.
|
|
22
|
+
3. Validate Proof state — verify hash-chain generation without revealing plaintext.
|
|
23
|
+
4. Solscan Verification — confirm transaction memo contains strictly local:// hash commitments.
|
|
24
|
+
5. Blind Step Memory Verification — confirm slot assignment strictly matches execution sequence.
|
|
25
|
+
|
|
26
|
+
Architectural Guarantees:
|
|
27
|
+
- Execution is strictly bounded to the Solana Devnet.
|
|
28
|
+
- Security relies on deterministic TFHE-rs Coprocessor Hash Commitments.
|
|
29
|
+
- AI Agents operate exclusively as permissionless logic routers bounded by strict Zod schemas.`;
|
|
30
|
+
//# sourceMappingURL=overview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overview.js","sourceRoot":"","sources":["../../src/content/overview.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;;;;uHAU8E,CAAC;AAExH,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;+FAiB2D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tweets.d.ts","sourceRoot":"","sources":["../../src/content/tweets.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExD,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CA+BpE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function draftTweet(kind, mission) {
|
|
2
|
+
if (kind === "phase3") {
|
|
3
|
+
return ("Phase 3 shipped on FHESTATE: fhestate-sdk on npm — real TFHE in the browser, " +
|
|
4
|
+
"Solana devnet commits, confidential agent runtime for builders. " +
|
|
5
|
+
"https://www.npmjs.com/package/fhestate-sdk");
|
|
6
|
+
}
|
|
7
|
+
if (kind === "phase4") {
|
|
8
|
+
return ("Phase 4 is live: confidential agents on Solana devnet — encrypt in your browser, " +
|
|
9
|
+
"blind step, proof on Solscan. Not a mock. https://app.fhestate.org");
|
|
10
|
+
}
|
|
11
|
+
const m = (mission ?? "vote").toLowerCase();
|
|
12
|
+
if (m.includes("vote")) {
|
|
13
|
+
return ("Ran Sentinel Secret Vote on @FHESTATE — YES stays encrypted, Solscan shows the hash not my ballot. " +
|
|
14
|
+
"Try it: https://app.fhestate.org");
|
|
15
|
+
}
|
|
16
|
+
if (m.includes("signal")) {
|
|
17
|
+
return ("Encrypted market signal on Solana devnet with FHESTATE Sentinel — proof on chain, level stays private. " +
|
|
18
|
+
"https://app.fhestate.org");
|
|
19
|
+
}
|
|
20
|
+
return ("FHESTATE confidential agents on Solana devnet — FHE in the browser, blind steps, verifiable hashes. " +
|
|
21
|
+
"https://app.fhestate.org");
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=tweets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tweets.js","sourceRoot":"","sources":["../../src/content/tweets.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU,CAAC,IAAe,EAAE,OAAgB;IAC1D,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,OAAO,CACL,+EAA+E;YAC/E,kEAAkE;YAClE,4CAA4C,CAC7C,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,OAAO,CACL,mFAAmF;YACnF,oEAAoE,CACrE,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5C,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACvB,OAAO,CACL,qGAAqG;YACrG,kCAAkC,CACnC,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,OAAO,CACL,yGAAyG;YACzG,0BAA0B,CAC3B,CAAC;IACJ,CAAC;IACD,OAAO,CACL,sGAAsG;QACtG,0BAA0B,CAC3B,CAAC;AACJ,CAAC"}
|