@lingyao037/openclaw-lingyao-cli 0.3.5 → 0.4.1
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-DeDlxyS9.d.ts} +7 -1
- package/dist/cli.d.ts +16 -2
- package/dist/cli.js +42 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +258 -562
- package/dist/index.js +203 -59
- 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,40 +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-DeDlxyS9.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-DeDlxyS9.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
|
|
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 错误基类
|
|
11
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
|
+
}
|
|
12
34
|
/**
|
|
13
|
-
*
|
|
35
|
+
* 错误处理器
|
|
14
36
|
*/
|
|
15
|
-
|
|
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
|
+
}
|
|
16
117
|
|
|
17
118
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* serverUrl is NOT exposed to users — hardcoded as LINGYAO_SERVER_URL.
|
|
119
|
+
* Token management utilities
|
|
21
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
|
+
}
|
|
22
164
|
|
|
23
165
|
/**
|
|
24
|
-
*
|
|
166
|
+
* Agent message format - messages passed directly to Agent
|
|
25
167
|
*/
|
|
26
|
-
interface
|
|
27
|
-
|
|
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;
|
|
28
176
|
}
|
|
29
177
|
/**
|
|
30
|
-
*
|
|
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
|
|
31
183
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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;
|
|
38
260
|
}
|
|
39
261
|
|
|
40
262
|
/**
|
|
@@ -395,106 +617,9 @@ declare class LingyaoWSClient {
|
|
|
395
617
|
}
|
|
396
618
|
|
|
397
619
|
/**
|
|
398
|
-
*
|
|
620
|
+
* 监控和指标收集模块
|
|
399
621
|
*/
|
|
400
|
-
|
|
401
|
-
id: string;
|
|
402
|
-
type: "diary" | "memory" | "heartbeat";
|
|
403
|
-
from: string;
|
|
404
|
-
deviceId: string;
|
|
405
|
-
content: string;
|
|
406
|
-
metadata: Record<string, unknown>;
|
|
407
|
-
timestamp: number;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Message handler callback for delivering messages to Agent
|
|
411
|
-
*/
|
|
412
|
-
type MessageHandler = (message: AgentMessage) => void | Promise<void>;
|
|
413
|
-
/**
|
|
414
|
-
* Message Processor - Handles incoming messages and routes them to Agent
|
|
415
|
-
*/
|
|
416
|
-
declare class MessageProcessor {
|
|
417
|
-
private runtime;
|
|
418
|
-
private accountManager;
|
|
419
|
-
private messageQueue;
|
|
420
|
-
private seenMessages;
|
|
421
|
-
private messageHandler;
|
|
422
|
-
private readonly maxQueueSize;
|
|
423
|
-
constructor(runtime: LingyaoRuntime, accountManager: AccountManager);
|
|
424
|
-
/**
|
|
425
|
-
* Initialize the message processor
|
|
426
|
-
*/
|
|
427
|
-
initialize(): Promise<void>;
|
|
428
|
-
/**
|
|
429
|
-
* Set the message handler for delivering messages to Agent
|
|
430
|
-
*/
|
|
431
|
-
setMessageHandler(handler: MessageHandler): void;
|
|
432
|
-
/**
|
|
433
|
-
* Get the currently registered Agent message handler.
|
|
434
|
-
*/
|
|
435
|
-
getMessageHandler(): MessageHandler | null;
|
|
436
|
-
/**
|
|
437
|
-
* Deliver a normalized message directly to the registered Agent handler.
|
|
438
|
-
*/
|
|
439
|
-
deliverToAgent(message: AgentMessage): Promise<void>;
|
|
440
|
-
/**
|
|
441
|
-
* Process sync request from app
|
|
442
|
-
*/
|
|
443
|
-
processSync(deviceId: string, request: SyncRequest): Promise<SyncResponse>;
|
|
444
|
-
/**
|
|
445
|
-
* Process a single message
|
|
446
|
-
*/
|
|
447
|
-
private processMessage;
|
|
448
|
-
/**
|
|
449
|
-
* Process diary sync - Pass directly to Agent
|
|
450
|
-
*/
|
|
451
|
-
private processDiarySync;
|
|
452
|
-
/**
|
|
453
|
-
* Process memory sync - Pass directly to Agent
|
|
454
|
-
*/
|
|
455
|
-
private processMemorySync;
|
|
456
|
-
/**
|
|
457
|
-
* Process sync acknowledgment
|
|
458
|
-
*/
|
|
459
|
-
private processSyncAck;
|
|
460
|
-
/**
|
|
461
|
-
* Process heartbeat
|
|
462
|
-
*/
|
|
463
|
-
private processHeartbeat;
|
|
464
|
-
/**
|
|
465
|
-
* Poll for new messages (long-polling)
|
|
466
|
-
*/
|
|
467
|
-
pollMessages(deviceId: string, timeout?: number): Promise<LingyaoMessage[]>;
|
|
468
|
-
/**
|
|
469
|
-
* Queue a message for a device
|
|
470
|
-
*/
|
|
471
|
-
queueMessage(deviceId: string, message: LingyaoMessage): boolean;
|
|
472
|
-
/**
|
|
473
|
-
* Acknowledge messages
|
|
474
|
-
*/
|
|
475
|
-
acknowledgeMessages(messageIds: string[]): Promise<void>;
|
|
476
|
-
/**
|
|
477
|
-
* Check if message has been seen (deduplication)
|
|
478
|
-
*/
|
|
479
|
-
private isMessageSeen;
|
|
480
|
-
/**
|
|
481
|
-
* Mark message as seen
|
|
482
|
-
*/
|
|
483
|
-
private markMessageSeen;
|
|
484
|
-
/**
|
|
485
|
-
* Get queue size for a device
|
|
486
|
-
*/
|
|
487
|
-
getQueueSize(deviceId: string): number;
|
|
488
|
-
/**
|
|
489
|
-
* Get total queue size
|
|
490
|
-
*/
|
|
491
|
-
getTotalQueueSize(): number;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* 监控和指标收集模块
|
|
496
|
-
*/
|
|
497
|
-
|
|
622
|
+
|
|
498
623
|
/**
|
|
499
624
|
* 指标类型
|
|
500
625
|
*/
|
|
@@ -658,334 +783,6 @@ declare class Monitor {
|
|
|
658
783
|
};
|
|
659
784
|
}
|
|
660
785
|
|
|
661
|
-
/**
|
|
662
|
-
* 错误处理模块
|
|
663
|
-
*/
|
|
664
|
-
|
|
665
|
-
/**
|
|
666
|
-
* 错误严重级别
|
|
667
|
-
*/
|
|
668
|
-
declare enum ErrorSeverity {
|
|
669
|
-
LOW = "low",
|
|
670
|
-
MEDIUM = "medium",
|
|
671
|
-
HIGH = "high",
|
|
672
|
-
CRITICAL = "critical"
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* Lingyao 错误基类
|
|
676
|
-
*/
|
|
677
|
-
declare class LingyaoError extends Error {
|
|
678
|
-
readonly code: string;
|
|
679
|
-
readonly severity: ErrorSeverity;
|
|
680
|
-
readonly timestamp: number;
|
|
681
|
-
readonly context?: Record<string, unknown>;
|
|
682
|
-
readonly cause?: Error;
|
|
683
|
-
constructor(message: string, code: string, severity?: ErrorSeverity, context?: Record<string, unknown>, cause?: Error);
|
|
684
|
-
/**
|
|
685
|
-
* 转换为 JSON 可序列化格式
|
|
686
|
-
*/
|
|
687
|
-
toJSON(): Record<string, unknown>;
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* 错误处理器
|
|
691
|
-
*/
|
|
692
|
-
declare class ErrorHandler {
|
|
693
|
-
private runtime;
|
|
694
|
-
private errorCounts;
|
|
695
|
-
private lastErrors;
|
|
696
|
-
private errorThresholds;
|
|
697
|
-
constructor(runtime: LingyaoRuntime);
|
|
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
|
-
* Directory Adapter - List paired devices (peers)
|
|
775
|
-
*
|
|
776
|
-
* Implements ChannelDirectoryAdapter:
|
|
777
|
-
* - listPeers: return all active paired devices for an account
|
|
778
|
-
*
|
|
779
|
-
* SDK passes:
|
|
780
|
-
* listPeers({ cfg, accountId?, query?, limit?, runtime })
|
|
781
|
-
*
|
|
782
|
-
* Returns ChannelDirectoryEntry[] with { kind, id, name?, ... }
|
|
783
|
-
*
|
|
784
|
-
* Uses AccountManager to get the device list.
|
|
785
|
-
* Each device is returned as a "user" peer (no groups in Lingyao).
|
|
786
|
-
*/
|
|
787
|
-
|
|
788
|
-
/**
|
|
789
|
-
* SDK-compatible directory interfaces
|
|
790
|
-
*/
|
|
791
|
-
interface OpenClawConfig$3 {
|
|
792
|
-
channels?: Record<string, unknown>;
|
|
793
|
-
}
|
|
794
|
-
type ChannelDirectoryEntryKind = 'user' | 'group' | 'channel';
|
|
795
|
-
interface ChannelDirectoryEntry {
|
|
796
|
-
kind: ChannelDirectoryEntryKind;
|
|
797
|
-
id: string;
|
|
798
|
-
name?: string;
|
|
799
|
-
handle?: string;
|
|
800
|
-
avatarUrl?: string;
|
|
801
|
-
rank?: number;
|
|
802
|
-
raw?: unknown;
|
|
803
|
-
}
|
|
804
|
-
interface RuntimeEnv$1 {
|
|
805
|
-
}
|
|
806
|
-
interface ChannelDirectoryListParams {
|
|
807
|
-
cfg: OpenClawConfig$3;
|
|
808
|
-
accountId?: string | null;
|
|
809
|
-
query?: string | null;
|
|
810
|
-
limit?: number | null;
|
|
811
|
-
runtime: RuntimeEnv$1;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
/**
|
|
815
|
-
* Status Adapter - Health checks and channel summary
|
|
816
|
-
*
|
|
817
|
-
* Implements ChannelStatusAdapter:
|
|
818
|
-
* - probeAccount: run health checks for a specific account
|
|
819
|
-
* - buildChannelSummary: aggregate status for a single account
|
|
820
|
-
*
|
|
821
|
-
* SDK passes:
|
|
822
|
-
* probeAccount({ account, timeoutMs, cfg })
|
|
823
|
-
* buildChannelSummary({ account, cfg, defaultAccountId, snapshot })
|
|
824
|
-
*
|
|
825
|
-
* Wraps existing Probe and Monitor classes.
|
|
826
|
-
*/
|
|
827
|
-
|
|
828
|
-
/**
|
|
829
|
-
* SDK-compatible status interfaces
|
|
830
|
-
*/
|
|
831
|
-
interface OpenClawConfig$2 {
|
|
832
|
-
channels?: Record<string, unknown>;
|
|
833
|
-
}
|
|
834
|
-
interface ChannelAccountSnapshot$1 {
|
|
835
|
-
accountId: string;
|
|
836
|
-
configured: boolean;
|
|
837
|
-
enabled: boolean;
|
|
838
|
-
running: boolean;
|
|
839
|
-
}
|
|
840
|
-
/**
|
|
841
|
-
* Probe result structure.
|
|
842
|
-
*/
|
|
843
|
-
interface LingyaoProbeResult {
|
|
844
|
-
ok: boolean;
|
|
845
|
-
status: 'healthy' | 'degraded' | 'unhealthy';
|
|
846
|
-
wsConnected: boolean;
|
|
847
|
-
uptime?: number;
|
|
848
|
-
checks?: Record<string, {
|
|
849
|
-
passed: boolean;
|
|
850
|
-
message: string;
|
|
851
|
-
duration?: number;
|
|
852
|
-
}>;
|
|
853
|
-
error?: string;
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
/**
|
|
857
|
-
* Outbound Adapter - Send messages from Agent to App devices
|
|
858
|
-
*
|
|
859
|
-
* Implements ChannelOutboundAdapter:
|
|
860
|
-
* - deliveryMode: "direct" (synchronous via WS)
|
|
861
|
-
* - sendText: send plain text notification
|
|
862
|
-
* - sendPayload: send structured payload notification
|
|
863
|
-
* - resolveTarget: validate and resolve target deviceId
|
|
864
|
-
*
|
|
865
|
-
* SDK passes ChannelOutboundContext = { cfg, to, text, accountId?, ... }
|
|
866
|
-
* and expects OutboundDeliveryResult = { channel, messageId, ... } return.
|
|
867
|
-
*
|
|
868
|
-
* Routes through MultiAccountOrchestrator to the correct
|
|
869
|
-
* account's WS connection.
|
|
870
|
-
*/
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* SDK-compatible outbound interfaces
|
|
874
|
-
*/
|
|
875
|
-
interface OpenClawConfig$1 {
|
|
876
|
-
channels?: Record<string, unknown>;
|
|
877
|
-
}
|
|
878
|
-
interface ChannelOutboundContext {
|
|
879
|
-
cfg: OpenClawConfig$1;
|
|
880
|
-
to: string;
|
|
881
|
-
text: string;
|
|
882
|
-
mediaUrl?: string;
|
|
883
|
-
accountId?: string | null;
|
|
884
|
-
silent?: boolean;
|
|
885
|
-
}
|
|
886
|
-
interface ChannelOutboundPayloadContext extends ChannelOutboundContext {
|
|
887
|
-
payload: unknown;
|
|
888
|
-
}
|
|
889
|
-
interface OutboundDeliveryResult {
|
|
890
|
-
channel: string;
|
|
891
|
-
messageId: string;
|
|
892
|
-
chatId?: string;
|
|
893
|
-
timestamp?: number;
|
|
894
|
-
meta?: Record<string, unknown>;
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
/**
|
|
898
|
-
* Gateway Adapter - Account lifecycle management
|
|
899
|
-
*
|
|
900
|
-
* Implements ChannelGatewayAdapter:
|
|
901
|
-
* - startAccount: create WS/HTTP connections for an account
|
|
902
|
-
* - stopAccount: tear down connections for an account
|
|
903
|
-
*
|
|
904
|
-
* Delegates to MultiAccountOrchestrator for all operations.
|
|
905
|
-
*
|
|
906
|
-
* SDK passes ChannelGatewayContext with required fields:
|
|
907
|
-
* cfg, accountId, account, runtime, abortSignal, log,
|
|
908
|
-
* getStatus, setStatus, channelRuntime?
|
|
909
|
-
*/
|
|
910
|
-
|
|
911
|
-
/**
|
|
912
|
-
* SDK-compatible ChannelGatewayContext interface
|
|
913
|
-
*/
|
|
914
|
-
interface ChannelGatewayContext<ResolvedAccount = unknown> {
|
|
915
|
-
cfg: OpenClawConfig;
|
|
916
|
-
accountId: string;
|
|
917
|
-
account: ResolvedAccount;
|
|
918
|
-
runtime: RuntimeEnv;
|
|
919
|
-
abortSignal: AbortSignal;
|
|
920
|
-
log?: {
|
|
921
|
-
info: (msg: string) => void;
|
|
922
|
-
warn?: (msg: string) => void;
|
|
923
|
-
error?: (msg: string) => void;
|
|
924
|
-
debug?: (msg: string) => void;
|
|
925
|
-
};
|
|
926
|
-
getStatus: () => ChannelAccountSnapshot;
|
|
927
|
-
setStatus: (next: ChannelAccountSnapshot) => void;
|
|
928
|
-
channelRuntime?: unknown;
|
|
929
|
-
}
|
|
930
|
-
interface OpenClawConfig {
|
|
931
|
-
channels?: Record<string, unknown>;
|
|
932
|
-
}
|
|
933
|
-
interface RuntimeEnv {
|
|
934
|
-
}
|
|
935
|
-
interface ChannelAccountSnapshot {
|
|
936
|
-
accountId: string;
|
|
937
|
-
configured: boolean;
|
|
938
|
-
enabled: boolean;
|
|
939
|
-
running: boolean;
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
/**
|
|
943
|
-
* Token management utilities
|
|
944
|
-
*/
|
|
945
|
-
declare class TokenManager {
|
|
946
|
-
constructor(_runtime: LingyaoRuntime);
|
|
947
|
-
/**
|
|
948
|
-
* Generate a new device token
|
|
949
|
-
*/
|
|
950
|
-
generateDeviceToken(pairingId: string, deviceInfo: DeviceInfo, expiryDays?: number): DeviceToken;
|
|
951
|
-
/**
|
|
952
|
-
* Validate a device token
|
|
953
|
-
*/
|
|
954
|
-
validateToken(token: string, storedSecret: string): boolean;
|
|
955
|
-
/**
|
|
956
|
-
* Check if token is expired
|
|
957
|
-
*/
|
|
958
|
-
isTokenExpired(token: DeviceToken): boolean;
|
|
959
|
-
/**
|
|
960
|
-
* Refresh an existing token
|
|
961
|
-
*/
|
|
962
|
-
refreshToken(oldToken: DeviceToken, expiryDays?: number): DeviceToken;
|
|
963
|
-
/**
|
|
964
|
-
* Extract device ID from token string
|
|
965
|
-
*/
|
|
966
|
-
extractDeviceId(token: string): string | null;
|
|
967
|
-
/**
|
|
968
|
-
* Generate a unique device ID
|
|
969
|
-
*/
|
|
970
|
-
private generateDeviceId;
|
|
971
|
-
/**
|
|
972
|
-
* Generate a random secret key
|
|
973
|
-
*/
|
|
974
|
-
private generateSecret;
|
|
975
|
-
/**
|
|
976
|
-
* Generate a JWT-like token string
|
|
977
|
-
*/
|
|
978
|
-
private generateTokenString;
|
|
979
|
-
/**
|
|
980
|
-
* Sign data with secret
|
|
981
|
-
*/
|
|
982
|
-
private sign;
|
|
983
|
-
/**
|
|
984
|
-
* Base64URL encode without padding
|
|
985
|
-
*/
|
|
986
|
-
private base64UrlEncode;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
786
|
/**
|
|
990
787
|
* 灵爻频道插件 - 服务器中转模式
|
|
991
788
|
*/
|
|
@@ -1146,14 +943,17 @@ declare function validateConfig(config: unknown): LingyaoConfig;
|
|
|
1146
943
|
*/
|
|
1147
944
|
declare function getDefaultConfig(): LingyaoConfig;
|
|
1148
945
|
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
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. */
|
|
1153
955
|
declare function createPlugin(runtime: LingyaoRuntime, config?: Partial<LingyaoConfig>): Promise<LingyaoChannel>;
|
|
1154
|
-
/**
|
|
1155
|
-
* Plugin metadata (legacy API).
|
|
1156
|
-
*/
|
|
956
|
+
/** @deprecated Use openclaw.plugin.json for plugin metadata. */
|
|
1157
957
|
declare const pluginMetadata: {
|
|
1158
958
|
name: string;
|
|
1159
959
|
version: string;
|
|
@@ -1167,109 +967,5 @@ declare const pluginMetadata: {
|
|
|
1167
967
|
};
|
|
1168
968
|
defaultConfig: LingyaoConfig;
|
|
1169
969
|
};
|
|
1170
|
-
declare const pluginEntry: {
|
|
1171
|
-
id: string;
|
|
1172
|
-
name: string;
|
|
1173
|
-
description: string;
|
|
1174
|
-
setRuntime(runtime: unknown): void;
|
|
1175
|
-
readonly plugin: {
|
|
1176
|
-
id: "lingyao";
|
|
1177
|
-
meta: {
|
|
1178
|
-
id: string;
|
|
1179
|
-
label: string;
|
|
1180
|
-
selectionLabel: string;
|
|
1181
|
-
docsPath: string;
|
|
1182
|
-
docsLabel: string;
|
|
1183
|
-
blurb: string;
|
|
1184
|
-
order: number;
|
|
1185
|
-
aliases: string[];
|
|
1186
|
-
};
|
|
1187
|
-
capabilities: {
|
|
1188
|
-
chatTypes: readonly ["direct"];
|
|
1189
|
-
media: boolean;
|
|
1190
|
-
reactions: boolean;
|
|
1191
|
-
threads: boolean;
|
|
1192
|
-
polls: boolean;
|
|
1193
|
-
edit: boolean;
|
|
1194
|
-
unsend: boolean;
|
|
1195
|
-
reply: boolean;
|
|
1196
|
-
effects: boolean;
|
|
1197
|
-
groupManagement: boolean;
|
|
1198
|
-
nativeCommands: boolean;
|
|
1199
|
-
blockStreaming: boolean;
|
|
1200
|
-
};
|
|
1201
|
-
config: {
|
|
1202
|
-
listAccountIds(cfg: OpenClawConfig$4): string[];
|
|
1203
|
-
resolveAccount(cfg: OpenClawConfig$4, accountId?: string | null): ResolvedAccount;
|
|
1204
|
-
isConfigured(_account: ResolvedAccount, _cfg: OpenClawConfig$4): boolean;
|
|
1205
|
-
isEnabled(account: ResolvedAccount, _cfg: OpenClawConfig$4): boolean;
|
|
1206
|
-
};
|
|
1207
|
-
gateway: {
|
|
1208
|
-
startAccount(ctx: ChannelGatewayContext<ResolvedAccount>): Promise<void>;
|
|
1209
|
-
stopAccount(ctx: ChannelGatewayContext<ResolvedAccount>): Promise<void>;
|
|
1210
|
-
};
|
|
1211
|
-
outbound: {
|
|
1212
|
-
deliveryMode: "direct";
|
|
1213
|
-
sendText(ctx: ChannelOutboundContext): Promise<OutboundDeliveryResult>;
|
|
1214
|
-
sendPayload(ctx: ChannelOutboundPayloadContext): Promise<OutboundDeliveryResult>;
|
|
1215
|
-
resolveTarget(params: {
|
|
1216
|
-
cfg?: OpenClawConfig$1;
|
|
1217
|
-
to?: string;
|
|
1218
|
-
accountId?: string | null;
|
|
1219
|
-
}): {
|
|
1220
|
-
ok: true;
|
|
1221
|
-
to: string;
|
|
1222
|
-
} | {
|
|
1223
|
-
ok: false;
|
|
1224
|
-
error: Error;
|
|
1225
|
-
};
|
|
1226
|
-
};
|
|
1227
|
-
status: {
|
|
1228
|
-
probeAccount(params: {
|
|
1229
|
-
account: ResolvedAccount;
|
|
1230
|
-
timeoutMs: number;
|
|
1231
|
-
cfg: OpenClawConfig$2;
|
|
1232
|
-
}): Promise<LingyaoProbeResult>;
|
|
1233
|
-
buildChannelSummary(params: {
|
|
1234
|
-
account: ResolvedAccount;
|
|
1235
|
-
cfg: OpenClawConfig$2;
|
|
1236
|
-
defaultAccountId: string;
|
|
1237
|
-
snapshot: ChannelAccountSnapshot$1;
|
|
1238
|
-
}): Promise<Record<string, unknown>>;
|
|
1239
|
-
};
|
|
1240
|
-
directory: {
|
|
1241
|
-
listPeers(params: ChannelDirectoryListParams): Promise<ChannelDirectoryEntry[]>;
|
|
1242
|
-
};
|
|
1243
|
-
messaging: {
|
|
1244
|
-
normalizeTarget(raw: string): string | undefined;
|
|
1245
|
-
resolveSessionTarget(params: {
|
|
1246
|
-
kind: "user" | "group" | "channel";
|
|
1247
|
-
id: string;
|
|
1248
|
-
threadId?: string | number | null;
|
|
1249
|
-
}): string | undefined;
|
|
1250
|
-
inferTargetChatType(_params: {
|
|
1251
|
-
to: string;
|
|
1252
|
-
}): ChatType | undefined;
|
|
1253
|
-
};
|
|
1254
|
-
};
|
|
1255
|
-
security: {
|
|
1256
|
-
dm: {
|
|
1257
|
-
channelKey: string;
|
|
1258
|
-
resolvePolicy: (account: ResolvedAccount) => "paired" | "open" | "deny";
|
|
1259
|
-
resolveAllowFrom: (account: ResolvedAccount) => readonly string[];
|
|
1260
|
-
defaultPolicy: "paired";
|
|
1261
|
-
};
|
|
1262
|
-
};
|
|
1263
|
-
pairing: {
|
|
1264
|
-
text: {
|
|
1265
|
-
idLabel: string;
|
|
1266
|
-
message: string;
|
|
1267
|
-
notify: (params: {
|
|
1268
|
-
cfg: unknown;
|
|
1269
|
-
id: string;
|
|
1270
|
-
}) => Promise<void>;
|
|
1271
|
-
};
|
|
1272
|
-
};
|
|
1273
|
-
};
|
|
1274
970
|
|
|
1275
|
-
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 };
|