enigma-memory 0.1.18 → 0.1.22
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 +76 -24
- package/apps/cli/bin/enigma-desktop.mjs +140 -0
- package/apps/cli/bin/enigma-terminal.mjs +78 -0
- package/apps/cli/bin/enigma.mjs +1923 -285
- package/apps/desktop/electron-main.cjs +217 -0
- package/apps/desktop/package.json +12 -0
- package/apps/desktop/src/app.js +264 -7
- package/apps/desktop/src/index.html +3514 -1373
- package/apps/desktop/src/launch-electron.mjs +51 -0
- package/apps/desktop/src/server.mjs +2914 -0
- package/apps/desktop/src/styles.css +2972 -260
- package/apps/desktop/src/zk-browser-prove.mjs +53 -0
- package/apps/desktop/src/zk-state.mjs +1789 -0
- package/apps/gateway/bin/enigma-gateway.mjs +102 -5
- package/apps/gateway/src/server.mjs +271 -8
- package/apps/ios/EnigmaCore/Package.swift +12 -0
- package/apps/ios/EnigmaCore/Sources/EnigmaCore/EnigmaAPIClient.swift +227 -0
- package/apps/ios/EnigmaCore/Sources/EnigmaCore/Models.swift +278 -0
- package/apps/ios/EnigmaCore/Sources/EnigmaCore/PKCE.swift +96 -0
- package/apps/ios/EnigmaCore/Sources/EnigmaCore/PrivacyMinimizer.swift +187 -0
- package/apps/ios/EnigmaCore/Sources/EnigmaCore/ToolModels.swift +129 -0
- package/apps/ios/EnigmaCore/Tests/EnigmaCoreTests/EnigmaCoreTests.swift +42 -0
- package/apps/ios/EnigmaIOS/Enigma/AppModel.swift +346 -0
- package/apps/ios/EnigmaIOS/Enigma/Assets.xcassets/AccentColor.colorset/Contents.json +12 -0
- package/apps/ios/EnigmaIOS/Enigma/Assets.xcassets/AppIcon.appiconset/Contents.json +11 -0
- package/apps/ios/EnigmaIOS/Enigma/Assets.xcassets/AppIcon.appiconset/EnigmaAppIcon.png +0 -0
- package/apps/ios/EnigmaIOS/Enigma/Assets.xcassets/Contents.json +3 -0
- package/apps/ios/EnigmaIOS/Enigma/Assets.xcassets/LaunchBackground.colorset/Contents.json +12 -0
- package/apps/ios/EnigmaIOS/Enigma/ChatView.swift +181 -0
- package/apps/ios/EnigmaIOS/Enigma/CouncilView.swift +78 -0
- package/apps/ios/EnigmaIOS/Enigma/CreateView.swift +152 -0
- package/apps/ios/EnigmaIOS/Enigma/EnigmaApp.swift +52 -0
- package/apps/ios/EnigmaIOS/Enigma/Info.plist +52 -0
- package/apps/ios/EnigmaIOS/Enigma/NaturalLanguagePrivacyTagger.swift +26 -0
- package/apps/ios/EnigmaIOS/Enigma/OAuthClient.swift +321 -0
- package/apps/ios/EnigmaIOS/Enigma/OnboardingView.swift +105 -0
- package/apps/ios/EnigmaIOS/Enigma/PrivateVaultView.swift +275 -0
- package/apps/ios/EnigmaIOS/Enigma/SecureStore.swift +76 -0
- package/apps/ios/EnigmaIOS/Enigma/SettingsView.swift +60 -0
- package/apps/ios/EnigmaIOS/Enigma/Theme.swift +80 -0
- package/apps/ios/EnigmaIOS/EnigmaIOS.xcodeproj/project.pbxproj +211 -0
- package/apps/ios/EnigmaIOS/EnigmaIOS.xcodeproj/xcshareddata/xcschemes/Enigma.xcscheme +23 -0
- package/apps/native-host/README.md +19 -8
- package/apps/native-host/bin/enigma-native-host.mjs +229 -13
- package/apps/relay/bin/enigma-relay.mjs +103 -5
- package/apps/relay/src/federation-runtime.mjs +618 -0
- package/apps/relay/src/server.mjs +310 -9
- package/apps/verifier/bin/enigma-verify.mjs +327 -11
- package/cortex-v3/circuits/build/intent_vk_bytes.json +35 -0
- package/cortex-v3/circuits/build/sale_vk_bytes.json +35 -0
- package/cortex-v3/circuits/build/vk_bytes.json +32 -0
- package/cortex-v3/proving-assets.json +64 -0
- package/cortex-v3/zk/BUILD-CONTRACT.md +87 -0
- package/cortex-v3/zk/action-transition-vk.json +119 -0
- package/cortex-v3/zk/alias-adversarial.test.mjs +220 -0
- package/cortex-v3/zk/groth16-verify-child.mjs +17 -0
- package/cortex-v3/zk/intent-witness.mjs +365 -0
- package/cortex-v3/zk/intent-witness.test.mjs +485 -0
- package/cortex-v3/zk/proving-assets.mjs +203 -0
- package/cortex-v3/zk/sale-witness.mjs +783 -0
- package/cortex-v3/zk/sale-witness.test.mjs +784 -0
- package/cortex-v3/zk/sealed-sale-release-vk.json +119 -0
- package/cortex-v3/zk/settlement-evidence.mjs +722 -0
- package/cortex-v3/zk/setup-intent.mjs +688 -0
- package/cortex-v3/zk/setup-sale.mjs +666 -0
- package/cortex-v3/zk/setup.mjs +594 -0
- package/cortex-v3/zk/witness.mjs +184 -0
- package/cortex-v3/zk/zk-codec.mjs +232 -0
- package/cortex-v3/zk/zk-codec.test.mjs +293 -0
- package/cortex-v3/zk/zk-settle.mjs +370 -0
- package/cortex-v3/zk/zk-tree.mjs +256 -0
- package/cortex-v3/zk/zk-tree.test.mjs +419 -0
- package/deploy/docker-compose.local-production-simulation.yml +36 -0
- package/docs/browser-extension-install.md +8 -6
- package/docs/client-connectors.md +15 -11
- package/docs/developer-ecosystem.md +15 -13
- package/docs/enigma-memory-ready-conformance.md +11 -9
- package/docs/install-anywhere.md +61 -28
- package/docs/installers-and-desktop.md +8 -7
- package/docs/novelty-invention-candidates.md +161 -161
- package/docs/proof-network-claim-boundaries.md +320 -318
- package/examples/01-quickstart-agent/index.mjs +49 -0
- package/examples/01_agent_memory_quickstart.mjs +57 -0
- package/examples/02-multi-agent-swarm/index.mjs +57 -0
- package/examples/02_cross_model_passport.mjs +64 -0
- package/examples/03-langchain-memory/index.mjs +41 -0
- package/examples/03_poseidon_commitment_verification.mjs +71 -0
- package/examples/04-python-trading-agent/trader.py +49 -0
- package/examples/README.md +27 -0
- package/examples/ci/github-actions.yml +7 -2
- package/package.json +142 -11
- package/packages/adapters/PACKAGE_CONTRACT.md +1 -1
- package/packages/connectors/src/index.js +196 -4
- package/packages/connectors/swarm-router.mjs +168 -0
- package/packages/core/src/index.js +248 -1
- package/packages/core/src/version.mjs +7 -0
- package/packages/dev-tools/package.json +19 -0
- package/packages/dev-tools/src/index.js +4 -0
- package/packages/dev-tools/src/memory-benchmark-suite.js +112 -0
- package/packages/dev-tools/src/swarm-simulator.js +101 -0
- package/packages/dev-tools/src/vault-inspector.js +114 -0
- package/packages/dev-tools/src/vector-benchmark.js +100 -0
- package/packages/developer-platform/src/access-credentials.js +341 -0
- package/packages/developer-platform/src/http.js +132 -0
- package/packages/developer-platform/src/index.js +4 -0
- package/packages/developer-platform/src/usage-http.js +60 -0
- package/packages/developer-platform/src/usage.js +295 -0
- package/packages/enclave-runtime/attestation.mjs +159 -0
- package/packages/enclave-runtime/index.mjs +47 -0
- package/packages/enclave-runtime/session-manager.mjs +253 -0
- package/packages/enclave-runtime/zeroization-proof.mjs +227 -0
- package/packages/enigma-reflex/package.json +14 -0
- package/packages/enigma-reflex/src/index.js +204 -0
- package/packages/enigma-reflex/training/generate-dataset.mjs +40 -0
- package/packages/enigma-reflex/training/requirements.txt +8 -0
- package/packages/enigma-reflex/training/train.py +314 -0
- package/packages/enigma-weave/LICENSE +22 -0
- package/packages/enigma-weave/UPSTREAM.json +21 -0
- package/packages/enigma-weave/package.json +14 -0
- package/packages/enigma-weave/src/index.js +286 -0
- package/packages/hosted-cloud/src/index.js +80 -5
- package/packages/importers/src/index.js +432 -0
- package/packages/inference-runtime/src/browser.js +401 -0
- package/packages/inference-runtime/src/chat.js +265 -0
- package/packages/inference-runtime/src/code.js +407 -0
- package/packages/inference-runtime/src/contracts.js +162 -0
- package/packages/inference-runtime/src/http.js +232 -0
- package/packages/inference-runtime/src/image.js +186 -0
- package/packages/inference-runtime/src/index.js +10 -0
- package/packages/inference-runtime/src/model-router.js +320 -0
- package/packages/inference-runtime/src/platform.js +125 -0
- package/packages/inference-runtime/src/privacy.js +400 -0
- package/packages/inference-runtime/src/video.js +253 -0
- package/packages/mcp-server/README.md +22 -6
- package/packages/mcp-server/bin/enigma-mcp.mjs +2 -1
- package/packages/mcp-server/src/index.js +1418 -105
- package/packages/mcp-server/src/oauth.js +561 -0
- package/packages/mcp-server/src/private-handoff.js +84 -0
- package/packages/mcp-server/src/remote-http.js +273 -0
- package/packages/mcp-server/src/remote-policy.js +72 -0
- package/packages/mcp-server/swarm-bridge.mjs +361 -0
- package/packages/mesh/index.d.ts +283 -0
- package/packages/mesh/package.json +23 -0
- package/packages/mesh/src/crypto.js +189 -0
- package/packages/mesh/src/federation-packets.js +353 -0
- package/packages/mesh/src/gossip.js +311 -0
- package/packages/mesh/src/index.js +6 -0
- package/packages/mesh/src/protocol.js +255 -0
- package/packages/mesh/src/router.js +279 -0
- package/packages/mesh/src/transport.js +306 -0
- package/packages/passport/src/index.js +426 -1
- package/packages/private-economy/src/credits-http.js +100 -0
- package/packages/private-economy/src/credits.js +447 -0
- package/packages/private-economy/src/index.js +5 -0
- package/packages/private-economy/src/payments-http.js +120 -0
- package/packages/private-economy/src/payments.js +509 -0
- package/packages/private-economy/src/x402.js +346 -0
- package/packages/proof-network/PACKAGE_CONTRACT.md +21 -0
- package/packages/rag/index.d.ts +182 -0
- package/packages/rag/models/Xenova/all-MiniLM-L6-v2/THIRD_PARTY_LICENSES.txt +207 -0
- package/packages/rag/models/Xenova/all-MiniLM-L6-v2/config.json +25 -0
- package/packages/rag/models/Xenova/all-MiniLM-L6-v2/onnx/model_quantized.onnx +0 -0
- package/packages/rag/models/Xenova/all-MiniLM-L6-v2/sha256-manifest.json +28 -0
- package/packages/rag/models/Xenova/all-MiniLM-L6-v2/tokenizer.json +30686 -0
- package/packages/rag/models/Xenova/all-MiniLM-L6-v2/tokenizer_config.json +15 -0
- package/packages/rag/package.json +27 -0
- package/packages/rag/src/blinded-search.js +109 -0
- package/packages/rag/src/bm25.js +169 -0
- package/packages/rag/src/embeddings.js +459 -0
- package/packages/rag/src/hybrid.js +76 -0
- package/packages/rag/src/index.js +38 -0
- package/packages/rag/src/reranker.js +61 -0
- package/packages/rag/src/research.js +107 -0
- package/packages/rag/src/vector-store.js +430 -0
- package/packages/rag/src/verify-model-artifacts.mjs +4 -0
- package/packages/sdk/index.d.ts +760 -0
- package/packages/sdk/package.json +33 -0
- package/packages/sdk/python/README.md +24 -0
- package/packages/sdk/python/enigma_sdk.py +250 -0
- package/packages/sdk/python/pyproject.toml +34 -0
- package/packages/sdk/python/requirements.txt +1 -0
- package/packages/sdk/python/setup.py +20 -0
- package/packages/sdk/src/federation/capability-grant.js +389 -0
- package/packages/sdk/src/federation/federation-router.js +360 -0
- package/packages/sdk/src/federation/ghostmesh-bridge.js +497 -0
- package/packages/sdk/src/federation/index.js +3 -0
- package/packages/sdk/src/index.js +1796 -0
- package/packages/sdk/src/intelligence/contradiction.js +337 -0
- package/packages/sdk/src/intelligence/decision-engine.js +155 -0
- package/packages/sdk/src/intelligence/index.js +4 -0
- package/packages/sdk/src/intelligence/ontology.js +122 -0
- package/packages/sdk/src/intelligence/temporal.js +123 -0
- package/packages/sdk/src/market-client.js +142 -0
- package/packages/sdk/src/mesh-client.js +110 -0
- package/packages/sdk/src/middleware/index.js +3 -0
- package/packages/sdk/src/middleware/langchain.js +159 -0
- package/packages/sdk/src/middleware/llamaindex.js +101 -0
- package/packages/sdk/src/middleware/vercel-ai.js +112 -0
- package/packages/sdk/src/rag-client.js +85 -0
- package/packages/sdk/src/swarm-orchestrator.js +260 -0
- package/packages/settlement/PACKAGE_CONTRACT.md +1 -1
- package/packages/snapcompact/THIRD_PARTY_LICENSES.txt +40 -0
- package/packages/snapcompact/assets/8x13-latin1.bdf +3837 -0
- package/packages/snapcompact/index.d.ts +284 -0
- package/packages/snapcompact/package.json +25 -0
- package/packages/snapcompact/src/index.js +716 -0
- package/packages/storage/PACKAGE_CONTRACT.md +1 -1
- package/packages/terminal-console/animations.mjs +240 -0
- package/packages/terminal-console/auto-anchor.mjs +220 -0
- package/packages/terminal-console/banner.mjs +91 -0
- package/packages/terminal-console/commands.mjs +459 -0
- package/packages/terminal-console/delegation.mjs +152 -0
- package/packages/terminal-console/index.mjs +5 -0
- package/packages/terminal-console/outbox.mjs +143 -0
- package/packages/terminal-console/phantom-bridge.mjs +637 -0
- package/packages/terminal-console/repl.mjs +136 -0
- package/packages/terminal-console/signer-store.mjs +130 -0
- package/packages/terminal-console/solana-rpc.mjs +214 -0
- package/packages/terminal-console/solana-transport.mjs +189 -0
- package/packages/terminal-tui/dashboard.mjs +214 -0
- package/packages/terminal-tui/index.mjs +28 -0
- package/packages/terminal-tui/merkle-tree-renderer.mjs +268 -0
- package/packages/terminal-tui/telemetry-hud.mjs +137 -0
- package/packages/vault/index.d.ts +449 -0
- package/packages/vault/package.json +27 -0
- package/packages/vault/src/e2ee.mjs +393 -0
- package/packages/vault/src/enclave.js +481 -0
- package/packages/vault/src/erasure.js +207 -0
- package/packages/vault/src/index.js +1018 -155
- package/packages/vault/src/persistence.js +307 -0
- package/packages/vault/src/poseidon.js +354 -0
- package/packages/vault/src/receipt.js +459 -0
- package/scripts/benchmark-optical-context.mjs +166 -0
- package/scripts/bootstrap-enigma.mjs +502 -0
- package/scripts/build-edge-backend-workers.mjs +20 -5
- package/scripts/build-goal-completion-audit.mjs +72 -25
- package/scripts/build-hosted-api-key-lifecycle.mjs +26 -8
- package/scripts/build-hosted-customer-lifecycle.mjs +20 -3
- package/scripts/build-hosted-probe-worker.mjs +19 -4
- package/scripts/build-installer-assets.mjs +41 -21
- package/scripts/build-operator-evidence-starter.mjs +59 -1
- package/scripts/build-production-backend-env-kit.mjs +2 -0
- package/scripts/build-production-unblocker.mjs +3 -0
- package/scripts/check.mjs +17 -3
- package/scripts/collect-hosted-backend-live-evidence.mjs +49 -12
- package/scripts/install-enigma-local.mjs +18 -5
- package/scripts/release-audit.mjs +65 -109
- package/scripts/release-provenance.mjs +6 -0
- package/scripts/run-backend-readiness-smoke.mjs +112 -10
- package/scripts/scan-secrets.mjs +1 -0
- package/scripts/simulate-production-env.mjs +7 -2
- package/scripts/validate-hosted-backend-live.mjs +112 -1
- package/specs/antibody-pack-v1.schema.json +95 -0
- package/specs/antigen-envelope-v1.schema.json +81 -0
- package/specs/boundary-manifest-v1.schema.json +35 -35
- package/specs/capsule-v1.schema.json +55 -55
- package/specs/claim-boundary-manifest-v1.schema.json +22 -22
- package/specs/claim-ledger-v1.schema.json +291 -0
- package/specs/context-passport-v1.schema.json +59 -0
- package/specs/deletion-tombstone-v1.schema.json +26 -26
- package/specs/evidence-packet-v1.schema.json +177 -0
- package/specs/hosted-backend-live-evidence-v1.schema.json +72 -3
- package/specs/immune-scan-report-v1.schema.json +112 -0
- package/specs/lifecycle-receipt-log-v1.schema.json +67 -0
- package/specs/memory-atom-v1.schema.json +59 -0
- package/specs/memory-event-v1.schema.json +42 -42
- package/specs/passport-v1.schema.json +50 -50
- package/specs/proof-of-non-use-v1.schema.json +65 -0
- package/specs/quarantine-record-v1.schema.json +126 -0
- package/specs/receipt-v1.schema.json +61 -61
- package/specs/state-checkpoint-v1.schema.json +37 -37
- package/specs/trust-bundle-v1.schema.json +56 -56
- package/specs/trust-card-v1.schema.json +119 -0
- package/docs/proof-network-launch-plan.md +0 -421
- package/packages/metering/PACKAGE_CONTRACT.md +0 -20
- package/scripts/build-ai-orchestration-plan.mjs +0 -248
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Production storage contract
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`enigma-memory/storage` defines the production storage schema contract for relay/gateway deployments. It is pure local code: no sockets, no provider SDKs, no environment loading, and no secret handling.
|
|
4
4
|
|
|
5
5
|
## Purpose
|
|
6
6
|
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { ANSI } from '../terminal-tui/merkle-tree-renderer.mjs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { OFFICIAL_TOKEN_CA } from './banner.mjs';
|
|
5
|
+
import { fetchSolanaStreamMetrics } from './solana-rpc.mjs';
|
|
6
|
+
|
|
7
|
+
function sleep(ms) {
|
|
8
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function isInteractiveTty(io) {
|
|
12
|
+
return Boolean(io.stdout?.isTTY);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function runConstellationAnimation(io, { frames = 15, color = true, shouldStop = undefined } = {}) {
|
|
16
|
+
const c = (text, code) => (color ? `${code}${text}${ANSI.reset}` : text);
|
|
17
|
+
|
|
18
|
+
const starFields = [
|
|
19
|
+
[
|
|
20
|
+
' * · + . * · +',
|
|
21
|
+
' · [NODE: alpha]-----------[NODE: beta] .',
|
|
22
|
+
' + . | / ·',
|
|
23
|
+
' * | [TOPOLOGY MESH] * +',
|
|
24
|
+
' · | \\ . ',
|
|
25
|
+
' . [NODE: gamma]-----------[NODE: delta] ·',
|
|
26
|
+
' + * · + . * +',
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
' . * · + . * ·',
|
|
30
|
+
' + [NODE: alpha]=====*=====[NODE: beta] *',
|
|
31
|
+
' · * | \\ +',
|
|
32
|
+
' . | [TOPOLOGY MESH] · .',
|
|
33
|
+
' + | / * ',
|
|
34
|
+
' * [NODE: gamma]=====*=====[NODE: delta] +',
|
|
35
|
+
' · . * · + . ·',
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
' + · * . + · *',
|
|
39
|
+
' · [NODE: alpha]-----*-----[NODE: beta] +',
|
|
40
|
+
' * . | / ·',
|
|
41
|
+
' + * [TOPOLOGY MESH] + *',
|
|
42
|
+
' · | \\ . ',
|
|
43
|
+
' . [NODE: gamma]-----*-----[NODE: delta] ·',
|
|
44
|
+
' * + · * . + ·',
|
|
45
|
+
],
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
io.stdout.write(c('\n CONSTELLATION MESH VISUALIZER (DECORATIVE TOPOLOGY DISPLAY)\n\n', `${ANSI.bold}${ANSI.amber}`));
|
|
49
|
+
|
|
50
|
+
function renderFrameLines(frame) {
|
|
51
|
+
return frame.map((line) => line
|
|
52
|
+
.replace(/\[NODE: [^\]]+\]/g, (match) => c(match, `${ANSI.bold}${ANSI.cyan}`))
|
|
53
|
+
.replace(/\[TOPOLOGY MESH\]/g, (match) => c(match, `${ANSI.bold}${ANSI.amber}`))
|
|
54
|
+
.replace(/====\*====/g, (match) => c(match, ANSI.amberGlow))
|
|
55
|
+
.replace(/----\*----/g, (match) => c(match, ANSI.green))
|
|
56
|
+
.replace(/[*+·.]/g, (match) => c(match, ANSI.dimText))
|
|
57
|
+
).join('\n') + '\n';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!isInteractiveTty(io) || !color) {
|
|
61
|
+
// Non-interactive or piped mode: print single static frame without cursor movement
|
|
62
|
+
io.stdout.write(renderFrameLines(starFields[0]));
|
|
63
|
+
io.stdout.write(c(' [END CONSTELLATION DISPLAY]\n\n', ANSI.dim));
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Interactive TTY mode with cursor-controlled animation
|
|
68
|
+
for (let i = 0; i < frames; i++) {
|
|
69
|
+
if (shouldStop && shouldStop()) break;
|
|
70
|
+
if (i > 0) {
|
|
71
|
+
io.stdout.write('\x1b[7A\r'); // Move cursor up 7 lines only after initial frame is printed
|
|
72
|
+
}
|
|
73
|
+
const frame = starFields[i % starFields.length];
|
|
74
|
+
io.stdout.write(renderFrameLines(frame));
|
|
75
|
+
await sleep(90);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
io.stdout.write(c(' [END CONSTELLATION DISPLAY]\n\n', ANSI.dim));
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export async function runMatrixStream(io, { lines = 12, color = true, shouldStop = undefined } = {}) {
|
|
83
|
+
const c = (text, code) => (color ? `${code}${text}${ANSI.reset}` : text);
|
|
84
|
+
|
|
85
|
+
io.stdout.write(c('\n HEXADECIMAL TELEMETRY RAIN (DECORATIVE STREAM)\n', `${ANSI.bold}${ANSI.amber}`));
|
|
86
|
+
|
|
87
|
+
const hexChars = '0123456789abcdef';
|
|
88
|
+
const count = (!isInteractiveTty(io) || !color) ? 4 : lines;
|
|
89
|
+
|
|
90
|
+
for (let i = 0; i < count; i++) {
|
|
91
|
+
if (shouldStop && shouldStop()) break;
|
|
92
|
+
let row = ' ';
|
|
93
|
+
for (let j = 0; j < 56; j++) {
|
|
94
|
+
const char = hexChars[Math.floor(Math.random() * hexChars.length)];
|
|
95
|
+
if (j % 8 === 0) row += ' ';
|
|
96
|
+
row += j % 4 === 0 ? c(char, ANSI.amber) : c(char, ANSI.dimText);
|
|
97
|
+
}
|
|
98
|
+
io.stdout.write(row + '\n');
|
|
99
|
+
if (isInteractiveTty(io) && color) {
|
|
100
|
+
await sleep(35);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
io.stdout.write(c(' [STREAM COMPLETE]\n\n', ANSI.dim));
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function resolveVaultRoot(bundlePath) {
|
|
109
|
+
if (!bundlePath) return 'N/A';
|
|
110
|
+
try {
|
|
111
|
+
const raw = JSON.parse(await readFile(resolve(bundlePath), 'utf8'));
|
|
112
|
+
const root = raw.vault?.active_set_root
|
|
113
|
+
|| raw.vault?.set_root
|
|
114
|
+
|| raw.active_set_root
|
|
115
|
+
|| raw.state_root
|
|
116
|
+
|| raw.merkle_root
|
|
117
|
+
|| raw.passport?.active_set_root;
|
|
118
|
+
if (typeof root === 'string' && root.startsWith('sha256:')) return root;
|
|
119
|
+
return 'N/A';
|
|
120
|
+
} catch {
|
|
121
|
+
return 'N/A';
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function runSolanaHeartbeatStream(io, {
|
|
126
|
+
cluster = 'mainnet-beta',
|
|
127
|
+
rpcUrl = undefined,
|
|
128
|
+
samples = undefined,
|
|
129
|
+
intervalMs = 350,
|
|
130
|
+
fetchFn = globalThis.fetch,
|
|
131
|
+
color = true,
|
|
132
|
+
bundlePath = undefined,
|
|
133
|
+
shouldStop = undefined,
|
|
134
|
+
} = {}) {
|
|
135
|
+
const c = (text, code) => (color ? `${code}${text}${ANSI.reset}` : text);
|
|
136
|
+
|
|
137
|
+
const resolvedRoot = await resolveVaultRoot(bundlePath);
|
|
138
|
+
|
|
139
|
+
io.stdout.write('\n' + c(' ╔═══════════════════════════════════════════════════════════════════════════╗', ANSI.amber) + '\n');
|
|
140
|
+
io.stdout.write(c(' ║ ENIGMA ⚡ SOLANA LIVE BLOCKCHAIN HEARTBEAT & PROOF STREAM ║', `${ANSI.bold}${ANSI.amber}`) + '\n');
|
|
141
|
+
io.stdout.write(c(' ╚═══════════════════════════════════════════════════════════════════════════╝', ANSI.amber) + '\n\n');
|
|
142
|
+
|
|
143
|
+
let sampleCount = 0;
|
|
144
|
+
let lastSlot = null;
|
|
145
|
+
let lastTxCount = null;
|
|
146
|
+
let hasPrintedHeader = false;
|
|
147
|
+
let latestOk = true;
|
|
148
|
+
const interactive = isInteractiveTty(io) && color;
|
|
149
|
+
const isCancellable = typeof shouldStop === 'function';
|
|
150
|
+
const maxSamples = (typeof samples === 'number' && samples > 0) || samples === Infinity
|
|
151
|
+
? samples
|
|
152
|
+
: ((isCancellable || interactive) ? Infinity : 3);
|
|
153
|
+
while (sampleCount < maxSamples) {
|
|
154
|
+
if (shouldStop && shouldStop()) break;
|
|
155
|
+
|
|
156
|
+
const metrics = await fetchSolanaStreamMetrics({ cluster, rpcUrl, fetchFn });
|
|
157
|
+
latestOk = metrics.ok === true;
|
|
158
|
+
|
|
159
|
+
const epochPct = (metrics.slot_index !== null && metrics.slots_in_epoch)
|
|
160
|
+
? ((metrics.slot_index / metrics.slots_in_epoch) * 100).toFixed(1)
|
|
161
|
+
: null;
|
|
162
|
+
const epochBar = epochPct !== null
|
|
163
|
+
? `[${'█'.repeat(Math.min(24, Math.max(0, Math.round((Number(epochPct) / 100) * 24))))}${'░'.repeat(24 - Math.min(24, Math.max(0, Math.round((Number(epochPct) / 100) * 24))))}] ${epochPct}%`
|
|
164
|
+
: 'N/A';
|
|
165
|
+
|
|
166
|
+
if (!hasPrintedHeader) {
|
|
167
|
+
const statusBadge = metrics.ok
|
|
168
|
+
? `${c('● CONNECTED', `${ANSI.bold}${ANSI.green}`)} (${metrics.latency_ms}ms)`
|
|
169
|
+
: `${c('○ UNREACHABLE', `${ANSI.bold}${ANSI.yellow}`)} (${metrics.error || 'no response'})`;
|
|
170
|
+
|
|
171
|
+
io.stdout.write(` ${c('Cluster:', ANSI.dimText)} ${metrics.cluster} (${metrics.rpc_url})\n`);
|
|
172
|
+
io.stdout.write(` ${c('Solana Core:', ANSI.dimText)} ${metrics.solana_core_version || 'N/A'}\n`);
|
|
173
|
+
io.stdout.write(` ${c('RPC Status:', ANSI.dimText)} ${statusBadge}\n`);
|
|
174
|
+
io.stdout.write(` ${c('Token Mint CA:', ANSI.dimText)} ${c(OFFICIAL_TOKEN_CA, `${ANSI.bold}${ANSI.white}`)}\n`);
|
|
175
|
+
io.stdout.write(` ${c('Active SMT Root:', ANSI.dimText)} ${c(resolvedRoot, ANSI.cyan)}\n`);
|
|
176
|
+
io.stdout.write(` ${c('Epoch Progress:', ANSI.dimText)} ${c(epochBar, ANSI.amberGlow)}\n\n`);
|
|
177
|
+
hasPrintedHeader = true;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Build the horizontal pulse beam wave
|
|
181
|
+
const wave = '♥───^v';
|
|
182
|
+
const beamWidth = 32;
|
|
183
|
+
const pos = (sampleCount * 2) % (beamWidth - wave.length);
|
|
184
|
+
const coloredBeam = `[${c('─'.repeat(pos), ANSI.dimText)}${c('♥', `${ANSI.bold}${ANSI.amberGlow}`)}${c('───^v', ANSI.green)}${c('─'.repeat(beamWidth - pos - wave.length), ANSI.dimText)}]`;
|
|
185
|
+
|
|
186
|
+
if (metrics.ok) {
|
|
187
|
+
const slotText = metrics.slot !== null ? String(metrics.slot) : 'N/A';
|
|
188
|
+
let deltaSlotText = '';
|
|
189
|
+
if (metrics.slot !== null && lastSlot !== null) {
|
|
190
|
+
const delta = metrics.slot - lastSlot;
|
|
191
|
+
deltaSlotText = ` (${c(delta >= 0 ? `+${delta}` : String(delta), ANSI.amberGlow)} slots)`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
let txText = 'N/A';
|
|
195
|
+
if (metrics.transaction_count !== null) {
|
|
196
|
+
txText = metrics.transaction_count.toLocaleString();
|
|
197
|
+
if (lastTxCount !== null) {
|
|
198
|
+
const txDelta = metrics.transaction_count - lastTxCount;
|
|
199
|
+
if (txDelta > 0) txText += ` (+${txDelta.toLocaleString()})`;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const line = ` ${c('Live Pulse Bar:', ANSI.dimText)} ${coloredBeam} slot ${c(slotText, ANSI.bold)}${deltaSlotText} • tx_count ${txText} • rpc ${metrics.latency_ms}ms`;
|
|
204
|
+
|
|
205
|
+
if (interactive && sampleCount > 0) {
|
|
206
|
+
io.stdout.write(`\r\x1b[2K${line}`);
|
|
207
|
+
} else {
|
|
208
|
+
io.stdout.write(line + (interactive ? '' : '\n'));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
lastSlot = metrics.slot;
|
|
212
|
+
lastTxCount = metrics.transaction_count;
|
|
213
|
+
} else {
|
|
214
|
+
const errLine = ` ${c('Live Pulse Bar:', ANSI.dimText)} [${c('DISCONNECTED', ANSI.red)}] ${metrics.error || 'Connection failed'} (${metrics.latency_ms}ms)`;
|
|
215
|
+
if (interactive && sampleCount > 0) {
|
|
216
|
+
io.stdout.write(`\r\x1b[2K${errLine}`);
|
|
217
|
+
} else {
|
|
218
|
+
io.stdout.write(errLine + (interactive ? '' : '\n'));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
sampleCount += 1;
|
|
223
|
+
|
|
224
|
+
if (sampleCount < maxSamples) {
|
|
225
|
+
await sleep(intervalMs);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (interactive) {
|
|
230
|
+
io.stdout.write('\n');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (Number.isFinite(maxSamples)) {
|
|
234
|
+
io.stdout.write('\n' + c(` [STREAM COMPLETE • ${sampleCount} sample${sampleCount === 1 ? '' : 's'} recorded]`, ANSI.dim) + '\n\n');
|
|
235
|
+
} else {
|
|
236
|
+
io.stdout.write('\n' + c(' [STREAM STOPPED]', ANSI.dim) + '\n\n');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return latestOk ? 0 : 1;
|
|
240
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// Enigma Sovereign AI Memory — Autonomous Solana Auto-Anchor Engine
|
|
2
|
+
// Orchestrates SignerStore, AutoAnchorOutbox, and SolanaTransport with strict policy guardrails.
|
|
3
|
+
|
|
4
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
5
|
+
import { resolve, join } from 'node:path';
|
|
6
|
+
import { SignerStore } from './signer-store.mjs';
|
|
7
|
+
import { AutoAnchorOutbox } from './outbox.mjs';
|
|
8
|
+
import { SolanaTransport, SOLANA_MEMO_PROGRAM_ID, MAX_AUTO_ANCHOR_FEE_LAMPORTS } from './solana-transport.mjs';
|
|
9
|
+
import {
|
|
10
|
+
buildDelegationChallenge,
|
|
11
|
+
createDelegationArtifact,
|
|
12
|
+
verifyDelegationArtifact,
|
|
13
|
+
computeAuthorizationHash,
|
|
14
|
+
DEFAULT_DELEGATION_EXPIRY_DAYS,
|
|
15
|
+
} from './delegation.mjs';
|
|
16
|
+
|
|
17
|
+
export { SignerStore } from './signer-store.mjs';
|
|
18
|
+
export { AutoAnchorOutbox } from './outbox.mjs';
|
|
19
|
+
export { SolanaTransport, SOLANA_MEMO_PROGRAM_ID, MAX_AUTO_ANCHOR_FEE_LAMPORTS } from './solana-transport.mjs';
|
|
20
|
+
export {
|
|
21
|
+
buildDelegationChallenge,
|
|
22
|
+
createDelegationArtifact,
|
|
23
|
+
verifyDelegationArtifact,
|
|
24
|
+
computeAuthorizationHash,
|
|
25
|
+
} from './delegation.mjs';
|
|
26
|
+
|
|
27
|
+
export const MAX_DAILY_TRANSACTIONS = 50;
|
|
28
|
+
|
|
29
|
+
export class AutoAnchorEngine {
|
|
30
|
+
constructor({
|
|
31
|
+
rootDir = '.enigma/auto-anchor',
|
|
32
|
+
cluster = 'mainnet-beta',
|
|
33
|
+
rpcUrl = undefined,
|
|
34
|
+
signerStore = undefined,
|
|
35
|
+
transport = undefined,
|
|
36
|
+
maxDailyTx = MAX_DAILY_TRANSACTIONS,
|
|
37
|
+
} = {}) {
|
|
38
|
+
this.rootDir = resolve(rootDir);
|
|
39
|
+
this.cluster = cluster;
|
|
40
|
+
this.signerStore = signerStore || new SignerStore({ signerPath: join(this.rootDir, 'signer.enc.json') });
|
|
41
|
+
this.transport = transport || new SolanaTransport({ rpcUrl, cluster });
|
|
42
|
+
this.delegationPath = join(this.rootDir, 'delegation.json');
|
|
43
|
+
this.outboxPath = join(this.rootDir, 'outbox.json');
|
|
44
|
+
this.outbox = new AutoAnchorOutbox(this.outboxPath);
|
|
45
|
+
this.maxDailyTx = maxDailyTx;
|
|
46
|
+
this.active = false;
|
|
47
|
+
this.timer = null;
|
|
48
|
+
this.isProcessing = false;
|
|
49
|
+
}
|
|
50
|
+
isConfigured() {
|
|
51
|
+
return this.signerStore.hasSigner() && existsSync(this.delegationPath);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
setupSigner() {
|
|
55
|
+
if (!existsSync(this.rootDir)) mkdirSync(this.rootDir, { recursive: true });
|
|
56
|
+
const { publicKeyBase58, secretKeyBuffer } = this.signerStore.generateKeypair();
|
|
57
|
+
this.signerStore.saveSignerSecretKey(secretKeyBuffer, { publicKeyBase58 });
|
|
58
|
+
return { publicKeyBase58 };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
getDelegationChallenge({ ownerPubkey }) {
|
|
62
|
+
const signerPubkey = this.signerStore.getPublicKey();
|
|
63
|
+
if (!signerPubkey) throw new Error('Automation signer must be initialized first');
|
|
64
|
+
const issuedAt = new Date().toISOString();
|
|
65
|
+
const expiresAt = new Date(Date.now() + DEFAULT_DELEGATION_EXPIRY_DAYS * 24 * 60 * 60 * 1000).toISOString();
|
|
66
|
+
const descriptor = {
|
|
67
|
+
schema: 'enigma.delegated_signer_authorization.v1',
|
|
68
|
+
owner_pubkey: ownerPubkey,
|
|
69
|
+
signer_pubkey: signerPubkey,
|
|
70
|
+
cluster: this.cluster,
|
|
71
|
+
policy: 'spl-memo-proof-anchoring-only',
|
|
72
|
+
max_fee_lamports: MAX_AUTO_ANCHOR_FEE_LAMPORTS,
|
|
73
|
+
issued_at: issuedAt,
|
|
74
|
+
expires_at: expiresAt,
|
|
75
|
+
};
|
|
76
|
+
const authorizationHash = computeAuthorizationHash(descriptor);
|
|
77
|
+
const challenge = buildDelegationChallenge({ ...descriptor, authorization_hash: authorizationHash });
|
|
78
|
+
return {
|
|
79
|
+
challenge,
|
|
80
|
+
descriptor: { ...descriptor, authorization_hash: authorizationHash },
|
|
81
|
+
signerPubkey,
|
|
82
|
+
ownerPubkey,
|
|
83
|
+
cluster: this.cluster,
|
|
84
|
+
issuedAt,
|
|
85
|
+
expiresAt,
|
|
86
|
+
authorizationHash,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
getDelegation() {
|
|
90
|
+
try {
|
|
91
|
+
const data = JSON.parse(readFileSync(this.delegationPath, 'utf8'));
|
|
92
|
+
const verification = verifyDelegationArtifact(data, { expectedCluster: this.cluster });
|
|
93
|
+
return verification.ok ? data : null;
|
|
94
|
+
} catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
setDelegation(delegationArtifact) {
|
|
100
|
+
const verified = verifyDelegationArtifact(delegationArtifact, { expectedCluster: this.cluster });
|
|
101
|
+
if (!verified.ok) throw new Error(`Invalid delegation authorization: ${verified.error}`);
|
|
102
|
+
if (!existsSync(this.rootDir)) mkdirSync(this.rootDir, { recursive: true });
|
|
103
|
+
writeFileSync(this.delegationPath, JSON.stringify(delegationArtifact, null, 2), 'utf8');
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
get24HourTxCount() {
|
|
108
|
+
const oneDayAgo = Date.now() - 24 * 60 * 60 * 1000;
|
|
109
|
+
return this.outbox.history.filter((item) => new Date(item.confirmedAt).getTime() >= oneDayAgo).length;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async processNextOutboxItem({ force = false } = {}) {
|
|
113
|
+
if (this.isProcessing) return { ok: false, skipped: true, reason: 'Processing already in progress' };
|
|
114
|
+
if (!this.active && !force) return { ok: false, skipped: true, reason: 'Auto-anchor engine is inactive' };
|
|
115
|
+
const item = this.outbox.peek();
|
|
116
|
+
if (!item) return { ok: true, skipped: true, reason: 'Outbox queue is empty' };
|
|
117
|
+
// Rate limiting: daily velocity cap
|
|
118
|
+
const dailyCount = this.get24HourTxCount();
|
|
119
|
+
if (dailyCount >= this.maxDailyTx) {
|
|
120
|
+
this.outbox.markFailed(item.id, `Daily transaction velocity limit reached (${dailyCount}/${this.maxDailyTx})`);
|
|
121
|
+
return { ok: false, error: 'DAILY_VELOCITY_LIMIT_REACHED' };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this.isProcessing = true;
|
|
125
|
+
this.outbox.markProcessing(item.id);
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
const pubkey = this.signerStore.getPublicKey();
|
|
129
|
+
if (!pubkey) throw new Error('Signer public key not configured');
|
|
130
|
+
|
|
131
|
+
const { lamports } = await this.transport.getBalance(pubkey);
|
|
132
|
+
if (lamports < MAX_AUTO_ANCHOR_FEE_LAMPORTS) {
|
|
133
|
+
this.outbox.markFailed(item.id, `Insufficient signer funds: ${lamports} lamports available (minimum ${MAX_AUTO_ANCHOR_FEE_LAMPORTS} required)`);
|
|
134
|
+
return { ok: false, error: 'INSUFFICIENT_FUNDS', lamports };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const delegation = this.getDelegation();
|
|
138
|
+
if (!delegation) {
|
|
139
|
+
throw new Error('Valid owner delegation authorization required before broadcasting on-chain');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Check delegation binds this exact automation signer public key
|
|
143
|
+
if (delegation.signer_pubkey !== pubkey) {
|
|
144
|
+
throw new Error(`Delegation signer public key mismatch: authorized for ${delegation.signer_pubkey}, but active signer is ${pubkey}`);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Check authorization hash if enqueued item specified one
|
|
148
|
+
if (item.authorizationHash && delegation.authorization_hash !== item.authorizationHash) {
|
|
149
|
+
throw new Error(`Authorization hash mismatch: queued for ${item.authorizationHash}, active is ${delegation.authorization_hash}`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Check delegation expiry
|
|
153
|
+
if (new Date(delegation.expires_at).getTime() < Date.now()) {
|
|
154
|
+
throw new Error('Delegation authorization has expired');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const secretKey = this.signerStore.loadSignerSecretKey();
|
|
158
|
+
const memoRef = {
|
|
159
|
+
v: 1,
|
|
160
|
+
protocol: 'enigma-proof-network',
|
|
161
|
+
rail: 'solana-memo',
|
|
162
|
+
cluster: this.cluster,
|
|
163
|
+
owner: delegation.owner_pubkey,
|
|
164
|
+
auth_hash: delegation.authorization_hash,
|
|
165
|
+
active_set_root: item.activeSetRoot,
|
|
166
|
+
receipt_log_root: item.receiptLogRoot,
|
|
167
|
+
sequence: item.sequence || 0,
|
|
168
|
+
timestamp: item.createdAt,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const result = await this.transport.broadcastMemo({
|
|
172
|
+
payerSecretKey: secretKey,
|
|
173
|
+
memoRef,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const confirmed = this.outbox.markAnchored(item.id, {
|
|
177
|
+
signature: result.signature,
|
|
178
|
+
slot: result.slot,
|
|
179
|
+
cluster: this.cluster,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
return { ok: true, item: confirmed, result };
|
|
183
|
+
} catch (err) {
|
|
184
|
+
this.outbox.markFailed(item.id, err.message);
|
|
185
|
+
return { ok: false, error: err.message };
|
|
186
|
+
} finally {
|
|
187
|
+
this.isProcessing = false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
start(intervalMs = 3000) {
|
|
192
|
+
this.active = true;
|
|
193
|
+
if (!this.timer) {
|
|
194
|
+
this.timer = setInterval(() => {
|
|
195
|
+
this.processNextOutboxItem().catch(() => {});
|
|
196
|
+
}, intervalMs);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
stop() {
|
|
201
|
+
this.active = false;
|
|
202
|
+
if (this.timer) {
|
|
203
|
+
clearInterval(this.timer);
|
|
204
|
+
this.timer = null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
getStatus() {
|
|
209
|
+
return {
|
|
210
|
+
configured: this.isConfigured(),
|
|
211
|
+
active: this.active,
|
|
212
|
+
signerPublicKey: this.signerStore.getPublicKey(),
|
|
213
|
+
delegation: this.getDelegation(),
|
|
214
|
+
pendingOutboxCount: this.outbox.queue.length,
|
|
215
|
+
historicalAnchorCount: this.outbox.history.length,
|
|
216
|
+
dailyTxCount: this.get24HourTxCount(),
|
|
217
|
+
maxDailyTx: this.maxDailyTx,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ANSI } from '../terminal-tui/merkle-tree-renderer.mjs';
|
|
2
|
+
import { ENIGMA_VERSION } from '../core/src/version.mjs';
|
|
3
|
+
|
|
4
|
+
export const OFFICIAL_TOKEN_CA = 'EknDj8VZUHL6FhV9pSk3m6xP2U2sDzwjRDVstKeQpump';
|
|
5
|
+
|
|
6
|
+
export function renderTerminalBanner({ color = true } = {}) {
|
|
7
|
+
const c = (text, code) => (color ? `${code}${text}${ANSI.reset}` : text);
|
|
8
|
+
|
|
9
|
+
const lines = [
|
|
10
|
+
c(' ███████╗███╗ ██╗██╗ ██████╗ ███╗ ███╗ █████╗ ', `${ANSI.bold}${ANSI.amber}`),
|
|
11
|
+
c(' ██╔════╝████╗ ██║██║██╔════╝ ████╗ ████║██╔══██╗', `${ANSI.bold}${ANSI.amber}`),
|
|
12
|
+
c(' █████╗ ██╔██╗ ██║██║██║ ███╗██╔████╔██║███████║', `${ANSI.bold}${ANSI.amberGlow}`),
|
|
13
|
+
c(' ██╔══╝ ██║╚██╗██║██║██║ ██║██║╚██╔╝██║██╔══██║', `${ANSI.bold}${ANSI.amberGlow}`),
|
|
14
|
+
c(' ███████╗██║ ╚████║██║╚██████╔╝██║ ╚═╝ ██║██║ ██║', `${ANSI.bold}${ANSI.amber}`),
|
|
15
|
+
c(' ╚══════╝╚═╝ ╚═══╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝', `${ANSI.bold}${ANSI.amber}`),
|
|
16
|
+
'',
|
|
17
|
+
` ${c('ENIGMA SOVEREIGN AI MEMORY TERMINAL', `${ANSI.bold}${ANSI.white}`)} ${c(`v${ENIGMA_VERSION}`, ANSI.gray)}`,
|
|
18
|
+
` ${c('Decentralized Context Layer for Autonomous AI on Solana', ANSI.dimText)}`,
|
|
19
|
+
` ${c('● LIVE TOKEN CA:', `${ANSI.bold}${ANSI.amber}`)} ${c(OFFICIAL_TOKEN_CA, `${ANSI.bold}${ANSI.white}`)}`,
|
|
20
|
+
` ${c('Security Mode:', ANSI.gray)} ${c('Local Standalone', ANSI.green)} | ${c('Developer Default: Plaintext Keyring (Set ENIGMA_PASSPHRASE for AES-GCM Encryption)', ANSI.dim)}`,
|
|
21
|
+
'',
|
|
22
|
+
c(' Type "help" or "?" to list commands, "constellation" or "matrix" for animations.', ANSI.gray),
|
|
23
|
+
c(' ----------------------------------------------------------------------------------', ANSI.dim),
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
return lines.join('\n');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function renderHelpCatalog({ color = true } = {}) {
|
|
30
|
+
const c = (text, code) => (color ? `${code}${text}${ANSI.reset}` : text);
|
|
31
|
+
|
|
32
|
+
const sections = [
|
|
33
|
+
` ${c('CORE MEMORY COMMANDS', `${ANSI.bold}${ANSI.amber}`)}`,
|
|
34
|
+
` ${c('quickstart', ANSI.cyan)} [--overwrite] Initialize a new sovereign memory vault bundle`,
|
|
35
|
+
` ${c('remember', ANSI.cyan)} <text> [--purpose <p>] Ingest an encrypted memory atom with signed receipt`,
|
|
36
|
+
` ${c('context', ANSI.cyan)} <query> [--out <path>] Query purpose-scoped context pack`,
|
|
37
|
+
` ${c('doctor', ANSI.cyan)} Verify local runtime, keyring, and connector health`,
|
|
38
|
+
'',
|
|
39
|
+
` ${c('VISUALIZATION & TELEMETRY', `${ANSI.bold}${ANSI.amber}`)}`,
|
|
40
|
+
` ${c('tree', ANSI.cyan)} [--depth <n>] Render live ASCII Merkle tree with proof verification path`,
|
|
41
|
+
` ${c('tui', ANSI.cyan)} | ${c('dashboard', ANSI.cyan)} Open full-screen terminal control plane dashboard`,
|
|
42
|
+
` ${c('monitor', ANSI.cyan)} [--interval <ms>] Stream real-time vault telemetry and MCP events`,
|
|
43
|
+
` ${c('constellation', ANSI.cyan)} Run animated multi-node context mesh visualization`,
|
|
44
|
+
` ${c('matrix', ANSI.cyan)} Stream animated cryptographic hash rain`,
|
|
45
|
+
'',
|
|
46
|
+
` ${c('ENTERPRISE SECURITY & SWARM', `${ANSI.bold}${ANSI.amber}`)}`,
|
|
47
|
+
` ${c('enclave cycle', ANSI.cyan)} Execute atomic key zeroization with signed receipt`,
|
|
48
|
+
` ${c('enclave attest', ANSI.cyan)} Generate simulated PCR attestation measurement`,
|
|
49
|
+
` ${c('enclave verify', ANSI.cyan)} <receipt_path> Verify enclave zeroization receipt offline`,
|
|
50
|
+
` ${c('swarm status', ANSI.cyan)} Inspect multi-agent namespace fencing and metadata`,
|
|
51
|
+
` ${c('swarm graph', ANSI.cyan)} View memory entity and associative relation graph`,
|
|
52
|
+
'',
|
|
53
|
+
` ${c('SOLANA & DECENTRALIZED PROOFS', `${ANSI.bold}${ANSI.amber}`)}`,
|
|
54
|
+
` ${c('solana status', ANSI.cyan)} Probe Solana RPC health without exposing memory plaintext`,
|
|
55
|
+
` ${c('solana stream', ANSI.cyan)} | ${c('pulse', ANSI.cyan)} Stream live Solana blockchain heartbeat & block metrics`,
|
|
56
|
+
` ${c('solana anchor-bundle', ANSI.cyan)} --out <file> Build public-safe bundle root anchor batch for Solana Memo`,
|
|
57
|
+
` ${c('solana submit', ANSI.cyan)} --file <file> Dry-run or execute SPL Memo proof anchoring`,
|
|
58
|
+
` ${c('solana verify-anchor', ANSI.cyan)} --sig <tx> --file <file> Verify on-chain SPL Memo proof commitment against local artifact`,
|
|
59
|
+
` ${c('wallet connect', ANSI.cyan)} Connect Phantom browser wallet via authenticated companion`,
|
|
60
|
+
` ${c('wallet status', ANSI.cyan)} Inspect active connected wallet and balance`,
|
|
61
|
+
` ${c('wallet disconnect', ANSI.cyan)} Disconnect active wallet session`,
|
|
62
|
+
` ${c('token', ANSI.cyan)} | ${c('ca', ANSI.cyan)} Display official Solana token CA and launch coordinates`,
|
|
63
|
+
` ${c('export', ANSI.cyan)} [--out <path>] Export self-contained cryptographic proof bundle`,
|
|
64
|
+
` ${c('verify', ANSI.cyan)} [--export <path>] Perform 100% offline verification across all receipts`,
|
|
65
|
+
'',
|
|
66
|
+
` ${c('ZKCP MARKETPLACE // CLIENT-PROVEN FAIR EXCHANGE', `${ANSI.bold}${ANSI.amber}`)}`,
|
|
67
|
+
` ${c('market status', ANSI.cyan)} Inspect local marketplace configuration, circuit parameters, and custody state`,
|
|
68
|
+
` ${c('market list', ANSI.cyan)} List local saleable memory listings from ZK state`,
|
|
69
|
+
` ${c('market verify', ANSI.cyan)} --listing <file> Verify delivered ciphertext fold against 32-chunk Poseidon commitments`,
|
|
70
|
+
` ${c('market demo', ANSI.cyan)} Run simulated ZKCP fair-exchange fixture demo`,
|
|
71
|
+
` ${c('GHOSTMESH // ENCRYPTED P2P RELAY LAYER', `${ANSI.bold}${ANSI.amber}`)}`,
|
|
72
|
+
` ${c('mesh status', ANSI.cyan)} Inspect local destination hash, peer count, and store-forward queue`,
|
|
73
|
+
` ${c('mesh announce', ANSI.cyan)} Broadcast Ed25519-signed announce packet across active transports`,
|
|
74
|
+
` ${c('mesh send', ANSI.cyan)} --to <dest> --memory <m> Seal & route E2EE memory capsule via multi-hop mesh`,
|
|
75
|
+
` ${c('mesh demo', ANSI.cyan)} Run in-memory multi-node multi-transport mesh simulation`,
|
|
76
|
+
'',
|
|
77
|
+
` ${c('TERMINAL CONTROLS', `${ANSI.bold}${ANSI.amber}`)}`,
|
|
78
|
+
` ${c('clear', ANSI.cyan)} | ${c('cls', ANSI.cyan)} Clear the terminal screen`,
|
|
79
|
+
` ${c('bundle', ANSI.cyan)} <path> Switch active memory bundle path`,
|
|
80
|
+
` ${c('help', ANSI.cyan)} | ${c('?', ANSI.cyan)} Show this command reference`,
|
|
81
|
+
` ${c('exit', ANSI.cyan)} | ${c('quit', ANSI.cyan)} Exit the Enigma Terminal Console`,
|
|
82
|
+
'',
|
|
83
|
+
` ${c('SECURITY & AT-REST CONFIDENTIALITY NOTICE', `${ANSI.bold}${ANSI.amber}`)}`,
|
|
84
|
+
` • ${c('Encrypted Default', ANSI.white)}: Set ${c('ENIGMA_PASSPHRASE', ANSI.cyan)} or pass ${c('--passphrase-file <path>', ANSI.cyan)}.`,
|
|
85
|
+
` ${c('Quickstart and persistent vault access fail closed without credentials.', ANSI.dim)}`,
|
|
86
|
+
` • ${c('INSECURE, EVALUATION ONLY', ANSI.white)}: ${c('--insecure-dev', ANSI.cyan)} creates an unencrypted disposable keyring.`,
|
|
87
|
+
` ${c('It has NO at-rest confidentiality and must never hold normal or persistent data.', ANSI.dim)}`,
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
return sections.join('\n');
|
|
91
|
+
}
|