@lingyao037/openclaw-lingyao-cli 0.9.7 → 0.9.8

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,4 +1,4 @@
1
- import { L as LingyaoRuntime, g as LingyaoAccount, c as DeviceToken, D as DeviceInfo } from './types-LFC6Wpqo.js';
1
+ import { L as LingyaoRuntime, g as LingyaoAccount, c as DeviceToken, D as DeviceInfo } from './types-D3SmE-b0.js';
2
2
 
3
3
  /**
4
4
  * Account storage and management
package/dist/cli.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { L as LingyaoRuntime, H as HealthStatus } from './types-LFC6Wpqo.js';
2
- import { A as AccountManager } from './accounts-BykE02r0.js';
1
+ import { L as LingyaoRuntime, H as HealthStatus } from './types-D3SmE-b0.js';
2
+ import { A as AccountManager } from './accounts-t-QtF58y.js';
3
3
 
4
4
  /**
5
5
  * Probe status levels
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { R as ResolvedAccount, L as LingyaoProbeResult } from './status-CVwSoPKi.js';
1
+ import { R as ResolvedAccount, L as LingyaoProbeResult } from './status-BaZOYVZY.js';
2
2
  import * as openclaw_plugin_sdk from 'openclaw/plugin-sdk';
3
3
  import { PluginRuntime, ChannelPlugin } from 'openclaw/plugin-sdk';
4
- import { L as LingyaoRuntime, S as SyncRequest, a as SyncResponse, b as LingyaoMessage, D as DeviceInfo, c as DeviceToken, d as LingyaoConfig, N as NotifyPayload, H as HealthStatus } from './types-LFC6Wpqo.js';
5
- export { A as AckRequest, e as DiarySyncPayload, F as FailedEntry, f as LINGYAO_SERVER_URL, g as LingyaoAccount, h as LingyaoAccountConfig, M as MemorySyncPayload, i as MessageType, j as NotifyAction, k as NotifyRequest, P as PairingCode, l as PairingConfirmRequest, m as PairingConfirmResponse, n as PollRequest, o as PollResponse, Q as QueuedMessage, T as TokenRefreshRequest, p as TokenRefreshResponse, W as WebSocketConnection, q as getLingyaoGatewayWsUrl } from './types-LFC6Wpqo.js';
6
- import { A as AccountManager } from './accounts-BykE02r0.js';
4
+ import { L as LingyaoRuntime, S as SyncRequest, a as SyncResponse, b as LingyaoMessage, D as DeviceInfo, c as DeviceToken, d as LingyaoConfig, N as NotifyPayload, H as HealthStatus } from './types-D3SmE-b0.js';
5
+ export { A as AckRequest, e as DiarySyncPayload, F as FailedEntry, f as LINGYAO_SERVER_URL, g as LingyaoAccount, h as LingyaoAccountConfig, M as MemorySyncPayload, i as MessageType, j as NotifyAction, k as NotifyRequest, P as PairingCode, l as PairingConfirmRequest, m as PairingConfirmResponse, n as PollRequest, o as PollResponse, Q as QueuedMessage, T as TokenRefreshRequest, p as TokenRefreshResponse, W as WebSocketConnection, q as getLingyaoGatewayWsUrl } from './types-D3SmE-b0.js';
6
+ import { A as AccountManager } from './accounts-t-QtF58y.js';
7
7
 
8
8
  /**
9
9
  * 灵爻服务器 HTTP 客户端
@@ -126,6 +126,10 @@ declare class ServerHttpClient {
126
126
  * 获取 Gateway Token
127
127
  */
128
128
  getGatewayToken(): string | null;
129
+ /**
130
+ * HTTP 注册/恢复后由 `serverConfig.heartbeatInterval` 写入(毫秒),用于与 WebSocket `gateway_heartbeat` 对齐。
131
+ */
132
+ getHeartbeatIntervalMs(): number;
129
133
  /**
130
134
  * 检查 Token 是否即将过期
131
135
  */
