@clawchatsai/connector 0.1.11 → 0.1.12

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.js CHANGED
@@ -13,6 +13,7 @@ import * as fs from 'node:fs';
13
13
  import * as http from 'node:http';
14
14
  import * as os from 'node:os';
15
15
  import * as path from 'node:path';
16
+ import { createRequire } from 'node:module';
16
17
  import { SignalingClient } from './signaling-client.js';
17
18
  import { dispatchRpc } from './shim.js';
18
19
  import { initAuth, handleAuthMessage, cleanupAuth } from './auth-handler.js';
@@ -103,7 +104,20 @@ function getPrebuildKey() {
103
104
  }
104
105
  async function ensureNativeModules(ctx) {
105
106
  const pluginDir = path.resolve(__dirname, '..');
106
- const targetPath = path.join(pluginDir, 'node_modules', 'node-datachannel', 'build', 'Release', 'node_datachannel.node');
107
+ // Resolve node-datachannel's actual install root (handles npm hoisting).
108
+ // Writing to <pluginDir>/node_modules/node-datachannel/ would create a
109
+ // package-shaped directory that lacks package.json + JS, shadowing the
110
+ // hoisted copy and breaking subpath imports like 'node-datachannel/polyfill'.
111
+ const require = createRequire(import.meta.url);
112
+ let ndcRoot;
113
+ try {
114
+ ndcRoot = path.dirname(require.resolve('node-datachannel/package.json'));
115
+ }
116
+ catch {
117
+ ctx.logger.error('[clawchats] node-datachannel package not resolvable; WebRTC unavailable.');
118
+ return;
119
+ }
120
+ const targetPath = path.join(ndcRoot, 'build', 'Release', 'node_datachannel.node');
107
121
  // Already built — nothing to do.
108
122
  if (fs.existsSync(targetPath))
109
123
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawchatsai/connector",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "description": "ClawChats OpenClaw plugin — P2P tunnel + local API bridge",
6
6
  "main": "dist/index.js",
package/server/gateway.js CHANGED
@@ -77,7 +77,7 @@ export class GatewayClient {
77
77
  if (msg.type === 'event' && msg.event === 'connect.challenge') {
78
78
  const identity = loadOrCreateDeviceIdentity(path.join(this.dataDir, 'device-identity.json'));
79
79
  const device = buildDeviceAuth(identity, { clientId: 'gateway-client', clientMode: 'backend', role: 'operator', scopes: ['operator.read', 'operator.write', 'operator.admin'], token: this.authToken, nonce: msg.payload?.nonce || '' });
80
- this.ws.send(JSON.stringify({ type: 'req', id: 'gw-connect-1', method: 'connect', params: { minProtocol: 3, maxProtocol: 3, client: { id: 'gateway-client', version: '0.1.0', platform: 'node', mode: 'backend' }, role: 'operator', scopes: ['operator.read', 'operator.write', 'operator.admin'], device, auth: { token: this.authToken }, caps: ['tool-events'] } }));
80
+ this.ws.send(JSON.stringify({ type: 'req', id: 'gw-connect-1', method: 'connect', params: { minProtocol: 3, maxProtocol: 4, client: { id: 'gateway-client', version: '0.1.0', platform: 'node', mode: 'backend' }, role: 'operator', scopes: ['operator.read', 'operator.write', 'operator.admin'], device, auth: { token: this.authToken }, caps: ['tool-events'] } }));
81
81
  return;
82
82
  }
83
83
  if (msg.type === 'res' && msg.payload?.type === 'hello-ok') { console.log('Gateway handshake complete'); this.connected = true; this.broadcastGatewayStatus(true); }