vapi-network 0.3.0 → 0.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/README.md CHANGED
@@ -5,318 +5,54 @@ TypeScript toolkit for discovering and paying x402 services from a terminal, an
5
5
  MCP client, or your own code. Your key is generated on your machine, encrypted
6
6
  under your passphrase, and never leaves it. vAPI applies spend policy before
7
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.
8
10
 
9
11
  Call works today. Tasks and Compute are next.
10
12
 
11
- ## Quickstart
13
+ ## Install
12
14
 
13
15
  ```bash
14
16
  npm i -g vapi-network
15
- vapi init # creates ~/.vapi, the wallet main, and prints its address
16
- vapi backup # write the 12 words down; vAPI cannot recover them
17
- vapi fund # opens the hosted funding page for your address
18
- vapi search "weather" # every catalogue, merged, with provenance
19
- vapi pay <listing-ref> --max 0.02
20
- vapi receipts # one line per paid call: quote, settlement, latency
21
17
  ```
22
18
 
23
- That is the same order `vapi init` prints as its next steps, and the same order
24
- `vapi` alone lists. Two more are worth knowing early: `vapi inspect <ref>` shows
25
- a listing's request contract and live 402 quote for free, before you pay, and
26
- `vapi balance` shows what the wallet holds.
27
-
28
- `vapi search` tags each listing with its group — `[vapi]`, `[added]`,
29
- `[partner]` or `[external]` — and prints the network fee that is already inside
30
- the price. vAPI and added APIs carry a 5% network fee inside the quoted price;
31
- partner and external listings carry none. `vapi inspect` and `--json` return the
32
- same `group` and `fee` fields.
33
-
34
19
  No install? Prefix any command with `npx vapi-network`, for example
35
20
  `npx vapi-network init`. (`npx vapi` cannot work: the bare `vapi` name on npm
36
21
  belongs to an unrelated package.)
37
22
 
