apow-cli 0.11.19 → 0.12.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/.env.example CHANGED
@@ -1,23 +1,37 @@
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= # For headless unlock only. Prefer shell/process secret storage.
5
+ # KEYSTORE_PASSWORD_CMD=security find-generic-password -s apow-keystore -w
4
6
  USE_X402=true
5
7
  USE_X402_GRIND=true
6
8
  ALLOW_LOCAL_FALLBACK_WITH_X402=false
7
9
 
10
+ # Wallet Protocol v2
11
+ # APOW_POLICY=enforce # enforce | warn | off
12
+ # APOW_POLICY_PATH=~/.apow/policy.json
13
+ # APOW_PAYOUT_ADDRESS= # cold wallet that receives AGENT sweeps
14
+ # APOW_SWEEP_THRESHOLD_AGENT=25
15
+ # APOW_X402_DAILY_USDC=20
16
+ # APOW_X402_MAX_PER_REQUEST_USDC=1
17
+
8
18
  # === Custom Configuration (override any defaults below) ===
9
19
 
10
20
  # RPC — bring your own endpoint instead of x402
11
21
  # RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY
12
22
  # USE_X402=false
13
23
 
14
- # LLM Provider (clawrouter / openai / anthropic / gemini / deepseek / qwen / ollama / claude-code / codex)
24
+ # LLM Provider
25
+ # x402: clawrouter
26
+ # API key: openai / anthropic / gemini / deepseek / qwen
27
+ # Local inference: ollama
28
+ # Subscription CLI (hosted inference): claude-code / codex
15
29
  # Default: clawrouter when USE_X402=true, openai otherwise
16
30
  # LLM_PROVIDER=clawrouter
17
- # LLM_MODEL=blockrun/eco
31
+ # LLM_MODEL= # optional override; x402 selects automatically
18
32
  # CLAWROUTER_PORT=8402 # only if default port is in use
19
33
 
20
- # API key (not needed for clawrouter, ollama, claude-code, or codex)
34
+ # API key (not used by clawrouter, ollama, claude-code, or codex)
21
35
  # LLM_API_KEY=
22
36
 
23
37
  # Provider-specific keys (alternative to LLM_API_KEY)
@@ -28,6 +42,10 @@ ALLOW_LOCAL_FALLBACK_WITH_X402=false
28
42
  # Ollama (only if LLM_PROVIDER=ollama)
29
43
  # OLLAMA_URL=http://127.0.0.1:11434
30
44
 
45
+ # Subscription CLIs
46
+ # LLM_PROVIDER=claude-code # install/sign in with `claude login`; default model: haiku
47
+ # LLM_PROVIDER=codex # install/sign in with `codex login`; default model: gpt-5.6-luna
48
+
31
49
  # Bridging (only needed for `apow fund`)
32
50
  # SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
33
51
  # 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-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
 
@@ -34,37 +38,29 @@ npx apow-cli
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
+ Mining cannot begin until the dedicated wallet has ETH and USDC on Base. The
42
+ same command handles both phases: it first creates/configures the wallet and
43
+ prints its funding address, then automatically mints and mines when rerun after
44
+ the user funds that address and confirms funding.
39
45
 
40
46
  ```bash
41
- npx apow-cli start
47
+ npx --yes apow-cli@0.12.0 start --easy
42
48
  ```
43
49
 
44
- Easy Mode writes an `.env` equivalent to:
50
+ Relevant Easy Mode settings include:
45
51
 
46
52
  ```bash
47
- PRIVATE_KEY=0x...
53
+ KEYSTORE_PATH=~/.apow/keystores/wallet-0x....json
48
54
  USE_X402=true
49
55
  USE_X402_GRIND=true
50
56
  LLM_PROVIDER=clawrouter
51
- LLM_MODEL=blockrun/eco
52
57
  ALLOW_LOCAL_FALLBACK_WITH_X402=false
53
58
  ```
54
59
 
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.
60
+ The keystore password is prompted interactively. For headless launch services,
61
+ provide `KEYSTORE_PASSWORD` from your shell, process manager, or secret store.
62
+ Never put it in chat or commit it to a project file. See [skill.md](skill.md) for
63
+ the narrow autonomous mining workflow.
68
64
 
