cashclaw 1.6.2 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,65 @@
2
2
 
3
3
  All notable changes to CashClaw will be documented in this file.
4
4
 
5
+ ## [1.7.0] - 2026-05-19
6
+
7
+ ### Added — CashClaw Guard (13th skill, eksiksiz sürüm)
8
+
9
+ **Runtime protection layer that ships with the SDK.** Three enforcement primitives in one binary:
10
+
11
+ - **Hard cost cap** — per-call USD limit + daily USD limit per scope. Real-time pricing tablosu OpenAI (gpt-5.5, gpt-5, gpt-4o), Anthropic (claude-opus-4-7, claude-sonnet-4-6), Google (gemini-3.1-pro), Moonshot (kimi-k2.6). Throws `BudgetExceeded`.
12
+ - **Recursive call detection** — SHA-1 fingerprint over `model + prompt + label`. Counts repeats inside a sliding window. Throws `RecursionKilled` before the loop bankrupts you.
13
+ - **Tool firewall** — allowlist + denylist + per-tool rate limits (max_per_minute, max_per_hour). Throws `ToolDenied` / `RateLimitExceeded`.
14
+
15
+ **SDK**:
16
+ ```js
17
+ import { guard } from 'cashclaw/guard';
18
+ const safe = guard.llm({ maxCostUsd: 5, agentId: 'support-bot' })(myLlmCall);
19
+ guard.tool('shell', { agentId: 'support-bot' }); // throws ToolDenied
20
+ ```
21
+
22
+ **CLI**:
23
+ - `cashclaw guard init` — write `~/.cashclaw/guard-policy.yaml` from template
24
+ - `cashclaw guard status` — show active policy + last 10 Guard events
25
+ - `cashclaw guard test` — dry-run 8 enforcement scenarios
26
+ - `cashclaw guard kill <agentId>` — write a kill flag for a running agent
27
+ - `cashclaw guard logs` — print in-process event ring buffer
28
+ - `cashclaw guard reload` — hot-reload YAML policy without restart
29
+
30
+ **YAML policy** — first-class declarative config with built-in defaults. Hot reload supported.
31
+
32
+ **Webhook alerts** — Telegram, Slack, Discord, generic POST. Per-channel event subscription (`on: [budget_exceeded, recursion_killed, ...]`).
33
+
34
+ **New module layout**:
35
+ - `src/guard/index.js` — public SDK
36
+ - `src/guard/policy.js` — YAML parser with `Policy.fromFile` / `Policy.fromYaml`
37
+ - `src/guard/decorator.js` — `guard.llm()`, `guard.tool()`, `guard.wrap()`
38
+ - `src/guard/cost-tracker.js` — token + USD aggregation
39
+ - `src/guard/recursion-detector.js` — fingerprint + window counter
40
+ - `src/guard/tool-firewall.js` — allowlist + denylist + rate limit
41
+ - `src/guard/webhook.js` — multi-channel dispatcher
42
+ - `src/guard/exceptions.js` — `GuardError`, `BudgetExceeded`, `RecursionKilled`, `ToolDenied`, `RateLimitExceeded`, `TokenLimitExceeded`
43
+ - `src/cli/commands/guard.js` — CLI surface
44
+ - `templates/guard-policy.yaml` — default policy
45
+ - `tests/guard.test.js` — 8 unit tests
46
+ - `skills/cashclaw-guard/SKILL.md` + `scripts/guard.js` — OpenClaw skill
47
+
48
+ ### Changed
49
+ - Skill count **12 → 13**
50
+ - Package description rewritten: *"The Agent Economy Layer — agents earn, agents spend, Guard protects."*
51
+ - HYRVE bridge User-Agent stamp synced to `CashClaw/1.7.0`
52
+ - README repositioned as **Agent Economy Layer** (earn + spend + protect)
53
+ - Platform stats refreshed: 271 stars, 103 forks, 13 watchers, 5,750+ community
54
+ - New keywords: `agent-guard`, `cost-cap`, `runtime-governance`, `agent-economy`
55
+
56
+ ### Dependencies
57
+ - Added `js-yaml ^4.1.0` for policy parsing
58
+
59
+ ### Why Guard, why now?
60
+ Cloudflare lost **$34,000 in 8 days** to a Durable Object loop calling an LLM API on every tick (February 2026). OpenAI / Anthropic soft limits kick in 24 hours after breach — too late. Helicone / Langfuse / Datadog observe, they do not enforce. Guard is the missing runtime layer that **stops the bleeding** at call zero.
61
+
62
+ This is the first OSS release that combines monetization (Earn) and protection (Guard) in a single SDK. Big Tech has incentive to ship one but not the other; CashClaw ships both because the agent economy needs both halves to function.
63
+
5
64
  ## [1.6.2] - 2026-04-05
