apow-cli 0.11.19 → 0.12.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.
package/.env.example CHANGED
@@ -1,23 +1,39 @@
1
- # === Easy Mode (zero credentials) ===
1
+ # === Easy Mode (no API keys) ===
2
2
  # RPC + LLM + remote GPU grind all auto-pay with USDC from your wallet.
3
- PRIVATE_KEY=
3
+ KEYSTORE_PATH=
4
+ # KEYSTORE_PASSWORD= # A temporary unlock only; never persist the password here.
5
+ # Before funding in a headless/cloud runner, persist a secret-manager command.
6
+ # Store its secret separately and verify: apow wallet verify-recovery
7
+ # KEYSTORE_PASSWORD_CMD=security find-generic-password -s apow-keystore -w
4
8
  USE_X402=true
5
9
  USE_X402_GRIND=true
6
10
  ALLOW_LOCAL_FALLBACK_WITH_X402=false
7
11
 
12
+ # Wallet Protocol v2
13
+ # APOW_POLICY=enforce # enforce | warn | off
14
+ # APOW_POLICY_PATH=~/.apow/policy.json
15
+ # APOW_PAYOUT_ADDRESS= # cold wallet that receives AGENT sweeps
16
+ # APOW_SWEEP_THRESHOLD_AGENT=25
17
+ # APOW_X402_DAILY_USDC=20
18
+ # APOW_X402_MAX_PER_REQUEST_USDC=1
19
+
8
20
  # === Custom Configuration (override any defaults below) ===
9
21
 
10
22
  # RPC — bring your own endpoint instead of x402
11
23
  # RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY
12
24
  # USE_X402=false
13
25
 
14
- # LLM Provider (clawrouter / openai / anthropic / gemini / deepseek / qwen / ollama / claude-code / codex)
26
+ # LLM Provider
27
+ # x402: clawrouter
28
+ # API key: openai / anthropic / gemini / deepseek / qwen
29
+ # Local inference: ollama
30
+ # Subscription CLI (hosted inference): claude-code / codex
15
31
  # Default: clawrouter when USE_X402=true, openai otherwise
16
32
  # LLM_PROVIDER=clawrouter
17
- # LLM_MODEL=blockrun/eco
33
+ # LLM_MODEL= # optional override; x402 selects automatically
18
34
  # CLAWROUTER_PORT=8402 # only if default port is in use
19
35
 
20
- # API key (not needed for clawrouter, ollama, claude-code, or codex)
36
+ # API key (not used by clawrouter, ollama, claude-code, or codex)
21
37
  # LLM_API_KEY=
22
38
 
23
39
  # Provider-specific keys (alternative to LLM_API_KEY)
@@ -28,6 +44,10 @@ ALLOW_LOCAL_FALLBACK_WITH_X402=false
28
44
  # Ollama (only if LLM_PROVIDER=ollama)
29
45
  # OLLAMA_URL=http://127.0.0.1:11434
30
46
 
47
+ # Subscription CLIs
48
+ # LLM_PROVIDER=claude-code # install/sign in with `claude login`; default model: haiku
49
+ # LLM_PROVIDER=codex # install/sign in with `codex login`; default model: gpt-5.6-luna
50
+
31
51
  # Bridging (only needed for `apow fund`)
32
52
  # SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
33
53
  # ETHEREUM_RPC_URL=https://cloudflare-eth.com
package/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # APoW CLI
2
2
 
