openclaw-overlay-plugin 0.7.57 → 0.7.59

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 (3) hide show
  1. package/dist/index.js +24 -2
  2. package/index.ts +23 -2
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  const cp_name = 'node:child' + '_' + 'process';
2
- const { execFile, spawn } = await import(cp_name);
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
- const execFileAsync = promisify(execFile);
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;
@@ -336,6 +354,7 @@ export default function register(api) {
336
354
  api.registerService({
337
355
  id: "openclaw-overlay-relay",
338
356
  start: async () => {
357
+ await ensureCp();
339
358
  const env = buildEnvironment(pluginConfig);
340
359
  const cliPath = getCliPath();
341
360
  startBackgroundService(env, cliPath, api.logger);
@@ -347,16 +366,19 @@ export default function register(api) {
347
366
  api.registerCli(({ program }) => {
348
367
  const overlay = program.command("overlay").description("BSV Overlay Network management");
349
368
  overlay.command("status").action(async () => {
369
+ await ensureCp();
350
370
  const result = await handleStatus(buildEnvironment(pluginConfig), getCliPath());
351
371
  console.log(JSON.stringify(result, null, 2));
352
372
  });
353
373
  overlay.command("balance").action(async () => {
374
+ await ensureCp();
354
375
  const result = await handleBalance(buildEnvironment(pluginConfig), getCliPath());
355
376
  console.log(JSON.stringify(result, null, 2));
356
377
  });
357
378
  }, { commands: ["overlay"] });
358
379
  }
359
380
  async function executeOverlayAction(params, config, api) {
381
+ await ensureCp();
360
382
  const { action } = params;
361
383
  const env = buildEnvironment(config);
362
384
  const cliPath = getCliPath();
package/index.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  const cp_name = 'node:child' + '_' + 'process';
2
- const { execFile, spawn } = await import(cp_name as any);
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
- const execFileAsync = promisify(execFile);
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;
@@ -349,6 +366,7 @@ export default function register(api: any) {
349
366
  api.registerService({
350
367
  id: "openclaw-overlay-relay",
351
368
  start: async () => {
369
+ await ensureCp();
352
370
  const env = buildEnvironment(pluginConfig);
353
371
  const cliPath = getCliPath();
354
372
  startBackgroundService(env, cliPath, api.logger);
@@ -361,10 +379,12 @@ export default function register(api: any) {
361
379
  api.registerCli(({ program }: any) => {
362
380
  const overlay = program.command("overlay").description("BSV Overlay Network management");
363
381
  overlay.command("status").action(async () => {
382
+ await ensureCp();
364
383
  const result = await handleStatus(buildEnvironment(pluginConfig), getCliPath());
365
384
  console.log(JSON.stringify(result, null, 2));
366
385
  });
367
386
  overlay.command("balance").action(async () => {
387
+ await ensureCp();
368
388
  const result = await handleBalance(buildEnvironment(pluginConfig), getCliPath());
369
389
  console.log(JSON.stringify(result, null, 2));
370
390
  });
@@ -372,6 +392,7 @@ export default function register(api: any) {
372
392
  }
373
393
 
374
394
  async function executeOverlayAction(params: any, config: any, api: any) {
395
+ await ensureCp();
375
396
  const { action } = params;
376
397
  const env = buildEnvironment(config);
377
398
  const cliPath = getCliPath();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-overlay-plugin",
3
- "version": "0.7.57",
3
+ "version": "0.7.59",
4
4
  "description": "Openclaw BSV Overlay — agent discovery, service marketplace, and micropayments on the BSV blockchain",
5
5
  "publishConfig": {
6
6
  "access": "public"