@chrysb/alphaclaw 0.8.7-beta.4 → 0.8.7-beta.5
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/lib/server/gateway.js +32 -14
- package/lib/server/openclaw-runtime.js +1 -70
- package/package.json +1 -1
package/lib/server/gateway.js
CHANGED
|
@@ -2,6 +2,7 @@ const path = require("path");
|
|
|
2
2
|
const { spawn, execSync } = require("child_process");
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const net = require("net");
|
|
5
|
+
const { getManagedOpenclawBinPath } = require("./openclaw-runtime");
|
|
5
6
|
const {
|
|
6
7
|
ALPHACLAW_DIR,
|
|
7
8
|
OPENCLAW_DIR,
|
|
@@ -48,6 +49,16 @@ const gatewayEnv = () => ({
|
|
|
48
49
|
XDG_CONFIG_HOME: OPENCLAW_DIR,
|
|
49
50
|
});
|
|
50
51
|
|
|
52
|
+
const shellQuote = (value) =>
|
|
53
|
+
`'${String(value || "").replace(/'/g, `'\"'\"'`)}'`;
|
|
54
|
+
|
|
55
|
+
const getOpenclawCommandPath = () => {
|
|
56
|
+
const managedBinPath = getManagedOpenclawBinPath();
|
|
57
|
+
return fs.existsSync(managedBinPath) ? managedBinPath : "openclaw";
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const getOpenclawCommandPrefix = () => shellQuote(getOpenclawCommandPath());
|
|
61
|
+
|
|
51
62
|
const writeOnboardingMarker = (reason) => {
|
|
52
63
|
fs.mkdirSync(ALPHACLAW_DIR, { recursive: true });
|
|
53
64
|
fs.writeFileSync(
|
|
@@ -119,9 +130,10 @@ const isGatewayRunning = () =>
|
|
|
119
130
|
});
|
|
120
131
|
|
|
121
132
|
const runGatewayCmd = (cmd) => {
|
|
122
|
-
|
|
133
|
+
const openclawCommandPrefix = getOpenclawCommandPrefix();
|
|
134
|
+
console.log(`[alphaclaw] Running: ${openclawCommandPrefix} gateway ${cmd}`);
|
|
123
135
|
try {
|
|
124
|
-
const out = execSync(
|
|
136
|
+
const out = execSync(`${openclawCommandPrefix} gateway ${cmd}`, {
|
|
125
137
|
env: gatewayEnv(),
|
|
126
138
|
timeout: 15000,
|
|
127
139
|
encoding: "utf8",
|
|
@@ -146,7 +158,7 @@ const launchGatewayProcess = () => {
|
|
|
146
158
|
return gatewayChild;
|
|
147
159
|
}
|
|
148
160
|
gatewayStderrTail = [];
|
|
149
|
-
const child = spawn(
|
|
161
|
+
const child = spawn(getOpenclawCommandPath(), ["gateway", "run"], {
|
|
150
162
|
env: gatewayEnv(),
|
|
151
163
|
stdio: ["pipe", "pipe", "pipe"],
|
|
152
164
|
});
|
|
@@ -306,7 +318,7 @@ const syncChannelConfig = (savedVars, mode = "all") => {
|
|
|
306
318
|
const appToken = savedMap[def.extraEnvKeys?.[0]];
|
|
307
319
|
if (!appToken) continue;
|
|
308
320
|
execSync(
|
|
309
|
-
|
|
321
|
+
`${getOpenclawCommandPrefix()} channels add --channel slack --bot-token "${token}" --app-token "${appToken}"`,
|
|
310
322
|
{ env, timeout: 15000, encoding: "utf8" },
|
|
311
323
|
);
|
|
312
324
|
let raw = fs.readFileSync(configPath, "utf8");
|
|
@@ -318,11 +330,14 @@ const syncChannelConfig = (savedVars, mode = "all") => {
|
|
|
318
330
|
}
|
|
319
331
|
fs.writeFileSync(configPath, raw);
|
|
320
332
|
} else {
|
|
321
|
-
execSync(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
333
|
+
execSync(
|
|
334
|
+
`${getOpenclawCommandPrefix()} channels add --channel ${ch} --token "${token}"`,
|
|
335
|
+
{
|
|
336
|
+
env,
|
|
337
|
+
timeout: 15000,
|
|
338
|
+
encoding: "utf8",
|
|
339
|
+
},
|
|
340
|
+
);
|
|
326
341
|
const raw = fs.readFileSync(configPath, "utf8");
|
|
327
342
|
if (raw.includes(token)) {
|
|
328
343
|
fs.writeFileSync(
|
|
@@ -344,11 +359,14 @@ const syncChannelConfig = (savedVars, mode = "all") => {
|
|
|
344
359
|
) {
|
|
345
360
|
console.log(`[alphaclaw] Removing channel: ${ch}`);
|
|
346
361
|
try {
|
|
347
|
-
execSync(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
362
|
+
execSync(
|
|
363
|
+
`${getOpenclawCommandPrefix()} channels remove --channel ${ch} --delete`,
|
|
364
|
+
{
|
|
365
|
+
env,
|
|
366
|
+
timeout: 15000,
|
|
367
|
+
encoding: "utf8",
|
|
368
|
+
},
|
|
369
|
+
);
|
|
352
370
|
console.log(`[alphaclaw] Channel ${ch} removed`);
|
|
353
371
|
} catch (e) {
|
|
354
372
|
console.error(
|
|
@@ -11,7 +11,6 @@ const {
|
|
|
11
11
|
isPackageRootSymlink,
|
|
12
12
|
packLocalPackageForInstall,
|
|
13
13
|
resolvePackageRootFromEntryPath,
|
|
14
|
-
seedRuntimeFromBundledInstall,
|
|
15
14
|
} = require("./package-fingerprint");
|
|
16
15
|
|
|
17
16
|
const getManagedOpenclawRuntimeDir = ({ rootDir = kRootDir } = {}) =>
|
|
@@ -216,48 +215,6 @@ const installManagedOpenclawRuntime = ({
|
|
|
216
215
|
};
|
|
217
216
|
};
|
|
218
217
|
|
|
219
|
-
const seedManagedOpenclawRuntimeFromBundledInstall = ({
|
|
220
|
-
execSyncImpl,
|
|
221
|
-
fsModule = fs,
|
|
222
|
-
logger = console,
|
|
223
|
-
runtimeDir,
|
|
224
|
-
bundledPackageRoot,
|
|
225
|
-
alphaclawRoot,
|
|
226
|
-
} = {}) => {
|
|
227
|
-
const seedResult = seedRuntimeFromBundledInstall({
|
|
228
|
-
fsModule,
|
|
229
|
-
packageRoot: bundledPackageRoot,
|
|
230
|
-
runtimeDir,
|
|
231
|
-
runtimePackageJson: {
|
|
232
|
-
name: "alphaclaw-openclaw-runtime",
|
|
233
|
-
private: true,
|
|
234
|
-
},
|
|
235
|
-
});
|
|
236
|
-
if (!seedResult.seeded) {
|
|
237
|
-
return {
|
|
238
|
-
seeded: false,
|
|
239
|
-
version: null,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
const installedVersion = readManagedOpenclawRuntimeVersion({
|
|
243
|
-
fsModule,
|
|
244
|
-
runtimeDir,
|
|
245
|
-
});
|
|
246
|
-
applyManagedOpenclawPatch({
|
|
247
|
-
execSyncImpl,
|
|
248
|
-
fsModule,
|
|
249
|
-
logger,
|
|
250
|
-
runtimeDir,
|
|
251
|
-
version: installedVersion,
|
|
252
|
-
alphaclawRoot,
|
|
253
|
-
});
|
|
254
|
-
logger.log("[alphaclaw] Seeded managed OpenClaw runtime from bundled node_modules");
|
|
255
|
-
return {
|
|
256
|
-
seeded: true,
|
|
257
|
-
version: installedVersion,
|
|
258
|
-
};
|
|
259
|
-
};
|
|
260
|
-
|
|
261
218
|
const syncManagedOpenclawRuntimeWithBundled = ({
|
|
262
219
|
execSyncImpl,
|
|
263
220
|
fsModule = fs,
|
|
@@ -323,35 +280,10 @@ const syncManagedOpenclawRuntimeWithBundled = ({
|
|
|
323
280
|
logger.log(
|
|
324
281
|
runtimeVersion
|
|
325
282
|
? `[alphaclaw] Managed OpenClaw runtime ${runtimeVersion} is older than bundled ${bundledVersion}; syncing runtime...`
|
|
326
|
-
: `[alphaclaw] Managed OpenClaw runtime missing;
|
|
283
|
+
: `[alphaclaw] Managed OpenClaw runtime missing; installing bundled OpenClaw ${bundledVersion}...`,
|
|
327
284
|
);
|
|
328
285
|
}
|
|
329
286
|
|
|
330
|
-
if (!runtimeVersion) {
|
|
331
|
-
try {
|
|
332
|
-
const seedResult = seedManagedOpenclawRuntimeFromBundledInstall({
|
|
333
|
-
execSyncImpl,
|
|
334
|
-
fsModule,
|
|
335
|
-
logger,
|
|
336
|
-
runtimeDir,
|
|
337
|
-
bundledPackageRoot,
|
|
338
|
-
alphaclawRoot,
|
|
339
|
-
});
|
|
340
|
-
if (seedResult.seeded) {
|
|
341
|
-
return {
|
|
342
|
-
checked: true,
|
|
343
|
-
synced: true,
|
|
344
|
-
bundledVersion,
|
|
345
|
-
runtimeVersion: seedResult.version || bundledVersion,
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
} catch (error) {
|
|
349
|
-
logger.log(
|
|
350
|
-
`[alphaclaw] Could not seed managed OpenClaw runtime from bundled node_modules: ${error.message}`,
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
287
|
const installResult = installManagedOpenclawRuntime({
|
|
356
288
|
execSyncImpl,
|
|
357
289
|
fsModule,
|
|
@@ -402,6 +334,5 @@ module.exports = {
|
|
|
402
334
|
prependManagedOpenclawBinToPath,
|
|
403
335
|
readBundledOpenclawVersion,
|
|
404
336
|
readManagedOpenclawRuntimeVersion,
|
|
405
|
-
seedManagedOpenclawRuntimeFromBundledInstall,
|
|
406
337
|
syncManagedOpenclawRuntimeWithBundled,
|
|
407
338
|
};
|