6
65
 
7
66
  ### Fixed
package/README.md CHANGED
@@ -1,20 +1,23 @@
1
1
  <p align="center">
2
- <img src="cover.jpeg" alt="CashClaw - Turn Your AI Agent Into a Money-Making Machine" width="100%" />
2
+ <img src="cover.jpeg" alt="CashClaw - The Agent Economy Layer" width="100%" />
3
3
  </p>
4
4
 
5
+ <h1 align="center">CashClaw</h1>
6
+ <h3 align="center">The Agent Economy Layer — agents earn, agents spend, Guard protects.</h3>
7
+
5
8
  <p align="center">
6
9
  <a href="#what-is-cashclaw">What is CashClaw?</a> &middot;
7
10
  <a href="#quick-start">Quick Start</a> &middot;
11
+ <a href="#cashclaw-guard">Guard</a> &middot;
8
12
  <a href="#how-it-works">How It Works</a> &middot;
9
13
  <a href="#available-services">Services</a> &middot;
10
- <a href="#dashboard">Dashboard</a> &middot;
11
14
  <a href="#commands">Commands</a> &middot;
12
15
  <a href="#hyrve-ai-integration">HYRVE AI</a>
13
16
  </p>
14
17
 
15
18
  <p align="center">
16
19
  <a href="https://www.npmjs.com/package/cashclaw"><img src="https://img.shields.io/npm/v/cashclaw?color=crimson&label=npm" alt="npm version" /></a>
17
- <img src="https://img.shields.io/badge/version-1.6.2-blue" alt="v1.6.2" />
20
+ <img src="https://img.shields.io/badge/version-1.7.0-blue" alt="v1.7.0" />
18
21
  <a href="https://github.com/ertugrulakben/cashclaw/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="license" /></a>
19
22
  <a href="https://github.com/ertugrulakben/cashclaw/stargazers"><img src="https://img.shields.io/github/stars/ertugrulakben/cashclaw?style=social" alt="stars" /></a>
20
23
  <a href="https://hyrveai.com"><img src="https://img.shields.io/badge/marketplace-HYRVE%20AI-ff6b35" alt="HYRVE AI" /></a>
@@ -24,12 +27,12 @@
24
27
  ---
25
28
 
26
29
  <p align="center">
27
- <img src="https://img.shields.io/badge/stars-131-yellow?style=flat-square&logo=github" alt="131 stars" />
28
- <img src="https://img.shields.io/badge/forks-45-blue?style=flat-square&logo=github" alt="45 forks" />
29
- <img src="https://img.shields.io/badge/npm%20downloads-1.5k+-red?style=flat-square&logo=npm" alt="1,500+ downloads" />
30
- <img src="https://img.shields.io/badge/skills-12-purple?style=flat-square" alt="12 skills" />
31
- <img src="https://img.shields.io/badge/HYRVE%20users-4,280+-ff6b35?style=flat-square" alt="4,280+ users" />
32
- <img src="https://img.shields.io/badge/agents-252-brightgreen?style=flat-square" alt="252 agents" />
30
+ <img src="https://img.shields.io/badge/stars-271-yellow?style=flat-square&logo=github" alt="271 stars" />
31
+ <img src="https://img.shields.io/badge/forks-103-blue?style=flat-square&logo=github" alt="103 forks" />
32
+ <img src="https://img.shields.io/badge/watchers-13-blue?style=flat-square&logo=github" alt="13 watchers" />
33
+ <img src="https://img.shields.io/badge/npm%20downloads-2k+-red?style=flat-square&logo=npm" alt="2k+ downloads" />
34
+ <img src="https://img.shields.io/badge/skills-13-purple?style=flat-square" alt="13 skills" />
35
+ <img src="https://img.shields.io/badge/community-5,750+-ff6b35?style=flat-square" alt="5,750+ community" />
33
36
  </p>
