@lingyao037/openclaw-lingyao-cli 1.4.0 → 1.5.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/cli.d.ts +2 -210
- package/dist/index.d.ts +290 -6
- package/dist/index.js +41 -10
- package/dist/index.js.map +1 -1
- package/dist/probe-DW7_cF66.d.ts +212 -0
- package/dist/setup-entry.d.ts +2 -2
- package/dist/setup-entry.js +14 -0
- package/dist/setup-entry.js.map +1 -1
- package/dist/{status-Bjzb8u67.d.ts → status-n_XeBoR3.d.ts} +1 -1
- package/dist/{types-XJDsfTRA.d.ts → types-BFXkMaHp.d.ts} +10 -1
- package/package.json +1 -1
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { L as LingyaoRuntime, f as LingyaoAccount, c as DeviceToken, D as DeviceInfo, H as HealthStatus } from './types-BFXkMaHp.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Account storage and management
|
|
5
|
+
*/
|
|
6
|
+
declare class AccountManager {
|
|
7
|
+
private runtime;
|
|
8
|
+
private accounts;
|
|
9
|
+
private pendingPairings;
|
|
10
|
+
/** Debounced flush for high-frequency updates (e.g. heartbeat lastSeen). */
|
|
11
|
+
private accountsSaveTimer;
|
|
12
|
+
private static readonly ACCOUNTS_SAVE_DEBOUNCE_MS;
|
|
13
|
+
constructor(runtime: LingyaoRuntime);
|
|
14
|
+
/**
|
|
15
|
+
* Initialize account manager from storage
|
|
16
|
+
*/
|
|
17
|
+
initialize(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Get account by device ID
|
|
20
|
+
*/
|
|
21
|
+
getAccount(deviceId: string): LingyaoAccount | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Get account by device token
|
|
24
|
+
*/
|
|
25
|
+
getAccountByToken(token: string): LingyaoAccount | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Get all active accounts
|
|
28
|
+
*/
|
|
29
|
+
getActiveAccounts(): LingyaoAccount[];
|
|
30
|
+
/**
|
|
31
|
+
* Create a new pairing session
|
|
32
|
+
*/
|
|
33
|
+
createPairingSession(code: string, expiresAt: number): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Get pairing session by code
|
|
36
|
+
*/
|
|
37
|
+
getPairingSession(code: string): PairingSession | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Remove a pending pairing (e.g. expired or cancelled)
|
|
40
|
+
*/
|
|
41
|
+
deletePendingPairing(code: string): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Confirm pairing and create account
|
|
44
|
+
*/
|
|
45
|
+
confirmPairing(pairingCode: string, deviceToken: DeviceToken, deviceInfo: DeviceInfo): Promise<LingyaoAccount | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Update account's last seen timestamp
|
|
48
|
+
*/
|
|
49
|
+
updateLastSeen(deviceId: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Persist any debounced account state immediately (e.g. before process/account shutdown).
|
|
52
|
+
*/
|
|
53
|
+
flushPendingAccountsSave(): Promise<void>;
|
|
54
|
+
private scheduleDebouncedAccountsSave;
|
|
55
|
+
/**
|
|
56
|
+
* Revoke an account
|
|
57
|
+
*/
|
|
58
|
+
revokeAccount(deviceId: string): Promise<boolean>;
|
|
59
|
+
/**
|
|
60
|
+
* Manually add a device by deviceId (user-initiated pairing).
|
|
61
|
+
* No pairing code or deviceToken required — the user explicitly
|
|
62
|
+
* trusts this device from the OpenClaw CLI.
|
|
63
|
+
*/
|
|
64
|
+
addDevice(deviceId: string, deviceInfo: DeviceInfo): Promise<LingyaoAccount>;
|
|
65
|
+
/**
|
|
66
|
+
* Refresh device token
|
|
67
|
+
*/
|
|
68
|
+
refreshDeviceToken(deviceId: string, newToken: DeviceToken): Promise<boolean>;
|
|
69
|
+
/**
|
|
70
|
+
* Clean up expired accounts
|
|
71
|
+
*/
|
|
72
|
+
cleanupExpired(): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Save accounts to storage (immediate; clears any pending debounced save).
|
|
75
|
+
*/
|
|
76
|
+
private saveAccounts;
|
|
77
|
+
private persistAccounts;
|
|
78
|
+
/**
|
|
79
|
+
* Save pending pairings to storage
|
|
80
|
+
*/
|
|
81
|
+
private savePendingPairings;
|
|
82
|
+
}
|
|
83
|
+
interface PairingSession {
|
|
84
|
+
code: string;
|
|
85
|
+
createdAt: number;
|
|
86
|
+
expiresAt: number;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Probe status levels
|
|
91
|
+
*/
|
|
92
|
+
declare enum ProbeStatus {
|
|
93
|
+
HEALTHY = "healthy",
|
|
94
|
+
DEGRADED = "degraded",
|
|
95
|
+
UNHEALTHY = "unhealthy"
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Health check result
|
|
99
|
+
*/
|
|
100
|
+
interface HealthCheckResult {
|
|
101
|
+
status: ProbeStatus;
|
|
102
|
+
checks: Map<string, CheckResult>;
|
|
103
|
+
timestamp: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Individual check result
|
|
107
|
+
*/
|
|
108
|
+
interface CheckResult {
|
|
109
|
+
passed: boolean;
|
|
110
|
+
message?: string;
|
|
111
|
+
duration: number;
|
|
112
|
+
error?: Error;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Channel status for reporting
|
|
116
|
+
*/
|
|
117
|
+
interface ChannelStatus {
|
|
118
|
+
configured: boolean;
|
|
119
|
+
running: boolean;
|
|
120
|
+
lastError?: string;
|
|
121
|
+
activeAccounts: number;
|
|
122
|
+
uptime: number;
|
|
123
|
+
status: ProbeStatus;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Probe - Channel health status and monitoring
|
|
127
|
+
*/
|
|
128
|
+
declare class Probe {
|
|
129
|
+
private runtime;
|
|
130
|
+
private startTime;
|
|
131
|
+
private lastError;
|
|
132
|
+
private lastErrorTime;
|
|
133
|
+
private errorCounts;
|
|
134
|
+
private healthChecks;
|
|
135
|
+
constructor(runtime: LingyaoRuntime);
|
|
136
|
+
/**
|
|
137
|
+
* Register a custom health check
|
|
138
|
+
*/
|
|
139
|
+
registerHealthCheck(name: string, check: HealthCheckFn): void;
|
|
140
|
+
/**
|
|
141
|
+
* Run all health checks
|
|
142
|
+
*/
|
|
143
|
+
runHealthChecks(): Promise<HealthCheckResult>;
|
|
144
|
+
/**
|
|
145
|
+
* Get channel status for reporting
|
|
146
|
+
*/
|
|
147
|
+
getChannelStatus(configured: boolean, running: boolean, activeAccounts?: number): ChannelStatus;
|
|
148
|
+
/**
|
|
149
|
+
* Get health status for API endpoint
|
|
150
|
+
*/
|
|
151
|
+
getHealthStatus(activeConnections?: number, queuedMessages?: number): Promise<HealthStatus>;
|
|
152
|
+
/**
|
|
153
|
+
* Record an error
|
|
154
|
+
*/
|
|
155
|
+
recordError(error: string, category?: string): void;
|
|
156
|
+
/**
|
|
157
|
+
* Get last error
|
|
158
|
+
*/
|
|
159
|
+
getLastError(): string | null;
|
|
160
|
+
/**
|
|
161
|
+
* Clear last error
|
|
162
|
+
*/
|
|
163
|
+
clearLastError(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Get error counts by category
|
|
166
|
+
*/
|
|
167
|
+
getErrorCounts(): Record<string, number>;
|
|
168
|
+
/**
|
|
169
|
+
* Reset error counts
|
|
170
|
+
*/
|
|
171
|
+
resetErrorCounts(): void;
|
|
172
|
+
/**
|
|
173
|
+
* Get uptime in milliseconds
|
|
174
|
+
*/
|
|
175
|
+
getUptime(): number;
|
|
176
|
+
/**
|
|
177
|
+
* Get uptime formatted as human-readable string
|
|
178
|
+
*/
|
|
179
|
+
getUptimeString(): string;
|
|
180
|
+
/**
|
|
181
|
+
* Health check: uptime
|
|
182
|
+
*/
|
|
183
|
+
private checkUptime;
|
|
184
|
+
/**
|
|
185
|
+
* Health check: errors
|
|
186
|
+
*/
|
|
187
|
+
private checkErrors;
|
|
188
|
+
/**
|
|
189
|
+
* Create status adapter for OpenClaw integration
|
|
190
|
+
*/
|
|
191
|
+
createStatusAdapter(configured: boolean): {
|
|
192
|
+
getStatus: (running: boolean, activeAccounts?: number, activeConnections?: number, queuedMessages?: number) => Promise<{
|
|
193
|
+
activeConnections: number;
|
|
194
|
+
queuedMessages: number;
|
|
195
|
+
configured: boolean;
|
|
196
|
+
running: boolean;
|
|
197
|
+
lastError?: string;
|
|
198
|
+
activeAccounts: number;
|
|
199
|
+
uptime: number;
|
|
200
|
+
status: ProbeStatus;
|
|
201
|
+
}>;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Health check function signature
|
|
206
|
+
*/
|
|
207
|
+
type HealthCheckFn = () => Promise<{
|
|
208
|
+
passed: boolean;
|
|
209
|
+
message?: string;
|
|
210
|
+
}>;
|
|
211
|
+
|
|
212
|
+
export { AccountManager as A, Probe as P };
|
package/dist/setup-entry.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as openclaw_plugin_sdk from 'openclaw/plugin-sdk';
|
|
2
|
-
import { R as ResolvedAccount, L as LingyaoProbeResult } from './status-
|
|
3
|
-
import './types-
|
|
2
|
+
import { R as ResolvedAccount, L as LingyaoProbeResult } from './status-n_XeBoR3.js';
|
|
3
|
+
import './types-BFXkMaHp.js';
|
|
4
4
|
|
|
5
5
|
declare const _default: {
|
|
6
6
|
plugin: openclaw_plugin_sdk.ChannelPlugin<ResolvedAccount, LingyaoProbeResult>;
|
package/dist/setup-entry.js
CHANGED
|
@@ -32,6 +32,8 @@ var lingyaoConfigSchema = z.object({
|
|
|
32
32
|
dmPolicy: lingyaoDmPolicySchema.optional().default("pairing"),
|
|
33
33
|
allowFrom: allowFromSchema.default([]),
|
|
34
34
|
websocketHeartbeatIntervalMs: z.number().int().min(5e3).max(12e4).optional(),
|
|
35
|
+
notificationRatePerSecond: z.number().positive().max(500).optional(),
|
|
36
|
+
notificationBurst: z.number().int().positive().max(1e4).optional(),
|
|
35
37
|
defaultAccount: z.string().min(1).optional(),
|
|
36
38
|
accounts: z.record(lingyaoAccountConfigSchema).optional()
|
|
37
39
|
});
|
|
@@ -63,6 +65,18 @@ var lingyaoChannelConfigSchema = {
|
|
|
63
65
|
maximum: 12e4,
|
|
64
66
|
description: "WebSocket gateway_heartbeat interval in ms (default: server register response). Use 5000\u201355000 for typical relay timeout."
|
|
65
67
|
},
|
|
68
|
+
notificationRatePerSecond: {
|
|
69
|
+
type: "number",
|
|
70
|
+
minimum: 0.1,
|
|
71
|
+
maximum: 500,
|
|
72
|
+
description: "Token bucket refill rate for outbound App notifications (default 15). Override with LINGYAO_NOTIFY_RATE_PER_SEC env if runtime config is not merged."
|
|
73
|
+
},
|
|
74
|
+
notificationBurst: {
|
|
75
|
+
type: "integer",
|
|
76
|
+
minimum: 1,
|
|
77
|
+
maximum: 1e4,
|
|
78
|
+
description: "Max burst for outbound notifications (default 25). Env: LINGYAO_NOTIFY_BURST."
|
|
79
|
+
},
|
|
66
80
|
accounts: {
|
|
67
81
|
type: "object",
|
|
68
82
|
additionalProperties: false,
|