@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.
@@ -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 qrcode_terminal_1 = require("qrcode-terminal");
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
- // For very long URLs, qrcode-terminal can crash with { small: true }
191
- (0, qrcode_terminal_1.generate)(connectionString);
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('(Terminal too small or string too long to render QR code)');
206
+ console.log('(Failed to render QR code)');
195
207
  }
196
208
  console.log(`\nConnection String: ${connectionString}\n`);
197
209
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "claw-link",
3
3
  "name": "Claw Link",
4
- "version": "0.1.1",
4
+ "version": "0.2.0",
5
5
  "description": "Cloud relay bridge — connects mobile devices to the local gateway via a relay server.",
6
6
  "configSchema": {
7
7
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iml1s/claw-link",
3
- "version": "0.1.1",
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-terminal": "^0.12.0",
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-terminal": "^0.12.2",
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
+ }