69
65
  ## For Humans
70
66
 
@@ -80,35 +76,43 @@ If you want to control each step manually, the older step-by-step flow is still
80
76
 
81
77
  | Command | Description |
82
78
  |---------|-------------|
83
- | `apow start` | Guided happy path: setup -> funding checks -> mint -> mine |
79
+ | `apow start [--easy]` | Existing Easy/Advanced flow: setup -> Base funding check/handoff -> mint -> mine |
84
80
  | `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 |
81
+ | `apow fund` | Interactive bridge/deposit route and ETH+USDC auto-split |
82
+ | `apow wallet new` | Generate a new encrypted mining wallet |
83
+ | `apow wallet list` | List every wallet generated locally by this APoW CLI and mark the active wallet |
84
+ | `apow wallet use [address-or-number]` | Select a generated wallet for the current project (`select` is an alias) |
87
85
  | `apow wallet show` | Show configured wallet address |
88
- | `apow wallet export` | Export your wallet's private key and optional backups |
86
+ | `apow wallet backup` | Show the encrypted keystore backup location; never display wallet secrets |
87
+ | `apow wallet migrate` | Encrypt legacy `PRIVATE_KEY` into a keystore and clear `.env` |
88
+ | `apow wallet payout set <addr>` | Configure a cold payout address for AGENT sweeps |
89
+ | `apow wallet sweep [--all]` | Sweep mined AGENT, and optionally excess ETH/USDC, to payout |
89
90
  | `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 |
91
+ | `apow policy show/init/set mode` | Inspect or change local signing policy |
92
+ | `apow mint` | Confirm and mint a MiningAgent NFT (one per wallet) |
93
+ | `apow mine [tokenId]` | Mine $AGENT continuously (auto-detects best rig) |
94
+ | `apow stats [tokenId]` | View mining stats |
95
+ | `apow dashboard start` | Launch the local APoW-wallet dashboard |
96
+ | `apow dashboard wallets` | List wallets generated locally by this CLI |
96
97
 
97
98
  ## Configuration
98
99
 
99
100
  Create a `.env` file or use `apow setup`:
100
101
 
