openclaw-quiubo 2.6.31 → 2.6.32

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 CHANGED
@@ -12498,11 +12498,13 @@ var RealtimeGateway = class {
12498
12498
  onRequest;
12499
12499
  onCacheMiss;
12500
12500
  pollIntervalMs;
12501
+ slowPollIntervalMs;
12501
12502
  log;
12502
12503
  // Pusher state
12503
12504
  pusherClient = null;
12504
12505
  pusherConfig;
12505
12506
  pusherConnected = false;
12507
+ pusherConnectedSince = null;
12506
12508
  // Polling state (fallback)
12507
12509
  pollTimer = null;
12508
12510
  polling = false;
@@ -12545,6 +12547,7 @@ var RealtimeGateway = class {
12545
12547
  this.cursorsFile = join(CURSORS_DIR, `quiubo-cursors-${opts.accountId}.json`);
12546
12548
  this.pusherConfig = opts.pusher ?? null;
12547
12549
  this.pollIntervalMs = opts.pollIntervalMs ?? 5e3;
12550
+ this.slowPollIntervalMs = opts.slowPollIntervalMs ?? 15e3;
12548
12551
  this.onMessage = opts.onMessage;
12549
12552
  this.onRequest = opts.onRequest;
12550
12553
  this.onCacheMiss = opts.onCacheMiss;
@@ -12781,20 +12784,29 @@ var RealtimeGateway = class {
12781
12784
  });
12782
12785
  this.pusherClient.connection.bind("connected", () => {
12783
12786
  this.pusherConnected = true;
12784
- log.info?.("Pusher connected (polling continues as safety net)");
12787
+ this.pusherConnectedSince = Date.now();
12788
+ log.info?.("Pusher connected \u2014 polling slows to adaptive interval after 30s stability");
12785
12789
  if (this.agentId) this.startHeartbeat();
12786
12790
  });
12787
12791
  this.pusherClient.connection.bind("disconnected", () => {
12788
12792
  this.pusherConnected = false;
12793
+ this.pusherConnectedSince = null;
12789
12794
  this.stopHeartbeat();
12790
- log.warn?.("Pusher disconnected \u2014 falling back to polling");
12791
- if (!this.stopped) this.startPolling();
12795
+ log.warn?.("Pusher disconnected \u2014 resuming fast polling");
12796
+ if (!this.stopped) {
12797
+ this.stopPolling();
12798
+ this.startPolling();
12799
+ }
12792
12800
  });
12793
12801
  this.pusherClient.connection.bind("unavailable", () => {
12794
12802
  this.pusherConnected = false;
12803
+ this.pusherConnectedSince = null;
12795
12804
  this.stopHeartbeat();
12796
- log.warn?.("Pusher unavailable \u2014 falling back to polling");
12797
- if (!this.stopped) this.startPolling();
12805
+ log.warn?.("Pusher unavailable \u2014 resuming fast polling");
12806
+ if (!this.stopped) {
12807
+ this.stopPolling();
12808
+ this.startPolling();
12809
+ }
12798
12810
  });
12799
12811
  this.pusherClient.connection.bind("error", (error) => {
12800
12812
  log.error?.("Pusher error:", error);
@@ -13011,6 +13023,7 @@ var RealtimeGateway = class {
13011
13023
  this.pusherClient.disconnect();
13012
13024
  this.pusherClient = null;
13013
13025
  this.pusherConnected = false;
13026
+ this.pusherConnectedSince = null;
13014
13027
  }
13015
13028
  }
13016
13029
  // ── Polling (fallback) ──────────────────────────────────────────
@@ -13019,20 +13032,35 @@ var RealtimeGateway = class {
13019
13032
  this.log.info?.(`Polling started: interval=${this.pollIntervalMs}ms`);
13020
13033
  this.schedulePoll();
13021
13034
  }
13035
+ // Track last poll mode for transition logging
13036
+ lastPollMode = null;
13022
13037
  /** Schedule the next poll with backoff-aware delay */
13023
13038
  schedulePoll() {
13024
13039
  if (this.stopped || this.pollTimer) return;
13025
13040
  const delay = this.getBackoffDelay();
13041
+ const currentMode = delay >= this.slowPollIntervalMs ? "slow" : "fast";
13042
+ if (this.lastPollMode !== null && this.lastPollMode !== currentMode) {
13043
+ this.log.info?.(`Adaptive polling: ${this.lastPollMode} \u2192 ${currentMode} (interval=${delay}ms)`);
13044
+ }
13045
+ this.lastPollMode = currentMode;
13026
13046
  this.pollTimer = setTimeout(async () => {
13027
13047
  this.pollTimer = null;
13028
13048
  await this.poll();
13029
13049
  if (!this.stopped) this.schedulePoll();
13030
13050
  }, delay);
13031
13051
  }
13032
- /** Get poll delay: base interval * 2^errors, capped at MAX_BACKOFF_MS */
13052
+ /** Get adaptive poll interval: slow when Pusher is stably connected (30s+), fast otherwise */
13053
+ getAdaptivePollInterval() {
13054
+ if (this.pusherConnected && this.pusherConnectedSince !== null && Date.now() - this.pusherConnectedSince > 3e4) {
13055
+ return this.slowPollIntervalMs;
13056
+ }
13057
+ return this.pollIntervalMs;
13058
+ }
13059
+ /** Get poll delay: adaptive base interval * 2^errors, capped at MAX_BACKOFF_MS */
13033
13060
  getBackoffDelay() {
13034
- if (this.consecutivePollErrors === 0) return this.pollIntervalMs;
13035
- const backoff = this.pollIntervalMs * Math.pow(2, Math.min(this.consecutivePollErrors, 6));
13061
+ const base = this.getAdaptivePollInterval();
13062
+ if (this.consecutivePollErrors === 0) return base;
13063
+ const backoff = base * Math.pow(2, Math.min(this.consecutivePollErrors, 6));
13036
13064
  return Math.min(backoff, this.MAX_BACKOFF_MS);
13037
13065
  }
13038
13066
  stopPolling() {
@@ -13828,7 +13856,7 @@ var quiuboPlugin = {
13828
13856
  gateways.delete(accountId);
13829
13857
  }
13830
13858
  const apiUrl = quiuboConfig.apiUrl ?? DEFAULT_API_URL;
13831
- const { apiKey, botIdentityId, pollIntervalMs } = quiuboConfig;
13859
+ const { apiKey, botIdentityId, pollIntervalMs, slowPollIntervalMs } = quiuboConfig;
13832
13860
  const runtime2 = getQuiuboRuntime();
13833
13861
  const client = new QuiuboApiClient(apiUrl, apiKey);
13834
13862
  clients.set(accountId, client);
@@ -13983,6 +14011,7 @@ var quiuboPlugin = {
13983
14011
  accountId,
13984
14012
  pusher: pusherConfig,
13985
14013
  pollIntervalMs: pollIntervalMs ?? 5e3,
14014
+ slowPollIntervalMs: slowPollIntervalMs ?? 15e3,
13986
14015
  log: gatewayLog,
13987
14016
  agentId: resolvedAgentId,
13988
14017
  keyManager,