@agenttech/tpay-cli 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. package/README.md +142 -54
  2. package/dist/index.js +2 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,82 +1,170 @@
1
1
  # @agenttech/tpay-cli
2
2
 
3
- A CLI for AI agents to send USDT via the T402 x402 v2 payment protocol on Solana.
4
- Output defaults to structured JSON. Use `--format text` for human-readable output. Logs go to stderr.
3
+ Send USDT payments on Solana via the T402 x402 v2 protocol. Designed for AI agents — all output is structured JSON on stdout, logs go to stderr.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g @agenttech/tpay-cli
9
+ ```
10
+
11
+ Verify:
12
+
13
+ ```bash
14
+ tpay version
15
+ ```
16
+
17
+ ## Setup
18
+
19
+ The CLI needs a BIP-39 seed phrase to sign transactions. Two setup paths:
20
+
21
+ ### Non-interactive (recommended for agents)
22
+
23
+ ```bash
24
+ WALLET_SEED_PHRASE="your twelve or twenty four word seed phrase here" \
25
+ TPAY_PASSPHRASE="encryption-password" \
26
+ tpay setup
27
+ ```
28
+
29
+ This encrypts and saves the seed phrase to `~/.config/tpay/.env`.
30
+
31
+ ### From env file
32
+
33
+ ```bash
34
+ tpay setup --from-env /path/to/.env
35
+ ```
36
+
37
+ The file must contain `WALLET_SEED_PHRASE=...`.
38
+
39
+ ### Skip setup (inline seed phrase)
40
+
41
+ You can skip `tpay setup` entirely by passing the seed phrase as an environment variable on every call:
42
+
43
+ ```bash
44
+ WALLET_SEED_PHRASE="your seed phrase" tpay send --to <address> --amount 10
45
+ ```
46
+
47
+ ### Setup output
48
+
49
+ ```json
50
+ {"status":"success","saved":true}
51
+ ```
5
52
 
6
53
  ## Commands
7
54
 
8
- | Command | Description |
9
- |---|---|
10
- | `tpay setup` | Configure wallet keys interactively |
11
- | `tpay setup --from-env <file>` | Import keys from an env file |
12
- | `tpay send --to <addr> --amount <n>` | Send payment |
13
- | `tpay balance --address <addr>` | Show wallet SOL and USDT balances |
14
- | `tpay intent status <intent_id>` | Check payment status |
15
- | `tpay version` | Print version |
16
- | `tpay help` / `tpay --help` | Show all commands |
17
- | `tpay send --help` | Show send args |
18
-
19
- Global flags:
20
- - `--verbose` — debug output to stderr
21
- - `--format text|json` — output format (default: `json`)
55
+ ### `tpay send`
56
+
57
+ Send a USDT payment.
22
58
 
23
59
  ```bash
24
- # JSON output (default, for programmatic use)
25
- tpay send --to <solana-address> --amount 10
26
- {"status":"success","intent_id":"...","tx_hash":"...","explorer_url":"..."}
60
+ tpay send --to <solana-address> --amount <number>
61
+ ```
62
+
63
+ Or pipe JSON via stdin:
64
+
65
+ ```bash
66
+ echo '{"to":"<solana-address>","amount":"10"}' | tpay send
67
+ ```
68
+
69
+ **Success output:**
27
70
 
28
- # Text output (human-readable)
29
- tpay send --to <solana-address> --amount 10 --format text
30
- status: success
31
- intent_id: abc123
32
- tx_hash: ...
33
- explorer_url: https://...
71
+ ```json
72
+ {"status":"success","intent_id":"intent_abc123","tx_hash":"5xY...","explorer_url":"https://..."}
34
73
  ```
35
74
 
75
+ **Error output:**
76
+
77
+ ```json
78
+ {"status":"error","error_type":"payment_error","message":"Payment failed","intent_id":"intent_abc123"}
79
+ ```
80
+
81
+ ### `tpay balance`
82
+
83
+ Check SOL and USDT balances for any address. No wallet keys required.
84
+
36
85
  ```bash
37
- # Check wallet balance (read-only, no keys needed)
38
86
  tpay balance --address <solana-address>