38
- ## Wallets
39
-
40
- One machine can hold several wallets: your own, and a capped one per agent. Each
41
- keystore lives in `$VAPI_HOME/wallets/<name>.json`; `$VAPI_HOME/wallets.json`
42
- records which one is the default, what each may spend, and its label. Names are
43
- 1 to 32 characters of lowercase letters, digits and dashes.
44
-
45
- ```bash
46
- vapi wallet list # address, default marker, caps, unlocked, label
47
- vapi wallet create agent --label "claude code" # a wallet of its own for the agent
48
- vapi wallet caps agent --per-call 0.05 --per-day 1
49
- vapi wallet use agent # make it the default for later commands
50
- vapi pay <listing-ref> --wallet agent --max 0.02
51
- vapi receipts --wallet agent # or --all-wallets for every one
52
- ```
53
-
54
- Every command that touches a wallet takes `--wallet <name>`: `balance`,
55
- `accounts`, `fund`, `pay`, `sweep`, `receipts`, `stats`, `export-key`, `backup`,
56
- `import`, `passphrase`, `unlock`, `lock` and `mcp`. Without it, `VAPI_WALLET`
57
- decides; without that, the default set by `vapi wallet use` does. Each of them
58
- names the wallet it used — `Wallet: main (0x…)` on the first line, or a `wallet`
59
- field in `--json` — so neither you nor an agent can be wrong about which key
60
- just moved.
61
-
62
- Spend caps belong to the wallet, not to the machine, and today's total is
63
- counted per wallet: an agent cannot spend your daily allowance. Removing a
64
- wallet is a move, not a delete — the encrypted keystore goes to
65
- `wallets/.trash/`, where `vapi wallet restore` can bring it back.
66
-
67
- **Coming from 0.2.x?** Nothing to do. The first command you run opens the wallet
68
- store, moves `keystore.json` to `wallets/main.json` with its contents untouched,
69
- turns `config.json`'s spend caps into the caps of `main`, and leaves
70
- `keystore.json` behind as a mode 0600 symlink for one release so existing
71
- scripts keep working. A home with no keystore migrates nothing.
72
-
73
- ## Your wallet is yours
74
-
75
- `vapi init` generates a 12-word BIP-39 recovery phrase on your machine, derives
76
- the Base account (`m/44'/60'/0'/0/0`) and, with `--networks base,solana`, the
77
- Solana account (`m/44'/501'/0'/0'`) from it, and writes the phrase encrypted
78
- under your passphrase to `$VAPI_HOME/wallets/main.json` (mode 0600). The phrase
79
- is shown once, on a terminal, and never in `--json` or piped output.
80
-
81
- Three things vAPI cannot do:
82
-
83
- - **See it.** No key, phrase or passphrase ever leaves the machine.
84
- - **Recover it.** There is no copy anywhere to restore from.
85
- - **Freeze it.** Payments go straight from your wallet to the service.
86
-
87
- ### Back it up
88
-
89
- ```bash
90
- vapi backup # the 12 words, numbered, on a terminal
91
- vapi backup --json # { "wallet": "main", "recoveryPhrase": "..." }
92
- ```
93
-
94
- Write the words on paper and keep them somewhere only you reach. Anyone holding
95
- them can spend the wallet, so never type them into a website or a chat.
96
-
97
- Wallets created before 0.2.5 have no recovery phrase. `vapi backup` says so and
98
- points at `vapi export-key`, which prints the private key itself; back that key
99
- up, or `vapi import --key` it into a new wallet. Restoring a phrase-based wallet
100
- in MetaMask, Rabby, Coinbase Wallet or Phantom gives the same addresses.
101
-
102
- ### Import and move a wallet
103
-
104
- ```bash
105
- vapi import --phrase # type the words at the prompt
106
- vapi import --phrase --networks base,solana # restore both accounts
107
- vapi import --key # a 0x private key instead of words
108
- vapi import --phrase --wallet backup-2026 # into a named wallet of its own
109
- ```
110
-
111
- `vapi import` reads the secret from a prompt, never from the command line where
112
- a shell history would keep it, and asks for a new passphrase. It writes a new
113
- named wallet rather than replacing one: `--wallet <name>` chooses the name, and
114
- `main` is assumed only on a machine with no wallet yet. `--replace` moves the
115
- named wallet to `wallets/.trash/` first, and still refuses a wallet that holds
116
- USDC on Base unless you add `--force`.
117
-
118
- ### Change the passphrase
119
-
120
- ```bash
121
- vapi passphrase # current passphrase, then the new one twice
122
- ```
123
-
124
- The wallet, its addresses and its recovery phrase are unchanged. Any copy of the
125
- old passphrase stored by `vapi unlock` is removed at the same time, so nothing
126
- is left behind that no longer opens the wallet.
127
-
128
- ### Agents and secrets
129
-
130
- An agent can drive vAPI all day without ever seeing a secret. It can search,
131
- inspect, pay from the wallet you gave it, read balances and receipts, and pick a
132
- wallet by name with `wallet.use` — which changes only that session, never your
133
- default on disk. It cannot see a recovery phrase, a private key or a passphrase,
134
- and the MCP server has no tool that creates, removes, renames, backs up or
135
- exports a wallet.
136
-
137
- `vapi backup` and `vapi export-key` print a secret, so they run only when a
138
- person is demonstrably there: stdin and stdout are both a real terminal, no
139
- agent or CI marker is set, and you type the wallet's own name to confirm.
140
- Otherwise they print nothing and say:
141
-
142
- ```text
143
- Run this yourself in a terminal; an agent must never see these words.
144
- ```
145
-
146
- The markers vAPI refuses on are `VAPI_NO_SECRETS`, `CLAUDECODE`, `CLAUDE_CODE`,
147
- `CURSOR_AGENT`, `CODEX_SANDBOX`, `OPENAI_CODEX`, `AGENT` and `CI`. Set
148
- `VAPI_NO_SECRETS=1` in a machine's agent configuration to switch secret printing
149
- off outright. `vapi init` and `vapi wallet create` still create the wallet under
150
- those conditions; they simply say `Recovery phrase: run vapi backup yourself in
151
- a terminal to see it.`
152
-
153
- In the SDK the same line is drawn by the module layout: the functions that
154
- return a phrase or a key live in the separate `@vapi-network/core/secrets` entry
155
- point, which the MCP package is forbidden by lint to import.
156
-
157
- ### Where the passphrase lives
158
-
159
- An unlock looks in three places, in this order:
160
-
161
- 1. `VAPI_KEYSTORE_PASSWORD`, kept for CI and for Windows.
162
- 2. The OS secret store: the macOS Keychain, or libsecret on Linux, under the
163
- service `vapi-network` and the wallet's name.
164
- 3. A prompt, when a person is there to answer it.
165
-
166
- ```bash
167
- vapi unlock --wallet agent # store it, once, in your own terminal
168
- vapi wallet list # the UNLOCKED column says which agents can pay
169
- vapi lock --all # take every stored passphrase back out
170
- ```
171
-
172
- `vapi unlock` runs only on a real terminal with no agent marker set, and only
173
- after it has verified that the passphrase really opens that wallet. The
174
- passphrase is handed to the OS binary over its standard input, never as a
175
- command-line argument, so it never appears in `ps`. A run that finds no
176
- passphrase anywhere and has no terminal says so and names both other routes; an
177
- agent is never prompted. Windows has no store yet and keeps
178
- `VAPI_KEYSTORE_PASSWORD`.
179
-
180
- ### The audit log
181
-
182
- Every secret export, every wallet change — create, import, remove, restore,
183
- rename, default, caps, passphrase, unlock, lock — and every MCP session wallet
184
- switch appends one JSON line to `$VAPI_HOME/audit.log` (mode 0600): the time,
185
- the event, the wallet, whether a terminal was attached, and which marker was
186
- set. The line never contains the secret itself, so the log answers "did anything
187
- export my phrase while the agent was running" without you having to trust the
188
- agent's own account of it.
189
-
190
- ## CLI reference
191
-
192
- Every command accepts `--json`, which writes one JSON value — success or error —
193
- to stdout. Exit codes are `0` for success, `1` for an operational failure, and
194
- `2` for invalid usage or an announced preview-only command.
195
-
196
- | Command | Options | What it does |
197
- | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
198
- | `vapi init` | `--networks <base,solana>` | Creates `~/.vapi`, the wallet `main` and the config. Says so if one exists. |
199
- | `vapi wallet list` | — | Name, address, default marker, caps in USD, unlocked, label |
200
- | `vapi wallet create <name>` | `--networks <base,solana>`, `--label <text>` | A new wallet, with its own phrase, caps and passphrase |
201
- | `vapi wallet use <name>` | — | Makes it the default for every later command |
202
- | `vapi wallet rename <old> <new>` | — | Renames the keystore, the registry entry and that wallet's receipts |
203
- | `vapi wallet remove <name>` | `--force` | Moves the keystore to `wallets/.trash/`; asks you to type the name |
204
- | `vapi wallet restore <name>` | — | Brings a removed wallet back, same passphrase |
205
- | `vapi wallet caps <name>` | `--per-call <usd>`, `--per-day <usd>` | Sets that wallet's spend caps, in US dollars |
206
- | `vapi fund` | `--amount <usd>`, `--wallet <name>` | Prints and opens the hosted funding page. Makes no network call. |
207
- | `vapi accounts` | `--enable solana`, `--wallet <name>` | One deposit account per configured network, with balances and guidance |
208
- | `vapi search [query]` | `--kind <kind>` (repeatable), `--network <caip2>`, `--limit <n>`, `--cursor <cursor>` | Merged discovery across every configured source |
209
- | `vapi inspect <id>` | `--endpoint <name>` | A listing's request contract and live 402 quote, for free |
210
- | `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 |
211
- | `vapi balance` | `--wallet <name>` | The wallet's address and USDC balances |
212
- | `vapi receipts` | `--limit <n>`, `--wallet <name>`, `--all-wallets` | The local append-only call ledger, newest last |
213
- | `vapi receipts export` | `--format <json\|csv>`, `--range <24h\|7d\|30d>`, `--wallet <name>`, `--all-wallets` | Raw receipts for a spreadsheet or dashboard |
214
- | `vapi stats` | `--range <24h\|7d\|30d>`, `--wallet <name>`, `--all-wallets` | Spend, outcomes, latency percentiles and top services |
215
- | `vapi sweep <address>` | `--network <caip2>`, `--wallet <name>` | Moves the USDC balance out to an address you own |
216
- | `vapi export-key` | `--network <caip2>`, `--wallet <name>` | Prints the private key. Terminal only, never for an agent. |
217
- | `vapi backup` | `--wallet <name>` | Prints the 12 words. Terminal only, never for an agent. |
218
- | `vapi import` | `--phrase` or `--key`, `--wallet <name>`, `--networks <base,solana>`, `--replace`, `--force` | Restores a wallet from a prompt, never from argv |
219
- | `vapi passphrase` | `--wallet <name>` | Re-encrypts the keystore under a new passphrase |
220
- | `vapi unlock` | `--wallet <name>` | Puts that wallet's passphrase in the OS secret store |
221
- | `vapi lock` | `--wallet <name>`, `--all` | Takes a stored passphrase back out |
222
- | `vapi report "<what>"` | `--include-addresses`, `--send` | Writes a privacy-preserving local bug report |
223
- | `vapi mcp` | `--wallet <name>` | Serves the MCP tools over stdio |
224
- | `vapi serve` | — | Preview only; exits `2` with a message |
225
- | `vapi publish` | — | Preview only; exits `2` with a message |
226
- | `vapi version` | — | The client version, also as `--version` or `-v` |
227
- | `vapi help` | — | The same help bare `vapi` shows, also as `--help` or `-h` |
228
-
229
- `vapi pay` also accepts `--max-price-usd` as a long-standing alias for `--max`;
230
- the two cannot be combined. `mcp --json` is accepted as a no-op, because the
231
- stdio transport is already JSON-RPC.
232
-
233
- ## MCP
234
-
235
- Add this to Claude Code, Claude Desktop or Cursor:
236
-
237
- ```json
238
- {
239
- "mcpServers": {
240
- "vapi": {
241
- "command": "npx",
242
- "args": ["-y", "vapi-network", "mcp"]
243
- }
244
- }
245
- }
246
- ```
247
-
248
- Then hand the passphrase to your operating system once, in your own terminal:
249
-
250
- ```bash
251
- vapi unlock # the passphrase goes into the macOS Keychain or libsecret
252
- ```
253
-
254
- The passphrase never leaves the machine and never has to appear in an editor's
255
- configuration file. `vapi lock` takes it back out. On Windows, until there is a
256
- Credential Manager path, keep using
257
- `"env": { "VAPI_KEYSTORE_PASSWORD": "your-passphrase" }` instead.
258
-
259
- Give an agent its own capped wallet by creating it yourself and pinning the
260
- agent to it:
23
+ ## Quickstart
261
24
 
262
25
  ```bash
