@clawchatsai/connector 0.0.9 → 0.0.10
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 +25 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -51,6 +51,28 @@ function loadConfig() {
|
|
|
51
51
|
// ---------------------------------------------------------------------------
|
|
52
52
|
// Service lifecycle
|
|
53
53
|
// ---------------------------------------------------------------------------
|
|
54
|
+
async function ensureNativeModules(ctx) {
|
|
55
|
+
// OpenClaw installs plugins with --ignore-scripts, which skips native module compilation.
|
|
56
|
+
// Check if better-sqlite3 is usable; if not, rebuild it automatically.
|
|
57
|
+
const pluginDir = path.resolve(__dirname, '..');
|
|
58
|
+
const bindingPath = path.join(pluginDir, 'node_modules', 'better-sqlite3', 'build', 'Release', 'better_sqlite3.node');
|
|
59
|
+
if (fs.existsSync(bindingPath))
|
|
60
|
+
return; // already built
|
|
61
|
+
ctx.logger.info('Building native modules (first run)...');
|
|
62
|
+
const { execFileSync } = await import('node:child_process');
|
|
63
|
+
try {
|
|
64
|
+
execFileSync('npm', ['rebuild', 'better-sqlite3'], {
|
|
65
|
+
cwd: pluginDir,
|
|
66
|
+
stdio: 'pipe',
|
|
67
|
+
timeout: 120_000,
|
|
68
|
+
});
|
|
69
|
+
ctx.logger.info('Native modules ready.');
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
ctx.logger.error(`Failed to build native modules: ${e.message}`);
|
|
73
|
+
ctx.logger.error('Try running manually: cd ~/.openclaw/extensions/connector && npm rebuild better-sqlite3');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
54
76
|
async function startShellChat(ctx, api) {
|
|
55
77
|
_stopRequested = false;
|
|
56
78
|
let config = loadConfig();
|
|
@@ -89,7 +111,9 @@ async function startShellChat(ctx, api) {
|
|
|
89
111
|
ctx.logger.error('No gateway token available. Re-run: openclaw shellchats setup <token>');
|
|
90
112
|
return;
|
|
91
113
|
}
|
|
92
|
-
// 3.
|
|
114
|
+
// 3. Ensure native modules are built (OpenClaw installs with --ignore-scripts)
|
|
115
|
+
await ensureNativeModules(ctx);
|
|
116
|
+
// 4. Import server.js and create app instance with plugin paths
|
|
93
117
|
const dataDir = path.join(ctx.stateDir, 'shellchats', 'data');
|
|
94
118
|
const uploadsDir = path.join(ctx.stateDir, 'shellchats', 'uploads');
|
|
95
119
|
// Dynamic import of server.js (plain JS, no type declarations)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clawchatsai/connector",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ShellChat OpenClaw plugin — P2P tunnel + local API bridge",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"prebuild": "cp ../server.js ./server.js",
|
|
21
21
|
"build": "tsc",
|
|
22
22
|
"dev": "tsc --watch",
|
|
23
|
-
"prepublishOnly": "npm run build"
|
|
23
|
+
"prepublishOnly": "npm run build",
|
|
24
|
+
"postinstall": "npm rebuild better-sqlite3 2>/dev/null || true"
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
26
27
|
"better-sqlite3": ">=9.0.0",
|