enigma-memory 0.1.17 → 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 +85 -27
- package/apps/cli/bin/enigma-desktop.mjs +140 -0
- package/apps/cli/bin/enigma-terminal.mjs +78 -0
- package/apps/cli/bin/enigma.mjs +4979 -3263
- 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/SIMULATION.md +14 -9
- package/deploy/docker-compose.local-production-simulation.yml +54 -12
- package/docs/benchmark-attestation-network.md +487 -487
- package/docs/benchmark-reproducibility.md +289 -289
- package/docs/blockchain-only-mechanisms.md +400 -400
- package/docs/browser-extension-install.md +8 -6
- package/docs/client-connectors.md +16 -12
- package/docs/demo-proof-network.md +275 -275
- package/docs/developer-ecosystem.md +15 -13
- package/docs/developer-proof-quickstart.md +325 -325
- package/docs/enigma-memory-ready-conformance.md +378 -376
- package/docs/install-anywhere.md +64 -30
- package/docs/installers-and-desktop.md +8 -7
- package/docs/memory-benchmarks.md +1 -1
- package/docs/memory-drive-health-model.md +690 -690
- package/docs/novelty-invention-candidates.md +161 -161
- package/docs/proof-network-build-notes.md +240 -240
- package/docs/proof-network-claim-boundaries.md +320 -318
- package/docs/proof-network.md +339 -339
- package/docs/sdk-api.md +324 -324
- package/docs/solana-proof-rail.md +453 -453
- 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 +410 -278
- 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 +249 -2
- 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 +2498 -1185
- 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 +436 -7
- 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 +1150 -125
- 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 +292 -274
- package/scripts/build-hosted-customer-lifecycle.mjs +493 -476
- package/scripts/build-hosted-probe-worker.mjs +19 -4
- package/scripts/build-installer-assets.mjs +409 -389
- 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 +4 -1
- package/scripts/build-proof-network-packet.mjs +213 -213
- package/scripts/check.mjs +25 -4
- package/scripts/collect-hosted-backend-live-evidence.mjs +49 -12
- package/scripts/install-enigma-local.mjs +18 -5
- package/scripts/release-audit.mjs +74 -115
- package/scripts/release-provenance.mjs +12 -2
- package/scripts/run-backend-readiness-smoke.mjs +112 -10
- package/scripts/run-standard-memory-benchmarks.mjs +1354 -1352
- package/scripts/scan-secrets.mjs +178 -0
- package/scripts/simulate-production-env.mjs +71 -10
- 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 dependency adapters contract
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`enigma-memory/adapters` is a pure local evidence-normalization package. It does not provision cloud resources, open sockets, read environment variables, or load secrets.
|
|
4
4
|
|
|
5
5
|
## Purpose
|
|
6
6
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { access, copyFile, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { dirname, posix, win32 } from 'node:path';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
|
+
import { canonicalize, MerkleSet, sha256Hex } from '../../core/src/index.js';
|
|
4
5
|
|
|
5
6
|
const PROFILE_SCHEMA = 'enigma.connector_profile.v1';
|
|
6
7
|
const DEFAULT_SERVER_NAME = 'enigma';
|
|
7
8
|
const MCP_COMMAND = 'enigma-mcp';
|
|
8
9
|
const MCP_CONTAINER_PATH = Object.freeze(['mcpServers']);
|
|
9
10
|
const SUPPORTED_PLATFORMS = Object.freeze(['win32', 'darwin', 'linux']);
|
|
11
|
+
const TRUST_CARD_SCHEMA = 'enigma.trust_card.v1';
|
|
10
12
|
|
|
11
13
|
const CLIENT_DEFINITIONS = Object.freeze({
|
|
12
14
|
'claude-desktop': Object.freeze({
|
|
@@ -36,6 +38,15 @@ const CLIENT_DEFINITIONS = Object.freeze({
|
|
|
36
38
|
linux: '$HOME/.config/kimi-code/mcp.json',
|
|
37
39
|
}),
|
|
38
40
|
}),
|
|
41
|
+
'kimi-k3': Object.freeze({
|
|
42
|
+
display_name: 'Kimi K3',
|
|
43
|
+
description: 'Kimi K3 Autonomous AI MCP configuration.',
|
|
44
|
+
default_config_paths: Object.freeze({
|
|
45
|
+
win32: '%APPDATA%\\Kimi K3\\mcp.json',
|
|
46
|
+
darwin: '$HOME/Library/Application Support/Kimi K3/mcp.json',
|
|
47
|
+
linux: '$HOME/.config/kimi-k3/mcp.json',
|
|
48
|
+
}),
|
|
49
|
+
}),
|
|
39
50
|
'vscode-cline': Object.freeze({
|
|
40
51
|
display_name: 'VS Code Cline',
|
|
41
52
|
description: 'Cline extension MCP settings for VS Code.',
|
|
@@ -74,6 +85,74 @@ const CLIENT_DEFINITIONS = Object.freeze({
|
|
|
74
85
|
}),
|
|
75
86
|
});
|
|
76
87
|
|
|
88
|
+
const CONNECTOR_CAPABILITY_DEFINITIONS = Object.freeze({
|
|
89
|
+
'claude-desktop': Object.freeze({
|
|
90
|
+
integration_kind: 'mcp_client',
|
|
91
|
+
client_surface: 'claude_desktop',
|
|
92
|
+
transport: 'mcp_stdio',
|
|
93
|
+
mcp_tools: true,
|
|
94
|
+
browser_context_bridge: false,
|
|
95
|
+
offline_export_import: false,
|
|
96
|
+
}),
|
|
97
|
+
cursor: Object.freeze({
|
|
98
|
+
integration_kind: 'mcp_client',
|
|
99
|
+
client_surface: 'cursor_editor',
|
|
100
|
+
transport: 'mcp_stdio',
|
|
101
|
+
mcp_tools: true,
|
|
102
|
+
browser_context_bridge: false,
|
|
103
|
+
offline_export_import: false,
|
|
104
|
+
}),
|
|
105
|
+
'browser-extension': Object.freeze({
|
|
106
|
+
integration_kind: 'browser_context_bridge',
|
|
107
|
+
client_surface: 'supported_web_ai_pages',
|
|
108
|
+
transport: 'browser_native_messaging',
|
|
109
|
+
mcp_tools: false,
|
|
110
|
+
browser_context_bridge: true,
|
|
111
|
+
offline_export_import: false,
|
|
112
|
+
}),
|
|
113
|
+
'chatgpt-import': Object.freeze({
|
|
114
|
+
integration_kind: 'offline_export_import',
|
|
115
|
+
client_surface: 'chatgpt_user_export',
|
|
116
|
+
transport: 'local_file',
|
|
117
|
+
mcp_tools: false,
|
|
118
|
+
browser_context_bridge: false,
|
|
119
|
+
offline_export_import: true,
|
|
120
|
+
}),
|
|
121
|
+
'generic-mcp': Object.freeze({
|
|
122
|
+
integration_kind: 'mcp_client',
|
|
123
|
+
client_surface: 'generic_local_model_or_mcp_client',
|
|
124
|
+
transport: 'mcp_stdio',
|
|
125
|
+
mcp_tools: true,
|
|
126
|
+
browser_context_bridge: false,
|
|
127
|
+
offline_export_import: false,
|
|
128
|
+
}),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
export const connectorCapabilityIds = Object.freeze(Object.keys(CONNECTOR_CAPABILITY_DEFINITIONS));
|
|
132
|
+
|
|
133
|
+
export function getConnectorCapabilityDescriptor(capabilityId) {
|
|
134
|
+
const id = String(capabilityId ?? '').trim().toLowerCase();
|
|
135
|
+
const explicit = CONNECTOR_CAPABILITY_DEFINITIONS[id];
|
|
136
|
+
const definition = explicit ?? (Object.hasOwn(CLIENT_DEFINITIONS, id)
|
|
137
|
+
? {
|
|
138
|
+
...CONNECTOR_CAPABILITY_DEFINITIONS['generic-mcp'],
|
|
139
|
+
client_surface: id,
|
|
140
|
+
}
|
|
141
|
+
: undefined);
|
|
142
|
+
if (!definition) throw new Error(`Unknown connector capability id: ${id || '(empty)'}`);
|
|
143
|
+
return Object.freeze({
|
|
144
|
+
schema: 'enigma.connector_capability.v1',
|
|
145
|
+
capability_id: id,
|
|
146
|
+
...definition,
|
|
147
|
+
native_provider_integration: false,
|
|
148
|
+
provider_api_access: false,
|
|
149
|
+
provider_memory_read: false,
|
|
150
|
+
provider_memory_write: false,
|
|
151
|
+
provider_memory_delete: false,
|
|
152
|
+
canonical_storage: 'enigma_local_vault',
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
77
156
|
export const supportedClients = Object.freeze(Object.keys(CLIENT_DEFINITIONS));
|
|
78
157
|
|
|
79
158
|
function isPlainObject(value) {
|
|
@@ -187,6 +266,10 @@ function defaultConfigPathFor(clientId, platform, options = {}) {
|
|
|
187
266
|
return joinForPlatform(platform, appData, 'Claude', 'claude_desktop_config.json');
|
|
188
267
|
case 'cursor':
|
|
189
268
|
return joinForPlatform(platform, home, '.cursor', 'mcp.json');
|
|
269
|
+
case 'kimi-k3':
|
|
270
|
+
return platform === 'linux'
|
|
271
|
+
? joinForPlatform(platform, appData, 'kimi-k3', 'mcp.json')
|
|
272
|
+
: joinForPlatform(platform, appData, 'Kimi K3', 'mcp.json');
|
|
190
273
|
case 'kimi-code':
|
|
191
274
|
return platform === 'linux'
|
|
192
275
|
? joinForPlatform(platform, appData, 'kimi-code', 'mcp.json')
|
|
@@ -231,6 +314,7 @@ export function getClientProfile(clientIdOrOptions = 'generic-mcp', maybeOptions
|
|
|
231
314
|
server_name: DEFAULT_SERVER_NAME,
|
|
232
315
|
command: MCP_COMMAND,
|
|
233
316
|
required_env: Object.freeze(['ENIGMA_BUNDLE']),
|
|
317
|
+
capabilities: getConnectorCapabilityDescriptor(clientId),
|
|
234
318
|
platform,
|
|
235
319
|
});
|
|
236
320
|
}
|
|
@@ -557,6 +641,10 @@ function redactErrorMessage(message, configPath, options = {}) {
|
|
|
557
641
|
function publicBundlePlaceholder(platform) {
|
|
558
642
|
return platform === 'win32' ? '%USERPROFILE%\\.enigma\\bundle.json' : '$HOME/.enigma/bundle.json';
|
|
559
643
|
}
|
|
644
|
+
function publicPassphrasePlaceholder(platform) {
|
|
645
|
+
return platform === 'win32' ? '%USERPROFILE%\\.enigma\\passphrase' : '$HOME/.enigma/passphrase';
|
|
646
|
+
}
|
|
647
|
+
|
|
560
648
|
|
|
561
649
|
function publicDefaultConfigPath(clientId, platform) {
|
|
562
650
|
return CLIENT_DEFINITIONS[clientId].default_config_paths[platform];
|
|
@@ -567,7 +655,7 @@ function connectCommandFor(clientId, platform) {
|
|
|
567
655
|
}
|
|
568
656
|
|
|
569
657
|
function setupConnectCommandFor(clientId, platform) {
|
|
570
|
-
return `enigma setup --client ${clientId} --write-connectors --bundle "${publicBundlePlaceholder(platform)}" --overwrite`;
|
|
658
|
+
return `enigma setup --client ${clientId} --write-connectors --bundle "${publicBundlePlaceholder(platform)}" --passphrase-file "${publicPassphrasePlaceholder(platform)}" --overwrite`;
|
|
571
659
|
}
|
|
572
660
|
|
|
573
661
|
function installConnectCommandFor(clientId, platform) {
|
|
@@ -589,7 +677,7 @@ function wizardStepsForClient(clientId, platform) {
|
|
|
589
677
|
id: 'create_local_bundle',
|
|
590
678
|
title: 'Create and verify the local Enigma bundle.',
|
|
591
679
|
commands: [
|
|
592
|
-
`enigma quickstart --bundle "${publicBundlePlaceholder(platform)}" --overwrite`,
|
|
680
|
+
`enigma quickstart --bundle "${publicBundlePlaceholder(platform)}" --passphrase-file "${publicPassphrasePlaceholder(platform)}" --overwrite`,
|
|
593
681
|
`enigma verify --bundle "${publicBundlePlaceholder(platform)}"`,
|
|
594
682
|
],
|
|
595
683
|
writes: 'local_enigma_bundle',
|
|
@@ -615,11 +703,11 @@ function wizardStepsForClient(clientId, platform) {
|
|
|
615
703
|
writes: false,
|
|
616
704
|
},
|
|
617
705
|
];
|
|
618
|
-
if (clientId === 'kimi-code') {
|
|
706
|
+
if (clientId === 'kimi-k3' || clientId === 'kimi-code') {
|
|
619
707
|
steps.splice(4, 0, {
|
|
620
708
|
order: 5,
|
|
621
709
|
id: 'kimi_gui_path_caveat',
|
|
622
|
-
title: 'If Kimi Code was launched from the GUI and cannot find enigma-mcp, reconnect with an absolute command path.',
|
|
710
|
+
title: 'If Kimi K3 / Kimi Code was launched from the GUI and cannot find enigma-mcp, reconnect with an absolute command path.',
|
|
623
711
|
command: `${connectCommandFor(clientId, platform)} --mcp-command "/absolute/path/to/enigma-mcp"`,
|
|
624
712
|
writes: 'client_config_when_user_runs_command',
|
|
625
713
|
});
|
|
@@ -726,6 +814,110 @@ export async function doctorConnectors(clientIdOrOptions = {}, maybeOptions = {}
|
|
|
726
814
|
return detectConnectors(clientIdOrOptions, maybeOptions);
|
|
727
815
|
}
|
|
728
816
|
|
|
817
|
+
function sha256Root(value) {
|
|
818
|
+
return `sha256:${sha256Hex(typeof value === 'string' ? value : canonicalize(value))}`;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
function publicTrustRef(kind, value) {
|
|
822
|
+
return `ref:${kind}:${sha256Hex(typeof value === 'string' ? value : canonicalize(value)).slice(0, 32)}`;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
function uniqueSortedStrings(values) {
|
|
826
|
+
return [...new Set(values.map(String).filter((value) => value.length > 0))].sort();
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
function connectorTrustBoundary() {
|
|
830
|
+
return {
|
|
831
|
+
public_payload_only: true,
|
|
832
|
+
raw_memory_included: false,
|
|
833
|
+
raw_prompt_included: false,
|
|
834
|
+
raw_transcript_included: false,
|
|
835
|
+
raw_embedding_included: false,
|
|
836
|
+
private_key_included: false,
|
|
837
|
+
credential_included: false,
|
|
838
|
+
local_path_included: false,
|
|
839
|
+
provider_deletion_claim: false,
|
|
840
|
+
model_forgetting_claim: false,
|
|
841
|
+
hosted_saas_ready_claim: false,
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
function connectorTrustEvidenceRefs(clientId, profile) {
|
|
846
|
+
return uniqueSortedStrings([
|
|
847
|
+
publicTrustRef('connector_profile', {
|
|
848
|
+
schema: PROFILE_SCHEMA,
|
|
849
|
+
client_id: clientId,
|
|
850
|
+
display_name: profile.display_name,
|
|
851
|
+
command: profile.command,
|
|
852
|
+
server_name: profile.server_name,
|
|
853
|
+
server_container_path: profile.server_container_path,
|
|
854
|
+
}),
|
|
855
|
+
publicTrustRef('mcp_command', {
|
|
856
|
+
command: profile.command,
|
|
857
|
+
server_name: profile.server_name,
|
|
858
|
+
}),
|
|
859
|
+
]);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
export function createConnectorTrustCard(clientIdOrOptions = 'generic-mcp', maybeOptions = {}) {
|
|
863
|
+
const options = normalizeOptions(clientIdOrOptions, maybeOptions);
|
|
864
|
+
const clientId = normalizeClientId(options.clientId ?? options.client_id ?? 'generic-mcp');
|
|
865
|
+
const profile = getClientProfile(clientId, options);
|
|
866
|
+
const generatedAt = String(options.generated_at ?? options.generatedAt ?? options.now ?? new Date().toISOString());
|
|
867
|
+
const evidenceRefs = connectorTrustEvidenceRefs(clientId, profile);
|
|
868
|
+
const claims = [
|
|
869
|
+
{
|
|
870
|
+
claim_id: 'claim:connector.local_mcp_profile',
|
|
871
|
+
claim_type: PROFILE_SCHEMA,
|
|
872
|
+
status: 'supported',
|
|
873
|
+
evidence_refs: [evidenceRefs[0]],
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
claim_id: 'claim:connector.public_payload_only',
|
|
877
|
+
claim_type: 'enigma.trust_boundary.v1',
|
|
878
|
+
status: 'supported',
|
|
879
|
+
evidence_refs: [evidenceRefs[1]],
|
|
880
|
+
},
|
|
881
|
+
];
|
|
882
|
+
const claimIds = claims.map((claim) => claim.claim_id);
|
|
883
|
+
return {
|
|
884
|
+
schema: TRUST_CARD_SCHEMA,
|
|
885
|
+
trust_card_id: `trustcard:connector:${clientId}`,
|
|
886
|
+
generated_at: generatedAt,
|
|
887
|
+
subject: {
|
|
888
|
+
subject_type: 'connector',
|
|
889
|
+
subject_id: `connector:${clientId}`,
|
|
890
|
+
subject_ref: `ref:connector:${clientId}`,
|
|
891
|
+
subject_hash: sha256Root({
|
|
892
|
+
schema: 'enigma.connector_trust_subject.v1',
|
|
893
|
+
client_id: clientId,
|
|
894
|
+
command: profile.command,
|
|
895
|
+
server_name: profile.server_name,
|
|
896
|
+
}),
|
|
897
|
+
},
|
|
898
|
+
posture: options.posture ?? 'reviewed',
|
|
899
|
+
claim_ids: claimIds,
|
|
900
|
+
claims,
|
|
901
|
+
evidence_refs: evidenceRefs,
|
|
902
|
+
roots: {
|
|
903
|
+
claim_root: new MerkleSet(claimIds).root(),
|
|
904
|
+
evidence_root: new MerkleSet(evidenceRefs).root(),
|
|
905
|
+
receipt_chain_root: options.receipt_chain_root ?? options.receiptChainRoot ?? sha256Root({
|
|
906
|
+
schema: 'enigma.connector_trust_card.empty_receipt_chain.v1',
|
|
907
|
+
client_id: clientId,
|
|
908
|
+
}),
|
|
909
|
+
},
|
|
910
|
+
boundary: connectorTrustBoundary(),
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
export function createConnectorTrustCards(options = {}) {
|
|
915
|
+
const selected = options.clientId ?? options.client_id
|
|
916
|
+
? [normalizeClientId(options.clientId ?? options.client_id)]
|
|
917
|
+
: supportedClients;
|
|
918
|
+
return selected.map((clientId) => createConnectorTrustCard({ ...options, clientId }));
|
|
919
|
+
}
|
|
920
|
+
|
|
729
921
|
export function runConnectorDemo(input = {}) {
|
|
730
922
|
const options = { ...input, clientId: input.clientId ?? input.client_id ?? 'generic-mcp' };
|
|
731
923
|
const clientId = normalizeClientId(options.clientId);
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { access, mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import {
|
|
4
|
+
createSwarmBridge,
|
|
5
|
+
projectSwarmCommitmentAtom,
|
|
6
|
+
SWARM_PERMISSIONS,
|
|
7
|
+
validateSwarmCommitmentAtom,
|
|
8
|
+
} from '../mcp-server/swarm-bridge.mjs';
|
|
9
|
+
|
|
10
|
+
const pathQueues = new Map();
|
|
11
|
+
|
|
12
|
+
async function exists(path) {
|
|
13
|
+
try { await access(path); return true; } catch { return false; }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function statePathFor(bundlePath) {
|
|
17
|
+
return `${resolve(bundlePath)}.swarm.json`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function readJson(path) {
|
|
21
|
+
return JSON.parse(await readFile(path, 'utf8'));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function writeJsonAtomic(path, value) {
|
|
25
|
+
await mkdir(dirname(path), { recursive: true });
|
|
26
|
+
const temporary = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
27
|
+
await writeFile(temporary, `${JSON.stringify(value, null, 2)}\n`, { encoding: 'utf8', mode: 0o600 });
|
|
28
|
+
await rename(temporary, path);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function persistenceSafeState(bridge) {
|
|
32
|
+
const state = bridge.exportState();
|
|
33
|
+
for (const atoms of Object.values(state.namespaces)) {
|
|
34
|
+
for (let index = 0; index < atoms.length; index += 1) {
|
|
35
|
+
atoms[index] = projectSwarmCommitmentAtom(atoms[index]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return state;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function enqueue(path, operation) {
|
|
42
|
+
const prior = pathQueues.get(path) ?? Promise.resolve();
|
|
43
|
+
const current = prior.catch(() => {}).then(operation);
|
|
44
|
+
pathQueues.set(path, current);
|
|
45
|
+
return current.finally(() => { if (pathQueues.get(path) === current) pathQueues.delete(path); });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function loadBridge(bundlePath, requestedSwarmId) {
|
|
49
|
+
const statePath = statePathFor(bundlePath);
|
|
50
|
+
if (await exists(statePath)) {
|
|
51
|
+
const state = await readJson(statePath);
|
|
52
|
+
if (state.schema !== 'enigma.swarm_bridge_state.v1') throw new Error(`unsupported swarm state schema: ${state.schema ?? '<missing>'}`);
|
|
53
|
+
for (const atoms of Object.values(state.namespaces ?? {})) {
|
|
54
|
+
if (!Array.isArray(atoms)) throw new Error('persisted swarm namespace must contain an atom array');
|
|
55
|
+
atoms.forEach(validateSwarmCommitmentAtom);
|
|
56
|
+
}
|
|
57
|
+
if (requestedSwarmId && requestedSwarmId !== state.swarm_id) throw new Error('swarm domain does not match persisted bundle swarm');
|
|
58
|
+
return { bridge: createSwarmBridge(state), statePath };
|
|
59
|
+
}
|
|
60
|
+
return { bridge: createSwarmBridge(requestedSwarmId ? { swarm_id: requestedSwarmId } : {}), statePath };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function bundleAtoms(bundlePath) {
|
|
64
|
+
if (!(await exists(resolve(bundlePath)))) return [];
|
|
65
|
+
const bundle = await readJson(resolve(bundlePath));
|
|
66
|
+
if (bundle.schema !== 'enigma.vault_bundle.v1') throw new Error(`unsupported Enigma bundle schema: ${bundle.schema ?? '<missing>'}`);
|
|
67
|
+
const active = new Set(Array.isArray(bundle.active_memory_addresses) ? bundle.active_memory_addresses : []);
|
|
68
|
+
return (Array.isArray(bundle.memory_objects) ? bundle.memory_objects : []).filter((atom) => active.has(atom.memory_addr));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function runPersisted(bundlePath, swarmId, operation) {
|
|
72
|
+
const statePath = statePathFor(bundlePath);
|
|
73
|
+
return enqueue(statePath, async () => {
|
|
74
|
+
const loaded = await loadBridge(bundlePath, swarmId);
|
|
75
|
+
const result = await operation(loaded.bridge);
|
|
76
|
+
await writeJsonAtomic(loaded.statePath, persistenceSafeState(loaded.bridge));
|
|
77
|
+
return result;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function hydrateSuppliedAtoms(bridge, input, permission) {
|
|
82
|
+
const atoms = input.atoms ?? input.memories;
|
|
83
|
+
if (!Array.isArray(atoms) || atoms.length === 0) return;
|
|
84
|
+
const { namespace } = bridge.requireAgent(input.agent_id, permission, input.namespace);
|
|
85
|
+
bridge.hydrateCanonicalMemories(namespace, atoms);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function enigma_swarm_register_agent(input = {}) {
|
|
89
|
+
const bundlePath = input.bundlePath ?? input.bundle_path ?? '.enigma/bundle.json';
|
|
90
|
+
return runPersisted(bundlePath, input.swarm_id ?? input.swarmId, (bridge) => ({
|
|
91
|
+
ok: true,
|
|
92
|
+
agent: bridge.registerAgent(input),
|
|
93
|
+
status: bridge.status(),
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function enigma_graph_query(input = {}) {
|
|
98
|
+
const bundlePath = input.bundlePath ?? input.bundle_path ?? '.enigma/bundle.json';
|
|
99
|
+
return runPersisted(bundlePath, input.swarm_id ?? input.swarmId, (bridge) => {
|
|
100
|
+
hydrateSuppliedAtoms(bridge, input, SWARM_PERMISSIONS.GRAPH);
|
|
101
|
+
return bridge.graphQuery(input);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const enigma_graph_search = enigma_graph_query;
|
|
106
|
+
|
|
107
|
+
export async function enigma_cluster_memories(input = {}) {
|
|
108
|
+
const bundlePath = input.bundlePath ?? input.bundle_path ?? '.enigma/bundle.json';
|
|
109
|
+
return runPersisted(bundlePath, input.swarm_id ?? input.swarmId, (bridge) => {
|
|
110
|
+
hydrateSuppliedAtoms(bridge, input, SWARM_PERMISSIONS.CLUSTER);
|
|
111
|
+
return bridge.clusterMemories(input);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export async function enigma_swarm_sync(input = {}) {
|
|
116
|
+
const bundlePath = input.bundlePath ?? input.bundle_path ?? '.enigma/bundle.json';
|
|
117
|
+
return runPersisted(bundlePath, input.swarm_id ?? input.swarmId, (bridge) => {
|
|
118
|
+
hydrateSuppliedAtoms(bridge, input, SWARM_PERMISSIONS.SYNC);
|
|
119
|
+
if (input.snapshot ?? input.peer_snapshot ?? input.peerSnapshot) return bridge.sync(input);
|
|
120
|
+
return bridge.createSnapshot(input);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export async function routeSwarmTool(name, input = {}) {
|
|
125
|
+
const handlers = { enigma_swarm_register_agent, enigma_graph_query, enigma_graph_search, enigma_cluster_memories, enigma_swarm_sync };
|
|
126
|
+
const handler = handlers[name];
|
|
127
|
+
if (!handler) throw new Error(`unknown swarm tool: ${name}`);
|
|
128
|
+
return handler(input);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export async function swarmStatusFromBundle(bundlePath = '.enigma/bundle.json') {
|
|
132
|
+
const resolved = resolve(bundlePath);
|
|
133
|
+
const { bridge } = await loadBridge(resolved);
|
|
134
|
+
const status = bridge.status();
|
|
135
|
+
const atoms = await bundleAtoms(resolved);
|
|
136
|
+
return {
|
|
137
|
+
...status,
|
|
138
|
+
bundle: resolved,
|
|
139
|
+
active_bundle_memory_count: atoms.length,
|
|
140
|
+
state_path: statePathFor(resolved),
|
|
141
|
+
claim_boundaries: {
|
|
142
|
+
local_simulator_only: true,
|
|
143
|
+
network_transmission: false,
|
|
144
|
+
decentralized_network_claim: false,
|
|
145
|
+
raw_memory_replicated_by_default: false,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export async function swarmGraphFromBundle(bundlePath = '.enigma/bundle.json') {
|
|
151
|
+
const resolved = resolve(bundlePath);
|
|
152
|
+
const loaded = await loadBridge(resolved);
|
|
153
|
+
const bridge = loaded.bridge;
|
|
154
|
+
const atoms = await bundleAtoms(resolved);
|
|
155
|
+
const inspectorId = '__enigma_cli_swarm_inspector__';
|
|
156
|
+
const namespace = '__enigma_bundle_active_set__';
|
|
157
|
+
bridge.registerAgent({ agent_id: inspectorId, namespace, permission_mask: SWARM_PERMISSIONS.ADMIN });
|
|
158
|
+
if (atoms.length > 0) bridge.ingestMemories({ agent_id: inspectorId, namespace, atoms });
|
|
159
|
+
const query = bridge.graphQuery({ agent_id: inspectorId, namespace, max_depth: 12, limit: 500 });
|
|
160
|
+
return {
|
|
161
|
+
...query,
|
|
162
|
+
bundle: resolved,
|
|
163
|
+
active_bundle_memory_count: atoms.length,
|
|
164
|
+
content_redacted: true,
|
|
165
|
+
local_only: true,
|
|
166
|
+
network_transmission: false,
|
|
167
|
+
};
|
|
168
|
+
}
|