apow-cli 0.9.2 → 0.9.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.
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ /**
3
+ * HTTP x402 nonce grinder — pay-per-grind GPU mining via GrindProxy.
4
+ *
5
+ * Sends {challenge, target, address} to a remote GPU endpoint (default:
6
+ * grind.apow.io). Payment ($0.01 USDC) is handled automatically via the
7
+ * x402 protocol — the server returns 402, the client signs a USDC
8
+ * authorization and retries. No accounts, no API keys.
9
+ *
10
+ * Front-running is cryptographically impossible: nonces are bound to
11
+ * keccak256(challenge, msg.sender, nonce) — a nonce ground for address A
12
+ * is useless for address B.
13
+ */
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
27
+ }) : function(o, v) {
28
+ o["default"] = v;
29
+ });
30
+ var __importStar = (this && this.__importStar) || (function () {
31
+ var ownKeys = function(o) {
32
+ ownKeys = Object.getOwnPropertyNames || function (o) {
33
+ var ar = [];
34
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
35
+ return ar;
36
+ };
37
+ return ownKeys(o);
38
+ };
39
+ return function (mod) {
40
+ if (mod && mod.__esModule) return mod;
41
+ var result = {};
42
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
43
+ __setModuleDefault(result, mod);
44
+ return result;
45
+ };
46
+ })();
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.isHttpGrinderConfigured = isHttpGrinderConfigured;
49
+ exports.getGrindUrl = getGrindUrl;
50
+ exports.grindNonceHttp = grindNonceHttp;
51
+ const config_1 = require("./config");
52
+ const DEFAULT_GRIND_URL = "https://grind.apow.io/grind";
53
+ // Lazy singleton — created on first grind, reused across calls
54
+ let _fetchWithPayment = null;
55
+ async function getPaymentFetch(privateKey) {
56
+ if (_fetchWithPayment)
57
+ return _fetchWithPayment;
58
+ const { privateKeyToAccount } = await Promise.resolve().then(() => __importStar(require("viem/accounts")));
59
+ const { x402Client, wrapFetchWithPayment } = await Promise.resolve().then(() => __importStar(require("@x402/fetch")));
60
+ const { registerExactEvmScheme } = await Promise.resolve().then(() => __importStar(require("@x402/evm/exact/client")));
61
+ const signer = privateKeyToAccount(privateKey);
62
+ const client = new x402Client();
63
+ registerExactEvmScheme(client, { signer });
64
+ _fetchWithPayment = wrapFetchWithPayment(fetch, client);
65
+ return _fetchWithPayment;
66
+ }
67
+ function isHttpGrinderConfigured() {
68
+ return config_1.config.useX402Grind && !!config_1.config.privateKey;
69
+ }
70
+ function getGrindUrl() {
71
+ return config_1.config.grindUrl ?? DEFAULT_GRIND_URL;
72
+ }
73
+ async function grindNonceHttp(challengeNumber, target, minerAddress, grindUrl, privateKey, signal) {
74
+ const paidFetch = await getPaymentFetch(privateKey);
75
+ const start = process.hrtime();
76
+ const response = await paidFetch(grindUrl, {
77
+ method: "POST",
78
+ headers: { "Content-Type": "application/json" },
79
+ body: JSON.stringify({
80
+ challenge: challengeNumber,
81
+ target: target.toString(),
82
+ address: minerAddress,
83
+ }),
84
+ signal,
85
+ });
86
+ if (!response.ok) {
87
+ const body = await response.text().catch(() => "");
88
+ if (response.status === 402) {
89
+ throw new Error("x402 GPU grind payment failed — insufficient USDC on Base");
90
+ }
91
+ if (response.status === 504) {
92
+ throw new Error("Remote GPU grind timed out (90s)");
93
+ }
94
+ throw new Error(`GrindProxy HTTP ${response.status}: ${body.slice(0, 200)}`);
95
+ }
96
+ const data = (await response.json());
97
+ if (!data.nonce) {
98
+ throw new Error("GrindProxy returned no nonce");
99
+ }
100
+ const [s, ns] = process.hrtime(start);
101
+ const totalElapsed = s + ns / 1_000_000_000;
102
+ return {
103
+ nonce: BigInt(data.nonce),
104
+ attempts: 0n, // remote — unknown
105
+ elapsed: data.elapsed ?? totalElapsed,
106
+ hashrate: 0, // remote — unknown
107
+ };
108
+ }
@@ -42,6 +42,7 @@ function detectGrinders() {
42
42
  cuda: detectLocalCuda(),
43
43
  cpu: detectLocalCpu(),
44
44
  remoteGpu: !!(config_1.config.vastIp && config_1.config.vastPort),
45
+ httpGrind: config_1.config.useX402Grind && !!config_1.config.privateKey,
45
46
  };
