@lingyao037/openclaw-lingyao-cli 0.9.6 → 0.9.7
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 +11 -8
- package/dist/index.js +34 -9
- package/dist/index.js.map +1 -1
- package/dist/setup-entry.js +1 -1
- package/dist/setup-entry.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -169,18 +169,17 @@ declare class ServerHttpClient {
|
|
|
169
169
|
*/
|
|
170
170
|
type ConnectionState = "connecting" | "connected" | "disconnected" | "error";
|
|
171
171
|
/**
|
|
172
|
-
* WebSocket
|
|
172
|
+
* WebSocket 消息类型(与 `lingyao/server/src/server.ts` 中 Gateway 协议一致)
|
|
173
173
|
*/
|
|
174
174
|
declare enum WSMessageType {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
HEARTBEAT_ACK = "heartbeat_ack",
|
|
175
|
+
GATEWAY_REGISTER = "gateway_register",
|
|
176
|
+
GATEWAY_HEARTBEAT = "gateway_heartbeat",
|
|
177
|
+
GATEWAY_SEND_MESSAGE = "gateway_send_message",
|
|
178
|
+
GATEWAY_REGISTERED = "gateway_registered",
|
|
179
|
+
GATEWAY_HEARTBEAT_ACK = "gateway_heartbeat_ack",
|
|
181
180
|
MESSAGE_DELIVERED = "message_delivered",
|
|
182
181
|
MESSAGE_FAILED = "message_failed",
|
|
183
|
-
APP_MESSAGE = "app_message"
|
|
182
|
+
APP_MESSAGE = "app_message",
|
|
184
183
|
DEVICE_ONLINE = "device_online",
|
|
185
184
|
PAIRING_COMPLETED = "pairing_completed",
|
|
186
185
|
ERROR = "error"
|
|
@@ -340,6 +339,10 @@ declare class LingyaoWSClient {
|
|
|
340
339
|
* 处理消息发送成功
|
|
341
340
|
*/
|
|
342
341
|
private handleMessageDelivered;
|
|
342
|
+
/**
|
|
343
|
+
* 设备上线(服务器可选推送)
|
|
344
|
+
*/
|
|
345
|
+
private handleDeviceOnline;
|
|
343
346
|
/**
|
|
344
347
|
* 处理配对完成通知(来自 lingyao.live 服务器)
|
|
345
348
|
*/
|
package/dist/index.js
CHANGED
|
@@ -736,6 +736,20 @@ import WebSocket from "ws";
|
|
|
736
736
|
function isWebsocketUpgradeNotFoundError(message) {
|
|
737
737
|
return /Unexpected server response:\s*404/i.test(message) || /\b404\b/.test(message);
|
|
738
738
|
}
|
|
739
|
+
function normalizeIncomingGatewayMessageType(type) {
|
|
740
|
+
switch (type) {
|
|
741
|
+
case "registered":
|
|
742
|
+
return "gateway_registered" /* GATEWAY_REGISTERED */;
|
|
743
|
+
case "heartbeat_ack":
|
|
744
|
+
return "gateway_heartbeat_ack" /* GATEWAY_HEARTBEAT_ACK */;
|
|
745
|
+
case "gateway_registered":
|
|
746
|
+
return "gateway_registered" /* GATEWAY_REGISTERED */;
|
|
747
|
+
case "gateway_heartbeat_ack":
|
|
748
|
+
return "gateway_heartbeat_ack" /* GATEWAY_HEARTBEAT_ACK */;
|
|
749
|
+
default:
|
|
750
|
+
return type;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
739
753
|
var LingyaoWSClient = class {
|
|
740
754
|
config;
|
|
741
755
|
ws = null;
|
|
@@ -750,11 +764,12 @@ var LingyaoWSClient = class {
|
|
|
750
764
|
constructor(runtime, config) {
|
|
751
765
|
this.logger = runtime.logger;
|
|
752
766
|
this.config = { ...config };
|
|
753
|
-
this.registerMessageHandler("
|
|
754
|
-
this.registerMessageHandler("
|
|
767
|
+
this.registerMessageHandler("gateway_registered" /* GATEWAY_REGISTERED */, this.handleRegistered.bind(this));
|
|
768
|
+
this.registerMessageHandler("gateway_heartbeat_ack" /* GATEWAY_HEARTBEAT_ACK */, this.handleHeartbeatAck.bind(this));
|
|
755
769
|
this.registerMessageHandler("message_delivered" /* MESSAGE_DELIVERED */, this.handleMessageDelivered.bind(this));
|
|
756
770
|
this.registerMessageHandler("message_failed" /* MESSAGE_FAILED */, this.handleMessageFailed.bind(this));
|
|
757
771
|
this.registerMessageHandler("app_message" /* APP_MESSAGE */, this.handleAppMessage.bind(this));
|
|
772
|
+
this.registerMessageHandler("device_online" /* DEVICE_ONLINE */, this.handleDeviceOnline.bind(this));
|
|
758
773
|
this.registerMessageHandler("pairing_completed" /* PAIRING_COMPLETED */, this.handlePairingCompleted.bind(this));
|
|
759
774
|
this.registerMessageHandler("error" /* ERROR */, this.handleError.bind(this));
|
|
760
775
|
}
|
|
@@ -828,12 +843,14 @@ var LingyaoWSClient = class {
|
|
|
828
843
|
async handleMessage(data) {
|
|
829
844
|
try {
|
|
830
845
|
const message = JSON.parse(data.toString());
|
|
831
|
-
|
|
832
|
-
const
|
|
846
|
+
const rawType = String(message.type);
|
|
847
|
+
const handlerKey = normalizeIncomingGatewayMessageType(rawType);
|
|
848
|
+
this.logger.debug("Received message from server", { type: rawType, handlerKey });
|
|
849
|
+
const handler = this.messageHandlers.get(handlerKey);
|
|
833
850
|
if (handler) {
|
|
834
851
|
handler(message);
|
|
835
852
|
} else {
|
|
836
|
-
this.logger.warn("No handler for message type", { type:
|
|
853
|
+
this.logger.warn("No handler for message type", { type: rawType });
|
|
837
854
|
}
|
|
838
855
|
this.emitEvent({ type: "message", message });
|
|
839
856
|
} catch (error) {
|
|
@@ -884,7 +901,7 @@ var LingyaoWSClient = class {
|
|
|
884
901
|
*/
|
|
885
902
|
sendRegister() {
|
|
886
903
|
const message = {
|
|
887
|
-
type: "
|
|
904
|
+
type: "gateway_register" /* GATEWAY_REGISTER */,
|
|
888
905
|
id: this.generateMessageId(),
|
|
889
906
|
timestamp: Date.now(),
|
|
890
907
|
payload: {
|
|
@@ -913,7 +930,7 @@ var LingyaoWSClient = class {
|
|
|
913
930
|
*/
|
|
914
931
|
sendHeartbeat() {
|
|
915
932
|
const message = {
|
|
916
|
-
type: "
|
|
933
|
+
type: "gateway_heartbeat" /* GATEWAY_HEARTBEAT */,
|
|
917
934
|
id: this.generateMessageId(),
|
|
918
935
|
timestamp: Date.now(),
|
|
919
936
|
payload: {
|
|
@@ -984,7 +1001,7 @@ var LingyaoWSClient = class {
|
|
|
984
1001
|
*/
|
|
985
1002
|
sendNotification(deviceId, notification) {
|
|
986
1003
|
const message = {
|
|
987
|
-
type: "
|
|
1004
|
+
type: "gateway_send_message" /* GATEWAY_SEND_MESSAGE */,
|
|
988
1005
|
id: this.generateMessageId(),
|
|
989
1006
|
timestamp: Date.now(),
|
|
990
1007
|
payload: {
|
|
@@ -1023,6 +1040,14 @@ var LingyaoWSClient = class {
|
|
|
1023
1040
|
messageId: message.id
|
|
1024
1041
|
});
|
|
1025
1042
|
}
|
|
1043
|
+
/**
|
|
1044
|
+
* 设备上线(服务器可选推送)
|
|
1045
|
+
*/
|
|
1046
|
+
handleDeviceOnline(message) {
|
|
1047
|
+
this.logger.debug("Device online (server push)", {
|
|
1048
|
+
payload: message.payload
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1026
1051
|
/**
|
|
1027
1052
|
* 处理配对完成通知(来自 lingyao.live 服务器)
|
|
1028
1053
|
*/
|
|
@@ -3799,7 +3824,7 @@ async function createPlugin(runtime, config = {}) {
|
|
|
3799
3824
|
}
|
|
3800
3825
|
var pluginMetadata = {
|
|
3801
3826
|
name: "lingyao",
|
|
3802
|
-
version: "0.9.
|
|
3827
|
+
version: "0.9.7",
|
|
3803
3828
|
description: "Lingyao Channel Plugin - bidirectional sync via lingyao.live server relay",
|
|
3804
3829
|
type: "channel",
|
|
3805
3830
|
capabilities: {
|