263
- vapi wallet create agent-claude --label "claude code"
264
- vapi wallet caps agent-claude --per-day 5
265
- vapi unlock --wallet agent-claude
266
- ```
267
-
268
- ```json
269
- {
270
- "mcpServers": {
271
- "vapi": {
272
- "command": "npx",
273
- "args": ["-y", "vapi-network", "mcp", "--wallet", "agent-claude"],
274
- "env": {
275
- "VAPI_WALLET": "agent-claude",
276
- "VAPI_NO_SECRETS": "1"
277
- }
278
- }
279
- }
280
- }
26
+ npm i -g vapi-network
27
+ vapi setup [--no-cloud-backup] # creates or restores the vault, derives main, links it to your owner wallet; safe to rerun
28
+ vapi fund # opens the hosted funding page for your address
29
+ vapi search "weather" # every catalogue, merged, with provenance
30
+ vapi pay <listing-ref> --max 0.02
31
+ vapi receipts # one line per paid call: quote, settlement, latency
281
32
  ```
282
33
 
283
- The agent pays from `agent-claude` and no more than $5 a day, whatever it asks
284
- for; your own wallet is not reachable from that session, because only
285
- `agent-claude` was unlocked. `vapi wallet list` shows which wallets are unlocked
286
- that way.
34
+ Back up the recovery phrase only in a terminal; vAPI cannot recover it.
35
+ Turn on encrypted cloud backup with `vapi backup --cloud`; only the owner can approve a restore.
287
36
 
288
- ### Tools
37
+ ## What you can do
289
38
 
290
- | Tool | Input | Result |
291
- | ----------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
292
- | `call.search` | `query`, `kinds[]`, `network`, `limit`, `cursor` | One discovery page: `items`, `nextCursor`, `unavailableKinds`, `rankingVersion` |
293
- | `call.inspect` | `id`, `endpoint` | A listing's request contract and live quote, for free, before paying |
294
- | `call.pay` | `wallet`, `id` or `url`, `method`, `endpoint`, `body`, `contentType`, `network`, `expectedPayTo`, `maxPriceUsd` | `wallet`, `status`, `body`, `payment`, and `expectedRequest` when a 402 named one |
295
- | `wallet.address` | `wallet` | `wallet`, `address` |
296
- | `wallet.balance` | `wallet` | `wallet`, `address`, `balances[]` per configured network |
297
- | `wallet.accounts` | `wallet` | `wallet`, `accounts[]` with USDC, gas balance and deposit guidance |
298
- | `wallet.list` | — | `wallet`, `default`, and every wallet with caps in atomic USDC and dollars, balances, and `balanceError` when an RPC is unreachable |
299
- | `wallet.use` | `name` | `wallet`, `active`, `previous`, `scope: "session"` |
300
- | `wallet.fund` | `wallet`, `amountUsd` | `wallet`, `address`, `network`, `url`, `instructions` |
301
- | `receipts.list` | `wallet`, `allWallets`, `limit` | `wallet`, `receipts[]` |
302
- | `receipts.stats` | `wallet`, `allWallets`, `range` | `wallet`, `range`, `generatedAt`, `totals`, `outcomes`, `latency`, `topServices`, `search` |
303
- | `support.report` | `message`, `includeAddresses`, `send` | `path`, `issueUrl`, the report itself, and `responseCode` when sent |
39
+ | Surface | What it does | Guide |
40
+ | ------- | ------------------------------------------------------------------- | ------------------------------------------------------------ |
41
+ | Call | Discover, check, publish and pay for x402 APIs. | [docs/call.md](./docs/call.md) |
42
+ | Router | Use vAPI Router for model access and balance. | [docs/router.md](./docs/router.md) |
43
+ | Agents | Run capped local agents with dedicated wallets and profiles. | [docs/agents.md](./docs/agents.md) |
44
+ | MCP | Use namespaced payment tools from an MCP client. | [docs/mcp.md](./docs/mcp.md) |
45
+ | SDK | Use Call, vAPI Router and local agents behind one wallet-bound API. | [docs/sdk.md](./docs/sdk.md) |
46
+ | Vault | Manage the owner wallet, device vault, accounts and spend caps. | [docs/wallets.md](./docs/wallets.md) |
47
+ | Backup | Store encrypted vault copies and restore with owner approval. | [docs/backup-and-recovery.md](./docs/backup-and-recovery.md) |
304
48
 
305
- `wallet` is optional on every tool that takes it: without it the session's
306
- active wallet is used, then `VAPI_WALLET`, then the machine default. Every
307
- result names the wallet it used. `call.pay` applies that wallet's own spend caps
308
- before it signs and tags the receipt with its name. `wallet.use` moves the
309
- session onto another wallet **for this process only** — it never rewrites
310
- `wallets.json`, so your own terminal keeps the default you chose — and appends a
311
- `wallet.use.session` line to the audit log. Reads need no passphrase at all.
49
+ Wallets and custody are in [docs/wallets.md](./docs/wallets.md), and account transfers are in [docs/sending.md](./docs/sending.md). Configuration, funding, networks and bug reports are in [docs/configuration.md](./docs/configuration.md).
312
50
 
313
- Spend caps default to $0.10 per call and $1.00 per day.
51
+ The MCP server registers `vapi.status`, `vapi.accounts`, `vapi.siblings`, `accounts.add`, `accounts.caps`, `accounts.send`, `auth.link`, `auth.status`, `router.models`, `router.usage`, `router.chat`, `router.buy`, `call.search`, `call.inspect`, `call.pay`, `wallet.address`, `wallet.balance`, `wallet.accounts`, `wallet.list`, `wallet.use`, `wallet.fund`, `receipts.list`, `receipts.stats`, `support.report`; inputs and results are in [docs/mcp.md](./docs/mcp.md).
314
52
 
315
53
  #### Deprecated tool aliases
316
54
 
317
- These four pre-namespace names still work and still behave identically, but each
318
- result carries one `DEPRECATED:` line naming its replacement. They will be
319
- removed in a later release.
55
+ These pre-namespace names still work and each result carries a DEPRECATED: line naming its replacement.
320
56
 
321
57
  | Alias | Use instead |
322
58
  | --------- | ---------------- |
@@ -325,237 +61,91 @@ removed in a later release.
325
61
  | `call` | `call.pay` |
326
62
  | `wallet` | `wallet.balance` |
327
63
 
328
- #### What the MCP server cannot do
329
-
330
- Create, rename, remove, restore, back up, import or export a wallet, or return a
331
- recovery phrase, a private key or a passphrase. Those stay in the CLI, in front
332
- of a person.
333
-
334
- ## SDK
335
-
336
- ```bash
337
- npm i @vapi-network/core @vapi-network/sources
338
- ```
339
-
340
- `@vapi-network/core` is the main entry point: the x402 protocol, the wallet
341
- store, spend policy, the network guard, discovery merge and the receipt ledger.
342
- `@vapi-network/core/secrets` is a second, deliberately separate entry point for
343
- the four functions that return a recovery phrase or a private key —
344
- `exportRecoveryPhrase`, `exportKeystoreKeys`, `createKeystoreWithPhrase` and
345
- `decryptPrivateKey`. They are not re-exported from the main index, and the MCP
346
- package is forbidden by lint to import them, so a surface an agent drives cannot
347
- reach a secret by accident.
348
-
349
- Search and pay:
350
-
351
- ```ts
352
- import {
353
- LocalWallet,
354
- SpendPolicy,
355
- WalletStore,
356
- getVapiPaths,
357
- loadConfig,
358
- resolvePassphrase,
359
- spendCapsForWallet,
360
- } from "@vapi-network/core";
361
- import { vapiRegistrySource } from "@vapi-network/sources";
362
-
363
- const paths = getVapiPaths();
364
- const config = await loadConfig(paths.config);
365
- const [listing] = await vapiRegistrySource(config.marketplaceDiscoveryUrl, {
366
- discoveryUrl: config.discoveryUrl,
367
- }).search("weather");
368
-
369
- const store = await WalletStore.open(paths.directory);
370
- const { name } = store.resolve();
371
- const account = await store.unlock(name, (await resolvePassphrase(name)).passphrase);
372
- const wallet = new LocalWallet(
373
- account,
374
- new SpendPolicy(await spendCapsForWallet(store, name), {
375
- ledgerPath: paths.ledger,
376
- wallet: name,
377
- }),
378
- );
379
- ```
380
-
381
- Manage wallets:
382
-
383
- ```ts
384
- import { WalletStore, getVapiPaths, usdToAtomic } from "@vapi-network/core";
385
-
386
- const store = await WalletStore.open(getVapiPaths().directory);
387
- for (const wallet of await store.list()) {
388
- console.log(wallet.name, wallet.address, wallet.isDefault, wallet.spendCaps);
389
- }
390
- await store.setSpendCaps("agent", {
391
- perCallAtomic: String(usdToAtomic(0.05)),
392
- perDayAtomic: String(usdToAtomic(1)),
393
- });
394
- ```
395
-
396
- `WalletStore` is the one entry point for the layout: `open`, `list`, `resolve`,
397
- `create`, `importKey`, `unlock`, `setDefault`, `rename`, `setLabel`,
398
- `setSpendCaps`, `remove`, `restore` and `listTrash`. It never rewrites key
399
- material; it moves, names and caps keystores.
400
-
401
- Two runnable examples live in [`examples/`](./examples):
402
- [`pay-with-sdk.ts`](./examples/pay-with-sdk.ts) (`pnpm example:pay -- weather`)
403
- and [`wallets.ts`](./examples/wallets.ts) (`pnpm example:wallets -- agent-demo`).
404
-
405
- ## Configuration
406
-
407
- Local state lives in `~/.vapi/`:
408
-
409
- ```text
410
- config.json registry URLs, networks and RPC endpoints
411
- wallets.json which wallet is the default, plus per-wallet caps and labels
412
- wallets/
413
- main.json one encrypted keystore per wallet, mode 0600
414
- .trash/ removed wallets, kept encrypted, never deleted for you
415
- keystore.json a 0600 symlink to wallets/main.json, for one release
416
- audit.log one JSON line per secret export or wallet change
417
- receipts.jsonl the append-only call ledger
418
- searches.jsonl one line per discovery query
419
- spend-ledger.json today's total, per wallet
420
- reports/ what vapi report writes
421
- ```
422
-
423
- | Variable | What it does |
424
- | ------------------------ | --------------------------------------------------------------------------- |
425
- | `VAPI_HOME` | Use a different directory instead of `~/.vapi` |
426
- | `VAPI_WALLET` | The wallet to use when no `--wallet` is given |
427
- | `VAPI_REGISTRY_URL` | Replace the registry base; the canonical discovery paths derive from it |
428
- | `VAPI_KEYSTORE_PASSWORD` | The passphrase, for CI and for Windows. Checked before the OS secret store. |
429
- | `VAPI_NO_SECRETS` | Set to `1` to stop `vapi backup` and `vapi export-key` printing anything |
430
-
431
- `ARC_TESTNET_RPC_URL` and `SOLANA_RPC_URL` point those two networks at an
432
- endpoint you trust. On first use of the default home, the client copies an
433
- existing `~/.vapi/agent-cash/` configuration into `~/.vapi/` when it can do so
434
- without overwriting files, prints a notice, and leaves the old directory alone.
435
-
436
- ## Funding
437
-
438
- ```bash
439
- vapi fund # open the funding page for your address
440
- vapi fund --amount 25 # prefill a US dollar amount
441
- vapi fund --json # { address, network, url }
442
- ```
443
-
444
- `vapi fund` prints `<registry>/fund/<your-address>` and opens it in your default
445
- browser when you are on a terminal. The page offers three routes: a card via
446
- Coinbase (needs a Coinbase account; US guest checkout), a transfer from
447
- MetaMask, Coinbase Wallet or WalletConnect, or a bridge from another chain. It
448
- is public, takes no sign-in, and mints the card session when you click — so the
449
- link keeps working while you log in, and nothing expires in your scrollback.
450
-
451
- The command itself makes **no network call**: it works offline, and it always
452
- also prints
453
-
454
- ```text
455
- Send USDC on Base (eip155:8453) to this address; add a little ETH for gas if you plan to sweep.
456
- ```
457
-
458
- Whichever route you pick, the USDC lands on your local address on Base. **vAPI
459
- never holds your funds**, never proxies the payment, and never sees your card
460
- details or your private key. MCP clients use `wallet.fund`, which returns the
461
- same `{ address, network, url }` plus a line telling the agent to hand the link
462
- to its human.
463
-
464
- ## Networks and accounts
465
-
466
- | Network | x402 identifier | USDC | Gas / RPC notes |
467
- | -------------- | ----------------------------------------------------- | ---------------------------------------------- | ------------------------------------------------------ |
468
- | Base mainnet | `eip155:8453` | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | ETH; defaults to `https://mainnet.base.org` |
469
- | Arc testnet | `eip155:5042002` | `0x3600000000000000000000000000000000000000` | USDC is also the gas token; set `ARC_TESTNET_RPC_URL` |
470
- | Solana mainnet | `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d` | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` | SOL; defaults to `https://api.mainnet-beta.solana.com` |
471
-
472
- The x402 reference packages shorten the Solana CAIP-2 reference to
473
- `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`; vAPI accepts that identifier as an
474
- alias while persisting the full genesis hash above. Arc mainnet is **not yet — a
475
- placeholder only**: Arc and the x402 packages publish no mainnet RPC plus
476
- canonical USDC, so the client carries a non-routable placeholder rather than
477
- guessing a production configuration.
478
-
479
- `vapi accounts` lists one deposit account per configured network: its CAIP-2 ID,
480
- network name, address, atomic and formatted USDC balance, gas-token balance, and
481
- deposit guidance. Account lookup dispatches by CAIP namespace, so the EVM and
482
- Solana adapters stay independent of one another. For Arc testnet, add the faucet
483
- to that network's `config.json` entry:
484
-
485
- ```json
486
- {
487
- "depositUrl": "https://your-arc-faucet.example",
488
- "depositInstructions": "Use the configured Arc testnet faucet, then send USDC to this address."
489
- }
490
- ```
491
-
492
- Create both local accounts at initialization with `vapi init --networks
493
- base,solana`, or add an Ed25519 account to an existing keystore with `vapi
494
- accounts --enable solana`. Fund the printed Solana address with SPL USDC. Exact
495
- x402 payments use the facilitator advertised in the challenge as fee payer, so
496
- they do not consume the local SOL balance; `vapi sweep` is a separate
497
- transaction and does need a little SOL. The default public Solana RPC is
498
- rate-limited and has no availability guarantee; set `SOLANA_RPC_URL` to a
499
- dedicated endpoint for regular use.
500
-
501
- ## Discovery sources
502
-
503
- Discovery is a plugin interface. The client merges listings from several
504
- sources, de-duplicates them by normalized resource URL, and keeps each listing's
505
- provenance:
506
-
507
- - **vAPI Registry**, enabled by the default distribution, using
508
- `https://api.vapinetwork.ai/api/call/discovery` and
509
- `https://api.vapinetwork.ai/api/call/services`. If the primary returns HTTP
510
- 404 or cannot be resolved, the client logs one notice and tries the hosts in
511
- `registryFallbacks` on the same canonical paths. The historical
512
- `/api/marketplace/discovery` and `/api/network/services` paths are deprecated;
513
- a base URL supplied on either is normalized to the canonical pair.
514
- - **Coinbase Bazaar**, the public x402 v2 `/discovery/resources` catalogue
515
- exposed by a facilitator.
516
- - **Local file**, a JSON array of listings for private or development
517
- catalogues.
518
- - **x402scan**, a deliberate stub until x402scan documents a stable public read
519
- API this client can safely target.
520
-
521
- Use `@vapi-network/sources` to compose only the catalogues you trust. Every
522
- outbound request is guarded against local and private destinations before it is
523
- made, and redirects and resolved IP addresses are re-validated as new
524
- destinations.
525
-
526
- ## Sign-in with X
527
-
528
- x402 v2 services can require Sign-In-With-X (SIWX) before returning a price.
529
- When `vapi pay` or `call.pay` receives that challenge, vAPI checks that both the
530
- challenge domain and URI match the final resource origin, signs the canonical
531
- EIP-4361 message locally with EVM `personal_sign`, and retries once with
532
- `SIGN-IN-WITH-X`. The proof is never sent to a redirect or a different host.
533
-
534
- If the retry returns a normal 402 quote, the usual spend-policy and payment flow
535
- continues. If the resource is free after sign-in, the result has
536
- `outcome: "signed_in"` and the local receipt records `amountAtomic: "0"`.
537
-
538
- ## Metrics and bug reports
539
-
540
- vAPI measures call and discovery health locally and uploads nothing. Receipts
541
- can include the listing name and provider host, policy decision, retry count,
542
- client version, outcome, total latency, and discovery, quote, signing, request
543
- and settlement phase timings. Policy declines are recorded with the quoted
544
- amount but without a payer or transaction, so blocked spend stays visible
545
- without creating a payment authorization. Search events record the query,
546
- sources tried, per-source latency and result count, merged result count and
547
- timestamp.
64
+ ## CLI reference
548
65
 