39
- {"status":"ok","address":"<solana-address>","sol":"0.5","usdt":"100.0"}
40
87
  ```
41
88
 
42
- Stdin JSON mode: pipe `{"to":"...","amount":"..."}` to `tpay send`.
89
+ **Output:**
43
90
 
44
- ## Supported Chains
91
+ ```json
92
+ {"status":"ok","address":"<solana-address>","sol":"1.5","usdt":"100.0"}
93
+ ```
45
94
 
46
- | Network |
47
- |---|
48
- | Solana Mainnet |
49
- | Solana Devnet |
95
+ ### `tpay intent status`
50
96
 
51
- ## Runtime Environment Variables
97
+ Check the status of a payment intent.
52
98
 
53
- | Variable | Required | Description |
54
- |---|---|---|
55
- | `WALLET_SEED_PHRASE` | Yes | BIP-39 mnemonic seed phrase |
56
- | `TPAY_PASSPHRASE` | No | Passphrase for decrypting config file (cleared from env after use) |
57
- | `SOLANA_FEE_PAYER` | No | Override fee payer address (build-time default used if unset) |
99
+ ```bash
100
+ tpay intent status <intent_id>
101
+ ```
102
+
103
+ Or via stdin:
104
+
105
+ ```bash
106
+ echo '{"intent_id":"intent_abc123"}' | tpay intent status
107
+ ```
108
+
109
+ **Output:**
110
+
111
+ ```json
112
+ {"status":"ok","intent_id":"intent_abc123","payment_status":"BASE_SETTLED","sending_amount":"10","receiving_amount":"10","payer_chain":"solana","created_at":"...","expires_at":"...","tx_hash":"5xY...","explorer_url":"https://..."}
113
+ ```
58
114
 
59
- ## Build
115
+ ### `tpay version`
60
116
 
61
117
  ```bash
62
- T402_API_URL=https://api.example.com \
63
- SOLANA_RPC_URL=https://your-rpc.example.com \
64
- SOLANA_FEE_PAYER=<base58> \
65
- bun build --compile src/index.ts --outfile tpay
118
+ tpay version
66
119
  ```
67
120
 
68
- ## Development
121
+ ### `tpay help`
69
122
 
70
123
  ```bash
71
- bun install
72
- bun test
73
- WALLET_SEED_PHRASE="..." bun run src/index.ts send --to <solana-address> --amount 1
124
+ tpay help
74
125
  ```
75
126
 
76
- ## Adding a New Chain Plugin
127
+ ## Global Flags
128
+
129
+ | Flag | Description |
130
+ |---|---|
131
+ | `--verbose` | Debug logs to stderr |
132
+ | `--format json\|text` | Output format (default: `json`) |
133
+
134
+ ## Environment Variables
135
+
136
+ | Variable | Required | Description |
137
+ |---|---|---|
138
+ | `WALLET_SEED_PHRASE` | Yes (if no config file) | BIP-39 mnemonic (12–24 words) |
139
+ | `TPAY_PASSPHRASE` | No | Decrypts saved config at `~/.config/tpay/.env` |
140
+ | `SOLANA_FEE_PAYER` | No | Override fee payer address |
141
+
142
+ If both `WALLET_SEED_PHRASE` env var and an encrypted config file exist, the env var takes precedence.
143
+
144
+ ## Exit Codes
145
+
146
+ | Code | Type | Meaning |
147
+ |---|---|---|
148
+ | 0 | — | Success |
149
+ | 1 | `validation_error` | Invalid arguments or input |
150
+ | 2 | `runtime_error` | Unexpected runtime failure |
151
+ | 3 | `configuration_error` | Missing or invalid config |
152
+ | 4 | `network_error` | API or RPC failure |
153
+ | 5 | `payment_error` | Payment-specific failure |
154
+
155
+ All errors output JSON to stdout:
156
+
157
+ ```json
158
+ {"status":"error","error_type":"<type>","message":"<description>"}
159
+ ```
160
+
161
+ ## Supported Chains
162
+
163
+ | Chain | Network ID |
164
+ |---|---|
165
+ | Solana Mainnet | `solana` |
166
+ | Solana Devnet | `solana-devnet` |
167
+
168
+ ## License
77
169
 
78
- - [ ] Create `src/plugins/chains/<name>.ts`
79
- - [ ] Implement `ChainPlugin` interface (`name`, `chains[]`, `sign()`)
80
- - [ ] Add to `CHAIN_PLUGIN_LOADERS` in `src/loader.ts`
81
- - [ ] Add to Supported Chains table above
82
- - [ ] Test: verify x402 payload structure matches T402 backend
170
+ ISC
package/dist/index.js CHANGED
@@ -64037,7 +64037,7 @@ async function runHelp(ctx) {
64037
64037
  async function runVersion(ctx) {
64038
64038
  output(ctx.format, {
64039
64039
  name: "@agenttech/tpay-cli",
64040
- version: "0.0.2"
64040
+ version: "0.0.3"
64041
64041
  });
64042
64042
  return 0;
64043
64043
  }
@@ -64422,7 +64422,7 @@ function createProgram() {
64422
64422
  const program2 = new Command;
64423
64423
  const versionInfo = {
64424
64424
  name: "@agenttech/tpay-cli",
64425
- version: "0.0.2"
64425
+ version: "0.0.3"
64426
64426
  };
64427
64427
  const versionString = typeof versionInfo === "string" ? versionInfo : versionInfo.version;
64428
64428
  program2.name("tpay").version(versionString, "-v, --version", "Show version").option("--verbose", "Enable debug logging to stderr").option("--format <fmt>", "Output format: json | text", "json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenttech/tpay-cli",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "T402 CLI for agent automation",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",