@lingyao037/openclaw-lingyao-cli 0.9.4 → 0.9.6
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/accounts-BykE02r0.d.ts +80 -0
- package/dist/cli.d.ts +2 -1
- package/dist/index.d.ts +315 -323
- package/dist/index.js +288 -41
- package/dist/index.js.map +1 -1
- package/dist/setup-entry.d.ts +9 -3
- package/dist/setup-entry.js +187 -2613
- package/dist/setup-entry.js.map +1 -1
- package/dist/status-CVwSoPKi.d.ts +39 -0
- package/dist/{accounts-B9ijYIIu.d.ts → types-LFC6Wpqo.d.ts} +9 -80
- package/openclaw.plugin.json +9 -3
- package/package.json +9 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,285 +1,9 @@
|
|
|
1
|
+
import { R as ResolvedAccount, L as LingyaoProbeResult } from './status-CVwSoPKi.js';
|
|
2
|
+
import * as openclaw_plugin_sdk from 'openclaw/plugin-sdk';
|
|
1
3
|
import { PluginRuntime, ChannelPlugin } from 'openclaw/plugin-sdk';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
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-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';
|
|
283
7
|
|
|
284
8
|
/**
|
|
285
9
|
* 灵爻服务器 HTTP 客户端
|
|
@@ -410,6 +134,11 @@ declare class ServerHttpClient {
|
|
|
410
134
|
* 检查是否已注册
|
|
411
135
|
*/
|
|
412
136
|
isReady(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Clear local gateway token/session (storage + in-memory). Used when WS handshake
|
|
139
|
+
* fails with 404 or when forcing re-registration with the same gatewayId.
|
|
140
|
+
*/
|
|
141
|
+
clearLocalSession(): Promise<void>;
|
|
413
142
|
/**
|
|
414
143
|
* 从存储恢复会话
|
|
415
144
|
*/
|
|
@@ -494,6 +223,9 @@ type WSClientEvent = {
|
|
|
494
223
|
} | {
|
|
495
224
|
type: "error";
|
|
496
225
|
error: Error;
|
|
226
|
+
} | {
|
|
227
|
+
type: "fatal_handshake";
|
|
228
|
+
reason: "http_404";
|
|
497
229
|
} | {
|
|
498
230
|
type: "message";
|
|
499
231
|
message: WSMessage;
|
|
@@ -535,6 +267,8 @@ declare class LingyaoWSClient {
|
|
|
535
267
|
private connectionId;
|
|
536
268
|
private heartbeatTimer;
|
|
537
269
|
private reconnectTimer;
|
|
270
|
+
/** When set, close handler will not schedule reconnect (e.g. HTTP 404 on upgrade). */
|
|
271
|
+
private suppressReconnect;
|
|
538
272
|
private messageHandlers;
|
|
539
273
|
private logger;
|
|
540
274
|
constructor(runtime: LingyaoRuntime, config: WSClientConfig);
|
|
@@ -587,73 +321,170 @@ declare class LingyaoWSClient {
|
|
|
587
321
|
*/
|
|
588
322
|
private stopHeartbeat;
|
|
589
323
|
/**
|
|
590
|
-
* 安排重连
|
|
324
|
+
* 安排重连
|
|
325
|
+
*/
|
|
326
|
+
private scheduleReconnect;
|
|
327
|
+
/**
|
|
328
|
+
* 发送消息到服务器
|
|
329
|
+
*/
|
|
330
|
+
send(message: WSMessage): void;
|
|
331
|
+
/**
|
|
332
|
+
* 发送通知到鸿蒙 App
|
|
333
|
+
*/
|
|
334
|
+
sendNotification(deviceId: string, notification: any): void;
|
|
335
|
+
/**
|
|
336
|
+
* 处理 App 消息
|
|
337
|
+
*/
|
|
338
|
+
private handleAppMessage;
|
|
339
|
+
/**
|
|
340
|
+
* 处理消息发送成功
|
|
341
|
+
*/
|
|
342
|
+
private handleMessageDelivered;
|
|
343
|
+
/**
|
|
344
|
+
* 处理配对完成通知(来自 lingyao.live 服务器)
|
|
345
|
+
*/
|
|
346
|
+
private handlePairingCompleted;
|
|
347
|
+
/**
|
|
348
|
+
* 处理消息发送失败
|
|
349
|
+
*/
|
|
350
|
+
private handleMessageFailed;
|
|
351
|
+
/**
|
|
352
|
+
* 处理服务器错误
|
|
353
|
+
*/
|
|
354
|
+
private handleError;
|
|
355
|
+
/**
|
|
356
|
+
* 注册消息处理器
|
|
357
|
+
*/
|
|
358
|
+
registerMessageHandler(type: string, handler: (message: WSMessage) => void): void;
|
|
359
|
+
/**
|
|
360
|
+
* 发送事件
|
|
361
|
+
*/
|
|
362
|
+
private emitEvent;
|
|
363
|
+
/**
|
|
364
|
+
* 更新 WebSocket 连接使用的 token
|
|
365
|
+
*/
|
|
366
|
+
updateToken(token: string): void;
|
|
367
|
+
/**
|
|
368
|
+
* 断开连接
|
|
369
|
+
*/
|
|
370
|
+
disconnect(): void;
|
|
371
|
+
/**
|
|
372
|
+
* 获取连接状态
|
|
373
|
+
*/
|
|
374
|
+
getState(): ConnectionState;
|
|
375
|
+
/**
|
|
376
|
+
* 获取连接 ID
|
|
377
|
+
*/
|
|
378
|
+
getConnectionId(): string | null;
|
|
379
|
+
/**
|
|
380
|
+
* 是否已连接
|
|
381
|
+
*/
|
|
382
|
+
isConnected(): boolean;
|
|
383
|
+
/**
|
|
384
|
+
* 生成消息 ID
|
|
385
|
+
*/
|
|
386
|
+
private generateMessageId;
|
|
387
|
+
/**
|
|
388
|
+
* 生成连接 ID
|
|
389
|
+
*/
|
|
390
|
+
private generateConnectionId;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Agent message format - messages passed directly to Agent
|
|
395
|
+
*/
|
|
396
|
+
interface AgentMessage {
|
|
397
|
+
id: string;
|
|
398
|
+
type: "diary" | "memory" | "heartbeat";
|
|
399
|
+
from: string;
|
|
400
|
+
deviceId: string;
|
|
401
|
+
content: string;
|
|
402
|
+
metadata: Record<string, unknown>;
|
|
403
|
+
timestamp: number;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Message handler callback for delivering messages to Agent
|
|
407
|
+
*/
|
|
408
|
+
type MessageHandler = (message: AgentMessage) => void | Promise<void>;
|
|
409
|
+
/**
|
|
410
|
+
* Message Processor - Handles incoming messages and routes them to Agent
|
|
411
|
+
*/
|
|
412
|
+
declare class MessageProcessor {
|
|
413
|
+
private runtime;
|
|
414
|
+
private accountManager;
|
|
415
|
+
private messageQueue;
|
|
416
|
+
private seenMessages;
|
|
417
|
+
private messageHandler;
|
|
418
|
+
private readonly maxQueueSize;
|
|
419
|
+
constructor(runtime: LingyaoRuntime, accountManager: AccountManager);
|
|
420
|
+
/**
|
|
421
|
+
* Initialize the message processor
|
|
591
422
|
*/
|
|
592
|
-
|
|
423
|
+
initialize(): Promise<void>;
|
|
593
424
|
/**
|
|
594
|
-
*
|
|
425
|
+
* Set the message handler for delivering messages to Agent
|
|
595
426
|
*/
|
|
596
|
-
|
|
427
|
+
setMessageHandler(handler: MessageHandler): void;
|
|
597
428
|
/**
|
|
598
|
-
*
|
|
429
|
+
* Get the currently registered Agent message handler.
|
|
599
430
|
*/
|
|
600
|
-
|
|
431
|
+
getMessageHandler(): MessageHandler | null;
|
|
601
432
|
/**
|
|
602
|
-
*
|
|
433
|
+
* Deliver a normalized message directly to the registered Agent handler.
|
|
603
434
|
*/
|
|
604
|
-
|
|
435
|
+
deliverToAgent(message: AgentMessage): Promise<void>;
|
|
605
436
|
/**
|
|
606
|
-
*
|
|
437
|
+
* Process sync request from app
|
|
607
438
|
*/
|
|
608
|
-
|
|
439
|
+
processSync(deviceId: string, request: SyncRequest): Promise<SyncResponse>;
|
|
609
440
|
/**
|
|
610
|
-
*
|
|
441
|
+
* Process a single message
|
|
611
442
|
*/
|
|
612
|
-
private
|
|
443
|
+
private processMessage;
|
|
613
444
|
/**
|
|
614
|
-
*
|
|
445
|
+
* Process diary sync - Pass directly to Agent
|
|
615
446
|
*/
|
|
616
|
-
private
|
|
447
|
+
private processDiarySync;
|
|
617
448
|
/**
|
|
618
|
-
*
|
|
449
|
+
* Process memory sync - Pass directly to Agent
|
|
619
450
|
*/
|
|
620
|
-
private
|
|
451
|
+
private processMemorySync;
|
|
621
452
|
/**
|
|
622
|
-
*
|
|
453
|
+
* Process sync acknowledgment
|
|
623
454
|
*/
|
|
624
|
-
|
|
455
|
+
private processSyncAck;
|
|
625
456
|
/**
|
|
626
|
-
*
|
|
457
|
+
* Process heartbeat
|
|
627
458
|
*/
|
|
628
|
-
private
|
|
459
|
+
private processHeartbeat;
|
|
629
460
|
/**
|
|
630
|
-
*
|
|
461
|
+
* Poll for new messages (long-polling)
|
|
631
462
|
*/
|
|
632
|
-
|
|
463
|
+
pollMessages(deviceId: string, timeout?: number): Promise<LingyaoMessage[]>;
|
|
633
464
|
/**
|
|
634
|
-
*
|
|
465
|
+
* Queue a message for a device
|
|
635
466
|
*/
|
|
636
|
-
|
|
467
|
+
queueMessage(deviceId: string, message: LingyaoMessage): boolean;
|
|
637
468
|
/**
|
|
638
|
-
*
|
|
469
|
+
* Acknowledge messages
|
|
639
470
|
*/
|
|
640
|
-
|
|
471
|
+
acknowledgeMessages(messageIds: string[]): Promise<void>;
|
|
641
472
|
/**
|
|
642
|
-
*
|
|
473
|
+
* Check if message has been seen (deduplication)
|
|
643
474
|
*/
|
|
644
|
-
|
|
475
|
+
private isMessageSeen;
|
|
645
476
|
/**
|
|
646
|
-
*
|
|
477
|
+
* Mark message as seen
|
|
647
478
|
*/
|
|
648
|
-
|
|
479
|
+
private markMessageSeen;
|
|
649
480
|
/**
|
|
650
|
-
*
|
|
481
|
+
* Get queue size for a device
|
|
651
482
|
*/
|
|
652
|
-
|
|
483
|
+
getQueueSize(deviceId: string): number;
|
|
653
484
|
/**
|
|
654
|
-
*
|
|
485
|
+
* Get total queue size
|
|
655
486
|
*/
|
|
656
|
-
|
|
487
|
+
getTotalQueueSize(): number;
|
|
657
488
|
}
|
|
658
489
|
|
|
659
490
|
/**
|
|
@@ -823,6 +654,169 @@ declare class Monitor {
|
|
|
823
654
|
};
|
|
824
655
|
}
|
|
825
656
|
|
|
657
|
+
/**
|
|
658
|
+
* 错误处理模块
|
|
659
|
+
*/
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* 错误严重级别
|
|
663
|
+
*/
|
|
664
|
+
declare enum ErrorSeverity {
|
|
665
|
+
LOW = "low",
|
|
666
|
+
MEDIUM = "medium",
|
|
667
|
+
HIGH = "high",
|
|
668
|
+
CRITICAL = "critical"
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Lingyao 错误基类
|
|
672
|
+
*/
|
|
673
|
+
declare class LingyaoError extends Error {
|
|
674
|
+
readonly code: string;
|
|
675
|
+
readonly severity: ErrorSeverity;
|
|
676
|
+
readonly timestamp: number;
|
|
677
|
+
readonly context?: Record<string, unknown>;
|
|
678
|
+
readonly cause?: Error;
|
|
679
|
+
constructor(message: string, code: string, severity?: ErrorSeverity, context?: Record<string, unknown>, cause?: Error);
|
|
680
|
+
/**
|
|
681
|
+
* 转换为 JSON 可序列化格式
|
|
682
|
+
*/
|
|
683
|
+
toJSON(): Record<string, unknown>;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* 错误处理器
|
|
687
|
+
*/
|
|
688
|
+
declare class ErrorHandler {
|
|
689
|
+
private runtime;
|
|
690
|
+
private errorCounts;
|
|
691
|
+
private lastErrors;
|
|
692
|
+
private errorThresholds;
|
|
693
|
+
private cleanupTimer;
|
|
694
|
+
private errorTimestamps;
|
|
695
|
+
constructor(runtime: LingyaoRuntime);
|
|
696
|
+
destroy(): void;
|
|
697
|
+
private cleanupOldErrors;
|
|
698
|
+
/**
|
|
699
|
+
* 处理错误
|
|
700
|
+
*/
|
|
701
|
+
handleError(error: Error | LingyaoError): void;
|
|
702
|
+
/**
|
|
703
|
+
* 记录错误
|
|
704
|
+
*/
|
|
705
|
+
private recordError;
|
|
706
|
+
/**
|
|
707
|
+
* 检查错误阈值
|
|
708
|
+
*/
|
|
709
|
+
private checkThresholds;
|
|
710
|
+
/**
|
|
711
|
+
* 触发警报
|
|
712
|
+
*/
|
|
713
|
+
private triggerAlert;
|
|
714
|
+
/**
|
|
715
|
+
* 设置错误阈值
|
|
716
|
+
*/
|
|
717
|
+
setErrorThreshold(code: string, threshold: {
|
|
718
|
+
count: number;
|
|
719
|
+
window: number;
|
|
720
|
+
}): void;
|
|
721
|
+
/**
|
|
722
|
+
* 获取错误统计
|
|
723
|
+
*/
|
|
724
|
+
getErrorStats(): {
|
|
725
|
+
byCode: Record<string, number>;
|
|
726
|
+
total: number;
|
|
727
|
+
recent: Array<{
|
|
728
|
+
code: string;
|
|
729
|
+
error: LingyaoError;
|
|
730
|
+
timestamp: number;
|
|
731
|
+
}>;
|
|
732
|
+
};
|
|
733
|
+
/**
|
|
734
|
+
* 重置错误计数
|
|
735
|
+
*/
|
|
736
|
+
resetErrorCounts(code?: string): void;
|
|
737
|
+
/**
|
|
738
|
+
* 包装异步函数以自动处理错误
|
|
739
|
+
*/
|
|
740
|
+
wrapAsync<T>(fn: () => Promise<T>, context?: {
|
|
741
|
+
operation?: string;
|
|
742
|
+
fallback?: T;
|
|
743
|
+
retryable?: boolean;
|
|
744
|
+
}): Promise<T>;
|
|
745
|
+
/**
|
|
746
|
+
* 创建带有错误处理的重试逻辑
|
|
747
|
+
*/
|
|
748
|
+
retry<T>(fn: () => Promise<T>, options?: {
|
|
749
|
+
maxRetries?: number;
|
|
750
|
+
retryDelay?: number;
|
|
751
|
+
backoff?: boolean;
|
|
752
|
+
onRetry?: (error: Error, attempt: number) => void;
|
|
753
|
+
}): Promise<T>;
|
|
754
|
+
/**
|
|
755
|
+
* 判断错误是否可重试
|
|
756
|
+
*/
|
|
757
|
+
isRetryable(error: Error): boolean;
|
|
758
|
+
/**
|
|
759
|
+
* 判断错误是否需要降级处理
|
|
760
|
+
*/
|
|
761
|
+
shouldDegrade(error: Error): boolean;
|
|
762
|
+
/**
|
|
763
|
+
* 创建降级响应
|
|
764
|
+
*/
|
|
765
|
+
createDegradedResponse<T>(fallback: T, error?: Error): {
|
|
766
|
+
success: false;
|
|
767
|
+
degraded: true;
|
|
768
|
+
fallback: T;
|
|
769
|
+
error?: Error;
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Token management utilities
|
|
775
|
+
*/
|
|
776
|
+
declare class TokenManager {
|
|
777
|
+
constructor(_runtime: LingyaoRuntime);
|
|
778
|
+
/**
|
|
779
|
+
* Generate a new device token
|
|
780
|
+
*/
|
|
781
|
+
generateDeviceToken(pairingId: string, deviceInfo: DeviceInfo, expiryDays?: number): DeviceToken;
|
|
782
|
+
/**
|
|
783
|
+
* Validate a device token
|
|
784
|
+
*/
|
|
785
|
+
validateToken(token: string, storedSecret: string): boolean;
|
|
786
|
+
/**
|
|
787
|
+
* Check if token is expired
|
|
788
|
+
*/
|
|
789
|
+
isTokenExpired(token: DeviceToken): boolean;
|
|
790
|
+
/**
|
|
791
|
+
* Refresh an existing token
|
|
792
|
+
*/
|
|
793
|
+
refreshToken(oldToken: DeviceToken, expiryDays?: number): DeviceToken;
|
|
794
|
+
/**
|
|
795
|
+
* Extract device ID from token string
|
|
796
|
+
*/
|
|
797
|
+
extractDeviceId(token: string): string | null;
|
|
798
|
+
/**
|
|
799
|
+
* Generate a unique device ID
|
|
800
|
+
*/
|
|
801
|
+
private generateDeviceId;
|
|
802
|
+
/**
|
|
803
|
+
* Generate a random secret key
|
|
804
|
+
*/
|
|
805
|
+
private generateSecret;
|
|
806
|
+
/**
|
|
807
|
+
* Generate a JWT-like token string
|
|
808
|
+
*/
|
|
809
|
+
private generateTokenString;
|
|
810
|
+
/**
|
|
811
|
+
* Sign data with secret
|
|
812
|
+
*/
|
|
813
|
+
private sign;
|
|
814
|
+
/**
|
|
815
|
+
* Base64URL encode without padding
|
|
816
|
+
*/
|
|
817
|
+
private base64UrlEncode;
|
|
818
|
+
}
|
|
819
|
+
|
|
826
820
|
/**
|
|
827
821
|
* 灵爻频道插件 - 服务器中转模式
|
|
828
822
|
*/
|
|
@@ -983,7 +977,7 @@ declare function validateConfig(config: unknown): LingyaoConfig;
|
|
|
983
977
|
*/
|
|
984
978
|
declare function getDefaultConfig(): LingyaoConfig;
|
|
985
979
|
|
|
986
|
-
declare const lingyaoPlugin: ChannelPlugin<ResolvedAccount>;
|
|
980
|
+
declare const lingyaoPlugin: ChannelPlugin<ResolvedAccount, LingyaoProbeResult>;
|
|
987
981
|
declare function initializeLingyaoRuntime(runtime: PluginRuntime): void;
|
|
988
982
|
/** @deprecated Use the default export (OpenClaw SDK entry) instead. */
|
|
989
983
|
declare function createPlugin(runtime: LingyaoRuntime, config?: Partial<LingyaoConfig>): Promise<LingyaoChannel>;
|
|
@@ -1006,12 +1000,10 @@ declare const plugin: {
|
|
|
1006
1000
|
id: string;
|
|
1007
1001
|
name: string;
|
|
1008
1002
|
description: string;
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
}) => void;
|
|
1014
|
-
}): void;
|
|
1003
|
+
configSchema: openclaw_plugin_sdk.ChannelConfigSchema;
|
|
1004
|
+
register: (api: openclaw_plugin_sdk.OpenClawPluginApi) => void;
|
|
1005
|
+
channelPlugin: openclaw_plugin_sdk.ChannelPlugin<ResolvedAccount, LingyaoProbeResult>;
|
|
1006
|
+
setChannelRuntime?: (runtime: openclaw_plugin_sdk.PluginRuntime) => void;
|
|
1015
1007
|
};
|
|
1016
1008
|
|
|
1017
|
-
export { type AgentMessage, DeviceInfo, DeviceToken, HealthStatus,
|
|
1009
|
+
export { type AgentMessage, DeviceInfo, DeviceToken, HealthStatus, LingyaoChannel, LingyaoConfig, LingyaoMessage, LingyaoRuntime, NotifyPayload, SyncRequest, SyncResponse, createPlugin, plugin as default, getDefaultConfig, initializeLingyaoRuntime, lingyaoPlugin, pluginMetadata, validateConfig };
|