549
- ```sh
550
- vapi stats --range 7d
551
- vapi receipts export --format csv --range 30d
552
- ```
66
+ Every command accepts `--json`, which writes one JSON value, success or error,
67
+ to stdout. Exit codes are `0` for success, `1` for an operational failure, and
68
+ `2` for invalid usage or an announced preview-only command.
553
69
 
554
- `vapi report "<what happened>"` writes `$VAPI_HOME/reports/<timestamp>.json` and
555
- prints that path plus a prefilled GitHub issue URL. Reports contain the message,
556
- client version, OS and Node information, and only the newest five receipt IDs.
557
- Wallet and payee addresses are included only with `--include-addresses`; amounts
558
- never are. Nothing is uploaded unless `--send` is explicit.
70
+ Every wallet command takes `--account <name>`, falls back to `VAPI_WALLET`, then the default from `vapi accounts use`; `--wallet <name>` keeps working for one release.
71
+
72
+ | Command | Options | What it does |
73
+ | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
74
+ | `vapi init` | `--networks <base,arc,solana>` | Creates `~/.vapi`, the wallet `main` and the config. Says so if one exists. |
75
+ | `vapi setup` | `--no-cloud-backup`, `--json` | Creates or restores the vault, links the first account, and can offer cloud backup. Safe to rerun. |
76
+ | `vapi accounts` | `--all`, `--json` | Lists local accounts and can add the owner's accounts on other devices as read-only rows |
77
+ | `vapi accounts add <name>` | `--label <text>`, `--no-link`, `--json` | Derives and links a new account |
78
+ | `vapi accounts import <name>` | `--keystore <path>` or `--key-file <path>`, `--label <text>`, `--json` | Imports an account from a private-key prompt or local keystore |
79
+ | `vapi accounts rename <old> <new>` | `--json` | Renames an account and its local records |
80
+ | `vapi accounts use <name>` | `--json` | Sets the default account |
81
+ | `vapi accounts remove <name>` | `--force`, `--json` | Moves an account to `wallets/.trash/` |
82
+ | `vapi accounts restore <name>` | `--json` | Restores an account from `wallets/.trash/` |
83
+ | `vapi accounts caps <name>` | `--per-call <usd>`, `--per-day <usd>`, `--ceiling <usd\|off>`, `--json` | Sets the account's spend caps and automatic Base USDC ceiling |
84
+ | `vapi accounts distribute <amount>` | `--from <account>`, `--to <a,b,c>`, `--network <base\|arc>`, `--json` | Splits USDC across linked local accounts and records resumable legs |
85
+ | `vapi accounts distribute --resume <id>` | `--json` | Continues an unfinished distribution without replacing its recorded nonces |
86
+ | `vapi send <amount>` | `--from <account>`, `--to <account\|owner\|0x…>`, `--network <base\|arc>`, `--resume <nonce>`, `--json` | Sends USDC to the owner or another active account; vAPI pays gas |
87
+ | `vapi wallet list` | - | Name, address, default marker, caps in USD, unlocked, label |
88
+ | `vapi wallet create <name>` | `--networks <base,arc,solana>`, `--label <text>` | A new wallet, with its own phrase, caps and passphrase |
89
+ | `vapi wallet use <name>` | - | Makes it the default for every later command |
90
+ | `vapi wallet rename <old> <new>` | - | Renames the keystore, the registry entry and that wallet's receipts |
91
+ | `vapi wallet remove <name>` | `--force` | Moves the keystore to `wallets/.trash/`; asks you to type the name |
92
+ | `vapi wallet restore <name>` | - | Brings a removed wallet back, same passphrase |
93
+ | `vapi wallet caps <name>` | `--per-call <usd>`, `--per-day <usd>` | Sets that wallet's spend caps, in US dollars |
94
+ | `vapi fund` | `--amount <usd>`, `--wallet <name>` | Prints and opens the hosted funding page. Makes no network call. |
95
+ | `vapi accounts` | `--enable <solana\|arc>`, `--wallet <name>` | One deposit account per configured network, with balances and guidance |
96
+ | `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 |
97
+ | `vapi inspect <id>` | `--endpoint <name>` | Verification, fee, liveness, conformance, identity, contract and live quote, for free |
98
+ | `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 |
99
+ | `vapi pay --resume <receipt-id>` | - | Checks settlement, shows its payment id, and never pays |
100
+ | `vapi check <url>` | `--method <method>` | Grades its 402, extensions and same-origin discovery. Never pays |
101
+ | `vapi balance` | `--wallet <name>` | The wallet's address and USDC balances |
102
+ | `vapi receipts` | `--limit <n>`, `--wallet <name>`, `--all-wallets` | The local append-only call ledger, newest last |
103
+ | `vapi receipts export` | `--format <json\|csv>`, `--range <24h\|7d\|30d>`, `--wallet <name>`, `--all-wallets` | Raw receipts for a spreadsheet or dashboard |
104
+ | `vapi stats` | `--range <24h\|7d\|30d>`, `--wallet <name>`, `--all-wallets` | Spend, outcomes, latency percentiles and top services |
105
+ | `vapi sweep [<address>]` | `--network <caip2>`, `--wallet <name>` | Moves USDC to an address, or to the linked owner when omitted |
106
+ | `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 |
107
+ | `vapi agent run <name> "<task>"` | None | Runs the named agent on this machine |
108
+ | `vapi agent list` | None | Lists profiles, links and today's Call and Router budgets |
109
+ | `vapi agent pause <name>` | None | Stops future runs until the agent is resumed |
110
+ | `vapi agent resume <name>` | None | Allows a paused agent to run again |
111
+ | `vapi agent revoke <name>` | None | Revokes the link and removes the profile, but keeps its wallet |
112
+ | `vapi login` | `--wallet <name>`, `--label <name>`, `--publish`, `--no-browser` | Links the local agent wallet to your vAPI account |
113
+ | `vapi logout` | `--wallet <name>` | Removes the selected wallet's agent link and stored credentials |
114
+ | `vapi whoami` | `--wallet <name>` | Shows the chosen wallet's owner link and permissions, whether the link is live, and its ERC-8004 agent identity. |
115
+ | `vapi router models` | `--wallet <name>` | Lists the vAPI Router model ids |
116
+ | `vapi router usage` | `--wallet <name>` | Shows the agent's Compute allowance and Router balance |
117
+ | `vapi router chat --model <id> "<prompt>"` | `--system <text>`, `--max-tokens <n>`, `--wallet <name>` | Sends one chat request through vAPI Router |
118
+ | `vapi router key` | `--rotate`, `--wallet <name>` | Prints a gated Router key or rotates it without printing it |
119
+ | `vapi router buy <1\|5\|20\|50>` | `--wallet <name>`, `--json` | Buys vAPI Router balance with USDC from your wallet |
120
+ | `vapi router buy --auto <tier> --below <usd>` | `--wallet <name>`, or use `--auto off` | Sets or clears automatic vAPI Router balance refill |
121
+ | `vapi stake status` | `--wallet <name>` | Shows the linked owner's stake and Compute today |
122
+ | `vapi stake open` | `--wallet <name>`, `--no-browser` | Prints and optionally opens the staking page |
123
+ | `vapi export-key` | `--network <caip2>`, `--wallet <name>` | Prints the private key. Terminal only, never for an agent. |
124
+ | `vapi backup` | `--account <name>`, `--cloud [off]`, `--json` | Prints the 12 words, or turns encrypted cloud backup on or off. |
125
+ | `vapi restore` | `--from-owner [--owner <0x…>]`, `--json` | Rebuilds the vault from a recovery phrase typed at the prompt or piped on stdin, or restores an owner-approved cloud backup. |
126
+ | `vapi import` | `--phrase` or `--key`, `--wallet <name>`, `--networks <base,arc,solana>`, `--replace`, `--force` | Restores a wallet from a prompt, never from argv |
127
+ | `vapi passphrase` | `--wallet <name>` | Re-encrypts the keystore under a new passphrase |
128
+ | `vapi vault protect` | `--json` | Adds a password to the device vault |
129
+ | `vapi vault unprotect` | `--json` | Removes the password from the device vault |
130
+ | `vapi vault lock` | `--json` | Closes the protected vault on this device |
131
+ | `vapi vault unlock` | `--json` | Opens the protected vault for 8 hours, or set `VAPI_VAULT_PASSWORD` |
132
+ | `vapi vault status` | `--json` | Shows whether the device vault is protected and open |
133
+ | `vapi unlock` | `--wallet <name>` | Puts that wallet's passphrase in the OS secret store |
134
+ | `vapi lock` | `--wallet <name>`, `--all` | Takes a stored passphrase back out |
135
+ | `vapi report "<what>"` | `--include-addresses`, `--send` | Writes a privacy-preserving local bug report |
136
+ | `vapi auth set-key` | - | Types the registry API key on a prompt into the OS secret store |
137
+ | `vapi auth status` | - | Whether this machine has a key and where it comes from, masked |
138
+ | `vapi auth clear` | - | Takes the stored key back out |
139
+ | `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 |
140
+ | `vapi publish activate <slug>` | - | Takes a listing live once its FeeSplitter is deployed |
141
+ | `vapi publish verify-request <slug>` | - | Asks vAPI to review the listing |
142
+ | `vapi publish list` | - | Every listing this API key owns |
143
+ | `vapi claim <origin>` | `--wallet <name>` | Takes over the listings vAPI indexed from your API, signed by their payee |
144
+ | `vapi mcp` | `--wallet <name>` | Serves the MCP tools over stdio |
145
+ | `vapi mcp install <claude\|cursor\|codex>` | `--home <dir>`, `--registry <url>` | Writes that app's MCP config and prints the file |
146
+ | `vapi serve` | - | Preview only; exits `2` with a message |
147
+ | `vapi version` | - | The client version, also as `--version` or `-v` |
148
+ | `vapi help` | - | The same help bare `vapi` shows, also as `--help` or `-h` |
559
149
 
560
150
  ## Packages
561
151
 
@@ -570,17 +160,6 @@ never are. Nothing is uploaded unless `--send` is explicit.
570
160
  Every npm tarball is bundled and has zero runtime dependencies. The scoped
571
161
  packages are useful for embedding; most users should start with `vapi-network`.
572
162
 
573
- ## Roadmap
574
-
575
- - A local gateway daemon (`vapi serve`) with per-key budgets
576
- - OpenTelemetry traces and metrics, with exporters enabled only by the user
577
- - `task.*` tools for posting, funding, delivering and reviewing work
578
- - `compute.*` tools for discovering models and paying for inference
579
-
580
- Until the gateway lands, `vapi serve` and the provider-side `vapi publish` exit
581
- with a preview message. Payments stay direct from the local wallet to each
582
- service.
583
-
584
163
  ## Development
585
164
 
586
165
  A pnpm workspace for Node.js 22 and pnpm 10. The gate, in order: