solana-traderclaw 1.0.113 → 1.0.115

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.
@@ -317,7 +317,7 @@ var SessionManager = class {
317
317
  this.log.info(`[session] Session refreshed. Tier: ${this.tier}, Scopes: ${this.scopes.join(", ")}`);
318
318
  return;
319
319
  } catch (err) {
320
- this.log.warn(`[session] Refresh failed: ${err.message}. Falling back to challenge flow.`);
320
+ this.log.warn(`[session] Refresh failed: ${err.message}. Trying recovery secret, then challenge flow.`);
321
321
  }
322
322
  }
323
323
  if (!this.apiKey) {
@@ -450,12 +450,18 @@ var SessionManager = class {
450
450
  * Schedule a repeating background token refresh. Uses setInterval so the
451
451
  * chain cannot silently break if a single cycle fails to re-schedule.
452
452
  *
453
- * Interval = min(50% refresh-token TTL, accessTokenTtl - 2.5 min buffer),
453
+ * Interval = min(50% refresh-token TTL, 60% of access-token TTL),
454
454
  * clamped between 2 min and 20 min. Falls back to 10 min when TTLs unknown.
455
+ * Using 60% of access TTL (vs the old "TTL - 2.5 min") gives a much larger
456
+ * safety window — for a 15-min token the interval is 9 min, leaving 6 min
457
+ * of runway before expiry instead of the former 2.5 min.
455
458
  *
456
459
  * Goes through unifiedRefresh() so it shares the same mutex as on-demand
457
- * callers and can fall back to the full challenge flow when refresh tokens
458
- * are permanently revoked.
460
+ * callers and can fall back to the full challenge/recovery flow when refresh
461
+ * tokens are permanently revoked.
462
+ *
463
+ * On failure a one-shot 60-second retry is scheduled so a transient network
464
+ * hiccup does not leave the token to expire silently between setInterval ticks.
459
465
  */
460
466
  scheduleProactiveRefresh() {
461
467
  if (this.proactiveRefreshTimer) {
@@ -465,6 +471,7 @@ var SessionManager = class {
465
471
  const MIN_INTERVAL_MS = 2 * 60 * 1e3;
466
472
  const MAX_INTERVAL_MS = 20 * 60 * 1e3;
467
473
  const DEFAULT_INTERVAL_MS = 10 * 60 * 1e3;
474
+ const RETRY_ON_FAILURE_MS = 60 * 1e3;
468
475
  let intervalMs;
469
476
  if (this.refreshTokenTtlMs > 0) {
470
477
  intervalMs = Math.max(MIN_INTERVAL_MS, Math.min(this.refreshTokenTtlMs * 0.5, MAX_INTERVAL_MS));
@@ -472,7 +479,7 @@ var SessionManager = class {
472
479
  intervalMs = DEFAULT_INTERVAL_MS;
473
480
  }
474
481
  if (this.accessTokenTtlMs > 0) {
475
- const accessBasedMs = Math.max(MIN_INTERVAL_MS, this.accessTokenTtlMs - 15e4);
482
+ const accessBasedMs = Math.max(MIN_INTERVAL_MS, Math.floor(this.accessTokenTtlMs * 0.6));
476
483
  intervalMs = Math.min(intervalMs, accessBasedMs);
477
484
  }
478
485
  this.log.info(`[session] Proactive refresh scheduled every ${Math.round(intervalMs / 1e3)}s`);
@@ -484,7 +491,17 @@ var SessionManager = class {
484
491
  await this.unifiedRefresh();
485
492
  this.log.info("[session] Proactive refresh succeeded \u2014 token chain extended.");
486
493
  } catch (err) {
487
- this.log.warn(`[session] Proactive refresh failed: ${err.message}. Will retry next interval or on-demand.`);
494
+ this.log.warn(
495
+ `[session] Proactive refresh failed: ${err.message}. Scheduling retry in ${RETRY_ON_FAILURE_MS / 1e3}s.`
496
+ );
497
+ const retryTimer = setTimeout(() => {
498
+ this.unifiedRefresh().catch(
499
+ (retryErr) => this.log.warn(`[session] Proactive retry also failed: ${retryErr.message}. On-demand path will recover.`)
500
+ );
501
+ }, RETRY_ON_FAILURE_MS);
502
+ if (retryTimer && typeof retryTimer === "object" && "unref" in retryTimer) {
503
+ retryTimer.unref();
504
+ }
488
505
  } finally {
489
506
  this.proactiveRefreshRunning = false;
490
507
  }
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-SBYHSJLU.js";
4
4
  import {
5
5
  SessionManager
6
- } from "./chunk-OXQX7Y2B.js";
6
+ } from "./chunk-6IS5XPDB.js";
7
7
  import {
8
8
  looksLikeTelegramChatId,
9
9
  resolveTelegramRecipientToChatId
@@ -1005,12 +1005,13 @@ var solanaTraderPlugin = {
1005
1005
  onTokensRotated: (tokens) => {
1006
1006
  try {
1007
1007
  const current = readSessionSidecar() ?? {};
1008
+ const walletEntry = tokens.walletPublicKey != null ? { walletPublicKey: tokens.walletPublicKey } : {};
1008
1009
  writeSessionSidecarAtomic({
1009
1010
  ...current,
1010
1011
  refreshToken: tokens.refreshToken,
1011
1012
  accessToken: tokens.accessToken,
1012
1013
  accessTokenExpiresAt: tokens.accessTokenExpiresAt,
1013
- walletPublicKey: tokens.walletPublicKey
1014
+ ...walletEntry
1014
1015
  });
1015
1016
  api.logger.info(`[solana-trader] Persisted session tokens to ${sessionTokensPath}`);
1016
1017
  } catch (err) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SessionManager
3
- } from "../chunk-OXQX7Y2B.js";
3
+ } from "../chunk-6IS5XPDB.js";
4
4
  export {
5
5
  SessionManager
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solana-traderclaw",
3
- "version": "1.0.113",
3
+ "version": "1.0.115",
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",