vapi-network 0.2.3 → 0.5.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/README.md CHANGED
@@ -1,308 +1,856 @@
1
1
  # vAPI Network
2
2
 
3
3
  **One wallet, every x402 API.** vAPI Network is an open-source, non-custodial
4
- TypeScript toolkit for discovering and paying x402 services from a CLI, MCP
5
- client, or your own code. Call works today. Tasks and Compute are next.
4
+ TypeScript toolkit for discovering and paying x402 services from a terminal, an
5
+ MCP client, or your own code. Your key is generated on your machine, encrypted
6
+ under your passphrase, and never leaves it. vAPI applies spend policy before
7
+ signing, sends the payment straight to the service, and writes a local receipt.
8
+ Every payment identifies this client as `vapi` through x402 `builder-code`; when
9
+ an API advertises `payment-identifier`, the generated id is kept on that receipt.
6
10
 
7
- Your key stays encrypted on your machine. vAPI Network applies spend policy
8
- before signing, sends payment directly to the service, and writes receipts to a
9
- local append-only ledger. It does not hold funds, proxy payments, or send
10
- telemetry off the machine by default.
11
+ Call works today. Tasks and Compute are next.
11
12
 
12
- ## 60-second quickstart
13
-
14
- Install once, then every command is `vapi …`:
13
+ ## Quickstart
15
14
 
16
15
  ```bash
17
16
  npm i -g vapi-network
18
- vapi init # encrypted wallet + config under ~/.vapi (or $VAPI_HOME), prints the address
19
- ```
20
-
21
- Fund that address with `vapi fund` (card or Apple Pay via Coinbase Onramp) or by
22
- sending USDC on Base to it. Then:
23
-
24
- ```bash
25
- vapi fund # hosted onramp link, or direct-transfer instructions
26
- vapi search "weather" # every catalog, merged, with provenance
27
- vapi inspect <listing-ref> # request contract and the live 402 quote, before paying
17
+ vapi init # creates ~/.vapi, the wallet main, and prints its address
18
+ vapi backup # write the 12 words down; vAPI cannot recover them
19
+ vapi fund # opens the hosted funding page for your address
20
+ vapi search "weather" # every catalogue, merged, with provenance
28
21
  vapi pay <listing-ref> --max 0.02
29
- vapi balance
30
- vapi accounts # balances plus network-specific deposit guidance
31
- vapi receipts # one line per paid call: quote, settlement, latency
32
- vapi export-key # print the private key for this wallet, on stdout only
22
+ vapi receipts # one line per paid call: quote, settlement, latency
33
23
  ```
34
24
 
25
+ That is the same order `vapi init` prints as its next steps, and the same order
26
+ `vapi` alone lists. Two more are worth knowing early: `vapi inspect <ref>` shows
27
+ a listing's request contract and live 402 quote for free, before you pay, and
28
+ `vapi balance` shows what the wallet holds.
29
+
35
30
  `vapi search` tags each listing with its group — `[vapi]`, `[added]`,
36
- `[partner]`, or `[external]` — and prints the network fee already inside the
37
- price: vAPI and added APIs carry a 5% network fee inside the quoted price, while
31
+ `[partner]` or `[external]` — and prints the network fee that is already inside
32
+ the price. vAPI and added APIs carry a 5% network fee inside the quoted price;
38
33
  partner and external listings carry none. `vapi inspect` and `--json` return the
39
34
  same `group` and `fee` fields.
40
35
 
41
- No install? Prefix any command with `npx vapi-network`, for example `npx vapi-network init`.
42
- (`npx vapi` cannot work: the bare `vapi` name on npm belongs to an unrelated package.)
36
+ Listing on vAPI is permissionless, and verification is a tier on top of it. Each
37
+ result also carries `[verified]`, `[requested]` or `[unverified]`, and a
38
+ mirrored catalog row carries `[external]` instead. By default `vapi search`
39
+ answers with vAPI-verified listings plus the mirrored external catalogs;
40
+ `--include-unverified` also returns self-listed APIs that passed vAPI's
41
+ automated x402 probe but were never reviewed. `vapi inspect` prints a
42
+ `Verification:` line, `vapi pay` says so in one line before the result when the
43
+ listing it just paid is not verified, and `--json` carries `verification` on
44
+ all three.
45
+
46
+ `vapi inspect` also says how a listing has behaved lately, when the registry
47
+ has measured it: a `Liveness:` line with its uptime over the last seven days of
48
+ hourly re-probes and its p50 and p95 latency, and a `Conformance:` line with the
49
+ x402 version its 402 declares, whether it follows that version, where the offer
50
+ travels, and any issue codes — the same codes `vapi check` reports. A registry
51
+ that has not measured a listing sends neither, and neither line is printed.
52
+ `--json` carries them as `liveness` and `conformance`.
53
+
54
+ When the registry knows it, `vapi inspect` also prints the listing's ERC-8004
55
+ agent identity on Base and its reputation. The client reads these fields from
56
+ the registry and does not read the chain.
57
+
58
+ No install? Prefix any command with `npx vapi-network`, for example
59
+ `npx vapi-network init`. (`npx vapi` cannot work: the bare `vapi` name on npm
60
+ belongs to an unrelated package.)
61
+
62
+ ## Wallets
63
+
64
+ One machine can hold several wallets: your own, and a capped one per agent. Each
65
+ keystore lives in `$VAPI_HOME/wallets/<name>.json`; `$VAPI_HOME/wallets.json`
66
+ records which one is the default, what each may spend, and its label. Names are
67
+ 1 to 32 characters of lowercase letters, digits and dashes.
43
68
 
44
- ### Use it from an agent (MCP)
69
+ ```bash
70
+ vapi wallet list # address, default marker, caps, unlocked, label
71
+ vapi wallet create agent --label "claude code" # a wallet of its own for the agent
72
+ vapi wallet caps agent --per-call 0.05 --per-day 1
73
+ vapi wallet use agent # make it the default for later commands
74
+ vapi pay <listing-ref> --wallet agent --max 0.02
75
+ vapi receipts --wallet agent # or --all-wallets for every one
76
+ ```
45
77
 
46
- Add this to Claude Desktop, Claude Code, or Cursor. The passphrase unlocks the local keystore; it never leaves the machine.
78
+ Every command that touches a wallet takes `--wallet <name>`: `balance`,
79
+ `accounts`, `fund`, `pay`, `sweep`, `receipts`, `stats`, `export-key`, `backup`,
80
+ `import`, `passphrase`, `unlock`, `lock` and `mcp`. Without it, `VAPI_WALLET`
81
+ decides; without that, the default set by `vapi wallet use` does. Each of them
82
+ names the wallet it used — `Wallet: main (0x…)` on the first line, or a `wallet`
83
+ field in `--json` — so neither you nor an agent can be wrong about which key
84
+ just moved.
47
85
 
48
- ```json
49
- {
50
- "mcpServers": {
51
- "vapi": {
52
- "command": "npx",
53
- "args": ["-y", "vapi-network", "mcp"],
54
- "env": { "VAPI_KEYSTORE_PASSWORD": "your-passphrase" }
55
- }
56
- }
57
- }
86
+ Spend caps belong to the wallet, not to the machine, and today's total is
87
+ counted per wallet: an agent cannot spend your daily allowance. Removing a
88
+ wallet is a move, not a delete — the encrypted keystore goes to
89
+ `wallets/.trash/`, where `vapi wallet restore` can bring it back.
90
+
91
+ **Coming from 0.2.x?** Nothing to do. The first command you run opens the wallet
92
+ store, moves `keystore.json` to `wallets/main.json` with its contents untouched,
93
+ turns `config.json`'s spend caps into the caps of `main`, and leaves
94
+ `keystore.json` behind as a mode 0600 symlink for one release so existing
95
+ scripts keep working. A home with no keystore migrates nothing.
96
+
97
+ ## Your wallet is yours
98
+
99
+ `vapi init` generates a 12-word BIP-39 recovery phrase on your machine, derives
100
+ the Base account (`m/44'/60'/0'/0/0`) and, with `--networks base,solana`, the
101
+ Solana account (`m/44'/501'/0'/0'`) from it, and writes the phrase encrypted
102
+ under your passphrase to `$VAPI_HOME/wallets/main.json` (mode 0600). The phrase
103
+ is shown once, on a terminal, and never in `--json` or piped output.
104
+
105
+ Three things vAPI cannot do:
106
+
107
+ - **See it.** No key, phrase or passphrase ever leaves the machine.
108
+ - **Recover it.** There is no copy anywhere to restore from.
109
+ - **Freeze it.** Payments go straight from your wallet to the service.
110
+
111
+ ### Back it up
112
+
113
+ ```bash
114
+ vapi backup # the 12 words, numbered, on a terminal
115
+ vapi backup --json # { "wallet": "main", "recoveryPhrase": "..." }
58
116
  ```
