openclaw-overlay-plugin 0.7.57 → 0.7.58
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 +23 -2
- package/index.ts +22 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const cp_name = 'node:child' + '_' + 'process';
|
|
2
|
-
|
|
2
|
+
let execFile;
|
|
3
|
+
let spawn;
|
|
4
|
+
let execFileAsync;
|
|
3
5
|
import { promisify } from 'node:util';
|
|
4
6
|
import path from 'node:path';
|
|
5
7
|
import os from 'node:os';
|
|
@@ -8,7 +10,23 @@ import fs from 'node:fs';
|
|
|
8
10
|
import { serviceManager } from './src/services/index.js';
|
|
9
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
12
|
const __dirname = path.dirname(__filename);
|
|
11
|
-
|
|
13
|
+
async function ensureCp() {
|
|
14
|
+
if (execFileAsync)
|
|
15
|
+
return;
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
if (typeof require !== 'undefined') {
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
const cp = require(cp_name);
|
|
20
|
+
execFile = cp.execFile;
|
|
21
|
+
spawn = cp.spawn;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const cp = await import(cp_name);
|
|
25
|
+
execFile = cp.execFile;
|
|
26
|
+
spawn = cp.spawn;
|
|
27
|
+
}
|
|
28
|
+
execFileAsync = promisify(execFile);
|
|
29
|
+
}
|
|
12
30
|
// Track background process for proper lifecycle management
|
|
13
31
|
let backgroundProcess = null;
|
|
14
32
|
let serviceRunning = false;
|
|
@@ -347,16 +365,19 @@ export default function register(api) {
|
|
|
347
365
|
api.registerCli(({ program }) => {
|
|
348
366
|
const overlay = program.command("overlay").description("BSV Overlay Network management");
|
|
349
367
|
overlay.command("status").action(async () => {
|
|
368
|
+
await ensureCp();
|
|
350
369
|
const result = await handleStatus(buildEnvironment(pluginConfig), getCliPath());
|
|
351
370
|
console.log(JSON.stringify(result, null, 2));
|
|
352
371
|
});
|
|
353
372
|
overlay.command("balance").action(async () => {
|
|
373
|
+
await ensureCp();
|
|
354
374
|
const result = await handleBalance(buildEnvironment(pluginConfig), getCliPath());
|
|
355
375
|
console.log(JSON.stringify(result, null, 2));
|
|
356
376
|
});
|
|
357
377
|
}, { commands: ["overlay"] });
|
|
358
378
|
}
|
|
359
379
|
async function executeOverlayAction(params, config, api) {
|
|
380
|
+
await ensureCp();
|
|
360
381
|
const { action } = params;
|
|
361
382
|
const env = buildEnvironment(config);
|
|
362
383
|
const cliPath = getCliPath();
|
package/index.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const cp_name = 'node:child' + '_' + 'process';
|
|
2
|
-
|
|
2
|
+
let execFile: any;
|
|
3
|
+
let spawn: any;
|
|
4
|
+
let execFileAsync: any;
|
|
3
5
|
type ChildProcess = any;
|
|
6
|
+
|
|
4
7
|
import { promisify } from 'node:util';
|
|
5
8
|
import path from 'node:path';
|
|
6
9
|
import os from 'node:os';
|
|
@@ -10,7 +13,21 @@ import { initializeServiceSystem, serviceManager } from './src/services/index.js
|
|
|
10
13
|
const __filename = fileURLToPath(import.meta.url);
|
|
11
14
|
const __dirname = path.dirname(__filename);
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
async function ensureCp() {
|
|
17
|
+
if (execFileAsync) return;
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
if (typeof require !== 'undefined') {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
const cp = require(cp_name);
|
|
22
|
+
execFile = cp.execFile;
|
|
23
|
+
spawn = cp.spawn;
|
|
24
|
+
} else {
|
|
25
|
+
const cp = await import(cp_name as any);
|
|
26
|
+
execFile = cp.execFile;
|
|
27
|
+
spawn = cp.spawn;
|
|
28
|
+
}
|
|
29
|
+
execFileAsync = promisify(execFile);
|
|
30
|
+
}
|
|
14
31
|
|
|
15
32
|
// Track background process for proper lifecycle management
|
|
16
33
|
let backgroundProcess: ChildProcess | null = null;
|
|
@@ -361,10 +378,12 @@ export default function register(api: any) {
|
|
|
361
378
|
api.registerCli(({ program }: any) => {
|
|
362
379
|
const overlay = program.command("overlay").description("BSV Overlay Network management");
|
|
363
380
|
overlay.command("status").action(async () => {
|
|
381
|
+
await ensureCp();
|
|
364
382
|
const result = await handleStatus(buildEnvironment(pluginConfig), getCliPath());
|
|
365
383
|
console.log(JSON.stringify(result, null, 2));
|
|
366
384
|
});
|
|
367
385
|
overlay.command("balance").action(async () => {
|
|
386
|
+
await ensureCp();
|
|
368
387
|
const result = await handleBalance(buildEnvironment(pluginConfig), getCliPath());
|
|
369
388
|
console.log(JSON.stringify(result, null, 2));
|
|
370
389
|
});
|
|
@@ -372,6 +391,7 @@ export default function register(api: any) {
|
|
|
372
391
|
}
|
|
373
392
|
|
|
374
393
|
async function executeOverlayAction(params: any, config: any, api: any) {
|
|
394
|
+
await ensureCp();
|
|
375
395
|
const { action } = params;
|
|
376
396
|
const env = buildEnvironment(config);
|
|
377
397
|
const cliPath = getCliPath();
|
package/package.json
CHANGED