Skip to content

Commit 3a22978

Browse files
MajorTalclaude
andcommitted
Rename wallet to agent allowance across all user-facing interfaces
Renames the user-facing concept from "wallet" to "agent allowance" across MCP tools, CLI commands, OpenClaw scripts, and all documentation. Technical wire-level terms (X-Run402-Wallet header, API parameter names) are preserved. Includes auto-migration from wallet.json to allowance.json on first access. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a889527 commit 3a22978

56 files changed

Lines changed: 467 additions & 459 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ When adding a new tool/command, add it to the `SURFACE` array in `sync.test.ts`.
5454

5555
The `core/` module contains shared logic imported by all three interfaces:
5656

57-
- **`config.ts`** — Path resolution and env vars: `getApiBase()`, `getConfigDir()`, `getKeystorePath()`, `getWalletPath()`.
58-
- **`wallet.ts`**`readWallet()`, `saveWallet()` with atomic writes (temp-file + rename, mode 0600).
59-
- **`wallet-auth.ts`** — EIP-191 signing with `@noble/curves`. `getWalletAuthHeaders()` returns headers or null.
57+
- **`config.ts`** — Path resolution and env vars: `getApiBase()`, `getConfigDir()`, `getKeystorePath()`, `getAllowancePath()`.
58+
- **`allowance.ts`**`readAllowance()`, `saveAllowance()` with atomic writes (temp-file + rename, mode 0600).
59+
- **`allowance-auth.ts`** — EIP-191 signing with `@noble/curves`. `getAllowanceAuthHeaders()` returns headers or null.
6060
- **`keystore.ts`** — Unified project credential store. Object schema: `{projects: {id: {anon_key, service_key, tier, lease_expires_at}}}`. Auto-migrates legacy array format and `expires_at``lease_expires_at`. Functions: `loadKeyStore()`, `saveKeyStore()`, `getProject()`, `saveProject()`, `removeProject()`.
6161
- **`client.ts`**`apiRequest()` fetch wrapper. Handles JSON/text responses, 402 payment detection.
6262

@@ -66,15 +66,15 @@ Core functions return `null` or throw — they never call `process.exit()`. Each
6666

6767
Thin re-export layer over `core/dist/` plus MCP-specific wrappers:
6868

69-
- **`config.ts`**, **`client.ts`**, **`keystore.ts`**, **`wallet.ts`** — re-export from core
70-
- **`wallet-auth.ts`** — re-exports core's `getWalletAuthHeaders()` + adds `requireWalletAuth()` which returns MCP error shape
69+
- **`config.ts`**, **`client.ts`**, **`keystore.ts`**, **`allowance.ts`** — re-export from core
70+
- **`allowance-auth.ts`** — re-exports core's `getAllowanceAuthHeaders()` + adds `requireAllowanceAuth()` which returns MCP error shape
7171
- **`errors.ts`** — MCP-specific error formatting (`formatApiError`, `projectNotFound`)
7272
- **`index.ts`** — Entry point. Registers all tools via `McpServer`.
7373
- **`tools/*.ts`** — Each tool exports a Zod schema + async handler
7474

7575
### CLI (`cli/`)
7676

