apow-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/.env.example +24 -0
- package/LICENSE +21 -0
- package/README.md +125 -0
- package/dist/abi/AgentCoin.json +173 -0
- package/dist/abi/MiningAgent.json +186 -0
- package/dist/config.js +113 -0
- package/dist/detect.js +62 -0
- package/dist/errors.js +101 -0
- package/dist/explorer.js +20 -0
- package/dist/index.js +466 -0
- package/dist/miner.js +327 -0
- package/dist/mint.js +256 -0
- package/dist/preflight.js +183 -0
- package/dist/smhl.js +317 -0
- package/dist/stats.js +166 -0
- package/dist/ui.js +142 -0
- package/dist/wallet.js +33 -0
- package/package.json +43 -0
- package/skill.md +553 -0
package/dist/ui.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cyan = exports.yellow = exports.green = exports.red = exports.bold = exports.dim = void 0;
|
|
4
|
+
exports.banner = banner;
|
|
5
|
+
exports.table = table;
|
|
6
|
+
exports.spinner = spinner;
|
|
7
|
+
exports.stopAll = stopAll;
|
|
8
|
+
exports.confirm = confirm;
|
|
9
|
+
exports.prompt = prompt;
|
|
10
|
+
exports.promptSecret = promptSecret;
|
|
11
|
+
exports.ok = ok;
|
|
12
|
+
exports.fail = fail;
|
|
13
|
+
exports.hint = hint;
|
|
14
|
+
exports.error = error;
|
|
15
|
+
exports.warn = warn;
|
|
16
|
+
exports.info = info;
|
|
17
|
+
const promises_1 = require("node:readline/promises");
|
|
18
|
+
const node_process_1 = require("node:process");
|
|
19
|
+
const isTTY = node_process_1.stdout.isTTY && node_process_1.stderr.isTTY;
|
|
20
|
+
const noColor = !!process.env.NO_COLOR || !isTTY;
|
|
21
|
+
function wrap(code, reset) {
|
|
22
|
+
if (noColor)
|
|
23
|
+
return (s) => s;
|
|
24
|
+
return (s) => `\x1b[${code}m${s}\x1b[${reset}m`;
|
|
25
|
+
}
|
|
26
|
+
exports.dim = wrap(2, 22);
|
|
27
|
+
exports.bold = wrap(1, 22);
|
|
28
|
+
exports.red = wrap(31, 39);
|
|
29
|
+
exports.green = wrap(32, 39);
|
|
30
|
+
exports.yellow = wrap(33, 39);
|
|
31
|
+
exports.cyan = wrap(36, 39);
|
|
32
|
+
function banner(lines) {
|
|
33
|
+
if (!lines.length)
|
|
34
|
+
return;
|
|
35
|
+
const maxLen = Math.max(...lines.map((l) => l.length));
|
|
36
|
+
const pad = (s) => s + " ".repeat(maxLen - s.length);
|
|
37
|
+
const border = "=".repeat(maxLen + 4);
|
|
38
|
+
console.log(` ${(0, exports.dim)(border)}`);
|
|
39
|
+
for (const line of lines) {
|
|
40
|
+
console.log(` ${pad(line)}`);
|
|
41
|
+
}
|
|
42
|
+
console.log(` ${(0, exports.dim)(border)}`);
|
|
43
|
+
}
|
|
44
|
+
function table(rows) {
|
|
45
|
+
const maxKey = Math.max(...rows.map(([k]) => k.length));
|
|
46
|
+
for (const [key, value] of rows) {
|
|
47
|
+
console.log(` ${(0, exports.dim)(key + ":")}${" ".repeat(maxKey - key.length + 2)}${value}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const activeSpinners = new Set();
|
|
51
|
+
function spinner(label) {
|
|
52
|
+
if (!isTTY) {
|
|
53
|
+
console.error(` ${label}`);
|
|
54
|
+
const noop = {
|
|
55
|
+
update(l) { console.error(` ${l}`); },
|
|
56
|
+
stop(l) { console.error(` ${l}`); },
|
|
57
|
+
fail(l) { console.error(` ${l}`); },
|
|
58
|
+
};
|
|
59
|
+
return noop;
|
|
60
|
+
}
|
|
61
|
+
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
62
|
+
let frame = 0;
|
|
63
|
+
let current = label;
|
|
64
|
+
let stopped = false;
|
|
65
|
+
const render = () => {
|
|
66
|
+
if (stopped)
|
|
67
|
+
return;
|
|
68
|
+
node_process_1.stderr.write(`\r ${(0, exports.cyan)(frames[frame % frames.length])} ${current} \x1b[K`);
|
|
69
|
+
frame++;
|
|
70
|
+
};
|
|
71
|
+
const interval = setInterval(render, 80);
|
|
72
|
+
render();
|
|
73
|
+
const s = {
|
|
74
|
+
update(l) {
|
|
75
|
+
current = l;
|
|
76
|
+
},
|
|
77
|
+
stop(finalLabel) {
|
|
78
|
+
if (stopped)
|
|
79
|
+
return;
|
|
80
|
+
stopped = true;
|
|
81
|
+
clearInterval(interval);
|
|
82
|
+
node_process_1.stderr.write(`\r ${(0, exports.green)("✔")} ${finalLabel}\x1b[K\n`);
|
|
83
|
+
activeSpinners.delete(s);
|
|
84
|
+
},
|
|
85
|
+
fail(failLabel) {
|
|
86
|
+
if (stopped)
|
|
87
|
+
return;
|
|
88
|
+
stopped = true;
|
|
89
|
+
clearInterval(interval);
|
|
90
|
+
node_process_1.stderr.write(`\r ${(0, exports.red)("✖")} ${failLabel}\x1b[K\n`);
|
|
91
|
+
activeSpinners.delete(s);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
activeSpinners.add(s);
|
|
95
|
+
return s;
|
|
96
|
+
}
|
|
97
|
+
function stopAll() {
|
|
98
|
+
for (const s of activeSpinners) {
|
|
99
|
+
s.fail("interrupted");
|
|
100
|
+
}
|
|
101
|
+
activeSpinners.clear();
|
|
102
|
+
}
|
|
103
|
+
async function confirm(question) {
|
|
104
|
+
if (!isTTY)
|
|
105
|
+
return true;
|
|
106
|
+
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stderr });
|
|
107
|
+
const answer = await rl.question(` ${question} ${(0, exports.dim)("(Y/n)")} `);
|
|
108
|
+
rl.close();
|
|
109
|
+
const trimmed = answer.trim().toLowerCase();
|
|
110
|
+
return trimmed === "" || trimmed === "y" || trimmed === "yes";
|
|
111
|
+
}
|
|
112
|
+
async function prompt(question, defaultValue) {
|
|
113
|
+
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stderr });
|
|
114
|
+
const hint = defaultValue ? ` ${(0, exports.dim)(`[${defaultValue}`)}${(0, exports.dim)("]")}` : "";
|
|
115
|
+
const answer = await rl.question(` ${question}${hint}: `);
|
|
116
|
+
rl.close();
|
|
117
|
+
return answer.trim() || defaultValue || "";
|
|
118
|
+
}
|
|
119
|
+
async function promptSecret(question) {
|
|
120
|
+
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stderr });
|
|
121
|
+
const answer = await rl.question(` ${question}: `);
|
|
122
|
+
rl.close();
|
|
123
|
+
return answer.trim();
|
|
124
|
+
}
|
|
125
|
+
function ok(label) {
|
|
126
|
+
console.log(` ${(0, exports.green)("[OK]")} ${label}`);
|
|
127
|
+
}
|
|
128
|
+
function fail(label) {
|
|
129
|
+
console.log(` ${(0, exports.red)("[X]")} ${label}`);
|
|
130
|
+
}
|
|
131
|
+
function hint(message) {
|
|
132
|
+
console.log(` ${(0, exports.dim)(message)}`);
|
|
133
|
+
}
|
|
134
|
+
function error(message) {
|
|
135
|
+
console.error(` ${(0, exports.red)("Error:")} ${message}`);
|
|
136
|
+
}
|
|
137
|
+
function warn(message) {
|
|
138
|
+
console.log(` ${(0, exports.yellow)("Warning:")} ${message}`);
|
|
139
|
+
}
|
|
140
|
+
function info(label, value) {
|
|
141
|
+
console.log(` ${label} ${value}`);
|
|
142
|
+
}
|
package/dist/wallet.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.walletClient = exports.account = exports.publicClient = void 0;
|
|
4
|
+
exports.requireWallet = requireWallet;
|
|
5
|
+
exports.getEthBalance = getEthBalance;
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const accounts_1 = require("viem/accounts");
|
|
8
|
+
const config_1 = require("./config");
|
|
9
|
+
exports.publicClient = (0, viem_1.createPublicClient)({
|
|
10
|
+
chain: config_1.config.chain,
|
|
11
|
+
transport: (0, viem_1.http)(config_1.config.rpcUrl),
|
|
12
|
+
});
|
|
13
|
+
exports.account = config_1.config.privateKey
|
|
14
|
+
? (0, accounts_1.privateKeyToAccount)(config_1.config.privateKey)
|
|
15
|
+
: null;
|
|
16
|
+
exports.walletClient = exports.account
|
|
17
|
+
? (0, viem_1.createWalletClient)({
|
|
18
|
+
account: exports.account,
|
|
19
|
+
chain: config_1.config.chain,
|
|
20
|
+
transport: (0, viem_1.http)(config_1.config.rpcUrl),
|
|
21
|
+
})
|
|
22
|
+
: null;
|
|
23
|
+
function requireWallet() {
|
|
24
|
+
if (!exports.account || !exports.walletClient) {
|
|
25
|
+
throw new Error("Wallet is not configured. Set PRIVATE_KEY in .env.");
|
|
26
|
+
}
|
|
27
|
+
return { account: exports.account, walletClient: exports.walletClient };
|
|
28
|
+
}
|
|
29
|
+
async function getEthBalance() {
|
|
30
|
+
if (!exports.account)
|
|
31
|
+
return 0n;
|
|
32
|
+
return exports.publicClient.getBalance({ address: exports.account.address });
|
|
33
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "apow-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Mine AGENT tokens on Base L2 with AI-powered proof of work",
|
|
5
|
+
"keywords": ["apow", "agentcoin", "mining", "base", "l2", "proof-of-work", "ai", "crypto"],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Agentoshi",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/Agentoshi/apow-cli.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/Agentoshi/apow-cli",
|
|
13
|
+
"bin": {
|
|
14
|
+
"apow": "./dist/index.js",
|
|
15
|
+
"apow-cli": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18.17.0"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"skill.md",
|
|
23
|
+
".env.example",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"dev": "tsx src/index.ts",
|
|
30
|
+
"prepublishOnly": "npm run build"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"commander": "^14.0.0",
|
|
34
|
+
"dotenv": "^17.2.3",
|
|
35
|
+
"openai": "^6.6.0",
|
|
36
|
+
"viem": "^2.38.2"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^24.6.0",
|
|
40
|
+
"tsx": "^4.20.5",
|
|
41
|
+
"typescript": "^5.9.3"
|
|
42
|
+
}
|
|
43
|
+
}
|