101
102
  ```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)
103
+ KEYSTORE_PATH=~/.apow/keystores/wallet-0x....json # Preferred: encrypted wallet JSON
104
+ USE_X402=true # Auto-pay RPC + LLM via x402 (2.00 USDC minimum starting balance, no API keys)
104
105
  USE_X402_GRIND=true # Auto-pay remote GPU grinding via x402
105
106
  ALLOW_LOCAL_FALLBACK_WITH_X402=false # Easy Mode default: do not burn local CPU while x402 GPU is active
106
107
  # STALE_CHECK_INTERVAL=5 # Seconds between stale-challenge checks while grinding (default: 5)
107
108
  # 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
109
+ # LLM_PROVIDER=clawrouter # x402: clawrouter | API key: openai/anthropic/gemini/deepseek/qwen | local/subscription CLI: ollama/claude-code/codex
110
+ # LLM_MODEL=... # Optional override; x402 selects automatically
111
+ # LLM_API_KEY=sk-... # Required only for API-key providers
112
+ # KEYSTORE_PASSWORD=... # Headless unlock only; prefer shell/process secret storage over committing to .env
113
+ # KEYSTORE_PASSWORD_CMD=... # Preferred headless unlock command, stdout is used as password
114
+ # APOW_POLICY=enforce # enforce | warn | off
115
+ # APOW_PAYOUT_ADDRESS=0x... # optional cold payout wallet for AGENT sweeps
112
116
  # Bridging (only for `apow fund`)
113
117
  # SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
114
118
  # ETHEREUM_RPC_URL=https://cloudflare-eth.com
@@ -120,23 +124,79 @@ ALLOW_LOCAL_FALLBACK_WITH_X402=false # Easy Mode default: do not burn local CPU
120
124
 
121
125
  See [.env.example](.env.example) for all options.
122
126
 
127
+ ## Wallet Protocol v2
128
+
129
+ Mining requires a hot EOA because the immutable APoW contracts require direct wallet signatures. Wallet Protocol v2 limits that hot wallet's blast radius:
130
+
131
+ - every transaction and x402 typed-data signature goes through a local policy guard;
132
+ - 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);
133
+ - audit and spend ledgers are written under `~/.apow/audit-<address>.jsonl` and `~/.apow/spend-<address>.jsonl`;
134
+ - child grinder and local LLM processes do not receive wallet or keystore-password secrets;
135
+ - generated wallets are written only as encrypted keystores, and wallet commands never print or write a raw-key export;
136
+ - Easy Mode refuses to run if the enforce-mode mint or x402 policy caps were relaxed beyond its defaults;
137
+ - `apow start --easy` selects the existing Easy Mode without adding a second approval or wallet-control system.
138
+
139
+ Useful commands:
140
+
141
+ ```bash
142
+ apow policy show
143
+ apow wallet payout set 0x...
144
+ apow wallet sweep
145
+ apow wallet migrate # convert legacy PRIVATE_KEY to KEYSTORE_PATH
146
+ ```
147
+
148
+ For headless unlocks, prefer a command that prints the password from your OS secret store:
149
+
150
+ ```bash
151
+ KEYSTORE_PASSWORD_CMD="security find-generic-password -s apow-keystore -w"
152
+ ```
153
+
123
154
  ## LLM Providers (for Minting)
124
155
 
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.
156
+ An LLM is required when minting a new Mining Rig NFT because the mint gate uses a
157
+ 20-second SMHL challenge. Easy Mode handles SMHL and mining automatically after
158
+ the user funds the dedicated wallet.
159
+
160
+ Advanced Step 3 groups the choices by payment and execution model:
126
161
 
127
- | Provider | Model | Cost/call | Notes |
128
- |----------|-------|-----------|-------|
129
- | ClawRouter | `blockrun/eco` | ~$0.006 | Recommended. Zero credentials, pays with USDC via x402 |
162
+ 1. **Auto** — Zero Config via x402. The model is selected automatically and each
163
+ request is paid from the mining wallet's Base USDC balance.
164
+ 2. **API key** — OpenAI, Anthropic, Gemini, DeepSeek, or Qwen.
165
+ 3. **Local / subscription CLI** — Ollama runs inference on the user's machine;
166
+ Claude Code and Codex run local command-line clients but use hosted models and
167
+ the user's existing subscription allowance.
168
+
169
+ | Provider | Default model | Billing | Notes |
170
+ |----------|---------------|---------|-------|
171
+ | Auto via x402 | Automatic | Wallet-paid USDC | Zero Config; no API key or model selection required |
130
172
  | OpenAI | `gpt-4o-mini` | ~$0.001 | Cheapest API key option, fast |
131
173
  | Gemini | `gemini-2.5-flash` | ~$0.001 | Fast, good accuracy |
132
174
  | DeepSeek | `deepseek-chat` | ~$0.001 | Fast, accessible in China |
133
175
  | Qwen | `qwen-plus` | ~$0.002 | Alibaba Cloud |
134
176
  | Anthropic | `claude-sonnet-4-5-20250929` | ~$0.005 | Works but slower |
135
- | Ollama | `llama3.1` | Free | Local GPU required |
177
+ | Ollama | `llama3.1` | Local compute | Truly local inference; Ollama must be running with the model installed |
178
+ | Claude Code | `haiku` | Claude subscription allowance | Hosted inference through an installed, signed-in CLI |
179
+ | Codex | `gpt-5.6-luna` | ChatGPT subscription allowance | Hosted inference through an installed, signed-in CLI |
180
+
181
+ Prepare one of the local/subscription choices before minting:
182
+
183
+ ```bash
184
+ ollama pull llama3.1 # Ollama only; keep the Ollama service running
185
+ claude login # Claude Code; sign in with the intended Claude subscription
186
+ codex login # Codex; choose ChatGPT subscription access
187
+ ```
188
+
189
+ APoW disables Claude Code tools and session persistence. It runs Codex from an
190
+ isolated temporary directory in ephemeral, read-only mode. Both child processes
191
+ receive a strict environment allowlist rather than wallet secrets or API-billing
192
+ keys. Both subscription adapters passed off-chain SMHL command tests; neither is
193
+ yet recorded as a completed APoW mainnet mint.
136
194
 
137
195
  ## Funding (v0.7.0+)
138
196
 
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:
197
+ Mining requires two assets on Base: **ETH** (gas) and **USDC** (x402 RPC).
198
+ `apow start` checks both and gives a Base funding handoff without moving funds.
199
+ The separate `fund` command provides an interactive bridge or auto-split flow:
140
200
 
141
201
  ```bash