59
117
 
60
- Tools: `call.search`, `call.inspect`, `call.pay`, `wallet.address`, `wallet.balance`,
61
- `wallet.accounts`, `wallet.fund`, `receipts.list`, `receipts.stats`, `support.report`. Spend caps
62
- default to $0.10 per call and $1.00 per day; the wallet checks both before it signs a payment.
118
+ Write the words on paper and keep them somewhere only you reach. Anyone holding
119
+ them can spend the wallet, so never type them into a website or a chat.
63
120
 
64
- ## Sign-in with X
121
+ Wallets created before 0.2.5 have no recovery phrase. `vapi backup` says so and
122
+ points at `vapi export-key`, which prints the private key itself; back that key
123
+ up, or `vapi import --key` it into a new wallet. Restoring a phrase-based wallet
124
+ in MetaMask, Rabby, Coinbase Wallet or Phantom gives the same addresses.
65
125
 
66
- x402 v2 services can require Sign-In-With-X (SIWX) before returning a price. When `call.pay` or
67
- `vapi pay` receives that challenge, vAPI checks that both the challenge domain and URI match the
68
- final resource origin, signs the canonical EIP-4361 message locally with EVM `personal_sign`, and
69
- retries once with `SIGN-IN-WITH-X`. The proof is never sent to a redirect or a different host.
126
+ ### Import and move a wallet
127
+
128
+ ```bash
129
+ vapi import --phrase # type the words at the prompt
130
+ vapi import --phrase --networks base,solana # restore both accounts
131
+ vapi import --key # a 0x private key instead of words
132
+ vapi import --phrase --wallet backup-2026 # into a named wallet of its own
133
+ ```
70
134
 
71
- If the retry returns a normal 402 quote, the usual spend-policy and payment flow continues. If the
72
- resource is free after sign-in, the result has `outcome: "signed_in"` and the local receipt records
73
- `amountAtomic: "0"`.
135
+ `vapi import` reads the secret from a prompt, never from the command line where
136
+ a shell history would keep it, and asks for a new passphrase. It writes a new
137
+ named wallet rather than replacing one: `--wallet <name>` chooses the name, and
138
+ `main` is assumed only on a machine with no wallet yet. `--replace` moves the
139
+ named wallet to `wallets/.trash/` first, and still refuses a wallet that holds
140
+ USDC on Base unless you add `--force`.
74
141
 
75
- ## Fund the wallet
142
+ ### Change the passphrase
76
143
 
77
144
  ```bash
78
- vapi fund # ask the registry for a hosted onramp session
79
- vapi fund --amount 25 # prefill a US dollar amount
80
- vapi fund --json # stable machine-readable shape
145
+ vapi passphrase # current passphrase, then the new one twice
81
146
  ```
82
147
 
83
- `vapi fund` POSTs `{ address, network: "base", asset: "USDC", fiatAmount }` to
84
- `<registry>/api/wallet/onramp-session` through the same guarded network client as
85
- every other command, prints the returned URL, and opens it in your default
86
- browser when you are on a terminal. The onramp is **Coinbase's**: Coinbase takes
87
- the card or Apple Pay payment and sends USDC straight to your local address.
88
- **vAPI never holds your funds**, never proxies the payment, and never sees your
89
- card details or your private key.
148
+ The wallet, its addresses and its recovery phrase are unchanged. Any copy of the
149
+ old passphrase stored by `vapi unlock` is removed at the same time, so nothing
150
+ is left behind that no longer opens the wallet.
151
+
152
+ ### Agents and secrets
153
+
154
+ An agent can drive vAPI all day without ever seeing a secret. It can search,
155
+ inspect, pay from the wallet you gave it, read balances and receipts, and pick a
156
+ wallet by name with `wallet.use` — which changes only that session, never your
157
+ default on disk. It cannot see a recovery phrase, a private key or a passphrase,
158
+ and the MCP server has no tool that creates, removes, renames, backs up or
159
+ exports a wallet.
160
+
161
+ vAPI agents combine a local profile, a dedicated wallet and vAPI Router into a
162
+ small run loop on your machine. By default they use only verified listings, ask
163
+ before a call above $0.50 and stop after at most 12 model steps. vAPI does not
164
+ host agents; they run wherever you run `vapi agent run`.
90
165
 
91
- When the registry replies `503 onramp_unavailable` — or cannot be reached at all
92
- — the command stays useful instead of failing: it prints your address and
166
+ `vapi backup` and `vapi export-key` print a secret, so they run only when a
167
+ person is demonstrably there: stdin and stdout are both a real terminal, no
168
+ agent or CI marker is set, and you type the wallet's own name to confirm.
169
+ Otherwise they print nothing and say:
93
170
 
