akemon 0.1.6 → 0.1.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/relay-client.js +24 -0
- package/package.json +1 -1
package/dist/relay-client.js
CHANGED
|
@@ -90,6 +90,9 @@ export function connectRelay(options) {
|
|
|
90
90
|
case "mcp_request":
|
|
91
91
|
handleMCPRequest(ws, msg, options.localPort);
|
|
92
92
|
break;
|
|
93
|
+
case "control":
|
|
94
|
+
handleControl(ws, msg);
|
|
95
|
+
break;
|
|
93
96
|
default:
|
|
94
97
|
console.log(`[relay-ws] Unknown message type: ${msg.type}`);
|
|
95
98
|
}
|
|
@@ -113,6 +116,27 @@ export function connectRelay(options) {
|
|
|
113
116
|
}
|
|
114
117
|
connect();
|
|
115
118
|
}
|
|
119
|
+
function handleControl(ws, msg) {
|
|
120
|
+
const action = msg.action || "";
|
|
121
|
+
console.log(`[control] Received: ${action}`);
|
|
122
|
+
switch (action) {
|
|
123
|
+
case "shutdown":
|
|
124
|
+
console.log("[control] Shutting down by remote command...");
|
|
125
|
+
ws.send(JSON.stringify({ type: "control_ack", action }));
|
|
126
|
+
setTimeout(() => process.exit(0), 500);
|
|
127
|
+
break;
|
|
128
|
+
case "set_public":
|
|
129
|
+
console.log("[control] Agent set to public by remote command");
|
|
130
|
+
ws.send(JSON.stringify({ type: "control_ack", action }));
|
|
131
|
+
break;
|
|
132
|
+
case "set_private":
|
|
133
|
+
console.log("[control] Agent set to private by remote command");
|
|
134
|
+
ws.send(JSON.stringify({ type: "control_ack", action }));
|
|
135
|
+
break;
|
|
136
|
+
default:
|
|
137
|
+
console.log(`[control] Unknown action: ${action}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
116
140
|
function handleMCPRequest(ws, msg, localPort) {
|
|
117
141
|
const requestId = msg.request_id;
|
|
118
142
|
console.log(`[relay-ws] → mcp_request ${requestId}`);
|