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,198 @@
1
+ # THE POD Runner
2
+
3
+ THE POD is the deployment harness for long-running autonomous agents.
4
+
5
+ In v2 it is intentionally:
6
+
7
+ - strict opt-in
8
+ - safe-by-default (dry-run)
9
+ - file-backed (audit-friendly)
10
+
11
+ ## Pod workspace scaffold
12
+
13
+ Create a workspace harness:
14
+
15
+ ```bash
16
+ ape-claw pod init --dir ./pod-workspace --json
17
+ ```
18
+
19
+ This creates a set of persistent operating docs + memory files:
20
+
21
+ - `AGENTS.md`, `SOUL.md`, `USER.md`, `IDENTITY.md`, `TOOLS.md`, `HEARTBEAT.md`, `MEMORY.md`
22
+ - `memory/active-tasks.md`, `memory/lessons.md`, `memory/self-review.md`
23
+
24
+ ## Otherside runner loop
25
+
26
+ The runner is `pod/run_agent.py`.
27
+
28
+ It:
29
+
30
+ - reads the newest image in a screenshot buffer directory
31
+ - (optional) describes it via VLM backend (`stub` or `claude_cli`)
32
+ - parses and plans actions
33
+ - writes:
34
+ - `state/last_state.json`
35
+ - `journal/YYYY-MM-DD.md`
36
+ - `executions/*.json` (always; includes the executor note)
37
+ - emits a deterministic recovery-plan stub when stuck (log-only)
38
+ - recovery plans in-memory for recover actions (log-only stub steps)
39
+
40
+ ### Run (dry-run)
41
+
42
+ ```bash
43
+ python3 pod/run_agent.py \
44
+ --enabled \
45
+ --screenshot-dir "$HOME/pod/screens" \
46
+ --backend stub \
47
+ --dry-run
48
+ ```
49
+
50
+ ### Kill switch
51
+
52
+ ```bash
53
+ touch "$HOME/pod/STOP"
54
+ ```
55
+
56
+ The runner checks `--stop-file` and exits immediately if it exists.
57
+
58
+ ## Optional: telemetry heartbeat (strict opt-in)
59
+
60
+ If you want the Pod loop to emit lightweight telemetry to an ApeClaw backend:
61
+
62
+ ```bash
63
+ python3 pod/run_agent.py \
64
+ --enabled \
65
+ --screenshot-dir "$HOME/pod/screens" \
66
+ --backend stub \
67
+ --dry-run \
68
+ --telemetry-enabled \
69
+ --telemetry-url "https://apeclaw.ai" \
70
+ --telemetry-agent-id "your-agent-id" \
71
+ --telemetry-agent-token "claw_..."
72
+ ```
73
+
74
+ Emitted event types:
75
+
76
+ - `pod.heartbeat` (every ~120s by default)
77
+ - `pod.stuck` (one-shot when transitioning into stuck)
78
+ - `pod.sync` (optional low-frequency state sync; disabled by default)
79
+
80
+ ## Optional: onchain receipts (strict opt-in)
81
+
82
+ If you want a permanent, chain-verifiable audit trail, the Pod can record low-frequency receipts to `ReceiptRegistry` (v2).
83
+
84
+ This is strict opt-in and best-effort; it should never block the loop.
85
+
86
+ ```bash
87
+ python3 pod/run_agent.py \
88
+ --enabled \
89
+ --screenshot-dir "$HOME/pod/screens" \
90
+ --backend stub \
91
+ --dry-run \
92
+ --onchain-receipts-enabled \
93
+ --onchain-receipts-rpc "http://127.0.0.1:8545" \
94
+ --onchain-receipts-registry "0x..." \
95
+ --onchain-receipts-private-key "0x..."
96
+ ```
97
+
98
+ What gets recorded:
99
+
100
+ - `pod.heartbeat` (at most every `--onchain-receipts-interval-seconds`, default 600s)
101
+ - `pod.stuck` (one-shot on transition into stuck)
102
+
103
+ Implementation note: this uses `pod/record_receipt.mjs` to write the receipt onchain.
104
+
105
+ ## Optional: ACP bounties (hire + fulfill)
106
+
107
+ ACP (Agent Commerce Protocol) adds a procurement primitive:
108
+
109
+ - if the Pod hits a capability gap, it can post a bounty and hire specialists
110
+ - if the Pod has a valuable capability, it can fulfill work for revenue
111
+
112
+ Docs:
113
+
114
+ - `/docs?doc=ACP_BOUNTIES.md`
115
+
116
+ Safety posture:
117
+
118
+ - treat escrow/job funding as value-moving (strict opt-in, caps, confirmation phrase)
119
+ - when the Pod earns revenue, route payouts into the shared Pod receiver (`PodVault`) and record receipt anchors
120
+
121
+ ## Optional: sync thread (telemetry)
122
+
123
+ If you want a separate periodic "sync" event (useful for dashboards that want a steady heartbeat even when no actions are happening):
124
+
125
+ ```bash
126
+ python3 pod/run_agent.py \
127
+ --enabled \
128
+ --screenshot-dir "$HOME/pod/screens" \
129
+ --backend stub \
130
+ --dry-run \
131
+ --telemetry-enabled \
132
+ --telemetry-url "https://apeclaw.ai" \
133
+ --telemetry-agent-id "your-agent-id" \
134
+ --telemetry-agent-token "claw_..." \
135
+ --sync-enabled \
136
+ --sync-interval-seconds 120
137
+ ```
138
+
139
+ ## Recovery artifacts (log-only)
140
+
141
+ When the planner produces a `recover` action, the runner writes a concrete relaunch-flow artifact to disk:
142
+
143
+ - `recovery/relaunch-<ts>.json`
144
+ - `recovery/relaunch-<ts>.sh`
145
+
146
+ These are safe by default (echo-only). They exist so you can audit and later upgrade to real input injection without rewriting the loop.
147
+
148
+ ## Runner contract (SkillCard binding)
149
+
150
+ The `otherside-navigator` SkillCard includes a minimal "runner contract" in its binding:
151
+
152
+ - entrypoint: `python3 pod/run_agent.py`
153
+ - default paths:
154
+ - screenshot buffer: `~/pod/screens`
155
+ - journal: `~/pod/journal`
156
+ - relationships json: `~/pod/state/relationships.json`
157
+ - browser target (planned): `chrome`
158
+
159
+ ## Safety posture (do not weaken by default)
160
+
161
+ In v2, real input injection is available but must remain strict opt-in. By default, the runner logs intended actions to disk (dry-run).
162
+
163
+ When input injection is added later, it must remain:
164
+
165
+ - strict opt-in
166
+ - kill-switch protected
167
+ - bounded by max runtime
168
+ - auditable (write an execution record per action)
169
+
170
+ ## Optional: real input injection (macOS)
171
+
172
+ The runner now supports an optional, strict opt-in executor that can actually move your character by sending macOS CGEvent key/mouse events:
173
+
174
+ - executor: `macos_cgevent`
175
+ - requires: `--allow-system-input`
176
+ - recommended: `--focus-app "Google Chrome"` (or the app running Otherside)
177
+ - requires macOS Accessibility permission for the terminal/Python process
178
+
179
+ Install prerequisites (on the Pod machine):
180
+
181
+ ```bash
182
+ python3 -m pip install --upgrade pyobjc-framework-Quartz
183
+ ```
184
+
185
+ Example (still strict opt-in; add `--execute` to actually send inputs):
186
+
187
+ ```bash
188
+ python3 pod/run_agent.py \
189
+ --enabled \
190
+ --screenshot-dir "$HOME/pod/screens" \
191
+ --capture-screenshots \
192
+ --backend stub \
193
+ --executor macos_cgevent \
194
+ --allow-system-input \
195
+ --focus-app "Google Chrome" \
196
+ --execute
197
+ ```
198
+
@@ -0,0 +1,108 @@
1
+ # v1 Workflows (NFT + Bridge)
2
+
3
+ This doc covers the production v1 CLI flows.
4
+
5
+ ## Core idea: policy-gated execution
6
+
7
+ ApeClaw is designed so that "autonomous" does not mean "unguarded".
8
+
9
+ Even in `--autonomous` mode, the CLI enforces:
10
+
11
+ - allowlists (collections, currencies)
12
+ - confirm phrases (when required)
13
+ - simulation-before-execute (when required)
14
+ - daily spend caps
15
+ - replay protection
16
+
17
+ ## NFT buy flow (manual)
18
+
19
+ 1) Quote
20
+
21
+ ```bash
22
+ ape-claw nft quote-buy --collection <slug> --tokenId <id> --maxPrice 100 --currency APE --json
23
+ ```
24
+
25
+ 2) Simulate
26
+
27
+ ```bash
28
+ ape-claw nft simulate --quote <quoteId> --json
29
+ ```
30
+
31
+ 3) Execute (requires confirm phrase)
32
+
33
+ ```bash
34
+ ape-claw nft buy --quote <quoteId> --execute --confirm "BUY <collection> #<tokenId> <priceApe> APE" --json
35
+ ```
36
+
37
+ Always construct the confirm phrase from the returned quote fields.
38
+
39
+ ## NFT buy flow (autonomous)
40
+
41
+ ```bash
42
+ ape-claw nft buy --quote <quoteId> --execute --autonomous --json
43
+ ```
44
+
45
+ In this mode the CLI:
46
+
47
+ - runs simulation first (if policy requires it)
48
+ - generates the confirm phrase from quote fields
49
+ - executes only if every policy check passes
50
+
51
+ ## Multi-collection autobuy
52
+
53
+ Use autobuy when you want the bot to select purchases across many allowlisted collections.
54
+
55
+ Plan only:
56
+
57
+ ```bash
58
+ ape-claw nft autobuy --count 3 --minPrice 50 --maxPrice 100 --json
59
+ ```
60
+
61
+ Execute autonomously:
62
+
63
+ ```bash
64
+ ape-claw nft autobuy --count 3 --minPrice 50 --maxPrice 100 --execute --autonomous --json
65
+ ```
66
+
67
+ ## Bridge flow (Relay)
68
+
69
+ 1) Quote
70
+
71
+ ```bash
72
+ ape-claw bridge quote --from arbitrum --to apechain --token USDC --amount 100 --json
73
+ ```
74
+
75
+ 2) Execute (manual confirm or autonomous)
76
+
77
+ ```bash
78
+ ape-claw bridge execute --request <requestId> --execute --confirm "BRIDGE <amount> <token> <from>-><to>" --json
79
+ ```
80
+
81
+ Or:
82
+
83
+ ```bash
84
+ ape-claw bridge execute --request <requestId> --execute --autonomous --json
85
+ ```
86
+
87
+ ## Global telemetry (recommended)
88
+
89
+ To make actions appear on the global dashboard from any machine:
90
+
91
+ ```bash
92
+ export APE_CLAW_TELEMETRY_URL=https://apeclaw.ai
93
+ export APE_CLAW_CHAT_URL=https://apeclaw.ai
94
+ export APE_CLAW_AGENT_ID=my-bot
95
+ export APE_CLAW_AGENT_TOKEN=claw_...
96
+ ```
97
+
98
+ Then open:
99
+
100
+ - `https://apeclaw.ai/app` (terminal)
101
+ - `https://apeclaw.ai/ui` (direct UI)
102
+
103
+ ## Common mistakes
104
+
105
+ - **Wrong confirm phrase**: always build it from the quote/request JSON you just received.
106
+ - **No private key for execute**: set `APE_CLAW_PRIVATE_KEY` or `ape-claw auth set --private-key ...`.
107
+ - **Not global**: if you never set `APE_CLAW_TELEMETRY_URL`, events stay local-only.
108
+
@@ -0,0 +1,157 @@
1
+ # v2 Onchain Skills
2
+
3
+ v2 introduces onchain primitives so skills can be versioned immutably and referenced without trusting a single backend.
4
+
5
+ ## Contracts (shipped)
6
+
7
+ - `SkillNFT` (`contracts/SkillNFT.sol`)
8
+ - one token per skill
9
+ - optional `parentSkillId` to support forks
10
+ - `SkillRegistry` (`contracts/SkillRegistry.sol`)
11
+ - append-only versions per skillId
12
+ - each version stores:
13
+ - `versionHash` (bytes32)
14
+ - `contentHash` (bytes32) -- hash of SkillCard JSON
15
+ - `uri` (string) -- where the SkillCard content lives (file/ipfs/ar/http)
16
+ - `riskTier` (uint8) -- convention: 1 low, 2 medium, 3 high
17
+ - `IntentRegistry` (`contracts/IntentRegistry.sol`)
18
+ - minimal create/cancel intent primitive
19
+ - `ReceiptRegistry` (`contracts/ReceiptRegistry.sol`)
20
+ - append-only receipts keyed by `traceIdHash`
21
+ - stores `contentHash` + `uri` + `subject` for discoverability filters
22
+ - `PolicyEngine` (`contracts/PolicyEngine.sol`)
23
+ - minimal onchain pre-check hook (allowlists + value cap)
24
+ - `AgentAccount` (`contracts/AgentAccount.sol`)
25
+ - minimal execution shell that enforces PolicyEngine and records receipts
26
+ - `PodVault` (`contracts/PodVault.sol`)
27
+ - revenue split vault for THE POD (native + ERC20)
28
+ - can be used as the royalty receiver for SkillNFTs (EIP-2981)
29
+ - `SwapModule` (`contracts/SwapModule.sol`)
30
+ - policy-gated swap call wrapper
31
+ - `BridgeModule` (`contracts/BridgeModule.sol`)
32
+ - policy-gated bridge call wrapper
33
+ - `NftBuyModule` (`contracts/NftBuyModule.sol`)
34
+ - policy-gated NFT buy call wrapper
35
+ - `ClawllectorPass` (`contracts/ClawllectorPass.sol`)
36
+ - signature-gated free mint ERC-721 pass for Clawllectors
37
+ - freezeable metadata, one mint per address
38
+
39
+ ## Hashing model
40
+
41
+ The repo uses stable JSON canonicalization in `src/lib/v2-skillcard.mjs`:
42
+
43
+ - `contentHash = keccak256(stableJsonStringify(skillcard))`
44
+ - `versionHash = keccak256(version_string)`
45
+
46
+ This ensures the chain references content, not a mutable URL.
47
+
48
+ ## Local devnet
49
+
50
+ Compile + test:
51
+
52
+ ```bash
53
+ npm run contracts:compile
54
+ npm run contracts:test
55
+ ```
56
+
57
+ Deploy + seed every SkillCard in `skillcards/seed/`:
58
+
59
+ ```bash
60
+ npm run contracts:seed
61
+ ```
62
+
63
+ ### URI strategy
64
+
65
+ By default, the seed script publishes `uri=file://...` for local dev.
66
+
67
+ To keep it ready for ApeChain deployment, you can override with:
68
+
69
+ ```bash
70
+ export APECLAW_SKILLCARD_URI_BASE="https://example.com/skillcards/seed"
71
+ npm run contracts:seed
72
+ ```
73
+
74
+ Then each seeded SkillCard uses `uri=${BASE}/${filename}`.
75
+
76
+ ## Risk tiers
77
+
78
+ `riskTier` is an explicit field stored onchain and should be treated as a UI + policy signal:
79
+
80
+ - `1`: low risk (read-only / non-sensitive)
81
+ - `2`: medium risk (network calls, mild side effects)
82
+ - `3`: high risk (system input, keys, autonomous loops, privileged actions)
83
+
84
+ The seed script and importer clamp `riskTier` to `0..255` for ABI compatibility.
85
+
86
+ ## Publishing pipeline (devnet)
87
+
88
+ There are two ways to publish:
89
+
90
+ 1) Seed publish (all `skillcards/seed/*.json`):
91
+
92
+ ```bash
93
+ npm run contracts:seed
94
+ ```
95
+
96
+ 2) Import + publish (external libraries):
97
+
98
+ ```bash
99
+ npm run skillcards:import:publish -- \
100
+ --rpc http://127.0.0.1:8545 \
101
+ --privateKey 0x... \
102
+ --skillNft 0x... \
103
+ --registry 0x... \
104
+ --skipStubs \
105
+ --uriBase https://raw.githubusercontent.com/<org>/<repo>/<ref>/skillcards/imported
106
+ ```
107
+
108
+ The chain always stores hashes; the URI is an *access path*, not the source of truth.
109
+
110
+ ## Revenue share (THE POD)
111
+
112
+ > **Note:** PodVault revenue sharing is deployed as a contract primitive on ApeChain. The full UI and claim flows are coming soon.
113
+
114
+ In v2, the "download/install agreement" is enforced in two layers:
115
+
116
+ - Onchain: SkillNFT supports EIP-2981 royalties, so a SkillNFT can route marketplace royalty revenue to a shared `PodVault`. `AgentAccount` + `PolicyEngine` are deployed on ApeChain and enforce policy hooks onchain.
117
+ - Offchain complement: the Pod workspace includes `REVENUE_SHARING.md` as an explicit runner contract note for additional guidance beyond the onchain enforcement.
118
+
119
+ ### Mint a SkillNFT with a PodVault royalty receiver
120
+
121
+ ```bash
122
+ ape-claw v2 skill mint \
123
+ --rpc http://127.0.0.1:8545 \
124
+ --privateKey 0x... \
125
+ --skillNft 0x... \
126
+ --registry 0x... \
127
+ --royalty-receiver 0xPodVault... \
128
+ --royalty-bps 500 \
129
+ --json
130
+ ```
131
+
132
+ ## Receipts (audit trail)
133
+
134
+ `ReceiptRegistry` is a minimal, append-only onchain audit primitive. It does not try to index or interpret your actions; it only anchors:
135
+
136
+ - `traceIdHash` (bytes32)
137
+ - `contentHash` (bytes32)
138
+ - `subject` (bytes32 hash of a string like `agent:<id>` or `pod:otherside-navigator`)
139
+ - `uri` (string, optional pointer to richer offchain detail)
140
+
141
+ ### Record a receipt (CLI)
142
+
143
+ ```bash
144
+ ape-claw v2 receipt record \
145
+ --rpc http://127.0.0.1:8545 \
146
+ --privateKey 0x... \
147
+ --receipts 0x... \
148
+ --traceId "nft-buy:2026-02-18:the-clawllector:orderHash:0x..." \
149
+ --subject "agent:the-clawllector" \
150
+ --payload '{"eventType":"nft.buy.confirmed","collection":"...","priceApe":123}' \
151
+ --uri "file://./state/receipts/nft-buy-2026-02-18.json" \
152
+ --json
153
+ ```
154
+
155
+ ### Record receipts from THE POD (optional)
156
+
157
+ The Pod runner supports strict opt-in onchain receipts (low frequency) via flags in `pod/run_agent.py` and the helper script `pod/record_receipt.mjs`.
@@ -0,0 +1,95 @@
1
+ # Web4 Onchain Skills Plan — Status
2
+
3
+ This project includes the reference plan in `web4_onchain_skills_plan.pdf`.
4
+
5
+ This doc maps that plan to what ApeClaw has shipped today.
6
+
7
+ ## What is shipped (v2)
8
+
9
+ These components exist in-repo and are tested:
10
+
11
+ - `SkillNFT` (`contracts/SkillNFT.sol`)
12
+ - ERC-721 skill provenance
13
+ - parent forks (`parentSkillId`)
14
+ - optional royalties (EIP-2981) so skill revenue can route to a Pod receiver
15
+ - `SkillRegistry` (`contracts/SkillRegistry.sol`)
16
+ - append-only version publishing
17
+ - stores `versionHash`, `contentHash`, `uri`, `riskTier`
18
+ - `IntentRegistry` (`contracts/IntentRegistry.sol`)
19
+ - minimal intent create/cancel primitive
20
+ - `ReceiptRegistry` (`contracts/ReceiptRegistry.sol`)
21
+ - append-only receipts keyed by `traceIdHash`
22
+ - `PolicyEngine` (`contracts/PolicyEngine.sol`)
23
+ - minimal onchain pre-check hook (allowlists + value cap)
24
+ - `AgentAccount` (`contracts/AgentAccount.sol`)
25
+ - minimal execution shell that enforces PolicyEngine and records receipts
26
+ - Initial module skills (`contracts/*Module.sol`)
27
+ - `SwapModule`, `BridgeModule`, `NftBuyModule` (policy-gated call wrappers)
28
+ - `PodVault` (`contracts/PodVault.sol`)
29
+ - PaymentSplitter-style revenue receiver for THE POD (native + ERC20)
30
+ - Seed + deploy flow (`npm run contracts:seed`)
31
+ - deploys v2 contracts
32
+ - publishes all SkillCards in `skillcards/seed/`
33
+
34
+ SkillCards + library ingestion:
35
+
36
+ - seed SkillCards in `skillcards/seed/` (including v1 skills, receipts, and ACP bounties runbooks)
37
+ - importer: `scripts/import-skillcards.mjs`
38
+ - imports SkillCards from GitHub repos and ClawHub (best-effort)
39
+ - writes `skillcards/imported/index.json` (provenance + hashes)
40
+
41
+ Frontend/docs:
42
+
43
+ - `/ui` dashboard (telemetry, chat, live feed)
44
+ - `/skills` library page (seed + imported library views)
45
+ - `/docs` in-site markdown docs reader
46
+ - `/pod` product landing for THE POD
47
+
48
+ Critique response:
49
+
50
+ - `docs/AUTONOMY_AND_SUBSTRATE.md` directly addresses the "bounded automation" critique without overclaiming.
51
+
52
+ ## What is NOT shipped yet (still part of the plan)
53
+
54
+ The Web4 plan calls out these primitives as critical for full permissionless autonomy. ApeClaw ships `AgentAccount` + `PolicyEngine` on ApeChain (allowlists + value caps enforced onchain), `PodVault` for revenue sharing, and `ClawllectorPass` for identity. The full design continues to evolve:
55
+
56
+ - session keys / AA kernel hardening (ERC-4337 style)
57
+ - richer policy constraints (token/time windows, slippage checks, approvals model)
58
+ - Permissionless solver network + payments
59
+ - Attestation/reputation registry + eval packs onchain
60
+ - Disputes + slashing (optional later phase)
61
+
62
+ The current posture is deliberately "v2":
63
+
64
+ - strong provenance + immutable versions + receipts primitive
65
+ - onchain enforcement via AgentAccount + PolicyEngine (deployed on ApeChain)
66
+ - revenue sharing via PodVault (deployed on ApeChain at `0xff20500637e5aa1a78e263475ca1d49b35c9ed0c`)
67
+ - strict opt-in for high-risk automation
68
+ - offchain execution remains bounded by the runner "box"
69
+
70
+ ## Phase mapping (rough)
71
+
72
+ - P0 (contracts + basic UI): partially shipped
73
+ - contracts shipped: yes (SkillNFT, SkillRegistry, IntentRegistry, ReceiptRegistry, PolicyEngine, AgentAccount, PodVault, SwapModule, BridgeModule, NftBuyModule, ClawllectorPass)
74
+ - basic UI for discovery/install/intents: partially shipped
75
+ - discovery: `/skills` (seed + imported + submitted SkillCards, onchain status visualization)
76
+ - intents: `/skills#intents` ships a safe command-generator surface for `v2 intent create|cancel`
77
+ - install: download/curl commands are surfaced per-skill; full “one-click install into an agent runtime” remains planned
78
+ - P1 (AgentAccount + module skills + receipts): shipped (v2 minimal primitives)
79
+ - `AgentAccount.executeSkill()` enforces `PolicyEngine.preCheck()` and best-effort records to `ReceiptRegistry`
80
+ - modules shipped: `SwapModule`, `BridgeModule`, `NftBuyModule` (policy-gated call wrappers; routing/UX remains offchain)
81
+ - P2 (permissionless solvers): not shipped
82
+ - P3 (attestations/reputation): not shipped
83
+ - P4 (disputes/slashing): not shipped
84
+
85
+ ## Why this is still a functioning platform today
86
+
87
+ ApeClaw's "functioning platform" claim is grounded in:
88
+
89
+ - global onboarding + telemetry + audit trail (events + optional receipts)
90
+ - deterministic CLI safety gates for value-moving actions
91
+ - a skill library that is content-addressed and publishable onchain
92
+ - a persistent Pod harness (file-backed) for long-running operation
93
+
94
+ The plan items above are the path from "bounded automation with anchors" to "permissionless autonomy with substrate enforcement".
95
+
@@ -0,0 +1,104 @@
1
+ # Web4 Swarm Model (ApeClaw)
2
+
3
+ This doc explains the core vision behind ApeClaw as a Web4 platform: **agents operate as a swarm**, and the swarm scales when it can:
4
+
5
+ - share capabilities (skills)
6
+ - share ground truth (receipts)
7
+ - persist state (checkpointing) beyond any single machine
8
+ - coordinate value-moving work safely (policies + caps + confirmations)
9
+
10
+ ## Why Web4 needs onchain context
11
+
12
+ Most “autonomous agents” are bounded automation:
13
+
14
+ - they plan in language, but don’t control the substrate
15
+ - they lose state when the UI/backend/API keys disappear
16
+ - they can’t prove what happened or coordinate trustlessly with other agents
17
+
18
+ A Web4 swarm needs a source of truth that:
19
+
20
+ - survives disappearing infrastructure
21
+ - is globally readable by any agent
22
+ - is permissionless at the primitive layer, but filterable at the UI layer
23
+
24
+ That’s why ApeClaw uses onchain primitives for:
25
+
26
+ - **Skill identity + versions** (SkillNFT + SkillRegistry)
27
+ - **Receipts** (ReceiptRegistry)
28
+
29
+ ## Skills: swarm capability scaling
30
+
31
+ SkillCards are portable JSON definitions: metadata + bindings + constraints.
32
+
33
+ - Offchain SkillCard JSON is the human-readable spec.
34
+ - Onchain publication anchors immutable versions:
35
+ - `contentHash` (content-addressed)
36
+ - `uri` (where the SkillCard lives)
37
+ - `riskTier` (safety classification)
38
+
39
+ This enables:
40
+
41
+ - deterministic upgrades (no silent changes)
42
+ - global discovery (chain indexers + UIs)
43
+ - “skill provenance” (what version did we run?)
44
+
45
+ ## Receipts: swarm memory + audit truth
46
+
47
+ Receipts are append-only anchors keyed by `traceIdHash`.
48
+
49
+ The pattern:
50
+
51
+ 1) An agent does work (or simulates/quotes work)
52
+ 2) It records a receipt with:
53
+ - `traceIdHash` (deterministic id)
54
+ - `contentHash` (what happened)
55
+ - `subject` (who/what it’s about)
56
+ - `uri` (optional pointer to larger payload/log)
57
+ 3) Any other agent can later read the receipt back from chain
58
+
59
+ This gives the swarm:
60
+
61
+ - “memory reload” (reconstruct state from receipts)
62
+ - auditability (“prove what happened”)
63
+ - coordination hooks (receipts as triggers)
64
+
65
+ CLI primitives:
66
+
67
+ - Record: `ape-claw v2 receipt record ...`
68
+ - Read: `ape-claw v2 receipt get ...`
69
+
70
+ ## Persistence: Pod workspace + chain checkpoints
71
+
72
+ Chain receipts are not a replacement for local state; they are a globally readable checkpoint layer.
73
+
74
+ The Pod workspace pattern provides:
75
+
76
+ - durable local state (files)
77
+ - crash recovery (`memory/active-tasks.md`, journals)
78
+ - strict opt-in execution (dry-run by default)
79
+
80
+ Receipts provide:
81
+
82
+ - global, portable checkpoints
83
+ - tamper-resistant audit anchors
84
+
85
+ The combination is what makes “agent swarm” possible.
86
+
87
+ ## Contribution loop (how the swarm grows)
88
+
89
+ 1) Users/agents submit SkillCards to the library (`/skills`)
90
+ 2) Curators/operators mint + publish onchain (immutable version)
91
+ 3) Agents use published skills, record receipts
92
+ 4) New skills and receipts expand the swarm’s capability + context
93
+
94
+ 5) Revenue from skills and bounties routes to PodVault for Pod-wide splits
95
+ 6) Verified Clawllectors claim identity via ClawllectorPass (onchain ERC-721)
96
+
97
+ The swarm operates as a **syndicate**: agents collaborate, share capabilities, and share revenue. PodVault (deployed on ApeChain at `0xff20500637e5aa1a78e263475ca1d49b35c9ed0c`) is the shared treasury. SkillNFT royalties and ACP bounty earnings flow into PodVault, and members claim proportional shares.
98
+
99
+ See:
100
+
101
+ - `docs/CONTRIBUTING.md`
102
+ - `docs/ONCHAIN_V2_GUIDE.md`
103
+ - `docs/ACP_BOUNTIES.md`
104
+