94
171
  ```text
95
- Send USDC on Base (eip155:8453) to this address; add a little ETH for gas if you plan to sweep.
172
+ Run this yourself in a terminal; an agent must never see these words.
173
+ ```
174
+
175
+ The markers vAPI refuses on are `VAPI_NO_SECRETS`, `CLAUDECODE`, `CLAUDE_CODE`,
176
+ `CURSOR_AGENT`, `CODEX_SANDBOX`, `OPENAI_CODEX`, `AGENT` and `CI`. Set
177
+ `VAPI_NO_SECRETS=1` in a machine's agent configuration to switch secret printing
178
+ off outright. `vapi init` and `vapi wallet create` still create the wallet under
179
+ those conditions; they simply say `Recovery phrase: run vapi backup yourself in
180
+ a terminal to see it.`
181
+
182
+ In the SDK the same line is drawn by the module layout: the functions that
183
+ return a phrase or a key live in the separate `@vapi-network/core/secrets` entry
184
+ point, which the MCP package is forbidden by lint to import.
185
+
186
+ ### Where the passphrase lives
187
+
188
+ An unlock looks in three places, in this order:
189
+
190
+ 1. `VAPI_KEYSTORE_PASSWORD`, kept for CI and for Windows.
191
+ 2. The OS secret store: the macOS Keychain, or libsecret on Linux, under the
192
+ service `vapi-network` and the wallet's name.
193
+ 3. A prompt, when a person is there to answer it.
194
+
195
+ ```bash
196
+ vapi unlock --wallet agent # store it, once, in your own terminal
197
+ vapi wallet list # the UNLOCKED column says which agents can pay
198
+ vapi lock --all # take every stored passphrase back out
199
+ ```
200
+
201
+ `vapi unlock` runs only on a real terminal with no agent marker set, and only
202
+ after it has verified that the passphrase really opens that wallet. The
203
+ passphrase is handed to the OS binary over its standard input, never as a
204
+ command-line argument, so it never appears in `ps`. A run that finds no
205
+ passphrase anywhere and has no terminal says so and names both other routes; an
206
+ agent is never prompted. Windows has no store yet and keeps
207
+ `VAPI_KEYSTORE_PASSWORD`.
208
+
209
+ ### The audit log
210
+
211
+ Every secret export, every wallet change — create, import, remove, restore,
212
+ rename, default, caps, passphrase, unlock, lock — and every MCP session wallet
213
+ switch appends one JSON line to `$VAPI_HOME/audit.log` (mode 0600): the time,
214
+ the event, the wallet, whether a terminal was attached, and which marker was
215
+ set. The line never contains the secret itself, so the log answers "did anything
216
+ export my phrase while the agent was running" without you having to trust the
217
+ agent's own account of it.
218
+
219
+ ## CLI reference
220
+
221
+ Every command accepts `--json`, which writes one JSON value — success or error —
222
+ to stdout. Exit codes are `0` for success, `1` for an operational failure, and
223
+ `2` for invalid usage or an announced preview-only command.
224
+
225
+ | Command | Options | What it does |
226
+ | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
227
+ | `vapi init` | `--networks <base,arc,solana>` | Creates `~/.vapi`, the wallet `main` and the config. Says so if one exists. |
228
+ | `vapi wallet list` | — | Name, address, default marker, caps in USD, unlocked, label |
229
+ | `vapi wallet create <name>` | `--networks <base,arc,solana>`, `--label <text>` | A new wallet, with its own phrase, caps and passphrase |
230
+ | `vapi wallet use <name>` | — | Makes it the default for every later command |
231
+ | `vapi wallet rename <old> <new>` | — | Renames the keystore, the registry entry and that wallet's receipts |
232
+ | `vapi wallet remove <name>` | `--force` | Moves the keystore to `wallets/.trash/`; asks you to type the name |
233
+ | `vapi wallet restore <name>` | — | Brings a removed wallet back, same passphrase |
234
+ | `vapi wallet caps <name>` | `--per-call <usd>`, `--per-day <usd>` | Sets that wallet's spend caps, in US dollars |
235
+ | `vapi fund` | `--amount <usd>`, `--wallet <name>` | Prints and opens the hosted funding page. Makes no network call. |
236
+ | `vapi accounts` | `--enable <solana\|arc>`, `--wallet <name>` | One deposit account per configured network, with balances and guidance |
237
+ | `vapi search [query]` | `--kind <kind>` (repeatable), `--network <caip2>`, `--limit <n>`, `--cursor <cursor>`, `--include-unverified` | Merged discovery across every configured source, tagged by group and tier |
238
+ | `vapi inspect <id>` | `--endpoint <name>` | Verification, fee, liveness, conformance, identity, contract and live quote, for free |
239
+ | `vapi pay <id-or-url>` | `--method`, `--endpoint`, `--body <json>`, `--content-type`, `--network <caip2>`, `--expected-pay-to`, `--max <usd>`, `--wallet <name>` | Calls the API and pays it from the local wallet, naming an unverified tier |
240
+ | `vapi pay --resume <receipt-id>` | — | Checks settlement, shows its payment id, and never pays |
241
+ | `vapi check <url>` | `--method <method>` | Grades its 402, extensions and same-origin discovery. Never pays |
242
+ | `vapi balance` | `--wallet <name>` | The wallet's address and USDC balances |
243
+ | `vapi receipts` | `--limit <n>`, `--wallet <name>`, `--all-wallets` | The local append-only call ledger, newest last |
244
+ | `vapi receipts export` | `--format <json\|csv>`, `--range <24h\|7d\|30d>`, `--wallet <name>`, `--all-wallets` | Raw receipts for a spreadsheet or dashboard |
245
+ | `vapi stats` | `--range <24h\|7d\|30d>`, `--wallet <name>`, `--all-wallets` | Spend, outcomes, latency percentiles and top services |
246
+ | `vapi sweep [<address>]` | `--network <caip2>`, `--wallet <name>` | Moves USDC to an address, or to the linked owner when omitted |
247
+ | `vapi agent create <name>` | `--model <id>`, `--instructions <file>`, `--call-budget <usd>`, `--max-per-call <usd>`, `--router-budget <usd>`, `--approve-above <usd>`, `--include-unverified`, `--max-steps <n>` | Creates a capped local agent wallet, profile and owner link |
248
+ | `vapi agent run <name> "<task>"` | None | Runs the named agent on this machine |
249
+ | `vapi agent list` | None | Lists profiles, links and today's Call and Router budgets |
250
+ | `vapi agent pause <name>` | None | Stops future runs until the agent is resumed |
251
+ | `vapi agent resume <name>` | None | Allows a paused agent to run again |
252
+ | `vapi agent revoke <name>` | None | Revokes the link and removes the profile, but keeps its wallet |
253
+ | `vapi login` | `--wallet <name>`, `--label <name>`, `--publish`, `--no-browser` | Links the local agent wallet to your vAPI account |
254
+ | `vapi logout` | `--wallet <name>` | Removes the selected wallet's agent link and stored credentials |
255
+ | `vapi whoami` | `--wallet <name>` | Shows the chosen wallet's owner link and permissions, whether the link is live, and its ERC-8004 agent identity. |
256
+ | `vapi router models` | `--wallet <name>` | Lists the vAPI Router model ids |
257
+ | `vapi router usage` | `--wallet <name>` | Shows the agent's Compute allowance and Router balance |
258
+ | `vapi router chat --model <id> "<prompt>"` | `--system <text>`, `--max-tokens <n>`, `--wallet <name>` | Sends one chat request through vAPI Router |
259
+ | `vapi router key` | `--rotate`, `--wallet <name>` | Prints a gated Router key or rotates it without printing it |
260
+ | `vapi router buy <1\|5\|20\|50>` | `--wallet <name>`, `--json` | Buys vAPI Router balance with USDC from your wallet |
261
+ | `vapi router buy --auto <tier> --below <usd>` | `--wallet <name>`, or use `--auto off` | Sets or clears automatic vAPI Router balance refill |
262
+ | `vapi stake status` | `--wallet <name>` | Shows the linked owner's stake and Compute today |
263
+ | `vapi stake open` | `--wallet <name>`, `--no-browser` | Prints and optionally opens the staking page |
264
+ | `vapi export-key` | `--network <caip2>`, `--wallet <name>` | Prints the private key. Terminal only, never for an agent. |
265
+ | `vapi backup` | `--wallet <name>` | Prints the 12 words. Terminal only, never for an agent. |
266
+ | `vapi import` | `--phrase` or `--key`, `--wallet <name>`, `--networks <base,arc,solana>`, `--replace`, `--force` | Restores a wallet from a prompt, never from argv |
267
+ | `vapi passphrase` | `--wallet <name>` | Re-encrypts the keystore under a new passphrase |
268
+ | `vapi unlock` | `--wallet <name>` | Puts that wallet's passphrase in the OS secret store |
269
+ | `vapi lock` | `--wallet <name>`, `--all` | Takes a stored passphrase back out |
270
+ | `vapi report "<what>"` | `--include-addresses`, `--send` | Writes a privacy-preserving local bug report |
271
+ | `vapi auth set-key` | — | Types the registry API key on a prompt into the OS secret store |
272
+ | `vapi auth status` | — | Whether this machine has a key and where it comes from, masked |
273
+ | `vapi auth clear` | — | Takes the stored key back out |
274
+ | `vapi publish <url>` | `--method`, `--mode <origin\|endpoint\|openapi>`, `--name <text>`, `--description <text>`, `--category <ai\|data\|crypto\|compute\|search>`, `--select <names>`, `--wallet <name>`, `--yes`, `--resume` | Probes your API, lists the endpoints you pick, signs the payout wallet |
275
+ | `vapi publish activate <slug>` | — | Takes a listing live once its FeeSplitter is deployed |
276
+ | `vapi publish verify-request <slug>` | — | Asks vAPI to review the listing |
277
+ | `vapi publish list` | — | Every listing this API key owns |
278
+ | `vapi claim <origin>` | `--wallet <name>` | Takes over the listings vAPI indexed from your API, signed by their payee |
279
+ | `vapi mcp` | `--wallet <name>` | Serves the MCP tools over stdio |
280
+ | `vapi serve` | — | Preview only; exits `2` with a message |
281
+ | `vapi version` | — | The client version, also as `--version` or `-v` |
282
+ | `vapi help` | — | The same help bare `vapi` shows, also as `--help` or `-h` |
283
+
284
+ `vapi pay` also accepts `--max-price-usd` as a long-standing alias for `--max`;
285
+ the two cannot be combined. When a paid call loses its response, `vapi pay` refuses to guess
286
+ and names its receipt: `vapi pay --resume <receipt-id>` asks the token contract
287
+ on that receipt's network, with EIP-3009 `authorizationState(authorizer,
288
+ nonce)`, whether the signed authorization was used. **Settled** means the
289
+ payment went through — do not pay again. **Expired** means it was never used
290
+ and the chain is past its `validBefore`, so it never can be — paying again is
291
+ safe. **Pending** means it is unused but still valid — wait until the time it
292
+ prints. It unlocks no wallet and signs nothing. EVM only for now; a Solana
293
+ receipt says so, and a receipt written before 0.4.0 does not record the nonce.
294
+ Every payment payload carries the client code `vapi` in the x402 `builder-code`
295
+ extension. When the API advertises `payment-identifier`, vAPI generates one id,
296
+ sends it with the payment, records it as `paymentId` on the receipt, and shows
297
+ it again in `vapi pay --resume`. `mcp --json` is accepted as a no-op, because
298
+ the stdio transport is already JSON-RPC.
299
+
300
+ ## Check your API
301
+
302
+ `vapi check` is a free x402 conformance doctor for the API you are building. It
303
+ asks the URL for its price without paying, grades the 402 the way a client reads
304
+ it, and looks for the origin's discovery documents:
305
+
306
+ ```bash
307
+ vapi check https://weather.example/forecast
308
+ vapi check https://weather.example/alerts --method POST --json
96
309
  ```
97
310
 
98
- Either way it finishes by printing the current balance. MCP clients can use the
99
- `wallet.fund` tool, which returns the same `{ url }` or the same fallback text.
311
+ | Rule | Passes when |
312
+ | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
313
+ | `status` | the URL answers HTTP 402 |
314
+ | `transport` | the offer is readable: a base64 `PAYMENT-REQUIRED` header, a JSON body, or both; or the 402 carries an MPP (`WWW-Authenticate: Payment`) challenge, which is recognised but not payable with `vapi pay` |
315
+ | `version` | it declares `x402Version` 2 (1 is a warning: v2-only clients cannot pay it) |
316
+ | `fields` | every field that version requires is present and well-typed |
317
+ | `scheme` | at least one accepted option is `exact` |
318
+ | `asset` | an exact option pays canonical USDC, with USDC's EIP-712 domain, on Base, Arc mainnet, Arc testnet or Solana |
319
+ | `pay_to` | every exact option's `payTo` is a valid, non-zero address for its network |
320
+ | `timeout` | `maxTimeoutSeconds` is a whole number between 10 and 3600 |
321
+ | `extensions` | the offer advertises Bazaar metadata; every known advertised extension is listed |
322
+ | `discovery` | `/.well-known/x402` serves a JSON document (a warning otherwise) |
323
+ | `openapi` | a discovered OpenAPI document describes the operation with `x-payment-info` |
324
+
325
+ The JSON report's `transport` field is `x402` or `mpp`; x402-only rules are
326
+ skipped for an MPP 402.
327
+
328
+ The `extensions` rule reports `bazaar`, `builder-code`, `payment-identifier`,
329
+ `sign-in-with-x`, `offer-and-receipt` and `auth-hints` in that order. Missing
330
+ Bazaar metadata is a `bazaar_metadata_missing` warning because adding it makes
331
+ the API discoverable in Coinbase's Bazaar and by Coinbase for Agents. This
332
+ local warning does not appear in the registry-shaped `conformance.issues`.
333
+
334
+ For OpenAPI, the check tries `openapi.json` beside the checked path and then in
335
+ each ancestor directory, nearest first, ending at the origin's `/openapi.json`.
336
+ If none has a `paths` object, it reads `/.well-known/api-catalog` and follows up
337
+ to 10 RFC 9264 `service-desc` links in order. It only follows same-origin links.
338
+
339
+ Offer findings carry stable snake_case codes — `v2_missing_resource`,
340
+ `offer_header_only`, `v2_header_malformed`, `scheme_unsupported` and the rest —
341
+ the same codes the registry records for a listing and `vapi inspect` prints.
342
+ `--json` returns the whole report, including the advertised `extensions` list
343
+ and a `conformance` object in the registry's shape. The exit code is `0` when
344
+ nothing failed, warnings included, `1` when a rule failed, and `2` for invalid
345
+ usage. No wallet is opened, nothing is signed, and no registry is called: the
346
+ only requests go to the origin being checked, through the same network guard as
347
+ every other request.
348
+
349
+ In CI, the repository is also a GitHub Action that runs the published CLI:
350
+
351
+ ```yaml
352
+ - uses: vAPI-Network/vapi-network@main
353
+ with:
354
+ url: https://weather.example/forecast
355
+ fail-on: warn # or fail, the default
356
+ ```
357
+
358
+ It prints every rule, annotates failures and warnings, exposes the JSON report
359
+ as the `report` output, and fails the step on a failed rule — or on a warning
360
+ too, with `fail-on: warn`.
361
+
362
+ ## Publish an API
100
363
 
101
- ## Accounts and deposits
364
+ Listing on vAPI is permissionless. vAPI probes the URL you hand it; if it
365
+ answers x402, the listing exists, and you decide when it goes live.
102
366
 
103
- `vapi accounts` lists one deposit account for every configured network, including its CAIP-2 ID,
104
- network name, address, atomic and formatted USDC balance, gas-token balance, and deposit guidance.
105
- Use `--json` for the stable `{ "accounts": [...] }` shape. `vapi init` prints the same account list
106
- after creating the encrypted keystore and configuration. MCP clients can use `wallet.accounts`.
367
+ ```bash
368
+ vapi auth set-key # paste the key from the console, once
369
+ vapi publish https://weather.example # probe, pick endpoints, sign the payout wallet
370
+ vapi publish activate weather-call # once the FeeSplitter is deployed
371
+ vapi publish verify-request weather-call # ask for the review that ends the [unverified] tag
372
+ vapi publish list
373
+ ```
374
+
375
+ `vapi publish` takes an origin, a single endpoint, or an OpenAPI document, plus
376
+ `--mode` when the registry should not have to guess which. It prints every
377
+ probe step; on a refusal it prints the code, the reason and the hint, and exits
378
+ `2` without signing anything. On a terminal it asks which endpoints to list — a
379
+ script names them with `--select forecast,alerts`, or takes all of them with
380
+ `--yes`, and then has to supply `--name`, `--description` and `--category`
381
+ itself.
382
+
383
+ A listing holds at most 20 endpoints, so a larger catalog is published as
384
+ several listings of up to 20 — `Weather (1/4)`, `Weather (2/4)` and so on, in
385
+ probe order — each with its own signature of the payout line, and every
386
+ endpoint gets one result line: `listed` with its slug, `failed` with the
387
+ reason, or `pending` when an earlier refusal stopped the run. A batch refused
388
+ on its own merits does not stop the next one; a rejected key, a rate limit or
389
+ an outage does. Run the same command again with `--resume` and it asks
390
+ `vapi publish list` what this key already lists, skips those endpoints, and
391
+ lists only the rest.
392
+
393
+ Your wallet signs one line, `Confirm this wallet receives vAPI Call payouts`,
394
+ so the registry knows where the money goes. It is an EIP-4361 message bound to
395
+ the registry's own host and to Base: nothing is paid, nothing is approved, and
396
+ no key leaves the machine.
397
+
398
+ Payouts arrive through a FeeSplitter you own. Deploying it is a wallet
399
+ transaction against the factory, so it stays in the console at
400
+ `<registry>/providers`; `vapi publish` prints the address it will have on each
401
+ network and the exact next step. An active listing answers
402
+ `vapi search --include-unverified`, and `vapi publish verify-request <slug>`
403
+ asks for the review that puts it in the default search.
404
+
405
+ ### Claim a listing vAPI indexed
406
+
407
+ vAPI mirrors public x402 catalogs, so your API may already be listed without
408
+ you. If it is, you can own those listings instead of publishing new ones:
409
+
410
+ ```bash
411
+ vapi claim https://weather.example --wallet payout # the wallet the listings pay
412
+ ```
107
413
 
108
- Base uses the wallet's EVM address and tells you to send USDC on Base. For Arc testnet, add the
109
- faucet URL or instructions to that network's `config.json` entry:
414
+ The registry sends an EIP-4361 message bound to its own host and to Base, with
415
+ the statement `Claim the vAPI Call listings served from <origin>`. vapi checks
416
+ that the message says exactly that for this wallet before it signs anything,
417
+ signs it the same way `vapi publish` signs its payout line, and the registry
418
+ matches the signer against the listings' `payTo`. Every unowned indexed listing
419
+ served from that origin that pays this wallet becomes yours; they stay paid
420
+ directly to it with no vAPI fee, `vapi publish list` shows them, and `vapi
421
+ publish verify-request <slug>` asks for review. A wallet that is not the payee,
422
+ an origin with nothing to claim, and listings that already have an owner each
423
+ get their own sentence and exit `1`. Like publishing, claiming needs `vapi auth
424
+ set-key` and has no MCP tool.
425
+
426
+ The API key is a secret like any other here. `vapi auth set-key` reads it from
427
+ a prompt, never from an argument, and keeps it in the same OS secret store as
428
+ your passphrase — or in `~/.vapi/config.json` at mode 0600 on a platform that
429
+ has none. `VAPI_API_KEY` is the route for CI. No agent can reach it: there is
430
+ no publish tool on the MCP server, and the key lives behind its own package
431
+ entry point that `packages/mcp` is forbidden to import.
432
+
433
+ ## MCP
434
+
435
+ Add this to Claude Code, Claude Desktop or Cursor:
110
436
 
111
437
  ```json
