@clawchatsai/connector 0.0.25 → 0.0.26

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.
Files changed (2) hide show
  1. package/dist/index.js +33 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -65,8 +65,8 @@ async function ensureNativeModules(ctx) {
65
65
  // Check if native modules are usable; if not, rebuild them automatically.
66
66
  const pluginDir = path.resolve(__dirname, '..');
67
67
  const modules = [
68
- { name: 'better-sqlite3', binding: 'build/Release/better_sqlite3.node' },
69
- { name: 'node-datachannel', binding: 'build/Release/node_datachannel.node' },
68
+ { name: 'better-sqlite3', binding: 'build/Release/better_sqlite3.node', strategy: 'rebuild' },
69
+ { name: 'node-datachannel', binding: 'build/Release/node_datachannel.node', strategy: 'install-script' },
70
70
  ];
71
71
  const missing = modules.filter(m => !fs.existsSync(path.join(pluginDir, 'node_modules', m.name, m.binding)));
72
72
  if (missing.length === 0)
@@ -75,11 +75,37 @@ async function ensureNativeModules(ctx) {
75
75
  const { execFileSync } = await import('node:child_process');
76
76
  for (const mod of missing) {
77
77
  try {
78
- execFileSync('npm', ['rebuild', mod.name], {
79
- cwd: pluginDir,
80
- stdio: 'pipe',
81
- timeout: 120_000,
82
- });
78
+ if (mod.strategy === 'install-script') {
79
+ // Packages using prebuild-install need their install script re-run (npm rebuild
80
+ // only triggers node-gyp, not prebuild-install). Run the install script directly
81
+ // from the package's directory.
82
+ const modDir = path.join(pluginDir, 'node_modules', mod.name);
83
+ const modPkg = JSON.parse(fs.readFileSync(path.join(modDir, 'package.json'), 'utf-8'));
84
+ const installCmd = modPkg.scripts?.install;
85
+ if (installCmd) {
86
+ execFileSync('sh', ['-c', installCmd], {
87
+ cwd: modDir,
88
+ stdio: 'pipe',
89
+ timeout: 120_000,
90
+ env: { ...process.env, npm_config_node_gyp: '' },
91
+ });
92
+ }
93
+ else {
94
+ // Fallback to rebuild if no install script found
95
+ execFileSync('npm', ['rebuild', mod.name], {
96
+ cwd: pluginDir,
97
+ stdio: 'pipe',
98
+ timeout: 120_000,
99
+ });
100
+ }
101
+ }
102
+ else {
103
+ execFileSync('npm', ['rebuild', mod.name], {
104
+ cwd: pluginDir,
105
+ stdio: 'pipe',
106
+ timeout: 120_000,
107
+ });
108
+ }
83
109
  ctx.logger.info(`${mod.name} ready.`);
84
110
  }
85
111
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawchatsai/connector",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "description": "ClawChats OpenClaw plugin — P2P tunnel + local API bridge",
6
6
  "main": "dist/index.js",