silo-agent 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/README.md +330 -0
- package/bin/silo.js +55 -0
- package/build/demo.d.ts +13 -0
- package/build/demo.js +91 -0
- package/build/demo.js.map +1 -0
- package/build/doctor.d.ts +13 -0
- package/build/doctor.js +108 -0
- package/build/doctor.js.map +1 -0
- package/build/index.d.ts +16 -0
- package/build/index.js +17 -0
- package/build/index.js.map +1 -0
- package/build/lib/agent-router.d.ts +110 -0
- package/build/lib/agent-router.js +197 -0
- package/build/lib/agent-router.js.map +1 -0
- package/build/lib/attestation.d.ts +64 -0
- package/build/lib/attestation.js +112 -0
- package/build/lib/attestation.js.map +1 -0
- package/build/lib/autonomy.d.ts +116 -0
- package/build/lib/autonomy.js +266 -0
- package/build/lib/autonomy.js.map +1 -0
- package/build/lib/crypto.d.ts +33 -0
- package/build/lib/crypto.js +63 -0
- package/build/lib/crypto.js.map +1 -0
- package/build/lib/heartbeat.d.ts +111 -0
- package/build/lib/heartbeat.js +256 -0
- package/build/lib/heartbeat.js.map +1 -0
- package/build/lib/memory-coordinator.d.ts +150 -0
- package/build/lib/memory-coordinator.js +249 -0
- package/build/lib/memory-coordinator.js.map +1 -0
- package/build/lib/memory-index.d.ts +83 -0
- package/build/lib/memory-index.js +209 -0
- package/build/lib/memory-index.js.map +1 -0
- package/build/lib/shared-memory.d.ts +165 -0
- package/build/lib/shared-memory.js +398 -0
- package/build/lib/shared-memory.js.map +1 -0
- package/build/lib/storage.d.ts +38 -0
- package/build/lib/storage.js +106 -0
- package/build/lib/storage.js.map +1 -0
- package/build/lib/vault.d.ts +71 -0
- package/build/lib/vault.js +119 -0
- package/build/lib/vault.js.map +1 -0
- package/build/mcp.d.ts +32 -0
- package/build/mcp.js +734 -0
- package/build/mcp.js.map +1 -0
- package/build/server.d.ts +1 -0
- package/build/server.js +370 -0
- package/build/server.js.map +1 -0
- package/build/tests/attestation.test.d.ts +1 -0
- package/build/tests/attestation.test.js +175 -0
- package/build/tests/attestation.test.js.map +1 -0
- package/build/tests/crypto.test.d.ts +1 -0
- package/build/tests/crypto.test.js +109 -0
- package/build/tests/crypto.test.js.map +1 -0
- package/build/verify-flow.d.ts +10 -0
- package/build/verify-flow.js +81 -0
- package/build/verify-flow.js.map +1 -0
- package/build/verify.d.ts +14 -0
- package/build/verify.js +77 -0
- package/build/verify.js.map +1 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# SILO
|
|
2
|
+
|
|
3
|
+
**Encrypted private memory + execution attestation for AI agents, powered by 0G.**
|
|
4
|
+
|
|
5
|
+
AI agents are accumulating sensitive personal data — medical records, financial info, personal preferences — and storing it in plaintext. SILO fixes this by giving any agent framework encrypted, decentralized memory backed by 0G Storage, with cryptographic proof of every action the agent takes.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## What It Does
|
|
10
|
+
|
|
11
|
+
| Feature | Description |
|
|
12
|
+
|---|---|
|
|
13
|
+
| **Encrypted Vault** | AES-256-GCM encryption with PBKDF2 key derivation. Data is encrypted in-memory and stored on 0G — never at rest in plaintext. |
|
|
14
|
+
| **Execution Attestation** | Every store/retrieve is hashed into a Merkle tree. Commit a session to publish a verifiable proof of agent behavior without revealing content. |
|
|
15
|
+
| **Multi-Agent Sharing** | Agents can securely share encrypted memories via `vault_share` and `vault_import` — enabling cross-agent collaboration with cryptographic accountability. |
|
|
16
|
+
| **MCP Server** | 8 tools for Claude Desktop, Cursor, or any MCP-compatible client. |
|
|
17
|
+
| **Real-Time Dashboard** | Live WebSocket-powered UI showing stores, retrieves, Merkle tree visualization, and session attestation ceremonies. |
|
|
18
|
+
| **CLI Tools** | `verify` to prove data exists, `doctor` to validate setup, `demo` to run the full cycle. |
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Clone and install
|
|
26
|
+
git clone https://github.com/rohanpotta/ethdenverhack.git
|
|
27
|
+
cd silo
|
|
28
|
+
|
|
29
|
+
# Install backend
|
|
30
|
+
cd 0g-agent-shield
|
|
31
|
+
npm install
|
|
32
|
+
|
|
33
|
+
# Configure
|
|
34
|
+
cp .env.example .env
|
|
35
|
+
# Edit .env with your private key (get testnet tokens: https://faucet.0g.ai)
|
|
36
|
+
|
|
37
|
+
# Validate setup
|
|
38
|
+
npm run build
|
|
39
|
+
npm run doctor
|
|
40
|
+
|
|
41
|
+
# Start the API server + dashboard backend
|
|
42
|
+
npm start
|
|
43
|
+
|
|
44
|
+
# In a second terminal — start the dashboard UI
|
|
45
|
+
cd ../0g-agent-shield-ui
|
|
46
|
+
npm install
|
|
47
|
+
npm run dev
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Open `http://localhost:5173` to see the SILO dashboard.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Use With Claude Desktop / Cursor
|
|
55
|
+
|
|
56
|
+
Add to your MCP config (`~/Library/Application Support/Claude/claude_desktop_config.json` or Cursor MCP settings):
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"mcpServers": {
|
|
61
|
+
"silo": {
|
|
62
|
+
"command": "npx",
|
|
63
|
+
"args": ["silo-agent", "mcp"],
|
|
64
|
+
"env": {
|
|
65
|
+
"PRIVATE_KEY": "your_private_key_no_0x_prefix",
|
|
66
|
+
"EVM_RPC": "https://evmrpc-testnet.0g.ai",
|
|
67
|
+
"INDEXER_RPC": "https://indexer-storage-testnet-turbo.0g.ai"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
No build step or absolute paths needed — `npx` resolves the package from npm.
|
|
75
|
+
|
|
76
|
+
1. Ask Claude: *"Store my medical diagnosis securely"*
|
|
77
|
+
2. Claude responds with a root hash and attestation event number
|
|
78
|
+
3. Verify: `npx silo-agent verify <rootHash>`
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## MCP Tools (8)
|
|
83
|
+
|
|
84
|
+
| Tool | Description |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `vault_store` | Encrypt data and upload to 0G Storage |
|
|
87
|
+
| `vault_retrieve` | Download from 0G and decrypt |
|
|
88
|
+
| `vault_session_log` | View the current attestation session |
|
|
89
|
+
| `session_commit` | Finalize session: Merkle root + encrypted trace to 0G |
|
|
90
|
+
| `vault_balance` | Check wallet balance |
|
|
91
|
+
| `vault_status` | Show agent address, session ID, network |
|
|
92
|
+
| `vault_share` | Encrypt, store, and generate a share descriptor for another agent |
|
|
93
|
+
| `vault_import` | Retrieve and decrypt shared memory from another agent's descriptor |
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Multi-Agent Sharing
|
|
98
|
+
|
|
99
|
+
SILO enables agents to share encrypted memories without exposing plaintext:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
Agent A (Claude Desktop) Agent B (Cursor)
|
|
103
|
+
│ │
|
|
104
|
+
├─ vault_share("patient data") │
|
|
105
|
+
│ → rootHash: 0xabc... │
|
|
106
|
+
│ → share descriptor ─────────────► │
|
|
107
|
+
│ ├─ vault_import("0xabc...")
|
|
108
|
+
│ │ → decrypted data
|
|
109
|
+
│ │
|
|
110
|
+
└─── Both actions are attested ────────┘
|
|
111
|
+
in their respective Merkle trees
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Both agents' actions are independently recorded in their attestation sessions. The shared secret (VAULT_SECRET or PRIVATE_KEY) must match for cross-agent decryption.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Dashboard
|
|
119
|
+
|
|
120
|
+
The real-time dashboard provides:
|
|
121
|
+
|
|
122
|
+
- **Vault Panel** — Store and retrieve data with live encryption visualization
|
|
123
|
+
- **Merkle Tree** — D3.js visualization of the attestation tree building in real-time
|
|
124
|
+
- **Agents Panel** — Multi-agent sharing demo with transfer animation
|
|
125
|
+
- **Event Log** — Full audit trail of all vault operations
|
|
126
|
+
- **SDK Fix Panel** — Documents SILO's contribution to the 0G SDK ecosystem
|
|
127
|
+
|
|
128
|
+
The dashboard connects to the API server via WebSocket for live event streaming.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Use As a Library
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npm install silo-agent
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { AgentVault } from "silo-agent";
|
|
140
|
+
|
|
141
|
+
const vault = new AgentVault({
|
|
142
|
+
privateKey: "abc123...",
|
|
143
|
+
evmRpc: "https://evmrpc-testnet.0g.ai",
|
|
144
|
+
indexerRpc: "https://indexer-storage-testnet-turbo.0g.ai",
|
|
145
|
+
});
|
|
146
|
+
await vault.init();
|
|
147
|
+
|
|
148
|
+
// Store encrypted data
|
|
149
|
+
const { rootHash } = await vault.store("Patient has arrhythmia");
|
|
150
|
+
|
|
151
|
+
// Retrieve and decrypt
|
|
152
|
+
const data = await vault.retrieve(rootHash);
|
|
153
|
+
|
|
154
|
+
// Commit attestation (Merkle root + encrypted trace → 0G)
|
|
155
|
+
const proof = await vault.commitSession();
|
|
156
|
+
console.log(proof.merkleRoot); // public commitment
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## How Attestation Works
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
Agent Action #1 ──hash──┐
|
|
165
|
+
Agent Action #2 ──hash──┤
|
|
166
|
+
Agent Action #3 ──hash──┼──► Merkle Root (public commitment)
|
|
167
|
+
Agent Action #4 ──hash──┘ │
|
|
168
|
+
▼
|
|
169
|
+
Published on-chain or
|
|
170
|
+
stored as verifiable proof
|
|
171
|
+
|
|
172
|
+
Full trace (encrypted) ──────────► 0G Storage
|
|
173
|
+
(only vault holder can decrypt)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**What this proves:**
|
|
177
|
+
- The agent performed exactly N actions in this session
|
|
178
|
+
- The actions occurred in a specific order
|
|
179
|
+
- No actions were added or removed after the fact
|
|
180
|
+
- The full trace is available for audit — but only to the key holder
|
|
181
|
+
|
|
182
|
+
**What this does NOT reveal:**
|
|
183
|
+
- What the actual data was
|
|
184
|
+
- What the agent's prompts or memory contained
|
|
185
|
+
- Any personally identifiable information
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Architecture
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
┌────────────────────────────────────────────────────────┐
|
|
193
|
+
│ MCP Server (mcp.ts) │
|
|
194
|
+
│ 8 tools for any AI client │
|
|
195
|
+
│ pushes events to dashboard via REST │
|
|
196
|
+
└────────────────────┬───────────────────────────────────┘
|
|
197
|
+
│
|
|
198
|
+
┌────────────────────▼───────────────────────────────────┐
|
|
199
|
+
│ AgentVault (vault.ts) │
|
|
200
|
+
│ Unified API: store / retrieve / commit │
|
|
201
|
+
└──┬──────────────┬──────────────────┬───────────────────┘
|
|
202
|
+
│ │ │
|
|
203
|
+
▼ ▼ ▼
|
|
204
|
+
┌────────┐ ┌──────────┐ ┌──────────────────┐
|
|
205
|
+
│ Crypto │ │ Storage │ │ Attestation │
|
|
206
|
+
│ AES-256│ │ 0G SDK │ │ Merkle Tree │
|
|
207
|
+
│ GCM │ │ Upload/ │ │ Event Hashing │
|
|
208
|
+
│ PBKDF2 │ │ Download │ │ Session Commit │
|
|
209
|
+
└────────┘ └──────────┘ └──────────────────┘
|
|
210
|
+
|
|
211
|
+
┌────────────────────────────────────────────────────────┐
|
|
212
|
+
│ API Server (server.ts) │
|
|
213
|
+
│ Express REST + Socket.IO WebSocket │
|
|
214
|
+
│ /api/store /api/retrieve /api/attest │
|
|
215
|
+
│ /api/push-event (MCP bridge) /api/events │
|
|
216
|
+
└────────────────────┬───────────────────────────────────┘
|
|
217
|
+
│ WebSocket
|
|
218
|
+
▼
|
|
219
|
+
┌────────────────────────────────────────────────────────┐
|
|
220
|
+
│ Dashboard (React + Vite) │
|
|
221
|
+
│ VaultPanel │ MerkleTree │ AgentsPanel │ EventLog │
|
|
222
|
+
└────────────────────────────────────────────────────────┘
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## CLI Tools
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Validate your environment
|
|
231
|
+
npm run doctor
|
|
232
|
+
|
|
233
|
+
# Run the full demo cycle
|
|
234
|
+
npm run demo
|
|
235
|
+
|
|
236
|
+
# Verify a specific stored memory
|
|
237
|
+
npm run verify -- <rootHash>
|
|
238
|
+
|
|
239
|
+
# Inspect an attestation trace
|
|
240
|
+
npm run verify -- <traceRootHash> --trace
|
|
241
|
+
|
|
242
|
+
# Check 0G Flow contract state
|
|
243
|
+
npm run verify-flow
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Project Structure
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
silo/
|
|
252
|
+
├── 0g-agent-shield/ # Backend — Node.js TypeScript
|
|
253
|
+
│ ├── src/
|
|
254
|
+
│ │ ├── lib/
|
|
255
|
+
│ │ │ ├── crypto.ts # AES-256-GCM encryption (WebCrypto)
|
|
256
|
+
│ │ │ ├── storage.ts # 0G Storage SDK wrapper + ABI fix
|
|
257
|
+
│ │ │ ├── attestation.ts # Merkle-based execution proofs
|
|
258
|
+
│ │ │ └── vault.ts # Unified public API (AgentVault)
|
|
259
|
+
│ │ ├── mcp.ts # MCP server (8 tools)
|
|
260
|
+
│ │ ├── server.ts # Express API + WebSocket server
|
|
261
|
+
│ │ ├── verify.ts # CLI: verify stored data
|
|
262
|
+
│ │ ├── doctor.ts # CLI: validate environment
|
|
263
|
+
│ │ ├── demo.ts # CLI: full end-to-end demo
|
|
264
|
+
│ │ ├── verify-flow.ts # CLI: 0G Flow contract debugger
|
|
265
|
+
│ │ ├── index.ts # Library exports
|
|
266
|
+
│ │ └── tests/ # Unit tests (node:test)
|
|
267
|
+
│ │ ├── crypto.test.ts # 14 tests — encryption round-trips, tamper detection
|
|
268
|
+
│ │ └── attestation.test.ts # 21 tests — Merkle tree, session lifecycle
|
|
269
|
+
│ ├── claude-desktop-config.json
|
|
270
|
+
│ ├── .env.example
|
|
271
|
+
│ ├── package.json
|
|
272
|
+
│ └── tsconfig.json
|
|
273
|
+
│
|
|
274
|
+
├── 0g-agent-shield-ui/ # Frontend — React + Vite + Tailwind
|
|
275
|
+
│ ├── src/
|
|
276
|
+
│ │ ├── App.tsx # Dashboard shell (5 views)
|
|
277
|
+
│ │ ├── components/
|
|
278
|
+
│ │ │ ├── ColdOpen.tsx # Particle assembly splash screen
|
|
279
|
+
│ │ │ ├── VaultPanel.tsx # Store/Retrieve with HexCascade effect
|
|
280
|
+
│ │ │ ├── MerkleTree.tsx # D3.js Merkle proof visualization
|
|
281
|
+
│ │ │ ├── AgentsPanel.tsx # Multi-agent sharing demo
|
|
282
|
+
│ │ │ ├── EventLog.tsx # Audit trail table
|
|
283
|
+
│ │ │ ├── CommitCeremony.tsx # Session commit celebration
|
|
284
|
+
│ │ │ ├── SdkDiffPanel.tsx # SDK contribution showcase
|
|
285
|
+
│ │ │ └── effects/ # Visual effects (HexCascade, DotGrid)
|
|
286
|
+
│ │ └── hooks/
|
|
287
|
+
│ │ └── useHashScramble.ts
|
|
288
|
+
│ └── package.json
|
|
289
|
+
│
|
|
290
|
+
├── .env.example
|
|
291
|
+
└── README.md
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## SDK Contribution
|
|
297
|
+
|
|
298
|
+
During development, we discovered and fixed a breaking ABI mismatch in the 0G TS SDK for the Galileo testnet. The SDK's `submit()` function was missing the required `submitter` address parameter. SILO's storage layer includes a transparent proxy fix that upgrades the transaction payload automatically.
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Testing
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
cd 0g-agent-shield
|
|
306
|
+
npm test
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Runs 35 unit tests covering:
|
|
310
|
+
- **Crypto** (14 tests): Encrypt/decrypt round-trips, tamper detection, cross-key isolation, unicode handling
|
|
311
|
+
- **Attestation** (21 tests): Merkle tree construction, session lifecycle, event ordering, edge cases
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Why This Matters
|
|
316
|
+
|
|
317
|
+
Every AI agent project on 0G today builds its own storage integration from scratch. None of them encrypt agent memory. None of them provide verifiable execution proofs.
|
|
318
|
+
|
|
319
|
+
**SILO is the missing middleware:**
|
|
320
|
+
- Drop-in encrypted memory for any agent framework
|
|
321
|
+
- Execution attestation that proves agent behavior without revealing data
|
|
322
|
+
- Multi-agent sharing with cryptographic accountability
|
|
323
|
+
- MCP-native, so it works with the entire AI tooling ecosystem
|
|
324
|
+
- Real-time dashboard for monitoring and demo purposes
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## License
|
|
329
|
+
|
|
330
|
+
MIT
|
package/bin/silo.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { execFileSync } from "node:child_process";
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const buildDir = join(__dirname, "..", "build");
|
|
9
|
+
|
|
10
|
+
const commands = {
|
|
11
|
+
mcp: join(buildDir, "mcp.js"),
|
|
12
|
+
doctor: join(buildDir, "doctor.js"),
|
|
13
|
+
demo: join(buildDir, "demo.js"),
|
|
14
|
+
verify: join(buildDir, "verify.js"),
|
|
15
|
+
start: join(buildDir, "server.js"),
|
|
16
|
+
"verify-flow": join(buildDir, "verify-flow.js"),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const cmd = process.argv[2];
|
|
20
|
+
|
|
21
|
+
if (!cmd || cmd === "--help" || cmd === "-h") {
|
|
22
|
+
console.log(`
|
|
23
|
+
\x1b[1m\x1b[35msilo-agent\x1b[0m — Encrypted Agent Memory on 0G
|
|
24
|
+
|
|
25
|
+
\x1b[1mUsage:\x1b[0m
|
|
26
|
+
silo-agent <command> [args]
|
|
27
|
+
|
|
28
|
+
\x1b[1mCommands:\x1b[0m
|
|
29
|
+
mcp Start the MCP server (for Claude Desktop / Cursor)
|
|
30
|
+
doctor Validate environment (key, RPC, balance, encryption)
|
|
31
|
+
demo Run full demo (store → retrieve → commit)
|
|
32
|
+
verify <hash> Verify stored data by root hash
|
|
33
|
+
start Start the API + WebSocket server
|
|
34
|
+
verify-flow Debug 0G Flow contract
|
|
35
|
+
|
|
36
|
+
\x1b[1mExamples:\x1b[0m
|
|
37
|
+
npx silo-agent mcp
|
|
38
|
+
npx silo-agent doctor
|
|
39
|
+
npx silo-agent demo
|
|
40
|
+
npx silo-agent verify 0xabc123...
|
|
41
|
+
`);
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!commands[cmd]) {
|
|
46
|
+
console.error(`Unknown command: ${cmd}\nRun 'silo-agent --help' for available commands.`);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const args = [commands[cmd], ...process.argv.slice(3)];
|
|
51
|
+
try {
|
|
52
|
+
execFileSync("node", args, { stdio: "inherit", env: process.env });
|
|
53
|
+
} catch (e) {
|
|
54
|
+
process.exit(e.status ?? 1);
|
|
55
|
+
}
|
package/build/demo.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SILO — Demo
|
|
3
|
+
*
|
|
4
|
+
* Runs a complete end-to-end cycle that you can show judges:
|
|
5
|
+
* 1. Store encrypted data
|
|
6
|
+
* 2. Retrieve and decrypt it
|
|
7
|
+
* 3. Store a second piece of data
|
|
8
|
+
* 4. Commit the attestation session
|
|
9
|
+
* 5. Verify the attestation trace
|
|
10
|
+
*
|
|
11
|
+
* Usage: npm run demo
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
package/build/demo.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SILO — Demo
|
|
3
|
+
*
|
|
4
|
+
* Runs a complete end-to-end cycle that you can show judges:
|
|
5
|
+
* 1. Store encrypted data
|
|
6
|
+
* 2. Retrieve and decrypt it
|
|
7
|
+
* 3. Store a second piece of data
|
|
8
|
+
* 4. Commit the attestation session
|
|
9
|
+
* 5. Verify the attestation trace
|
|
10
|
+
*
|
|
11
|
+
* Usage: npm run demo
|
|
12
|
+
*/
|
|
13
|
+
import { AgentVault } from "./lib/vault.js";
|
|
14
|
+
import dotenv from "dotenv";
|
|
15
|
+
dotenv.config();
|
|
16
|
+
async function demo() {
|
|
17
|
+
console.log(`\n${"═".repeat(60)}`);
|
|
18
|
+
console.log(` 🛡️ SILO — Full Demo`);
|
|
19
|
+
console.log(`${"═".repeat(60)}\n`);
|
|
20
|
+
const vault = new AgentVault({
|
|
21
|
+
privateKey: process.env.PRIVATE_KEY,
|
|
22
|
+
evmRpc: process.env.EVM_RPC,
|
|
23
|
+
indexerRpc: process.env.INDEXER_RPC,
|
|
24
|
+
vaultSecret: process.env.VAULT_SECRET,
|
|
25
|
+
});
|
|
26
|
+
await vault.init();
|
|
27
|
+
console.log(`Agent: ${vault.address}`);
|
|
28
|
+
console.log(`Balance: ${await vault.getBalance()} 0G\n`);
|
|
29
|
+
// --- Step 1: Store sensitive data ---
|
|
30
|
+
console.log(`${"─".repeat(60)}`);
|
|
31
|
+
console.log(`Step 1: Encrypting and storing sensitive data on 0G...\n`);
|
|
32
|
+
const sensitiveData = "Patient: Jane Doe | Diagnosis: Type 2 Diabetes | A1C: 7.2% | Medication: Metformin 500mg";
|
|
33
|
+
console.log(` Plaintext: "${sensitiveData.slice(0, 40)}..."`);
|
|
34
|
+
const store1 = await vault.store(sensitiveData, "medical_record");
|
|
35
|
+
console.log(` ✅ Stored!`);
|
|
36
|
+
console.log(` Root Hash: ${store1.rootHash}`);
|
|
37
|
+
console.log(` Content Hash: ${store1.contentHash.slice(0, 24)}...`);
|
|
38
|
+
console.log(` Size: ${store1.size} bytes (encrypted)\n`);
|
|
39
|
+
// --- Step 2: Retrieve and decrypt ---
|
|
40
|
+
console.log(`${"─".repeat(60)}`);
|
|
41
|
+
console.log(`Step 2: Retrieving and decrypting from 0G...\n`);
|
|
42
|
+
const retrieved = await vault.retrieve(store1.rootHash, "medical_record_read");
|
|
43
|
+
console.log(` 🔓 Decrypted: "${retrieved.slice(0, 40)}..."`);
|
|
44
|
+
console.log(` ✅ Match: ${retrieved === sensitiveData ? "EXACT MATCH" : "MISMATCH!"}\n`);
|
|
45
|
+
// --- Step 3: Store another piece of data ---
|
|
46
|
+
console.log(`${"─".repeat(60)}`);
|
|
47
|
+
console.log(`Step 3: Storing additional agent memory...\n`);
|
|
48
|
+
const moreData = "User preference: Do not share data with insurance providers. Emergency contact: John Doe, 555-0123.";
|
|
49
|
+
const store2 = await vault.store(moreData, "user_preferences");
|
|
50
|
+
console.log(` ✅ Stored second record.`);
|
|
51
|
+
console.log(` Root Hash: ${store2.rootHash}\n`);
|
|
52
|
+
// --- Step 4: View session log ---
|
|
53
|
+
console.log(`${"─".repeat(60)}`);
|
|
54
|
+
console.log(`Step 4: Current attestation session:\n`);
|
|
55
|
+
console.log(vault.sessionSummary().split("\n").map(l => ` ${l}`).join("\n"));
|
|
56
|
+
console.log("");
|
|
57
|
+
// --- Step 5: Commit attestation ---
|
|
58
|
+
console.log(`${"─".repeat(60)}`);
|
|
59
|
+
console.log(`Step 5: Committing attestation to 0G...\n`);
|
|
60
|
+
const commit = await vault.commitSession();
|
|
61
|
+
console.log(` 🔏 Attestation committed!`);
|
|
62
|
+
console.log(` Session ID: ${commit.sessionId}`);
|
|
63
|
+
console.log(` Events: ${commit.eventCount}`);
|
|
64
|
+
console.log(` Merkle Root: ${commit.merkleRoot.slice(0, 32)}...`);
|
|
65
|
+
console.log(` Trace stored: ${commit.traceRootHash}`);
|
|
66
|
+
// --- Summary ---
|
|
67
|
+
console.log(`\n${"═".repeat(60)}`);
|
|
68
|
+
console.log(` Demo Complete!`);
|
|
69
|
+
console.log(`${"═".repeat(60)}`);
|
|
70
|
+
console.log(`
|
|
71
|
+
What just happened:
|
|
72
|
+
1. Sensitive medical data was encrypted client-side (AES-256-GCM)
|
|
73
|
+
2. Encrypted blob was stored on 0G's decentralized storage
|
|
74
|
+
3. Data was retrieved and decrypted — only the agent holder can read it
|
|
75
|
+
4. Every action was recorded in an attestation session
|
|
76
|
+
5. The session was finalized into a Merkle root commitment
|
|
77
|
+
6. The encrypted full trace was stored on 0G for future audit
|
|
78
|
+
|
|
79
|
+
To verify any stored data:
|
|
80
|
+
npm run verify -- ${store1.rootHash}
|
|
81
|
+
|
|
82
|
+
To inspect the attestation trace:
|
|
83
|
+
npm run verify -- ${commit.traceRootHash} --trace
|
|
84
|
+
`);
|
|
85
|
+
}
|
|
86
|
+
demo().catch((err) => {
|
|
87
|
+
console.error("\n❌ Demo failed:", err.message);
|
|
88
|
+
console.error("\nRun 'npm run doctor' to diagnose setup issues.");
|
|
89
|
+
process.exit(1);
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=demo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.js","sourceRoot":"","sources":["../src/demo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,KAAK,UAAU,IAAI;IACjB,OAA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C,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/build/doctor.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SILO — Doctor
|
|
3
|
+
*
|
|
4
|
+
* Checks everything works before you start building:
|
|
5
|
+
* - Env vars present
|
|
6
|
+
* - RPC reachable
|
|
7
|
+
* - Wallet has balance
|
|
8
|
+
* - Indexer reachable
|
|
9
|
+
* - Encryption works
|
|
10
|
+
*
|
|
11
|
+
* Usage: npm run doctor
|
|
12
|
+
*/
|
|
13
|
+
import { ethers } from "ethers";
|
|
14
|
+
import { VaultCrypto } from "./lib/crypto.js";
|
|
15
|
+
import dotenv from "dotenv";
|
|
16
|
+
dotenv.config();
|
|
17
|
+
const checks = [
|
|
18
|
+
{
|
|
19
|
+
name: "PRIVATE_KEY set",
|
|
20
|
+
fn: async () => {
|
|
21
|
+
if (!process.env.PRIVATE_KEY)
|
|
22
|
+
throw new Error("Missing in .env");
|
|
23
|
+
if (process.env.PRIVATE_KEY === "your_private_key_here")
|
|
24
|
+
throw new Error("Still set to placeholder");
|
|
25
|
+
return `${process.env.PRIVATE_KEY.slice(0, 6)}...`;
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "EVM RPC reachable",
|
|
30
|
+
fn: async () => {
|
|
31
|
+
const provider = new ethers.JsonRpcProvider(process.env.EVM_RPC);
|
|
32
|
+
const network = await provider.getNetwork();
|
|
33
|
+
const chainId = Number(network.chainId);
|
|
34
|
+
// Galileo Testnet = 16602, Mainnet = 16661
|
|
35
|
+
if (chainId !== 16602 && chainId !== 16661) {
|
|
36
|
+
throw new Error(`Unexpected chain ID ${chainId}. Expected 16602 (Galileo testnet) or 16661 (mainnet)`);
|
|
37
|
+
}
|
|
38
|
+
const label = chainId === 16602 ? "Galileo Testnet" : "Mainnet";
|
|
39
|
+
return `${label} (Chain ID: ${chainId})`;
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "Wallet balance",
|
|
44
|
+
fn: async () => {
|
|
45
|
+
const provider = new ethers.JsonRpcProvider(process.env.EVM_RPC);
|
|
46
|
+
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
|
|
47
|
+
const balance = await provider.getBalance(wallet.address);
|
|
48
|
+
const formatted = ethers.formatEther(balance);
|
|
49
|
+
if (parseFloat(formatted) === 0) {
|
|
50
|
+
throw new Error(`0 balance — get testnet tokens from https://faucet.0g.ai`);
|
|
51
|
+
}
|
|
52
|
+
return `${formatted} 0G (${wallet.address.slice(0, 10)}...)`;
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "Indexer RPC reachable",
|
|
57
|
+
fn: async () => {
|
|
58
|
+
// Simple fetch to check the indexer is up
|
|
59
|
+
const url = process.env.INDEXER_RPC;
|
|
60
|
+
// The indexer doesn't have a simple health endpoint,
|
|
61
|
+
// so we just verify the URL is set and looks valid
|
|
62
|
+
if (!url.startsWith("http"))
|
|
63
|
+
throw new Error("Invalid URL");
|
|
64
|
+
return url;
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "Encryption round-trip",
|
|
69
|
+
fn: async () => {
|
|
70
|
+
const crypto = new VaultCrypto();
|
|
71
|
+
await crypto.init(process.env.PRIVATE_KEY);
|
|
72
|
+
const original = "doctor-test-" + Date.now();
|
|
73
|
+
const encrypted = await crypto.encrypt(original);
|
|
74
|
+
const decrypted = await crypto.decrypt(encrypted);
|
|
75
|
+
if (decrypted !== original)
|
|
76
|
+
throw new Error("Decrypt mismatch!");
|
|
77
|
+
return "AES-256-GCM ✓";
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
async function doctor() {
|
|
82
|
+
console.log(`\n🛡️ SILO — Doctor\n`);
|
|
83
|
+
let allPassed = true;
|
|
84
|
+
for (const check of checks) {
|
|
85
|
+
try {
|
|
86
|
+
const result = await check.fn();
|
|
87
|
+
console.log(` ✅ ${check.name}: ${result}`);
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
console.log(` ❌ ${check.name}: ${err.message}`);
|
|
91
|
+
allPassed = false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
console.log("");
|
|
95
|
+
if (allPassed) {
|
|
96
|
+
console.log(` 🎉 All checks passed. You're ready to build.\n`);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
console.log(` ⚠️ Some checks failed. Fix the issues above and re-run.\n`);
|
|
100
|
+
console.log(` Need help?`);
|
|
101
|
+
console.log(` • Get testnet tokens: https://faucet.0g.ai`);
|
|
102
|
+
console.log(` • 0G docs: https://docs.0g.ai`);
|
|
103
|
+
console.log(` • SDK reference: https://build.0g.ai/sdks\n`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
doctor();
|
|
108
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAOhB,MAAM,MAAM,GAAY;IACtB;QACE,IAAI,EAAE,iBAAiB;QACvB,EAAE,EAAE,KAAK,IAAI,EAAE;YACb,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW;gBA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AAG,CAAC,wBAAwB,CAAC,CAAC;IAEtC,IAAI,SAAS,GAAG,IAAI,CAAC;IAErB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,EAAE,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YACjD,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;IAClE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC;QAC5E,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;QACjD,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;QAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,MAAM,EAAE,CAAC"}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 0G Agent Shield — Public API
|
|
3
|
+
*
|
|
4
|
+
* Import everything you need from one place:
|
|
5
|
+
* import { AgentVault, SharedMemoryBus, HeartbeatDaemon, AgentRouter, AutonomyEngine } from "0g-agent-shield";
|
|
6
|
+
*/
|
|
7
|
+
export { AgentVault, type VaultConfig, type StoreResult, type CommitResult } from "./lib/vault.js";
|
|
8
|
+
export { VaultCrypto, type EncryptedPayload } from "./lib/crypto.js";
|
|
9
|
+
export { StorageClient, type UploadResult } from "./lib/storage.js";
|
|
10
|
+
export { AttestationSession, type AttestationEvent, type SessionAttestation } from "./lib/attestation.js";
|
|
11
|
+
export { SharedMemoryBus, type MemoryEntry, type ChannelManifest, type ChannelSubscription, type ChannelSchema, type WriteResult } from "./lib/shared-memory.js";
|
|
12
|
+
export { MemoryCoordinator, type ChannelLock, type ChannelHead, type WriteReceipt, type ForkRecord, type CoordinatorConfig } from "./lib/memory-coordinator.js";
|
|
13
|
+
export { MemoryIndex, type IndexEntry, type SearchQuery, type IndexSnapshot } from "./lib/memory-index.js";
|
|
14
|
+
export { HeartbeatDaemon, type HeartbeatConfig, type HeartbeatTask, type HeartbeatRecord, type TaskResult, type TaskContext } from "./lib/heartbeat.js";
|
|
15
|
+
export { AgentRouter, type SubAgentDescriptor, type SpawnOptions, type SubAgentResult, type AgentMessage } from "./lib/agent-router.js";
|
|
16
|
+
export { AutonomyEngine, type AutonomyConfig, type AutonomyLevel, type DiagnosticHandler, type AutonomyDecision, type AutonomyFix } from "./lib/autonomy.js";
|
package/build/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 0G Agent Shield — Public API
|
|
3
|
+
*
|
|
4
|
+
* Import everything you need from one place:
|
|
5
|
+
* import { AgentVault, SharedMemoryBus, HeartbeatDaemon, AgentRouter, AutonomyEngine } from "0g-agent-shield";
|
|
6
|
+
*/
|
|
7
|
+
export { AgentVault } from "./lib/vault.js";
|
|
8
|
+
export { VaultCrypto } from "./lib/crypto.js";
|
|
9
|
+
export { StorageClient } from "./lib/storage.js";
|
|
10
|
+
export { AttestationSession } from "./lib/attestation.js";
|
|
11
|
+
export { SharedMemoryBus } from "./lib/shared-memory.js";
|
|
12
|
+
export { MemoryCoordinator } from "./lib/memory-coordinator.js";
|
|
13
|
+
export { MemoryIndex } from "./lib/memory-index.js";
|
|
14
|
+
export { HeartbeatDaemon } from "./lib/heartbeat.js";
|
|
15
|
+
export { AgentRouter } from "./lib/agent-router.js";
|
|
16
|
+
export { AutonomyEngine } from "./lib/autonomy.js";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAyD,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,WAAW,EAAyB,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAqB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAkD,MAAM,sBAAsB,CAAC;AAC1G,OAAO,EAAE,eAAe,EAA0G,MAAM,wBAAwB,CAAC;AACjK,OAAO,EAAE,iBAAiB,EAAkG,MAAM,6BAA6B,CAAC;AAChK,OAAO,EAAE,WAAW,EAAyD,MAAM,uBAAuB,CAAC;AAC3G,OAAO,EAAE,eAAe,EAAqG,MAAM,oBAAoB,CAAC;AACxJ,OAAO,EAAE,WAAW,EAAsF,MAAM,uBAAuB,CAAC;AACxI,OAAO,EAAE,cAAc,EAA4G,MAAM,mBAAmB,CAAC"}
|