create-silo-app 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/package.json +22 -0
- package/src/index.js +263 -0
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-silo-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Scaffold a SILO-powered AI agent with encrypted memory on 0G",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-silo-app": "./src/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"0g",
|
|
14
|
+
"ai-agents",
|
|
15
|
+
"mcp",
|
|
16
|
+
"scaffold",
|
|
17
|
+
"silo",
|
|
18
|
+
"encrypted-memory",
|
|
19
|
+
"model-context-protocol"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT"
|
|
22
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
import { execSync } from 'node:child_process';
|
|
6
|
+
|
|
7
|
+
const BOLD = '\x1b[1m';
|
|
8
|
+
const DIM = '\x1b[2m';
|
|
9
|
+
const RESET = '\x1b[0m';
|
|
10
|
+
const PURPLE = '\x1b[35m';
|
|
11
|
+
const GREEN = '\x1b[32m';
|
|
12
|
+
const CYAN = '\x1b[36m';
|
|
13
|
+
const YELLOW = '\x1b[33m';
|
|
14
|
+
|
|
15
|
+
function log(msg) { console.log(msg); }
|
|
16
|
+
function step(msg) { log(`\n${PURPLE}>${RESET} ${msg}`); }
|
|
17
|
+
function done(msg) { log(` ${GREEN}✓${RESET} ${msg}`); }
|
|
18
|
+
|
|
19
|
+
// ── Parse args ──
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
const projectName = args[0];
|
|
22
|
+
|
|
23
|
+
if (!projectName || projectName === '--help' || projectName === '-h') {
|
|
24
|
+
log(`
|
|
25
|
+
${BOLD}${PURPLE}create-silo-app${RESET} — Scaffold an AI agent with encrypted memory on 0G
|
|
26
|
+
|
|
27
|
+
${BOLD}Usage:${RESET}
|
|
28
|
+
npx create-silo-app ${CYAN}my-agent${RESET}
|
|
29
|
+
|
|
30
|
+
${BOLD}What it creates:${RESET}
|
|
31
|
+
my-agent/
|
|
32
|
+
├── src/
|
|
33
|
+
│ └── agent.ts ${DIM}# Example: store, retrieve, commit${RESET}
|
|
34
|
+
├── package.json ${DIM}# Dependencies pre-configured${RESET}
|
|
35
|
+
├── tsconfig.json
|
|
36
|
+
├── .env ${DIM}# Add your private key here${RESET}
|
|
37
|
+
├── claude-desktop-config.json
|
|
38
|
+
└── README.md
|
|
39
|
+
|
|
40
|
+
${BOLD}Then:${RESET}
|
|
41
|
+
cd my-agent
|
|
42
|
+
npm install
|
|
43
|
+
${DIM}# Add your private key to .env${RESET}
|
|
44
|
+
npm run build && npm run demo
|
|
45
|
+
`);
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const projectDir = resolve(projectName);
|
|
50
|
+
|
|
51
|
+
if (existsSync(projectDir)) {
|
|
52
|
+
log(`\n${YELLOW}Error:${RESET} Directory "${projectName}" already exists.\n`);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
log(`\n${BOLD}${PURPLE}SILO${RESET} ${DIM}— Encrypted Agent Memory on 0G${RESET}\n`);
|
|
57
|
+
step(`Creating project: ${BOLD}${projectName}${RESET}`);
|
|
58
|
+
|
|
59
|
+
mkdirSync(join(projectDir, 'src'), { recursive: true });
|
|
60
|
+
|
|
61
|
+
// ── package.json ──
|
|
62
|
+
writeFileSync(join(projectDir, 'package.json'), JSON.stringify({
|
|
63
|
+
name: projectName,
|
|
64
|
+
version: '0.1.0',
|
|
65
|
+
type: 'module',
|
|
66
|
+
scripts: {
|
|
67
|
+
build: 'tsc',
|
|
68
|
+
demo: 'node build/agent.js',
|
|
69
|
+
doctor: 'npx silo-agent doctor',
|
|
70
|
+
},
|
|
71
|
+
dependencies: {
|
|
72
|
+
'silo-agent': '^1.0.0',
|
|
73
|
+
dotenv: '^16.4.7',
|
|
74
|
+
},
|
|
75
|
+
devDependencies: {
|
|
76
|
+
'@types/node': '^22.10.10',
|
|
77
|
+
typescript: '^5.7.3',
|
|
78
|
+
},
|
|
79
|
+
}, null, 2) + '\n');
|
|
80
|
+
done('package.json');
|
|
81
|
+
|
|
82
|
+
// ── tsconfig.json ──
|
|
83
|
+
writeFileSync(join(projectDir, 'tsconfig.json'), JSON.stringify({
|
|
84
|
+
compilerOptions: {
|
|
85
|
+
target: 'ES2022',
|
|
86
|
+
module: 'NodeNext',
|
|
87
|
+
moduleResolution: 'NodeNext',
|
|
88
|
+
outDir: './build',
|
|
89
|
+
rootDir: './src',
|
|
90
|
+
strict: true,
|
|
91
|
+
esModuleInterop: true,
|
|
92
|
+
skipLibCheck: true,
|
|
93
|
+
declaration: true,
|
|
94
|
+
sourceMap: true,
|
|
95
|
+
},
|
|
96
|
+
include: ['src/**/*'],
|
|
97
|
+
exclude: ['node_modules', 'build'],
|
|
98
|
+
}, null, 2) + '\n');
|
|
99
|
+
done('tsconfig.json');
|
|
100
|
+
|
|
101
|
+
// ── .env ──
|
|
102
|
+
writeFileSync(join(projectDir, '.env'), `# SILO Configuration
|
|
103
|
+
# Get testnet tokens: https://faucet.0g.ai
|
|
104
|
+
|
|
105
|
+
# Your wallet private key (no 0x prefix)
|
|
106
|
+
PRIVATE_KEY=your_private_key_here
|
|
107
|
+
|
|
108
|
+
# 0G Network RPCs (testnet defaults)
|
|
109
|
+
EVM_RPC=https://evmrpc-testnet.0g.ai
|
|
110
|
+
INDEXER_RPC=https://indexer-storage-testnet-turbo.0g.ai
|
|
111
|
+
|
|
112
|
+
# Optional: custom encryption passphrase (defaults to PRIVATE_KEY)
|
|
113
|
+
# VAULT_SECRET=your_custom_passphrase
|
|
114
|
+
`);
|
|
115
|
+
done('.env');
|
|
116
|
+
|
|
117
|
+
// ── .gitignore ──
|
|
118
|
+
writeFileSync(join(projectDir, '.gitignore'), `node_modules/
|
|
119
|
+
build/
|
|
120
|
+
.env
|
|
121
|
+
*.js.map
|
|
122
|
+
.DS_Store
|
|
123
|
+
`);
|
|
124
|
+
done('.gitignore');
|
|
125
|
+
|
|
126
|
+
// ── claude-desktop-config.json ──
|
|
127
|
+
writeFileSync(join(projectDir, 'claude-desktop-config.json'), JSON.stringify({
|
|
128
|
+
mcpServers: {
|
|
129
|
+
silo: {
|
|
130
|
+
command: 'npx',
|
|
131
|
+
args: ['silo-agent', 'mcp'],
|
|
132
|
+
env: {
|
|
133
|
+
PRIVATE_KEY: 'your_private_key',
|
|
134
|
+
EVM_RPC: 'https://evmrpc-testnet.0g.ai',
|
|
135
|
+
INDEXER_RPC: 'https://indexer-storage-testnet-turbo.0g.ai',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
}, null, 2) + '\n');
|
|
140
|
+
done('claude-desktop-config.json');
|
|
141
|
+
|
|
142
|
+
// ── src/agent.ts ──
|
|
143
|
+
writeFileSync(join(projectDir, 'src/agent.ts'), `/**
|
|
144
|
+
* ${projectName} — AI Agent with Encrypted Memory on 0G
|
|
145
|
+
*
|
|
146
|
+
* Scaffolded with create-silo-app
|
|
147
|
+
*
|
|
148
|
+
* This example demonstrates:
|
|
149
|
+
* 1. Storing encrypted data on 0G
|
|
150
|
+
* 2. Retrieving and decrypting it
|
|
151
|
+
* 3. Committing a Merkle attestation of the session
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
import { AgentVault } from "silo-agent";
|
|
155
|
+
import dotenv from "dotenv";
|
|
156
|
+
|
|
157
|
+
dotenv.config();
|
|
158
|
+
|
|
159
|
+
async function main() {
|
|
160
|
+
// ── Initialize the vault ──
|
|
161
|
+
const vault = new AgentVault({
|
|
162
|
+
privateKey: process.env.PRIVATE_KEY!,
|
|
163
|
+
evmRpc: process.env.EVM_RPC!,
|
|
164
|
+
indexerRpc: process.env.INDEXER_RPC!,
|
|
165
|
+
vaultSecret: process.env.VAULT_SECRET,
|
|
166
|
+
});
|
|
167
|
+
await vault.init();
|
|
168
|
+
|
|
169
|
+
console.log(\`\\n\${"═".repeat(50)}\`);
|
|
170
|
+
console.log(\` SILO — \${vault.address.slice(0, 10)}...\`);
|
|
171
|
+
console.log(\`\${"═".repeat(50)}\\n\`);
|
|
172
|
+
|
|
173
|
+
// ── 1. Store encrypted data ──
|
|
174
|
+
console.log("1. Storing encrypted data on 0G...");
|
|
175
|
+
const { rootHash, contentHash, size } = await vault.store(
|
|
176
|
+
"Sensitive agent memory: patient vitals HR 72, BP 120/80",
|
|
177
|
+
"medical_data"
|
|
178
|
+
);
|
|
179
|
+
console.log(\` Root Hash: \${rootHash}\`);
|
|
180
|
+
console.log(\` Content Hash: \${contentHash.slice(0, 16)}...\`);
|
|
181
|
+
console.log(\` Size: \${size} bytes\\n\`);
|
|
182
|
+
|
|
183
|
+
// ── 2. Retrieve and decrypt ──
|
|
184
|
+
console.log("2. Retrieving and decrypting from 0G...");
|
|
185
|
+
const decrypted = await vault.retrieve(rootHash);
|
|
186
|
+
console.log(\` Decrypted: \${decrypted}\\n\`);
|
|
187
|
+
|
|
188
|
+
// ── 3. Commit attestation ──
|
|
189
|
+
console.log("3. Committing Merkle attestation to 0G...");
|
|
190
|
+
const proof = await vault.commitSession();
|
|
191
|
+
console.log(\` Session ID: \${proof.sessionId}\`);
|
|
192
|
+
console.log(\` Events: \${proof.eventCount}\`);
|
|
193
|
+
console.log(\` Merkle Root: \${proof.merkleRoot.slice(0, 32)}...\`);
|
|
194
|
+
console.log(\` Trace Hash: \${proof.traceRootHash}\\n\`);
|
|
195
|
+
|
|
196
|
+
console.log("Done. Your agent's memory is encrypted and attested on 0G.");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
main().catch((err) => {
|
|
200
|
+
console.error("Error:", err.message);
|
|
201
|
+
process.exit(1);
|
|
202
|
+
});
|
|
203
|
+
`);
|
|
204
|
+
done('src/agent.ts');
|
|
205
|
+
|
|
206
|
+
// ── README.md ──
|
|
207
|
+
writeFileSync(join(projectDir, 'README.md'), `# ${projectName}
|
|
208
|
+
|
|
209
|
+
AI agent with encrypted memory on 0G, powered by [SILO](https://github.com/rohanpotta/ethdenverhack).
|
|
210
|
+
|
|
211
|
+
## Quick Start
|
|
212
|
+
|
|
213
|
+
\`\`\`bash
|
|
214
|
+
# Install dependencies
|
|
215
|
+
npm install
|
|
216
|
+
|
|
217
|
+
# Add your private key to .env
|
|
218
|
+
# Get testnet tokens: https://faucet.0g.ai
|
|
219
|
+
|
|
220
|
+
# Build and run the demo
|
|
221
|
+
npm run build
|
|
222
|
+
npm run demo
|
|
223
|
+
\`\`\`
|
|
224
|
+
|
|
225
|
+
## Connect to Claude Desktop
|
|
226
|
+
|
|
227
|
+
Copy \`claude-desktop-config.json\` contents into:
|
|
228
|
+
- **Mac**: \`~/Library/Application Support/Claude/claude_desktop_config.json\`
|
|
229
|
+
- **Windows**: \`%APPDATA%\\\\Claude\\\\claude_desktop_config.json\`
|
|
230
|
+
|
|
231
|
+
Then restart Claude Desktop. Your agent now has 8 vault tools available.
|
|
232
|
+
|
|
233
|
+
## What This Does
|
|
234
|
+
|
|
235
|
+
- **\`vault_store\`** — Encrypts data with AES-256-GCM and uploads to 0G Storage
|
|
236
|
+
- **\`vault_retrieve\`** — Downloads and decrypts from 0G
|
|
237
|
+
- **\`vault_share\`** / **\`vault_import\`** — Share encrypted memories between agents
|
|
238
|
+
- **\`session_commit\`** — Publishes a Merkle root proving what the agent did
|
|
239
|
+
|
|
240
|
+
## Learn More
|
|
241
|
+
|
|
242
|
+
- [SILO Documentation](https://github.com/rohanpotta/ethdenverhack)
|
|
243
|
+
- [0G Docs](https://docs.0g.ai)
|
|
244
|
+
- [0G Faucet](https://faucet.0g.ai)
|
|
245
|
+
`);
|
|
246
|
+
done('README.md');
|
|
247
|
+
|
|
248
|
+
// ── Install ──
|
|
249
|
+
step('Installing dependencies...');
|
|
250
|
+
try {
|
|
251
|
+
execSync('npm install', { cwd: projectDir, stdio: 'pipe' });
|
|
252
|
+
done('Dependencies installed');
|
|
253
|
+
} catch {
|
|
254
|
+
log(` ${YELLOW}!${RESET} npm install failed — run it manually: cd ${projectName} && npm install`);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// ── Done ──
|
|
258
|
+
log(`\n${GREEN}${BOLD}Done!${RESET} Your SILO agent is ready.\n`);
|
|
259
|
+
log(` ${CYAN}cd ${projectName}${RESET}`);
|
|
260
|
+
log(` ${DIM}# Edit .env with your private key${RESET}`);
|
|
261
|
+
log(` ${CYAN}npm run build && npm run demo${RESET}\n`);
|
|
262
|
+
log(` ${DIM}To connect to Claude Desktop:${RESET}`);
|
|
263
|
+
log(` ${DIM}Copy claude-desktop-config.json into your Claude config${RESET}\n`);
|