77-
- **`cli/lib/config.mjs`** — Imports from `core/dist/`, adds CLI wrappers (`walletAuthHeaders()` with process.exit, `findProject()` with process.exit). Re-exports core keystore functions.
77+
- **`cli/lib/config.mjs`** — Imports from `core/dist/`, adds CLI wrappers (`allowanceAuthHeaders()` with process.exit, `findProject()` with process.exit). Re-exports core keystore functions.
7878
- **`cli/lib/paid-fetch.mjs`** — Shared `setupPaidFetch()` using viem + @x402/fetch for paid endpoints.
7979
- **`cli/lib/*.mjs`** — Each module exports `async run(sub, args)` with CLI output format.
8080

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![npm: run402](https://img.shields.io/npm/v/run402?label=run402)](https://www.npmjs.com/package/run402)
1111
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
1212

13-
Developer tools for [Run402](https://run402.com) — provision Postgres databases, deploy static sites, serverless functions, generate images, and manage x402 wallets. Available as an MCP server, an OpenClaw skill, and a CLI.
13+
Developer tools for [Run402](https://run402.com) — provision Postgres databases, deploy static sites, serverless functions, generate images, and manage agent allowances. Available as an MCP server, an OpenClaw skill, and a CLI.
1414

1515
English | [简体中文](./README.zh-CN.md)
1616

@@ -60,13 +60,13 @@ npx run402-mcp
6060
| `publish_app` | Publish a project as a forkable app. |
6161
| `list_versions` | List published versions of a project. |
6262
| `get_quote` | Get tier pricing. Free, no auth required. |
63-
| `set_tier` | Subscribe, renew, or upgrade wallet tier. Auto-detects action. Handles x402 payment. |
63+
| `set_tier` | Subscribe, renew, or upgrade tier. Auto-detects action. Handles x402 payment. |
6464
| `archive_project` | Archive a project and remove from local key store. |
65-
| `check_balance` | Check billing account balance for a wallet address. |
66-
| `list_projects` | List all active projects for a wallet address. |
67-
| `wallet_status` | Check local wallet status — address, network, funding. |
68-
| `wallet_create` | Create a new local wallet (Base Sepolia testnet). |
69-
| `wallet_export` | Export the local wallet address. |
65+
| `check_balance` | Check billing account balance for an agent allowance address. |
66+
| `list_projects` | List all active projects for an agent allowance address. |
67+
| `allowance_status` | Check local agent allowance status — address, network, funding. |
68+
| `allowance_create` | Create a new local agent allowance (Base Sepolia testnet). |
69+
| `allowance_export` | Export the local agent allowance address. |
7070
| `request_faucet` | Request free testnet USDC from the Run402 faucet. |
7171
| `generate_image` | Generate a PNG image from a text prompt. $0.03 via x402. |
7272

@@ -79,8 +79,8 @@ A standalone CLI is available in the [`cli/`](./cli/) directory.
7979
```bash
8080
npm install -g run402
8181

82-
run402 wallet create
83-
run402 wallet fund
82+
run402 allowance create
83+
run402 allowance fund
8484
run402 deploy --tier prototype --manifest app.json
8585
```
8686

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ The Run402 API (`api.run402.com`) is operated by Kychee LLC. Report API-side vul
3333

3434
## Security Design
3535

36-
- **Credential storage**: Project keys and wallet private keys are stored locally at `~/.config/run402/` with `0600` permissions (owner read/write only). Atomic writes via temp-file + rename prevent partial-write corruption.
36+
- **Credential storage**: Project keys and allowance private keys are stored locally at `~/.config/run402/` with `0600` permissions (owner read/write only). Atomic writes via temp-file + rename prevent partial-write corruption.
3737
- **No secrets in transit to MCP clients**: The MCP server never sends private keys or service keys in tool responses. Keys are stored locally and used internally for API authentication.
38-
- **Wallet isolation**: Wallet private keys never leave the local machine. They are used only for signing x402 payment transactions.
38+
- **Allowance isolation**: Allowance private keys never leave the local machine. They are used only for signing x402 payment transactions.
3939
- **SQL safety**: The API blocks dangerous SQL operations (CREATE EXTENSION, COPY PROGRAM, ALTER SYSTEM, GRANT/REVOKE, etc.) at the gateway level.
4040
- **Schema isolation**: Each project runs in its own Postgres schema with cross-schema access blocked.

SKILL.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Deploy a static site (HTML/CSS/JS/images). Files are uploaded to S3 and served v
150150
}
151151
```
152152

153-
Free with active tier. Requires wallet auth.
153+
Free with active tier. Requires allowance auth.
154154

155155
**Examples:**
156156
```
@@ -316,8 +316,8 @@ Run402 uses the x402 HTTP payment protocol. Here's what you need to know:
316316

317317
**How to handle it:**
318318
1. Explain to the user what the cost is (e.g., "$0.10 for a 7-day prototype database")
319-
2. If the user has a wallet set up, help them complete the payment
320-
3. If not, guide them through wallet setup (see Wallet Setup below)
319+
2. If the user has an allowance set up, help them complete the payment
320+
3. If not, guide them through allowance setup (see Agent Allowance Setup below)
321321
4. Once payment is complete, retry the same tool call
322322

323323
**Pricing tiers:**
@@ -358,21 +358,21 @@ Run402 uses the x402 HTTP payment protocol. Here's what you need to know:
358358

359359
**Idempotency:** When provisioning or renewing, include an `Idempotency-Key` header to prevent double-charging on retries. The MCP tools handle this automatically when possible.
360360

361-
## Wallet Setup
361+
## Agent Allowance Setup
362362

363-
To pay Run402, the user needs a crypto wallet with USDC on Base. If they don't have one yet, here are the options:
363+
To pay Run402, the user needs an agent allowance with USDC on Base. If they don't have one yet, here are the options:
364364

365-
**Option A: Coinbase AgentKit (recommended)** — Gives you a wallet on Base with built-in x402 support. No KYC, no manual key management.
365+
**Option A: Coinbase AgentKit (recommended)** — Gives you an allowance on Base with built-in x402 support. No KYC, no manual key management.
366366

367367
**Option B: AgentPayy** — Auto-bootstraps an MPC wallet on Base using Coinbase CDP. Purpose-built for x402.
368368

369369
**Option C: x402 OpenClaw Skill** — Install the x402 skill from ClawHub for x402 payment capabilities.
370370

371-
**Funding the wallet:** Once the user has a wallet address, they need USDC on Base. The simplest path: download Coinbase Wallet, buy USDC, send to the wallet address. Base transactions cost under $0.01.
371+
**Funding the allowance:** Once the user has an allowance address, they need USDC on Base. The simplest path: download Coinbase Wallet, buy USDC, send to the allowance address. Base transactions cost under $0.01.
372372

373373
**Testnet:** For testing without real money, use Base Sepolia testnet. Get test USDC from Circle's faucet. The Run402 API supports testnet at the same endpoints.
374374

375-
**Asking for an allowance:** If the user's human controls the wallet funding, suggest:
375+
**Requesting an allowance:** If the user's human controls the allowance funding, suggest:
376376
- Trial: $1 in USDC covers 10 prototype databases
377377
- Monthly: $10/month covers two Hobby projects or 100 prototypes
378378
- One-off: $10 for a project plus buffer for renewals

SKILL.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const REQUIRED_SECTIONS = [
9999
"Payment Handling",
100100
"Tips & Guardrails",
101101
"Tools Reference",
102-
"Wallet Setup",
102+
"Agent Allowance Setup",
103103
];
104104

105105
describe("body required sections", () => {

cli-e2e.test.mjs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -353,60 +353,60 @@ beforeEach(() => {
353353

354354
describe("CLI e2e happy path", () => {
355355

356-
// ── Wallet ──────────────────────────────────────────────────────────────
356+
// ── Allowance ───────────────────────────────────────────────────────────
357357

358-
it("wallet create", async () => {
359-
const { run } = await import("./cli/lib/wallet.mjs");
358+
it("allowance create", async () => {
359+
const { run } = await import("./cli/lib/allowance.mjs");
360360
captureStart();
361361
await run("create", []);
362362
captureStop();
363363
assert.ok(captured().includes("ok"), "should output ok status");
364-
assert.ok(existsSync(join(tempDir, "wallet.json")), "wallet.json should exist");
364+
assert.ok(existsSync(join(tempDir, "allowance.json")), "allowance.json should exist");
365365
});
366366

367-
it("wallet status", async () => {
368-
const { run } = await import("./cli/lib/wallet.mjs");
367+
it("allowance status", async () => {
368+
const { run } = await import("./cli/lib/allowance.mjs");
369369
captureStart();
370370
await run("status", []);
371371
captureStop();
372372
assert.ok(captured().includes("ok"), "should show ok status");
373373
});
374374

375-
it("wallet fund", async () => {
376-
const { run } = await import("./cli/lib/wallet.mjs");
375+
it("allowance fund", async () => {
376+
const { run } = await import("./cli/lib/allowance.mjs");
377377
captureStart();
378378
await run("fund", []);
379379
captureStop();
380380
// Fund polls for balance — mock returns positive immediately
381381
assert.ok(captured().includes("base-sepolia"), "should show balance or faucet result");
382382
});
383383

384-
it("wallet export", async () => {
385-
const { run } = await import("./cli/lib/wallet.mjs");
384+
it("allowance export", async () => {
385+
const { run } = await import("./cli/lib/allowance.mjs");
386386
captureStart();
387387
await run("export", []);
388388
captureStop();
389-
assert.ok(captured().includes("0x"), "should print wallet address");
389+
assert.ok(captured().includes("0x"), "should print allowance address");
390390
});
391391

392-
it("wallet balance", async () => {
393-
const { run } = await import("./cli/lib/wallet.mjs");
392+
it("allowance balance", async () => {
393+
const { run } = await import("./cli/lib/allowance.mjs");
394394
captureStart();
395395
await run("balance", []);
396396
captureStop();
397397
assert.ok(captured().includes("base-sepolia_usd_micros"), "should show balance");
398398
});
399399

400-
it("wallet checkout", async () => {
401-
const { run } = await import("./cli/lib/wallet.mjs");
400+
it("allowance checkout", async () => {
401+
const { run } = await import("./cli/lib/allowance.mjs");
402402
captureStart();
403403
await run("checkout", ["--amount", "5000000"]);
404404
captureStop();
405405
assert.ok(captured().includes("checkout_url"), "should return checkout URL");
406406
});
407407

408-
it("wallet history", async () => {
409-
const { run } = await import("./cli/lib/wallet.mjs");
408+
it("allowance history", async () => {
409+
const { run } = await import("./cli/lib/allowance.mjs");
410410
captureStart();
411411
await run("history", ["--limit", "5"]);
412412
captureStop();
@@ -774,16 +774,16 @@ describe("CLI e2e happy path", () => {
774774
assert.ok(captured().includes("deleted") || captured().includes("ok"), "should delete project");
775775
});
776776

777-
// ── Init (runs after wallet exists) ─────────────────────────────────────
777+
// ── Init (runs after allowance exists) ──────────────────────────────────
778778

779-
it("init (wallet already exists)", async () => {
779+
it("init (allowance already exists)", async () => {
780780
const { run } = await import("./cli/lib/init.mjs");
781781
captureStart();
782782
await run();
783783
captureStop();
784784
const out = captured();
785785
assert.ok(out.includes("Config"), "should show config dir");
786-
assert.ok(out.includes("Wallet"), "should show wallet");
786+
assert.ok(out.includes("Allowance"), "should show allowance");
787787
assert.ok(out.includes("Balance") || out.includes("USDC"), "should show balance");
788788
assert.ok(out.includes("Tier") || out.includes("prototype"), "should show tier");
789789
});

cli/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# run402 CLI
22

3-
Command-line interface for [Run402](https://run402.com) — provision Postgres databases, deploy static sites, generate images, and manage wallets via x402 micropayments.
3+
Command-line interface for [Run402](https://run402.com) — provision Postgres databases, deploy static sites, generate images, and manage agent allowances via x402 micropayments.
44

55
## Installation
66

@@ -17,27 +17,27 @@ npx run402 <command>
1717
## Getting Started
1818

1919
```bash
20-
# 1. Create a local wallet
21-
run402 wallet create
20+
# 1. Create a local agent allowance
21+
run402 allowance create
2222

2323
# 2. Fund it with test USDC (Base Sepolia faucet)
24-
run402 wallet fund
24+
run402 allowance fund
2525

2626
# 3. Deploy your app
2727
run402 deploy --tier prototype --manifest app.json
2828
```
2929

3030
## Commands
3131

32-
### `run402 wallet`
32+
### `run402 allowance`
3333

34-
Manage your local x402 wallet.
34+
Manage your local agent allowance.
3535

3636
```bash
37-
run402 wallet create # Generate a new wallet
38-
run402 wallet status # Show address, network, funding status
39-
run402 wallet fund # Request test USDC from the faucet
40-
run402 wallet export # Print wallet address (for scripting)
37+
run402 allowance create # Generate a new allowance
38+
run402 allowance status # Show address, network, funding status
39+
run402 allowance fund # Request test USDC from the faucet
40+
run402 allowance export # Print allowance address (for scripting)
4141
```
4242

4343
### `run402 deploy`
@@ -98,15 +98,15 @@ Every command supports `--help` / `-h`:
9898

9999
```bash
100100
run402 --help
101-
run402 wallet --help
101+
run402 allowance --help
102102
run402 deploy --help
103103
run402 projects --help
104104
run402 image --help
105105
```
106106

107107
## Notes
108108

109-
- Wallet stored at `~/.run402/wallet.json`
109+
- Agent allowance stored at `~/.run402/allowance.json`
110110
- Project credentials stored at `~/.run402/projects.json`
111111
- Network: Base Sepolia (testnet) — USDC for x402 payments
112112
- Payments are handled automatically — no manual signing required

cli/cli.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Usage:
1313
run402 <command> [subcommand] [options]
1414
1515
Commands:
16-
init Set up wallet, funding, and check tier status
17-
wallet Manage your x402 wallet (create, fund, balance, status)
16+
init Set up allowance, funding, and check tier status
17+
allowance Manage your agent allowance (create, fund, balance, status)
1818
tier Manage tier subscription (status, set)
1919
projects Manage projects (provision, list, query, inspect, delete)
2020
deploy Deploy a full-stack app or static site (requires active tier)
@@ -31,8 +31,8 @@ Commands:
3131
Run 'run402 <command> --help' for detailed usage of each command.
3232
3333
Examples:
34-
run402 wallet create
35-
run402 wallet fund
34+
run402 allowance create
35+
run402 allowance fund
3636
run402 deploy --manifest app.json
3737
run402 projects list
3838
run402 projects sql <project_id> "SELECT * FROM users LIMIT 5"
@@ -57,8 +57,8 @@ switch (cmd) {
5757
await run();
5858
break;
5959
}
60-
case "wallet": {
61-
const { run } = await import("./lib/wallet.mjs");
60+
case "allowance": {
61+
const { run } = await import("./lib/allowance.mjs");
6262
await run(sub, rest);
6363
break;
6464
}

cli/lib/agent.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { API, walletAuthHeaders } from "./config.mjs";
1+
import { API, allowanceAuthHeaders } from "./config.mjs";
22

33
const HELP = `run402 agent — Manage agent identity
44
55
Usage:
66
run402 agent contact --name <name> [--email <email>] [--webhook <url>]
77
88
Notes:
9-
- Free with wallet auth
9+
- Free with allowance auth
1010
- Registers contact info so Run402 can reach your agent
1111
- Only name is required; email and webhook are optional
1212
@@ -23,7 +23,7 @@ async function contact(args) {
2323
if (args[i] === "--webhook" && args[i + 1]) webhook = args[++i];
2424
}
2525
if (!name) { console.error(JSON.stringify({ status: "error", message: "Missing --name <name>" })); process.exit(1); }
26-
const authHeaders = await walletAuthHeaders();
26+
const authHeaders = await allowanceAuthHeaders();
2727

2828
const body = { name };
2929
if (email) body.email = email;

0 commit comments

Comments
 (0)