142
202
  # From Solana (deposit address — send from any wallet, QR code included)
@@ -212,43 +272,31 @@ The CUDA grinder runs over SSH alongside your local Metal/CPU grinders — genui
212
272
 
213
273
  ### Other Optimizations
214
274
 
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
275
  - **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
276
  - **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
277
 
219
278
  ## Dashboard
220
279
 
221
- Monitor your entire mining fleet from a single web UI. Zero external dependencies -- vanilla HTML/JS served by the CLI.
280
+ 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
281
 
223
282
  ```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
283
+ # Quick start: generate an encrypted wallet and launch
284
+ apow wallet new
285
+ apow dashboard start # open http://localhost:3847
227
286
  ```
228
287
 
229
288
  ### Commands
230
289
 
231
290
  | Command | Description |
232
291
  |---------|-------------|
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
- ```
292
+ | `apow dashboard start` | Launch dashboard web UI |
293
+ | `apow dashboard wallets` | List wallets generated locally by this CLI |
294
+
295
+ ### Wallet Scope
296
+
297
+ `~/.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
298
 
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`).
299
+ 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
300
 
253
301
  ## Protocol
254
302
 
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderBrandLogo = renderBrandLogo;
4
+ exports.renderStartWelcome = renderStartWelcome;
5
+ exports.showBrandIntro = showBrandIntro;
6
+ const node_process_1 = require("node:process");
7
+ const BASE_BLUE = [0, 82, 255];
8
+ const WHITE = [255, 255, 255];
9
+ /**
10
+ * Generated from the canonical 512x512 logo.png with:
11
+ * jp2a --colors --color-depth=24 --background=light --size=40x20 --chars='##'
12
+ *
13
+ * The circular edge was normalized after conversion to remove asymmetric
14
+ * transparency sampling at the bottom of the source PNG.
15
+ *
16
+ * # = Base-blue circle
17
+ * @ = white APoW mark
18
+ */
19
+ const FULL_LOGO = [
20
+ "############",
21
+ "######################",
22
+ "##########################",
23
+ "##############################",
24
+ "################@@################",
25
+ "################@@@@################",
26
+ "################@@@@@@################",
27
+ "###############@@@##@@@###############",
28
+ "###############@@@####@@@###############",
29
+ "###########@@@@@@@@@@@@@@@@@@###########",
30
+ "#############@@@########@@@#############",
31
+ "#########@@@@@@@@@@@@@@@@@@@@@@#########",
32
+ "##########@@@############@@@##########",
33
+ "#########@@@##############@@@#########",
34
+ "####################################",
35
+ "##################################",
36
+ "##############################",
37
+ "##########################",
38
+ "######################",
39
+ "############",
40
+ ];
41
+ const COMPACT_LOGO = [
42
+ "############",
43
+ "##################",
44
+ "########################",
45
+ "##########################",
46
+ "#############@@#############",
47
+ "#############@@@@#############",
48
+ "#############@@##@@#############",
49
+ "#########@@@@@@@@@@@@@@#########",
50
+ "##########@@@######@@@##########",
51
+ "#######@@@@@@@@@@@@@@@@@@#######",
52
+ "#######@@############@@#######",
53
+ "############################",
54
+ "##########################",
55
+ "########################",
56
+ "##################",
57
+ "############",
58
+ ];
59
+ const MICRO_LOGO = [
60
+ "##########",
61
+ "################",
62
+ "####################",
63
+ "##########@@##########",
64
+ "##########@##@##########",
65
+ "#######@@@@@@@@@@#######",
66
+ "########@@####@@########",
67
+ "######@@@@@@@@@@@@######",
68
+ "######################",
69
+ "####################",
70
+ "################",
71
+ "##########",
72
+ ];
73
+ function startWelcomeLines(columns) {
74
+ const startFlow = columns >= 47
75
+ ? [
76
+ "1 Choose Easy or Advanced Mode",
77
+ "2 Fund the displayed Base wallet when prompted",
78
+ "3 Rerun apow start to mint your rig and mine",
79
+ ]
80
+ : [
81
+ "1 Choose Easy or Advanced",
82
+ "2 Fund the Base wallet",
83
+ "3 Rerun apow start to mine",
84
+ ];
85
+ const docsLink = columns >= 27
86
+ ? "Docs: https://apow.io/docs/"
87
+ : "Docs: apow.io/docs";
88
+ const skillLink = columns >= 54
89
+ ? "Skill: https://clawhub.ai/agentoshi/skills/apow-mining"
90
+ : columns >= 46
91
+ ? "Skill: clawhub.ai/agentoshi/skills/apow-mining"
92
+ : "Skill: ClawHub agentoshi/apow-mining";
93
+ return [
94
+ "WELCOME TO THE APoW CLI",
95
+ "Agentic Proof of Work on Base",
96
+ "",
97
+ "START FLOW",
98
+ ...startFlow,
99
+ "",
100
+ docsLink,
101
+ skillLink,
102
+ ];
103
+ }
104
+ function ansi(text, rgb, enabled) {
105
+ if (!enabled || !text)
106
+ return text;
107
+ return `\x1b[38;2;${rgb[0]};${rgb[1]};${rgb[2]}m${text}\x1b[39m`;
108
+ }
109
+ function renderMaskLine(line, color) {
110
+ if (!color)
111
+ return line;
112
+ return (line.match(/#+|@+| +/g) ?? [])
113
+ .map((run) => {
114
+ if (run[0] === "#")
115
+ return ansi(run, BASE_BLUE, true);
116
+ if (run[0] === "@")
117
+ return ansi(run, WHITE, true);
118
+ return run;
119
+ })
120
+ .join("");
121
+ }
122
+ function maskWidth(mask) {
123
+ return Math.max(...mask.map((line) => line.length));
124
+ }
125
+ function renderBrandLogo(options = {}) {
126
+ const columns = options.columns ?? 48;
127
+ const mask = columns >= 40 ? FULL_LOGO : columns >= 32 ? COMPACT_LOGO : MICRO_LOGO;
128
+ const width = maskWidth(mask);
129
+ const canvasWidth = Math.max(width, columns);
130
+ return mask.map((line) => {
131
+ const leftPadding = " ".repeat(Math.max(0, Math.floor((canvasWidth - line.length) / 2)));
132
+ return leftPadding + renderMaskLine(line, options.color === true);
133
+ });
134
+ }
135
+ function renderStartWelcome(options = {}) {
136
+ const columns = options.columns ?? 48;
137
+ const lines = startWelcomeLines(columns);
138
+ const width = Math.max(...lines.map((line) => line.length));
139
+ const leftPadding = " ".repeat(Math.max(0, Math.floor((columns - width) / 2)));
140
+ return lines.map((line, index) => {
141
+ if (!line)
142
+ return "";
143
+ if (index <= 1) {
144
+ const centered = " ".repeat(Math.max(0, Math.floor((columns - line.length) / 2))) + line;
145
+ return index === 0 ? ansi(centered, BASE_BLUE, options.color === true) : centered;
146
+ }
147
+ return leftPadding + line;
148
+ });
149
+ }
150
+ async function showBrandIntro(sequence, options = {}) {
151
+ const output = options.output ?? node_process_1.stdout;
152
+ const color = options.color
153
+ ?? (output.isTTY === true && !process.env.NO_COLOR && process.env.TERM !== "dumb");
154
+ const lines = renderBrandLogo({ color, columns: output.columns });
155
+ const sections = [lines.join("\n")];
156
+ if (sequence === "start") {
157
+ sections.push(renderStartWelcome({ color, columns: output.columns }).join("\n"));
158
+ }
159
+ output.write(`\n${sections.join("\n\n")}\n\n`);
160
+ }
@@ -1,39 +1,5 @@
1
1
  "use strict";
2
2
  // Solana balance utilities for deposit detection.
3
- // Uses dynamic import() for @solana/web3.js to avoid bloating startup.
4
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
- if (k2 === undefined) k2 = k;
6
- var desc = Object.getOwnPropertyDescriptor(m, k);
7
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
- desc = { enumerable: true, get: function() { return m[k]; } };
9
- }
10
- Object.defineProperty(o, k2, desc);
11
- }) : (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- o[k2] = m[k];
14
- }));
15
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
- Object.defineProperty(o, "default", { enumerable: true, value: v });
17
- }) : function(o, v) {
18
- o["default"] = v;
19
- });
20
- var __importStar = (this && this.__importStar) || (function () {
21
- var ownKeys = function(o) {
22
- ownKeys = Object.getOwnPropertyNames || function (o) {
23
- var ar = [];
24
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
- return ar;
26
- };
27
- return ownKeys(o);
28
- };
29
- return function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
36
- })();
37
3
  Object.defineProperty(exports, "__esModule", { value: true });
38
4
  exports.getSolanaRpcUrl = getSolanaRpcUrl;
39
5
  exports.getAddressBalance = getAddressBalance;
@@ -42,22 +8,38 @@ const DEFAULT_SOLANA_RPC = "https://api.mainnet-beta.solana.com";
42
8
  function getSolanaRpcUrl() {
43
9
  return process.env.SOLANA_RPC_URL || DEFAULT_SOLANA_RPC;
44
10
  }
11
+ async function solanaRpc(method, params) {
12
+ const response = await fetch(getSolanaRpcUrl(), {
13
+ method: "POST",
14
+ headers: { "Content-Type": "application/json" },
15
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
16
+ });
17
+ if (!response.ok) {
18
+ throw new Error(`Solana RPC ${method} failed (${response.status})`);
19
+ }
20
+ const body = (await response.json());
21
+ if (body.error || body.result === undefined) {
22
+ const message = body.error?.message || "missing result";
23
+ throw new Error(`Solana RPC ${method} failed: ${message}`);
24
+ }
25
+ return body.result;
26
+ }
45
27
  /** Get SOL balance for any address (used to detect deposits). */
46
28
  async function getAddressBalance(address) {
47
- const { Connection, PublicKey } = await Promise.resolve().then(() => __importStar(require("@solana/web3.js")));
48
- const connection = new Connection(getSolanaRpcUrl(), "confirmed");
49
- const lamports = await connection.getBalance(new PublicKey(address));
50
- return lamports / 1e9;
29
+ const result = await solanaRpc("getBalance", [
30
+ address,
31
+ { commitment: "confirmed" },
32
+ ]);
33
+ return result.value / 1e9;
51
34
  }
52
35
  /** Get SPL token balance (e.g., USDC) for a Solana public key. Returns UI amount (not raw). */
53
36
  async function getSplTokenBalance(publicKeyBase58, mintAddress) {
54
- const { Connection, PublicKey } = await Promise.resolve().then(() => __importStar(require("@solana/web3.js")));
55
- const connection = new Connection(getSolanaRpcUrl(), "confirmed");
56
- const owner = new PublicKey(publicKeyBase58);
57
- const mint = new PublicKey(mintAddress);
58
- const accounts = await connection.getParsedTokenAccountsByOwner(owner, { mint });
37
+ const accounts = await solanaRpc("getTokenAccountsByOwner", [
38
+ publicKeyBase58,
39
+ { mint: mintAddress },
40
+ { encoding: "jsonParsed", commitment: "confirmed" },
41
+ ]);
59
42
  if (accounts.value.length === 0)
60
43
  return 0;
61
- const parsed = accounts.value[0].account.data.parsed;
62
- return parsed?.info?.tokenAmount?.uiAmount ?? 0;
44
+ return accounts.value[0].account.data.parsed?.info?.tokenAmount?.uiAmount ?? 0;
63
45
  }