@lingyao037/openclaw-lingyao-cli 0.9.4 → 0.9.5

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.d.ts CHANGED
@@ -1,285 +1,9 @@
1
+ import { R as ResolvedAccount, L as LingyaoProbeResult } from './status-DdIuhIHE.js';
2
+ import * as openclaw_plugin_sdk from 'openclaw/plugin-sdk';
1
3
  import { PluginRuntime, ChannelPlugin } from 'openclaw/plugin-sdk';
2
- import { a as LingyaoAccountConfig, L as LingyaoRuntime, D as DeviceInfo, b as DeviceToken, A as AccountManager, S as SyncRequest, c as SyncResponse, d as LingyaoMessage, e as LingyaoConfig, N as NotifyPayload, H as HealthStatus } from './accounts-B9ijYIIu.js';
3
- export { f as AckRequest, g as DiarySyncPayload, F as FailedEntry, h as LINGYAO_SERVER_URL, i as LingyaoAccount, M as MemorySyncPayload, j as MessageType, k as NotifyAction, l as NotifyRequest, P as PairingCode, m as PairingConfirmRequest, n as PairingConfirmResponse, o as PollRequest, p as PollResponse, Q as QueuedMessage, T as TokenRefreshRequest, q as TokenRefreshResponse, W as WebSocketConnection } from './accounts-B9ijYIIu.js';
4
-
5
- /**
6
- * Config Adapter - Account resolution, config validation
7
- *
8
- * serverUrl is NOT exposed to users — hardcoded as LINGYAO_SERVER_URL.
9
- */
10
-
11
- /**
12
- * Resolved account after config resolution.
13
- */
14
- interface ResolvedAccount {
15
- readonly id: string;
16
- readonly accountId?: string | null;
17
- readonly enabled: boolean;
18
- readonly dmPolicy: 'paired' | 'open' | 'deny';
19
- readonly allowFrom: string[];
20
- readonly gatewayId?: string;
21
- readonly rawConfig: LingyaoAccountConfig;
22
- }
23
-
24
- /**
25
- * 错误处理模块
26
- */
27
-
28
- /**
29
- * 错误严重级别
30
- */
31
- declare enum ErrorSeverity {
32
- LOW = "low",
33
- MEDIUM = "medium",
34
- HIGH = "high",
35
- CRITICAL = "critical"
36
- }
37
- /**
38
- * Lingyao 错误基类
39
- */
40
- declare class LingyaoError extends Error {
41
- readonly code: string;
42
- readonly severity: ErrorSeverity;
43
- readonly timestamp: number;
44
- readonly context?: Record<string, unknown>;
45
- readonly cause?: Error;
46
- constructor(message: string, code: string, severity?: ErrorSeverity, context?: Record<string, unknown>, cause?: Error);
47
- /**
48
- * 转换为 JSON 可序列化格式
49
- */
50
- toJSON(): Record<string, unknown>;
51
- }
52
- /**
53
- * 错误处理器
54
- */
55
- declare class ErrorHandler {
56
- private runtime;
57
- private errorCounts;
58
- private lastErrors;
59
- private errorThresholds;
60
- private cleanupTimer;
61
- private errorTimestamps;
62
- constructor(runtime: LingyaoRuntime);
63
- destroy(): void;
64
- private cleanupOldErrors;
65
- /**
66
- * 处理错误
67
- */
68
- handleError(error: Error | LingyaoError): void;
69
- /**
70
- * 记录错误
71
- */
72
- private recordError;
73
- /**
74
- * 检查错误阈值
75
- */
76
- private checkThresholds;
77
- /**
78
- * 触发警报
79
- */
80
- private triggerAlert;
81
- /**
82
- * 设置错误阈值
83
- */
84
- setErrorThreshold(code: string, threshold: {
85
- count: number;
86
- window: number;
87
- }): void;
88
- /**
89
- * 获取错误统计
90
- */
91
- getErrorStats(): {
92
- byCode: Record<string, number>;
93
- total: number;
94
- recent: Array<{
95
- code: string;
96
- error: LingyaoError;
97
- timestamp: number;
98
- }>;
99
- };
100
- /**
101
- * 重置错误计数
102
- */
103
- resetErrorCounts(code?: string): void;
104
- /**
105
- * 包装异步函数以自动处理错误
106
- */
107
- wrapAsync<T>(fn: () => Promise<T>, context?: {
108
- operation?: string;
109
- fallback?: T;
110
- retryable?: boolean;
111
- }): Promise<T>;
112
- /**
113
- * 创建带有错误处理的重试逻辑
114
- */
115
- retry<T>(fn: () => Promise<T>, options?: {
116
- maxRetries?: number;
117
- retryDelay?: number;
118
- backoff?: boolean;
119
- onRetry?: (error: Error, attempt: number) => void;
120
- }): Promise<T>;
121
- /**
122
- * 判断错误是否可重试
123
- */
124
- isRetryable(error: Error): boolean;
125
- /**
126
- * 判断错误是否需要降级处理
127
- */
128
- shouldDegrade(error: Error): boolean;
129
- /**
130
- * 创建降级响应
131
- */
132
- createDegradedResponse<T>(fallback: T, error?: Error): {
133
- success: false;
134
- degraded: true;
135
- fallback: T;
136
- error?: Error;
137
- };
138
- }
139
-
140
- /**
141
- * Token management utilities
142
- */
143
- declare class TokenManager {
144
- constructor(_runtime: LingyaoRuntime);
145
- /**
146
- * Generate a new device token
147
- */
148
- generateDeviceToken(pairingId: string, deviceInfo: DeviceInfo, expiryDays?: number): DeviceToken;
149
- /**
150
- * Validate a device token
151
- */
152
- validateToken(token: string, storedSecret: string): boolean;
153
- /**
154
- * Check if token is expired
155
- */
156
- isTokenExpired(token: DeviceToken): boolean;
157
- /**
158
- * Refresh an existing token
159
- */
160
- refreshToken(oldToken: DeviceToken, expiryDays?: number): DeviceToken;
161
- /**
162
- * Extract device ID from token string
163
- */
164
- extractDeviceId(token: string): string | null;
165
- /**
166
- * Generate a unique device ID
167
- */
168
- private generateDeviceId;
169
- /**
170
- * Generate a random secret key
171
- */
172
- private generateSecret;
173
- /**
174
- * Generate a JWT-like token string
175
- */
176
- private generateTokenString;
177
- /**
178
- * Sign data with secret
179
- */
180
- private sign;
181
- /**
182
- * Base64URL encode without padding
183
- */
184
- private base64UrlEncode;
185
- }
186
-
187
- /**
188
- * Agent message format - messages passed directly to Agent
189
- */
190
- interface AgentMessage {
191
- id: string;
192
- type: "diary" | "memory" | "heartbeat";
193
- from: string;
194
- deviceId: string;
195
- content: string;
196
- metadata: Record<string, unknown>;
197
- timestamp: number;
198
- }
199
- /**
200
- * Message handler callback for delivering messages to Agent
201
- */
202
- type MessageHandler = (message: AgentMessage) => void | Promise<void>;
203
- /**
204
- * Message Processor - Handles incoming messages and routes them to Agent
205
- */
206
- declare class MessageProcessor {
207
- private runtime;
208
- private accountManager;
209
- private messageQueue;
210
- private seenMessages;
211
- private messageHandler;
212
- private readonly maxQueueSize;
213
- constructor(runtime: LingyaoRuntime, accountManager: AccountManager);
214
- /**
215
- * Initialize the message processor
216
- */
217
- initialize(): Promise<void>;
218
- /**
219
- * Set the message handler for delivering messages to Agent
220
- */
221
- setMessageHandler(handler: MessageHandler): void;
222
- /**
223
- * Get the currently registered Agent message handler.
224
- */
225
- getMessageHandler(): MessageHandler | null;
226
- /**
227
- * Deliver a normalized message directly to the registered Agent handler.
228
- */
229
- deliverToAgent(message: AgentMessage): Promise<void>;
230
- /**
231
- * Process sync request from app
232
- */
233
- processSync(deviceId: string, request: SyncRequest): Promise<SyncResponse>;
234
- /**
235
- * Process a single message
236
- */
237
- private processMessage;
238
- /**
239
- * Process diary sync - Pass directly to Agent
240
- */
241
- private processDiarySync;
242
- /**
243
- * Process memory sync - Pass directly to Agent
244
- */
245
- private processMemorySync;
246
- /**
247
- * Process sync acknowledgment
248
- */
249
- private processSyncAck;
250
- /**
251
- * Process heartbeat
252
- */
253
- private processHeartbeat;
254
- /**
255
- * Poll for new messages (long-polling)
256
- */
257
- pollMessages(deviceId: string, timeout?: number): Promise<LingyaoMessage[]>;
258
- /**
259
- * Queue a message for a device
260
- */
261
- queueMessage(deviceId: string, message: LingyaoMessage): boolean;
262
- /**
263
- * Acknowledge messages
264
- */
265
- acknowledgeMessages(messageIds: string[]): Promise<void>;
266
- /**
267
- * Check if message has been seen (deduplication)
268
- */
269
- private isMessageSeen;
270
- /**
271
- * Mark message as seen
272
- */
273
- private markMessageSeen;
274
- /**
275
- * Get queue size for a device
276
- */
277
- getQueueSize(deviceId: string): number;
278
- /**
279
- * Get total queue size
280
- */
281
- getTotalQueueSize(): number;
282
- }
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-Zbv12l39.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 } from './types-Zbv12l39.js';
6
+ import { A as AccountManager } from './accounts-CzjBLXMH.js';
283
7
 