46
47
  }
47
48
  function detectLocalGpu() {
@@ -95,7 +96,7 @@ function detectLocalCpu() {
95
96
  return null;
96
97
  }
97
98
  function hasNativeGrinders(info) {
98
- return !!(info.gpu || info.cuda || info.cpu || info.remoteGpu);
99
+ return !!(info.gpu || info.cuda || info.cpu || info.remoteGpu || info.httpGrind);
99
100
  }
100
101
  function grinderLabel(info) {
101
102
  const parts = [];
@@ -183,7 +184,8 @@ async function grindNonceNative(challengeNumber, target, minerAddress, info, sig
183
184
  // Local Metal GPU
184
185
  if (info.gpu) {
185
186
  totalGrinders++;
186
- const proc = (0, node_child_process_1.spawn)(info.gpu, [challengeNumber, minerAddress, targetHex]);
187
+ // Set CWD to binary's directory so Metal grinder finds keccak.metal shader
188
+ const proc = (0, node_child_process_1.spawn)(info.gpu, [challengeNumber, minerAddress, targetHex], { cwd: (0, node_path_1.dirname)(info.gpu) });
187
189
  processes.push(proc);
188
190
  let stdout = "";
189
191
  proc.stdout.on("data", (d) => { stdout += d.toString(); });
package/dist/index.js CHANGED
@@ -119,9 +119,21 @@ async function setupWizard() {
119
119
  console.log("");
120
120
  ui.banner(["AgentCoin Miner Setup"]);
121
121
  console.log("");
122
+ // Mode selection
123
+ console.log(` ${ui.bold("How do you want to configure?")}`);
124
+ console.log("");
125
+ console.log(` ${ui.cyan("1.")} Quick Start ${ui.dim("(recommended)")}`);
126
+ console.log(` ${ui.dim("Zero credentials. Pays for RPC + LLM with USDC from your wallet.")}`);
127
+ console.log(` ${ui.cyan("2.")} Custom`);
128
+ console.log(` ${ui.dim("Bring your own RPC endpoint and/or LLM API key.")}`);
129
+ console.log("");
130
+ const modeInput = await ui.prompt("Choice", "1");
131
+ const quickStart = modeInput !== "2";
132
+ console.log("");
133
+ const totalSteps = quickStart ? 2 : 3;
122
134
  const values = {};
123
135
  // Step 1: Wallet
124
- console.log(` ${ui.bold("Step 1/3: Wallet")}`);
136
+ console.log(` ${ui.bold(`Step 1/${totalSteps}: Wallet`)}`);
125
137
  const hasWallet = await ui.confirm("Do you have a Base wallet?");
126
138
  let privateKey;
127
139
  let addr;
@@ -168,72 +180,85 @@ async function setupWizard() {
168
180
  values.PRIVATE_KEY = privateKey;
169
181
  ui.ok(`Wallet: ${addr.slice(0, 6)}...${addr.slice(-4)}`);
170
182
  console.log("");
171
- // Step 2: RPC
172
- console.log(` ${ui.bold("Step 2/3: RPC")}`);
173
- console.log(` ${ui.dim("You need a Base RPC endpoint. Two options:")}`);
174
- console.log(` ${ui.dim(" 1. Bring your own (free from Alchemy, QuickNode, etc.)")}`);
175
- console.log(` ${ui.dim(" 2. Auto-pay via QuickNode x402 ($10 USDC for ~1M calls)")}`);
176
- const hasRpc = await ui.confirm("Do you have a Base RPC URL?");
177
- if (hasRpc) {
178
- const rpcUrl = await ui.prompt("RPC URL");
179
- if (rpcUrl) {
180
- values.RPC_URL = rpcUrl;
181
- ui.ok(`RPC: Custom (${rpcUrl.slice(0, 40)}${rpcUrl.length > 40 ? "..." : ""})`);
183
+ if (quickStart) {
184
+ // Quick Start: auto-configure x402 + clawrouter
185
+ console.log(` ${ui.bold(`Step 2/${totalSteps}: Configuration`)}`);
186
+ values.USE_X402 = "true";
187
+ values.LLM_PROVIDER = "clawrouter";
188
+ values.LLM_MODEL = "blockrun/eco";
189
+ ui.ok("RPC: QuickNode x402 (auto-pay with USDC, no API key)");
190
+ ui.ok("LLM: ClawRouter x402 (auto-pay with USDC, no API key)");
191
+ console.log(` ${ui.dim("Both services charge USDC from your mining wallet. ~$10 covers ~1M calls.")}`);
192
+ }
193
+ else {
194
+ // Custom: existing 3-step flow
195
+ // Step 2: RPC
196
+ console.log(` ${ui.bold(`Step 2/${totalSteps}: RPC`)}`);
197
+ console.log(` ${ui.dim("You need a Base RPC endpoint. Two options:")}`);
198
+ console.log(` ${ui.dim(" 1. Bring your own (free from Alchemy, QuickNode, etc.)")}`);
199
+ console.log(` ${ui.dim(" 2. Auto-pay via QuickNode x402 ($10 USDC for ~1M calls)")}`);
200
+ const hasRpc = await ui.confirm("Do you have a Base RPC URL?");
201
+ if (hasRpc) {
202
+ const rpcUrl = await ui.prompt("RPC URL");
203
+ if (rpcUrl) {
204
+ values.RPC_URL = rpcUrl;
205
+ ui.ok(`RPC: Custom (${rpcUrl.slice(0, 40)}${rpcUrl.length > 40 ? "..." : ""})`);
206
+ }
207
+ else {
208
+ ui.warn("No URL provided — using QuickNode x402");
209
+ values.USE_X402 = "true";
210
+ ui.ok("RPC: QuickNode x402 ($10 USDC for ~1M calls)");
211
+ }
182
212
  }
183
213
  else {
184
- ui.warn("No URL provided — using QuickNode x402");
185
214
  values.USE_X402 = "true";
215
+ console.log(` ${ui.dim("QuickNode x402 will charge $10 USDC from your mining wallet")}`);
216
+ console.log(` ${ui.dim("for ~1M RPC calls. No API key or account needed.")}`);
186
217
  ui.ok("RPC: QuickNode x402 ($10 USDC for ~1M calls)");
187
218
  }
188
- }
189
- else {
190
- values.USE_X402 = "true";
191
- console.log(` ${ui.dim("QuickNode x402 will charge $10 USDC from your mining wallet")}`);
192
- console.log(` ${ui.dim("for ~1M RPC calls. No API key or account needed.")}`);
193
- ui.ok("RPC: QuickNode x402 ($10 USDC for ~1M calls)");
194
- }
195
- console.log("");
196
- // Step 3: LLM (for minting)
197
- console.log(` ${ui.bold("Step 3/3: LLM Provider (for minting)")}`);
198
- console.log(` ${ui.dim("An LLM solves the SMHL challenge when minting your Mining Rig.")}`);
199
- console.log(` ${ui.dim("Mining uses optimized solving — no LLM needed after minting.")}`);
200
- console.log(` ${ui.dim(" clawrouter (recommended) — Zero credentials. Pays with USDC from your wallet.")}`);
201
- console.log(` ${ui.dim(" openai / anthropic / gemini / deepseek / qwen — Requires API key.")}`);
202
- console.log(` ${ui.dim(" ollama / claude-code / codex — Local, no API key.")}`);
203
- const providerInput = await ui.prompt("Provider", "clawrouter");
204
- const provider = (["clawrouter", "openai", "anthropic", "gemini", "ollama", "deepseek", "qwen", "claude-code", "codex"].includes(providerInput) ? providerInput : "clawrouter");
205
- values.LLM_PROVIDER = provider;
206
- if (provider === "clawrouter") {
207
- ui.ok("ClawRouter x402 — no API key needed, pays with USDC from your wallet");
208
- if (!values.USE_X402 && !values.RPC_URL) {
209
- values.USE_X402 = "true";
210
- ui.ok("Auto-enabled x402 RPC (same wallet, same USDC balance)");
219
+ console.log("");
220
+ // Step 3: LLM (for minting)
221
+ console.log(` ${ui.bold(`Step 3/${totalSteps}: LLM Provider (for minting)`)}`);
222
+ console.log(` ${ui.dim("An LLM solves the SMHL challenge when minting your Mining Rig.")}`);
223
+ console.log(` ${ui.dim("Mining uses optimized solving — no LLM needed after minting.")}`);
224
+ console.log(` ${ui.dim(" clawrouter (recommended) — Zero credentials. Pays with USDC from your wallet.")}`);
225
+ console.log(` ${ui.dim(" openai / anthropic / gemini / deepseek / qwen — Requires API key.")}`);
226
+ console.log(` ${ui.dim(" ollama / claude-code / codex — Local, no API key.")}`);
227
+ const providerInput = await ui.prompt("Provider", "clawrouter");
228
+ const provider = (["clawrouter", "openai", "anthropic", "gemini", "ollama", "deepseek", "qwen", "claude-code", "codex"].includes(providerInput) ? providerInput : "clawrouter");
229
+ values.LLM_PROVIDER = provider;
230
+ if (provider === "clawrouter") {
231
+ ui.ok("ClawRouter x402 — no API key needed, pays with USDC from your wallet");
232
+ if (!values.USE_X402 && !values.RPC_URL) {
233
+ values.USE_X402 = "true";
234
+ ui.ok("Auto-enabled x402 RPC (same wallet, same USDC balance)");
235
+ }
211
236
  }
212
- }
213
- else if (provider === "ollama") {
214
- const ollamaUrl = await ui.prompt("Ollama URL", "http://127.0.0.1:11434");
215
- values.OLLAMA_URL = ollamaUrl;
216
- ui.ok(`Ollama at ${ollamaUrl}`);
217
- }
218
- else if (provider === "claude-code" || provider === "codex") {
219
- ui.ok(`Using local ${provider} CLI — no API key needed`);
220
- }
221
- else {
222
- const apiKey = await ui.promptSecret("API key");
223
- if (apiKey) {
224
- values.LLM_API_KEY = apiKey;
225
- ui.ok(`${provider} key set`);
237
+ else if (provider === "ollama") {
238
+ const ollamaUrl = await ui.prompt("Ollama URL", "http://127.0.0.1:11434");
239
+ values.OLLAMA_URL = ollamaUrl;
240
+ ui.ok(`Ollama at ${ollamaUrl}`);
241
+ }
242
+ else if (provider === "claude-code" || provider === "codex") {
243
+ ui.ok(`Using local ${provider} CLI — no API key needed`);
226
244
  }
227
245
  else {
228
- ui.fail("No API key provided");
229
- ui.hint(`Set LLM_API_KEY in .env later`);
246
+ const apiKey = await ui.promptSecret("API key");
247
+ if (apiKey) {
248
+ values.LLM_API_KEY = apiKey;
249
+ ui.ok(`${provider} key set`);
250
+ }
251
+ else {
252
+ ui.fail("No API key provided");
253
+ ui.hint(`Set LLM_API_KEY in .env later`);
254
+ }
255
+ }
256
+ const defaultModel = (0, config_1.resolveDefaultModel)(provider);
257
+ const model = await ui.prompt("Model", defaultModel);
258
+ values.LLM_MODEL = model;
259
+ if ((0, config_1.isExpensiveModel)(model)) {
260
+ ui.warn(`${model} is expensive. Consider gpt-4o-mini for lower cost.`);
230
261
  }
231
- }
232
- const defaultModel = provider === "clawrouter" ? "blockrun/eco" : provider === "gemini" ? "gemini-2.5-flash" : provider === "anthropic" ? "claude-sonnet-4-5-20250929" : provider === "deepseek" ? "deepseek-chat" : provider === "qwen" ? "qwen-plus" : provider === "claude-code" || provider === "codex" ? "default" : "gpt-4o-mini";
233
- const model = await ui.prompt("Model", defaultModel);
234
- values.LLM_MODEL = model;
235
- if ((0, config_1.isExpensiveModel)(model)) {
236
- ui.warn(`${model} is expensive. Consider gpt-4o-mini for lower cost.`);
237
262
  }
238
263
  // Contract addresses
239
264
  values.MINING_AGENT_ADDRESS = config_1.config.miningAgentAddress ?? "";
@@ -294,8 +319,8 @@ async function main() {
294
319
  });
295
320
  program
296
321
  .command("fund")
297
- .description("Fund your wallet — bridge from Solana or send on Base")
298
- .option("--chain <chain>", "Source chain: solana, base")
322
+ .description("Fund your wallet — bridge from Solana/Ethereum or send on Base")
323
+ .option("--chain <chain>", "Source chain: solana, ethereum, base")
299
324
  .option("--token <token>", "Source token: sol, usdc, eth")
300
325
  .option("--amount <eth>", "Target ETH amount (default: 0.005)")
301
326
  .option("--no-swap", "Skip auto-split after bridging")
package/dist/miner.js CHANGED
@@ -45,6 +45,7 @@ const detect_1 = require("./detect");
45
45
  const errors_1 = require("./errors");
46
46
  const explorer_1 = require("./explorer");
47
47
  const grinder_1 = require("./grinder");
48
+ const grinder_http_1 = require("./grinder-http");
48
49
  const grinder_native_1 = require("./grinder-native");
49
50
  const smhl_1 = require("./smhl");
50
51
  const ui = __importStar(require("./ui"));
@@ -175,9 +176,25 @@ async function startMining(tokenId) {
175
176
  // Detect native grinders once at startup
176
177
  const grinderInfo = (0, grinder_native_1.detectGrinders)();
177
178
  const useNative = config_1.config.grinderMode !== "js" && (0, grinder_native_1.hasNativeGrinders)(grinderInfo);
178
- const modeLabel = useNative ? (0, grinder_native_1.grinderLabel)(grinderInfo) : `JS (${config_1.config.minerThreads} threads)`;
179
+ const useHttpGrind = (0, grinder_http_1.isHttpGrinderConfigured)();
180
+ const grindUrl = (0, grinder_http_1.getGrindUrl)();
181
+ // Build grinder label
182
+ const labelParts = [];
183
+ if (useNative)
184
+ labelParts.push((0, grinder_native_1.grinderLabel)(grinderInfo));
185
+ if (useHttpGrind) {
186
+ const host = new URL(grindUrl).hostname;
187
+ labelParts.push(`x402 GPU (${host})`);
188
+ }
189
+ if (labelParts.length === 0)
190
+ labelParts.push(`JS (${config_1.config.minerThreads} threads)`);
191
+ const modeLabel = labelParts.join(" + ");
179
192
  await showStartupBanner(tokenId);
180
193
  console.log(` Grinder: ${ui.bold(modeLabel)}`);
194
+ // Hint for JS-only miners without x402 grind
195
+ if (!useNative && !useHttpGrind) {
196
+ console.log(` ${ui.dim("Tip: Add USE_X402_GRIND=true for 10-100x faster mining ($0.01/grind).")}`);
197
+ }
181
198
  console.log("");
182
199
  while (true) {
183
200
  try {
@@ -277,36 +294,38 @@ async function startMining(tokenId) {
277
294
  }
278
295
  }, STALE_CHECK_INTERVAL_MS);
279
296
  try {
297
+ // Race all available grinders — first valid nonce wins
298
+ const grinders = [];
280
299
  if (useNative) {
281
- try {
282
- grind = await (0, grinder_native_1.grindNonceNative)(challengeNumber, target, account.address, grinderInfo, abortController.signal);
283
- }
284
- catch (err) {
300
+ grinders.push((0, grinder_native_1.grindNonceNative)(challengeNumber, target, account.address, grinderInfo, abortController.signal)
301
+ .catch((err) => {
285
302
  if (abortController.signal.aborted)
286
- throw err; // re-throw abort
287
- nonceSpinner.update("Native grinder failed — falling back to JS...");
288
- grind = await (0, grinder_1.grindNonceParallel)({
289
- challengeNumber,
290
- target,
291
- minerAddress: account.address,
292
- threads: config_1.config.minerThreads,
293
- signal: abortController.signal,
294
- });
295
- }
303
+ throw err;
304
+ // Native failed but don't abort the race — others may still win
305
+ return new Promise(() => { }); // hang forever (race will resolve via another grinder)
306
+ }));
296
307
  }
297
- else {
298
- grind = await (0, grinder_1.grindNonceParallel)({
299
- challengeNumber,
300
- target,
301
- minerAddress: account.address,
302
- threads: config_1.config.minerThreads,
303
- signal: abortController.signal,
304
- onProgress: (attempts, hashrate) => {
305
- const khs = (hashrate / 1000).toFixed(0);
306
- nonceSpinner.update(`Grinding nonce (JS)... ${khs}k H/s (${attempts.toLocaleString()} attempts)`);
307
- },
308
- });
308
+ if (useHttpGrind) {
309
+ grinders.push((0, grinder_http_1.grindNonceHttp)(challengeNumber, target, account.address, grindUrl, config_1.config.privateKey, abortController.signal)
310
+ .catch((err) => {
311
+ if (abortController.signal.aborted)
312
+ throw err;
313
+ return new Promise(() => { });
314
+ }));
309
315
  }
316
+ // JS fallback always runs (it's the baseline)
317
+ grinders.push((0, grinder_1.grindNonceParallel)({
318
+ challengeNumber,
319
+ target,
320
+ minerAddress: account.address,
321
+ threads: config_1.config.minerThreads,
322
+ signal: abortController.signal,
323
+ onProgress: !useNative && !useHttpGrind ? (attempts, hashrate) => {
324
+ const khs = (hashrate / 1000).toFixed(0);
325
+ nonceSpinner.update(`Grinding nonce (JS)... ${khs}k H/s (${attempts.toLocaleString()} attempts)`);
326
+ } : undefined,
327
+ }));
328
+ grind = await Promise.race(grinders);
310
329
  clearInterval(staleTimer);
311
330
  const khs = grind.hashrate > 0 ? (grind.hashrate / 1000).toFixed(0) : "?";
312
331
  nonceSpinner.stop(`Nonce found (${grind.elapsed.toFixed(1)}s${grind.hashrate > 0 ? `, ${khs}k H/s` : ""})`);
package/dist/preflight.js CHANGED
@@ -41,6 +41,7 @@ const viem_1 = require("viem");
41
41
  const chains_1 = require("viem/chains");
42
42
  const AgentCoin_json_1 = __importDefault(require("./abi/AgentCoin.json"));
43
43
  const config_1 = require("./config");
44
+ const grinder_http_1 = require("./grinder-http");
44
45
  const wallet_1 = require("./wallet");
45
46
  const ui = __importStar(require("./ui"));
46
47
  const agentCoinAbi = AgentCoin_json_1.default;
@@ -74,7 +75,7 @@ async function runPreflight(level) {
74
75
  results.push({
75
76
  label: "No RPC configured",
76
77
  passed: false,
77
- fix: "Run `apow setup` to configure RPC, or set RPC_URL or USE_X402=true in .env",
78
+ fix: "Set USE_X402=true in .env (auto-pay with USDC), or set RPC_URL to a Base endpoint, or run `apow setup`",
78
79
  });
79
80
  }
80
81
  // Check x402: USDC balance BEFORE RPC check (can't use x402 without USDC)
@@ -212,7 +213,7 @@ async function runPreflight(level) {
212
213
  results.push({
213
214
  label: `LLM API key not set for ${config_1.config.llmProvider}`,
214
215
  passed: false,
215
- fix: "Set LLM_API_KEY (or OPENAI_API_KEY / ANTHROPIC_API_KEY / GEMINI_API_KEY) in .env, or run `apow setup`",
216
+ fix: "Set LLM_API_KEY in .env, or switch to LLM_PROVIDER=clawrouter (zero credentials, pays with USDC)",
216
217
  });
217
218
  }
218
219
  }
@@ -244,6 +245,30 @@ async function runPreflight(level) {
244
245
  catch {
245
246
  // Skip if contract addresses not configured (already caught above)
246
247
  }
248
+ // Check: GrindProxy reachability (mining only, non-blocking)
249
+ if (level === "mining" && (0, grinder_http_1.isHttpGrinderConfigured)()) {
250
+ const grindUrl = (0, grinder_http_1.getGrindUrl)();
251
+ const healthUrl = grindUrl.replace(/\/grind$/, "/health");
252
+ try {
253
+ const resp = await fetch(healthUrl, { signal: AbortSignal.timeout(5000) });
254
+ if (resp.ok) {
255
+ const host = new URL(grindUrl).hostname;
256
+ results.push({ label: `GrindProxy: ${host} ($0.01/grind)`, passed: true });
257
+ }
258
+ else {
259
+ results.push({
260
+ label: "GrindProxy unreachable (will use local grinders only)",
261
+ passed: true, // warn but don't fail — local grinders still work
262
+ });
263
+ }
264
+ }
265
+ catch {
266
+ results.push({
267
+ label: "GrindProxy unreachable (will use local grinders only)",
268
+ passed: true,
269
+ });
270
+ }
271
+ }
247
272
  const failures = results.filter((r) => !r.passed);
248
273
  if (failures.length > 0) {
249
274
  console.log("");