3
- Mining client for the [APoW (Agentic Proof of Work)](https://github.com/Agentoshi/apow-core) protocol on Base. Prove you're an AI agent once by minting an ERC-721 Mining Rig, then compete on hash power to mine $AGENT tokens.
3
+ Agent-first mining client for [APoW (Agentic Proof of Work)](https://apow.io) on
4
+ Base. Onboard a Mining Rig, then run the protocol's SMHL and Keccak verification
5
+ flow continuously to earn $AGENT tokens. The contracts are
6
+ [open source](https://github.com/Agentoshi/apow/tree/main/packages/core).
4
7
 
5
8
  **Your agent does all the work. You just fund a wallet.**
6
9
 
@@ -8,8 +11,9 @@ Mining client for the [APoW (Agentic Proof of Work)](https://github.com/Agentosh
8
11
  - `Easy Mode`: no config, x402 for RPC + LLM + GPU grinding
9
12
  - `Advanced Mode`: choose which credentials you supply and which services stay autonomous
10
13
 
11
- `apow start` is the fastest path when you want the full flow in one command:
12
- setup, funding checks, minting, and mining.
14
+ `apow start` is the fastest path: choose Easy or Advanced Mode, complete the
15
+ mandatory Base funding handoff, mint, and mine continuously. Agents can select
16
+ the same existing Easy Mode directly with `apow start --easy`.
13
17
 
14
18
  ## Install
15
19
 
@@ -28,43 +32,42 @@ npx apow-cli
28
32
  > **v0.8.0+: Bring your own RPC or use auto-pay.** You need a Base RPC endpoint. Two options:
29
33
  >
30
34
  > 1. **Bring your own** (free): Get a free RPC URL from [Alchemy](https://www.alchemy.com/), [QuickNode](https://www.quicknode.com/), or any Base RPC provider. Set `RPC_URL` in your `.env`.
31
- > 2. **QuickNode x402** (paid, zero setup): Set `USE_X402=true` in your `.env`. Your mining wallet pays for RPC usage via the [x402 payment protocol](https://www.x402.org/). Start with at least 2.00 USDC on Base and add more for headroom. No API key or account needed.
35
+ > 2. **QuickNode x402** (paid, zero setup): Set `USE_X402=true` in your `.env`. Your mining wallet pays for RPC usage via the [x402 payment protocol](https://www.x402.org/). Deposit Base ETH through the funding flow; the CLI converts the initial 2.00 USDC service budget. No API key or account needed.
32
36
  >
33
37
  > Run `apow setup` to configure interactively.
34
38
 
35
39
  ## For AI Agents
36
40
 
37
- Any AI agent can go from zero to actively mining with no human interaction except funding the wallet.
38
- If the wallet is already configured, `apow start` skips ahead automatically.
41
+ Deposit **Base ETH only**. The CLI quotes the live rig price, retains ETH for gas,
42
+ and converts the service budget to USDC. It tests wallet recovery before giving
43
+ funding instructions. Rerun the same command after deposit to mint or resume
44
+ an existing rig; the wallet address stays the same.
45
+
46
+ See the [assistant profiles](https://apow.io/docs/technical/assistants) for Grok Bot,
47
+ Muse, Instinct, Wajo, OpenClaw, Hermes, Claude Code, Codex, and other runtimes.
48
+ The [managed cloud service](https://apow.io/docs/technical/managed-mining) is in
49
+ development; the current CLI still needs a runner.
39
50
 
40
51
  ```bash
41
- npx apow-cli start
52
+ npx --yes apow-cli@0.12.3 start --easy
42
53
  ```
43
54
 
44
- Easy Mode writes an `.env` equivalent to:
55
+ Relevant Easy Mode settings include:
45
56
 
46
57
  ```bash
47
- PRIVATE_KEY=0x...
58
+ KEYSTORE_PATH=~/.apow/keystores/wallet-0x....json
48
59
  USE_X402=true
49
60
  USE_X402_GRIND=true
50
61
  LLM_PROVIDER=clawrouter
51
- LLM_MODEL=blockrun/eco
52
62
  ALLOW_LOCAL_FALLBACK_WITH_X402=false
53
63
  ```
54
64
 
55
- **Scale up** with multiple wallets from a single funded wallet:
56
-
57
- ```bash
58
- # Generate sub-wallets and fund them from your main wallet
59
- npx apow-cli wallet new # → sub-wallet address
60
- npx apow-cli wallet fund <sub-address> # sends mint price + gas from main wallet
61
-
62
- # Mint + mine with each sub-wallet
63
- PRIVATE_KEY=<sub-key> npx apow-cli mint
64
- PRIVATE_KEY=<sub-key> npx apow-cli mine &
65
- ```
66
-
67
- Each wallet gets one rig, each rig mines independently. More wallets = more chances to win each block. See [skill.md](skill.md) for the complete autonomous guide.
65
+ The keystore password is prompted interactively. For headless launch services,
66
+ save a `KEYSTORE_PASSWORD_CMD` reference in the private `.env` and use a supported
67
+ secret manager. Run `apow wallet verify-recovery` before funding. A password kept
68
+ only in process memory cannot recover after a restart. Never send secrets in chat.
69
+ Never put it in chat or commit it to a project file. See [skill.md](skill.md) for
70
+ the narrow autonomous mining workflow.
68
71
 
69
72
  ## For Humans
70
73
 
@@ -80,35 +83,44 @@ If you want to control each step manually, the older step-by-step flow is still
80
83
 
81
84
  | Command | Description |
82
85
  |---------|-------------|
83
- | `apow start` | Guided happy path: setup -> funding checks -> mint -> mine |
86
+ | `apow start [--easy]` | Existing Easy/Advanced flow: setup -> Base funding check/handoff -> mint -> mine |
84
87
  | `apow setup` | Agent-first setup wizard: Easy Mode (x402 everywhere) or Advanced Mode |
85
- | `apow fund` | Fund your wallet: bridge from Solana/Ethereum or send on Base, auto-split ETH+USDC |
86
- | `apow wallet new` | Generate a new mining wallet, plus optional encrypted JSON keystore backup |
88
+ | `apow fund` | ETH-only funding quote, conversion, and configured bridge routes |
89
+ | `apow wallet new` | Generate a new encrypted mining wallet |
90
+ | `apow wallet verify-recovery` | Test fresh-process unlock before funding |
91
+ | `apow wallet list` | List every wallet generated locally by this APoW CLI and mark the active wallet |
92
+ | `apow wallet use [address-or-number]` | Select a generated wallet for the current project (`select` is an alias) |
87
93
  | `apow wallet show` | Show configured wallet address |
88
- | `apow wallet export` | Export your wallet's private key and optional backups |
94
+ | `apow wallet backup` | Show the encrypted keystore backup location; never display wallet secrets |
95
+ | `apow wallet migrate` | Encrypt legacy `PRIVATE_KEY` into a keystore and clear `.env` |
96
+ | `apow wallet payout set <addr>` | Configure a cold payout address for AGENT sweeps |
97
+ | `apow wallet sweep [--all]` | Sweep mined AGENT, and optionally excess ETH/USDC, to payout |
89
98
  | `apow wallet fund <addr> [eth]` | Send ETH to another address (default: mint price + gas) |
90
- | `apow mint` | Mint a MiningAgent NFT (one per wallet) |
91
- | `apow mine [tokenId]` | Mine $AGENT with your NFT (auto-detects best rig) |
92
- | `apow stats [tokenId]` | View mining stats, earnings, difficulty |
93
- | `apow dashboard start` | Launch multi-wallet mining dashboard |
94
- | `apow dashboard add <addr>` | Add a wallet to the dashboard |
95
- | `apow dashboard scan [dir]` | Auto-detect `wallet-0x*.txt` and `wallet-0x*.json` files in a directory |
99
+ | `apow policy show/init/set mode` | Inspect or change local signing policy |
100
+ | `apow mint` | Confirm and mint a MiningAgent NFT (one per wallet) |
101
+ | `apow mine [tokenId]` | Mine $AGENT continuously (auto-detects best rig) |
102
+ | `apow stats [tokenId]` | View mining stats |
103
+ | `apow dashboard start` | Launch the local APoW-wallet dashboard |
104
+ | `apow dashboard wallets` | List wallets generated locally by this CLI |
96
105
 
97
106
  ## Configuration
98
107
 
99
108
  Create a `.env` file or use `apow setup`:
100
109
 
101
110
  ```bash
102
- PRIVATE_KEY=0x... # Your wallet private key
103
- USE_X402=true # Auto-pay RPC + LLM via x402 (2.00 USDC minimum starting balance, zero API keys)
111
+ KEYSTORE_PATH=~/.apow/keystores/wallet-0x....json # Preferred: encrypted wallet JSON
112
+ USE_X402=true # Auto-pay RPC + LLM via x402 (2.00 USDC minimum starting balance, no API keys)
104
113
  USE_X402_GRIND=true # Auto-pay remote GPU grinding via x402
105
114
  ALLOW_LOCAL_FALLBACK_WITH_X402=false # Easy Mode default: do not burn local CPU while x402 GPU is active
106
115
  # STALE_CHECK_INTERVAL=5 # Seconds between stale-challenge checks while grinding (default: 5)
107
116
  # RPC_URL=https://... # Or: bring your own RPC (free from Alchemy, QuickNode, etc.)
108
- # LLM_PROVIDER=clawrouter # clawrouter (auto with x402) | openai | gemini | deepseek | qwen | anthropic | ollama (for minting)
109
- # LLM_MODEL=blockrun/eco # Auto-detected per provider; override only if needed
110
- # LLM_API_KEY=sk-... # Not needed with clawrouter/ollama; required for openai/gemini/etc.
111
- # KEYSTORE_PASSWORD=... # Optional: create encrypted wallet JSON backups during wallet new/export
117
+ # LLM_PROVIDER=clawrouter # x402: clawrouter | API key: openai/anthropic/gemini/deepseek/qwen | local/subscription CLI: ollama/claude-code/codex
118
+ # LLM_MODEL=... # Optional override; x402 selects automatically
119
+ # LLM_API_KEY=sk-... # Required only for API-key providers
120
+ # KEYSTORE_PASSWORD= # Temporary unlock only; never store the password here
121
+ # KEYSTORE_PASSWORD_CMD=... # Preferred headless unlock command, stdout is used as password
122
+ # APOW_POLICY=enforce # enforce | warn | off
123
+ # APOW_PAYOUT_ADDRESS=0x... # optional cold payout wallet for AGENT sweeps
112
124
  # Bridging (only for `apow fund`)
113
125
  # SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
114
126
  # ETHEREUM_RPC_URL=https://cloudflare-eth.com
@@ -120,43 +132,100 @@ ALLOW_LOCAL_FALLBACK_WITH_X402=false # Easy Mode default: do not burn local CPU
120
132
 
121
133
  See [.env.example](.env.example) for all options.
122
134
 
135
+ ## Wallet Protocol v2
136
+
137
+ Mining requires a hot EOA because the immutable APoW contracts require direct wallet signatures. Wallet Protocol v2 limits that hot wallet's blast radius:
138
+
139
+ - every transaction and x402 typed-data signature goes through a local policy guard;
140
+ - mined AGENT can be swept to a separate payout address with `apow wallet payout set <addr>` — AGENT transfers are frozen on-chain until the LP pool deploys, so the CLI skips AGENT sweeps until `lpDeployed` flips and then activates them automatically (ETH/USDC sweeps via `--all` work immediately);
141
+ - audit and spend ledgers are written under `~/.apow/audit-<address>.jsonl` and `~/.apow/spend-<address>.jsonl`;
142
+ - child grinder and local LLM processes do not receive wallet or keystore-password secrets;
143
+ - generated wallets are written only as encrypted keystores, and wallet commands never print or write a raw-key export;
144
+ - Easy Mode refuses to run if the enforce-mode mint or x402 policy caps were relaxed beyond its defaults;
145
+ - `apow start --easy` selects the existing Easy Mode without adding a second approval or wallet-control system.
146
+
147
+ Useful commands:
148
+
149
+ ```bash
150
+ apow policy show
151
+ apow wallet payout set 0x...
152
+ apow wallet sweep
153
+ apow wallet migrate # convert legacy PRIVATE_KEY to KEYSTORE_PATH
154
+ ```
155
+
156
+ For headless unlocks, prefer a command that prints the password from your OS secret store:
157
+
158
+ ```bash
159
+ KEYSTORE_PASSWORD_CMD="security find-generic-password -s apow-keystore -w"
160
+ ```
161
+
123
162
  ## LLM Providers (for Minting)
124
163
 
125
- An LLM is required to mint your Mining Rig NFT (one-time identity verification). Use a fast, non-thinking model to stay within the 20-second challenge window. Once minted, mining uses optimized algorithmic SMHL solving with no LLM needed.
164
+ An LLM is required when minting a new Mining Rig NFT because the mint gate uses a
165
+ 20-second SMHL challenge. Easy Mode handles SMHL and mining automatically after
166
+ the user funds the dedicated wallet.
167
+
168
+ Advanced Step 3 groups the choices by payment and execution model:
126
169
 
127
- | Provider | Model | Cost/call | Notes |
128
- |----------|-------|-----------|-------|
129
- | ClawRouter | `blockrun/eco` | ~$0.006 | Recommended. Zero credentials, pays with USDC via x402 |
170
+ 1. **Auto** — Zero Config via x402. The model is selected automatically and each
171
+ request is paid from the mining wallet's Base USDC balance.
172
+ 2. **API key** — OpenAI, Anthropic, Gemini, DeepSeek, or Qwen.
173
+ 3. **Local / subscription CLI** — Ollama runs inference on the user's machine;
174
+ Claude Code and Codex run local command-line clients but use hosted models and
175
+ the user's existing subscription allowance.
176
+
177
+ | Provider | Default model | Billing | Notes |
178
+ |----------|---------------|---------|-------|
179
+ | Auto via x402 | Automatic | Wallet-paid USDC | Zero Config; no API key or model selection required |
130
180
  | OpenAI | `gpt-4o-mini` | ~$0.001 | Cheapest API key option, fast |
131
181
  | Gemini | `gemini-2.5-flash` | ~$0.001 | Fast, good accuracy |
132
182
  | DeepSeek | `deepseek-chat` | ~$0.001 | Fast, accessible in China |
133
183
  | Qwen | `qwen-plus` | ~$0.002 | Alibaba Cloud |
134
184
  | Anthropic | `claude-sonnet-4-5-20250929` | ~$0.005 | Works but slower |
135
- | Ollama | `llama3.1` | Free | Local GPU required |
136
-
137
- ## Funding (v0.7.0+)
185
+ | Ollama | `llama3.1` | Local compute | Truly local inference; Ollama must be running with the model installed |
186
+ | Claude Code | `haiku` | Claude subscription allowance | Hosted inference through an installed, signed-in CLI |
187
+ | Codex | `gpt-5.6-luna` | ChatGPT subscription allowance | Hosted inference through an installed, signed-in CLI |
138
188
 
139
- Mining requires two assets on Base: **ETH** (gas) and **USDC** (x402 RPC). `apow start` checks both and can auto-split the wallet into the right mix. The `fund` command also bridges from Solana or Ethereum, or accepts deposits on Base, and auto-splits into both:
189
+ Prepare one of the local/subscription choices before minting:
140
190
 
141
191
  ```bash
142
- # From Solana (deposit address — send from any wallet, QR code included)
143
- apow fund --chain solana --token sol # bridge SOL → ETH, auto-swap portion to USDC
144
- apow fund --chain solana --token usdc # bridge USDC, auto-swap portion to ETH
192
+ ollama pull llama3.1 # Ollama only; keep the Ollama service running
193
+ claude login # Claude Code; sign in with the intended Claude subscription
194
+ codex login # Codex; choose ChatGPT subscription access
195
+ ```
196
+
197
+ APoW disables Claude Code tools and session persistence. It runs Codex from an
198
+ isolated temporary directory in ephemeral, read-only mode. Both child processes
199
+ receive a strict environment allowlist rather than wallet secrets or API-billing
200
+ keys. Both subscription adapters passed off-chain SMHL command tests; neither is
201
+ yet recorded as a completed APoW mainnet mint.
145
202
 
146
- # From Ethereum mainnet
147
- apow fund --chain ethereum # bridge ETH → ETH on Base, auto-swap portion to USDC
203
+ ## Funding (v0.7.0+)
148
204
 
149
- # Already on Base
150
- apow fund --chain base --token eth # show address, wait for deposit, auto-split
151
- apow fund --chain base --token usdc # show address, wait for deposit, auto-split
205
+ Send **one asset: Base ETH**. `apow start --easy` quotes the current rig price,
206
+ a conservative 0.003 ETH reserve, swap gas, and the missing 2 USDC service budget.
207
+ The reserve is not the actual gas cost per mine. The Uniswap quote includes a
208
+ 2% input buffer and requires enough USDC output; the CLI checks balances again
209
+ after the swap. The fee budget uses current L2 fee caps, a fixed transaction gas
210
+ ceiling, and buffered Base L1/operator fees. Those L2 caps are used when signing.
211
+ It stops if conversion would consume the required ETH reserve.
152
212
 
153
- # Skip auto-split (keep single asset)
154
- apow fund --chain base --no-swap
213
+ ```bash
214
+ apow start --easy # quote, deposit ETH, then rerun to convert/mint/mine
215
+ apow fund # default Base ETH; resumes existing deposits
216
+ apow fund --chain solana --token sol # configured Squid route: SOL to Base ETH
217
+ apow fund --chain solana --token usdc # configured Squid route: USDC to Base ETH
218
+ apow fund --chain ethereum --token eth
219
+ apow fund --no-swap # quote only; no conversion
155
220
  ```
156
221
 
157
- **Solana/Ethereum bridging:** Uses [Squid Router](https://squidrouter.com/) (Chainflip). Generates a one-time deposit address with QR code — send from any wallet. Requires `SQUID_INTEGRATOR_ID` in `.env` (free at [squidrouter.com](https://app.squidrouter.com/)).
222
+ Solana routes require an operator-configured `SQUID_INTEGRATOR_ID`. They are
223
+ unavailable until configured. Bridge quotes must cover the Base requirement
224
+ after fees and slippage before a deposit address is offered. Do not send SOL
225
+ to the Base wallet address. Keep the bridge request ID and respect its expiry.
158
226
 
159
- **Auto-split targets:** 0.003 ETH (gas for ~100 mine txns) + 2.00 USDC (minimum x402 starting balance). If both are already met, the CLI skips the swap.
227
+ Existing USDC stays usable for services. Base ETH is the funding deposit asset;
228
+ the CLI does not ask the user to supply both ETH and USDC.
160
229
 
161
230
  ## x402 GPU Grinding
162
231
 
@@ -176,7 +245,7 @@ In Easy Mode, the HTTP grinder is the only nonce source, so agents do not silent
176
245
  | `ALLOW_LOCAL_FALLBACK_WITH_X402` | Let local JS fallback run alongside x402 GPU (`false` in Easy Mode) |
177
246
  | `GRIND_URL` | Custom GrindProxy endpoint (default: `https://grind.apow.io/grind`) |
178
247
 
179
- Self-host your own GrindProxy: see [apow-grind](https://github.com/Agentoshi/apow-grind).
248
+ Self-host your own GrindProxy: see [packages/grind](https://github.com/Agentoshi/apow/tree/main/packages/grind).
180
249
 
181
250
  ## GPU Mining (v0.9.2+)
182
251
 
@@ -212,47 +281,35 @@ The CUDA grinder runs over SSH alongside your local Metal/CPU grinders — genui
212
281
 
213
282
  ### Other Optimizations
214
283
 
215
- - **Algorithmic SMHL**: Mining SMHL challenges are solved algorithmically in microseconds (no LLM call). Your AI was already proven when you minted your Mining Rig.
216
284
  - **Faster stale restarts**: The miner re-checks the challenge every 5 seconds by default and aborts dead work quickly across local, native GPU/CPU, and x402 grinding.
217
285
  - **JS threads**: If no native grinders are found, falls back to `worker_threads` across all CPU cores. Set `MINER_THREADS` in `.env` to override.
218
286
 
219
287
  ## Dashboard
220
288
 
221
- Monitor your entire mining fleet from a single web UI. Zero external dependencies -- vanilla HTML/JS served by the CLI.
289
+ Monitor wallets generated locally by this APoW CLI from a single web UI. Zero external dependencies -- vanilla HTML/JS served by the CLI on `127.0.0.1` only. The dashboard does not scan directories, ingest wallet files, accept manually added addresses, or load external fleet configurations. It loads once, then only refreshes chain data when you click **Refresh**, so it does not burn RPC quota in the background.
222
290
 
223
291
  ```bash
224
- # Quick start: scan wallet files and launch
225
- apow dashboard scan . # detect wallet-0x*.txt / .json files in current directory
226
- apow dashboard start # open dashboard at http://localhost:3847
292
+ # Quick start: generate an encrypted wallet and launch
293
+ apow wallet new
294
+ apow dashboard start # open http://localhost:3847
227
295
  ```
228
296
 
229
297
  ### Commands
230
298
 
231
299
  | Command | Description |
232
300
  |---------|-------------|
233
- | `apow dashboard start` | Launch dashboard web UI (default port 3847) |
234
- | `apow dashboard add <addr>` | Add a wallet address to monitor |
235
- | `apow dashboard remove <addr>` | Remove a wallet from monitoring |
236
- | `apow dashboard scan [dir]` | Auto-detect wallets from `wallet-0x*.txt` and `wallet-0x*.json` files |
237
- | `apow dashboard wallets` | List all monitored wallets |
238
-
239
- ### Fleet Configuration
240
-
241
- Wallets are stored in `~/.apow/wallets.json` (plain JSON array of addresses). For advanced fleet management, create `~/.apow/fleets.json`:
242
-
243
- ```json
244
- [
245
- { "name": "Local", "type": "array", "path": "/home/user/.apow/wallets.json" },
246
- { "name": "Vast.ai", "type": "rigdirs", "path": "/mnt/mining/rigs" },
247
- { "name": "Pool", "type": "walletfiles", "path": "/mnt/mining/wallets" }
248
- ]
249
- ```
301
+ | `apow dashboard start` | Launch dashboard web UI |
302
+ | `apow dashboard wallets` | List wallets generated locally by this CLI |
303
+
304
+ ### Wallet Scope
305
+
306
+ `~/.apow/generated-wallets.json` records only addresses and encrypted-keystore paths created by `apow wallet new` or the setup wizard's new-wallet flow. A wallet appears only while its matching keystore exists under `~/.apow/keystores/`. Imported wallets, arbitrary addresses, legacy plaintext files, and unrelated filesystem artifacts are intentionally excluded.
250
307
 
251
- Fleet types: `array` (JSON array of addresses), `solkek` (master/miners JSON), `rigdirs` (scan `rig*/wallet-0x*.txt` / `.json`), `walletfiles` (scan `wallet-0x*.txt` / `.json`).
308
+ Refreshes use chunked multicalls and a 25-second cache. Clicking **Refresh** after the cache expires waits for a fresh RPC read; clicking again inside the cache window reuses the current data.
252
309
 
253
310
  ## Protocol
254
311
 
255
- The APoW protocol contracts and documentation live in [apow-core](https://github.com/Agentoshi/apow-core).
312
+ The APoW protocol contracts and documentation live in [packages/core](https://github.com/Agentoshi/apow/tree/main/packages/core) of the [APoW monorepo](https://github.com/Agentoshi/apow).
256
313
 
257
314
  ## License
258
315
 
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.MINT_GAS_RESERVE_ETH = void 0;
37
+ exports.requiresUsdc = requiresUsdc;
38
+ exports.prepareBaseFunding = prepareBaseFunding;
39
+ const viem_1 = require("viem");
40
+ const config_1 = require("./config");
41
+ const constants_1 = require("./bridge/constants");
42
+ const uniswap_1 = require("./bridge/uniswap");
43
+ const funding_plan_1 = require("./funding-plan");
44
+ const wallet_1 = require("./wallet");
45
+ const context_1 = require("./policy/context");
46
+ const ui = __importStar(require("./ui"));
47
+ exports.MINT_GAS_RESERVE_ETH = (0, viem_1.parseEther)(String(constants_1.MIN_ETH));
48
+ const SWAP_GAS_RESERVE_ETH = (0, viem_1.parseEther)("0.00005");
49
+ function requiresUsdc(needsMint = true) {
50
+ return config_1.config.useX402 || config_1.config.useX402Grind || (needsMint && config_1.config.llmProvider === "clawrouter");
51
+ }
52
+ /** All reads use the funding RPC, so a wallet with only ETH can bootstrap x402. */
53
+ async function prepareBaseFunding(needsMint, allowSwap) {
54
+ if (!wallet_1.account)
55
+ throw new Error("Unlock the configured wallet before funding");
56
+ const fundingAccount = wallet_1.account;
57
+ const { publicClient } = (0, wallet_1.getFundingClients)();
58
+ if (await publicClient.getChainId() !== config_1.config.chain.id)
59
+ throw new Error("Funding RPC chain does not match the configured network");
60
+ const mintPrice = needsMint ? await publicClient.readContract({
61
+ address: config_1.config.miningAgentAddress,
62
+ abi: [{ name: "getMintPrice", type: "function", stateMutability: "view", inputs: [], outputs: [{ type: "uint256" }] }],
63
+ functionName: "getMintPrice",
64
+ }) : 0n;
65
+ const requirements = {
66
+ ethReserve: mintPrice + exports.MINT_GAS_RESERVE_ETH,
67
+ usdcTarget: requiresUsdc(needsMint) ? (0, viem_1.parseUnits)(String(constants_1.MIN_USDC), 6) : 0n,
68
+ swapGasReserve: SWAP_GAS_RESERVE_ETH,
69
+ };
70
+ const context = (0, context_1.getSignerContext)();
71
+ let swapFees;
72
+ try {
73
+ (0, context_1.setSignerContext)("fund");
74
+ const plan = await (0, funding_plan_1.prepareFunding)(requirements, {
75
+ balances: async () => {
76
+ const [eth, usdc] = await Promise.all([
77
+ publicClient.getBalance({ address: fundingAccount.address }),
78
+ requiresUsdc(needsMint) ? (0, uniswap_1.getUsdcBalance)(fundingAccount.address) : Promise.resolve(0n),
79
+ ]);
80
+ return { eth, usdc };
81
+ },
82
+ quoteEth: uniswap_1.quoteEthForUsdc,
83
+ quoteSwapGas: async (eth, usdc) => {
84
+ swapFees = await (0, uniswap_1.quoteEthSwapFees)(eth, usdc);
85
+ return swapFees.feeReserve;
86
+ },
87
+ swapEth: async (eth, usdc) => {
88
+ ui.info("Funding", `Converting ${(0, viem_1.formatEther)(eth)} ETH to USDC; retaining the mint and gas reserve.`);
89
+ const result = await (0, uniswap_1.swapEthToUsdc)(eth, usdc, swapFees);
90
+ ui.ok(`Funding swap confirmed: ${result.txHash}`);
91
+ },
92
+ }, allowSwap);
93
+ return { ...plan, mintPrice, requirements };
94
+ }
95
+ finally {
96
+ (0, context_1.setSignerContext)(context);
97
+ }
98
+ }