284
8
  /**
285
9
  * 灵爻服务器 HTTP 客户端
@@ -587,73 +311,170 @@ declare class LingyaoWSClient {
587
311
  */
588
312
  private stopHeartbeat;
589
313
  /**
590
- * 安排重连
314
+ * 安排重连
315
+ */
316
+ private scheduleReconnect;
317
+ /**
318
+ * 发送消息到服务器
319
+ */
320
+ send(message: WSMessage): void;
321
+ /**
322
+ * 发送通知到鸿蒙 App
323
+ */
324
+ sendNotification(deviceId: string, notification: any): void;
325
+ /**
326
+ * 处理 App 消息
327
+ */
328
+ private handleAppMessage;
329
+ /**
330
+ * 处理消息发送成功
331
+ */
332
+ private handleMessageDelivered;
333
+ /**
334
+ * 处理配对完成通知(来自 lingyao.live 服务器)
335
+ */
336
+ private handlePairingCompleted;
337
+ /**
338
+ * 处理消息发送失败
339
+ */
340
+ private handleMessageFailed;
341
+ /**
342
+ * 处理服务器错误
343
+ */
344
+ private handleError;
345
+ /**
346
+ * 注册消息处理器
347
+ */
348
+ registerMessageHandler(type: string, handler: (message: WSMessage) => void): void;
349
+ /**
350
+ * 发送事件
351
+ */
352
+ private emitEvent;
353
+ /**
354
+ * 更新 WebSocket 连接使用的 token
355
+ */
356
+ updateToken(token: string): void;
357
+ /**
358
+ * 断开连接
359
+ */
360
+ disconnect(): void;
361
+ /**
362
+ * 获取连接状态
363
+ */
364
+ getState(): ConnectionState;
365
+ /**
366
+ * 获取连接 ID
367
+ */
368
+ getConnectionId(): string | null;
369
+ /**
370
+ * 是否已连接
371
+ */
372
+ isConnected(): boolean;
373
+ /**
374
+ * 生成消息 ID
375
+ */
376
+ private generateMessageId;
377
+ /**
378
+ * 生成连接 ID
379
+ */
380
+ private generateConnectionId;
381
+ }
382
+
383
+ /**
384
+ * Agent message format - messages passed directly to Agent
385
+ */
386
+ interface AgentMessage {
387
+ id: string;
388
+ type: "diary" | "memory" | "heartbeat";
389
+ from: string;
390
+ deviceId: string;
391
+ content: string;
392
+ metadata: Record<string, unknown>;
393
+ timestamp: number;
394
+ }
395
+ /**
396
+ * Message handler callback for delivering messages to Agent
397
+ */
398
+ type MessageHandler = (message: AgentMessage) => void | Promise<void>;
399
+ /**
400
+ * Message Processor - Handles incoming messages and routes them to Agent
401
+ */
402
+ declare class MessageProcessor {
403
+ private runtime;
404
+ private accountManager;
405
+ private messageQueue;
406
+ private seenMessages;
407
+ private messageHandler;
408
+ private readonly maxQueueSize;
409
+ constructor(runtime: LingyaoRuntime, accountManager: AccountManager);
410
+ /**
411
+ * Initialize the message processor
591
412
  */
592
- private scheduleReconnect;
413
+ initialize(): Promise<void>;
593
414
  /**
594
- * 发送消息到服务器
415
+ * Set the message handler for delivering messages to Agent
595
416
  */
596
- send(message: WSMessage): void;
417
+ setMessageHandler(handler: MessageHandler): void;
597
418
  /**
598
- * 发送通知到鸿蒙 App
419
+ * Get the currently registered Agent message handler.
599
420
  */
600
- sendNotification(deviceId: string, notification: any): void;
421
+ getMessageHandler(): MessageHandler | null;
601
422
  /**
602
- * 处理 App 消息
423
+ * Deliver a normalized message directly to the registered Agent handler.
603
424
  */
604
- private handleAppMessage;
425
+ deliverToAgent(message: AgentMessage): Promise<void>;
605
426
  /**
606
- * 处理消息发送成功
427
+ * Process sync request from app
607
428
  */
608
- private handleMessageDelivered;
429
+ processSync(deviceId: string, request: SyncRequest): Promise<SyncResponse>;
609
430
  /**
610
- * 处理配对完成通知(来自 lingyao.live 服务器)
431
+ * Process a single message
611
432
  */
612
- private handlePairingCompleted;
433
+ private processMessage;
613
434
  /**
614
- * 处理消息发送失败
435
+ * Process diary sync - Pass directly to Agent
615
436
  */
616
- private handleMessageFailed;
437
+ private processDiarySync;
617
438
  /**
618
- * 处理服务器错误
439
+ * Process memory sync - Pass directly to Agent
619
440
  */
620
- private handleError;
441
+ private processMemorySync;
621
442
  /**
622
- * 注册消息处理器
443
+ * Process sync acknowledgment
623
444
  */
624
- registerMessageHandler(type: string, handler: (message: WSMessage) => void): void;
445
+ private processSyncAck;
625
446
  /**
626
- * 发送事件
447
+ * Process heartbeat
627
448
  */
628
- private emitEvent;
449
+ private processHeartbeat;
629
450
  /**
630
- * 更新 WebSocket 连接使用的 token
451
+ * Poll for new messages (long-polling)
631
452
  */
632
- updateToken(token: string): void;
453
+ pollMessages(deviceId: string, timeout?: number): Promise<LingyaoMessage[]>;
633
454
  /**
634
- * 断开连接
455
+ * Queue a message for a device
635
456
  */
636
- disconnect(): void;
457
+ queueMessage(deviceId: string, message: LingyaoMessage): boolean;
637
458
  /**
638
- * 获取连接状态
459
+ * Acknowledge messages
639
460
  */
640
- getState(): ConnectionState;
461
+ acknowledgeMessages(messageIds: string[]): Promise<void>;
641
462
  /**
642
- * 获取连接 ID
463
+ * Check if message has been seen (deduplication)
643
464
  */
644
- getConnectionId(): string | null;
465
+ private isMessageSeen;
645
466
  /**
646
- * 是否已连接
467
+ * Mark message as seen
647
468
  */
648
- isConnected(): boolean;
469
+ private markMessageSeen;
649
470
  /**
650
- * 生成消息 ID
471
+ * Get queue size for a device
651
472
  */
652
- private generateMessageId;
473
+ getQueueSize(deviceId: string): number;
653
474
  /**
654
- * 生成连接 ID
475
+ * Get total queue size
655
476
  */
656
- private generateConnectionId;
477
+ getTotalQueueSize(): number;
657
478
  }
