@agentkv/cli 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The AgentKV Authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # @agentkv/cli
2
+
3
+ The command-line client and MCP server for [AgentKV](https://github.com/agentx402-ai/agentkv) —
4
+ an agent-native, encrypted key-value store paid per request over [x402](https://x402.org).
5
+
6
+ No setup: AgentKV mints + manages a wallet for you on first run and defaults to the hosted
7
+ service. Just run a command:
8
+
9
+ ```bash
10
+ npx @agentkv/cli set mykey '{"hello":"world"}'
11
+ agentkv get mykey
12
+ agentkv list-keys # list your keys (paginated, free)
13
+ agentkv balance
14
+ agentkv wallet show # your auto-created wallet — fund it, then back up the key file
15
+ agentkv deposit 1 # pre-pay credits at a tenth the pay-per-op price (once the wallet is funded)
16
+ ```
17
+
18
+ Prefer to bring your own wallet? Set `AGENTKV_PRIVATE_KEY=0x…` (generate one with
19
+ `agentkv wallet new`); set `AGENTKV_ENDPOINT` to point at a different worker.
20
+
21
+ Values are encrypted client-side (AES-256-GCM) before upload. You hold **one AgentKV account**
22
+ in one of two ways, auto-detected by the CLI:
23
+
24
+ - **Wallet-as-key** (default): a signable wallet is the namespace + encryption key; deposits
25
+ fund its own namespace. The auto-provisioned wallet uses this.
26
+ - **Account-key**: for a *managed* wallet that can't sign (e.g. [awal](https://www.npmjs.com/package/awal)),
27
+ an opaque `ak_…` bearer token is the identity + namespace and a **local** key encrypts —
28
+ decoupled from the paying wallet.
29
+
30
+ ```bash
31
+ agentkv account new # mint ak_… + a local encryption key (saved 0600) — BACK THEM UP, unrecoverable
32
+ agentkv account show # status + credit balance; pass --reveal to print the raw secrets
33
+
34
+ # Fund it from ANY signing wallet (a real ≥$1 deposit creates the account on first deposit):
35
+ awal x402 pay https://api.agentx402.ai/account/deposit --headers '{"Authorization":"Bearer ak_..."}'
36
+
37
+ # Then use the account over just the bearer (no wallet, no signing):
38
+ export AGENTKV_ACCOUNT_KEY=ak_... AGENTKV_ENCRYPTION_KEY=0x...
39
+ agentkv set mykey '{"hello":"world"}'
40
+ ```
41
+
42
+ Account-key mode is selected when an `account.json` exists (from `account new`) or
43
+ `AGENTKV_ACCOUNT_KEY` is set; an explicit `AGENTKV_PRIVATE_KEY` keeps wallet mode.
44
+
45
+ Prefer not to fund it by hand every time? Set `AGENTKV_TOPOFF=awal` and the CLI tops itself
46
+ off automatically instead — see `AGENTKV_TOPOFF` in Configuration below.
47
+
48
+ Prefer to skip prepaid credits entirely? Set `AGENTKV_INLINE=awal` to pay each op inline via x402
49
+ as it happens — see `AGENTKV_INLINE` in Configuration below.
50
+
51
+ ## Buy USDC with a card
52
+
53
+ ```bash
54
+ agentkv fund 5 # print a card→USDC onramp URL delivering USDC to your wallet on Base
55
+ ```
56
+
57
+ `fund` only builds a URL (no payment, no network call). For the default Coinbase provider, set
58
+ `AGENTKV_ONRAMP_APP_ID` to a public CDP project id; swap providers with `AGENTKV_ONRAMP_PROVIDER`.
59
+
60
+ The card onramp is **Base mainnet only** — `agentkv fund` errors on a testnet network id
61
+ (`eip155:84532`); fund a testnet account from a faucet + a signing wallet instead.
62
+
63
+ ## Configuration
64
+
65
+ Secrets come from the environment only — never the config file. The one exception is the
66
+ opt-in payer key for `agentkv account fund <usd> --from-key <0xhex>` (fund a decoupled account
67
+ from a wallet other than the configured one); prefer `AGENTKV_PAYER_KEY` to keep the key out of
68
+ shell history / `ps` argv.
69
+
70
+ | Variable | Description |
71
+ |----------|-------------|
72
+ | `AGENTKV_PRIVATE_KEY` | Wallet key (hex). Unset → a local wallet is auto-provisioned on first use. |
73
+ | `AGENTKV_ACCOUNT_KEY` | `ak_…` bearer token — selects account-key mode. |
74
+ | `AGENTKV_ENCRYPTION_KEY` | Local AES key (hex). **Required** with `AGENTKV_ACCOUNT_KEY`; optional override in wallet mode (defaults to HKDF from the wallet key). |
75
+ | `AGENTKV_ENDPOINT` | Worker URL; defaults to `https://api.agentx402.ai`. |
76
+ | `AGENTKV_NETWORK` | `eip155:8453` (Base mainnet, default) or `eip155:84532` (Base Sepolia). |
77
+ | `AGENTKV_MAX_SPEND_USD` | Per-operation USD spend cap. |
78
+ | `AGENTKV_MAX_SESSION_SPEND_USD` | Cumulative, instance-lifetime USD cap (opt-in). |
79
+ | `AGENTKV_ONRAMP_PROVIDER` | Onramp provider id for `agentkv fund` (default `coinbase`). |
80
+ | `AGENTKV_ONRAMP_APP_ID` | Public CDP project id for the Coinbase onramp. |
81
+ | `AGENTKV_TOPOFF` | Account-key auto top-off payer. Only value: `awal` — pays `/account/deposit` via `npx awal x402 pay` when credits run low. Requires an authenticated, funded awal. |
82
+ | `AGENTKV_PREPAY_WATERMARK` | Top off when tracked credits fall below this (USD). Default `0.5`. Requires `AGENTKV_TOPOFF`. |
83
+ | `AGENTKV_PREPAY_TOPOFF` | Top-off amount (USD, >= 1). Default `1`. Requires `AGENTKV_TOPOFF`. |
84
+ | `AGENTKV_INLINE` | Account-key inline pay-per-op payer. Only value: `awal` — pays each `/kv` op via `npx awal x402 pay` at request time, no prepaid credits required. Requires an authenticated, funded awal. If both `AGENTKV_TOPOFF` and `AGENTKV_INLINE` are set, top-off takes precedence per op. |
85
+
86
+ On the awal path `AGENTKV_PREPAY_TOPOFF` is passed only as a `--max-amount` ceiling — the
87
+ worker's `/account/deposit` 402 quotes the actual amount minted (≥ $1 server minimum), capped at
88
+ that ceiling, so raising it above the server minimum may not increase what actually gets deposited.
89
+
90
+ If awal is unauthenticated or unfunded the op fails with `account_topoff_failed` — run
91
+ `npx awal status`; fund by sending USDC to `awal address`.
92
+
93
+ ## MCP server
94
+
95
+ `agentkv mcp` runs an MCP server over stdio exposing `agentkv_set`, `agentkv_get`,
96
+ `agentkv_delete`, `agentkv_list_keys`, `agentkv_deposit`, `agentkv_balance`,
97
+ `agentkv_wallet_address`, and `agentkv_fund` (card→USDC onramp URL), plus four secret-safe
98
+ tools (`agentkv_set_from_env` / `_from_file`, `agentkv_get_to_file` / `run_with_secret`), to
99
+ Claude Desktop / Code / Cursor and any MCP client.
100
+
101
+ In account-key mode (`AGENTKV_ACCOUNT_KEY` set, or a stored account with no `AGENTKV_PRIVATE_KEY`)
102
+ the two wallet-funding tools — `agentkv_deposit` and `agentkv_fund` — refuse with a structured
103
+ error, since a managed account has no wallet to deposit or buy USDC into; fund it by depositing to
104
+ `<endpoint>/account/deposit` from a signing wallet instead.
105
+
106
+ See the [monorepo README](https://github.com/agentx402-ai/agentkv#readme) for the SDK and the
107
+ Claude plugin.
108
+
109
+ ## License
110
+
111
+ [MIT](./LICENSE)