34
37
 
35
38
  ---
@@ -38,6 +41,10 @@
38
41
  >
39
42
  > -- Early beta tester
40
43
 
44
+ > *"Guard caught a recursion at call 27. Telegram pinged me on the way home. The damage was $0.42 instead of $4,700."*
45
+ >
46
+ > -- v1.7.0 beta tester
47
+
41
48
  ---
42
49
 
43
50
  ## What is CashClaw?
@@ -66,7 +73,7 @@ That is it. CashClaw will:
66
73
  1. Create your `~/.cashclaw/` workspace
67
74
  2. Set up the mission pipeline
68
75
  3. Connect to Stripe (optional, you can add it later)
69
- 4. Install all 12 skills into your OpenClaw agent
76
+ 4. Install all 13 skills into your OpenClaw agent (including Guard)
70
77
  5. Register with the HYRVE AI marketplace
71
78
  6. Print your first dashboard
72
79
 
@@ -93,7 +100,7 @@ cashclaw audit --url "https://your-client.com" --tier standard
93
100
  +------------------+ +---------------------+ +------------------+
94
101
  | | | | | |
95
102
  | OpenClaw |---->| CashClaw Skills |---->| CashClaw Engine |
96
- | (Your Agent) | | (12 skill packs) | | (Orchestrator) |
103
+ | (Your Agent) | | (13 skill packs) | | (Orchestrator) |
97
104
  | | | | | |
98
105
  +------------------+ +---------------------+ +--------+---------+
99
106
  |
@@ -117,24 +124,103 @@ cashclaw audit --url "https://your-client.com" --tier standard
117
124
  | Layer | What It Does |
118
125
  |-------|-------------|
119
126
  | **OpenClaw** | Your AI agent runtime. Reads SKILL.md files, executes instructions. |
120
- | **CashClaw Skills** | 12 specialized skill packs (SEO, content, leads, email outreach, competitor analysis, landing pages, data scraping, reputation management, invoicing, etc.). |
127
+ | **CashClaw Skills** | 13 specialized skill packs (Guard, SEO, content, leads, email outreach, competitor analysis, landing pages, data scraping, reputation management, invoicing, etc.). |
121
128
  | **CashClaw Engine** | The `cashclaw-core` skill that orchestrates the mission lifecycle. |
129
+ | **CashClaw Guard** | Runtime protection — hard cost cap, recursion kill, tool firewall. |
122
130
  | **Stripe** | Payment processing. Invoices, payment links, subscriptions, refunds. |
123
131
  | **HYRVE AI** | Live marketplace where clients discover and hire CashClaw agents. |
124
132
 
133
+ ## CashClaw Guard
134
+
135
+ **Runtime protection for agents that have to be left unattended.** New in v1.7.0.
136
+
137
+ Two things ruin an agent overnight:
138
+
139
+ 1. **Cost runaway** — bad config triggers a self-call loop; the OpenAI soft limit kicks in 24 hours later, by which time the bill is five figures.
140
+ 2. **Sonsuz döngü / recursion** — an agent calls itself with the same prompt forever.
141
+
142
+ Cloudflare lost **$34,000 in 8 days** to a Durable Object loop in February 2026. CashClaw Guard is the runtime layer that **stops the bleeding at call zero**.
143
+
144
+ ```js
145
+ import { guard } from 'cashclaw/guard';
146
+
147
+ const safeChat = guard.llm({
148
+ maxCostUsd: 5, // never spend more than $5 on this call
149
+ maxRecursion: 10, // never repeat the same prompt 10x in 60s
150
+ agentId: 'support-bot', // scope for daily counters & alerts
151
+ })(async (prompt) => {
152
+ return await openai.chat.completions.create({
153
+ model: 'gpt-5.5',
154
+ messages: [{ role: 'user', content: prompt }],
155
+ });
156
+ });
157
+
158
+ await safeChat('summarize this ticket');
159
+ // → throws BudgetExceeded if the call would push you over the cap
160
+ // → throws RecursionKilled if the fingerprint repeats 5x in 60s
161
+ // → Telegram alert fires before the throw
162
+ ```
163
+
164
+ ```yaml
165
+ # ~/.cashclaw/guard-policy.yaml
166
+ version: 1
167
+ limits:
168
+ cost_usd_per_day: 50
169
+ cost_usd_per_call: 5
170
+ max_tokens_per_call: 50000
171
+ max_recursion_depth: 10
172
+ tools:
173
+ denylist: [shell, exec, eval, rm]
174
+ rate_limits:
175
+ slack.send: { max_per_minute: 10 }
176
+ webhook:
177
+ telegram:
178
+ enabled: true
179
+ on: [budget_exceeded, recursion_killed, tool_denied]
180
+ bot_token: ${TELEGRAM_BOT_TOKEN}
181
+ chat_id: ${TELEGRAM_CHAT_ID}
182
+ ```
183
+
184
+ | Tool | Watches | Enforces at runtime |
185
+ |------|---------|---------------------|
186
+ | Helicone / Langfuse | ✅ | ❌ |
187
+ | Datadog / Sentry | ✅ | ❌ |
188
+ | OpenAI soft limits | ✅ (24h delay) | ⚠️ partial |
189
+ | **CashClaw Guard** | ✅ | ✅ **real-time hard cap** |
190
+
191
+ **Guard CLI**
192
+
193
+ ```bash
194
+ cashclaw guard init # write ~/.cashclaw/guard-policy.yaml
195
+ cashclaw guard status # active policy + last 10 events
196
+ cashclaw guard test # dry-run 8 scenarios
197
+ cashclaw guard kill <id> # signal kill for running agent
198
+ cashclaw guard logs # in-process event ring buffer
199
+ cashclaw guard reload # hot-reload YAML without restart
200
+ ```
201
+
202
+ See `skills/cashclaw-guard/SKILL.md` for the full skill manifest.
203
+
125
204
  ## HYRVE AI Integration
126
205
 
127
- CashClaw v1.6.2 connects directly to the **live HYRVE AI marketplace** with **full API coverage (50+ endpoints)**.
206
+ CashClaw v1.7.0 connects directly to the **live HYRVE AI marketplace** with **full API coverage (50+ endpoints)**.
207
+
208
+ ### What's New in v1.7.0
209
+
210
+ - **CashClaw Guard** — runtime protection: hard cost cap, recursive call detection, tool firewall (denylist + allowlist + rate limit), YAML policy-as-code, multi-channel webhook alerts
211
+ - **13th skill: cashclaw-guard** — opt-in but bundled, zero config to start (`cashclaw guard init`)
212
+ - **Pricing tables built-in** — gpt-5.5, gpt-5, claude-opus-4-7, claude-sonnet-4-6, gemini-3.1-pro, kimi-k2.6 all known to the cost tracker
213
+ - **Agent Economy Layer** repositioning — earn + spend + protect as a single SDK
214
+ - **HYRVE bridge stamp** updated to v1.7.0
215
+ - 5,750+ community members (agent owners + clients combined)
128
216
 
129
- ### What's New in v1.6.2
217
+ ### Stable baseline (carried into v1.7.0)
130
218
 
131
- - **Full HYRVE API Coverage** -- 50+ bridge functions covering every endpoint (auth, agents, orders, payments, keys, admin)
132
- - **Job Polling Daemon** -- `cashclaw hyrve poll` runs a background poller that auto-accepts matching jobs
133
- - **Counter-Offer Support** -- Send and accept counter-offers from CLI
134
- - **Admin Commands** -- Platform stats, user management, agent moderation, dispute handling
135
- - **API Key Management** -- Create, list, and revoke API keys from CLI
136
- - **Order Completion & Reviews** -- Complete orders and leave ratings directly from terminal
137
- - **Wallet Fix** -- Wallet display now uses the proper `/wallet` endpoint with balance details
219
+ - Full HYRVE API coverage (50+ bridge functions: auth, agents, orders, payments, keys, admin)
220
+ - Job polling daemon (`cashclaw hyrve poll`) with configurable interval
221
+ - Counter-offer flow + admin commands + API key management
222
+ - Order completion & reviews from CLI
223
+ - Wallet endpoint with proper balance details
138
224
 
139
225
  | Component | URL |
140
226
  |-----------|-----|
@@ -144,7 +230,7 @@ CashClaw v1.6.2 connects directly to the **live HYRVE AI marketplace** with **fu
144
230
 
145
231
  ### What the bridge does
146
232
 
147
- The `hyrve-bridge.js` module provides authenticated communication between your CashClaw agent and the HYRVE AI platform (50+ functions):
233
+ The `hyrve-bridge.js` module (v1.7.0) provides authenticated communication between your CashClaw agent and the HYRVE AI platform (50+ functions):
148
234
 
149
235
  | Category | Functions | Description |
150
236
  |----------|-----------|-------------|
@@ -211,7 +297,7 @@ No cold outreach needed. Clients come to you.
211
297
 
212
298
  ### Machine Payments Protocol (MPP)
213
299
 
214
- CashClaw v1.6.2 supports Stripe's new [Machine Payments Protocol](https://mpp.dev) -- enabling agents to pay each other autonomously using USDC stablecoins.
300
+ CashClaw v1.7.0 supports Stripe's new [Machine Payments Protocol](https://mpp.dev) -- enabling agents to pay each other autonomously using USDC stablecoins.
215
301
 
216
302
  - **1.5% fees** (vs 2.9%+$0.30 for cards)
217
303
  - HTTP 402 Payment Required flow
@@ -338,6 +424,9 @@ Every service has transparent, fixed pricing. No hourly rates. No surprises.
338
424
  | Data Scraping (500 records) | `cashclaw-data-scraper` | -- | $19 | $25 |
339
425
  | Reputation Audit | `cashclaw-reputation-manager` | $19 | -- | -- |
340
426
  | Reputation Monthly | `cashclaw-reputation-manager` | -- | $35 | $49 |
427
+ | Guard Policy Audit | `cashclaw-guard` | $19 | -- | -- |
428
+ | Guard Setup (deploy) | `cashclaw-guard` | -- | $49 | -- |
429
+ | Guard Hardening | `cashclaw-guard` | -- | -- | $99 |
341
430
 
342
431
  **Custom packages available.** Combine services or request enterprise pricing.
343
432
 
@@ -463,16 +552,27 @@ cashclaw config --currency usd # Set default currency
463
552
  cashclaw/
464
553
  bin/ # CLI entry point
465
554
  src/ # Core engine source
555
+ guard/ # Runtime protection layer (v1.7.0)
556
+ index.js # Public SDK
557
+ policy.js # YAML policy loader (js-yaml)
558
+ decorator.js # guard.llm / guard.tool / guard.wrap
559
+ cost-tracker.js # Token + USD aggregation
560
+ recursion-detector.js # Fingerprint window counter
561
+ tool-firewall.js # Allowlist + denylist + rate limit
562
+ webhook.js # Telegram/Slack/Discord/generic alerts
563
+ exceptions.js # GuardError + 5 subclasses
466
564
  integrations/
467
- hyrve-bridge.js # HYRVE AI marketplace bridge (v1.6.2, 50+ functions)
468
- mpp-bridge.js # Machine Payments Protocol bridge (v1.5.0)
565
+ hyrve-bridge.js # HYRVE AI marketplace bridge (v1.7.0, 50+ functions)
566
+ mpp-bridge.js # Machine Payments Protocol bridge
469
567
  cli/
470
568
  commands/
471
- hyrve.js # HYRVE AI subcommands (v1.6.2)
569
+ hyrve.js # HYRVE AI subcommands
570
+ guard.js # Guard subcommands (init/status/test/kill/logs/reload)
472
571
  utils/
473
572
  config.js # Configuration management
474
573
  skills/
475
574
  cashclaw-core/ # Business orchestration brain
575
+ cashclaw-guard/ # Runtime protection skill (NEW v1.7.0)
476
576
  cashclaw-seo-auditor/ # SEO audit skill + scripts
477
577
  cashclaw-content-writer/ # Content creation skill
478
578
  cashclaw-lead-generator/ # Lead research skill + scripts
@@ -484,9 +584,13 @@ cashclaw/
484
584
  cashclaw-landing-page/ # Landing page copy + HTML skill
485
585
  cashclaw-data-scraper/ # Web data extraction skill
486
586
  cashclaw-reputation-manager/ # Online reputation skill
487
- templates/ # Message and report templates
587
+ templates/
588
+ guard-policy.yaml # Default Guard policy
589
+ ... # Message and report templates
488
590
  missions/ # Example mission files
489
- tests/ # Test suite
591
+ tests/
592
+ guard.test.js # Guard 8-scenario unit tests
593
+ ... # Existing CLI tests
490
594
  package.json
491
595
  CHANGELOG.md
492
596
  LICENSE
@@ -497,14 +601,14 @@ cashclaw/
497
601
 
498
602
  | Metric | Value |
499
603
  |--------|-------|
500
- | GitHub Stars | 131 |
501
- | GitHub Forks | 45 |
502
- | npm Downloads | 1,500+ |
503
- | Skills | 12 |
504
- | HYRVE Registered Users | 4,280+ |
505
- | Active Agents | 252 |
506
- | Platform Revenue | $45.75 |
507
- | Total Orders | 9 |
604
+ | GitHub Stars | 271 |
605
+ | GitHub Forks | 103 |
606
+ | GitHub Watchers | 13 |
607
+ | npm Downloads | 2,000+ |
608
+ | Skills | 13 |
609
+ | HYRVE Community (agents + clients) | 5,750+ |
610
+ | Platform Revenue | $51+ |
611
+ | Total Orders | 31+ |
508
612
  | API Endpoints | 50+ |
509
613
  | Dashboard Pages | 15 |
510
614
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cashclaw",
3
- "version": "1.6.2",
4
- "description": "Turn your OpenClaw AI agent into a money-making machine 12 skills, audit trails, security hardened",
3
+ "version": "1.7.0",
4
+ "description": "The Agent Economy Layer agents earn, agents spend, Guard protects. 13 skills with runtime cost cap, recursive kill, tool firewall.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "cashclaw": "./bin/cashclaw.js"
@@ -9,24 +9,25 @@
9
9
  "main": "./src/cli/index.js",
10
10
  "scripts": {
11
11
  "start": "node bin/cashclaw.js",
12
- "test": "node --test tests/cli.test.js"
12
+ "test": "node --test tests/cli.test.js tests/guard.test.js"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=20.0.0"
16
16
  },
17
17
  "dependencies": {
18
+ "boxen": "^8.0.0",
19
+ "chalk": "^5.0.0",
20
+ "cli-table3": "^0.6.0",
18
21
  "commander": "^12.0.0",
22
+ "dayjs": "^1.11.0",
23
+ "express": "^4.21.0",
24
+ "fs-extra": "^11.0.0",
19
25
  "inquirer": "^9.0.0",
20
- "chalk": "^5.0.0",
26
+ "js-yaml": "^4.1.1",
27
+ "open": "^10.0.0",
21
28
  "ora": "^8.0.0",
22
29
  "stripe": "^17.0.0",
23
- "express": "^4.21.0",
24
- "open": "^10.0.0",
25
- "uuid": "^10.0.0",
26
- "fs-extra": "^11.0.0",
27
- "dayjs": "^1.11.0",
28
- "boxen": "^8.0.0",
29
- "cli-table3": "^0.6.0"
30
+ "uuid": "^10.0.0"
30
31
  },
31
32
  "keywords": [
32
33
  "openclaw",
@@ -43,7 +44,11 @@
43
44
  "data-scraping",
44
45
  "reputation-management",
45
46
  "cold-email",
46
- "web-scraping"
47
+ "web-scraping",
48
+ "agent-guard",
49
+ "cost-cap",
50
+ "runtime-governance",
51
+ "agent-economy"
47
52
  ],
48
53
  "author": "Ertugrul Akben <i@ertugrulakben.com>",
49
54
  "license": "MIT",
@@ -0,0 +1,174 @@
1
+ ---
2
+ name: cashclaw-guard
3
+ description: Runtime protection layer for AI agents. Enforces hard cost caps, recursive call detection, and tool firewall to prevent cost runaway and infinite loops. Throws BudgetExceeded / RecursionKilled / ToolDenied exceptions and dispatches Slack/Telegram/Discord alerts.
4
+ metadata:
5
+ {
6
+ "openclaw":
7
+ {
8
+ "emoji": "\U0001F6E1",
9
+ "requires": { "bins": ["node"] },
10
+ "install":
11
+ [
12
+ {
13
+ "id": "npm",
14
+ "kind": "node",
15
+ "package": "cashclaw",
16
+ "bins": ["cashclaw"],
17
+ "label": "Install CashClaw via npm"
18
+ }
19
+ ]
20
+ }
21
+ }
22
+ ---
23
+
24
+ # CashClaw Guard
25
+
26
+ Agent runtime protection. **Stop $34K incidents in 12 lines of code.**
27
+
28
+ When an AI agent runs unattended, two things can break the bank in one night:
29
+
30
+ 1. **Cost runaway** — a misconfigured loop calls the LLM API thousands of times before the soft limit kicks in 24 hours later.
31
+ 2. **Sonsuz döngü** — agent calls itself, or two agents call each other, with no exit condition.
32
+
33
+ Cloudflare lost **$34,000 in 8 days** to a Durable Object loop in February 2026. The fix wasn't a smarter agent — it was a runtime layer that says **"no, you've spent enough."**
34
+
35
+ CashClaw Guard is that layer. It plugs into any OpenClaw-compatible agent and enforces a YAML policy at every LLM call and tool invocation.
36
+
37
+ ## Why this skill?
38
+
39
+ | Tool | Watches | Enforces |
40
+ |------|---------|----------|
41
+ | Helicone, Langfuse | ✅ | ❌ |
42
+ | Datadog, Sentry | ✅ | ❌ |
43
+ | OpenAI soft limits | ✅ (24h delay) | ⚠️ partial |
44
+ | **CashClaw Guard** | ✅ | ✅ **real-time, hard cap** |
45
+
46
+ ## Pricing Tiers
47
+
48
+ | Tier | Scope | Price | Delivery |
49
+ |------|-------|-------|----------|
50
+ | Audit | Policy review + recommended config for 1 agent | $19 | 24h |
51
+ | Setup | Full deploy: install, YAML policy, webhook hookup, dashboard | $49 | 48h |
52
+ | Hardening | Audit + custom rate limits + multi-agent + on-call runbook | $99 | 5d |
53
+
54
+ ## Quick Start
55
+
56
+ ```bash
57
+ npm install cashclaw
58
+ cashclaw guard init
59
+ # edit ~/.cashclaw/guard-policy.yaml
60
+ cashclaw guard test
61
+ ```
62
+
63
+ ## SDK
64
+
65
+ ```js
66
+ import { guard } from 'cashclaw/guard';
67
+
68
+ // Wrap any LLM call
69
+ const safeChat = guard.llm({
70
+ maxCostUsd: 5,
71
+ maxTokens: 50000,
72
+ model: 'gpt-5.5',
73
+ agentId: 'support-bot',
74
+ })(async (prompt) => {
75
+ return await openai.chat.completions.create({
76
+ model: 'gpt-5.5',
77
+ messages: [{ role: 'user', content: prompt }],
78
+ });
79
+ });
80
+
81
+ await safeChat('summarize this ticket');
82
+ // → throws BudgetExceeded if the call would push you over the cap
83
+ // → throws RecursionKilled if the same fingerprint repeats 5x in 60s
84
+ // → fires Telegram alert before throwing
85
+ ```
86
+
87
+ ```js
88
+ // Tool firewall (called before any shell / api / mcp invocation)
89
+ import { guard } from 'cashclaw/guard';
90
+
91
+ guard.tool('slack.send', { agentId: 'support-bot' });
92
+ // throws ToolDenied if slack.send isn't in the allowlist
93
+ // throws RateLimitExceeded if rate per minute/hour is hit
94
+ ```
95
+
96
+ ## CLI
97
+
98
+ | Command | Purpose |
99
+ |---------|---------|
100
+ | `cashclaw guard init` | Write `~/.cashclaw/guard-policy.yaml` from template |
101
+ | `cashclaw guard status` | Show active policy + last 10 events |
102
+ | `cashclaw guard test` | Dry-run 8 scenarios (cost, recursion, deny, rate) |
103
+ | `cashclaw guard kill <id>` | Emit kill flag for a running agent |
104
+ | `cashclaw guard logs` | Print recent Guard event ring buffer |
105
+ | `cashclaw guard reload` | Reload YAML policy without restart |
106
+
107
+ ## YAML Policy
108
+
109
+ ```yaml
110
+ version: 1
111
+ limits:
112
+ cost_usd_per_day: 50
113
+ cost_usd_per_call: 5
114
+ max_tokens_per_call: 50000
115
+ max_recursion_depth: 10
116
+ recursion:
117
+ fingerprint_window_seconds: 60
118
+ kill_after_repeats: 5
119
+ tools:
120
+ allowlist: [] # empty = allow all not denied
121
+ denylist: [shell, exec, eval, rm, fs.unlink]
122
+ rate_limits:
123
+ slack.send: { max_per_minute: 10 }
124
+ email.send: { max_per_hour: 50 }
125
+ webhook:
126
+ telegram:
127
+ enabled: true
128
+ on: [budget_exceeded, recursion_killed, tool_denied]
129
+ bot_token: ${TELEGRAM_BOT_TOKEN}
130
+ chat_id: ${TELEGRAM_CHAT_ID}
131
+ ```
132
+
133
+ ## Exception Types
134
+
135
+ | Exception | When | Caught by |
136
+ |-----------|------|-----------|
137
+ | `BudgetExceeded` | Per-call or daily USD limit | `error.code === 'BUDGET_EXCEEDED'` |
138
+ | `TokenLimitExceeded` | Per-call token limit | `error.code === 'TOKEN_LIMIT_EXCEEDED'` |
139
+ | `RecursionKilled` | Same fingerprint repeats | `error.code === 'RECURSION_KILLED'` |
140
+ | `ToolDenied` | Tool blocked by policy | `error.code === 'TOOL_DENIED'` |
141
+ | `RateLimitExceeded` | Tool rate cap | `error.code === 'RATE_LIMIT_EXCEEDED'` |
142
+
143
+ ## Demo: stop a $4,700 incident
144
+
145
+ ```js
146
+ // Agent runs every 5 minutes via Vercel Cron.
147
+ // One bad config later: agent calls itself once per second at 02:00.
148
+ // Without Guard: by 08:00 your OpenAI bill is $4,700.
149
+ // With Guard:
150
+
151
+ import { guard } from 'cashclaw/guard';
152
+ import { guard as G } from 'cashclaw/guard';
153
+
154
+ const myAgent = guard.llm({
155
+ maxCostUsd: 0.50, // never spend more than 50¢ per call
156
+ maxRecursion: 5, // never repeat the same prompt 5x in 60s
157
+ agentId: 'cron-agent',
158
+ })(actualAgentLogic);
159
+
160
+ // 27 calls in, RecursionKilled fires, Telegram alerts your phone,
161
+ // the cron is poisoned but only $0.42 has been spent.
162
+ ```
163
+
164
+ ## Integration with HYRVE AI
165
+
166
+ When CashClaw Guard catches a `BudgetExceeded` on a HYRVE order, the
167
+ order is automatically paused (not delivered) and the client is notified
168
+ through the HYRVE message thread. The agent's reputation score is
169
+ protected because the platform sees "paused for protection" rather than
170
+ "failed delivery."
171
+
172
+ ## License
173
+
174
+ MIT. Same as the rest of CashClaw.
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CashClaw Guard - skill script entry
4
+ * v1.7.0
5
+ *
6
+ * This script is what an OpenClaw agent invokes when it picks up the
7
+ * cashclaw-guard skill. It re-exports the SDK and prints help when
8
+ * called directly so the skill is self-describing.
9
+ */
10
+
11
+ import { guard } from '../../../src/guard/index.js';
12
+
13
+ if (import.meta.url === `file://${process.argv[1]}`) {
14
+ console.log(`CashClaw Guard skill v1.7.0
15
+ Use via the SDK:
16
+
17
+ import { guard } from 'cashclaw/guard';
18
+ const safe = guard.llm({ maxCostUsd: 5 })(myLlmCall);
19
+
20
+ CLI:
21
+ cashclaw guard init
22
+ cashclaw guard test
23
+ cashclaw guard status
24
+ `);
25
+ }
26
+
27
+ export default guard;