clawpowers 2.0.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/COMPATIBILITY.md +13 -0
- package/KNOWN_LIMITATIONS.md +19 -0
- package/LICENSING.md +10 -0
- package/README.md +201 -9
- package/SECURITY.md +33 -53
- package/dist/index.d.ts +638 -5
- package/dist/index.js +986 -58
- package/dist/index.js.map +1 -1
- package/native/Cargo.lock +4863 -0
- package/native/Cargo.toml +73 -0
- package/native/crates/canonical/Cargo.toml +24 -0
- package/native/crates/canonical/src/lib.rs +673 -0
- package/native/crates/compression/Cargo.toml +20 -0
- package/native/crates/compression/benches/compression_bench.rs +42 -0
- package/native/crates/compression/src/lib.rs +393 -0
- package/native/crates/evm-eth/Cargo.toml +13 -0
- package/native/crates/evm-eth/src/lib.rs +105 -0
- package/native/crates/fee/Cargo.toml +15 -0
- package/native/crates/fee/src/lib.rs +281 -0
- package/native/crates/index/Cargo.toml +16 -0
- package/native/crates/index/src/lib.rs +277 -0
- package/native/crates/policy/Cargo.toml +17 -0
- package/native/crates/policy/src/lib.rs +614 -0
- package/native/crates/security/Cargo.toml +22 -0
- package/native/crates/security/src/lib.rs +478 -0
- package/native/crates/tokens/Cargo.toml +13 -0
- package/native/crates/tokens/src/lib.rs +534 -0
- package/native/crates/verification/Cargo.toml +23 -0
- package/native/crates/verification/src/lib.rs +333 -0
- package/native/crates/wallet/Cargo.toml +20 -0
- package/native/crates/wallet/src/lib.rs +261 -0
- package/native/crates/x402/Cargo.toml +30 -0
- package/native/crates/x402/src/lib.rs +423 -0
- package/native/ffi/Cargo.toml +34 -0
- package/native/ffi/build.rs +4 -0
- package/native/ffi/index.node +0 -0
- package/native/ffi/src/lib.rs +352 -0
- package/native/ffi/tests/integration.rs +354 -0
- package/native/pyo3/Cargo.toml +26 -0
- package/native/pyo3/pyproject.toml +16 -0
- package/native/pyo3/src/lib.rs +407 -0
- package/native/pyo3/tests/test_smoke.py +180 -0
- package/native/wasm/Cargo.toml +44 -0
- package/native/wasm/pkg/.gitignore +6 -0
- package/native/wasm/pkg/clawpowers_wasm.d.ts +208 -0
- package/native/wasm/pkg/clawpowers_wasm.js +872 -0
- package/native/wasm/pkg/clawpowers_wasm_bg.wasm +0 -0
- package/native/wasm/pkg/clawpowers_wasm_bg.wasm.d.ts +40 -0
- package/native/wasm/pkg/package.json +17 -0
- package/native/wasm/pkg-node/.gitignore +6 -0
- package/native/wasm/pkg-node/clawpowers_wasm.d.ts +143 -0
- package/native/wasm/pkg-node/clawpowers_wasm.js +798 -0
- package/native/wasm/pkg-node/clawpowers_wasm_bg.wasm +0 -0
- package/native/wasm/pkg-node/clawpowers_wasm_bg.wasm.d.ts +40 -0
- package/native/wasm/pkg-node/package.json +13 -0
- package/native/wasm/src/lib.rs +433 -0
- package/package.json +24 -3
- package/src/skills/catalog.ts +435 -0
- package/src/skills/executor.ts +56 -0
- package/src/skills/index.ts +3 -0
- package/src/skills/itp/SKILL.md +112 -0
- package/src/skills/loader.ts +193 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to ClawPowers are documented here.
|
|
4
4
|
|
|
5
|
+
## [2.2.0] - 2026-04-08
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **Full secp256k1 Ethereum wallet derivation** (MetaMask-compatible): private key → uncompressed public key (64 bytes) → Keccak-256 → last 20 bytes as EIP-55 checksummed address.
|
|
10
|
+
- **Pure Rust `k256`** (RustCrypto) in `native/crates/evm-eth`, wired into **WASM** and **FFI** with exports: `deriveEthereumAddress`, `derivePublicKey`, `signEcdsa`, `verifyEcdsa`.
|
|
11
|
+
- **TypeScript loader** (`src/native/index.ts`): `keccak256Digest`, `deriveEthereumAddress`, `derivePublicKey`, `signEcdsa`, `verifyEcdsa` (Tier 1 → Tier 2 → `null` / `false` as documented).
|
|
12
|
+
- **`signMessage` overload**: `(privateKeyHex, message)` returns a 65-byte ECDSA signature hex (`r‖s‖v`); existing `(message, keyFile, passphrase)` unchanged in shape, now uses ECDSA+Keccak when tiers allow, else HMAC fallback.
|
|
13
|
+
- **Tests**: `tests/wallet/secp256k1.test.ts` (Hardhat default account #0 vector).
|
|
14
|
+
|
|
15
|
+
### Notes
|
|
16
|
+
|
|
17
|
+
- **WASM**: `getrandom` 0.2 `js` feature enabled for `wasm32` so `k256` builds under `wasm-pack`.
|
|
18
|
+
- **Loader**: If Tier 1 (native) loads, Tier 2 (WASM) is still initialized when available so newer exports (e.g. secp256k1) work when an older `.node` lacks them. `getActiveTier()` remains `native` when the addon is present.
|
|
19
|
+
- Existing keyfiles still use the stored `address` field as the source of truth; newly generated/imported keys use real Ethereum addresses when native or WASM is loaded.
|
|
20
|
+
|
|
21
|
+
## [2.1.0] - 2026-04-06
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- **Native acceleration layer** (parity with ClawPowers-Agent): `native/` Rust workspace (wallet, tokens, policy, fee, x402, canonical, compression, index, verification, security, ffi, WASM crate, PyO3 bindings).
|
|
26
|
+
- **Pre-built WASM** in `native/wasm/pkg-node` and `native/wasm/pkg` so npm installs work **without** `wasm-pack` or Rust.
|
|
27
|
+
- **3-tier TypeScript loader** (`src/native/index.ts`): Tier 1 optional `.node` addon, Tier 2 WASM, Tier 3 pure TypeScript fallbacks. Exported from the package root (`getActiveTier`, `isNativeAvailable`, `isWasmAvailable`, `getCapabilitySummary`, `computeSha256`, `digestForWalletAddress`, `tokenAmountFromHuman`, `calculateFee`, `evaluateWriteFirewall`, etc.).
|
|
28
|
+
- **Payment bridges** (`calculateTransactionFee`, `createPaymentHeader`, `generateWalletAddress`) and **memory bridges** (`getBestCanonicalStore`, `compressVector`, `evaluateWriteSecurity`, …) via `src/payments/native-bridge.ts` and `src/memory/native-store.ts`.
|
|
29
|
+
- **npm scripts:** `build:native`, `build:wasm`.
|
|
30
|
+
- **WASM / native Keccak-256** for wallet address digest when Tier 1 or Tier 2 is active; **SHA-256** remains the Tier 3 fallback only.
|
|
31
|
+
|
|
32
|
+
### Notes
|
|
33
|
+
|
|
34
|
+
- Tier 1 (native) is **optional**; building `native/ffi` requires Rust locally. Published tarballs focus on Tier 2 WASM + Tier 3 TS.
|
|
35
|
+
- Backward compatible at the **API** level for v2.0.0 importers; wallet **address strings** for newly generated keys may differ from v2.0.0 when WASM/native is loaded (Keccak-256 vs former SHA-256-only digest). Existing keyfiles keep their stored `address` field.
|
|
36
|
+
|
|
5
37
|
## [2.0.0] - 2026-04-03
|
|
6
38
|
|
|
7
39
|
### Breaking Changes
|
package/COMPATIBILITY.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Compatibility Matrix
|
|
2
|
+
|
|
3
|
+
## Supported release line
|
|
4
|
+
|
|
5
|
+
| clawpowers | Recommended consumer |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| 2.2.x | capability-library consumers and `clawpowers-agent` 1.1.x |
|
|
8
|
+
|
|
9
|
+
## Notes
|
|
10
|
+
|
|
11
|
+
- `clawpowers` is the capability library, not the stock OpenClaw wrapper runtime.
|
|
12
|
+
- `clawpowers-agent` is the wrapper runtime that consumes this package.
|
|
13
|
+
- When `clawpowers` ships updated skills or capability implementations, `clawpowers-agent` should pick them up through package updates and skill sync.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Known Limitations
|
|
2
|
+
|
|
3
|
+
## Production-ready
|
|
4
|
+
|
|
5
|
+
- capability library APIs for payments, memory, RSI, wallet, swarm, and ITP
|
|
6
|
+
- native plus WASM fallback packaging when shipped correctly
|
|
7
|
+
- local validation commands: lint, typecheck, test, build, pack
|
|
8
|
+
|
|
9
|
+
## Experimental or environment-dependent
|
|
10
|
+
|
|
11
|
+
- prompt-cache economics in benchmark collateral remain modeled, not billed receipts
|
|
12
|
+
- native acceleration availability depends on platform and install environment
|
|
13
|
+
- some consumer behavior depends on the wrapper/runtime that integrates this package
|
|
14
|
+
|
|
15
|
+
## Important operational notes
|
|
16
|
+
|
|
17
|
+
- non-native environments depend on packaged WASM fallback artifacts for real wallet derivation
|
|
18
|
+
- users should not assume modeled prompt-cache savings are direct provider billing results
|
|
19
|
+
- downstream runtimes should validate their own integration behavior separately from this library
|
package/LICENSING.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Licensing and Commercial Use
|
|
2
|
+
|
|
3
|
+
`clawpowers` is released under **BSL-1.1**.
|
|
4
|
+
|
|
5
|
+
## What this means in practice
|
|
6
|
+
|
|
7
|
+
- this package is the core capability library
|
|
8
|
+
- commercial users should review the BSL terms before deployment or redistribution
|
|
9
|
+
- downstream runtimes such as `clawpowers-agent` may use different licenses for their own wrapper code
|
|
10
|
+
- always evaluate the exact published version you plan to ship
|
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# ClawPowers
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Launch surface:** `clawpowers` is the capability library. It is not the stock OpenClaw wrapper runtime. For the wrapper runtime, install `clawpowers-agent`.
|
|
4
|
+
|
|
5
|
+
**Recommended pairing:** `clawpowers` 2.2.x with `clawpowers-agent` 1.1.x.
|
|
6
|
+
|
|
7
|
+
**More docs:** [SECURITY](./SECURITY.md) · [Compatibility](./COMPATIBILITY.md) · [Known Limitations](./KNOWN_LIMITATIONS.md) · [Licensing](./LICENSING.md) · [Releasing](./RELEASING.md) · [Demo](./DEMO.md)
|
|
8
|
+
|
|
9
|
+
**Skills library for AI agents — payments, memory, RSI, wallet, parallel swarm, ITP.** Drop-in capability layer for any agent framework.
|
|
4
10
|
|
|
5
11
|
[](https://www.npmjs.com/package/clawpowers)
|
|
6
12
|
[](LICENSE)
|
|
@@ -9,6 +15,34 @@
|
|
|
9
15
|
npm install clawpowers
|
|
10
16
|
```
|
|
11
17
|
|
|
18
|
+
## 60-Second Demo
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install clawpowers
|
|
22
|
+
node -e "
|
|
23
|
+
const { generateWallet, detect402, SpendingPolicy, signMessage } = await import('clawpowers');
|
|
24
|
+
|
|
25
|
+
// 1. Generate a real Ethereum wallet (MetaMask-compatible)
|
|
26
|
+
const wallet = await generateWallet({ chain: 'base', dataDir: './demo-wallet' });
|
|
27
|
+
console.log('Address:', wallet.address);
|
|
28
|
+
|
|
29
|
+
// 2. Detect an x402 payment-required response
|
|
30
|
+
const req = detect402({ status: 402, headers: {
|
|
31
|
+
'x-payment-amount': '0.10',
|
|
32
|
+
'x-payment-currency': 'USD',
|
|
33
|
+
'x-payment-recipient': '0xabc',
|
|
34
|
+
'x-payment-network': 'base'
|
|
35
|
+
}});
|
|
36
|
+
console.log('Payment required:', req);
|
|
37
|
+
|
|
38
|
+
// 3. Enforce a spending policy
|
|
39
|
+
const policy = new SpendingPolicy({ dailyLimitUsd: 25, allowedDomains: ['api.example.com'] });
|
|
40
|
+
console.log('Allowed:', policy.checkTransaction(0.10, 'api.example.com').allowed);
|
|
41
|
+
"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
That's a real Ethereum wallet, real x402 detection, and a real spending policy check — all in 60 seconds, zero config, zero Rust toolchain. The `native/` Rust acceleration is optional; the WASM tier ships pre-built in the npm package.
|
|
45
|
+
|
|
12
46
|
> **⚠️ 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.
|
|
13
47
|
|
|
14
48
|
---
|
|
@@ -17,11 +51,64 @@ npm install clawpowers
|
|
|
17
51
|
|
|
18
52
|
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:
|
|
19
53
|
|
|
54
|
+
That separation is intentional:
|
|
55
|
+
|
|
56
|
+
- **`clawpowers`** owns the shared capability implementation.
|
|
57
|
+
- **`clawpowers-agent`** owns the stock OpenClaw wrapper runtime.
|
|
58
|
+
- Downstream wrappers should consume this package rather than duplicating capability logic.
|
|
59
|
+
|
|
20
60
|
- **x402 Payments** — Detect HTTP 402 responses, enforce spending policies, execute payments
|
|
21
61
|
- **Three-Tier Memory** — Working, episodic, procedural memory with crash recovery
|
|
22
62
|
- **RSI Engine** — Metrics collection, hypothesis generation, mutation, A/B testing
|
|
23
|
-
- **Wallet** — Generate, import, and sign with
|
|
63
|
+
- **Wallet** — Generate, import, and sign with **MetaMask-compatible** Ethereum addresses out of the box (secp256k1 + Keccak-256 via pre-built WASM, no Rust toolchain required)
|
|
24
64
|
- **Skills** — Discover, load, and track skill execution outcomes
|
|
65
|
+
- **Parallel Swarm** — Concurrent task execution with intelligent model routing and token budgeting
|
|
66
|
+
- **ITP (Identical Twins Protocol)** — Context compression that eliminates redundant token usage across agent sessions
|
|
67
|
+
|
|
68
|
+
## Native Acceleration
|
|
69
|
+
|
|
70
|
+
ClawPowers ships the same optional **Rust + WASM + PyO3** stack as [ClawPowers-Agent](https://github.com/up2itnow0822/ClawPowers-Agent), exposed through a **3-tier loader** in TypeScript. **v2.2.0+:** when a native `.node` addon is present, the WASM bundle is still loaded if available so helpers such as secp256k1 stay available even if your local addon predates those exports; `getActiveTier()` remains `native` in that case.
|
|
71
|
+
|
|
72
|
+
| Tier | Backend | When it loads |
|
|
73
|
+
|------|---------|----------------|
|
|
74
|
+
| **1 — Native** | `napi-rs` `.node` addon (`native/ffi`, built locally with Rust) | Fastest; optional — not required for npm installs |
|
|
75
|
+
| **2 — WASM** | Pre-built `native/wasm/pkg-node` (and `pkg` for web) | **Default** for most Node.js installs — no `wasm-pack` or Rust needed |
|
|
76
|
+
| **3 — TypeScript** | Pure JS / Node built-ins | Universal fallback when native and WASM are unavailable |
|
|
77
|
+
|
|
78
|
+
Check status in code:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { getActiveTier, isNativeAvailable, isWasmAvailable, getCapabilitySummary } from 'clawpowers';
|
|
82
|
+
|
|
83
|
+
console.log(getActiveTier()); // 'native' | 'wasm' | 'typescript'
|
|
84
|
+
console.log(isNativeAvailable(), isWasmAvailable());
|
|
85
|
+
console.log(getCapabilitySummary());
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Building native / WASM locally
|
|
89
|
+
|
|
90
|
+
**Requirements (optional):** Rust (`rustc` 1.70+), `wasm-pack` for regenerating WASM bindings.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npm run build:native # workspace `cargo build --release` (ignored if Rust missing)
|
|
94
|
+
npm run build:wasm # wasm-pack → native/wasm/pkg-node (optional)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`wasm-pack` may regenerate `pkg/.gitignore` / `pkg-node/.gitignore` that ignore all files in those folders — remove those ignore files if you need to commit refreshed WASM output.
|
|
98
|
+
|
|
99
|
+
Pre-built `.wasm` artifacts are included in the package so consumers are **not** required to run `wasm-pack`.
|
|
100
|
+
|
|
101
|
+
### Module coverage (aligned with ClawPowers-Agent)
|
|
102
|
+
|
|
103
|
+
| Area | Tier 1 / 2 capability | TypeScript fallback |
|
|
104
|
+
|------|------------------------|---------------------|
|
|
105
|
+
| Payments | `JsFeeSchedule`, WASM fee math | Pure-TS fee formula |
|
|
106
|
+
| Payments | `JsX402Client` | Base64 JSON header |
|
|
107
|
+
| Payments | `JsAgentWallet` (native only) | TS wallet + WASM secp256k1 + Keccak for real Ethereum addresses |
|
|
108
|
+
| Memory | `JsCanonicalStore`, `JsTurboCompressor`, `JsWriteFirewall` | File/JSONL memory; simplified firewall |
|
|
109
|
+
| Wallet / secp256k1 | Native + WASM: `deriveEthereumAddress`, `derivePublicKey`, `signEcdsa`, `verifyEcdsa`, `computeKeccak256` / `keccak256Bytes` | Tier 3: legacy digest-based “address” + HMAC signing fallback only |
|
|
110
|
+
|
|
111
|
+
Exported helpers include `calculateTransactionFee`, `createPaymentHeader`, `generateWalletAddress`, `compressVector`, `getBestCanonicalStore`, `digestForWalletAddress`, and the full loader API in `src/native/index.ts`.
|
|
25
112
|
|
|
26
113
|
## x402 Payment Flow
|
|
27
114
|
|
|
@@ -141,18 +228,35 @@ const result = ab.evaluateTest(test.testId);
|
|
|
141
228
|
|
|
142
229
|
### Wallet
|
|
143
230
|
|
|
231
|
+
**v2.2.0+ produces real MetaMask-compatible Ethereum addresses** via the standard derivation chain: secp256k1 private key → uncompressed public key → Keccak-256 → last 20 bytes, with EIP-55 checksum case. Verified against the Hardhat default test vector (`0xac09...ff80` → `0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266`). Addresses are importable into MetaMask, Etherscan, and any EVM wallet.
|
|
232
|
+
|
|
233
|
+
**Tier behavior:**
|
|
234
|
+
- **Tier 1** (native `.node` addon, built locally with `cargo`): full secp256k1 + ECDSA + Keccak-256 via the `k256` Rust crate
|
|
235
|
+
- **Tier 2** (pre-built WASM, ships in the npm package): same secp256k1 + ECDSA + Keccak-256 via `k256` compiled to WebAssembly
|
|
236
|
+
- **Tier 3** (pure TypeScript, used only if Tier 1 AND Tier 2 both fail to load): legacy SHA-256 digest and HMAC signing — **not production-safe for on-chain use**
|
|
237
|
+
|
|
238
|
+
Since Tier 2 WASM artifacts ship pre-built in the npm package, **every install gets real Ethereum wallets out of the box** — no Rust toolchain required.
|
|
239
|
+
|
|
144
240
|
```typescript
|
|
145
|
-
import { WalletManager } from 'clawpowers';
|
|
241
|
+
import { WalletManager, generateWallet, signMessage } from 'clawpowers';
|
|
146
242
|
|
|
243
|
+
// High-level API
|
|
147
244
|
const wallet = new WalletManager({
|
|
148
245
|
chain: 'base',
|
|
149
246
|
dataDir: '~/.clawpowers/wallet',
|
|
150
247
|
});
|
|
151
248
|
|
|
152
249
|
const info = await wallet.generate();
|
|
153
|
-
console.log(info.address); // 0x...
|
|
250
|
+
console.log(info.address); // 0x... — real Ethereum address, EIP-55 checksummed
|
|
251
|
+
|
|
252
|
+
// Low-level API for direct key handling
|
|
253
|
+
const sig = await signMessage(privateKeyHex, 'Hello, Ethereum');
|
|
254
|
+
// Returns 65-byte ECDSA signature (r || s || recovery) as 0x-prefixed hex
|
|
255
|
+
// Verifiable by any Ethereum node, ethers.js, viem, or MetaMask
|
|
154
256
|
```
|
|
155
257
|
|
|
258
|
+
For production on-chain sending and transaction construction, you can still use [`viem`](https://viem.sh) or [`ethers`](https://docs.ethers.org) alongside ClawPowers — our wallet produces the same addresses they do.
|
|
259
|
+
|
|
156
260
|
## Memory Module
|
|
157
261
|
|
|
158
262
|
| Layer | Storage | Purpose |
|
|
@@ -179,6 +283,81 @@ measure → hypothesize → mutate → A/B test → promote/rollback → repeat
|
|
|
179
283
|
|
|
180
284
|
Safety invariants (spending limits, identity, RSI definitions, sandbox boundaries, credentials) can **NEVER** be modified by RSI.
|
|
181
285
|
|
|
286
|
+
## Parallel Swarm
|
|
287
|
+
|
|
288
|
+
Run multiple tasks concurrently with intelligent model routing, shared context, and token budget management.
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
import { ConcurrencyManager, TokenPool, classifyHeuristic, selectModel } from 'clawpowers';
|
|
292
|
+
|
|
293
|
+
const pool = new TokenPool({ totalBudget: 100000 });
|
|
294
|
+
const concurrency = new ConcurrencyManager({ maxConcurrency: 5 });
|
|
295
|
+
|
|
296
|
+
// Classify and route tasks to optimal models
|
|
297
|
+
const complexity = classifyHeuristic('Build a distributed trading system');
|
|
298
|
+
const model = selectModel(complexity); // → claude-opus-4-5
|
|
299
|
+
|
|
300
|
+
// Allocate token budgets per task
|
|
301
|
+
pool.allocate('task-1', 5000);
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Swarm vs Sequential Sessions
|
|
305
|
+
|
|
306
|
+
Running N tasks as a single parallel swarm instead of N separate LLM sessions avoids reloading shared context (system prompt, workspace files, tool schemas) for every task.
|
|
307
|
+
|
|
308
|
+
**Measured benefits:**
|
|
309
|
+
- **Wall time:** parallel fan-out is significantly faster than sequential execution, scaling with task count and concurrency limit
|
|
310
|
+
- **Token usage:** shared-context overhead is paid once per swarm run instead of once per task
|
|
311
|
+
|
|
312
|
+
**Current measurement snapshot:**
|
|
313
|
+
|
|
314
|
+
**Live ITP compression measurements:**
|
|
315
|
+
- **25-message corpus:** 11 of 25 messages compressed, `862` to `759` estimated tokens, **11.95% token reduction**, **7.8 ms/message** round-trip
|
|
316
|
+
- **5-task live swarm payload:** `183` to `133` task tokens, **27.32% payload reduction**, **5 of 5 tasks compressed**, **10.8 ms** average encode latency
|
|
317
|
+
|
|
318
|
+
**Modeled prompt-cache economics on those same live prompt sizes:**
|
|
319
|
+
|
|
320
|
+
| Scenario | Effective input units | Reduction vs baseline | Source type |
|
|
321
|
+
|----------|-----------------------|-----------------------|-------------|
|
|
322
|
+
| Baseline | 1902.00 | 0.00% | Derived from live prompt sizes |
|
|
323
|
+
| ITP only | 1848.00 | 2.84% | Live ITP server compression applied to full prompts |
|
|
324
|
+
| Prompt cache only | 752.95 | 60.41% | Anthropic cache-pricing model |
|
|
325
|
+
| ITP + prompt cache | 698.95 | 63.25% | Hybrid result: live ITP compression + modeled cache pricing |
|
|
326
|
+
|
|
327
|
+
- **Shared prompt prefix in swarm test:** 1,372 characters, about 343 estimated input tokens
|
|
328
|
+
- **Three-set hybrid validation on a MacBook Pro (Apple M1, 16 GB RAM) with benchmark runner model `openai-codex/gpt-5.4`:** combined reduction ranged from **61.89%** to **63.25%**, with a **62.56%** mean and **0.56** standard deviation
|
|
329
|
+
|
|
330
|
+
**Reproduce:**
|
|
331
|
+
- `node benchmarks/itp-measurement.mjs` for the live ITP corpus benchmark
|
|
332
|
+
- `node benchmarks/swarm-vs-sequential.mjs` for the structure-only swarm cost model
|
|
333
|
+
- `node benchmarks/itp-cache-swarm-benchmark.mjs` for the hybrid benchmark (live ITP compression + modeled cache economics)
|
|
334
|
+
- `node benchmarks/itp-cache-multi-swarm-benchmark.mjs` for the same hybrid methodology across three swarm sets
|
|
335
|
+
|
|
336
|
+
## ITP (Identical Twins Protocol) - Experimental
|
|
337
|
+
|
|
338
|
+
> **Status: Experimental.** ITP compression and latency numbers below are measured against the running server. Any prompt-cache numbers are modeled Anthropic cache economics applied to those same live prompt sizes.
|
|
339
|
+
|
|
340
|
+
Context compression for multi-agent communication. When agents share similar context (same model, same workspace), ITP deduplicates the common payload before transmission. The library ships with a graceful passthrough fallback, so code using ITP works even when the ITP server is offline. Messages are simply forwarded unchanged.
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
import { itpEncode, itpDecode, itpHealthCheck, encodeTaskDescription, decodeSwarmResult } from 'clawpowers';
|
|
344
|
+
|
|
345
|
+
// Graceful fallback, works without ITP server running
|
|
346
|
+
const encoded = await encodeTaskDescription('Analyze quarterly revenue data');
|
|
347
|
+
const decoded = await decodeSwarmResult(result);
|
|
348
|
+
|
|
349
|
+
// Health check
|
|
350
|
+
const serverUp = await itpHealthCheck(); // false = passthrough mode
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**Live ITP benchmark snapshot:**
|
|
354
|
+
- **Codebook:** `v1.0.0`, 99 entries
|
|
355
|
+
- **Corpus benchmark:** **11.95%** token reduction on 25 messages
|
|
356
|
+
- **Swarm payload benchmark:** **27.32%** task-token reduction on a 5-task swarm
|
|
357
|
+
- **Hybrid swarm benchmark:** **63.25%** effective input-cost reduction from live ITP compression plus modeled prompt caching
|
|
358
|
+
|
|
359
|
+
ITP is most effective in parallel swarm scenarios where multiple tasks share the same model context. Prompt caching handles repeated prompt structure, and ITP reduces the changing task payload inside that structure. Cross-model savings can also compound because providers inject similar preambles across nearby model tiers.
|
|
360
|
+
|
|
182
361
|
## Fee Structure
|
|
183
362
|
|
|
184
363
|
| Operation | Fee |
|
|
@@ -195,13 +374,15 @@ import subprocess
|
|
|
195
374
|
import json
|
|
196
375
|
|
|
197
376
|
# Call ClawPowers via Node.js subprocess
|
|
377
|
+
# Note: use --input-type=module (or a .mjs file) because clawpowers is an ES module
|
|
198
378
|
result = subprocess.run(
|
|
199
|
-
['node', '-
|
|
379
|
+
['node', '--input-type=module'],
|
|
380
|
+
input='''
|
|
200
381
|
import { detect402, SpendingPolicy } from "clawpowers";
|
|
201
382
|
const policy = new SpendingPolicy({ dailyLimit: 25, transactionLimit: 10, allowedDomains: [] });
|
|
202
383
|
const decision = policy.checkTransaction(5.00, "api.example.com");
|
|
203
384
|
console.log(JSON.stringify(decision));
|
|
204
|
-
'''
|
|
385
|
+
''',
|
|
205
386
|
capture_output=True, text=True
|
|
206
387
|
)
|
|
207
388
|
decision = json.loads(result.stdout)
|
|
@@ -209,11 +390,17 @@ decision = json.loads(result.stdout)
|
|
|
209
390
|
|
|
210
391
|
## API Reference
|
|
211
392
|
|
|
393
|
+
### Native acceleration
|
|
394
|
+
- `getActiveTier()`, `isNativeAvailable()`, `isWasmAvailable()`, `getCapabilitySummary()` — Loader introspection
|
|
395
|
+
- `computeSha256`, `digestForWalletAddress`, `tokenAmountFromHuman`, `calculateFee`, `evaluateWriteFirewall` — Routed helpers
|
|
396
|
+
- `getNative()`, `getWasm()` — Low-level module access
|
|
397
|
+
|
|
212
398
|
### Payments
|
|
213
399
|
- `detect402(response)` — Parse x402 headers from 402 response
|
|
214
400
|
- `isPaymentRequired(error)` — Type guard for 402 errors
|
|
215
401
|
- `SpendingPolicy` — Enforce daily/transaction/domain limits
|
|
216
402
|
- `PaymentExecutor` — Execute payments via MCP client
|
|
403
|
+
- `calculateTransactionFee`, `createPaymentHeader`, `generateWalletAddress` — Native/WASM-accelerated payment helpers (with TS fallbacks)
|
|
217
404
|
|
|
218
405
|
### Memory
|
|
219
406
|
- `WorkingMemoryManager` — In-process context management
|
|
@@ -221,6 +408,7 @@ decision = json.loads(result.stdout)
|
|
|
221
408
|
- `ProceduralMemory` — Skill effectiveness tracking
|
|
222
409
|
- `CheckpointManager` — Crash recovery
|
|
223
410
|
- `ContextInjector` — Memory-to-context selection
|
|
411
|
+
- `getBestCanonicalStore`, `getWasmCanonicalStore`, `compressVector`, `decompressVector`, `evaluateWriteSecurity` — Optional native/WASM memory bridges
|
|
224
412
|
|
|
225
413
|
### RSI
|
|
226
414
|
- `MetricsCollector` — Task/skill metrics in JSONL
|
|
@@ -236,10 +424,12 @@ decision = json.loads(result.stdout)
|
|
|
236
424
|
- `SkillExecutor` — Execute skills with outcome tracking
|
|
237
425
|
|
|
238
426
|
### Wallet
|
|
427
|
+
|
|
239
428
|
- `WalletManager` — High-level wallet operations
|
|
240
|
-
- `generateWallet(config)` — Generate new wallet
|
|
241
|
-
- `importWallet(key, config)` — Import existing wallet
|
|
242
|
-
- `signMessage(
|
|
429
|
+
- `generateWallet(config)` — Generate new wallet (**v2.2.0+**: standard Ethereum address via secp256k1 when Tier 1/2 is active)
|
|
430
|
+
- `importWallet(key, config)` — Import existing wallet (same derivation)
|
|
431
|
+
- `signMessage(message, keyFile, passphrase)` — Sign; uses **ECDSA (secp256k1) over Keccak-256(UTF-8 message)** when native/WASM provides crypto, else legacy HMAC
|
|
432
|
+
- `signMessage(privateKeyHex, message)` — Same ECDSA path; returns `0x` + 130 hex chars (65-byte signature)
|
|
243
433
|
|
|
244
434
|
### Config
|
|
245
435
|
- `loadConfig()` / `saveConfig()` — Zod-validated config CRUD
|
|
@@ -261,3 +451,5 @@ See [LICENSE](LICENSE) for full terms.
|
|
|
261
451
|
---
|
|
262
452
|
|
|
263
453
|
Built by [AI Agent Economy](https://github.com/up2itnow0822) 🦅
|
|
454
|
+
|
|
455
|
+
For commercial use, review [LICENSING.md](./LICENSING.md).
|
package/SECURITY.md
CHANGED
|
@@ -2,71 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
## Supported Versions
|
|
4
4
|
|
|
5
|
-
| Version | Supported
|
|
6
|
-
| ------- |
|
|
7
|
-
| 2.
|
|
8
|
-
|
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
| ------- | --------- |
|
|
7
|
+
| 2.2.x | ✅ |
|
|
8
|
+
| 2.1.x | ✅ |
|
|
9
|
+
| < 2.1.0 | ❌ |
|
|
9
10
|
|
|
10
11
|
## Reporting a Vulnerability
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Please report security vulnerabilities via email:
|
|
15
|
-
|
|
16
|
-
📧 **security@ai-agent-economy.com**
|
|
13
|
+
Please report security issues privately to **bill@ai-agent-economy.com**.
|
|
17
14
|
|
|
18
15
|
Include:
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
## Response Timeline
|
|
25
|
-
|
|
26
|
-
- **Acknowledgment:** Within 48 hours
|
|
27
|
-
- **Initial Assessment:** Within 5 business days
|
|
28
|
-
- **Fix Timeline:** Critical vulnerabilities within 7 days
|
|
16
|
+
- affected version
|
|
17
|
+
- reproduction steps
|
|
18
|
+
- impact assessment
|
|
19
|
+
- whether the issue affects native, WASM, or TypeScript fallback paths
|
|
29
20
|
|
|
30
|
-
|
|
21
|
+
Please do not open public GitHub issues for unpatched vulnerabilities.
|
|
31
22
|
|
|
32
|
-
|
|
33
|
-
- **Fail-closed:** Any policy error results in payment rejection
|
|
34
|
-
- **Never auto-retry:** Failed payments are logged but never automatically retried
|
|
35
|
-
- **Daily limits:** Hard-enforced, cannot be overridden by RSI
|
|
36
|
-
- **Domain allowlists:** When configured, only listed domains can receive payments
|
|
23
|
+
## Response Expectations
|
|
37
24
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
2. Core identity and directives
|
|
42
|
-
3. RSI safety tier definitions
|
|
43
|
-
4. Sandbox boundaries
|
|
44
|
-
5. Authentication credentials
|
|
25
|
+
- initial acknowledgement: within 3 business days
|
|
26
|
+
- severity triage: within 5 business days
|
|
27
|
+
- fix target: depends on impact and exploitability
|
|
45
28
|
|
|
46
|
-
|
|
47
|
-
T4 (Architecture Proposals) mutations **always** require human approval. The `'auto'` mode is rejected at the type system level and the validation layer.
|
|
29
|
+
## Scope Notes
|
|
48
30
|
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
31
|
+
ClawPowers ships wallet, payment, memory, and RSI primitives. Security-sensitive areas include:
|
|
32
|
+
- private key generation and storage
|
|
33
|
+
- payment policy enforcement
|
|
34
|
+
- x402 header creation and parsing
|
|
35
|
+
- native and WASM crypto fallbacks
|
|
36
|
+
- local file-backed memory stores
|
|
54
37
|
|
|
55
|
-
|
|
56
|
-
- Episodic memory is append-only (JSONL)
|
|
57
|
-
- Procedural memory uses atomic writes with backup
|
|
58
|
-
- Checkpoint files use write-to-temp-then-rename pattern
|
|
59
|
-
- Corruption recovery is built into episodic memory
|
|
38
|
+
## Data Handling
|
|
60
39
|
|
|
61
|
-
|
|
40
|
+
ClawPowers is designed for local-first operation.
|
|
62
41
|
|
|
63
|
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
42
|
+
- no telemetry is sent by the library itself
|
|
43
|
+
- secrets are not intentionally exfiltrated by package code
|
|
44
|
+
- payment, wallet, and memory data storage behavior depends on the consuming application configuration
|
|
66
45
|
|
|
67
|
-
##
|
|
46
|
+
## Disclosure Policy
|
|
68
47
|
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
48
|
+
We prefer coordinated disclosure. After a fix is available, we may publish:
|
|
49
|
+
- affected versions
|
|
50
|
+
- impact summary
|
|
51
|
+
- remediation guidance
|
|
52
|
+
- CVE or advisory references when applicable
|