112
438
  {
113
- "depositUrl": "https://your-arc-faucet.example",
114
- "depositInstructions": "Use the configured Arc testnet faucet, then send USDC to this address."
439
+ "mcpServers": {
440
+ "vapi": {
441
+ "command": "npx",
442
+ "args": ["-y", "vapi-network", "mcp"]
443
+ }
444
+ }
115
445
  }
116
446
  ```
117
447
 
118
- Account lookup dispatches by CAIP namespace: the EVM and Solana adapters use their corresponding
119
- local address and guarded RPC balance calls without coupling one wallet family to the other.
120
-
121
- ## Exporting the key
122
-
123
- The wallet is yours, so the key can leave on demand:
448
+ Then hand the passphrase to your operating system once, in your own terminal:
124
449
 
125
450
  ```bash
126
- vapi export-key # EVM key (eip155:8453) as 0x-prefixed hex
127
- vapi export-key --network solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d
128
- vapi export-key --json # { "network", "address", "privateKey" }
451
+ vapi unlock # the passphrase goes into the macOS Keychain or libsecret
129
452
  ```
130
453
 
131
- The command asks for the keystore passphrase, prints a one-line warning on
132
- stderr, and writes the key alone on stdout so it can be piped into a password
133
- manager. Anyone holding that key can spend the wallet: never paste it into a
134
- website or a chat. Nothing else in vAPI ever logs it.
454
+ The passphrase never leaves the machine and never has to appear in an editor's
455
+ configuration file. `vapi lock` takes it back out. On Windows, until there is a
456
+ Credential Manager path, keep using
457
+ `"env": { "VAPI_KEYSTORE_PASSWORD": "your-passphrase" }` instead.
135
458
 
136
- ## Reporting a bug
459
+ Give an agent its own capped wallet by creating it yourself and pinning the
460
+ agent to it:
137
461
 
138
462
  ```bash
