@iml1s/claw-link 0.1.1 → 0.3.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/relay-client.js +18 -6
- package/openclaw.plugin.json +1 -1
- package/package.json +4 -4
package/dist/relay-client.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.buildRegisterUrl = buildRegisterUrl;
|
|
|
8
8
|
exports.buildJoinUrlFromRegister = buildJoinUrlFromRegister;
|
|
9
9
|
exports.buildConnectionString = buildConnectionString;
|
|
10
10
|
const ws_1 = __importDefault(require("ws"));
|
|
11
|
-
const
|
|
11
|
+
const qrcode_1 = __importDefault(require("qrcode"));
|
|
12
12
|
const node_crypto_1 = require("node:crypto");
|
|
13
13
|
function buildRegisterUrl(relayUrl, sessionId) {
|
|
14
14
|
const registerUrl = new URL(relayUrl);
|
|
@@ -56,6 +56,15 @@ class RelayClient {
|
|
|
56
56
|
this.relayUrl = relayUrl;
|
|
57
57
|
this.gatewayToken = gatewayToken;
|
|
58
58
|
}
|
|
59
|
+
/** Returns current connection info for RPC callers / agent skills. */
|
|
60
|
+
getConnectionInfo() {
|
|
61
|
+
return {
|
|
62
|
+
connectionString: buildConnectionString(this.relayUrl, this.sessionId, this.gatewayToken),
|
|
63
|
+
sessionId: this.sessionId,
|
|
64
|
+
relayUrl: this.relayUrl,
|
|
65
|
+
relayConnected: this.relayWs?.readyState === ws_1.default.OPEN,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
59
68
|
connect() {
|
|
60
69
|
this.isDisconnecting = false;
|
|
61
70
|
console.log(`[RelayClient] Connecting to Relay Server at ${this.relayUrl}...`);
|
|
@@ -64,7 +73,7 @@ class RelayClient {
|
|
|
64
73
|
this.relayWs.on('open', () => {
|
|
65
74
|
console.log('[RelayClient] Connected to Relay Server.');
|
|
66
75
|
if (!this.hasPrintedQrCode) {
|
|
67
|
-
this.displayQrCode();
|
|
76
|
+
this.displayQrCode().catch(() => { });
|
|
68
77
|
this.hasPrintedQrCode = true;
|
|
69
78
|
}
|
|
70
79
|
this.ensureLocalGatewayConnected();
|
|
@@ -183,15 +192,18 @@ class RelayClient {
|
|
|
183
192
|
}
|
|
184
193
|
return Buffer.alloc(0);
|
|
185
194
|
}
|
|
186
|
-
displayQrCode() {
|
|
195
|
+
async displayQrCode() {
|
|
187
196
|
const connectionString = buildConnectionString(this.relayUrl, this.sessionId, this.gatewayToken);
|
|
188
197
|
console.log('\nScan this QR Code with your mobile app to connect:\n');
|
|
189
198
|
try {
|
|
190
|
-
|
|
191
|
-
|
|
199
|
+
const qrAscii = await qrcode_1.default.toString(connectionString, {
|
|
200
|
+
type: 'terminal',
|
|
201
|
+
small: true,
|
|
202
|
+
});
|
|
203
|
+
console.log('\n' + qrAscii);
|
|
192
204
|
}
|
|
193
205
|
catch (e) {
|
|
194
|
-
console.log('(
|
|
206
|
+
console.log('(Failed to render QR code)');
|
|
195
207
|
}
|
|
196
208
|
console.log(`\nConnection String: ${connectionString}\n`);
|
|
197
209
|
}
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iml1s/claw-link",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Cloud relay bridge plugin for OpenClaw — connects mobile devices to local gateways via a relay server.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test": "vitest run"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"qrcode
|
|
31
|
+
"qrcode": "^1.5.4",
|
|
32
32
|
"ws": "^8.16.0"
|
|
33
33
|
},
|
|
34
34
|
"openclaw": {
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^20.0.0",
|
|
41
|
-
"@types/qrcode
|
|
41
|
+
"@types/qrcode": "^1.5.6",
|
|
42
42
|
"@types/ws": "^8.5.10",
|
|
43
43
|
"typescript": "^5.0.0",
|
|
44
44
|
"vitest": "^2.1.8"
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
}
|