solana-traderclaw 1.0.138 → 1.0.140
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.
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// src/session-manager.ts
|
|
2
2
|
var TRADERCLAW_SESSION_TROUBLESHOOTING = "https://docs.traderclaw.ai/docs/installation#troubleshooting-session-expired-auth-errors-or-the-agent-logged-out";
|
|
3
|
+
var TRADERCLAW_MANAGED_INSTALL_CONSOLE_PANEL_URL = "https://install.traderclaw.ai/panel";
|
|
4
|
+
var TRADERCLAW_MANAGED_INSTALL_LOGIN_HINT = `If you installed via install.traderclaw.ai's managed VPS console, re-authenticate in Panel \u2192 TraderClaw login (${TRADERCLAW_MANAGED_INSTALL_CONSOLE_PANEL_URL}), then openclaw gateway restart when convenient.`;
|
|
3
5
|
var BS58_CHARS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
4
6
|
function b58Decode(str) {
|
|
5
7
|
let num = BigInt(0);
|
|
@@ -357,7 +359,7 @@ var SessionManager = class _SessionManager {
|
|
|
357
359
|
const walletPrivateKey = (await this.walletPrivateKeyProvider?.())?.trim();
|
|
358
360
|
if (!walletPrivateKey) {
|
|
359
361
|
throw new Error(
|
|
360
|
-
`Wallet proof required but the gateway cannot sign interactively \u2014 no wallet key is wired into this process. This account already has a wallet. On the host that runs OpenClaw (with a normal terminal / TTY), run: traderclaw login \u2014 complete wallet proof when prompted \u2014 then openclaw gateway restart. That persists new session tokens without putting a private key in the gateway configuration. Do not paste private keys into openclaw.json. Troubleshooting: ${TRADERCLAW_SESSION_TROUBLESHOOTING}`
|
|
362
|
+
`Wallet proof required but the gateway cannot sign interactively \u2014 no wallet key is wired into this process. This account already has a wallet. On the host that runs OpenClaw (with a normal terminal / TTY), run: traderclaw login \u2014 complete wallet proof when prompted \u2014 then openclaw gateway restart. That persists new session tokens without putting a private key in the gateway configuration. Do not paste private keys into openclaw.json. Troubleshooting: ${TRADERCLAW_SESSION_TROUBLESHOOTING} ${TRADERCLAW_MANAGED_INSTALL_LOGIN_HINT}`
|
|
361
363
|
);
|
|
362
364
|
}
|
|
363
365
|
walletPubKey = challenge.walletPublicKey || this.walletPublicKey || void 0;
|
|
@@ -387,7 +389,7 @@ var SessionManager = class _SessionManager {
|
|
|
387
389
|
await this.unifiedRefresh();
|
|
388
390
|
if (!this.accessToken) {
|
|
389
391
|
throw new Error(
|
|
390
|
-
`Session expired and could not be refreshed. Re-authentication required. On the gateway host try: traderclaw login \u2014 then openclaw gateway restart. Troubleshooting: ${TRADERCLAW_SESSION_TROUBLESHOOTING}`
|
|
392
|
+
`Session expired and could not be refreshed. Re-authentication required. On the gateway host try: traderclaw login \u2014 then openclaw gateway restart. Troubleshooting: ${TRADERCLAW_SESSION_TROUBLESHOOTING} ${TRADERCLAW_MANAGED_INSTALL_LOGIN_HINT}`
|
|
391
393
|
);
|
|
392
394
|
}
|
|
393
395
|
return this.accessToken;
|
|
@@ -398,7 +400,7 @@ var SessionManager = class _SessionManager {
|
|
|
398
400
|
await this.unifiedRefresh();
|
|
399
401
|
if (!this.accessToken) {
|
|
400
402
|
throw new Error(
|
|
401
|
-
`Session expired and could not be refreshed. Re-authentication required. On the gateway host try: traderclaw login \u2014 then openclaw gateway restart. Troubleshooting: ${TRADERCLAW_SESSION_TROUBLESHOOTING}`
|
|
403
|
+
`Session expired and could not be refreshed. Re-authentication required. On the gateway host try: traderclaw login \u2014 then openclaw gateway restart. Troubleshooting: ${TRADERCLAW_SESSION_TROUBLESHOOTING} ${TRADERCLAW_MANAGED_INSTALL_LOGIN_HINT}`
|
|
402
404
|
);
|
|
403
405
|
}
|
|
404
406
|
return this.accessToken;
|
|
@@ -541,5 +543,7 @@ var SessionManager = class _SessionManager {
|
|
|
541
543
|
};
|
|
542
544
|
|
|
543
545
|
export {
|
|
546
|
+
TRADERCLAW_MANAGED_INSTALL_CONSOLE_PANEL_URL,
|
|
547
|
+
TRADERCLAW_MANAGED_INSTALL_LOGIN_HINT,
|
|
544
548
|
SessionManager
|
|
545
549
|
};
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,9 @@ import {
|
|
|
4
4
|
writeRefreshTokenToOpenclawAtomic
|
|
5
5
|
} from "./chunk-IAQC34O7.js";
|
|
6
6
|
import {
|
|
7
|
-
SessionManager
|
|
8
|
-
|
|
7
|
+
SessionManager,
|
|
8
|
+
TRADERCLAW_MANAGED_INSTALL_LOGIN_HINT
|
|
9
|
+
} from "./chunk-OKBHBUZ7.js";
|
|
9
10
|
import {
|
|
10
11
|
looksLikeTelegramChatId,
|
|
11
12
|
resolveTelegramRecipientToChatId
|
|
@@ -838,6 +839,10 @@ function parseConfig(raw) {
|
|
|
838
839
|
kaybaFolder
|
|
839
840
|
};
|
|
840
841
|
}
|
|
842
|
+
function isOrchestratorRateLimitError(err) {
|
|
843
|
+
const m = err instanceof Error ? err.message : String(err);
|
|
844
|
+
return /\bRATE_LIMIT\b|(^|[\s:])429([\s:]|$)|rate\s+limit\s+exceeded/i.test(m);
|
|
845
|
+
}
|
|
841
846
|
function buildTraderClawWelcomeMessage(apiKeyForDisplay) {
|
|
842
847
|
const keyBlock = apiKeyForDisplay ? `Your TraderClaw API Key:
|
|
843
848
|
|
|
@@ -928,7 +933,7 @@ var solanaTraderPlugin = {
|
|
|
928
933
|
}
|
|
929
934
|
if (!apiKey && !config.refreshToken) {
|
|
930
935
|
api.logger.error(
|
|
931
|
-
|
|
936
|
+
`[solana-trader] apiKey or refreshToken is required. Tell the user to run on their machine: traderclaw setup --signup (or traderclaw signup) for a new account, or traderclaw setup / traderclaw login if they already have an API key. The agent cannot sign up or edit credentials. ${TRADERCLAW_MANAGED_INSTALL_LOGIN_HINT}`
|
|
932
937
|
);
|
|
933
938
|
return;
|
|
934
939
|
}
|
|
@@ -4291,6 +4296,7 @@ Context compaction triggered. STATE.md synced from last persisted state. Decisio
|
|
|
4291
4296
|
description: "Sync STATE.md and append memory-flush entry to daily log before context compaction."
|
|
4292
4297
|
}
|
|
4293
4298
|
);
|
|
4299
|
+
let solanaTraderSessionWatchdogTimer = null;
|
|
4294
4300
|
api.registerService({
|
|
4295
4301
|
id: "solana-trader-session",
|
|
4296
4302
|
start: async () => {
|
|
@@ -4305,7 +4311,7 @@ Context compaction triggered. STATE.md synced from last persisted state. Decisio
|
|
|
4305
4311
|
`[solana-trader] Session initialization failed: ${err instanceof Error ? err.message : String(err)}`
|
|
4306
4312
|
);
|
|
4307
4313
|
api.logger.error(
|
|
4308
|
-
|
|
4314
|
+
`[solana-trader] Trading tools will fail until session is established. User should run on this machine: traderclaw login (after logout) or traderclaw setup / traderclaw signup for a new account. Wallet proof uses local signing only \u2014 private key never leaves this system. ${TRADERCLAW_MANAGED_INSTALL_LOGIN_HINT}`
|
|
4309
4315
|
);
|
|
4310
4316
|
return;
|
|
4311
4317
|
}
|
|
@@ -4352,11 +4358,25 @@ Context compaction triggered. STATE.md synced from last persisted state. Decisio
|
|
|
4352
4358
|
const WATCHDOG_INTERVAL_MS = 20 * 60 * 1e3;
|
|
4353
4359
|
const FORWARD_PROBE_WATCHDOG_MS = 7 * 60 * 1e3;
|
|
4354
4360
|
const STARTUP_GATE_AFTER_PROBE_FAIL_COOLDOWN_MS = 10 * 60 * 1e3;
|
|
4361
|
+
const GATEWAY_CRED_RATE_LIMIT_COOLDOWN_MS = 10 * 60 * 1e3;
|
|
4362
|
+
const GATEWAY_CRED_WARN_THROTTLE_MS = 6e4;
|
|
4363
|
+
let gatewayCredRateLimitBackoffUntilMs = 0;
|
|
4364
|
+
let gatewayCredWarnLastLoggedAtMs = 0;
|
|
4365
|
+
const throttleGatewayCredWarn = (msg) => {
|
|
4366
|
+
const t = Date.now();
|
|
4367
|
+
if (t - gatewayCredWarnLastLoggedAtMs < GATEWAY_CRED_WARN_THROTTLE_MS) return;
|
|
4368
|
+
gatewayCredWarnLastLoggedAtMs = t;
|
|
4369
|
+
api.logger.warn(msg);
|
|
4370
|
+
};
|
|
4371
|
+
if (solanaTraderSessionWatchdogTimer !== null) {
|
|
4372
|
+
clearInterval(solanaTraderSessionWatchdogTimer);
|
|
4373
|
+
solanaTraderSessionWatchdogTimer = null;
|
|
4374
|
+
}
|
|
4355
4375
|
let alphaStalePhase = 0;
|
|
4356
4376
|
const watchdogStartedAt = Date.now();
|
|
4357
4377
|
let lastForwardProbeWatchdogMs = watchdogStartedAt;
|
|
4358
4378
|
let lastProbeFailureStartupGateMs = watchdogStartedAt;
|
|
4359
|
-
|
|
4379
|
+
solanaTraderSessionWatchdogTimer = setInterval(async () => {
|
|
4360
4380
|
const now = Date.now();
|
|
4361
4381
|
if (!alphaStreamManager.isSubscribed()) {
|
|
4362
4382
|
alphaStalePhase = 0;
|
|
@@ -4394,14 +4414,25 @@ Context compaction triggered. STATE.md synced from last persisted state. Decisio
|
|
|
4394
4414
|
} else {
|
|
4395
4415
|
alphaStalePhase = 0;
|
|
4396
4416
|
}
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4417
|
+
if (now >= gatewayCredRateLimitBackoffUntilMs) {
|
|
4418
|
+
try {
|
|
4419
|
+
const creds = await get("/api/agents/gateway-credentials");
|
|
4420
|
+
gatewayCredRateLimitBackoffUntilMs = 0;
|
|
4421
|
+
if (!getActiveCredential(creds)) {
|
|
4422
|
+
api.logger.warn("[watchdog] Gateway credentials inactive \u2014 re-registering...");
|
|
4423
|
+
await runStartupGate({ autoFixGateway: true, force: true });
|
|
4424
|
+
}
|
|
4425
|
+
} catch (err) {
|
|
4426
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
4427
|
+
if (isOrchestratorRateLimitError(err)) {
|
|
4428
|
+
gatewayCredRateLimitBackoffUntilMs = now + GATEWAY_CRED_RATE_LIMIT_COOLDOWN_MS;
|
|
4429
|
+
throttleGatewayCredWarn(
|
|
4430
|
+
`[watchdog] Gateway credential check paused ${Math.round(GATEWAY_CRED_RATE_LIMIT_COOLDOWN_MS / 6e4)}m after orchestrator rate limit: ${detail}`
|
|
4431
|
+
);
|
|
4432
|
+
} else {
|
|
4433
|
+
throttleGatewayCredWarn(`[watchdog] Gateway credential check failed: ${detail}`);
|
|
4434
|
+
}
|
|
4402
4435
|
}
|
|
4403
|
-
} catch (err) {
|
|
4404
|
-
api.logger.warn(`[watchdog] Gateway credential check failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
4405
4436
|
}
|
|
4406
4437
|
if (now - lastForwardProbeWatchdogMs >= FORWARD_PROBE_WATCHDOG_MS) {
|
|
4407
4438
|
lastForwardProbeWatchdogMs = now;
|
|
@@ -4420,8 +4451,15 @@ Context compaction triggered. STATE.md synced from last persisted state. Decisio
|
|
|
4420
4451
|
}
|
|
4421
4452
|
}
|
|
4422
4453
|
}, WATCHDOG_INTERVAL_MS);
|
|
4423
|
-
if (
|
|
4424
|
-
|
|
4454
|
+
if (solanaTraderSessionWatchdogTimer && typeof solanaTraderSessionWatchdogTimer === "object" && "unref" in solanaTraderSessionWatchdogTimer) {
|
|
4455
|
+
solanaTraderSessionWatchdogTimer.unref();
|
|
4456
|
+
}
|
|
4457
|
+
},
|
|
4458
|
+
stop: async () => {
|
|
4459
|
+
if (solanaTraderSessionWatchdogTimer !== null) {
|
|
4460
|
+
clearInterval(solanaTraderSessionWatchdogTimer);
|
|
4461
|
+
solanaTraderSessionWatchdogTimer = null;
|
|
4462
|
+
api.logger.info("[solana-trader] Session health watchdog stopped");
|
|
4425
4463
|
}
|
|
4426
4464
|
}
|
|
4427
4465
|
});
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
SessionManager
|
|
3
|
-
|
|
2
|
+
SessionManager,
|
|
3
|
+
TRADERCLAW_MANAGED_INSTALL_CONSOLE_PANEL_URL,
|
|
4
|
+
TRADERCLAW_MANAGED_INSTALL_LOGIN_HINT
|
|
5
|
+
} from "../chunk-OKBHBUZ7.js";
|
|
4
6
|
export {
|
|
5
|
-
SessionManager
|
|
7
|
+
SessionManager,
|
|
8
|
+
TRADERCLAW_MANAGED_INSTALL_CONSOLE_PANEL_URL,
|
|
9
|
+
TRADERCLAW_MANAGED_INSTALL_LOGIN_HINT
|
|
6
10
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solana-traderclaw",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.140",
|
|
4
4
|
"description": "TraderClaw V1-Upgraded — Solana trading for OpenClaw with intelligence lab, tool envelopes, prompt scrubbing, read-only X social intel, and split skill docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|