ape-claw 0.1.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.
Files changed (114) hide show
  1. package/.cursor/skills/ape-claw/SKILL.md +322 -0
  2. package/LICENSE +21 -0
  3. package/README.md +826 -0
  4. package/allowlists/opensea-slug-overrides.json +13 -0
  5. package/allowlists/recommended.apechain.json +322 -0
  6. package/config/clawbots.example.json +3 -0
  7. package/config/policy.example.json +27 -0
  8. package/data/starter-pack-bundle.json +1 -0
  9. package/data/starter-pack.json +495 -0
  10. package/docs/ACP_BOUNTIES.md +108 -0
  11. package/docs/APECLAW_V2_ALPHA.md +206 -0
  12. package/docs/AUTONOMY_AND_SUBSTRATE.md +69 -0
  13. package/docs/CLAWBOTS_AND_INVITES.md +102 -0
  14. package/docs/CLI_GUIDE.md +124 -0
  15. package/docs/CONTRIBUTING.md +130 -0
  16. package/docs/DASHBOARD_GUIDE.md +108 -0
  17. package/docs/GLOBAL_BACKEND.md +145 -0
  18. package/docs/ONCHAIN_V2_GUIDE.md +140 -0
  19. package/docs/PRODUCT_OVERVIEW.md +127 -0
  20. package/docs/README.md +40 -0
  21. package/docs/SKILLCARDS_AND_IMPORTER.md +147 -0
  22. package/docs/STARTER_PACK.md +297 -0
  23. package/docs/SUPPORTED_NETWORKS.md +58 -0
  24. package/docs/TELEMETRY_AND_EVENTS.md +103 -0
  25. package/docs/THE_POD_RUNNER.md +198 -0
  26. package/docs/V1_WORKFLOWS.md +108 -0
  27. package/docs/V2_ONCHAIN_SKILLS.md +157 -0
  28. package/docs/WEB4_PLAN_STATUS.md +95 -0
  29. package/docs/WEB4_SWARM_MODEL.md +104 -0
  30. package/docs/archive/AUTONOMY_AND_SUBSTRATE.md +66 -0
  31. package/docs/archive/WEB4_PLAN_STATUS.md +93 -0
  32. package/docs/archive/WEB4_SWARM_MODEL.md +98 -0
  33. package/docs/developer/01-architecture.md +345 -0
  34. package/docs/developer/02-contracts.md +1034 -0
  35. package/docs/developer/03-writing-modules.md +513 -0
  36. package/docs/developer/04-skillcard-spec.md +336 -0
  37. package/docs/developer/05-backend-api.md +1079 -0
  38. package/docs/developer/06-telemetry.md +798 -0
  39. package/docs/developer/07-testing.md +546 -0
  40. package/docs/developer/08-contributing.md +211 -0
  41. package/docs/operator/01-quickstart.md +49 -0
  42. package/docs/operator/02-dashboard.md +174 -0
  43. package/docs/operator/03-cli-reference.md +818 -0
  44. package/docs/operator/04-skills-library.md +169 -0
  45. package/docs/operator/05-pod-operations.md +314 -0
  46. package/docs/operator/06-deployment.md +299 -0
  47. package/docs/operator/07-safety-and-policy.md +311 -0
  48. package/docs/operator/08-troubleshooting.md +457 -0
  49. package/docs/operator/09-env-reference.md +238 -0
  50. package/docs/social/STARTER_PACK_THREAD.md +209 -0
  51. package/package.json +77 -0
  52. package/skillcards/import-sources.json +93 -0
  53. package/skillcards/seed/acp-bounty-poll.v1.json +38 -0
  54. package/skillcards/seed/acp-bounty-post.v1.json +55 -0
  55. package/skillcards/seed/acp-browse.v1.json +41 -0
  56. package/skillcards/seed/acp-fulfill-and-route.v1.json +56 -0
  57. package/skillcards/seed/apeclaw-bridge-relay.v1.json +46 -0
  58. package/skillcards/seed/apeclaw-nft-autobuy.v1.json +60 -0
  59. package/skillcards/seed/apeclaw-receipt-recorder.v1.json +64 -0
  60. package/skillcards/seed/humanizer.v1.json +74 -0
  61. package/skillcards/seed/otherside-navigator.v1.json +116 -0
  62. package/skillcards/seed/stonkbrokers-launcher.v1.json +280 -0
  63. package/skillcards/seed/walkie-p2p.v1.json +66 -0
  64. package/src/cli/index.mjs +8 -0
  65. package/src/cli.mjs +1929 -0
  66. package/src/lib/bridge-relay.mjs +294 -0
  67. package/src/lib/clawbots.mjs +94 -0
  68. package/src/lib/io.mjs +36 -0
  69. package/src/lib/market.mjs +233 -0
  70. package/src/lib/nft-opensea.mjs +159 -0
  71. package/src/lib/paths.mjs +17 -0
  72. package/src/lib/pod-init.mjs +40 -0
  73. package/src/lib/policy.mjs +112 -0
  74. package/src/lib/rpc.mjs +49 -0
  75. package/src/lib/telemetry.mjs +92 -0
  76. package/src/lib/v2-onchain-abi.mjs +294 -0
  77. package/src/lib/v2-skillcard.mjs +27 -0
  78. package/src/server/index.mjs +169 -0
  79. package/src/server/logger.mjs +21 -0
  80. package/src/server/middleware/auth.mjs +90 -0
  81. package/src/server/middleware/body-limit.mjs +35 -0
  82. package/src/server/middleware/cors.mjs +33 -0
  83. package/src/server/middleware/rate-limit.mjs +44 -0
  84. package/src/server/routes/chat.mjs +178 -0
  85. package/src/server/routes/clawbots.mjs +182 -0
  86. package/src/server/routes/events.mjs +95 -0
  87. package/src/server/routes/health.mjs +72 -0
  88. package/src/server/routes/pod.mjs +64 -0
  89. package/src/server/routes/quotes.mjs +161 -0
  90. package/src/server/routes/skills.mjs +239 -0
  91. package/src/server/routes/static.mjs +161 -0
  92. package/src/server/routes/v2.mjs +48 -0
  93. package/src/server/sse.mjs +73 -0
  94. package/src/server/storage/file-backend.mjs +295 -0
  95. package/src/server/storage/index.mjs +37 -0
  96. package/src/server/storage/sqlite-backend.mjs +380 -0
  97. package/src/telemetry-server.mjs +1604 -0
  98. package/ui/css/dashboard.css +792 -0
  99. package/ui/css/skills.css +689 -0
  100. package/ui/docs.html +840 -0
  101. package/ui/favicon-180.png +0 -0
  102. package/ui/favicon-192.png +0 -0
  103. package/ui/favicon-32.png +0 -0
  104. package/ui/favicon-lobster.png +0 -0
  105. package/ui/favicon.svg +10 -0
  106. package/ui/index.html +2957 -0
  107. package/ui/js/dashboard.js +1766 -0
  108. package/ui/js/skills.js +1621 -0
  109. package/ui/pod.html +909 -0
  110. package/ui/shared/motion.css +286 -0
  111. package/ui/shared/motion.js +170 -0
  112. package/ui/shared/sidebar-nav.css +379 -0
  113. package/ui/shared/sidebar-nav.js +137 -0
  114. package/ui/skills.html +2879 -0