658
479
 
659
480
  /**
@@ -823,6 +644,169 @@ declare class Monitor {
823
644
  };
824
645
  }
825
646
 
647
+ /**
648
+ * 错误处理模块
649
+ */
650
+
651
+ /**
652
+ * 错误严重级别
653
+ */
654
+ declare enum ErrorSeverity {
655
+ LOW = "low",
656
+ MEDIUM = "medium",
657
+ HIGH = "high",
658
+ CRITICAL = "critical"
659
+ }
660
+ /**
661
+ * Lingyao 错误基类
662
+ */
663
+ declare class LingyaoError extends Error {
664
+ readonly code: string;
665
+ readonly severity: ErrorSeverity;
666
+ readonly timestamp: number;
667
+ readonly context?: Record<string, unknown>;
668
+ readonly cause?: Error;
669
+ constructor(message: string, code: string, severity?: ErrorSeverity, context?: Record<string, unknown>, cause?: Error);
670
+ /**
671
+ * 转换为 JSON 可序列化格式
672
+ */
673
+ toJSON(): Record<string, unknown>;
674
+ }
675
+ /**
676
+ * 错误处理器
677
+ */
678
+ declare class ErrorHandler {
679
+ private runtime;
680
+ private errorCounts;
681
+ private lastErrors;
682
+ private errorThresholds;
683
+ private cleanupTimer;
684
+ private errorTimestamps;
685
+ constructor(runtime: LingyaoRuntime);
686
+ destroy(): void;
687
+ private cleanupOldErrors;
688
+ /**
689
+ * 处理错误
690
+ */
691
+ handleError(error: Error | LingyaoError): void;
692
+ /**
693
+ * 记录错误
694
+ */
695
+ private recordError;
696
+ /**
697
+ * 检查错误阈值
698
+ */
699
+ private checkThresholds;
700
+ /**
701
+ * 触发警报
702
+ */
703
+ private triggerAlert;
704
+ /**
705
+ * 设置错误阈值
706
+ */
707
+ setErrorThreshold(code: string, threshold: {
708
+ count: number;
709
+ window: number;
710
+ }): void;
711
+ /**
712
+ * 获取错误统计
713
+ */
714
+ getErrorStats(): {
715
+ byCode: Record<string, number>;
716
+ total: number;
717
+ recent: Array<{
718
+ code: string;
719
+ error: LingyaoError;
720
+ timestamp: number;
721
+ }>;
722
+ };
723
+ /**
724
+ * 重置错误计数
725
+ */
726
+ resetErrorCounts(code?: string): void;
727
+ /**
728
+ * 包装异步函数以自动处理错误
729
+ */
730
+ wrapAsync<T>(fn: () => Promise<T>, context?: {
731
+ operation?: string;
732
+ fallback?: T;
733
+ retryable?: boolean;
734
+ }): Promise<T>;
735
+ /**
736
+ * 创建带有错误处理的重试逻辑
737
+ */
738
+ retry<T>(fn: () => Promise<T>, options?: {
739
+ maxRetries?: number;
740
+ retryDelay?: number;
741
+ backoff?: boolean;
742
+ onRetry?: (error: Error, attempt: number) => void;
743
+ }): Promise<T>;
744
+ /**
745
+ * 判断错误是否可重试
746
+ */
747
+ isRetryable(error: Error): boolean;
748
+ /**
749
+ * 判断错误是否需要降级处理
750
+ */
751
+ shouldDegrade(error: Error): boolean;
752
+ /**
753
+ * 创建降级响应
754
+ */
755
+ createDegradedResponse<T>(fallback: T, error?: Error): {
756
+ success: false;
757
+ degraded: true;
758
+ fallback: T;
759
+ error?: Error;
760
+ };
761
+ }
762
+
763
+ /**
764
+ * Token management utilities
765
+ */
766
+ declare class TokenManager {
767
+ constructor(_runtime: LingyaoRuntime);
768
+ /**
769
+ * Generate a new device token
770
+ */
771
+ generateDeviceToken(pairingId: string, deviceInfo: DeviceInfo, expiryDays?: number): DeviceToken;
772
+ /**
773
+ * Validate a device token
774
+ */
775
+ validateToken(token: string, storedSecret: string): boolean;
776
+ /**
777
+ * Check if token is expired
778
+ */
779
+ isTokenExpired(token: DeviceToken): boolean;
780
+ /**
781
+ * Refresh an existing token
782
+ */
783
+ refreshToken(oldToken: DeviceToken, expiryDays?: number): DeviceToken;
784
+ /**
785
+ * Extract device ID from token string
786
+ */
787
+ extractDeviceId(token: string): string | null;
788
+ /**
789
+ * Generate a unique device ID
790
+ */
791
+ private generateDeviceId;
792
+ /**
793
+ * Generate a random secret key
794
+ */
795
+ private generateSecret;
796
+ /**
797
+ * Generate a JWT-like token string
798
+ */
799
+ private generateTokenString;
800
+ /**
801
+ * Sign data with secret
802
+ */
803
+ private sign;
804
+ /**
805
+ * Base64URL encode without padding
806
+ */
807
+ private base64UrlEncode;
808
+ }
809
+
826
810
  /**
827
811
  * 灵爻频道插件 - 服务器中转模式
828
812
  */
