solana-traderclaw 1.0.138 → 1.0.139
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/dist/index.js +47 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -838,6 +838,10 @@ function parseConfig(raw) {
|
|
|
838
838
|
kaybaFolder
|
|
839
839
|
};
|
|
840
840
|
}
|
|
841
|
+
function isOrchestratorRateLimitError(err) {
|
|
842
|
+
const m = err instanceof Error ? err.message : String(err);
|
|
843
|
+
return /\bRATE_LIMIT\b|(^|[\s:])429([\s:]|$)|rate\s+limit\s+exceeded/i.test(m);
|
|
844
|
+
}
|
|
841
845
|
function buildTraderClawWelcomeMessage(apiKeyForDisplay) {
|
|
842
846
|
const keyBlock = apiKeyForDisplay ? `Your TraderClaw API Key:
|
|
843
847
|
|
|
@@ -4291,6 +4295,7 @@ Context compaction triggered. STATE.md synced from last persisted state. Decisio
|
|
|
4291
4295
|
description: "Sync STATE.md and append memory-flush entry to daily log before context compaction."
|
|
4292
4296
|
}
|
|
4293
4297
|
);
|
|
4298
|
+
let solanaTraderSessionWatchdogTimer = null;
|
|
4294
4299
|
api.registerService({
|
|
4295
4300
|
id: "solana-trader-session",
|
|
4296
4301
|
start: async () => {
|
|
@@ -4352,11 +4357,25 @@ Context compaction triggered. STATE.md synced from last persisted state. Decisio
|
|
|
4352
4357
|
const WATCHDOG_INTERVAL_MS = 20 * 60 * 1e3;
|
|
4353
4358
|
const FORWARD_PROBE_WATCHDOG_MS = 7 * 60 * 1e3;
|
|
4354
4359
|
const STARTUP_GATE_AFTER_PROBE_FAIL_COOLDOWN_MS = 10 * 60 * 1e3;
|
|
4360
|
+
const GATEWAY_CRED_RATE_LIMIT_COOLDOWN_MS = 10 * 60 * 1e3;
|
|
4361
|
+
const GATEWAY_CRED_WARN_THROTTLE_MS = 6e4;
|
|
4362
|
+
let gatewayCredRateLimitBackoffUntilMs = 0;
|
|
4363
|
+
let gatewayCredWarnLastLoggedAtMs = 0;
|
|
4364
|
+
const throttleGatewayCredWarn = (msg) => {
|
|
4365
|
+
const t = Date.now();
|
|
4366
|
+
if (t - gatewayCredWarnLastLoggedAtMs < GATEWAY_CRED_WARN_THROTTLE_MS) return;
|
|
4367
|
+
gatewayCredWarnLastLoggedAtMs = t;
|
|
4368
|
+
api.logger.warn(msg);
|
|
4369
|
+
};
|
|
4370
|
+
if (solanaTraderSessionWatchdogTimer !== null) {
|
|
4371
|
+
clearInterval(solanaTraderSessionWatchdogTimer);
|
|
4372
|
+
solanaTraderSessionWatchdogTimer = null;
|
|
4373
|
+
}
|
|
4355
4374
|
let alphaStalePhase = 0;
|
|
4356
4375
|
const watchdogStartedAt = Date.now();
|
|
4357
4376
|
let lastForwardProbeWatchdogMs = watchdogStartedAt;
|
|
4358
4377
|
let lastProbeFailureStartupGateMs = watchdogStartedAt;
|
|
4359
|
-
|
|
4378
|
+
solanaTraderSessionWatchdogTimer = setInterval(async () => {
|
|
4360
4379
|
const now = Date.now();
|
|
4361
4380
|
if (!alphaStreamManager.isSubscribed()) {
|
|
4362
4381
|
alphaStalePhase = 0;
|
|
@@ -4394,14 +4413,25 @@ Context compaction triggered. STATE.md synced from last persisted state. Decisio
|
|
|
4394
4413
|
} else {
|
|
4395
4414
|
alphaStalePhase = 0;
|
|
4396
4415
|
}
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4416
|
+
if (now >= gatewayCredRateLimitBackoffUntilMs) {
|
|
4417
|
+
try {
|
|
4418
|
+
const creds = await get("/api/agents/gateway-credentials");
|
|
4419
|
+
gatewayCredRateLimitBackoffUntilMs = 0;
|
|
4420
|
+
if (!getActiveCredential(creds)) {
|
|
4421
|
+
api.logger.warn("[watchdog] Gateway credentials inactive \u2014 re-registering...");
|
|
4422
|
+
await runStartupGate({ autoFixGateway: true, force: true });
|
|
4423
|
+
}
|
|
4424
|
+
} catch (err) {
|
|
4425
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
4426
|
+
if (isOrchestratorRateLimitError(err)) {
|
|
4427
|
+
gatewayCredRateLimitBackoffUntilMs = now + GATEWAY_CRED_RATE_LIMIT_COOLDOWN_MS;
|
|
4428
|
+
throttleGatewayCredWarn(
|
|
4429
|
+
`[watchdog] Gateway credential check paused ${Math.round(GATEWAY_CRED_RATE_LIMIT_COOLDOWN_MS / 6e4)}m after orchestrator rate limit: ${detail}`
|
|
4430
|
+
);
|
|
4431
|
+
} else {
|
|
4432
|
+
throttleGatewayCredWarn(`[watchdog] Gateway credential check failed: ${detail}`);
|
|
4433
|
+
}
|
|
4402
4434
|
}
|
|
4403
|
-
} catch (err) {
|
|
4404
|
-
api.logger.warn(`[watchdog] Gateway credential check failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
4405
4435
|
}
|
|
4406
4436
|
if (now - lastForwardProbeWatchdogMs >= FORWARD_PROBE_WATCHDOG_MS) {
|
|
4407
4437
|
lastForwardProbeWatchdogMs = now;
|
|
@@ -4420,8 +4450,15 @@ Context compaction triggered. STATE.md synced from last persisted state. Decisio
|
|
|
4420
4450
|
}
|
|
4421
4451
|
}
|
|
4422
4452
|
}, WATCHDOG_INTERVAL_MS);
|
|
4423
|
-
if (
|
|
4424
|
-
|
|
4453
|
+
if (solanaTraderSessionWatchdogTimer && typeof solanaTraderSessionWatchdogTimer === "object" && "unref" in solanaTraderSessionWatchdogTimer) {
|
|
4454
|
+
solanaTraderSessionWatchdogTimer.unref();
|
|
4455
|
+
}
|
|
4456
|
+
},
|
|
4457
|
+
stop: async () => {
|
|
4458
|
+
if (solanaTraderSessionWatchdogTimer !== null) {
|
|
4459
|
+
clearInterval(solanaTraderSessionWatchdogTimer);
|
|
4460
|
+
solanaTraderSessionWatchdogTimer = null;
|
|
4461
|
+
api.logger.info("[solana-trader] Session health watchdog stopped");
|
|
4425
4462
|
}
|
|
4426
4463
|
}
|
|
4427
4464
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solana-traderclaw",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.139",
|
|
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",
|