clawpowers 1.1.3 → 2.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/LICENSE +44 -0
  3. package/README.md +202 -384
  4. package/SECURITY.md +72 -0
  5. package/dist/index.d.ts +844 -0
  6. package/dist/index.js +2536 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +52 -42
  9. package/.claude-plugin/manifest.json +0 -19
  10. package/.codex/INSTALL.md +0 -36
  11. package/.cursor-plugin/manifest.json +0 -21
  12. package/.opencode/INSTALL.md +0 -52
  13. package/ARCHITECTURE.md +0 -69
  14. package/bin/clawpowers.js +0 -625
  15. package/bin/clawpowers.sh +0 -91
  16. package/docs/demo/clawpowers-demo.cast +0 -197
  17. package/docs/demo/clawpowers-demo.gif +0 -0
  18. package/docs/launch-images/25-skills-breakdown.jpg +0 -0
  19. package/docs/launch-images/clawpowers-vs-superpowers.jpg +0 -0
  20. package/docs/launch-images/economic-code-optimization.jpg +0 -0
  21. package/docs/launch-images/native-vs-bridge-2.jpg +0 -0
  22. package/docs/launch-images/native-vs-bridge.jpg +0 -0
  23. package/docs/launch-images/post1-hero-lobster.jpg +0 -0
  24. package/docs/launch-images/post2-dashboard.jpg +0 -0
  25. package/docs/launch-images/post3-superpowers.jpg +0 -0
  26. package/docs/launch-images/post4-before-after.jpg +0 -0
  27. package/docs/launch-images/post5-install-now.jpg +0 -0
  28. package/docs/launch-images/ultimate-stack.jpg +0 -0
  29. package/docs/launch-posts.md +0 -76
  30. package/docs/quickstart-first-transaction.md +0 -204
  31. package/gemini-extension.json +0 -32
  32. package/hooks/session-start +0 -205
  33. package/hooks/session-start.cmd +0 -43
  34. package/hooks/session-start.js +0 -163
  35. package/runtime/demo/README.md +0 -78
  36. package/runtime/demo/x402-mock-server.js +0 -230
  37. package/runtime/feedback/analyze.js +0 -621
  38. package/runtime/feedback/analyze.sh +0 -546
  39. package/runtime/init.js +0 -210
  40. package/runtime/init.sh +0 -178
  41. package/runtime/metrics/collector.js +0 -361
  42. package/runtime/metrics/collector.sh +0 -308
  43. package/runtime/payments/ledger.js +0 -305
  44. package/runtime/payments/ledger.sh +0 -262
  45. package/runtime/payments/pipeline.js +0 -459
  46. package/runtime/persistence/store.js +0 -433
  47. package/runtime/persistence/store.sh +0 -303
  48. package/skill.json +0 -106
  49. package/skills/agent-bounties/SKILL.md +0 -553
  50. package/skills/agent-payments/SKILL.md +0 -479
  51. package/skills/brainstorming/SKILL.md +0 -233
  52. package/skills/content-pipeline/SKILL.md +0 -282
  53. package/skills/cross-project-knowledge/SKILL.md +0 -345
  54. package/skills/dispatching-parallel-agents/SKILL.md +0 -305
  55. package/skills/economic-code-optimization/SKILL.md +0 -265
  56. package/skills/executing-plans/SKILL.md +0 -255
  57. package/skills/finishing-a-development-branch/SKILL.md +0 -260
  58. package/skills/formal-verification-lite/SKILL.md +0 -441
  59. package/skills/learn-how-to-learn/SKILL.md +0 -235
  60. package/skills/market-intelligence/SKILL.md +0 -323
  61. package/skills/meta-skill-evolution/SKILL.md +0 -325
  62. package/skills/prospecting/SKILL.md +0 -454
  63. package/skills/receiving-code-review/SKILL.md +0 -225
  64. package/skills/requesting-code-review/SKILL.md +0 -206
  65. package/skills/security-audit/SKILL.md +0 -353
  66. package/skills/self-healing-code/SKILL.md +0 -369
  67. package/skills/subagent-driven-development/SKILL.md +0 -244
  68. package/skills/systematic-debugging/SKILL.md +0 -355
  69. package/skills/test-driven-development/SKILL.md +0 -416
  70. package/skills/using-clawpowers/SKILL.md +0 -160
  71. package/skills/using-git-worktrees/SKILL.md +0 -261
  72. package/skills/verification-before-completion/SKILL.md +0 -254
  73. package/skills/writing-plans/SKILL.md +0 -276
  74. package/skills/writing-skills/SKILL.md +0 -260
package/README.md CHANGED
@@ -1,445 +1,263 @@
1
- # 🦞 ClawPowers
1
+ # ClawPowers
2
2
 
3
- **The skills framework that actually does something.**
3
+ **Skills library for AI agents payments, memory, RSI, wallet.** Drop-in capability layer for any agent framework.
4
4
 