139
- vapi report "the provider returned 402 twice"
140
- vapi report "the provider returned 402 twice" --include-addresses
141
- vapi report "the provider returned 402 twice" --send
463
+ vapi wallet create agent-claude --label "claude code"
464
+ vapi wallet caps agent-claude --per-day 5
465
+ vapi unlock --wallet agent-claude
142
466
  ```
143
467
 
144
- The command first writes `$VAPI_HOME/reports/<timestamp>.json`, then prints that path and a prefilled
145
- GitHub issue URL. Reports contain the message, client version, OS/Node information, and only the
146
- newest five receipt IDs. Wallet and payee addresses are included only with `--include-addresses`;
147
- amounts are never included. No report is uploaded unless `--send` is explicit. With `--send`, vAPI
148
- uses the guarded network client to POST the same JSON to the configured registry and prints the HTTP
149
- response code, including non-success responses such as 404. MCP clients can use `support.report`
150
- with the corresponding `includeAddresses` and `send` booleans.
468
+ ```json
469
+ {
470
+ "mcpServers": {
471
+ "vapi": {
472
+ "command": "npx",
473
+ "args": ["-y", "vapi-network", "mcp", "--wallet", "agent-claude"],
474
+ "env": {
475
+ "VAPI_WALLET": "agent-claude",
476
+ "VAPI_NO_SECRETS": "1"
477
+ }
478
+ }
479
+ }
480
+ }
481
+ ```
151
482
 
152
- ## Networks
483
+ The agent pays from `agent-claude` and no more than $5 a day, whatever it asks
484
+ for; your own wallet is not reachable from that session, because only
485
+ `agent-claude` was unlocked. `vapi wallet list` shows which wallets are unlocked
486
+ that way.
487
+
488
+ ### Tools
489
+
490
+ | Tool | Input | Result |
491
+ | ----------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
492
+ | `auth.link` | `label` | Starts linking this wallet to a person's vAPI account for browser approval with default permissions only; returns the code and URL |
493
+ | `auth.status` | `wallet` | Link status, owner, label, permissions, Router-key presence, and any pending browser approval |
494
+ | `router.models` | — | Model ids available from vAPI Router |
495
+ | `router.usage` | `wallet` | Router usage plus the linked owner's stake and stake-funded Compute |
496
+ | `router.chat` | `model`, `messages[]`, `max_tokens`, `wallet` | Completion `content`, resolved `model`, and token `usage`; the Router key stays in the OS secret store and is never returned |
497
+ | `router.buy` | `usd` (`1`, `5`, `20`, or `50`), `wallet` | Receipt summary and the new vAPI Router balance; the Router key stays in the OS secret store and is never returned |
498
+ | `call.search` | `query`, `kinds[]`, `network`, `limit`, `cursor`, `includeUnverified` | One discovery page: `items` with `group`, `fee` and `verification`, plus `nextCursor`, `unavailableKinds`, `rankingVersion` |
499
+ | `call.inspect` | `id`, `endpoint` | A listing's `verification`, `fee`, `liveness`, `conformance`, identity, request contract and live quote |
500
+ | `call.pay` | `wallet`, `id` or `url`, `method`, `endpoint`, `body`, `contentType`, `network`, `expectedPayTo`, `maxPriceUsd` | `wallet`, `status`, `body`, `payment`, `verification` for a registry listing, and `expectedRequest` when a 402 named one |
501
+ | `wallet.address` | `wallet` | `wallet`, `address` |
502
+ | `wallet.balance` | `wallet` | `wallet`, `address`, `balances[]` per configured network |
503
+ | `wallet.accounts` | `wallet` | `wallet`, `accounts[]` with USDC, gas balance and deposit guidance |
504
+ | `wallet.list` | — | `wallet`, `default`, and every wallet with caps in atomic USDC and dollars, balances, and `balanceError` when an RPC is unreachable |
505
+ | `wallet.use` | `name` | `wallet`, `active`, `previous`, `scope: "session"` |
506
+ | `wallet.fund` | `wallet`, `amountUsd` | `wallet`, `address`, `network`, `url`, `instructions` |
507
+ | `receipts.list` | `wallet`, `allWallets`, `limit` | `wallet`, `receipts[]` |
508
+ | `receipts.stats` | `wallet`, `allWallets`, `range` | `wallet`, `range`, `generatedAt`, `totals`, `outcomes`, `latency`, `topServices`, `search` |
509
+ | `support.report` | `message`, `includeAddresses`, `send` | `path`, `issueUrl`, the report itself, and `responseCode` when sent |
510
+
511
+ `wallet` is optional on every tool that takes it: without it the session's
512
+ active wallet is used, then `VAPI_WALLET`, then the machine default. Every
513
+ result names the wallet it used. `call.pay` applies that wallet's own spend caps
514
+ before it signs and tags the receipt with its name. When a paid call's outcome
515
+ is uncertain, `call.pay` fails with `settlement_unknown`, says not to retry
516
+ automatically, and names the `vapi pay --resume <receipt-id>` that settles the
517
+ question on-chain. `wallet.use` moves the
518
+ session onto another wallet **for this process only** — it never rewrites
519
+ `wallets.json`, so your own terminal keeps the default you chose — and appends a
520
+ `wallet.use.session` line to the audit log. Reads need no passphrase at all.
521
+
522
+ Spend caps default to $0.10 per call and $1.00 per day.
523
+
524
+ `call.search` returns vAPI-verified listings plus mirrored external catalogs;
525
+ `includeUnverified: true` adds unverified self-listed APIs, which passed vAPI's
526
+ automated x402 probe but were not reviewed. Every result of `call.search`,
527
+ `call.inspect` and `call.pay` carries `verification`, one of `"none"`,
528
+ `"requested"` or `"verified"` — a mirrored external row is always `"none"`.
529
+ Prefer a verified listing, and read the request contract and the price with
530
+ `call.inspect` before paying one that is not.
531
+
532
+ #### Deprecated tool aliases
533
+
534
+ These four pre-namespace names still work and still behave identically, but each
535
+ result carries one `DEPRECATED:` line naming its replacement. They will be
536
+ removed in a later release.
537
+
538
+ | Alias | Use instead |
539
+ | --------- | ---------------- |
540
+ | `search` | `call.search` |
541
+ | `inspect` | `call.inspect` |
542
+ | `call` | `call.pay` |
543
+ | `wallet` | `wallet.balance` |
544
+
545
+ #### What the MCP server cannot do
546
+
547
+ Create, rename, remove, restore, back up, import or export a wallet, or return a
548
+ recovery phrase, a private key or a passphrase. Those stay in the CLI, in front
549
+ of a person.
153
550
 
154
- | Network | x402 identifier | USDC | Gas / RPC notes |
155
- | -------------- | ----------------------------------------------------- | ---------------------------------------------- | ------------------------------------------------------ |
156
- | Base mainnet | `eip155:8453` | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | ETH; defaults to `https://mainnet.base.org` |
157
- | Arc testnet | `eip155:5042002` | `0x3600000000000000000000000000000000000000` | USDC is also the gas token; set `ARC_TESTNET_RPC_URL` |
158
- | Solana mainnet | `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d` | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` | SOL; defaults to `https://api.mainnet-beta.solana.com` |
551
+ ## SDK
159
552
 
