@clawdvault/cli 0.4.0 → 0.4.1
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/README.md +54 -39
- package/dist/index.js +206 -84
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -64,37 +64,6 @@ clawdvault trade sell --mint TOKEN_MINT_ADDRESS --amount 1000000
|
|
|
64
64
|
clawdvault trade sell --mint TOKEN_MINT_ADDRESS --percent 50
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
## USD Price Display
|
|
68
|
-
|
|
69
|
-
As of v0.4.0, the CLI displays USD prices by default for all price and market cap values:
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
# Token list shows USD price and market cap
|
|
73
|
-
clawdvault tokens list
|
|
74
|
-
# Output: SYMBOL | Name | $0.001234 | $50,000 | ...
|
|
75
|
-
|
|
76
|
-
# Token details shows USD with SOL in parentheses
|
|
77
|
-
clawdvault token get <mint>
|
|
78
|
-
# Output: Price: $0.001234 (0.00000678 SOL)
|
|
79
|
-
|
|
80
|
-
# Stats shows USD market cap
|
|
81
|
-
clawdvault token stats <mint>
|
|
82
|
-
# Output: Market Cap: $50,000
|
|
83
|
-
|
|
84
|
-
# Trade history shows USD prices
|
|
85
|
-
clawdvault trade history -m <mint>
|
|
86
|
-
# Output: Shows price_usd for each trade
|
|
87
|
-
|
|
88
|
-
# Candles default to USD
|
|
89
|
-
clawdvault token candles <mint>
|
|
90
|
-
# Output: OHLCV values in USD
|
|
91
|
-
|
|
92
|
-
# Use --currency sol for SOL-denominated candles
|
|
93
|
-
clawdvault token candles <mint> --currency sol
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**Breaking Change:** Previous versions displayed SOL values by default. USD is now the default currency for price display.
|
|
97
|
-
|
|
98
67
|
## Commands Reference
|
|
99
68
|
|
|
100
69
|
### `clawdvault tokens`
|
|
@@ -143,18 +112,10 @@ clawdvault token stats <mint> [--json]
|
|
|
143
112
|
# Get top holders
|
|
144
113
|
clawdvault token holders <mint> [--json]
|
|
145
114
|
|
|
146
|
-
# Get price candles
|
|
147
|
-
clawdvault token candles <mint> [options]
|
|
148
|
-
-i, --interval <interval> Candle interval: 1m, 5m, 15m, 1h, 1d (default: 5m)
|
|
149
|
-
-l, --limit <count> Number of candles (default: 100)
|
|
150
|
-
-c, --currency <currency> Currency: sol or usd (default: usd)
|
|
151
|
-
--json Output as JSON
|
|
152
|
-
|
|
153
115
|
Examples:
|
|
154
116
|
clawdvault token get 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
|
|
155
117
|
clawdvault token create -n "Moon Token" -s "MOON" -i ./moon.png
|
|
156
118
|
clawdvault token create --name "Test" --symbol "TEST" --initial-buy 0.5
|
|
157
|
-
clawdvault token candles <mint> --interval 15m --currency usd
|
|
158
119
|
```
|
|
159
120
|
|
|
160
121
|
### `clawdvault trade`
|
|
@@ -202,6 +163,44 @@ Examples:
|
|
|
202
163
|
clawdvault trade quote -m TOKEN_MINT -t buy -a 0.1
|
|
203
164
|
```
|
|
204
165
|
|
|
166
|
+
### `clawdvault agent`
|
|
167
|
+
|
|
168
|
+
AI agent registration, verification, and leaderboard.
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Register a new AI agent
|
|
172
|
+
clawdvault agent register --wallet <address> [--name <name>]
|
|
173
|
+
--wallet <address> Solana wallet address (required)
|
|
174
|
+
--name <name> Display name (optional)
|
|
175
|
+
|
|
176
|
+
# Output: API key, claim code, tweet template
|
|
177
|
+
# Config saved to ~/.clawdvault/agent.json
|
|
178
|
+
|
|
179
|
+
# Verify agent via Twitter
|
|
180
|
+
clawdvault agent claim --tweet <url> [--api-key <key>]
|
|
181
|
+
--tweet <url> URL of tweet containing claim code (required)
|
|
182
|
+
--api-key <key> API key (defaults to saved config)
|
|
183
|
+
|
|
184
|
+
# Upload agent avatar
|
|
185
|
+
clawdvault agent upload-avatar --image <path> [--api-key <key>] [--wallet <addr>]
|
|
186
|
+
--image <path> Path to image file (required)
|
|
187
|
+
--api-key <key> API key (defaults to saved config)
|
|
188
|
+
--wallet <address> Wallet address (defaults to saved config)
|
|
189
|
+
|
|
190
|
+
# List agents leaderboard
|
|
191
|
+
clawdvault agent list [options]
|
|
192
|
+
--sort <field> Sort by: volume, tokens, fees (default: volume)
|
|
193
|
+
--limit <n> Number of results (default: 25)
|
|
194
|
+
--page <n> Page number (default: 1)
|
|
195
|
+
--json Output as JSON
|
|
196
|
+
|
|
197
|
+
Examples:
|
|
198
|
+
clawdvault agent register --wallet 7xKXtg...AsU --name "My Bot"
|
|
199
|
+
clawdvault agent claim --tweet https://twitter.com/mybot/status/123
|
|
200
|
+
clawdvault agent upload-avatar --image ./avatar.png
|
|
201
|
+
clawdvault agent list --sort volume --limit 10
|
|
202
|
+
```
|
|
203
|
+
|
|
205
204
|
### `clawdvault wallet`
|
|
206
205
|
|
|
207
206
|
Wallet management and info.
|
|
@@ -235,6 +234,22 @@ Examples:
|
|
|
235
234
|
clawdvault wallet address
|
|
236
235
|
```
|
|
237
236
|
|
|
237
|
+
### 4. Agent Registration (For AI Agents)
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# Register your agent
|
|
241
|
+
clawdvault agent register --wallet YOUR_WALLET_ADDRESS --name "My Bot"
|
|
242
|
+
|
|
243
|
+
# Post the tweet template to Twitter, then verify
|
|
244
|
+
clawdvault agent claim --tweet https://twitter.com/mybot/status/123456
|
|
245
|
+
|
|
246
|
+
# Upload an avatar
|
|
247
|
+
clawdvault agent upload-avatar --image ./avatar.png
|
|
248
|
+
|
|
249
|
+
# View the leaderboard
|
|
250
|
+
clawdvault agent list
|
|
251
|
+
```
|
|
252
|
+
|
|
238
253
|
## Configuration
|
|
239
254
|
|
|
240
255
|
### Environment Variables
|
package/dist/index.js
CHANGED
|
@@ -24,8 +24,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// src/index.ts
|
|
27
|
-
var
|
|
28
|
-
var
|
|
27
|
+
var import_commander7 = require("commander");
|
|
28
|
+
var import_chalk8 = __toESM(require("chalk"));
|
|
29
29
|
|
|
30
30
|
// src/commands/tokens.ts
|
|
31
31
|
var import_commander = require("commander");
|
|
@@ -163,18 +163,18 @@ function formatTokens(amount) {
|
|
|
163
163
|
return amount.toFixed(2);
|
|
164
164
|
}
|
|
165
165
|
function formatUsd(amount) {
|
|
166
|
-
|
|
167
|
-
let maximumFractionDigits = 2;
|
|
168
|
-
if (absAmount < 1e-6) maximumFractionDigits = 10;
|
|
169
|
-
else if (absAmount < 1e-4) maximumFractionDigits = 8;
|
|
170
|
-
else if (absAmount < 0.01) maximumFractionDigits = 6;
|
|
171
|
-
else if (absAmount < 1) maximumFractionDigits = 4;
|
|
172
|
-
return `$${amount.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits })}`;
|
|
166
|
+
return `$${amount.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
173
167
|
}
|
|
174
168
|
function formatPercent(value) {
|
|
175
169
|
const formatted = (value * 100).toFixed(2);
|
|
176
170
|
return value >= 0 ? import_chalk.default.green(`+${formatted}%`) : import_chalk.default.red(`${formatted}%`);
|
|
177
171
|
}
|
|
172
|
+
function formatPriceChange(value) {
|
|
173
|
+
if (value == null) return import_chalk.default.gray("N/A");
|
|
174
|
+
const sign = value >= 0 ? "+" : "";
|
|
175
|
+
const formatted = `${sign}${value.toFixed(2)}%`;
|
|
176
|
+
return value >= 0 ? import_chalk.default.green(formatted) : import_chalk.default.red(formatted);
|
|
177
|
+
}
|
|
178
178
|
function shortenAddress(address, chars = 4) {
|
|
179
179
|
return `${address.slice(0, chars)}...${address.slice(-chars)}`;
|
|
180
180
|
}
|
|
@@ -227,7 +227,7 @@ tokensCommand.command("list").description("List all tokens").option("-s, --sort
|
|
|
227
227
|
const result = await client.listTokens({
|
|
228
228
|
sort: options.sort,
|
|
229
229
|
page: parseInt(options.page),
|
|
230
|
-
|
|
230
|
+
per_page: parseInt(options.limit),
|
|
231
231
|
graduated
|
|
232
232
|
});
|
|
233
233
|
spin.stop();
|
|
@@ -244,7 +244,7 @@ tokensCommand.command("list").description("List all tokens").option("-s, --sort
|
|
|
244
244
|
import_chalk2.default.cyan("Name"),
|
|
245
245
|
import_chalk2.default.cyan("Price"),
|
|
246
246
|
import_chalk2.default.cyan("Market Cap"),
|
|
247
|
-
import_chalk2.default.cyan("24h
|
|
247
|
+
import_chalk2.default.cyan("24h Change"),
|
|
248
248
|
import_chalk2.default.cyan("Status"),
|
|
249
249
|
import_chalk2.default.cyan("Mint")
|
|
250
250
|
],
|
|
@@ -255,9 +255,9 @@ tokensCommand.command("list").description("List all tokens").option("-s, --sort
|
|
|
255
255
|
table.push([
|
|
256
256
|
import_chalk2.default.bold(token.symbol ?? "???"),
|
|
257
257
|
token.name ?? "Unknown",
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
258
|
+
formatSol(token.price_sol ?? 0),
|
|
259
|
+
formatSol(token.market_cap_sol ?? 0),
|
|
260
|
+
formatPriceChange(token.price_change_24h),
|
|
261
261
|
status,
|
|
262
262
|
shortenAddress(token.mint ?? "")
|
|
263
263
|
]);
|
|
@@ -307,8 +307,11 @@ tokenCommand.command("get <mint>").description("Get token details").option("--js
|
|
|
307
307
|
table.push(
|
|
308
308
|
{ [import_chalk3.default.cyan("Mint")]: token.mint ?? "" },
|
|
309
309
|
{ [import_chalk3.default.cyan("Creator")]: shortenAddress(token.creator ?? "") },
|
|
310
|
-
{ [import_chalk3.default.cyan("Price")]:
|
|
311
|
-
{ [import_chalk3.default.cyan("
|
|
310
|
+
{ [import_chalk3.default.cyan("Price")]: formatSol(token.price_sol ?? 0) },
|
|
311
|
+
{ [import_chalk3.default.cyan("Price USD")]: token.price_usd ? formatUsd(token.price_usd) : "N/A" },
|
|
312
|
+
{ [import_chalk3.default.cyan("24h Change")]: formatPriceChange(token.price_change_24h) },
|
|
313
|
+
{ [import_chalk3.default.cyan("Market Cap")]: formatSol(token.market_cap_sol ?? 0) },
|
|
314
|
+
{ [import_chalk3.default.cyan("Market Cap USD")]: token.market_cap_usd ? formatUsd(token.market_cap_usd) : "N/A" },
|
|
312
315
|
{ [import_chalk3.default.cyan("Status")]: token.graduated ? "\u{1F393} Graduated" : "\u{1F4C8} Bonding Curve" }
|
|
313
316
|
);
|
|
314
317
|
if (token.description) {
|
|
@@ -333,7 +336,6 @@ tokenCommand.command("get <mint>").description("Get token details").option("--js
|
|
|
333
336
|
import_chalk3.default.cyan("Type"),
|
|
334
337
|
import_chalk3.default.cyan("SOL"),
|
|
335
338
|
import_chalk3.default.cyan("Tokens"),
|
|
336
|
-
import_chalk3.default.cyan("Price USD"),
|
|
337
339
|
import_chalk3.default.cyan("Trader"),
|
|
338
340
|
import_chalk3.default.cyan("Time")
|
|
339
341
|
],
|
|
@@ -345,7 +347,6 @@ tokenCommand.command("get <mint>").description("Get token details").option("--js
|
|
|
345
347
|
typeStr,
|
|
346
348
|
formatSol(trade.sol_amount ?? 0),
|
|
347
349
|
formatTokens(trade.token_amount ?? 0),
|
|
348
|
-
formatUsd(trade.price_usd ?? 0),
|
|
349
350
|
shortenAddress(trade.trader ?? ""),
|
|
350
351
|
new Date(trade.created_at ?? Date.now()).toLocaleString()
|
|
351
352
|
]);
|
|
@@ -426,13 +427,12 @@ tokenCommand.command("stats <mint>").description("Get on-chain stats").option("-
|
|
|
426
427
|
style: { head: [], border: [] }
|
|
427
428
|
});
|
|
428
429
|
table.push(
|
|
429
|
-
{ [import_chalk3.default.cyan("Price")]:
|
|
430
|
-
{ [import_chalk3.default.cyan("Market Cap")]:
|
|
430
|
+
{ [import_chalk3.default.cyan("Price")]: formatSol(onChain.price ?? 0) },
|
|
431
|
+
{ [import_chalk3.default.cyan("Market Cap")]: formatSol(onChain.marketCap ?? 0) },
|
|
431
432
|
{ [import_chalk3.default.cyan("Total Supply")]: formatTokens(onChain.totalSupply ?? 0) },
|
|
432
433
|
{ [import_chalk3.default.cyan("Circulating")]: formatTokens(onChain.circulatingSupply ?? 0) },
|
|
433
434
|
{ [import_chalk3.default.cyan("Curve Balance")]: formatTokens(onChain.bondingCurveBalance ?? 0) },
|
|
434
435
|
{ [import_chalk3.default.cyan("Curve SOL")]: formatSol(onChain.bondingCurveSol ?? 0) },
|
|
435
|
-
{ [import_chalk3.default.cyan("SOL Price")]: formatUsd(onChain.solPriceUsd ?? 0) },
|
|
436
436
|
{ [import_chalk3.default.cyan("Status")]: onChain.graduated ? "\u{1F393} Graduated" : "\u{1F4C8} Bonding" }
|
|
437
437
|
);
|
|
438
438
|
console.log(table.toString());
|
|
@@ -481,61 +481,6 @@ tokenCommand.command("holders <mint>").description("Get top token holders").opti
|
|
|
481
481
|
handleError(err);
|
|
482
482
|
}
|
|
483
483
|
});
|
|
484
|
-
tokenCommand.command("candles <mint>").description("Get price candles").option("-i, --interval <interval>", "Candle interval (1m, 5m, 15m, 1h, 1d)", "5m").option("-l, --limit <count>", "Number of candles to fetch", "100").option("-c, --currency <currency>", "Currency for prices (sol or usd)", "usd").option("--json", "Output as JSON").action(async (mint, options) => {
|
|
485
|
-
const spin = spinner("Fetching candles...").start();
|
|
486
|
-
try {
|
|
487
|
-
const client = createReadOnlyClient();
|
|
488
|
-
const result = await client.getCandles({
|
|
489
|
-
mint,
|
|
490
|
-
interval: options.interval,
|
|
491
|
-
limit: parseInt(options.limit),
|
|
492
|
-
currency: options.currency
|
|
493
|
-
});
|
|
494
|
-
spin.stop();
|
|
495
|
-
if (options.json) {
|
|
496
|
-
console.log(JSON.stringify(result, null, 2));
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
console.log(import_chalk3.default.bold(`
|
|
500
|
-
\u{1F4CA} Price Candles (${options.currency.toUpperCase()})
|
|
501
|
-
`));
|
|
502
|
-
const candles = result.candles ?? [];
|
|
503
|
-
if (candles.length === 0) {
|
|
504
|
-
console.log(import_chalk3.default.yellow("No candles available"));
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
const table = new import_cli_table32.default({
|
|
508
|
-
head: [
|
|
509
|
-
import_chalk3.default.cyan("Time"),
|
|
510
|
-
import_chalk3.default.cyan("Open"),
|
|
511
|
-
import_chalk3.default.cyan("High"),
|
|
512
|
-
import_chalk3.default.cyan("Low"),
|
|
513
|
-
import_chalk3.default.cyan("Close"),
|
|
514
|
-
import_chalk3.default.cyan("Volume")
|
|
515
|
-
],
|
|
516
|
-
style: { head: [], border: [] }
|
|
517
|
-
});
|
|
518
|
-
const isUsd = options.currency === "usd";
|
|
519
|
-
const formatPrice = isUsd ? formatUsd : formatSol;
|
|
520
|
-
candles.slice(-20).forEach((c) => {
|
|
521
|
-
table.push([
|
|
522
|
-
new Date(c.time * 1e3).toLocaleString(),
|
|
523
|
-
formatPrice(c.open),
|
|
524
|
-
formatPrice(c.high),
|
|
525
|
-
formatPrice(c.low),
|
|
526
|
-
formatPrice(c.close),
|
|
527
|
-
formatTokens(c.volume)
|
|
528
|
-
]);
|
|
529
|
-
});
|
|
530
|
-
console.log(table.toString());
|
|
531
|
-
console.log();
|
|
532
|
-
console.log(import_chalk3.default.gray(`Showing last ${Math.min(20, candles.length)} of ${candles.length} candles`));
|
|
533
|
-
console.log();
|
|
534
|
-
} catch (err) {
|
|
535
|
-
spin.stop();
|
|
536
|
-
handleError(err);
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
484
|
|
|
540
485
|
// src/commands/trade.ts
|
|
541
486
|
var import_commander3 = require("commander");
|
|
@@ -563,7 +508,7 @@ tradeCommand.command("buy").description("Buy tokens").requiredOption("-m, --mint
|
|
|
563
508
|
table.push(
|
|
564
509
|
{ [import_chalk4.default.cyan("Input")]: `${solAmount} SOL` },
|
|
565
510
|
{ [import_chalk4.default.cyan("Output")]: `~${formatTokens(quote.output ?? 0)} tokens` },
|
|
566
|
-
{ [import_chalk4.default.cyan("Price
|
|
511
|
+
{ [import_chalk4.default.cyan("Price")]: formatSol(quote.current_price ?? 0) },
|
|
567
512
|
{ [import_chalk4.default.cyan("Fee")]: formatSol(quote.fee ?? 0) },
|
|
568
513
|
{ [import_chalk4.default.cyan("Price Impact")]: formatPercent(priceImpact) },
|
|
569
514
|
{ [import_chalk4.default.cyan("Slippage")]: `${(slippage * 100).toFixed(1)}%` }
|
|
@@ -641,7 +586,7 @@ tradeCommand.command("sell").description("Sell tokens").requiredOption("-m, --mi
|
|
|
641
586
|
table.push(
|
|
642
587
|
{ [import_chalk4.default.cyan("Input")]: `${formatTokens(tokenAmount)} tokens` },
|
|
643
588
|
{ [import_chalk4.default.cyan("Output")]: `~${formatSol(quote.output ?? 0)}` },
|
|
644
|
-
{ [import_chalk4.default.cyan("Price
|
|
589
|
+
{ [import_chalk4.default.cyan("Price")]: formatSol(quote.current_price ?? 0) },
|
|
645
590
|
{ [import_chalk4.default.cyan("Fee")]: formatSol(quote.fee ?? 0) },
|
|
646
591
|
{ [import_chalk4.default.cyan("Price Impact")]: formatPercent(-sellPriceImpact) },
|
|
647
592
|
{ [import_chalk4.default.cyan("Slippage")]: `${(slippage * 100).toFixed(1)}%` }
|
|
@@ -703,7 +648,7 @@ tradeCommand.command("quote").description("Get a price quote without executing")
|
|
|
703
648
|
table.push(
|
|
704
649
|
{ [import_chalk4.default.cyan("Input")]: isBuy ? `${options.amount} SOL` : `${formatTokens(parseFloat(options.amount))} tokens` },
|
|
705
650
|
{ [import_chalk4.default.cyan("Output")]: isBuy ? `~${formatTokens(quote.output ?? 0)} tokens` : `~${formatSol(quote.output ?? 0)}` },
|
|
706
|
-
{ [import_chalk4.default.cyan("Price
|
|
651
|
+
{ [import_chalk4.default.cyan("Price")]: formatSol(quote.current_price ?? 0) },
|
|
707
652
|
{ [import_chalk4.default.cyan("Fee")]: formatSol(quote.fee ?? 0) },
|
|
708
653
|
{ [import_chalk4.default.cyan("Price Impact")]: formatPercent(isBuy ? quotePriceImpact : -quotePriceImpact) }
|
|
709
654
|
);
|
|
@@ -735,7 +680,7 @@ tradeCommand.command("history").description("Get trade history for a token").req
|
|
|
735
680
|
import_chalk4.default.cyan("Type"),
|
|
736
681
|
import_chalk4.default.cyan("SOL"),
|
|
737
682
|
import_chalk4.default.cyan("Tokens"),
|
|
738
|
-
import_chalk4.default.cyan("Price
|
|
683
|
+
import_chalk4.default.cyan("Price"),
|
|
739
684
|
import_chalk4.default.cyan("Trader"),
|
|
740
685
|
import_chalk4.default.cyan("Time")
|
|
741
686
|
],
|
|
@@ -747,7 +692,7 @@ tradeCommand.command("history").description("Get trade history for a token").req
|
|
|
747
692
|
typeStr,
|
|
748
693
|
formatSol(trade.sol_amount ?? 0),
|
|
749
694
|
formatTokens(trade.token_amount ?? 0),
|
|
750
|
-
|
|
695
|
+
formatSol(trade.price_sol ?? 0),
|
|
751
696
|
shortenAddress(trade.trader ?? ""),
|
|
752
697
|
new Date(trade.created_at ?? Date.now()).toLocaleString()
|
|
753
698
|
]);
|
|
@@ -1357,19 +1302,196 @@ chatCommand.command("unreact").description("Remove reaction from a message").req
|
|
|
1357
1302
|
}
|
|
1358
1303
|
});
|
|
1359
1304
|
|
|
1305
|
+
// src/commands/agent.ts
|
|
1306
|
+
var import_commander6 = require("commander");
|
|
1307
|
+
var import_chalk7 = __toESM(require("chalk"));
|
|
1308
|
+
var import_cli_table35 = __toESM(require("cli-table3"));
|
|
1309
|
+
var fs4 = __toESM(require("fs"));
|
|
1310
|
+
var path3 = __toESM(require("path"));
|
|
1311
|
+
function getAgentConfigPath() {
|
|
1312
|
+
return path3.join(getConfigDir(), "agent.json");
|
|
1313
|
+
}
|
|
1314
|
+
function loadAgentConfig() {
|
|
1315
|
+
const configPath = getAgentConfigPath();
|
|
1316
|
+
if (!fs4.existsSync(configPath)) {
|
|
1317
|
+
return null;
|
|
1318
|
+
}
|
|
1319
|
+
try {
|
|
1320
|
+
return JSON.parse(fs4.readFileSync(configPath, "utf-8"));
|
|
1321
|
+
} catch {
|
|
1322
|
+
return null;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
function saveAgentConfig(config) {
|
|
1326
|
+
const configDir = getConfigDir();
|
|
1327
|
+
if (!fs4.existsSync(configDir)) {
|
|
1328
|
+
fs4.mkdirSync(configDir, { recursive: true });
|
|
1329
|
+
}
|
|
1330
|
+
const configPath = getAgentConfigPath();
|
|
1331
|
+
fs4.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
1332
|
+
fs4.chmodSync(configPath, 384);
|
|
1333
|
+
}
|
|
1334
|
+
var agentCommand = new import_commander6.Command("agent").description("Agent registration and management");
|
|
1335
|
+
agentCommand.command("register").description("Register a new AI agent").requiredOption("--wallet <address>", "Solana wallet address").option("--name <name>", "Agent display name").action(async (options) => {
|
|
1336
|
+
const spin = spinner("Registering agent...").start();
|
|
1337
|
+
try {
|
|
1338
|
+
const client = createReadOnlyClient();
|
|
1339
|
+
const result = await client.registerAgent({
|
|
1340
|
+
wallet: options.wallet,
|
|
1341
|
+
name: options.name
|
|
1342
|
+
});
|
|
1343
|
+
spin.stop();
|
|
1344
|
+
success("Agent registered!");
|
|
1345
|
+
console.log();
|
|
1346
|
+
info(`Agent ID: ${result.agentId ?? ""}`);
|
|
1347
|
+
info(`API Key: ${import_chalk7.default.yellow(result.apiKey ?? "")}`);
|
|
1348
|
+
info(`Claim Code: ${import_chalk7.default.bold(result.claimCode ?? "")}`);
|
|
1349
|
+
console.log();
|
|
1350
|
+
warn("Save your API key \u2014 it is only shown once!");
|
|
1351
|
+
console.log();
|
|
1352
|
+
console.log(import_chalk7.default.bold("Tweet this to verify:"));
|
|
1353
|
+
console.log(import_chalk7.default.gray(result.tweetTemplate ?? ""));
|
|
1354
|
+
console.log();
|
|
1355
|
+
saveAgentConfig({
|
|
1356
|
+
apiKey: result.apiKey,
|
|
1357
|
+
wallet: options.wallet,
|
|
1358
|
+
agentId: result.agentId,
|
|
1359
|
+
name: options.name
|
|
1360
|
+
});
|
|
1361
|
+
info(`Config saved to ${getAgentConfigPath()}`);
|
|
1362
|
+
} catch (err) {
|
|
1363
|
+
spin.stop();
|
|
1364
|
+
handleError(err);
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1367
|
+
agentCommand.command("claim").description("Verify agent via Twitter tweet").requiredOption("--tweet <url>", "URL of the tweet containing your claim code").option("--api-key <key>", "API key (defaults to saved config)").action(async (options) => {
|
|
1368
|
+
const agentConfig = loadAgentConfig();
|
|
1369
|
+
const apiKey = options.apiKey ?? agentConfig?.apiKey;
|
|
1370
|
+
if (!apiKey) {
|
|
1371
|
+
error("No API key found. Run `clawdvault agent register` first or pass --api-key");
|
|
1372
|
+
process.exit(1);
|
|
1373
|
+
}
|
|
1374
|
+
const spin = spinner("Verifying tweet...").start();
|
|
1375
|
+
try {
|
|
1376
|
+
const client = createReadOnlyClient();
|
|
1377
|
+
const result = await client.claimAgent({
|
|
1378
|
+
apiKey,
|
|
1379
|
+
tweetUrl: options.tweet
|
|
1380
|
+
});
|
|
1381
|
+
spin.stop();
|
|
1382
|
+
success("Agent verified!");
|
|
1383
|
+
console.log();
|
|
1384
|
+
if (result.twitterHandle) {
|
|
1385
|
+
info(`Twitter: @${result.twitterHandle}`);
|
|
1386
|
+
}
|
|
1387
|
+
if (result.verifiedAt) {
|
|
1388
|
+
info(`Verified: ${new Date(result.verifiedAt).toLocaleString()}`);
|
|
1389
|
+
}
|
|
1390
|
+
} catch (err) {
|
|
1391
|
+
spin.stop();
|
|
1392
|
+
handleError(err);
|
|
1393
|
+
}
|
|
1394
|
+
});
|
|
1395
|
+
agentCommand.command("upload-avatar").description("Upload agent avatar image").requiredOption("--image <path>", "Path to image file").option("--api-key <key>", "API key (defaults to saved config)").option("--wallet <address>", "Wallet address (defaults to saved config)").action(async (options) => {
|
|
1396
|
+
const agentConfig = loadAgentConfig();
|
|
1397
|
+
const apiKey = options.apiKey ?? agentConfig?.apiKey;
|
|
1398
|
+
const wallet = options.wallet ?? agentConfig?.wallet;
|
|
1399
|
+
if (!apiKey) {
|
|
1400
|
+
error("No API key found. Run `clawdvault agent register` first or pass --api-key");
|
|
1401
|
+
process.exit(1);
|
|
1402
|
+
}
|
|
1403
|
+
if (!wallet) {
|
|
1404
|
+
error("No wallet found. Pass --wallet or register first");
|
|
1405
|
+
process.exit(1);
|
|
1406
|
+
}
|
|
1407
|
+
if (!fs4.existsSync(options.image)) {
|
|
1408
|
+
error(`Image file not found: ${options.image}`);
|
|
1409
|
+
process.exit(1);
|
|
1410
|
+
}
|
|
1411
|
+
const spin = spinner("Uploading avatar...").start();
|
|
1412
|
+
try {
|
|
1413
|
+
const client = createReadOnlyClient();
|
|
1414
|
+
const buffer = fs4.readFileSync(options.image);
|
|
1415
|
+
const filename = path3.basename(options.image);
|
|
1416
|
+
const result = await client.uploadAvatar(buffer, wallet, apiKey, filename);
|
|
1417
|
+
spin.stop();
|
|
1418
|
+
success("Avatar uploaded!");
|
|
1419
|
+
info(`URL: ${link(result.url ?? "")}`);
|
|
1420
|
+
} catch (err) {
|
|
1421
|
+
spin.stop();
|
|
1422
|
+
handleError(err);
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1425
|
+
agentCommand.command("list").description("List agents leaderboard").option("--sort <field>", "Sort by: volume, tokens, fees", "volume").option("--limit <n>", "Number of results", "25").option("--page <n>", "Page number", "1").option("--json", "Output as JSON").action(async (options) => {
|
|
1426
|
+
const spin = spinner("Fetching agents...").start();
|
|
1427
|
+
try {
|
|
1428
|
+
const client = createReadOnlyClient();
|
|
1429
|
+
const result = await client.listAgents({
|
|
1430
|
+
sortBy: options.sort,
|
|
1431
|
+
limit: parseInt(options.limit),
|
|
1432
|
+
page: parseInt(options.page)
|
|
1433
|
+
});
|
|
1434
|
+
spin.stop();
|
|
1435
|
+
if (options.json) {
|
|
1436
|
+
console.log(JSON.stringify(result, null, 2));
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
const agents = result.agents ?? [];
|
|
1440
|
+
if (agents.length === 0) {
|
|
1441
|
+
info("No agents found");
|
|
1442
|
+
return;
|
|
1443
|
+
}
|
|
1444
|
+
console.log(import_chalk7.default.bold(`
|
|
1445
|
+
\u{1F916} Agent Leaderboard (sorted by ${options.sort})
|
|
1446
|
+
`));
|
|
1447
|
+
const table = new import_cli_table35.default({
|
|
1448
|
+
head: [
|
|
1449
|
+
import_chalk7.default.cyan("#"),
|
|
1450
|
+
import_chalk7.default.cyan("Name"),
|
|
1451
|
+
import_chalk7.default.cyan("Handle"),
|
|
1452
|
+
import_chalk7.default.cyan("Volume"),
|
|
1453
|
+
import_chalk7.default.cyan("Tokens"),
|
|
1454
|
+
import_chalk7.default.cyan("Fees"),
|
|
1455
|
+
import_chalk7.default.cyan("Verified")
|
|
1456
|
+
],
|
|
1457
|
+
style: { head: [], border: [] }
|
|
1458
|
+
});
|
|
1459
|
+
const pageOffset = (parseInt(options.page) - 1) * parseInt(options.limit);
|
|
1460
|
+
agents.forEach((agent, i) => {
|
|
1461
|
+
table.push([
|
|
1462
|
+
pageOffset + i + 1,
|
|
1463
|
+
agent.name ?? shortenAddress(agent.wallet ?? ""),
|
|
1464
|
+
agent.twitter_handle ? `@${agent.twitter_handle}` : "-",
|
|
1465
|
+
formatUsd(agent.total_volume ?? 0),
|
|
1466
|
+
agent.tokens_created ?? 0,
|
|
1467
|
+
formatUsd(agent.total_fees ?? 0),
|
|
1468
|
+
agent.twitter_verified ? import_chalk7.default.green("\u2713") : import_chalk7.default.gray("-")
|
|
1469
|
+
]);
|
|
1470
|
+
});
|
|
1471
|
+
console.log(table.toString());
|
|
1472
|
+
console.log(import_chalk7.default.gray(`
|
|
1473
|
+
Page ${result.page ?? 1} | ${result.total ?? 0} total agents
|
|
1474
|
+
`));
|
|
1475
|
+
} catch (err) {
|
|
1476
|
+
spin.stop();
|
|
1477
|
+
handleError(err);
|
|
1478
|
+
}
|
|
1479
|
+
});
|
|
1480
|
+
|
|
1360
1481
|
// src/index.ts
|
|
1361
|
-
var program = new
|
|
1362
|
-
program.name("clawdvault").description("CLI for ClawdVault - Solana token launchpad").version("0.
|
|
1482
|
+
var program = new import_commander7.Command();
|
|
1483
|
+
program.name("clawdvault").description("CLI for ClawdVault - Solana token launchpad").version("0.1.0");
|
|
1363
1484
|
program.addCommand(tokensCommand);
|
|
1364
1485
|
program.addCommand(tokenCommand);
|
|
1365
1486
|
program.addCommand(tradeCommand);
|
|
1366
1487
|
program.addCommand(walletCommand);
|
|
1367
1488
|
program.addCommand(chatCommand);
|
|
1489
|
+
program.addCommand(agentCommand);
|
|
1368
1490
|
program.hook("preAction", () => {
|
|
1369
1491
|
});
|
|
1370
1492
|
program.configureOutput({
|
|
1371
1493
|
outputError: (str, write) => {
|
|
1372
|
-
write(
|
|
1494
|
+
write(import_chalk8.default.red(str));
|
|
1373
1495
|
}
|
|
1374
1496
|
});
|
|
1375
1497
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clawdvault/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "CLI for ClawdVault - Solana token launchpad",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"clean": "rm -rf dist"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@clawdvault/sdk": "^0.4.
|
|
18
|
+
"@clawdvault/sdk": "^0.4.1",
|
|
19
19
|
"@solana/spl-token": "^0.4.0",
|
|
20
20
|
"@solana/web3.js": "^1.91.0",
|
|
21
21
|
"bip39": "^3.1.0",
|