5
- ClawPowers gives your coding agent superpowers that go beyond instructions. While other frameworks hand your agent a reading list and hope for the best, ClawPowers gives it **runtime tools, persistent memory, self-improvement loops, and the ability to transact autonomously.**
6
-
7
- ## Demo
8
-
9
- ![ClawPowers Demo](docs/demo/clawpowers-demo.gif)
10
-
11
- *Install → persist state across sessions → track outcomes → self-improve. All from the terminal.*
12
-
13
- ## Why ClawPowers?
14
-
15
- | Feature | ClawPowers | Static Skills Frameworks |
16
- |---------|-----------|--------------------------|
17
- | Skills auto-load on session start | ✅ | ✅ |
18
- | Runtime tool execution | ✅ | ❌ |
19
- | Cross-session memory | ✅ | ❌ |
20
- | Self-improvement (RSI) | ✅ | ❌ |
21
- | Outcome tracking & metrics | ✅ | ❌ |
22
- | Agent payments (x402) | ✅ | ❌ |
23
- | Security scanning | ✅ | ❌ |
24
- | Content pipeline | ✅ | ❌ |
25
- | Market intelligence | ✅ | ❌ |
26
- | Resumable workflows | ✅ | ❌ |
27
- | Windows native support | ✅ | ❌ |
28
- | Zero dependencies | ✅ | ✅ |
29
-
30
- **26 skills.** 14 cover everything static frameworks do (TDD, subagent dev, debugging, planning, code review, git worktrees). 6 go where they can't — payments, security, content, prospecting, market intelligence, and metacognitive learning. 4 are things no other framework even attempts — self-healing code, agents that rewrite their own methodology, cross-project knowledge transfer, and property-based formal verification.
31
-
32
- ## Requirements
33
-
34
- - **Node.js >= 16** — for cross-platform runtime (Windows, macOS, Linux)
35
- - **OR bash** — for Unix-native runtime (macOS, Linux, WSL2)
36
- - **No other dependencies.** Zero. `package.json` has an empty `dependencies` object.
37
-
38
- > Every user of Claude Code, Cursor, Codex, or Gemini CLI already has Node.js installed.
39
- > No `requirements.txt` needed — this is not a Python project.
40
-
41
- ## Installation
42
-
43
- ### Universal (recommended — works on Windows, macOS, Linux)
44
-
45
- ```bash
46
- npx clawpowers init
47
- ```
48
-
49
- This downloads ClawPowers, creates the `~/.clawpowers/` runtime directory, and you're ready to go. Works in any terminal: Windows CMD, PowerShell, macOS Terminal, Linux shell.
50
-
51
- ### OpenClaw
52
-
53
- ```bash
54
- openclaw skills install clawpowers
55
- ```
56
-
57
- Or install from GitHub directly:
58
-
59
- ```bash
60
- openclaw skills install github:up2itnow0822/clawpowers
61
- ```
62
-
63
- ClawPowers registers as a native OpenClaw skill with session hooks, runtime init, and all 24 skills auto-discoverable.
64
-
65
- ### Claude Code (Plugin Marketplace)
66
-
67
- ```bash
68
- /plugin install clawpowers@claude-plugins-official
69
- ```
70
-
71
- Or register the marketplace first, then install:
72
-
73
- ```bash
74
- /plugin marketplace add up2itnow0822/clawpowers-marketplace
75
- /plugin install clawpowers@clawpowers-marketplace
76
- ```
77
-
78
- ### Cursor
79
-
80
- In Cursor Agent chat:
81
-
82
- ```
83
- /add-plugin clawpowers
84
- ```
85
-
86
- Or search for "clawpowers" in the Cursor plugin marketplace.
87
-
88
- ### Codex
89
-
90
- Tell Codex:
91
-
92
- ```
93
- Fetch and follow instructions from https://raw.githubusercontent.com/up2itnow0822/clawpowers/main/.codex/INSTALL.md
94
- ```
95
-
96
- ### OpenCode
97
-
98
- Tell OpenCode:
99
-
100
- ```
101
- Fetch and follow instructions from https://raw.githubusercontent.com/up2itnow0822/clawpowers/main/.opencode/INSTALL.md
102
- ```
103
-
104
- ### Gemini CLI
5
+ [![npm version](https://img.shields.io/npm/v/clawpowers)](https://www.npmjs.com/package/clawpowers)
6
+ [![License: BSL 1.1](https://img.shields.io/badge/License-BSL%201.1-blue.svg)](LICENSE)
105
7
 
106
8
  ```bash
107
- gemini extensions install https://github.com/up2itnow0822/clawpowers
9
+ npm install clawpowers
108
10
  ```
109
11
 
110
- ### Manual (git clone)
12
+ > **⚠️ Patent Pending:** The x402 payment detection, autonomous spending policy enforcement, and recursive self-improvement (RSI) systems described in this library are subject to pending patent applications. Use is governed by the BSL 1.1 license.
111
13
 
112
- ```bash
113
- git clone https://github.com/up2itnow0822/clawpowers.git
114
- cd clawpowers
115
- node bin/clawpowers.js init # Windows, macOS, Linux
116
- # or
117
- bash bin/clawpowers.sh init # macOS, Linux only
118
- ```
14
+ ---
119
15
 
120
- ### Verify Installation
16
+ ## What Is This?
121
17
 
122
- Start a new session in your chosen platform and ask for something that triggers a skill for example, "help me plan this feature" or "let's debug this issue." The agent should automatically apply the relevant ClawPowers skill.
18
+ ClawPowers extracts the core capabilities from [ClawPowers-Agent](https://github.com/up2itnow0822/ClawPowers-Agent) into a standalone library. **No agent control loop**bring your own agent framework and get:
123
19
 
124
- Check runtime status anytime:
20
+ - **x402 Payments** — Detect HTTP 402 responses, enforce spending policies, execute payments
21
+ - **Three-Tier Memory** — Working, episodic, procedural memory with crash recovery
22
+ - **RSI Engine** — Metrics collection, hypothesis generation, mutation, A/B testing
23
+ - **Wallet** — Generate, import, and sign with Ethereum-compatible wallets
24
+ - **Skills** — Discover, load, and track skill execution outcomes
125
25
 
126
- ```bash
127
- npx clawpowers status
128
- ```
129
-
130
- ## What Makes ClawPowers Different
131
-
132
- ### 1. Skills That Execute, Not Just Instruct
133
-
134
- Static skills tell your agent *what to do*. ClawPowers skills can *do things themselves*:
135
-
136
- - The **test-driven-development** skill doesn't just describe TDD — it runs mutation analysis on your tests to verify they actually catch bugs
137
- - The **systematic-debugging** skill doesn't just list debugging steps — it maintains a persistent hypothesis tree across sessions so you never re-investigate the same dead end
138
- - The **verification-before-completion** skill doesn't just say "verify" — it runs the actual verification suite and blocks completion until it passes
139
-
140
- ### 2. Cross-Session Memory
141
-
142
- Every ClawPowers skill can read from and write to a persistent state store. When your agent debugs an issue on Monday and encounters the same stack trace on Friday, it remembers what worked and what didn't. No more Groundhog Day debugging.
26
+ ## x402 Payment Flow
143
27
 
144
28
  ```
145
- ~/.clawpowers/
146
- ├── state/ # Cross-session key-value store
147
- ├── metrics/ # Outcome tracking per skill (JSONL)
148
- ├── checkpoints/ # Resumable workflow state
149
- ├── feedback/ # Self-improvement analysis
150
- ├── memory/ # Persistent knowledge base
151
- └── logs/ # Execution logs
29
+ ┌─────────┐ ┌──────────────┐ ┌───────────────┐ ┌──────────┐
30
+ │ Agent │────▶│ API Server │────▶│ detect402() │────▶│ Spending
31
+ │ │ returns 402 │ │ parse x402 │ │ Policy │
32
+ └─────────┘ └──────────────┘ │ headers │ │ check │
33
+ └───────────────┘ └────┬─────┘
34
+
35
+ ┌─────────────────▼─────────────────┐
36
+ │ PaymentExecutor │
37
+ │ ┌───────────┐ ┌─────────────┐ │
38
+ │ │ MCP Client │ │ Audit Log │ │
39
+ │ │ (agentpay) │ │ (append-only│ │
40
+ │ └─────┬─────┘ └─────────────┘ │
41
+ └───────┬───────────────────────────┘
42
+
43
+ ┌───────▼───────┐
44
+ │ Base Network │
45
+ │ USDC Payment │
46
+ └───────────────┘
152
47
  ```
153
48
 
154
- ### 3. Self-Improvement (RSI)
49
+ ## Framework Compatibility
155
50
 
156
- ClawPowers tracks what works and what doesn't. After every skill execution:
51
+ | Framework | Integration | Example |
52
+ |-----------|------------|---------|
53
+ | **LangChain** | `DynamicStructuredTool` | [`demos/langchain.ts`](demos/langchain.ts) |
54
+ | **Claude Code** | `CLAUDE.md` config | [`demos/claude-code.md`](demos/claude-code.md) |
55
+ | **ElizaOS** | Plugin pattern | [`demos/elizaos.ts`](demos/elizaos.ts) |
56
+ | **AutoGPT** | Direct import | See examples below |
57
+ | **CrewAI** | Tool wrapper | See examples below |
58
+ | **Custom** | Direct TypeScript import | See examples below |
157
59
 
158
- 1. **Measure** — Was the outcome successful? How long did it take? What went wrong?
159
- 2. **Analyze** — Are there patterns in failures? Which task types need different approaches?
160
- 3. **Adapt** — Adjust skill parameters, decomposition strategies, and review thresholds
60
+ ## Quick Start
161
61
 
162
- ```bash
163
- # Record an outcome
164
- npx clawpowers metrics record --skill test-driven-development --outcome success --duration 1800
62
+ ### Payments
165
63
 
166
- # Analyze performance
167
- npx clawpowers analyze
168
- ```
169
-
170
- This isn't theoretical — it's the same RSI framework running in production trading systems with 268+ measured outcomes.
171
-
172
- ### 4. Agent Payments (x402)
173
-
174
- Your agent can pay for premium APIs, compute resources, and services autonomously — within smart-contract-enforced spending limits. No wallet draining. No surprise bills. Built on the payment infrastructure [integrated into NVIDIA's official NeMo Agent Toolkit](https://github.com/NVIDIA/NeMo-Agent-Toolkit-Examples/pull/17).
175
-
176
- ### 5. Beyond Software Development
177
-
178
- Static frameworks stop at coding methodology. ClawPowers includes skills for:
179
-
180
- - **Security auditing** — Automated vulnerability scanning with Trivy, dependency checks, secret detection
181
- - **Content pipeline** — Write, humanize, and publish technical content with platform-specific formatting
182
- - **Market intelligence** — Research competitors, track trends, analyze opportunities
183
- - **Prospecting** — Find leads matching your ICP, enrich contacts, output to CRM
184
-
185
- ## Skills Reference
186
-
187
- ### Core Development (14 skills)
188
-
189
- | Skill | What It Does | Runtime Enhancement |
190
- |-------|-------------|---------------------|
191
- | `subagent-driven-development` | Orchestrate parallel subagents per task | Persistent execution DB, resumable checkpoints, outcome metrics |
192
- | `test-driven-development` | RED-GREEN-REFACTOR enforcement | Mutation analysis, test portfolio management, effectiveness scoring |
193
- | `writing-plans` | Spec → implementation plan | Historical task estimation, dependency validation, plan quality scoring |
194
- | `executing-plans` | Execute plans with verification | Progress persistence, interruption recovery, milestone tracking |
195
- | `brainstorming` | Structured ideation | Cross-session idea persistence, convergence tracking |
196
- | `systematic-debugging` | Hypothesis-driven debugging | Persistent hypothesis tree, pattern matching against known issues |
197
- | `verification-before-completion` | Pre-merge quality gates | Automated verification suite, historical pass rate tracking |
198
- | `finishing-a-development-branch` | Branch cleanup and merge prep | Automated changelog, squash strategy optimization |
199
- | `requesting-code-review` | Prepare and request review | Reviewer match scoring, review history |
200
- | `receiving-code-review` | Process and implement feedback | Feedback pattern tracking, common issues database |
201
- | `using-git-worktrees` | Isolated branch development | Worktree lifecycle management, conflict prediction |
202
- | `using-clawpowers` | Meta-skill: how to use ClawPowers | Adaptive onboarding based on user skill level |
203
- | `writing-skills` | Create new skills via TDD | Skill quality scoring, anti-pattern detection |
204
- | `dispatching-parallel-agents` | Fan-out parallel execution | Load balancing, failure isolation, result aggregation |
205
-
206
- ### Extended Capabilities (6 skills)
207
-
208
- | Skill | What It Does | Why Static Frameworks Can't |
209
- |-------|-------------|----------------------------|
210
- | `agent-payments` | x402 payment protocol, spending limits, autonomous transactions | Requires runtime wallet interaction, smart contract calls |
211
- | `security-audit` | Vulnerability scanning, secret detection, dependency audits | Requires tool execution (Trivy, gitleaks, npm audit) |
212
- | `content-pipeline` | Write → humanize → format → publish | Requires API calls, platform auth, content transformation |
213
- | `learn-how-to-learn` | Metacognitive protocols, anti-pattern detection, confidence calibration | Requires persistent learning state, outcome correlation |
214
- | `market-intelligence` | Competitive analysis, trend detection, opportunity scoring | Requires web access, data aggregation, persistent tracking |
215
- | `prospecting` | Lead generation, contact enrichment, CRM sync | Requires API calls (Exa, Apollo), structured output |
216
-
217
- ### RSI Intelligence Layer (4 skills)
218
-
219
- These skills don't exist in any other framework. They require runtime execution, persistent state, and self-modification capabilities that static prompt collections can never deliver.
220
-
221
- | Skill | What It Does | Why This Changes Everything |
222
- |-------|-------------|----------------------------|
223
- | `meta-skill-evolution` | Every 50 tasks, analyzes outcome patterns, identifies the weakest skill, surgically rewrites its methodology, version bumps | Your agent's coding discipline improves autonomously over time. After 30 days it's measurably better than any static install |
224
- | `self-healing-code` | On test failure: captures error → builds hypothesis tree → generates 2+ patches → applies with coverage guard → auto-commits winner | 3-cycle max with rollback. Turns red tests into green tests without human intervention |
225
- | `cross-project-knowledge` | Persistent pattern library across ALL repos. Bug fixes, architecture decisions, and performance optimizations transfer between projects | Agent working on Project B benefits from everything learned on Projects A, C, D. Knowledge compounds |
226
- | `formal-verification-lite` | Property-based testing with fast-check (JS), Hypothesis (Python), QuickCheck (Haskell). 5 property templates, 1000+ examples per property | Goes beyond "tests pass" to "tests actually prove correctness." Catches edge cases unit tests miss |
227
- | `economic-code-optimization` | Autonomously spends micro-budgets on premium models, cloud GPUs, expert reviews when ROI justifies it. Tracks every cent and learns optimal spend ratios | Agents literally invest in their own performance. Spending efficiency improves over time via RSI feedback loop |
64
+ ```typescript
65
+ import { SpendingPolicy, PaymentExecutor, detect402 } from 'clawpowers';
228
66
 
229
- ## Architecture
67
+ // Configure spending limits
68
+ const policy = new SpendingPolicy({
69
+ dailyLimit: 25, // $25/day
70
+ transactionLimit: 10, // $10 per tx
71
+ allowedDomains: ['api.example.com'],
72
+ });
230
73
 
74
+ // Create executor with your MCP client
75
+ const executor = new PaymentExecutor(policy, mcpClient);
76
+
77
+ // Detect and handle 402 responses
78
+ const payment = detect402({ status: 402, headers: responseHeaders });
79
+ if (payment) {
80
+ const result = await executor.executePayment({
81
+ amount: payment.amount,
82
+ currency: payment.currency,
83
+ recipient: payment.recipient,
84
+ domain: 'api.example.com',
85
+ x402Headers: payment.x402Headers,
86
+ });
87
+ }
231
88
  ```
232
- clawpowers/
233
- ├── skills/ # 26 skill directories, each with SKILL.md
234
- ├── runtime/
235
- │ ├── persistence/ # Cross-session state (store.js + store.sh)
236
- │ ├── metrics/ # Outcome tracking (collector.js + collector.sh)
237
- │ ├── feedback/ # RSI self-improvement (analyze.js + analyze.sh)
238
- │ ├── init.js # Cross-platform runtime setup
239
- │ └── init.sh # Unix-native runtime setup
240
- ├── hooks/
241
- │ ├── session-start # Bash session hook (macOS/Linux)
242
- │ ├── session-start.js # Node.js session hook (all platforms)
243
- │ └── session-start.cmd # Windows batch wrapper
244
- ├── bin/
245
- │ ├── clawpowers.js # Cross-platform CLI (Windows/macOS/Linux)
246
- │ └── clawpowers.sh # Unix-native CLI (macOS/Linux)
247
- ├── plugins/ # Platform-specific plugin manifests
248
- │ ├── .claude-plugin/ # Claude Code
249
- │ ├── .cursor-plugin/ # Cursor
250
- │ ├── .codex/ # Codex
251
- │ ├── .opencode/ # OpenCode
252
- │ └── gemini-extension.json # Gemini CLI
253
- ├── tests/ # 366 test assertions
254
- └── docs/ # Documentation
255
- ```
256
-
257
- **Dual runtime:** Every runtime script exists in both bash (`.sh`) and Node.js (`.js`). Unix users get native bash performance. Windows users get full functionality via Node.js. `npx clawpowers` auto-detects the best runtime for your platform.
258
89
 
259
- ## Platform Support
90
+ ### Memory
260
91
 
261
- | Platform | Windows | macOS | Linux | WSL2 |
262
- |----------|---------|-------|-------|------|
263
- | Claude Code | ✅ | ✅ | ✅ | ✅ |
264
- | Cursor | | ✅ | ✅ | ✅ |
265
- | Codex | | ✅ | ✅ | ✅ |
266
- | OpenCode | ✅ | ✅ | ✅ | ✅ |
267
- | Gemini CLI | ✅ | ✅ | ✅ | ✅ |
92
+ ```typescript
93
+ import { EpisodicMemory, ProceduralMemory, ContextInjector } from 'clawpowers';
94
+
95
+ // Episodic: Task history (append-only JSONL)
96
+ const episodic = new EpisodicMemory('~/.clawpowers/memory/episodic.jsonl');
97
+ await episodic.append({
98
+ taskId: 'task-1',
99
+ timestamp: new Date().toISOString(),
100
+ description: 'Built authentication module',
101
+ outcome: 'success',
102
+ lessonsLearned: ['Always test edge cases'],
103
+ skillsUsed: ['tdd'],
104
+ durationMs: 5000,
105
+ tags: ['auth'],
106
+ });
268
107
 
269
- ## Runtime CLI Reference
108
+ // Procedural: Skill effectiveness tracking
109
+ const procedural = new ProceduralMemory('~/.clawpowers/memory/procedural.json');
110
+ await procedural.update('tdd', { succeeded: true, durationMs: 5000, taskId: 'task-1' });
270
111
 
271
- ```bash
272
- npx clawpowers init # Set up ~/.clawpowers/
273
- npx clawpowers status # Runtime health check
274
- npx clawpowers metrics record --skill <name> --outcome success|failure # Track outcome
275
- npx clawpowers metrics show # View recent metrics
276
- npx clawpowers metrics summary # Per-skill stats
277
- npx clawpowers analyze # RSI performance analysis
278
- npx clawpowers analyze --skill <name> # Analyze specific skill
279
- npx clawpowers store set <key> <value> # Store persistent state
280
- npx clawpowers store get <key> # Retrieve state
281
- npx clawpowers store list [prefix] # List stored keys
112
+ // Context injection: Relevant memories for new tasks
113
+ const injector = new ContextInjector(episodic, procedural);
114
+ const context = await injector.inject(goal, 2000); // 2000 token budget
282
115
  ```
283
116
 
284
- ## Payments Are Optional (and Safe by Default)
285
-
286
- ClawPowers works without any wallet.
117
+ ### RSI (Recursive Self-Improvement)
287
118
 
288
- When you hit a paid boundary (HTTP 402 "Payment Required", premium tools, or agent-to-agent settlements), ClawPowers can pay **only if** you enable it and set spending limits.
289
-
290
- **Default mode: Dry Run**
291
- - We detect payment requirements.
292
- - We evaluate your spending policy (limits + allowlist).
293
- - We log exactly what would happen.
294
- - **No funds move until you explicitly enable live payments.**
295
-
296
- ### Enable payments (2 minutes)
297
-
298
- ```bash
299
- npx clawpowers init
300
- npx clawpowers payments setup
119
+ ```typescript
120
+ import { MetricsCollector, HypothesisEngine, MutationEngine, ABTestManager } from 'clawpowers';
121
+
122
+ // Collect metrics
123
+ const metrics = new MetricsCollector('task-metrics.jsonl', 'skill-metrics.jsonl');
124
+ await metrics.recordTaskMetrics({ taskId: 'task-1', outcome: 'success', /* ... */ });
125
+
126
+ // Generate improvement hypotheses
127
+ const hypothesis = new HypothesisEngine();
128
+ const hypotheses = hypothesis.analyze(skillStats, taskHistory);
129
+
130
+ // Create and test mutations
131
+ const mutations = new MutationEngine('mutations.jsonl');
132
+ const mutation = mutations.createMutation(hypotheses[0]);
133
+
134
+ // A/B test mutations
135
+ const ab = new ABTestManager();
136
+ const test = ab.startTest(mutation, baselineStats);
137
+ ab.recordResult(test.testId, newTaskMetrics);
138
+ const result = ab.evaluateTest(test.testId);
139
+ // result.decision: 'promote' | 'rollback' | 'continue'
301
140
  ```
302
141
 
303
- Choose:
304
- - Keep disabled
305
- - Enable Dry Run (observe what would happen)
306
- - Enable Live Payments (set per-tx and daily limits)
142
+ ### Wallet
307
143
 
308
- All logs are local at `~/.clawpowers/` (never share this directory).
144
+ ```typescript
145
+ import { WalletManager } from 'clawpowers';
309
146
 
310
- ### Try it risk-free
147
+ const wallet = new WalletManager({
148
+ chain: 'base',
149
+ dataDir: '~/.clawpowers/wallet',
150
+ });
311
151
 
312
- ```bash
313
- npx clawpowers demo x402
152
+ const info = await wallet.generate();
153
+ console.log(info.address); // 0x...
314
154
  ```
315
155
 
316
- Runs a local mock x402 merchant — see the full 402 → pay → 200 flow without any real money.
317
-
318
- ## Security Model
319
-
320
- ClawPowers takes agent autonomy seriously — which means taking agent *limits* seriously.
156
+ ## Memory Module
321
157
 
322
- ### Runtime Isolation
158
+ | Layer | Storage | Purpose |
159
+ |-------|---------|---------|
160
+ | **Working** | In-process | Current task context with token budget |
161
+ | **Episodic** | JSONL file | Task history, searchable by keywords |
162
+ | **Procedural** | JSON file | Skill effectiveness tracking with atomic writes |
163
+ | **Checkpoint** | JSON files | Crash recovery, stale detection |
164
+ | **Context Injector** | Computed | Selects relevant memories for new tasks |
323
165
 
324
- - **State directory** (`~/.clawpowers/`) uses `700` permissions — owner-only access
325
- - **Path traversal blocked** — keys containing `/` or `\` are rejected at the store level
326
- - **No network access** — runtime scripts (store, metrics, analyze) are fully offline
327
- - **No eval** — zero use of `eval()`, `Function()`, or dynamic code execution in any runtime script
166
+ ## RSI Module
328
167
 
329
- ### Agent Payment Guardrails
330
-
331
- The `agent-payments` skill uses `agentwallet-sdk` with hard on-chain spending limits:
168
+ The RSI engine implements a continuous improvement loop:
332
169
 
333
170
  ```
334
- Agent wants to spend $15 Auto-approved (under $25/tx limit)
335
- Agent wants to spend $500 → ⏳ Queued for owner approval
336
- Agent spent $490 today → 🛑 Next tx blocked ($500/day limit hit)
171
+ measure hypothesize mutate A/B test promote/rollback → repeat
337
172
  ```
338
173
 
339
- - **Non-custodial** — your private key, your wallet. No third-party custody.
340
- - **ERC-6551 token-bound accounts**wallet is tied to an NFT. Portable, auditable, on-chain.
341
- - **Smart-contract enforced** spending policies live on-chain. The agent literally *cannot* bypass them, even with a prompt injection.
342
- - **Owner override** you can revoke, pause, or adjust limits at any time.
343
-
344
- ### What This Means in Practice
174
+ **Tier Safety:**
175
+ - **T1** (Parameter Tuning)Can auto-apply
176
+ - **T2** (Strategy Evolution) Can auto-apply with notification
177
+ - **T3** (Skill Composition) Requires testing gate
178
+ - **T4** (Architecture Proposals) — **ALWAYS requires human approval**
345
179
 
346
- Even if an agent is compromised (prompt injection, jailbreak, malicious skill), it cannot:
347
- 1. Spend more than the per-transaction limit you set
348
- 2. Exceed the daily/weekly spending cap you configured
349
- 3. Access funds outside its ERC-6551 token-bound account
350
- 4. Modify its own spending policy (only the owner wallet can)
180
+ Safety invariants (spending limits, identity, RSI definitions, sandbox boundaries, credentials) can **NEVER** be modified by RSI.
351
181
 
352
- **Recommendation:** Start with low limits ($5/tx, $25/day) and increase as you build confidence. The SDK supports per-token policies — set tighter limits on volatile assets, looser on stablecoins.
182
+ ## Fee Structure
353
183
 
354
- ## Agent Payment Demo
184
+ | Operation | Fee |
185
+ |-----------|-----|
186
+ | Transaction | 0.77% |
187
+ | Token Swap | 0.30% |
355
188
 
356
- Here's a complete example of an agent autonomously paying for a premium API:
189
+ Fees are applied at the payment execution layer and are included in the transaction amount.
357
190
 
358
- ### 1. Set Up the Wallet (One-Time)
359
-
360
- ```typescript
361
- import { createWallet, setSpendPolicy, NATIVE_TOKEN } from 'agentwallet-sdk';
362
- import { createWalletClient, http } from 'viem';
363
- import { privateKeyToAccount } from 'viem/accounts';
364
- import { base } from 'viem/chains';
191
+ ## Python Integration
365
192
 
366
- // Create wallet on Base (cheapest gas for agent operations)
367
- const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY as `0x${string}`);
368
- const walletClient = createWalletClient({ account, chain: base, transport: http() });
193
+ ```python
194
+ import subprocess
195
+ import json
369
196
 
370
- const wallet = createWallet({
371
- accountAddress: '0xYourAgentWallet',
372
- chain: 'base',
373
- walletClient,
374
- });
375
-
376
- // Set spending guardrails: $5 per request, $50/day max
377
- await setSpendPolicy(wallet, {
378
- token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC on Base
379
- perTxLimit: 5_000_000n, // 5 USDC per transaction
380
- periodLimit: 50_000_000n, // 50 USDC per day
381
- periodLength: 86400, // 24 hours
382
- });
197
+ # Call ClawPowers via Node.js subprocess
198
+ result = subprocess.run(
199
+ ['node', '-e', '''
200
+ import { detect402, SpendingPolicy } from "clawpowers";
201
+ const policy = new SpendingPolicy({ dailyLimit: 25, transactionLimit: 10, allowedDomains: [] });
202
+ const decision = policy.checkTransaction(5.00, "api.example.com");
203
+ console.log(JSON.stringify(decision));
204
+ '''],
205
+ capture_output=True, text=True
206
+ )
207
+ decision = json.loads(result.stdout)
383
208
  ```
384
209
 
385
- ### 2. Agent Pays for Premium Data (Autonomous)
210
+ ## API Reference
211
+
212
+ ### Payments
213
+ - `detect402(response)` — Parse x402 headers from 402 response
214
+ - `isPaymentRequired(error)` — Type guard for 402 errors
215
+ - `SpendingPolicy` — Enforce daily/transaction/domain limits
216
+ - `PaymentExecutor` — Execute payments via MCP client
217
+
218
+ ### Memory
219
+ - `WorkingMemoryManager` — In-process context management
220
+ - `EpisodicMemory` — JSONL task history
221
+ - `ProceduralMemory` — Skill effectiveness tracking
222
+ - `CheckpointManager` — Crash recovery
223
+ - `ContextInjector` — Memory-to-context selection
224
+
225
+ ### RSI
226
+ - `MetricsCollector` — Task/skill metrics in JSONL
227
+ - `HypothesisEngine` — Generate improvement hypotheses
228
+ - `MutationEngine` — Create/apply/revert mutations
229
+ - `ABTestManager` — A/B test mutations
230
+ - `RSIAuditLog` — Append-only audit trail
231
+ - `AutoResearcher` — Research solutions to failures
232
+
233
+ ### Skills
234
+ - `discoverSkills(dir)` — Find skills in a directory
235
+ - `loadSkillManifest(dir)` — Load a single skill manifest
236
+ - `SkillExecutor` — Execute skills with outcome tracking
237
+
238
+ ### Wallet
239
+ - `WalletManager` — High-level wallet operations
240
+ - `generateWallet(config)` — Generate new wallet
241
+ - `importWallet(key, config)` — Import existing wallet
242
+ - `signMessage(msg, keyFile, passphrase)` — Sign a message
243
+
244
+ ### Config
245
+ - `loadConfig()` / `saveConfig()` — Zod-validated config CRUD
246
+ - `initConfig()` — Create default config
247
+ - `getConfigValue()` / `setConfigValue()` — Dot-notation access
386
248
 
387
- ```typescript
388
- import { createX402Client } from 'agentwallet-sdk';
389
-
390
- const x402 = createX402Client(wallet, {
391
- supportedNetworks: ['base:8453'],
392
- globalDailyLimit: 50_000_000n, // matches spend policy
393
- globalPerRequestMax: 5_000_000n,
394
- });
395
-
396
- // Agent encounters a 402 Payment Required response — pays automatically
397
- const response = await x402.fetch('https://api.premium-data.com/market-analysis');
398
- const data = await response.json();
399
- // Cost: $0.50 USDC, auto-approved (under $5 limit)
400
- // Owner sees: tx hash on Base, fully auditable
401
- ```
402
-
403
- ### 3. Track Payment Outcomes (RSI Loop)
404
-
405
- ```bash
406
- # ClawPowers tracks every payment outcome
407
- npx clawpowers metrics record \
408
- --skill agent-payments \
409
- --outcome success \
410
- --duration 3 \
411
- --notes "Paid $0.50 for market analysis API — data quality 9/10"
412
-
413
- # After 10+ payments, analyze ROI
414
- npx clawpowers analyze --skill agent-payments
415
- # Output: success rate, avg cost, cost-per-successful-outcome
416
- ```
417
-
418
- ## Credential
419
-
420
- Built by [AI Agent Economy](https://github.com/up2itnow0822) — the team behind:
249
+ ## License
421
250
 
422
- - Payment infrastructure in [NVIDIA's official NeMo Agent Toolkit](https://github.com/NVIDIA/NeMo-Agent-Toolkit-Examples/pull/17)
423
- - [agentwallet-sdk](https://www.npmjs.com/package/agentwallet-sdk) — agentwallet-sdk v6.0 — Full multi-chain agent wallet: x402 payments, Uniswap V3 swaps, CCTP bridging, ERC-8004 identity, mutual stake escrow, spending policies (741+ downloads/week)
424
- - [agentpay-mcp](https://github.com/up2itnow0822/agentpay-mcp) — MCP payment server for AI agents
425
- - Production trading systems with RSI self-improvement (268+ measured outcomes)
251
+ **Business Source License 1.1 (BSL 1.1)**
426
252
 
427
- ## Contributing
253
+ This software is licensed under the BSL 1.1. You may use it for non-production purposes freely. Production use requires a commercial license until the Change Date, after which the software converts to the Apache 2.0 license.
428
254
 
429
- We welcome contributions. Unlike some frameworks, we don't dismiss legitimate skill proposals with one-word responses. Open an issue or PR — every submission gets a genuine technical review.
255
+ See [LICENSE](LICENSE) for full terms.
430
256
 
431
257
  ## Patent Notice
432
258
 
433
- **Patent Pending** The underlying financial infrastructure (agentwallet-sdk, agentpay-mcp) is covered by USPTO provisional patent application filed March 2026: "Non-Custodial Multi-Chain Financial Infrastructure System for Autonomous AI Agents."
434
-
435
- ## Open Standard + Defensive Patent
436
-
437
- We support the open x402 standard and encourage interoperable implementations. Our [provisional patent filing](https://github.com/up2itnow0822) is defensive — intended to prevent hostile monopolization and protect builders' ability to use open payment rails. Our goal is to be the safest, fastest, most complete implementation, and to help the ecosystem adopt secure agent payments.
259
+ ⚠️ **Patent Pending:** The autonomous payment detection, spending policy enforcement, recursive self-improvement engine, and multi-tier memory systems implemented in this library are subject to pending patent applications filed by AI Agent Economy. Unauthorized commercial use may constitute patent infringement.
438
260
 
439
- ## Disclaimer
440
-
441
- ClawPowers and agentwallet-sdk are non-custodial developer tooling. You control your own keys and set your own spending limits. You are responsible for compliance with applicable laws in your jurisdiction. This software is provided as-is under the MIT license. Nothing in this project constitutes financial advice, custody services, or money transmission.
442
-
443
- ## License
261
+ ---
444
262
 
445
- MIT
263
+ Built by [AI Agent Economy](https://github.com/up2itnow0822) 🦅