traderclaw-cli 1.0.53 → 1.0.55
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/bin/cli.ts +52 -2
- package/bin/openclaw-trader.mjs +29 -6
- package/package.json +2 -2
package/bin/cli.ts
CHANGED
|
@@ -204,6 +204,8 @@ async function cmdSetup(args: string[]) {
|
|
|
204
204
|
let apiKey = "";
|
|
205
205
|
let orchestratorUrl = "";
|
|
206
206
|
|
|
207
|
+
let forwardTelegramRecipientArg = "";
|
|
208
|
+
|
|
207
209
|
for (let i = 0; i < args.length; i++) {
|
|
208
210
|
if ((args[i] === "--api-key" || args[i] === "-k") && args[i + 1]) {
|
|
209
211
|
apiKey = args[++i];
|
|
@@ -211,6 +213,14 @@ async function cmdSetup(args: string[]) {
|
|
|
211
213
|
if ((args[i] === "--url" || args[i] === "-u") && args[i + 1]) {
|
|
212
214
|
orchestratorUrl = args[++i];
|
|
213
215
|
}
|
|
216
|
+
if (
|
|
217
|
+
(args[i] === "--telegram-recipient" ||
|
|
218
|
+
args[i] === "--forward-telegram-chat-id" ||
|
|
219
|
+
args[i] === "--telegram-chat-id") &&
|
|
220
|
+
args[i + 1]
|
|
221
|
+
) {
|
|
222
|
+
forwardTelegramRecipientArg = args[++i];
|
|
223
|
+
}
|
|
214
224
|
}
|
|
215
225
|
|
|
216
226
|
if (!apiKey) {
|
|
@@ -344,6 +354,17 @@ async function cmdSetup(args: string[]) {
|
|
|
344
354
|
process.exit(1);
|
|
345
355
|
}
|
|
346
356
|
|
|
357
|
+
print("\nTelegram delivery (optional)...\n");
|
|
358
|
+
printInfo(" Enter your Telegram @username or numeric chat id so agent replies can be routed to you.");
|
|
359
|
+
printInfo(" Usernames are resolved with Telegram getChat (set TELEGRAM_BOT_TOKEN on the gateway, or");
|
|
360
|
+
printInfo(" export it here for immediate resolution). Private chats: message your bot once first.\n");
|
|
361
|
+
|
|
362
|
+
let forwardTelegramRecipient = forwardTelegramRecipientArg.trim();
|
|
363
|
+
if (!forwardTelegramRecipient) {
|
|
364
|
+
forwardTelegramRecipient = await prompt("Telegram @username or chat id (optional, Enter to skip)", "");
|
|
365
|
+
}
|
|
366
|
+
forwardTelegramRecipient = forwardTelegramRecipient.trim();
|
|
367
|
+
|
|
347
368
|
print("\nWriting configuration...\n");
|
|
348
369
|
|
|
349
370
|
const existingConfig = readConfig();
|
|
@@ -353,6 +374,32 @@ async function cmdSetup(args: string[]) {
|
|
|
353
374
|
apiKey,
|
|
354
375
|
apiTimeout: 120000,
|
|
355
376
|
};
|
|
377
|
+
|
|
378
|
+
if (forwardTelegramRecipient) {
|
|
379
|
+
try {
|
|
380
|
+
const { resolveTelegramRecipientToChatId, looksLikeTelegramChatId } = await import("../src/telegram-resolve.ts");
|
|
381
|
+
const botToken = String(
|
|
382
|
+
process.env.TELEGRAM_BOT_TOKEN || process.env.OPENCLAW_TELEGRAM_BOT_TOKEN || "",
|
|
383
|
+
).trim();
|
|
384
|
+
if (looksLikeTelegramChatId(forwardTelegramRecipient)) {
|
|
385
|
+
pluginConfig.forwardTelegramRecipient = forwardTelegramRecipient;
|
|
386
|
+
printSuccess(` Saved Telegram chat id`);
|
|
387
|
+
} else if (botToken) {
|
|
388
|
+
const id = await resolveTelegramRecipientToChatId({ botToken, raw: forwardTelegramRecipient });
|
|
389
|
+
pluginConfig.forwardTelegramRecipient = id;
|
|
390
|
+
printSuccess(` Resolved @${forwardTelegramRecipient.replace(/^@/, "")} → chat id ${id}`);
|
|
391
|
+
} else {
|
|
392
|
+
pluginConfig.forwardTelegramRecipient = forwardTelegramRecipient;
|
|
393
|
+
printInfo(
|
|
394
|
+
" Saved as-is; start the gateway with TELEGRAM_BOT_TOKEN set to resolve @username on first run.",
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
} catch (err) {
|
|
398
|
+
printWarn(` Telegram resolve failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
399
|
+
printInfo(" Saving your username anyway — fix token or use numeric chat id.");
|
|
400
|
+
pluginConfig.forwardTelegramRecipient = forwardTelegramRecipient;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
356
403
|
setPluginConfig(existingConfig, pluginConfig);
|
|
357
404
|
writeConfig(existingConfig);
|
|
358
405
|
|
|
@@ -365,6 +412,7 @@ async function cmdSetup(args: string[]) {
|
|
|
365
412
|
Orchestrator: ${orchestratorUrl}
|
|
366
413
|
Wallet: ${walletLabel} (ID: ${walletId})
|
|
367
414
|
API Key: ${maskKey(apiKey)}
|
|
415
|
+
Telegram fwd: ${(pluginConfig.forwardTelegramRecipient as string) || "(not set)"}
|
|
368
416
|
Config: ${CONFIG_FILE}
|
|
369
417
|
`);
|
|
370
418
|
print("Next steps:");
|
|
@@ -575,8 +623,9 @@ Commands:
|
|
|
575
623
|
config View and manage configuration
|
|
576
624
|
|
|
577
625
|
Setup options:
|
|
578
|
-
--api-key, -k
|
|
579
|
-
--url, -u
|
|
626
|
+
--api-key, -k API key (skip interactive prompt)
|
|
627
|
+
--url, -u Orchestrator URL (skip interactive prompt)
|
|
628
|
+
--telegram-recipient Telegram @username or chat id (alias: --forward-telegram-chat-id)
|
|
580
629
|
|
|
581
630
|
Config subcommands:
|
|
582
631
|
config show Show current configuration
|
|
@@ -586,6 +635,7 @@ Config subcommands:
|
|
|
586
635
|
Examples:
|
|
587
636
|
openclaw-trader setup
|
|
588
637
|
openclaw-trader setup --api-key sk_live_abc123 --url https://api.traderclaw.ai
|
|
638
|
+
openclaw-trader setup --telegram-recipient @MyChannelOrUser
|
|
589
639
|
openclaw-trader status
|
|
590
640
|
openclaw-trader config show
|
|
591
641
|
openclaw-trader config set apiTimeout 60000
|
package/bin/openclaw-trader.mjs
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { createInterface } from "readline";
|
|
4
4
|
import { readFileSync, writeFileSync, mkdirSync, appendFileSync, existsSync } from "fs";
|
|
5
|
-
import { join } from "path";
|
|
5
|
+
import { dirname, join } from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
6
7
|
import { homedir } from "os";
|
|
7
8
|
import { randomUUID, createPrivateKey, sign as cryptoSign } from "crypto";
|
|
8
9
|
import { execFile, execSync } from "child_process";
|
|
@@ -17,9 +18,27 @@ const execFileAsync = promisify(execFile);
|
|
|
17
18
|
const OPENCLAW_MODELS_PER_PROVIDER_TIMEOUT_MS = 16_000;
|
|
18
19
|
|
|
19
20
|
const PLUGIN_ROOT = resolvePluginPackageRoot(import.meta.url);
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const PLUGIN_PACKAGE_JSON = JSON.parse(readFileSync(join(PLUGIN_ROOT, "package.json"), "utf-8"));
|
|
22
|
+
const PLUGIN_VERSION =
|
|
23
|
+
typeof PLUGIN_PACKAGE_JSON.version === "string" ? PLUGIN_PACKAGE_JSON.version.trim() : "0.0.0";
|
|
24
|
+
/** npm folder name for skills path (always the plugin package). */
|
|
25
|
+
const NPM_PACKAGE_NAME =
|
|
26
|
+
typeof PLUGIN_PACKAGE_JSON.name === "string" ? PLUGIN_PACKAGE_JSON.name : "solana-traderclaw";
|
|
27
|
+
|
|
28
|
+
/** When installed via `npm i -g traderclaw-cli`, bin/ lives under traderclaw-cli — show that version for --version. */
|
|
29
|
+
let CLI_VERSION = null;
|
|
30
|
+
try {
|
|
31
|
+
const cliPkgPath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
32
|
+
const cliPkg = JSON.parse(readFileSync(cliPkgPath, "utf-8"));
|
|
33
|
+
if (cliPkg.name === "traderclaw-cli" && typeof cliPkg.version === "string") {
|
|
34
|
+
CLI_VERSION = cliPkg.version.trim();
|
|
35
|
+
}
|
|
36
|
+
} catch {
|
|
37
|
+
/* git checkout: only plugin package.json next to bin */
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** User-facing CLI version (wrapper package when present, else plugin). */
|
|
41
|
+
const VERSION = CLI_VERSION || PLUGIN_VERSION;
|
|
23
42
|
const PLUGIN_ID = "solana-trader";
|
|
24
43
|
const LEGACY_PLUGIN_IDS = ["traderclaw-v1", "solana-traderclaw-v1", "solana-traderclaw"];
|
|
25
44
|
const CONFIG_DIR = join(homedir(), ".openclaw");
|
|
@@ -2262,7 +2281,7 @@ function wizardHtml(defaults) {
|
|
|
2262
2281
|
const updateHint = () => {
|
|
2263
2282
|
const elapsedSeconds = Math.max(1, Math.floor((Date.now() - llmLoadStartedAt) / 1000));
|
|
2264
2283
|
if (elapsedSeconds >= 8) {
|
|
2265
|
-
llmLoadingHintTextEl.textContent = "Still loading provider catalog (" + elapsedSeconds + "s). First run can take up to ~
|
|
2284
|
+
llmLoadingHintTextEl.textContent = "Still loading provider catalog (" + elapsedSeconds + "s). First run can take up to ~60s.";
|
|
2266
2285
|
return;
|
|
2267
2286
|
}
|
|
2268
2287
|
llmLoadingHintTextEl.textContent = "Fetching provider list (" + elapsedSeconds + "s)...";
|
|
@@ -3188,7 +3207,11 @@ async function main() {
|
|
|
3188
3207
|
}
|
|
3189
3208
|
|
|
3190
3209
|
if (command === "--version" || command === "-v") {
|
|
3191
|
-
|
|
3210
|
+
if (CLI_VERSION && PLUGIN_VERSION && CLI_VERSION !== PLUGIN_VERSION) {
|
|
3211
|
+
print(`traderclaw v${CLI_VERSION} (plugin solana-traderclaw v${PLUGIN_VERSION})`);
|
|
3212
|
+
} else {
|
|
3213
|
+
print(`traderclaw v${VERSION}`);
|
|
3214
|
+
}
|
|
3192
3215
|
process.exit(0);
|
|
3193
3216
|
}
|
|
3194
3217
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "traderclaw-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.55",
|
|
4
4
|
"description": "Global TraderClaw CLI (install --wizard, setup, precheck). Installs solana-traderclaw as a dependency for OpenClaw plugin files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"node": ">=22"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"solana-traderclaw": "^1.0.
|
|
20
|
+
"solana-traderclaw": "^1.0.54"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
23
|
"traderclaw",
|