@lingyao037/openclaw-lingyao-cli 0.3.3 → 0.4.0
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-Bkwmg14Q.d.ts → accounts-AwHXj7VB.d.ts} +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/index.d.ts +265 -523
- package/dist/index.js +165 -63
- package/dist/index.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,262 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as openclaw_plugin_sdk_core from 'openclaw/plugin-sdk/core';
|
|
2
|
+
import * as openclaw_plugin_sdk from 'openclaw/plugin-sdk';
|
|
3
|
+
import { L as LingyaoRuntime, D as DeviceInfo, a as DeviceToken, A as AccountManager, S as SyncRequest, b as SyncResponse, c as LingyaoMessage, d as LingyaoConfig, N as NotifyPayload, H as HealthStatus } from './accounts-AwHXj7VB.js';
|
|
4
|
+
export { e as AckRequest, f as DiarySyncPayload, F as FailedEntry, g as LINGYAO_SERVER_URL, h as LingyaoAccount, i as LingyaoAccountConfig, 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-AwHXj7VB.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
* 错误处理模块
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 错误严重级别
|
|
12
|
+
*/
|
|
13
|
+
declare enum ErrorSeverity {
|
|
14
|
+
LOW = "low",
|
|
15
|
+
MEDIUM = "medium",
|
|
16
|
+
HIGH = "high",
|
|
17
|
+
CRITICAL = "critical"
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Lingyao 错误基类
|
|
21
|
+
*/
|
|
22
|
+
declare class LingyaoError extends Error {
|
|
23
|
+
readonly code: string;
|
|
24
|
+
readonly severity: ErrorSeverity;
|
|
25
|
+
readonly timestamp: number;
|
|
26
|
+
readonly context?: Record<string, unknown>;
|
|
27
|
+
readonly cause?: Error;
|
|
28
|
+
constructor(message: string, code: string, severity?: ErrorSeverity, context?: Record<string, unknown>, cause?: Error);
|
|
29
|
+
/**
|
|
30
|
+
* 转换为 JSON 可序列化格式
|
|
31
|
+
*/
|
|
32
|
+
toJSON(): Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 错误处理器
|
|
36
|
+
*/
|
|
37
|
+
declare class ErrorHandler {
|
|
38
|
+
private runtime;
|
|
39
|
+
private errorCounts;
|
|
40
|
+
private lastErrors;
|
|
41
|
+
private errorThresholds;
|
|
42
|
+
constructor(runtime: LingyaoRuntime);
|
|
43
|
+
/**
|
|
44
|
+
* 处理错误
|
|
45
|
+
*/
|
|
46
|
+
handleError(error: Error | LingyaoError): void;
|
|
47
|
+
/**
|
|
48
|
+
* 记录错误
|
|
49
|
+
*/
|
|
50
|
+
private recordError;
|
|
51
|
+
/**
|
|
52
|
+
* 检查错误阈值
|
|
53
|
+
*/
|
|
54
|
+
private checkThresholds;
|
|
55
|
+
/**
|
|
56
|
+
* 触发警报
|
|
57
|
+
*/
|
|
58
|
+
private triggerAlert;
|
|
59
|
+
/**
|
|
60
|
+
* 设置错误阈值
|
|
61
|
+
*/
|
|
62
|
+
setErrorThreshold(code: string, threshold: {
|
|
63
|
+
count: number;
|
|
64
|
+
window: number;
|
|
65
|
+
}): void;
|
|
66
|
+
/**
|
|
67
|
+
* 获取错误统计
|
|
68
|
+
*/
|
|
69
|
+
getErrorStats(): {
|
|
70
|
+
byCode: Record<string, number>;
|
|
71
|
+
total: number;
|
|
72
|
+
recent: Array<{
|
|
73
|
+
code: string;
|
|
74
|
+
error: LingyaoError;
|
|
75
|
+
timestamp: number;
|
|
76
|
+
}>;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* 重置错误计数
|
|
80
|
+
*/
|
|
81
|
+
resetErrorCounts(code?: string): void;
|
|
82
|
+
/**
|
|
83
|
+
* 包装异步函数以自动处理错误
|
|
84
|
+
*/
|
|
85
|
+
wrapAsync<T>(fn: () => Promise<T>, context?: {
|
|
86
|
+
operation?: string;
|
|
87
|
+
fallback?: T;
|
|
88
|
+
retryable?: boolean;
|
|
89
|
+
}): Promise<T>;
|
|
90
|
+
/**
|
|
91
|
+
* 创建带有错误处理的重试逻辑
|
|
92
|
+
*/
|
|
93
|
+
retry<T>(fn: () => Promise<T>, options?: {
|
|
94
|
+
maxRetries?: number;
|
|
95
|
+
retryDelay?: number;
|
|
96
|
+
backoff?: boolean;
|
|
97
|
+
onRetry?: (error: Error, attempt: number) => void;
|
|
98
|
+
}): Promise<T>;
|
|
99
|
+
/**
|
|
100
|
+
* 判断错误是否可重试
|
|
101
|
+
*/
|
|
102
|
+
isRetryable(error: Error): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* 判断错误是否需要降级处理
|
|
105
|
+
*/
|
|
106
|
+
shouldDegrade(error: Error): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* 创建降级响应
|
|
109
|
+
*/
|
|
110
|
+
createDegradedResponse<T>(fallback: T, error?: Error): {
|
|
111
|
+
success: false;
|
|
112
|
+
degraded: true;
|
|
113
|
+
fallback: T;
|
|
114
|
+
error?: Error;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Token management utilities
|
|
8
120
|
*/
|
|
121
|
+
declare class TokenManager {
|
|
122
|
+
constructor(_runtime: LingyaoRuntime);
|
|
123
|
+
/**
|
|
124
|
+
* Generate a new device token
|
|
125
|
+
*/
|
|
126
|
+
generateDeviceToken(pairingId: string, deviceInfo: DeviceInfo, expiryDays?: number): DeviceToken;
|
|
127
|
+
/**
|
|
128
|
+
* Validate a device token
|
|
129
|
+
*/
|
|
130
|
+
validateToken(token: string, storedSecret: string): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Check if token is expired
|
|
133
|
+
*/
|
|
134
|
+
isTokenExpired(token: DeviceToken): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Refresh an existing token
|
|
137
|
+
*/
|
|
138
|
+
refreshToken(oldToken: DeviceToken, expiryDays?: number): DeviceToken;
|
|
139
|
+
/**
|
|
140
|
+
* Extract device ID from token string
|
|
141
|
+
*/
|
|
142
|
+
extractDeviceId(token: string): string | null;
|
|
143
|
+
/**
|
|
144
|
+
* Generate a unique device ID
|
|
145
|
+
*/
|
|
146
|
+
private generateDeviceId;
|
|
147
|
+
/**
|
|
148
|
+
* Generate a random secret key
|
|
149
|
+
*/
|
|
150
|
+
private generateSecret;
|
|
151
|
+
/**
|
|
152
|
+
* Generate a JWT-like token string
|
|
153
|
+
*/
|
|
154
|
+
private generateTokenString;
|
|
155
|
+
/**
|
|
156
|
+
* Sign data with secret
|
|
157
|
+
*/
|
|
158
|
+
private sign;
|
|
159
|
+
/**
|
|
160
|
+
* Base64URL encode without padding
|
|
161
|
+
*/
|
|
162
|
+
private base64UrlEncode;
|
|
163
|
+
}
|
|
9
164
|
|
|
10
165
|
/**
|
|
11
|
-
*
|
|
166
|
+
* Agent message format - messages passed directly to Agent
|
|
167
|
+
*/
|
|
168
|
+
interface AgentMessage {
|
|
169
|
+
id: string;
|
|
170
|
+
type: "diary" | "memory" | "heartbeat";
|
|
171
|
+
from: string;
|
|
172
|
+
deviceId: string;
|
|
173
|
+
content: string;
|
|
174
|
+
metadata: Record<string, unknown>;
|
|
175
|
+
timestamp: number;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Message handler callback for delivering messages to Agent
|
|
179
|
+
*/
|
|
180
|
+
type MessageHandler = (message: AgentMessage) => void | Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Message Processor - Handles incoming messages and routes them to Agent
|
|
12
183
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
184
|
+
declare class MessageProcessor {
|
|
185
|
+
private runtime;
|
|
186
|
+
private accountManager;
|
|
187
|
+
private messageQueue;
|
|
188
|
+
private seenMessages;
|
|
189
|
+
private messageHandler;
|
|
190
|
+
private readonly maxQueueSize;
|
|
191
|
+
constructor(runtime: LingyaoRuntime, accountManager: AccountManager);
|
|
192
|
+
/**
|
|
193
|
+
* Initialize the message processor
|
|
194
|
+
*/
|
|
195
|
+
initialize(): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Set the message handler for delivering messages to Agent
|
|
198
|
+
*/
|
|
199
|
+
setMessageHandler(handler: MessageHandler): void;
|
|
200
|
+
/**
|
|
201
|
+
* Get the currently registered Agent message handler.
|
|
202
|
+
*/
|
|
203
|
+
getMessageHandler(): MessageHandler | null;
|
|
204
|
+
/**
|
|
205
|
+
* Deliver a normalized message directly to the registered Agent handler.
|
|
206
|
+
*/
|
|
207
|
+
deliverToAgent(message: AgentMessage): Promise<void>;
|
|
208
|
+
/**
|
|
209
|
+
* Process sync request from app
|
|
210
|
+
*/
|
|
211
|
+
processSync(deviceId: string, request: SyncRequest): Promise<SyncResponse>;
|
|
212
|
+
/**
|
|
213
|
+
* Process a single message
|
|
214
|
+
*/
|
|
215
|
+
private processMessage;
|
|
216
|
+
/**
|
|
217
|
+
* Process diary sync - Pass directly to Agent
|
|
218
|
+
*/
|
|
219
|
+
private processDiarySync;
|
|
220
|
+
/**
|
|
221
|
+
* Process memory sync - Pass directly to Agent
|
|
222
|
+
*/
|
|
223
|
+
private processMemorySync;
|
|
224
|
+
/**
|
|
225
|
+
* Process sync acknowledgment
|
|
226
|
+
*/
|
|
227
|
+
private processSyncAck;
|
|
228
|
+
/**
|
|
229
|
+
* Process heartbeat
|
|
230
|
+
*/
|
|
231
|
+
private processHeartbeat;
|
|
232
|
+
/**
|
|
233
|
+
* Poll for new messages (long-polling)
|
|
234
|
+
*/
|
|
235
|
+
pollMessages(deviceId: string, timeout?: number): Promise<LingyaoMessage[]>;
|
|
236
|
+
/**
|
|
237
|
+
* Queue a message for a device
|
|
238
|
+
*/
|
|
239
|
+
queueMessage(deviceId: string, message: LingyaoMessage): boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Acknowledge messages
|
|
242
|
+
*/
|
|
243
|
+
acknowledgeMessages(messageIds: string[]): Promise<void>;
|
|
244
|
+
/**
|
|
245
|
+
* Check if message has been seen (deduplication)
|
|
246
|
+
*/
|
|
247
|
+
private isMessageSeen;
|
|
248
|
+
/**
|
|
249
|
+
* Mark message as seen
|
|
250
|
+
*/
|
|
251
|
+
private markMessageSeen;
|
|
252
|
+
/**
|
|
253
|
+
* Get queue size for a device
|
|
254
|
+
*/
|
|
255
|
+
getQueueSize(deviceId: string): number;
|
|
256
|
+
/**
|
|
257
|
+
* Get total queue size
|
|
258
|
+
*/
|
|
259
|
+
getTotalQueueSize(): number;
|
|
19
260
|
}
|
|
20
261
|
|
|
21
262
|
/**
|
|
@@ -376,104 +617,7 @@ declare class LingyaoWSClient {
|
|
|
376
617
|
}
|
|
377
618
|
|
|
378
619
|
/**
|
|
379
|
-
*
|
|
380
|
-
*/
|
|
381
|
-
interface AgentMessage {
|
|
382
|
-
id: string;
|
|
383
|
-
type: "diary" | "memory" | "heartbeat";
|
|
384
|
-
from: string;
|
|
385
|
-
deviceId: string;
|
|
386
|
-
content: string;
|
|
387
|
-
metadata: Record<string, unknown>;
|
|
388
|
-
timestamp: number;
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Message handler callback for delivering messages to Agent
|
|
392
|
-
*/
|
|
393
|
-
type MessageHandler = (message: AgentMessage) => void | Promise<void>;
|
|
394
|
-
/**
|
|
395
|
-
* Message Processor - Handles incoming messages and routes them to Agent
|
|
396
|
-
*/
|
|
397
|
-
declare class MessageProcessor {
|
|
398
|
-
private runtime;
|
|
399
|
-
private accountManager;
|
|
400
|
-
private messageQueue;
|
|
401
|
-
private seenMessages;
|
|
402
|
-
private messageHandler;
|
|
403
|
-
private readonly maxQueueSize;
|
|
404
|
-
constructor(runtime: LingyaoRuntime, accountManager: AccountManager);
|
|
405
|
-
/**
|
|
406
|
-
* Initialize the message processor
|
|
407
|
-
*/
|
|
408
|
-
initialize(): Promise<void>;
|
|
409
|
-
/**
|
|
410
|
-
* Set the message handler for delivering messages to Agent
|
|
411
|
-
*/
|
|
412
|
-
setMessageHandler(handler: MessageHandler): void;
|
|
413
|
-
/**
|
|
414
|
-
* Get the currently registered Agent message handler.
|
|
415
|
-
*/
|
|
416
|
-
getMessageHandler(): MessageHandler | null;
|
|
417
|
-
/**
|
|
418
|
-
* Deliver a normalized message directly to the registered Agent handler.
|
|
419
|
-
*/
|
|
420
|
-
deliverToAgent(message: AgentMessage): Promise<void>;
|
|
421
|
-
/**
|
|
422
|
-
* Process sync request from app
|
|
423
|
-
*/
|
|
424
|
-
processSync(deviceId: string, request: SyncRequest): Promise<SyncResponse>;
|
|
425
|
-
/**
|
|
426
|
-
* Process a single message
|
|
427
|
-
*/
|
|
428
|
-
private processMessage;
|
|
429
|
-
/**
|
|
430
|
-
* Process diary sync - Pass directly to Agent
|
|
431
|
-
*/
|
|
432
|
-
private processDiarySync;
|
|
433
|
-
/**
|
|
434
|
-
* Process memory sync - Pass directly to Agent
|
|
435
|
-
*/
|
|
436
|
-
private processMemorySync;
|
|
437
|
-
/**
|
|
438
|
-
* Process sync acknowledgment
|
|
439
|
-
*/
|
|
440
|
-
private processSyncAck;
|
|
441
|
-
/**
|
|
442
|
-
* Process heartbeat
|
|
443
|
-
*/
|
|
444
|
-
private processHeartbeat;
|
|
445
|
-
/**
|
|
446
|
-
* Poll for new messages (long-polling)
|
|
447
|
-
*/
|
|
448
|
-
pollMessages(deviceId: string, timeout?: number): Promise<LingyaoMessage[]>;
|
|
449
|
-
/**
|
|
450
|
-
* Queue a message for a device
|
|
451
|
-
*/
|
|
452
|
-
queueMessage(deviceId: string, message: LingyaoMessage): boolean;
|
|
453
|
-
/**
|
|
454
|
-
* Acknowledge messages
|
|
455
|
-
*/
|
|
456
|
-
acknowledgeMessages(messageIds: string[]): Promise<void>;
|
|
457
|
-
/**
|
|
458
|
-
* Check if message has been seen (deduplication)
|
|
459
|
-
*/
|
|
460
|
-
private isMessageSeen;
|
|
461
|
-
/**
|
|
462
|
-
* Mark message as seen
|
|
463
|
-
*/
|
|
464
|
-
private markMessageSeen;
|
|
465
|
-
/**
|
|
466
|
-
* Get queue size for a device
|
|
467
|
-
*/
|
|
468
|
-
getQueueSize(deviceId: string): number;
|
|
469
|
-
/**
|
|
470
|
-
* Get total queue size
|
|
471
|
-
*/
|
|
472
|
-
getTotalQueueSize(): number;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* 监控和指标收集模块
|
|
620
|
+
* 监控和指标收集模块
|
|
477
621
|
*/
|
|
478
622
|
|
|
479
623
|
/**
|
|
@@ -639,301 +783,6 @@ declare class Monitor {
|
|
|
639
783
|
};
|
|
640
784
|
}
|
|
641
785
|
|
|
642
|
-
/**
|
|
643
|
-
* 错误处理模块
|
|
644
|
-
*/
|
|
645
|
-
|
|
646
|
-
/**
|
|
647
|
-
* 错误严重级别
|
|
648
|
-
*/
|
|
649
|
-
declare enum ErrorSeverity {
|
|
650
|
-
LOW = "low",
|
|
651
|
-
MEDIUM = "medium",
|
|
652
|
-
HIGH = "high",
|
|
653
|
-
CRITICAL = "critical"
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Lingyao 错误基类
|
|
657
|
-
*/
|
|
658
|
-
declare class LingyaoError extends Error {
|
|
659
|
-
readonly code: string;
|
|
660
|
-
readonly severity: ErrorSeverity;
|
|
661
|
-
readonly timestamp: number;
|
|
662
|
-
readonly context?: Record<string, unknown>;
|
|
663
|
-
readonly cause?: Error;
|
|
664
|
-
constructor(message: string, code: string, severity?: ErrorSeverity, context?: Record<string, unknown>, cause?: Error);
|
|
665
|
-
/**
|
|
666
|
-
* 转换为 JSON 可序列化格式
|
|
667
|
-
*/
|
|
668
|
-
toJSON(): Record<string, unknown>;
|
|
669
|
-
}
|
|
670
|
-
/**
|
|
671
|
-
* 错误处理器
|
|
672
|
-
*/
|
|
673
|
-
declare class ErrorHandler {
|
|
674
|
-
private runtime;
|
|
675
|
-
private errorCounts;
|
|
676
|
-
private lastErrors;
|
|
677
|
-
private errorThresholds;
|
|
678
|
-
constructor(runtime: LingyaoRuntime);
|
|
679
|
-
/**
|
|
680
|
-
* 处理错误
|
|
681
|
-
*/
|
|
682
|
-
handleError(error: Error | LingyaoError): void;
|
|
683
|
-
/**
|
|
684
|
-
* 记录错误
|
|
685
|
-
*/
|
|
686
|
-
private recordError;
|
|
687
|
-
/**
|
|
688
|
-
* 检查错误阈值
|
|
689
|
-
*/
|
|
690
|
-
private checkThresholds;
|
|
691
|
-
/**
|
|
692
|
-
* 触发警报
|
|
693
|
-
*/
|
|
694
|
-
private triggerAlert;
|
|
695
|
-
/**
|
|
696
|
-
* 设置错误阈值
|
|
697
|
-
*/
|
|
698
|
-
setErrorThreshold(code: string, threshold: {
|
|
699
|
-
count: number;
|
|
700
|
-
window: number;
|
|
701
|
-
}): void;
|
|
702
|
-
/**
|
|
703
|
-
* 获取错误统计
|
|
704
|
-
*/
|
|
705
|
-
getErrorStats(): {
|
|
706
|
-
byCode: Record<string, number>;
|
|
707
|
-
total: number;
|
|
708
|
-
recent: Array<{
|
|
709
|
-
code: string;
|
|
710
|
-
error: LingyaoError;
|
|
711
|
-
timestamp: number;
|
|
712
|
-
}>;
|
|
713
|
-
};
|
|
714
|
-
/**
|
|
715
|
-
* 重置错误计数
|
|
716
|
-
*/
|
|
717
|
-
resetErrorCounts(code?: string): void;
|
|
718
|
-
/**
|
|
719
|
-
* 包装异步函数以自动处理错误
|
|
720
|
-
*/
|
|
721
|
-
wrapAsync<T>(fn: () => Promise<T>, context?: {
|
|
722
|
-
operation?: string;
|
|
723
|
-
fallback?: T;
|
|
724
|
-
retryable?: boolean;
|
|
725
|
-
}): Promise<T>;
|
|
726
|
-
/**
|
|
727
|
-
* 创建带有错误处理的重试逻辑
|
|
728
|
-
*/
|
|
729
|
-
retry<T>(fn: () => Promise<T>, options?: {
|
|
730
|
-
maxRetries?: number;
|
|
731
|
-
retryDelay?: number;
|
|
732
|
-
backoff?: boolean;
|
|
733
|
-
onRetry?: (error: Error, attempt: number) => void;
|
|
734
|
-
}): Promise<T>;
|
|
735
|
-
/**
|
|
736
|
-
* 判断错误是否可重试
|
|
737
|
-
*/
|
|
738
|
-
isRetryable(error: Error): boolean;
|
|
739
|
-
/**
|
|
740
|
-
* 判断错误是否需要降级处理
|
|
741
|
-
*/
|
|
742
|
-
shouldDegrade(error: Error): boolean;
|
|
743
|
-
/**
|
|
744
|
-
* 创建降级响应
|
|
745
|
-
*/
|
|
746
|
-
createDegradedResponse<T>(fallback: T, error?: Error): {
|
|
747
|
-
success: false;
|
|
748
|
-
degraded: true;
|
|
749
|
-
fallback: T;
|
|
750
|
-
error?: Error;
|
|
751
|
-
};
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
/**
|
|
755
|
-
* Directory Adapter - List paired devices (peers)
|
|
756
|
-
*
|
|
757
|
-
* Implements ChannelDirectoryAdapter:
|
|
758
|
-
* - listPeers: return all active paired devices for an account
|
|
759
|
-
*
|
|
760
|
-
* SDK passes:
|
|
761
|
-
* listPeers({ cfg, accountId?, query?, limit?, runtime })
|
|
762
|
-
*
|
|
763
|
-
* Returns ChannelDirectoryEntry[] with { kind, id, name?, ... }
|
|
764
|
-
*
|
|
765
|
-
* Uses AccountManager to get the device list.
|
|
766
|
-
* Each device is returned as a "user" peer (no groups in Lingyao).
|
|
767
|
-
*/
|
|
768
|
-
|
|
769
|
-
/**
|
|
770
|
-
* Matches SDK's ChannelDirectoryEntry.
|
|
771
|
-
*/
|
|
772
|
-
interface DirectoryEntry {
|
|
773
|
-
kind: 'user' | 'group' | 'channel';
|
|
774
|
-
id: string;
|
|
775
|
-
name?: string;
|
|
776
|
-
handle?: string;
|
|
777
|
-
avatarUrl?: string;
|
|
778
|
-
rank?: number;
|
|
779
|
-
raw?: unknown;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
/**
|
|
783
|
-
* Status Adapter - Health checks and channel summary
|
|
784
|
-
*
|
|
785
|
-
* Implements ChannelStatusAdapter:
|
|
786
|
-
* - probeAccount: run health checks for a specific account
|
|
787
|
-
* - buildChannelSummary: aggregate status for a single account
|
|
788
|
-
*
|
|
789
|
-
* SDK passes:
|
|
790
|
-
* probeAccount({ account, timeoutMs, cfg })
|
|
791
|
-
* buildChannelSummary({ account, cfg, defaultAccountId, snapshot })
|
|
792
|
-
*
|
|
793
|
-
* Wraps existing Probe and Monitor classes.
|
|
794
|
-
*/
|
|
795
|
-
|
|
796
|
-
/**
|
|
797
|
-
* Probe result structure.
|
|
798
|
-
*/
|
|
799
|
-
interface LingyaoProbeResult {
|
|
800
|
-
ok: boolean;
|
|
801
|
-
status: 'healthy' | 'degraded' | 'unhealthy';
|
|
802
|
-
wsConnected: boolean;
|
|
803
|
-
uptime?: number;
|
|
804
|
-
checks?: Record<string, {
|
|
805
|
-
passed: boolean;
|
|
806
|
-
message: string;
|
|
807
|
-
duration?: number;
|
|
808
|
-
}>;
|
|
809
|
-
error?: string;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
/**
|
|
813
|
-
* Outbound Adapter - Send messages from Agent to App devices
|
|
814
|
-
*
|
|
815
|
-
* Implements ChannelOutboundAdapter:
|
|
816
|
-
* - deliveryMode: "direct" (synchronous via WS)
|
|
817
|
-
* - sendText: send plain text notification
|
|
818
|
-
* - sendPayload: send structured payload notification
|
|
819
|
-
* - resolveTarget: validate and resolve target deviceId
|
|
820
|
-
*
|
|
821
|
-
* SDK passes ChannelOutboundContext = { cfg, to, text, accountId?, ... }
|
|
822
|
-
* and expects OutboundDeliveryResult = { channel, messageId, ... } return.
|
|
823
|
-
*
|
|
824
|
-
* Routes through MultiAccountOrchestrator to the correct
|
|
825
|
-
* account's WS connection.
|
|
826
|
-
*/
|
|
827
|
-
|
|
828
|
-
/**
|
|
829
|
-
* Minimal subset of ChannelOutboundContext that we need.
|
|
830
|
-
*/
|
|
831
|
-
interface OutboundContext {
|
|
832
|
-
cfg?: unknown;
|
|
833
|
-
to: string;
|
|
834
|
-
text: string;
|
|
835
|
-
mediaUrl?: string;
|
|
836
|
-
accountId?: string | null;
|
|
837
|
-
silent?: boolean;
|
|
838
|
-
}
|
|
839
|
-
/**
|
|
840
|
-
* Minimal ChannelOutboundPayloadContext.
|
|
841
|
-
*/
|
|
842
|
-
interface OutboundPayloadContext extends OutboundContext {
|
|
843
|
-
payload: unknown;
|
|
844
|
-
}
|
|
845
|
-
/**
|
|
846
|
-
* OutboundDeliveryResult - what SDK expects back.
|
|
847
|
-
*/
|
|
848
|
-
interface DeliveryResult {
|
|
849
|
-
channel: string;
|
|
850
|
-
messageId: string;
|
|
851
|
-
chatId?: string;
|
|
852
|
-
timestamp?: number;
|
|
853
|
-
meta?: Record<string, unknown>;
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
/**
|
|
857
|
-
* Gateway Adapter - Account lifecycle management
|
|
858
|
-
*
|
|
859
|
-
* Implements ChannelGatewayAdapter:
|
|
860
|
-
* - startAccount: create WS/HTTP connections for an account
|
|
861
|
-
* - stopAccount: tear down connections for an account
|
|
862
|
-
*
|
|
863
|
-
* Delegates to MultiAccountOrchestrator for all operations.
|
|
864
|
-
*
|
|
865
|
-
* SDK passes ChannelGatewayContext which includes:
|
|
866
|
-
* cfg, accountId, account, runtime, abortSignal, log,
|
|
867
|
-
* getStatus, setStatus, channelRuntime?
|
|
868
|
-
*/
|
|
869
|
-
|
|
870
|
-
/**
|
|
871
|
-
* Minimal subset of ChannelGatewayContext that we need.
|
|
872
|
-
* We define this locally to avoid importing internal SDK types.
|
|
873
|
-
*/
|
|
874
|
-
interface GatewayContext {
|
|
875
|
-
accountId: string;
|
|
876
|
-
account: ResolvedAccount;
|
|
877
|
-
cfg?: unknown;
|
|
878
|
-
runtime?: unknown;
|
|
879
|
-
abortSignal?: AbortSignal;
|
|
880
|
-
log?: {
|
|
881
|
-
info: (msg: string) => void;
|
|
882
|
-
warn: (msg: string) => void;
|
|
883
|
-
error: (msg: string) => void;
|
|
884
|
-
debug?: (msg: string) => void;
|
|
885
|
-
};
|
|
886
|
-
getStatus?: () => unknown;
|
|
887
|
-
setStatus?: (next: unknown) => void;
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
/**
|
|
891
|
-
* Token management utilities
|
|
892
|
-
*/
|
|
893
|
-
declare class TokenManager {
|
|
894
|
-
constructor(_runtime: LingyaoRuntime);
|
|
895
|
-
/**
|
|
896
|
-
* Generate a new device token
|
|
897
|
-
*/
|
|
898
|
-
generateDeviceToken(pairingId: string, deviceInfo: DeviceInfo, expiryDays?: number): DeviceToken;
|
|
899
|
-
/**
|
|
900
|
-
* Validate a device token
|
|
901
|
-
*/
|
|
902
|
-
validateToken(token: string, storedSecret: string): boolean;
|
|
903
|
-
/**
|
|
904
|
-
* Check if token is expired
|
|
905
|
-
*/
|
|
906
|
-
isTokenExpired(token: DeviceToken): boolean;
|
|
907
|
-
/**
|
|
908
|
-
* Refresh an existing token
|
|
909
|
-
*/
|
|
910
|
-
refreshToken(oldToken: DeviceToken, expiryDays?: number): DeviceToken;
|
|
911
|
-
/**
|
|
912
|
-
* Extract device ID from token string
|
|
913
|
-
*/
|
|
914
|
-
extractDeviceId(token: string): string | null;
|
|
915
|
-
/**
|
|
916
|
-
* Generate a unique device ID
|
|
917
|
-
*/
|
|
918
|
-
private generateDeviceId;
|
|
919
|
-
/**
|
|
920
|
-
* Generate a random secret key
|
|
921
|
-
*/
|
|
922
|
-
private generateSecret;
|
|
923
|
-
/**
|
|
924
|
-
* Generate a JWT-like token string
|
|
925
|
-
*/
|
|
926
|
-
private generateTokenString;
|
|
927
|
-
/**
|
|
928
|
-
* Sign data with secret
|
|
929
|
-
*/
|
|
930
|
-
private sign;
|
|
931
|
-
/**
|
|
932
|
-
* Base64URL encode without padding
|
|
933
|
-
*/
|
|
934
|
-
private base64UrlEncode;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
786
|
/**
|
|
938
787
|
* 灵爻频道插件 - 服务器中转模式
|
|
939
788
|
*/
|
|
@@ -1094,14 +943,17 @@ declare function validateConfig(config: unknown): LingyaoConfig;
|
|
|
1094
943
|
*/
|
|
1095
944
|
declare function getDefaultConfig(): LingyaoConfig;
|
|
1096
945
|
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
946
|
+
declare const _default: {
|
|
947
|
+
id: string;
|
|
948
|
+
name: string;
|
|
949
|
+
description: string;
|
|
950
|
+
configSchema: openclaw_plugin_sdk.OpenClawPluginConfigSchema;
|
|
951
|
+
register: NonNullable<openclaw_plugin_sdk_core.OpenClawPluginDefinition["register"]>;
|
|
952
|
+
} & Pick<openclaw_plugin_sdk_core.OpenClawPluginDefinition, "kind">;
|
|
953
|
+
|
|
954
|
+
/** @deprecated Use the default export (OpenClaw SDK entry) instead. */
|
|
1101
955
|
declare function createPlugin(runtime: LingyaoRuntime, config?: Partial<LingyaoConfig>): Promise<LingyaoChannel>;
|
|
1102
|
-
/**
|
|
1103
|
-
* Plugin metadata (legacy API).
|
|
1104
|
-
*/
|
|
956
|
+
/** @deprecated Use openclaw.plugin.json for plugin metadata. */
|
|
1105
957
|
declare const pluginMetadata: {
|
|
1106
958
|
name: string;
|
|
1107
959
|
version: string;
|
|
@@ -1115,115 +967,5 @@ declare const pluginMetadata: {
|
|
|
1115
967
|
};
|
|
1116
968
|
defaultConfig: LingyaoConfig;
|
|
1117
969
|
};
|
|
1118
|
-
declare const pluginEntry: {
|
|
1119
|
-
id: string;
|
|
1120
|
-
name: string;
|
|
1121
|
-
description: string;
|
|
1122
|
-
setRuntime(runtime: unknown): void;
|
|
1123
|
-
readonly plugin: {
|
|
1124
|
-
id: "lingyao";
|
|
1125
|
-
meta: {
|
|
1126
|
-
id: string;
|
|
1127
|
-
label: string;
|
|
1128
|
-
selectionLabel: string;
|
|
1129
|
-
docsPath: string;
|
|
1130
|
-
docsLabel: string;
|
|
1131
|
-
blurb: string;
|
|
1132
|
-
order: number;
|
|
1133
|
-
aliases: string[];
|
|
1134
|
-
};
|
|
1135
|
-
capabilities: {
|
|
1136
|
-
chatTypes: readonly ["direct"];
|
|
1137
|
-
media: boolean;
|
|
1138
|
-
reactions: boolean;
|
|
1139
|
-
threads: boolean;
|
|
1140
|
-
polls: boolean;
|
|
1141
|
-
edit: boolean;
|
|
1142
|
-
unsend: boolean;
|
|
1143
|
-
reply: boolean;
|
|
1144
|
-
effects: boolean;
|
|
1145
|
-
groupManagement: boolean;
|
|
1146
|
-
nativeCommands: boolean;
|
|
1147
|
-
blockStreaming: boolean;
|
|
1148
|
-
};
|
|
1149
|
-
config: {
|
|
1150
|
-
listAccountIds(cfg: unknown): string[];
|
|
1151
|
-
resolveAccount(cfg: unknown, accountId?: string | null): ResolvedAccount;
|
|
1152
|
-
isConfigured(_account: ResolvedAccount): boolean;
|
|
1153
|
-
isEnabled(account: ResolvedAccount): boolean;
|
|
1154
|
-
};
|
|
1155
|
-
gateway: {
|
|
1156
|
-
startAccount(ctx: GatewayContext): Promise<void>;
|
|
1157
|
-
stopAccount(ctx: GatewayContext): Promise<void>;
|
|
1158
|
-
};
|
|
1159
|
-
outbound: {
|
|
1160
|
-
deliveryMode: "direct";
|
|
1161
|
-
sendText(ctx: OutboundContext): Promise<DeliveryResult>;
|
|
1162
|
-
sendPayload(ctx: OutboundPayloadContext): Promise<DeliveryResult>;
|
|
1163
|
-
resolveTarget(params: {
|
|
1164
|
-
cfg?: unknown;
|
|
1165
|
-
to?: string;
|
|
1166
|
-
accountId?: string | null;
|
|
1167
|
-
}): {
|
|
1168
|
-
ok: true;
|
|
1169
|
-
to: string;
|
|
1170
|
-
} | {
|
|
1171
|
-
ok: false;
|
|
1172
|
-
error: Error;
|
|
1173
|
-
};
|
|
1174
|
-
};
|
|
1175
|
-
status: {
|
|
1176
|
-
probeAccount(params: {
|
|
1177
|
-
account: ResolvedAccount;
|
|
1178
|
-
timeoutMs: number;
|
|
1179
|
-
cfg: unknown;
|
|
1180
|
-
}): Promise<LingyaoProbeResult>;
|
|
1181
|
-
buildChannelSummary(params: {
|
|
1182
|
-
account: ResolvedAccount;
|
|
1183
|
-
cfg: unknown;
|
|
1184
|
-
defaultAccountId: string;
|
|
1185
|
-
snapshot: Record<string, unknown>;
|
|
1186
|
-
}): Promise<Record<string, unknown>>;
|
|
1187
|
-
};
|
|
1188
|
-
directory: {
|
|
1189
|
-
listPeers(params: {
|
|
1190
|
-
cfg: unknown;
|
|
1191
|
-
accountId?: string | null;
|
|
1192
|
-
query?: string | null;
|
|
1193
|
-
limit?: number | null;
|
|
1194
|
-
runtime?: unknown;
|
|
1195
|
-
}): Promise<DirectoryEntry[]>;
|
|
1196
|
-
};
|
|
1197
|
-
messaging: {
|
|
1198
|
-
normalizeTarget(raw: string): string | undefined;
|
|
1199
|
-
resolveSessionTarget(params: {
|
|
1200
|
-
kind: "group" | "channel";
|
|
1201
|
-
id: string;
|
|
1202
|
-
threadId?: string | null;
|
|
1203
|
-
}): string | undefined;
|
|
1204
|
-
inferTargetChatType(_params: {
|
|
1205
|
-
to: string;
|
|
1206
|
-
}): "direct" | undefined;
|
|
1207
|
-
};
|
|
1208
|
-
};
|
|
1209
|
-
security: {
|
|
1210
|
-
dm: {
|
|
1211
|
-
channelKey: string;
|
|
1212
|
-
resolvePolicy: (account: ResolvedAccount) => "paired" | "open" | "deny";
|
|
1213
|
-
resolveAllowFrom: (account: ResolvedAccount) => readonly string[];
|
|
1214
|
-
defaultPolicy: "paired";
|
|
1215
|
-
};
|
|
1216
|
-
};
|
|
1217
|
-
pairing: {
|
|
1218
|
-
text: {
|
|
1219
|
-
idLabel: string;
|
|
1220
|
-
message: string;
|
|
1221
|
-
notify: (params: {
|
|
1222
|
-
cfg: unknown;
|
|
1223
|
-
id: string;
|
|
1224
|
-
}) => Promise<void>;
|
|
1225
|
-
};
|
|
1226
|
-
};
|
|
1227
|
-
};
|
|
1228
970
|
|
|
1229
|
-
export { type AgentMessage, DeviceInfo, DeviceToken, HealthStatus,
|
|
971
|
+
export { type AgentMessage, DeviceInfo, DeviceToken, HealthStatus, LingyaoChannel, LingyaoConfig, LingyaoMessage, LingyaoRuntime, NotifyPayload, SyncRequest, SyncResponse, createPlugin, _default as default, getDefaultConfig, pluginMetadata, validateConfig };
|