package/dist/index.js CHANGED
@@ -91,7 +91,8 @@ function extractAccounts(cfg) {
91
91
  allowFrom: Array.isArray(lingyao.allowFrom) ? lingyao.allowFrom : [],
92
92
  maxOfflineMessages: lingyao.maxOfflineMessages,
93
93
  tokenExpiryDays: lingyao.tokenExpiryDays,
94
- gatewayId: lingyao.gatewayId
94
+ gatewayId: lingyao.gatewayId,
95
+ websocketHeartbeatIntervalMs: lingyao.websocketHeartbeatIntervalMs
95
96
  };
96
97
  if (!accounts || Object.keys(accounts).length === 0) {
97
98
  return { default: baseConfig };
@@ -424,6 +425,25 @@ var MessageType = /* @__PURE__ */ ((MessageType2) => {
424
425
  return MessageType2;
425
426
  })(MessageType || {});
426
427
 
428
+ // src/ws-heartbeat-interval.ts
429
+ var MIN_MS = 5e3;
430
+ var MAX_MS = 55e3;
431
+ var FALLBACK_MS = 3e4;
432
+ function resolveLingyaoWsHeartbeatIntervalMs(account, httpClient) {
433
+ const fromServer = httpClient.getHeartbeatIntervalMs();
434
+ const fromCfg = account.rawConfig?.websocketHeartbeatIntervalMs;
435
+ let ms = typeof fromCfg === "number" && Number.isFinite(fromCfg) && fromCfg > 0 ? fromCfg : fromServer;
436
+ if (!Number.isFinite(ms) || ms <= 0) {
437
+ ms = FALLBACK_MS;
438
+ }
439
+ return Math.max(MIN_MS, Math.min(ms, MAX_MS));
440
+ }
441
+ function resolveLingyaoWsHeartbeatIntervalMsFromHttp(httpClient) {
442
+ const ms = httpClient.getHeartbeatIntervalMs();
443
+ const base = Number.isFinite(ms) && ms > 0 ? ms : FALLBACK_MS;
444
+ return Math.max(MIN_MS, Math.min(base, MAX_MS));
445
+ }
446
+
427
447
  // src/server-client.ts
428
448
  import axios from "axios";
429
449
  function isAxiosError(error) {
@@ -655,6 +675,12 @@ var ServerHttpClient = class {
655
675
  getGatewayToken() {
656
676
  return this.gatewayToken;
657
677
  }
678
+ /**
679
+ * HTTP 注册/恢复后由 `serverConfig.heartbeatInterval` 写入(毫秒),用于与 WebSocket `gateway_heartbeat` 对齐。
680
+ */
681
+ getHeartbeatIntervalMs() {
682
+ return this.heartbeatInterval > 0 ? this.heartbeatInterval : 3e4;
683
+ }
658
684
  /**
659
685
  * 检查 Token 是否即将过期
660
686
  */
@@ -2755,12 +2781,14 @@ var MultiAccountOrchestrator = class {
2755
2781
  messageProcessor.setMessageHandler(this.messageHandler);
2756
2782
  }
2757
2783
  await this.registerToServer(state);
2784
+ const wsHeartbeatMs = resolveLingyaoWsHeartbeatIntervalMs(account, httpClient);
2785
+ this.runtime.logger.info(`Lingyao WebSocket heartbeat interval: ${wsHeartbeatMs}ms (relay serverConfig / config)`);
2758
2786
  const wsClient = new LingyaoWSClient(this.runtime, {
2759
2787
  url: getLingyaoGatewayWsUrl(),
2760
2788
  gatewayId,
2761
2789
  token: httpClient.getGatewayToken() ?? void 0,
2762
2790
  reconnectInterval: 5e3,
2763
- heartbeatInterval: 3e4,
2791
+ heartbeatInterval: wsHeartbeatMs,
2764
2792
  messageHandler: this.createMessageHandler(state),
2765
2793
  eventHandler: this.createEventHandler(state)
2766
2794
  });
@@ -3249,8 +3277,7 @@ var LingyaoChannel = class {
3249
3277
  this.monitor = new Monitor(runtime);
3250
3278
  this.errorHandler = new ErrorHandler(runtime);
3251
3279
  this.serverClient = new ServerHttpClient(runtime, this.gatewayId, {
3252
- baseURL: LINGYAO_SERVER_URL,
3253
- apiBase: "/v1"
3280
+ baseURL: LINGYAO_SERVER_URL
3254
3281
  });
3255
3282
  }
3256
3283
  /**
@@ -3280,12 +3307,13 @@ var LingyaoChannel = class {
3280
3307
  this.runtime.logger.info("Starting Lingyao Channel...");
3281
3308
  try {
3282
3309
  await this.registerToServer();
3310
+ const wsHeartbeatMs = this.serverClient ? resolveLingyaoWsHeartbeatIntervalMsFromHttp(this.serverClient) : 3e4;
3283
3311
  this.wsClient = new LingyaoWSClient(this.runtime, {
3284
3312
  url: getLingyaoGatewayWsUrl(),
3285
3313
  gatewayId: this.gatewayId,
3286
3314
  token: this.serverClient?.getGatewayToken() ?? void 0,
3287
3315
  reconnectInterval: 5e3,
3288
- heartbeatInterval: 3e4,
3316
+ heartbeatInterval: wsHeartbeatMs,
3289
3317
  messageHandler: this.handleAppMessage.bind(this),
3290
3318
  eventHandler: this.handleClientEvent.bind(this)
3291
3319
  });
@@ -3632,7 +3660,8 @@ var lingyaoAccountConfigSchema = z.object({
3632
3660
  allowFrom: allowFromSchema,
3633
3661
  maxOfflineMessages: z.number().int().min(1).max(1e3).optional(),
3634
3662
  tokenExpiryDays: z.number().int().min(1).max(365).optional(),
3635
- gatewayId: z.string().min(1).optional()
3663
+ gatewayId: z.string().min(1).optional(),
3664
+ websocketHeartbeatIntervalMs: z.number().int().min(5e3).max(12e4).optional()
3636
3665
  });
3637
3666
  var lingyaoConfigSchema = z.object({
3638
3667
  enabled: z.boolean().default(true),
@@ -3640,6 +3669,7 @@ var lingyaoConfigSchema = z.object({
3640
3669
  allowFrom: allowFromSchema.default([]),
3641
3670
  maxOfflineMessages: z.number().int().min(1).max(1e3).optional().default(100),
3642
3671
  tokenExpiryDays: z.number().int().min(1).max(365).optional().default(30),
3672
+ websocketHeartbeatIntervalMs: z.number().int().min(5e3).max(12e4).optional(),
3643
3673
  defaultAccount: z.string().min(1).optional(),
3644
3674
  accounts: z.record(lingyaoAccountConfigSchema).optional()
3645
3675
  });
@@ -3677,6 +3707,12 @@ var lingyaoChannelConfigSchema = {
3677
3707
  defaultAccount: {
3678
3708
  type: "string"
3679
3709
  },
3710
+ websocketHeartbeatIntervalMs: {
3711
+ type: "integer",
3712
+ minimum: 5e3,
3713
+ maximum: 12e4,
3714
+ description: "WebSocket gateway_heartbeat interval in ms (default: server register response). Use 5000\u201355000 for typical relay timeout."
3715
+ },
3680
3716
  accounts: {
3681
3717
  type: "object",
3682
3718
  additionalProperties: {
@@ -3706,6 +3742,11 @@ var lingyaoChannelConfigSchema = {
3706
3742
  },
3707
3743
  gatewayId: {
3708
3744
  type: "string"
3745
+ },
3746
+ websocketHeartbeatIntervalMs: {
3747
+ type: "integer",
3748
+ minimum: 5e3,
3749
+ maximum: 12e4
3709
3750
  }
3710
3751
  }
3711
3752
  },
@@ -3824,7 +3865,7 @@ async function createPlugin(runtime, config = {}) {
3824
3865
  }
3825
3866
  var pluginMetadata = {
3826
3867
  name: "lingyao",
3827
- version: "0.9.7",
3868
+ version: "0.9.8",
3828
3869
  description: "Lingyao Channel Plugin - bidirectional sync via lingyao.live server relay",
3829
3870
  type: "channel",
3830
3871
  capabilities: {