160
- The x402 reference packages shorten the Solana CAIP-2 reference to
161
- `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`; vAPI accepts that identifier as an
162
- alias while persisting the full genesis hash above. Arc mainnet is not enabled:
163
- **not yet — placeholder only.** Arc and the x402 packages do not publish a
164
- mainnet RPC plus canonical USDC, so the client deliberately carries only a
165
- non-routable code placeholder instead of guessing a production configuration.
553
+ ### `createVapiClient`
166
554
 
167
- Create both local accounts during initialization:
555
+ Install the bundled client when you want Call, vAPI Router and local agents
556
+ behind one wallet-bound API:
168
557
 
169
558
  ```bash
170
- vapi init --networks base,solana
559
+ npm i vapi-network
171
560
  ```
172
561
 
173
- Or add an Ed25519 account to an existing encrypted keystore:
562
+ ```ts
563
+ import { createVapiClient } from "vapi-network";
564
+
565
+ const vapi = await createVapiClient({ wallet: "researcher" });
566
+ const reply = await vapi.router.chat({
567
+ model: "openai/gpt-5-mini",
568
+ messages: [{ role: "user", content: "Summarise Base DEX activity." }],
569
+ });
570
+ console.log(reply.content);
571
+
572
+ const listings = await vapi.call.search("Base DEX volume");
573
+ console.log(listings);
574
+ const result = await vapi.call.pay({ id: "base-dex-volume", maxPriceUsd: 0.05 });
575
+ console.log(result.body);
576
+
577
+ const purchase = await vapi.router.buy(5);
578
+ console.log(purchase.balance);
579
+ ```
580
+
581
+ `await vapi.router.openai()` returns the vAPI Router base URL and key for an
582
+ OpenAI-compatible framework. Use this in your own code. Do not pass it into a
583
+ model prompt.
584
+
585
+ Bought vAPI Router balance never expires and is used after the daily Compute
586
+ allowance runs out. Your wallet's client spend caps apply to every purchase,
587
+ including automatic refill.
588
+
589
+ ### Lower-level packages
174
590
 
175
591
  ```bash
176
- vapi accounts --enable solana
592
+ npm i @vapi-network/core @vapi-network/sources
177
593
  ```
178
594
 
179
- Fund the printed Solana address with SPL USDC. Exact x402 payments use the
180
- facilitator advertised in the challenge as fee payer, so they do not consume the
181
- local SOL balance. `vapi sweep <solana-address> --network
182
- solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d` is a separate transaction
183
- and requires a small amount of SOL locally for fees and, when necessary,
184
- creation of the destination token account. The default public Solana RPC is
185
- rate-limited and has no availability guarantee; set `SOLANA_RPC_URL` to a
186
- trusted dedicated endpoint for regular use.
595
+ `@vapi-network/core` is the main entry point: the x402 protocol, the wallet
596
+ store, spend policy, the network guard, discovery merge and the receipt ledger.
597
+ `@vapi-network/core/secrets` is a second, deliberately separate entry point for
598
+ the four functions that return a recovery phrase or a private key —
599
+ `exportRecoveryPhrase`, `exportKeystoreKeys`, `createKeystoreWithPhrase` and
600
+ `decryptPrivateKey`. They are not re-exported from the main index, and the MCP
601
+ package is forbidden by lint to import them, so a surface an agent drives cannot
602
+ reach a secret by accident.
603
+
604
+ Search and pay:
605
+
606
+ ```ts
607
+ import {
608
+ LocalWallet,
609
+ SpendPolicy,
610
+ WalletStore,
611
+ getVapiPaths,
612
+ loadConfig,
613
+ resolvePassphrase,
614
+ spendCapsForWallet,
615
+ } from "@vapi-network/core";
616
+ import { vapiRegistrySource } from "@vapi-network/sources";
617
+
618
+ const paths = getVapiPaths();
619
+ const config = await loadConfig(paths.config);
620
+ const [listing] = await vapiRegistrySource(config.marketplaceDiscoveryUrl, {
621
+ discoveryUrl: config.discoveryUrl,
622
+ }).search("weather");
623
+
624
+ const store = await WalletStore.open(paths.directory);
625
+ const { name } = store.resolve();
626
+ const account = await store.unlock(name, (await resolvePassphrase(name)).passphrase);
627
+ const wallet = new LocalWallet(
628
+ account,
629
+ new SpendPolicy(await spendCapsForWallet(store, name), {
630
+ ledgerPath: paths.ledger,
631
+ wallet: name,
632
+ }),
633
+ );
634
+ ```
187
635
 
188
- ## Discovery sources
636
+ Manage wallets:
189
637
 