@@ -0,0 +1,457 @@
1
+ # Troubleshooting Guide
2
+
3
+ This guide covers common issues and their solutions when operating ApeClaw.
4
+
5
+ ## Common Issues
6
+
7
+ | Symptom | Cause | Fix |
8
+ |---------|-------|-----|
9
+ | `EADDRINUSE` error on server start | Port 8787 already in use | Change port: `export APE_CLAW_UI_PORT=8788` or kill existing process |
10
+ | 404 on `/ui`, `/skills`, `/pod` pages | Server not running or wrong port | Start server: `node src/telemetry-server.mjs` or check `APE_CLAW_UI_PORT` |
11
+ | Transaction reverts with "PolicyEngine: module not allowed" | Module not allowlisted | Call `PolicyEngine.setModuleAllowed(moduleAddress, true)` |
12
+ | Transaction reverts with "PolicyEngine: target not allowed" | Target contract not allowlisted | Call `PolicyEngine.setTargetAllowed(targetAddress, true)` |
13
+ | Transaction reverts with "PolicyEngine: value exceeds cap" | Transaction value exceeds `maxValuePerTx` | Reduce value or increase cap in PolicyEngine |
14
+ | `Missing --rpc` error | RPC URL not set | Set `APE_CLAW_V2_RPC_URL` or use `--rpc` flag |
15
+ | `Missing --privateKey` error | Private key not set | Set `APE_CLAW_V2_PRIVATE_KEY` or use `--privateKey` flag |
16
+ | `Missing --skillNft` error | SkillNFT address not set | Set `APE_CLAW_V2_SKILL_NFT` or use `--skillNft` flag |
17
+ | `Missing --registry` error | SkillRegistry address not set | Set `APE_CLAW_V2_SKILL_REGISTRY` or use `--registry` flag |
18
+ | PolicyEngine blocking transactions | Module/target/selector not allowlisted | Add to allowlist via PolicyEngine contract |
19
+ | PodVault release failing | Insufficient gas or invalid member | Check member address, ensure sufficient gas, verify member exists |
20
+ | Skill not appearing in UI | Not indexed or invalid JSON | Check `skillcards/imported/index.json` or `state/skillcards-user/index.json` |
21
+ | OpenSea API key not injected | Clawbot not verified | Run `ape-claw doctor --agent-id ... --agent-token ...` |
22
+ | Pod agent not starting | `stop.flag` present | Remove `stop.flag` file from workspace |
23
+ | Pod agent stuck | No heartbeat updates | Check `state/last-heartbeat.json`, review logs |
24
+ | Daily spend cap exceeded | Total spending exceeds cap | Wait for reset (daily) or increase cap in policy |
25
+ | Confirmation phrase mismatch | Wrong phrase provided | Use exact phrase from quote/request |
26
+ | Quote expired | Quote older than expiry time | Generate fresh quote |
27
+ | Order not found (OpenSea) | Order sniped or cancelled | System auto-retries with fresh listing (up to 3 attempts) |
28
+ | Bridge quote expired | Bridge request older than expiry | Generate fresh bridge quote |
29
+ | Receipt not found | TraceId not recorded | Verify traceId, check ReceiptRegistry address |
30
+ | Intent not found | IntentId invalid or cancelled | Verify intentId, check IntentRegistry |
31
+ | Skill publish fails | Invalid SkillCard or missing fields | Verify SkillCard JSON, check required fields (name, slug, version) |
32
+ | Skill mint fails | Invalid royalty receiver or BPS | Check royalty receiver address, ensure BPS is 0-10000 (0-100%) |
33
+ | Import fails | Invalid source or network error | Check source URL, verify network connectivity |
34
+ | Telemetry not emitting | Server not running or wrong URL | Start server, check `APE_CLAW_TELEMETRY_URL` |
35
+ | Auth verification fails | Invalid agent ID or token | Re-register clawbot or check token |
36
+ | Registration fails | Missing invite or invalid key | Use invite token or set `APE_CLAW_REGISTRATION_KEY` |
37
+ | Invite expired | Invite past TTL | Create new invite |
38
+ | Invite exhausted | Invite used max times | Create new invite |
39
+ | Rate limited | Too many registrations from IP | Wait for cooldown or use invite |
40
+
41
+ ## Detailed Troubleshooting
42
+
43
+ ### EADDRINUSE Errors
44
+
45
+ **Symptom:**
46
+ ```
47
+ Error: listen EADDRINUSE: address already in use :::8787
48
+ ```
49
+
50
+ **Cause:** Port 8787 is already in use by another process.
51
+
52
+ **Fix:**
53
+ 1. Find the process using port 8787:
54
+ ```bash
55
+ lsof -i :8787
56
+ # or
57
+ netstat -an | grep 8787
58
+ ```
59
+
60
+ 2. Kill the process or change the port:
61
+ ```bash
62
+ # Option 1: Kill existing process
63
+ kill -9 <PID>
64
+
65
+ # Option 2: Use different port
66
+ export APE_CLAW_UI_PORT=8788
67
+ node src/telemetry-server.mjs
68
+ ```
69
+
70
+ ### 404 on Pages
71
+
72
+ **Symptom:** Pages return 404 (e.g., `/ui`, `/skills`, `/pod`).
73
+
74
+ **Cause:** Server not running or wrong port.
75
+
76
+ **Fix:**
77
+ 1. Check if server is running:
78
+ ```bash
79
+ curl http://localhost:8787/api/health
80
+ ```
81
+
82
+ 2. Start server if not running:
83
+ ```bash
84
+ node src/telemetry-server.mjs
85
+ ```
86
+
87
+ 3. Check port configuration:
88
+ ```bash
89
+ echo $APE_CLAW_UI_PORT # Should be 8787 or your custom port
90
+ ```
91
+
92
+ ### Transaction Reverts
93
+
94
+ **Symptom:** Transactions revert with PolicyEngine errors.
95
+
96
+ **Cause:** PolicyEngine blocking unauthorized operations.
97
+
98
+ **Fix:**
99
+
100
+ 1. **Module not allowed:**
101
+ ```solidity
102
+ // Allowlist the module
103
+ policyEngine.setModuleAllowed(moduleAddress, true);
104
+ ```
105
+
106
+ 2. **Target not allowed:**
107
+ ```solidity
108
+ // Allowlist the target
109
+ policyEngine.setTargetAllowed(targetAddress, true);
110
+ ```
111
+
112
+ 3. **Selector not allowed:**
113
+ ```solidity
114
+ // Allowlist the selector
115
+ policyEngine.setSelectorAllowed(targetAddress, selector, true);
116
+ ```
117
+
118
+ 4. **Value exceeds cap:**
119
+ ```solidity
120
+ // Increase cap or reduce transaction value
121
+ policyEngine.setMaxValuePerTx(newMaxValue);
122
+ ```
123
+
124
+ ### Missing Environment Variables
125
+
126
+ **Symptom:** Commands fail with "Missing --rpc" or similar errors.
127
+
128
+ **Cause:** Required environment variables not set.
129
+
130
+ **Fix:**
131
+
132
+ 1. Check current values:
133
+ ```bash
134
+ ape-claw doctor --json
135
+ ```
136
+
137
+ 2. Set missing variables:
138
+ ```bash
139
+ export APE_CLAW_V2_RPC_URL=https://apechain.calderachain.xyz/http
140
+ export APE_CLAW_V2_PRIVATE_KEY=0x...
141
+ export APE_CLAW_V2_SKILL_NFT=0x...
142
+ # etc.
143
+ ```
144
+
145
+ 3. Or use command-line flags:
146
+ ```bash
147
+ ape-claw v2 skill mint \
148
+ --rpc https://apechain.calderachain.xyz/http \
149
+ --privateKey 0x... \
150
+ --skillNft 0x... \
151
+ --json
152
+ ```
153
+
154
+ ### PolicyEngine Blocking
155
+
156
+ **Symptom:** Transactions blocked by PolicyEngine.
157
+
158
+ **Cause:** Module, target, or selector not allowlisted.
159
+
160
+ **Fix:**
161
+
162
+ 1. Check PolicyEngine configuration:
163
+ ```bash
164
+ # Query contract state
165
+ # (requires contract ABI and address)
166
+ ```
167
+
168
+ 2. Allowlist required addresses:
169
+ ```bash
170
+ # Via Hardhat console or script
171
+ await policyEngine.setModuleAllowed(swapModule.address, true);
172
+ await policyEngine.setTargetAllowed(seaportAddress, true);
173
+ ```
174
+
175
+ 3. Verify allowlist status:
176
+ ```bash
177
+ ape-claw doctor --json
178
+ ```
179
+
180
+ ### PodVault Release Failing
181
+
182
+ **Symptom:** `ape-claw v2 vault release` fails.
183
+
184
+ **Cause:** Invalid member address, insufficient gas, or member doesn't exist.
185
+
186
+ **Fix:**
187
+
188
+ 1. Check vault status:
189
+ ```bash
190
+ ape-claw v2 vault status \
191
+ --rpc <RPC_URL> \
192
+ --vault <PodVault address> \
193
+ --json
194
+ ```
195
+
196
+ 2. Verify member exists and has pending balance:
197
+ ```json
198
+ {
199
+ "members": [
200
+ {
201
+ "address": "0x...",
202
+ "shares": "5000",
203
+ "pendingNative": "1000000000000000000"
204
+ }
205
+ ]
206
+ }
207
+ ```
208
+
209
+ 3. Ensure sufficient gas:
210
+ ```bash
211
+ # Check gas price and set if needed
212
+ # (viem handles this automatically, but verify RPC is responsive)
213
+ ```
214
+
215
+ 4. Verify member address matches your wallet:
216
+ ```bash
217
+ # Use the exact address from vault status
218
+ ape-claw v2 vault release \
219
+ --member 0x... \ # Exact address from status
220
+ --json
221
+ ```
222
+
223
+ ### Pod Agent Not Starting
224
+
225
+ **Symptom:** Pod agent exits immediately or doesn't start.
226
+
227
+ **Cause:** `stop.flag` present or workspace not initialized.
228
+
229
+ **Fix:**
230
+
231
+ 1. Check for stop flag:
232
+ ```bash
233
+ ls pod-workspace/stop.flag
234
+ ```
235
+
236
+ 2. Remove stop flag:
237
+ ```bash
238
+ rm pod-workspace/stop.flag
239
+ ```
240
+
241
+ 3. Verify workspace is initialized:
242
+ ```bash
243
+ ls pod-workspace/AGENTS.md
244
+ ```
245
+
246
+ 4. Re-initialize if needed:
247
+ ```bash
248
+ ape-claw pod init --dir ./pod-workspace --json
249
+ ```
250
+
251
+ ### Pod Agent Stuck
252
+
253
+ **Symptom:** No heartbeat updates, agent appears frozen.
254
+
255
+ **Cause:** Agent crashed, stuck in loop, or screenshot buffer issue.
256
+
257
+ **Fix:**
258
+
259
+ 1. Check last heartbeat:
260
+ ```bash
261
+ cat pod-workspace/state/last-heartbeat.json
262
+ ```
263
+
264
+ 2. Check logs:
265
+ ```bash
266
+ # Review journal entries
267
+ ls pod-workspace/journal/
268
+ cat pod-workspace/journal/$(date +%Y-%m-%d).md
269
+ ```
270
+
271
+ 3. Check for stuck detection:
272
+ ```bash
273
+ # Agent should detect stuck state and emit recovery plan
274
+ # Check telemetry for "pod.stuck" events
275
+ ```
276
+
277
+ 4. Restart agent:
278
+ ```bash
279
+ # Stop gracefully
280
+ touch pod-workspace/stop.flag
281
+
282
+ # Wait a moment, then remove
283
+ rm pod-workspace/stop.flag
284
+
285
+ # Restart
286
+ python3 pod/run_agent.py --enabled --dry-run
287
+ ```
288
+
289
+ ### Daily Spend Cap Exceeded
290
+
291
+ **Symptom:** Transactions fail with "Daily spend cap exceeded".
292
+
293
+ **Cause:** Total spending (NFTs + bridges) exceeds `policy.execution.dailySpendCap`.
294
+
295
+ **Fix:**
296
+
297
+ 1. Check current spending:
298
+ ```bash
299
+ # Review quotes and bridge requests
300
+ cat state/quotes.json
301
+ cat state/bridge-requests.json
302
+ ```
303
+
304
+ 2. Wait for daily reset (midnight UTC) or increase cap:
305
+ ```json
306
+ {
307
+ "execution": {
308
+ "dailySpendCap": 200000 // Increase if authorized
309
+ }
310
+ }
311
+ ```
312
+
313
+ 3. Use `--allow-unsafe` (not recommended):
314
+ ```bash
315
+ # Only if absolutely necessary and authorized
316
+ ape-claw nft buy --quote q_123 --execute --allow-unsafe --json
317
+ ```
318
+
319
+ ### Confirmation Phrase Mismatch
320
+
321
+ **Symptom:** Transaction fails with "Confirmation phrase mismatch".
322
+
323
+ **Cause:** Wrong confirmation phrase provided.
324
+
325
+ **Fix:**
326
+
327
+ 1. Use exact phrase from quote:
328
+ ```bash
329
+ # Quote shows: "BUY dsnrs #123 50 APE"
330
+ ape-claw nft buy --quote q_123 \
331
+ --execute \
332
+ --confirm "BUY dsnrs #123 50 APE" \
333
+ --json
334
+ ```
335
+
336
+ 2. Or use `--autonomous` (auto-generates correct phrase):
337
+ ```bash
338
+ ape-claw nft buy --quote q_123 \
339
+ --execute \
340
+ --autonomous \
341
+ --json
342
+ ```
343
+
344
+ ### Quote Expired
345
+
346
+ **Symptom:** Quote validation fails with "Quote expired".
347
+
348
+ **Cause:** Quote older than expiry time (default: 10 minutes).
349
+
350
+ **Fix:**
351
+
352
+ 1. Generate fresh quote:
353
+ ```bash
354
+ ape-claw nft quote-buy \
355
+ --collection dsnrs \
356
+ --tokenId 123 \
357
+ --maxPrice 50 \
358
+ --json
359
+ ```
360
+
361
+ 2. Use new quote immediately:
362
+ ```bash
363
+ ape-claw nft buy --quote <new_quote_id> --execute --json
364
+ ```
365
+
366
+ ### Order Not Found (OpenSea)
367
+
368
+ **Symptom:** NFT buy fails with "order not found".
369
+
370
+ **Cause:** Order sniped or cancelled.
371
+
372
+ **Fix:**
373
+
374
+ - System auto-retries up to 3 times:
375
+ 1. Fetches fresh listing for same collection+token
376
+ 2. Validates price is at or below confirmed price
377
+ 3. Uses new order hash if found
378
+
379
+ - If retries fail:
380
+ ```bash
381
+ # Generate fresh quote
382
+ ape-claw nft quote-buy --collection ... --tokenId ... --json
383
+ ```
384
+
385
+ ### Skill Not Appearing in UI
386
+
387
+ **Symptom:** Skill doesn't show up in `/skills` browse.
388
+
389
+ **Cause:** Not indexed or invalid JSON.
390
+
391
+ **Fix:**
392
+
393
+ 1. Check index files:
394
+ ```bash
395
+ # Imported skills
396
+ cat skillcards/imported/index.json
397
+
398
+ # User skills
399
+ cat state/skillcards-user/index.json
400
+ ```
401
+
402
+ 2. Verify SkillCard file exists and is valid JSON:
403
+ ```bash
404
+ cat skillcards/imported/my-skill.v1.json | jq .
405
+ ```
406
+
407
+ 3. Rebuild index (if needed):
408
+ ```bash
409
+ # Server rebuilds index every 60 seconds
410
+ # Or restart server to force rebuild
411
+ ```
412
+
413
+ ### OpenSea API Key Not Injected
414
+
415
+ **Symptom:** OpenSea API calls fail or `doctor` shows key missing.
416
+
417
+ **Cause:** Clawbot not verified or shared key not configured.
418
+
419
+ **Fix:**
420
+
421
+ 1. Verify clawbot:
422
+ ```bash
423
+ ape-claw doctor \
424
+ --agent-id my-bot \
425
+ --agent-token claw_... \
426
+ --json
427
+ ```
428
+
429
+ 2. Check shared key is configured (server-side):
430
+ ```bash
431
+ # In config/clawbots.json
432
+ {
433
+ "sharedOpenseaApiKey": "..."
434
+ }
435
+ ```
436
+
437
+ 3. Or set `OPENSEA_API_KEY` directly:
438
+ ```bash
439
+ export OPENSEA_API_KEY=...
440
+ ```
441
+
442
+ ## Getting Help
443
+
444
+ 1. **Check logs**: Review telemetry events and journal entries
445
+ 2. **Run doctor**: `ape-claw doctor --json` shows configuration status
446
+ 3. **Check policy**: Verify `config/policy.json` settings
447
+ 4. **Review docs**: See other operator guides for detailed information
448
+ 5. **GitHub issues**: Report bugs at https://github.com/simplefarmer69/ape-claw
449
+
450
+ ## Prevention
451
+
452
+ - **Always use `--json`**: For deterministic parsing and error messages
453
+ - **Start with dry-run**: Test workflows before execution
454
+ - **Monitor telemetry**: Watch for policy violations and errors
455
+ - **Set appropriate caps**: Configure spend caps and value limits
456
+ - **Vet skills**: Review skills before installation
457
+ - **Keep backups**: Backup workspace and state files regularly
@@ -0,0 +1,238 @@
1
+ # Environment Variables Reference
2
+
3
+ This document lists all environment variables used by ApeClaw, organized by component.
4
+
5
+ ## CLI Variables
6
+
7
+ | Variable | Description | Required | Default |
8
+ |----------|-------------|----------|---------|
9
+ | `APE_CLAW_AGENT_ID` | Clawbot agent ID for telemetry and auth | No | `"local-cli"` |
10
+ | `APE_CLAW_AGENT_TOKEN` | Clawbot auth token (shown once on registration) | No | None |
11
+ | `APE_CLAW_API_BASE` | Remote API base URL (alternative to `APE_CLAW_TELEMETRY_URL`) | No | None |
12
+ | `APE_CLAW_TELEMETRY_URL` | Telemetry server URL for event emission | No | None |
13
+ | `APE_CLAW_CHAT_URL` | Chat server URL override (defaults to telemetry URL when set) | No | None |
14
+ | `APE_CLAW_TELEMETRY_REMOTE_ONLY` | Send telemetry remotely without local `state/events.jsonl` writes | No | `false` |
15
+ | `APE_CLAW_ROOT` | Override ApeClaw root directory (`process.cwd()` by default) | No | Current working directory |
16
+ | `APE_CLAW_STATE_DIR` | Override state directory location (`<root>/state` by default) | No | `<root>/state` |
17
+ | `APE_CLAW_PRIVATE_KEY` | Wallet private key for execute flows (0x-prefixed hex) | No* | None |
18
+ | `APE_CLAW_REGISTRATION_KEY` | Admin key for clawbot registration (server-side) | No | None |
19
+ | `APE_CLAW_INVITE` | Invitation token for clawbot registration | No | None |
20
+
21
+ \* Required for `--execute` commands (nft buy, bridge execute)
22
+
23
+ ## V2 Onchain Variables
24
+
25
+ | Variable | Description | Required | Default |
26
+ |----------|-------------|----------|---------|
27
+ | `APE_CLAW_V2_RPC_URL` | RPC URL for ApeChain (v2 operations) | Yes* | None |
28
+ | `RPC_URL_33139` | Alternative RPC URL env (ApeChain chain ID) | No | None |
29
+ | `APE_CLAW_V2_PRIVATE_KEY` | Private key for v2 onchain operations | Yes* | None |
30
+ | `APE_CLAW_V2_SKILL_NFT` | SkillNFT contract address | Yes* | None |
31
+ | `APE_CLAW_V2_SKILL_REGISTRY` | SkillRegistry contract address | Yes* | None |
32
+ | `APE_CLAW_V2_INTENT_REGISTRY` | IntentRegistry contract address | Yes* | None |
33
+ | `APE_CLAW_V2_RECEIPT_REGISTRY` | ReceiptRegistry contract address | Yes* | None |
34
+ | `APE_CLAW_V2_POLICY_ENGINE` | PolicyEngine contract address | No | None |
35
+ | `APE_CLAW_V2_AGENT_ACCOUNT` | AgentAccount contract address | Yes* | None |
36
+ | `APE_CLAW_V2_POD_VAULT` | PodVault contract address | No | None |
37
+ | `APE_CLAW_V2_SWAP_MODULE` | SwapModule contract address | No | None |
38
+ | `APE_CLAW_V2_BRIDGE_MODULE` | BridgeModule contract address | No | None |
39
+ | `APE_CLAW_V2_NFT_BUY_MODULE` | NftBuyModule contract address | No | None |
40
+
41
+ \* Required for specific v2 commands (mint, publish, execute, etc.)
42
+
43
+ ## Telemetry Server Variables
44
+
45
+ | Variable | Description | Required | Default |
46
+ |----------|-------------|----------|---------|
47
+ | `APE_CLAW_UI_PORT` | Port for telemetry server | No | `8787` |
48
+ | `APE_CLAW_BIND_HOST` | Host to bind telemetry server | No | `""` (all interfaces) |
49
+ | `APE_CLAW_CORS_ORIGINS` | Logged at startup; current runtime CORS allowlist is set in middleware code | No | `"https://apeclaw.ai"` |
50
+ | `APE_CLAW_STORAGE` | Storage backend: `file` (default) or `sqlite` | No | `"file"` |
51
+ | `APE_CLAW_SHARED_OPENSEA_KEY` | Shared OpenSea key injected to verified clawbots | No | None |
52
+ | `APE_CLAW_REGISTRATION_KEY` | Admin key for clawbot registration | No | None |
53
+ | `APE_CLAW_OPEN_REGISTRATION` | Enable open registration (no key/invite) | No | `false` |
54
+ | `APE_CLAW_REGISTRATION_COOLDOWN_MS` | Cooldown between registrations (IP-based) | No | `10000` |
55
+ | `APE_CLAW_INVITE_TTL_MS` | Invite token TTL in milliseconds | No | `86400000` (24h) |
56
+ | `APE_CLAW_INVITE_MAX_USES` | Maximum uses per invite token | No | `5` |
57
+ | `APE_CLAW_POD_DIR` | Pod workspace directory path | No | Auto-detected |
58
+
59
+ ## External Service Variables
60
+
61
+ | Variable | Description | Required | Default |
62
+ |----------|-------------|----------|---------|
63
+ | `OPENSEA_API_KEY` | OpenSea API key for market data | No* | None |
64
+ | `RELAY_API_KEY` | Relay bridge API key | No | None |
65
+ | `RELAY_API_BASE` | Relay API base URL override for quote/status discovery | No | `"https://api.relay.link"` |
66
+ | `MOLTBOOK_API_BASE` | Moltbook API base URL | No | `"https://www.moltbook.com/api/v1"` |
67
+ | `MOLTBOOK_APP_KEY` | Moltbook app key for identity verification | No | None |
68
+
69
+ \* Required if `policy.market.dataSource === "opensea"`
70
+
71
+ ## SkillCard Variables
72
+
73
+ | Variable | Description | Required | Default |
74
+ |----------|-------------|----------|---------|
75
+ | `APECLAW_SKILLCARD_URI_BASE` | Base URI for SkillCard file references | No | `"file://"` |
76
+
77
+ ## Usage Examples
78
+
79
+ ### Basic CLI Setup
80
+
81
+ ```bash
82
+ export APE_CLAW_AGENT_ID=my-bot
83
+ export APE_CLAW_AGENT_TOKEN=claw_...
84
+ export APE_CLAW_TELEMETRY_URL=https://apeclaw.ai
85
+ export APE_CLAW_CHAT_URL=https://apeclaw.ai
86
+ export APE_CLAW_TELEMETRY_REMOTE_ONLY=true
87
+ ```
88
+
89
+ ### Execute Flows (NFT Buy, Bridge)
90
+
91
+ ```bash
92
+ export APE_CLAW_PRIVATE_KEY=0x...
93
+ export OPENSEA_API_KEY=...
94
+ ```
95
+
96
+ ### V2 Onchain Operations
97
+
98
+ ```bash
99
+ export APE_CLAW_V2_RPC_URL=https://apechain.calderachain.xyz/http
100
+ export APE_CLAW_V2_PRIVATE_KEY=0x...
101
+ export APE_CLAW_V2_SKILL_NFT=0x...
102
+ export APE_CLAW_V2_SKILL_REGISTRY=0x...
103
+ export APE_CLAW_V2_INTENT_REGISTRY=0x...
104
+ export APE_CLAW_V2_RECEIPT_REGISTRY=0x...
105
+ export APE_CLAW_V2_AGENT_ACCOUNT=0x...
106
+ export APE_CLAW_V2_POD_VAULT=0x...
107
+ ```
108
+
109
+ ### Telemetry Server
110
+
111
+ ```bash
112
+ export APE_CLAW_UI_PORT=8787
113
+ export APE_CLAW_REGISTRATION_KEY=your-secret-key
114
+ export APE_CLAW_OPEN_REGISTRATION=false
115
+ # Optional: currently logged only; runtime CORS allowlist is in middleware.
116
+ export APE_CLAW_CORS_ORIGINS=https://apeclaw.ai
117
+ export APE_CLAW_STORAGE=file # or "sqlite"
118
+ ```
119
+
120
+ ### Pod Operations
121
+
122
+ ```bash
123
+ export APE_CLAW_POD_DIR=./pod-workspace
124
+ ```
125
+
126
+ ### Override Root/State Paths
127
+
128
+ ```bash
129
+ export APE_CLAW_ROOT=/srv/ape-claw
130
+ export APE_CLAW_STATE_DIR=/var/lib/ape-claw/state
131
+ ```
132
+
133
+ ## Environment Variable Resolution Order
134
+
135
+ For CLI commands, environment variables are checked in this order:
136
+
137
+ 1. **Command-line flags** (e.g., `--rpc`, `--privateKey`)
138
+ 2. **Environment variables** (e.g., `APE_CLAW_V2_RPC_URL`)
139
+ 3. **Local auth profile** (`~/.ape-claw/auth.json`) - for `APE_CLAW_PRIVATE_KEY`, `APE_CLAW_AGENT_ID`, `APE_CLAW_AGENT_TOKEN`, `OPENSEA_API_KEY`
140
+ 4. **Defaults** (if any)
141
+
142
+ ## Security Notes
143
+
144
+ 1. **Never commit private keys** to version control
145
+ 2. **Use environment variables** or `ape-claw auth set` for secrets
146
+ 3. **Private keys** are stored in `~/.ape-claw/auth.json` with mode `0600` (owner read/write only)
147
+ 4. **Agent tokens** are shown only once on registration—save them immediately
148
+ 5. **Registration keys** should be strong, random strings
149
+
150
+ ## Local Auth Profile
151
+
152
+ You can persist credentials locally using `ape-claw auth set`:
153
+
154
+ ```bash
155
+ ape-claw auth set \
156
+ --agent-id my-bot \
157
+ --agent-token claw_... \
158
+ --private-key 0x... \
159
+ --opensea-api-key ... \
160
+ --json
161
+ ```
162
+
163
+ This saves to `~/.ape-claw/auth.json` (mode 600). Environment variables still override these values.
164
+
165
+ ## Checking Configuration
166
+
167
+ Use `ape-claw doctor` to verify your configuration:
168
+
169
+ ```bash
170
+ ape-claw doctor --json
171
+ ```
172
+
173
+ This shows:
174
+ - Which env vars are set
175
+ - Which credentials are available
176
+ - Read-only vs execute-ready status
177
+ - Missing prerequisites
178
+
179
+ ## Deployment Records
180
+
181
+ After running `npm run contracts:seed`, deployment addresses are saved to:
182
+ - `state/v2-deployments/<network>.json`
183
+
184
+ The telemetry server can auto-detect these for read-only operations (no signing required).
185
+
186
+ ## Common Patterns
187
+
188
+ ### Development (Local Hardhat)
189
+
190
+ ```bash
191
+ export APE_CLAW_V2_RPC_URL=http://127.0.0.1:8545
192
+ export APE_CLAW_V2_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
193
+ # Contract addresses from state/v2-deployments/localhost.json
194
+ ```
195
+
196
+ ### Production (ApeChain)
197
+
198
+ ```bash
199
+ export APE_CLAW_V2_RPC_URL=https://apechain.calderachain.xyz/http
200
+ export APE_CLAW_V2_PRIVATE_KEY=0x... # Your production key
201
+ # Contract addresses from state/v2-deployments/apechain.json
202
+ ```
203
+
204
+ ### Standalone Mode (No Backend)
205
+
206
+ ```bash
207
+ export OPENSEA_API_KEY=...
208
+ export APE_CLAW_PRIVATE_KEY=0x...
209
+ # No APE_CLAW_AGENT_ID/TOKEN needed
210
+ ```
211
+
212
+ ### Backend-Connected Mode
213
+
214
+ ```bash
215
+ export APE_CLAW_AGENT_ID=my-bot
216
+ export APE_CLAW_AGENT_TOKEN=claw_...
217
+ export APE_CLAW_TELEMETRY_URL=https://apeclaw.ai
218
+ # Shared OpenSea key injected automatically
219
+ ```
220
+
221
+ ## Troubleshooting
222
+
223
+ **Missing RPC URL:**
224
+ - Set `APE_CLAW_V2_RPC_URL` or `RPC_URL_33139`
225
+ - For local dev, use `http://127.0.0.1:8545`
226
+
227
+ **Missing private key:**
228
+ - Set `APE_CLAW_PRIVATE_KEY` for v1 operations
229
+ - Set `APE_CLAW_V2_PRIVATE_KEY` for v2 operations
230
+ - Or use `ape-claw auth set --private-key 0x...`
231
+
232
+ **Missing contract addresses:**
233
+ - Run `npm run contracts:seed` to deploy and save addresses
234
+ - Or set env vars manually from deployment output
235
+
236
+ **OpenSea API key not injected:**
237
+ - Verify clawbot with `ape-claw doctor --agent-id ... --agent-token ...`
238
+ - Or set `OPENSEA_API_KEY` directly