@@ -983,7 +967,7 @@ declare function validateConfig(config: unknown): LingyaoConfig;
983
967
  */
984
968
  declare function getDefaultConfig(): LingyaoConfig;
985
969
 
986
- declare const lingyaoPlugin: ChannelPlugin<ResolvedAccount>;
970
+ declare const lingyaoPlugin: ChannelPlugin<ResolvedAccount, LingyaoProbeResult>;
987
971
  declare function initializeLingyaoRuntime(runtime: PluginRuntime): void;
988
972
  /** @deprecated Use the default export (OpenClaw SDK entry) instead. */
989
973
  declare function createPlugin(runtime: LingyaoRuntime, config?: Partial<LingyaoConfig>): Promise<LingyaoChannel>;
@@ -1006,12 +990,10 @@ declare const plugin: {
1006
990
  id: string;
1007
991
  name: string;
1008
992
  description: string;
1009
- register(api: {
1010
- runtime?: unknown;
1011
- registerChannel: (params: {
1012
- plugin: unknown;
1013
- }) => void;
1014
- }): void;
993
+ configSchema: openclaw_plugin_sdk.ChannelConfigSchema;
994
+ register: (api: openclaw_plugin_sdk.OpenClawPluginApi) => void;
995
+ channelPlugin: openclaw_plugin_sdk.ChannelPlugin<ResolvedAccount, LingyaoProbeResult>;
996
+ setChannelRuntime?: (runtime: openclaw_plugin_sdk.PluginRuntime) => void;
1015
997
  };
1016
998
 
1017
- export { type AgentMessage, DeviceInfo, DeviceToken, HealthStatus, LingyaoAccountConfig, LingyaoChannel, LingyaoConfig, LingyaoMessage, LingyaoRuntime, NotifyPayload, SyncRequest, SyncResponse, createPlugin, plugin as default, getDefaultConfig, initializeLingyaoRuntime, lingyaoPlugin, pluginMetadata, validateConfig };
999
+ export { type AgentMessage, DeviceInfo, DeviceToken, HealthStatus, LingyaoChannel, LingyaoConfig, LingyaoMessage, LingyaoRuntime, NotifyPayload, SyncRequest, SyncResponse, createPlugin, plugin as default, getDefaultConfig, initializeLingyaoRuntime, lingyaoPlugin, pluginMetadata, validateConfig };