190
- Discovery is a plugin interface. The client can merge listings from multiple
191
- sources, de-duplicate them by resource URL, and retain each listing's
192
- provenance:
638
+ ```ts
639
+ import { WalletStore, getVapiPaths, usdToAtomic } from "@vapi-network/core";
193
640
 
194
- - **vAPI Registry** is enabled by the default distribution, using
195
- `https://api.vapinetwork.ai/api/call/discovery` for discovery and
196
- `https://api.vapinetwork.ai/api/call/services` for service details. If the
197
- primary returns HTTP 404 or cannot be resolved, the client logs one notice
198
- and tries the fallbacks in `registryFallbacks`, using the same canonical
199
- paths; the default distribution no longer ships a distinct fallback host,
200
- because the `console.vapinetwork.ai` and `console-staging.vapinetwork.ai`
201
- hosts are retired. A `config.json` that still names them is repaired in
202
- memory on load and rewritten on disk by `vapi init`. The registry's historical `/api/marketplace/discovery`
203
- and `/api/network/services` paths still answer for one release and reply with
204
- `Deprecation: true` plus a `Link` header naming the successor; a base URL
205
- supplied on either of them is normalized to the canonical pair.
206
- - **Coinbase Bazaar** reads the public x402 v2
207
- `/discovery/resources` catalog exposed by a facilitator.
208
- - **Local file** reads a JSON array of listings for private or development
209
- catalogs.
210
- - **x402scan** is a deliberate stub for now. The source research documents its
211
- discovery convention, but not a stable public read API that this client can
212
- safely target.
213
-
214
- Use `@vapi-network/sources` to compose only the catalogs you trust. Network
215
- access is guarded against local and private destinations before a request is
216
- made.
217
-
218
- Set `VAPI_REGISTRY_URL` to replace the registry base; the client derives
219
- `/api/call/discovery` and `/api/call/services` beneath it. The existing
220
- `VAPI_MARKETPLACE_DISCOVERY_URL` and `VAPI_DISCOVERY_URL` variables can still
221
- override either full endpoint separately. Registry fallbacks are stored in
222
- `config.json` under `registryFallbacks`.
641
+ const store = await WalletStore.open(getVapiPaths().directory);
642
+ for (const wallet of await store.list()) {
643
+ console.log(wallet.name, wallet.address, wallet.isDefault, wallet.spendCaps);
644
+ }
645
+ await store.setSpendCaps("agent", {
646
+ perCallAtomic: String(usdToAtomic(0.05)),
647
+ perDayAtomic: String(usdToAtomic(1)),
648
+ });
649
+ ```
223
650
 
224
- ## Packages
651
+ `WalletStore` is the one entry point for the layout: `open`, `list`, `resolve`,
652
+ `create`, `importKey`, `unlock`, `setDefault`, `rename`, `setLabel`,
653
+ `setSpendCaps`, `remove`, `restore` and `listTrash`. It never rewrites key
654
+ material; it moves, names and caps keystores.
225
655
 
226
- | Package | Purpose |
227
- | ----------------------- | ------------------------------------------------------------------------ |
228
- | `@vapi-network/core` | x402 protocol, wallet, spend policy, discovery merge, and receipts |
229
- | `@vapi-network/sources` | vAPI Registry, Coinbase Bazaar, local-file, and x402scan source adapters |
230
- | `@vapi-network/mcp` | stdio MCP server with namespaced payment tools |
231
- | `@vapi-network/cli` | `init`, discovery, payment, wallet, receipt, and MCP commands |
232
- | `vapi-network` | zero-dependency distribution with the `vapi` binary and defaults |
656
+ Two runnable examples live in [`examples/`](./examples):
657
+ [`pay-with-sdk.ts`](./examples/pay-with-sdk.ts) (`pnpm example:pay -- weather`)
658
+ and [`wallets.ts`](./examples/wallets.ts) (`pnpm example:wallets -- agent-demo`).
233
659
 
234
- Every npm tarball is bundled and has zero runtime dependencies. The scoped
235
- packages are useful for embedding; most users should start with
236
- `vapi-network`.
660
+ ## Configuration
237
661
 
238
- ## SDK
662
+ Local state lives in `~/.vapi/`:
663
+
664
+ ```text
665
+ config.json registry URLs, networks and RPC endpoints
666
+ wallets.json which wallet is the default, plus per-wallet caps and labels
667
+ wallets/
668
+ main.json one encrypted keystore per wallet, mode 0600
669
+ .trash/ removed wallets, kept encrypted, never deleted for you
670
+ keystore.json a 0600 symlink to wallets/main.json, for one release
671
+ audit.log one JSON line per secret export or wallet change
672
+ receipts.jsonl the append-only call ledger
673
+ searches.jsonl one line per discovery query
674
+ spend-ledger.json today's total, per wallet
675
+ reports/ what vapi report writes
676
+ ```
677
+
678
+ | Variable | What it does |
679
+ | ------------------------ | --------------------------------------------------------------------------- |
680
+ | `VAPI_HOME` | Use a different directory instead of `~/.vapi` |
681
+ | `VAPI_WALLET` | The wallet to use when no `--wallet` is given |
682
+ | `VAPI_REGISTRY_URL` | Replace the registry base; the canonical discovery paths derive from it |
683
+ | `VAPI_KEYSTORE_PASSWORD` | The passphrase, for CI and for Windows. Checked before the OS secret store. |
684
+ | `VAPI_API_KEY` | The registry key `vapi publish` authenticates with, for CI |
685
+ | `VAPI_NO_SECRETS` | Set to `1` to stop `vapi backup` and `vapi export-key` printing anything |
239
686
 
240
- The core and source packages can be used without the CLI or MCP layer. See the
241
- runnable [SDK example](./examples/pay-with-sdk.ts) for discovery, policy
242
- validation, local signing, and direct x402 payment construction.
687
+ `ARC_RPC_URL` overrides the Arc mainnet RPC. `ARC_TESTNET_RPC_URL` and
688
+ `SOLANA_RPC_URL` point those two networks at an endpoint you trust. On first
689
+ use of the default home, the client copies an existing `~/.vapi/agent-cash/`
690
+ configuration into `~/.vapi/` when it can do so without overwriting files,
691
+ prints a notice, and leaves the old directory alone.
243
692
 
244
- Run it after initialization with `pnpm example:pay -- weather`.
693
+ ## Funding
694
+
695
+ ```bash
696
+ vapi fund # open the funding page for your address
697
+ vapi fund --amount 25 # prefill a US dollar amount
698
+ vapi fund --json # { address, network, url }
699
+ ```
245
700
 
246
- ## Local state and migration
701
+ `vapi fund` prints `<registry>/fund/<your-address>` and opens it in your default
702
+ browser when you are on a terminal. The page offers three routes: a card via
703
+ Coinbase (needs a Coinbase account; US guest checkout), a transfer from
704
+ MetaMask, Coinbase Wallet or WalletConnect, or a bridge from another chain. It
705
+ is public, takes no sign-in, and mints the card session when you click — so the
706
+ link keeps working while you log in, and nothing expires in your scrollback.
247
707
 
248
- By default, local state lives in `~/.vapi/`:
708
+ The command itself makes **no network call**: it works offline, and it always
709
+ also prints
249
710
 
250
711
  ```text
251
- config.json
252
- keystore.json
253
- receipts.jsonl
254
- spend-ledger.json
255
- reports/
712
+ Send USDC on Base (eip155:8453) to this address; add a little ETH for gas if you plan to sweep.
256
713
  ```
257
714
 
258
- Set `VAPI_HOME` to use a different directory. On first use of the default home,
259
- the client copies an existing `~/.vapi/agent-cash/` configuration into
260
- `~/.vapi/` when it can do so without overwriting files, prints a migration
261
- notice, and leaves the old directory untouched.
715
+ Whichever route you pick, the USDC lands on your local address on Base. **vAPI
716
+ never holds your funds**, never proxies the payment, and never sees your card
717
+ details or your private key. MCP clients use `wallet.fund`, which returns the
718
+ same `{ address, network, url }` plus a line telling the agent to hand the link
719
+ to its human.
262
720
 
263
- ## Metrics
721
+ ## Networks and accounts
264
722
 
265
- vAPI measures call and discovery health locally. Call receipts can include the
266
- listing name and provider host, policy decision, retry count, client version,
267
- outcome, total latency, and discovery, quote, signing, request, and settlement
268
- phase timings. Policy declines are recorded with the quoted amount but without
269
- a payer or transaction, so blocked spend remains visible without creating a
270
- payment authorization. Search events record the query, sources tried,
271
- per-source latency and result count, merged result count, and timestamp.
723
+ | Network | x402 identifier | USDC | Gas / RPC notes |
724
+ | -------------- | ----------------------------------------------------- | ---------------------------------------------- | -------------------------------------------------------------------- |
725
+ | Base mainnet | `eip155:8453` | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | ETH; defaults to `https://mainnet.base.org` |
726
+ | Arc mainnet | `eip155:5042` | `0x3600000000000000000000000000000000000000` | USDC is also the gas token; defaults to `https://rpc.mainnet.arc.io` |
727
+ | Arc testnet | `eip155:5042002` | `0x3600000000000000000000000000000000000000` | USDC is also the gas token; set `ARC_TESTNET_RPC_URL` |
728
+ | Solana mainnet | `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d` | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` | SOL; defaults to `https://api.mainnet-beta.solana.com` |
272
729
 
273
- Call receipts are appended to `$VAPI_HOME/receipts.jsonl`; search events are
274
- appended to `$VAPI_HOME/searches.jsonl`. Nothing in either ledger is uploaded,
275
- and vAPI sends no telemetry off the machine by default. The vAPI website can
276
- show public on-chain usage for a wallet address directly from the chain; that
277
- view does not require uploading these local files.
730
+ The x402 reference packages shorten the Solana CAIP-2 reference to
731
+ `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`; vAPI accepts that identifier as an
732
+ alias while persisting the full genesis hash above. Enable Arc mainnet with
733
+ `vapi init --networks base,arc` (or the same `--networks` value on `vapi wallet
734
+ create` or `vapi import`), `vapi accounts --enable arc`, or `ARC_RPC_URL`. Its
735
+ explorer is `https://explorer.arc.io`.
278
736
 
279
- Use `vapi stats --range 24h|7d|30d` for a human-readable summary or add `--json`
280
- for the stable `{ range, generatedAt, totals, outcomes, latency, topServices,
281
- search }` shape. `receipts.stats` exposes the same shape through MCP. Export raw
282
- receipts for spreadsheets and dashboards with:
737
+ `vapi accounts` lists one deposit account per configured network: its CAIP-2 ID,
738
+ network name, address, atomic and formatted USDC balance, gas-token balance, and
739
+ deposit guidance. Account lookup dispatches by CAIP namespace, so the EVM and
740
+ Solana adapters stay independent of one another. For Arc testnet, add the faucet
741
+ to that network's `config.json` entry:
742
+
743
+ ```json
744
+ {
745
+ "depositUrl": "https://your-arc-faucet.example",
746
+ "depositInstructions": "Use the configured Arc testnet faucet, then send USDC to this address."
747
+ }
748
+ ```
749
+
750
+ Arc mainnet uses the default public RPC or `ARC_RPC_URL` and needs no faucet
751
+ configuration.
752
+
753
+ Create both local accounts at initialization with `vapi init --networks
754
+ base,solana`, or add an Ed25519 account to an existing keystore with `vapi
755
+ accounts --enable solana`. Fund the printed Solana address with SPL USDC. Exact
756
+ x402 payments use the facilitator advertised in the challenge as fee payer, so
757
+ they do not consume the local SOL balance; `vapi sweep` is a separate
758
+ transaction and does need a little SOL. The default public Solana RPC is
759
+ rate-limited and has no availability guarantee; set `SOLANA_RPC_URL` to a
760
+ dedicated endpoint for regular use.
761
+
762
+ ## Discovery sources
763
+
764
+ Discovery is a plugin interface. The client merges listings from several
765
+ sources, de-duplicates them by normalized resource URL, and keeps each listing's
766
+ provenance:
767
+
768
+ - **vAPI Registry**, enabled by the default distribution, using
769
+ `https://api.vapinetwork.ai/api/call/discovery` and
770
+ `https://api.vapinetwork.ai/api/call/services`. If the primary returns HTTP
771
+ 404 or cannot be resolved, the client logs one notice and tries the hosts in
772
+ `registryFallbacks` on the same canonical paths. The historical
773
+ `/api/marketplace/discovery` and `/api/network/services` paths are deprecated;
774
+ a base URL supplied on either is normalized to the canonical pair.
775
+ - **Coinbase Bazaar**, the public x402 v2 `/discovery/resources` catalogue
776
+ exposed by a facilitator.
777
+ - **Local file**, a JSON array of listings for private or development
778
+ catalogues.
779
+ - **x402scan**, a deliberate stub until x402scan documents a stable public read
780
+ API this client can safely target.
781
+
782
+ Use `@vapi-network/sources` to compose only the catalogues you trust. Every
783
+ outbound request is guarded against local and private destinations before it is
784
+ made, and redirects and resolved IP addresses are re-validated as new
785
+ destinations.
786
+
787
+ ## Sign-in with X
788
+
789
+ x402 v2 services can require Sign-In-With-X (SIWX) before returning a price.
790
+ When `vapi pay` or `call.pay` receives that challenge, vAPI checks that both the
791
+ challenge domain and URI match the final resource origin, signs the canonical
792
+ EIP-4361 message locally with EVM `personal_sign`, and retries once with
793
+ `SIGN-IN-WITH-X`. The proof is never sent to a redirect or a different host.
794
+
795
+ If the retry returns a normal 402 quote, the usual spend-policy and payment flow
796
+ continues. If the resource is free after sign-in, the result has
797
+ `outcome: "signed_in"` and the local receipt records `amountAtomic: "0"`.
798
+
799
+ ## Metrics and bug reports
800
+
801
+ vAPI measures call and discovery health locally and uploads nothing. Receipts
802
+ can include the listing name and provider host, policy decision, retry count,
803
+ client version, outcome, total latency, and discovery, quote, signing, request
804
+ and settlement phase timings. Policy declines are recorded with the quoted
805
+ amount but without a payer or transaction, so blocked spend stays visible
806
+ without creating a payment authorization. Search events record the query,
807
+ sources tried, per-source latency and result count, merged result count and
808
+ timestamp.
283
809
 
284
810
  ```sh
285
- vapi receipts export --format json --range 30d
811
+ vapi stats --range 7d
286
812
  vapi receipts export --format csv --range 30d
287
813
  ```
288
814
 
815
+ When the registry reports it, `vapi stats` also shows the network-wide amount routed through vAPI for 24h and 30d in USD plus the 30d transaction count. This covers all vAPI clients, not just this wallet.
816
+
817
+ `vapi report "<what happened>"` writes `$VAPI_HOME/reports/<timestamp>.json` and
818
+ prints that path plus a prefilled GitHub issue URL. Reports contain the message,
819
+ client version, OS and Node information, and only the newest five receipt IDs.
820
+ Wallet and payee addresses are included only with `--include-addresses`; amounts
821
+ never are. Nothing is uploaded unless `--send` is explicit.
822
+
823
+ ## Packages
824
+
825
+ | Package | Purpose |
826
+ | ----------------------- | ----------------------------------------------------------------------- |
827
+ | `vapi-network` | zero-dependency distribution with the `vapi` binary and defaults |
828
+ | `@vapi-network/core` | x402 protocol, wallet store, spend policy, discovery merge and receipts |
829
+ | `@vapi-network/sources` | vAPI Registry, Coinbase Bazaar, local-file and x402scan source adapters |
830
+ | `@vapi-network/mcp` | stdio MCP server with namespaced payment tools |
831
+ | `@vapi-network/cli` | command parsing and the command implementations behind `vapi` |
832
+
833
+ Every npm tarball is bundled and has zero runtime dependencies. The scoped
834
+ packages are useful for embedding; most users should start with `vapi-network`.
835
+
289
836
  ## Roadmap
290
837
 
291
838
  - A local gateway daemon (`vapi serve`) with per-key budgets
292
839
  - OpenTelemetry traces and metrics, with exporters enabled only by the user
293
- - `task.*` tools for posting, funding, delivering, and reviewing work
840
+ - `task.*` tools for posting, funding, delivering and reviewing work
294
841
  - `compute.*` tools for discovering models and paying for inference
295
842
 
296
- Until the gateway lands, `vapi serve` and the provider-side `vapi publish`
297
- command exit with a preview message. Payments remain direct from the local
298
- wallet to each service.
843
+ Until the gateway lands, `vapi serve` and the provider-side `vapi publish` exit
844
+ with a preview message. Payments stay direct from the local wallet to each
845
+ service.
299
846
 
300
847
  ## Development
301
848
 
302
- This is a pnpm workspace for Node.js 22 and pnpm 10.
849
+ A pnpm workspace for Node.js 22 and pnpm 10. The gate, in order:
303
850
 
304
851
  ```sh
305
852
  pnpm install
853
+ pnpm format:check
306
854
  pnpm lint
307
855
  pnpm typecheck
308
856
  pnpm test
@@ -310,32 +858,13 @@ pnpm build
310
858
  pnpm pack:check
311
859
  ```
312
860
 
313
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for the development workflow,
314
- [CHANGELOG.md](./CHANGELOG.md) for what shipped in each release, and
315
- [SECURITY.md](./SECURITY.md) for private vulnerability reports.
316
-
317
- CLI commands exit `0` on success, `1` on an operational failure, and `2` for
318
- invalid usage or an announced preview-only command. `--json` sends both success
319
- values and errors to stdout as one JSON value; `mcp --json` is accepted as a
320
- no-op because the stdio transport is already JSON-RPC.
321
-
322
- ## Publishing
323
-
324
- All five packages share one version and are published together. npm reads a
861
+ All five packages share one version and are released together. npm reads a
325
862
  package manifest before lifecycle hooks run, so the release is made from the
326
863
  generated `publish/` directories, never from the workspace package roots.
327
864
 
328
- First update every package to the same version and verify the exact tarballs:
329
-
330
865
  ```sh
331
866
  pnpm install --frozen-lockfile
332
867
  pnpm pack:check
333
- ```
334
-
335
- After reviewing the output, a maintainer with npm access runs these commands
336
- manually:
337
-
338
- ```sh
339
868
  npm login
340
869
  pnpm --dir packages/core publish:npm
341
870
  pnpm --dir packages/sources publish:npm
@@ -344,11 +873,15 @@ pnpm --dir packages/cli publish:npm
344
873
  pnpm --dir packages/vapi-network publish:npm
345
874
  ```
346
875
 
347
- Each package's `publish:npm` script publishes its staged `./publish` directory
348
- to the `latest` npm tag. Every package also has a `publish:npm:next` script that
349
- publishes the same tarball to `next` instead, for preview builds. The manual
350
- release workflow verifies and prints these commands; it never receives npm
351
- credentials or publishes automatically.
876
+ `publish:npm` publishes a package's staged `./publish` directory to the `latest`
877
+ npm tag; `publish:npm:next` publishes the same tarball to `next`. The manual
878
+ release workflow verifies artifacts and prints these commands; it never receives
879
+ npm credentials and never publishes.
880
+
881
+ See [AGENTS.md](./AGENTS.md) for layout and invariants,
882
+ [CONTRIBUTING.md](./CONTRIBUTING.md) for the workflow,
883
+ [CHANGELOG.md](./CHANGELOG.md) for what shipped in each release, and
884
+ [SECURITY.md](./SECURITY.md) for private vulnerability reports.
352
885
 
353
886
  ## License
354
887