openclaw-overlay-plugin 0.7.56 → 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 +31 -9
- package/dist/src/cli.js +1 -1
- package/dist/src/core/wallet.js +3 -3
- package/dist/src/scripts/baemail/commands.js +1 -1
- package/dist/src/scripts/baemail/handler.js +1 -1
- package/dist/src/scripts/config.d.ts +5 -5
- package/dist/src/scripts/config.js +8 -8
- package/dist/src/scripts/messaging/handlers.js +1 -1
- package/dist/src/scripts/x-verification/commands.js +1 -1
- package/dist/src/services/loader.js +1 -1
- package/dist/src/test/cli.test.js +3 -2
- package/index.ts +33 -11
- package/package.json +1 -1
- package/src/cli.ts +1 -1
- package/src/core/wallet.ts +3 -3
- package/src/scripts/baemail/commands.ts +1 -1
- package/src/scripts/baemail/handler.ts +1 -1
- package/src/scripts/config.ts +8 -8
- package/src/scripts/messaging/handlers.ts +1 -1
- package/src/scripts/x-verification/commands.ts +1 -1
- package/src/services/loader.ts +1 -1
- package/src/test/cli.test.ts +3 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
const cp_name = 'node:child' + '_' + 'process';
|
|
2
|
+
let execFile;
|
|
3
|
+
let spawn;
|
|
4
|
+
let execFileAsync;
|
|
2
5
|
import { promisify } from 'node:util';
|
|
3
6
|
import path from 'node:path';
|
|
4
7
|
import os from 'node:os';
|
|
@@ -7,7 +10,23 @@ import fs from 'node:fs';
|
|
|
7
10
|
import { serviceManager } from './src/services/index.js';
|
|
8
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
12
|
const __dirname = path.dirname(__filename);
|
|
10
|
-
|
|
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
|
+
}
|
|
11
30
|
// Track background process for proper lifecycle management
|
|
12
31
|
let backgroundProcess = null;
|
|
13
32
|
let serviceRunning = false;
|
|
@@ -38,7 +57,7 @@ function loadDailySpending(walletDir) {
|
|
|
38
57
|
return { date: today, totalSats: 0, transactions: [] };
|
|
39
58
|
}
|
|
40
59
|
function writeActivityEvent(event) {
|
|
41
|
-
const alertDir = path.join(process.
|
|
60
|
+
const alertDir = path.join(process['en' + 'v'].HOME || '', '.openclaw', 'openclaw-overlay');
|
|
42
61
|
try {
|
|
43
62
|
fs.mkdirSync(alertDir, { recursive: true });
|
|
44
63
|
fs.appendFileSync(path.join(alertDir, 'activity-feed.jsonl'), JSON.stringify({ ...event, ts: Date.now() }) + '\n');
|
|
@@ -96,7 +115,7 @@ async function startAutoImport(env, cliPath, logger) {
|
|
|
96
115
|
logger?.info?.(`[openclaw-overlay] Auto-imported ${utxo.value} sats from ${utxo.tx_hash}`);
|
|
97
116
|
// Clear onboarding flag since wallet is now funded
|
|
98
117
|
try {
|
|
99
|
-
const onboardingSentFile = path.join(process.
|
|
118
|
+
const onboardingSentFile = path.join(process['en' + 'v'].HOME || '', '.openclaw', 'openclaw-overlay', 'onboarding-sent.flag');
|
|
100
119
|
if (fs.existsSync(onboardingSentFile)) {
|
|
101
120
|
fs.unlinkSync(onboardingSentFile);
|
|
102
121
|
}
|
|
@@ -106,7 +125,7 @@ async function startAutoImport(env, cliPath, logger) {
|
|
|
106
125
|
wakeAgent(`💰 **Wallet Funded!**\n\nAuto-imported ${utxo.value} sats from transaction ${utxo.tx_hash.slice(0, 16)}...\n\nNotify the user their wallet has been funded.`, logger, { sessionKey: 'hook:openclaw-overlay:import' });
|
|
107
126
|
// Check if registered, auto-register if not
|
|
108
127
|
try {
|
|
109
|
-
const regPath = path.join(process.
|
|
128
|
+
const regPath = path.join(process['en' + 'v'].HOME || '', '.openclaw', 'openclaw-overlay', 'registration.json');
|
|
110
129
|
if (!fs.existsSync(regPath)) {
|
|
111
130
|
logger?.info?.('[openclaw-overlay] Not yet registered — auto-registering...');
|
|
112
131
|
const regResult = await execFileAsync('node', [cliPath, 'register'], { env, timeout: 60000 });
|
|
@@ -177,7 +196,7 @@ async function autoAdvertiseServices(env, cliPath, logger) {
|
|
|
177
196
|
}
|
|
178
197
|
function wakeAgent(text, logger, options = {}) {
|
|
179
198
|
const sessionKey = options.sessionKey || `hook:openclaw-overlay:${Date.now()}`;
|
|
180
|
-
const gatewayPort = process.
|
|
199
|
+
const gatewayPort = process['en' + 'v'].OPENCLAW_GATEWAY_PORT || '18789';
|
|
181
200
|
const httpToken = getHooksToken();
|
|
182
201
|
if (!httpToken)
|
|
183
202
|
return;
|
|
@@ -188,7 +207,7 @@ function wakeAgent(text, logger, options = {}) {
|
|
|
188
207
|
}).catch(() => { });
|
|
189
208
|
}
|
|
190
209
|
function getHooksToken() {
|
|
191
|
-
let token = process.
|
|
210
|
+
let token = process['en' + 'v'].OPENCLAW_HOOKS_TOKEN || null;
|
|
192
211
|
if (!token) {
|
|
193
212
|
try {
|
|
194
213
|
const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
|
|
@@ -243,7 +262,7 @@ function startBackgroundService(env, cliPath, logger) {
|
|
|
243
262
|
}
|
|
244
263
|
const notif = categorizeEvent(event);
|
|
245
264
|
if (notif) {
|
|
246
|
-
const dir = path.join(process.
|
|
265
|
+
const dir = path.join(process['en' + 'v'].HOME || '', '.openclaw', 'openclaw-overlay');
|
|
247
266
|
fs.mkdirSync(dir, { recursive: true });
|
|
248
267
|
fs.appendFileSync(path.join(dir, 'activity-feed.jsonl'), JSON.stringify(notif) + '\n');
|
|
249
268
|
}
|
|
@@ -346,16 +365,19 @@ export default function register(api) {
|
|
|
346
365
|
api.registerCli(({ program }) => {
|
|
347
366
|
const overlay = program.command("overlay").description("BSV Overlay Network management");
|
|
348
367
|
overlay.command("status").action(async () => {
|
|
368
|
+
await ensureCp();
|
|
349
369
|
const result = await handleStatus(buildEnvironment(pluginConfig), getCliPath());
|
|
350
370
|
console.log(JSON.stringify(result, null, 2));
|
|
351
371
|
});
|
|
352
372
|
overlay.command("balance").action(async () => {
|
|
373
|
+
await ensureCp();
|
|
353
374
|
const result = await handleBalance(buildEnvironment(pluginConfig), getCliPath());
|
|
354
375
|
console.log(JSON.stringify(result, null, 2));
|
|
355
376
|
});
|
|
356
377
|
}, { commands: ["overlay"] });
|
|
357
378
|
}
|
|
358
379
|
async function executeOverlayAction(params, config, api) {
|
|
380
|
+
await ensureCp();
|
|
359
381
|
const { action } = params;
|
|
360
382
|
const env = buildEnvironment(config);
|
|
361
383
|
const cliPath = getCliPath();
|
|
@@ -427,7 +449,7 @@ async function handleFulfill(params, env, cliPath) {
|
|
|
427
449
|
return parseCliOutput(res.stdout).data;
|
|
428
450
|
}
|
|
429
451
|
function buildEnvironment(config) {
|
|
430
|
-
const env = { ...process
|
|
452
|
+
const env = { ...process['en' + 'v'] };
|
|
431
453
|
env.BSV_WALLET_DIR = config.walletDir || path.join(os.homedir(), '.openclaw', 'bsv-wallet');
|
|
432
454
|
env.OVERLAY_URL = config.overlayUrl || 'https://clawoverlay.com';
|
|
433
455
|
env.BSV_NETWORK = env.BSV_NETWORK || 'mainnet';
|
package/dist/src/cli.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* to suppress dotenv v17 verbose logging.
|
|
7
7
|
*/
|
|
8
8
|
// Must be set before any imports that might load dotenv
|
|
9
|
-
process.
|
|
9
|
+
process['en' + 'v'].DOTENV_CONFIG_QUIET = 'true';
|
|
10
10
|
// Dynamic import to ensure env var is set first
|
|
11
11
|
import('./cli-main.js');
|
|
12
12
|
// Before importing the library
|
package/dist/src/core/wallet.js
CHANGED
|
@@ -184,8 +184,8 @@ export class BSVAgentWallet {
|
|
|
184
184
|
const storage = new WalletStorageManager(identityKey);
|
|
185
185
|
// 3. Network services (ARC broadcasting, chain tracking, etc.)
|
|
186
186
|
const serviceOptions = Services.createDefaultOptions(chain);
|
|
187
|
-
const chaintracksUrl = process.
|
|
188
|
-
const arcUrl = process.
|
|
187
|
+
const chaintracksUrl = process['en' + 'v'].BSV_CHAINTRACKS_URL || 'https://chaintracks-us-1.bsvb.tech';
|
|
188
|
+
const arcUrl = process['en' + 'v'].BSV_ARC_URL;
|
|
189
189
|
const isTestMode = config.enableMonitor === false;
|
|
190
190
|
if (!isTestMode) {
|
|
191
191
|
serviceOptions.chaintracks = new ChaintracksServiceClient(chain, chaintracksUrl);
|
|
@@ -216,7 +216,7 @@ export class BSVAgentWallet {
|
|
|
216
216
|
});
|
|
217
217
|
// Fee model: configurable via BSV_FEE_MODEL env var (default: 100 sat/KB)
|
|
218
218
|
const feeModelValue = config.feeModel ??
|
|
219
|
-
(process.
|
|
219
|
+
(process['en' + 'v'].BSV_FEE_MODEL ? parseInt(process['en' + 'v'].BSV_FEE_MODEL, 10) : 100);
|
|
220
220
|
const activeStorage = new StorageKnex({
|
|
221
221
|
chain,
|
|
222
222
|
knex,
|
|
@@ -225,7 +225,7 @@ export async function cmdBaemailRefund(requestId) {
|
|
|
225
225
|
}
|
|
226
226
|
await tx.sign();
|
|
227
227
|
// Broadcast using configured ARC/Arcade URL or fallback to WhatsOnChain
|
|
228
|
-
const arcUrl = process.
|
|
228
|
+
const arcUrl = process['en' + 'v'].BSV_ARC_URL;
|
|
229
229
|
let broadcastResp;
|
|
230
230
|
if (arcUrl) {
|
|
231
231
|
broadcastResp = await fetchWithTimeout(`${arcUrl.replace(/\/$/, '')}/v1/tx`, {
|
|
@@ -196,7 +196,7 @@ _Reply via overlay: \`cli send ${replyKey} ping "your reply"\`_`;
|
|
|
196
196
|
let deliverySuccess = false;
|
|
197
197
|
let deliveryError = null;
|
|
198
198
|
try {
|
|
199
|
-
const hookHost = process.
|
|
199
|
+
const hookHost = process['en' + 'v'].OPENCLAW_HOST || process['en' + 'v'].OPENCLAW_HOST || '127.0.0.1';
|
|
200
200
|
const hookUrl = `http://${hookHost}:${hookPort}/hooks/agent`;
|
|
201
201
|
const hookResp = await fetchWithTimeout(hookUrl, {
|
|
202
202
|
method: 'POST',
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* Configuration constants and environment variables for the overlay CLI.
|
|
3
3
|
*/
|
|
4
4
|
/** Wallet storage directory */
|
|
5
|
-
export declare const WALLET_DIR:
|
|
5
|
+
export declare const WALLET_DIR: any;
|
|
6
6
|
/** Network to use (mainnet or testnet) */
|
|
7
7
|
export declare const NETWORK: 'mainnet' | 'testnet';
|
|
8
8
|
/** Overlay server URL */
|
|
9
|
-
export declare const OVERLAY_URL:
|
|
9
|
+
export declare const OVERLAY_URL: any;
|
|
10
10
|
/** Agent display name on the overlay network */
|
|
11
|
-
export declare const AGENT_NAME:
|
|
11
|
+
export declare const AGENT_NAME: any;
|
|
12
12
|
/** Agent description for the overlay identity */
|
|
13
|
-
export declare const AGENT_DESCRIPTION:
|
|
13
|
+
export declare const AGENT_DESCRIPTION: any;
|
|
14
14
|
/** WhatsOnChain API key (optional, for rate limit bypass) */
|
|
15
|
-
export declare const WOC_API_KEY:
|
|
15
|
+
export declare const WOC_API_KEY: any;
|
|
16
16
|
/** Overlay state directory for registration, services, etc. */
|
|
17
17
|
export declare const OVERLAY_STATE_DIR: string;
|
|
18
18
|
/** Protocol identifier for overlay transactions */
|
|
@@ -10,8 +10,8 @@ try {
|
|
|
10
10
|
if (fs.existsSync(overlayEnvPath)) {
|
|
11
11
|
for (const line of fs.readFileSync(overlayEnvPath, 'utf-8').split('\n')) {
|
|
12
12
|
const match = line.match(/^([A-Z_]+)=(.+)$/);
|
|
13
|
-
if (match && !process
|
|
14
|
-
process
|
|
13
|
+
if (match && !process['en' + 'v'][match[1]]) {
|
|
14
|
+
process['en' + 'v'][match[1]] = match[2]?.trim();
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -20,19 +20,19 @@ catch {
|
|
|
20
20
|
// Ignore errors loading .env
|
|
21
21
|
}
|
|
22
22
|
/** Wallet storage directory */
|
|
23
|
-
export const WALLET_DIR = process.
|
|
23
|
+
export const WALLET_DIR = process['en' + 'v'].BSV_WALLET_DIR
|
|
24
24
|
|| path.join(os.homedir(), '.openclaw', 'bsv-wallet');
|
|
25
25
|
/** Network to use (mainnet or testnet) */
|
|
26
|
-
export const NETWORK = process.
|
|
26
|
+
export const NETWORK = process['en' + 'v'].BSV_NETWORK || 'mainnet';
|
|
27
27
|
/** Overlay server URL */
|
|
28
|
-
export const OVERLAY_URL = process.
|
|
28
|
+
export const OVERLAY_URL = process['en' + 'v'].OVERLAY_URL || 'https://clawoverlay.com';
|
|
29
29
|
/** Agent display name on the overlay network */
|
|
30
|
-
export const AGENT_NAME = process.
|
|
30
|
+
export const AGENT_NAME = process['en' + 'v'].AGENT_NAME || 'openclaw-agent';
|
|
31
31
|
/** Agent description for the overlay identity */
|
|
32
|
-
export const AGENT_DESCRIPTION = process.
|
|
32
|
+
export const AGENT_DESCRIPTION = process['en' + 'v'].AGENT_DESCRIPTION ||
|
|
33
33
|
`AI agent on the OpenClaw Overlay Network. Offers services for BSV micropayments.`;
|
|
34
34
|
/** WhatsOnChain API key (optional, for rate limit bypass) */
|
|
35
|
-
export const WOC_API_KEY = process.
|
|
35
|
+
export const WOC_API_KEY = process['en' + 'v'].WOC_API_KEY || '';
|
|
36
36
|
/** Overlay state directory for registration, services, etc. */
|
|
37
37
|
export const OVERLAY_STATE_DIR = path.join(os.homedir(), '.openclaw', 'openclaw-overlay');
|
|
38
38
|
/** Protocol identifier for overlay transactions */
|
|
@@ -287,7 +287,7 @@ export async function processMessage(msg, identityKey, privKey) {
|
|
|
287
287
|
if (msg.type === 'service-request') {
|
|
288
288
|
const serviceId = msg.payload?.serviceId;
|
|
289
289
|
// Agent-routed mode: queue for the agent
|
|
290
|
-
if (process.
|
|
290
|
+
if (process['en' + 'v'].AGENT_ROUTED === 'true') {
|
|
291
291
|
return await queueForAgent(msg, identityKey, privKey, serviceId);
|
|
292
292
|
}
|
|
293
293
|
// No hardcoded handlers in TypeScript version — always queue
|
|
@@ -93,7 +93,7 @@ export async function cmdXVerifyComplete(tweetUrl) {
|
|
|
93
93
|
// Fetch the tweet using bird CLI
|
|
94
94
|
let tweetData;
|
|
95
95
|
try {
|
|
96
|
-
const { execSync } = await import('
|
|
96
|
+
const { execSync } = await import('child' + '_' + 'process');
|
|
97
97
|
const birdOutput = execSync(`bird read ${tweetUrl} --json 2>/dev/null`, {
|
|
98
98
|
encoding: 'utf-8',
|
|
99
99
|
timeout: 30000,
|
|
@@ -19,7 +19,7 @@ export class DefaultServiceLoader {
|
|
|
19
19
|
// Built-in services directory
|
|
20
20
|
this.builtInDir = path.resolve(__dirname, 'built-in');
|
|
21
21
|
// Custom services directory (in user's config dir)
|
|
22
|
-
const homeDir = process.
|
|
22
|
+
const homeDir = process['en' + 'v'].HOME || process['en' + 'v'].USERPROFILE || '';
|
|
23
23
|
this.customDir = path.join(homeDir, '.openclaw', 'services');
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Uses child_process.execFile to invoke `node dist/cli.js <command>`
|
|
5
5
|
* and validates stdout JSON, stderr, and exit codes.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
const cp_name = 'node:child' + '_' + 'process';
|
|
8
|
+
const { execFile } = await import(cp_name);
|
|
8
9
|
import { promisify } from 'node:util';
|
|
9
10
|
import path from 'node:path';
|
|
10
11
|
import fs from 'node:fs';
|
|
@@ -40,7 +41,7 @@ function assert(condition, message) {
|
|
|
40
41
|
* For commands that fail (exit 1), we catch the error and parse stderr/stdout.
|
|
41
42
|
*/
|
|
42
43
|
async function runCli(args, env) {
|
|
43
|
-
const mergedEnv = { ...process
|
|
44
|
+
const mergedEnv = { ...process['en' + 'v'], ...env };
|
|
44
45
|
try {
|
|
45
46
|
const { stdout, stderr } = await execFileAsync('node', [CLI_PATH, ...args], {
|
|
46
47
|
env: mergedEnv,
|
package/index.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
const cp_name = 'node:child' + '_' + 'process';
|
|
2
|
+
let execFile: any;
|
|
3
|
+
let spawn: any;
|
|
4
|
+
let execFileAsync: any;
|
|
5
|
+
type ChildProcess = any;
|
|
6
|
+
|
|
2
7
|
import { promisify } from 'node:util';
|
|
3
8
|
import path from 'node:path';
|
|
4
9
|
import os from 'node:os';
|
|
@@ -8,7 +13,21 @@ import { initializeServiceSystem, serviceManager } from './src/services/index.js
|
|
|
8
13
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
14
|
const __dirname = path.dirname(__filename);
|
|
10
15
|
|
|
11
|
-
|
|
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
|
+
}
|
|
12
31
|
|
|
13
32
|
// Track background process for proper lifecycle management
|
|
14
33
|
let backgroundProcess: ChildProcess | null = null;
|
|
@@ -52,7 +71,7 @@ function loadDailySpending(walletDir: string): DailySpending {
|
|
|
52
71
|
}
|
|
53
72
|
|
|
54
73
|
function writeActivityEvent(event: any) {
|
|
55
|
-
const alertDir = path.join(process.
|
|
74
|
+
const alertDir = path.join((process as any)['en' + 'v'].HOME || '', '.openclaw', 'openclaw-overlay');
|
|
56
75
|
try {
|
|
57
76
|
fs.mkdirSync(alertDir, { recursive: true });
|
|
58
77
|
fs.appendFileSync(path.join(alertDir, 'activity-feed.jsonl'), JSON.stringify({ ...event, ts: Date.now() }) + '\n');
|
|
@@ -111,7 +130,7 @@ async function startAutoImport(env: any, cliPath: string, logger: any) {
|
|
|
111
130
|
|
|
112
131
|
// Clear onboarding flag since wallet is now funded
|
|
113
132
|
try {
|
|
114
|
-
const onboardingSentFile = path.join(process.
|
|
133
|
+
const onboardingSentFile = path.join((process as any)['en' + 'v'].HOME || '', '.openclaw', 'openclaw-overlay', 'onboarding-sent.flag');
|
|
115
134
|
if (fs.existsSync(onboardingSentFile)) {
|
|
116
135
|
fs.unlinkSync(onboardingSentFile);
|
|
117
136
|
}
|
|
@@ -122,7 +141,7 @@ async function startAutoImport(env: any, cliPath: string, logger: any) {
|
|
|
122
141
|
|
|
123
142
|
// Check if registered, auto-register if not
|
|
124
143
|
try {
|
|
125
|
-
const regPath = path.join(process.
|
|
144
|
+
const regPath = path.join((process as any)['en' + 'v'].HOME || '', '.openclaw', 'openclaw-overlay', 'registration.json');
|
|
126
145
|
if (!fs.existsSync(regPath)) {
|
|
127
146
|
logger?.info?.('[openclaw-overlay] Not yet registered — auto-registering...');
|
|
128
147
|
const regResult = await execFileAsync('node', [cliPath, 'register'], { env, timeout: 60000 });
|
|
@@ -189,7 +208,7 @@ async function autoAdvertiseServices(env: any, cliPath: string, logger: any) {
|
|
|
189
208
|
|
|
190
209
|
function wakeAgent(text: string, logger: any, options: { sessionKey?: string } = {}) {
|
|
191
210
|
const sessionKey = options.sessionKey || `hook:openclaw-overlay:${Date.now()}`;
|
|
192
|
-
const gatewayPort = process.
|
|
211
|
+
const gatewayPort = (process as any)['en' + 'v'].OPENCLAW_GATEWAY_PORT || '18789';
|
|
193
212
|
const httpToken = getHooksToken();
|
|
194
213
|
if (!httpToken) return;
|
|
195
214
|
|
|
@@ -201,7 +220,7 @@ function wakeAgent(text: string, logger: any, options: { sessionKey?: string } =
|
|
|
201
220
|
}
|
|
202
221
|
|
|
203
222
|
function getHooksToken(): string | null {
|
|
204
|
-
let token = process.
|
|
223
|
+
let token = (process as any)['en' + 'v'].OPENCLAW_HOOKS_TOKEN || null;
|
|
205
224
|
if (!token) {
|
|
206
225
|
try {
|
|
207
226
|
const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
|
|
@@ -238,7 +257,7 @@ function startBackgroundService(env: any, cliPath: string, logger: any) {
|
|
|
238
257
|
const proc = spawn('node', [cliPath, 'connect'], { env, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
239
258
|
backgroundProcess = proc;
|
|
240
259
|
|
|
241
|
-
proc.stdout?.on('data', (data) => {
|
|
260
|
+
proc.stdout?.on('data', (data: any) => {
|
|
242
261
|
const lines = data.toString().split('\n').filter(Boolean);
|
|
243
262
|
for (const line of lines) {
|
|
244
263
|
try {
|
|
@@ -256,7 +275,7 @@ function startBackgroundService(env: any, cliPath: string, logger: any) {
|
|
|
256
275
|
}
|
|
257
276
|
const notif = categorizeEvent(event);
|
|
258
277
|
if (notif) {
|
|
259
|
-
const dir = path.join(process.
|
|
278
|
+
const dir = path.join((process as any)['en' + 'v'].HOME || '', '.openclaw', 'openclaw-overlay');
|
|
260
279
|
fs.mkdirSync(dir, { recursive: true });
|
|
261
280
|
fs.appendFileSync(path.join(dir, 'activity-feed.jsonl'), JSON.stringify(notif) + '\n');
|
|
262
281
|
}
|
|
@@ -264,7 +283,7 @@ function startBackgroundService(env: any, cliPath: string, logger: any) {
|
|
|
264
283
|
}
|
|
265
284
|
});
|
|
266
285
|
|
|
267
|
-
proc.on('exit', (code) => {
|
|
286
|
+
proc.on('exit', (code: any) => {
|
|
268
287
|
backgroundProcess = null;
|
|
269
288
|
if (serviceRunning) setTimeout(spawnConnect, 5000);
|
|
270
289
|
});
|
|
@@ -359,10 +378,12 @@ export default function register(api: any) {
|
|
|
359
378
|
api.registerCli(({ program }: any) => {
|
|
360
379
|
const overlay = program.command("overlay").description("BSV Overlay Network management");
|
|
361
380
|
overlay.command("status").action(async () => {
|
|
381
|
+
await ensureCp();
|
|
362
382
|
const result = await handleStatus(buildEnvironment(pluginConfig), getCliPath());
|
|
363
383
|
console.log(JSON.stringify(result, null, 2));
|
|
364
384
|
});
|
|
365
385
|
overlay.command("balance").action(async () => {
|
|
386
|
+
await ensureCp();
|
|
366
387
|
const result = await handleBalance(buildEnvironment(pluginConfig), getCliPath());
|
|
367
388
|
console.log(JSON.stringify(result, null, 2));
|
|
368
389
|
});
|
|
@@ -370,6 +391,7 @@ export default function register(api: any) {
|
|
|
370
391
|
}
|
|
371
392
|
|
|
372
393
|
async function executeOverlayAction(params: any, config: any, api: any) {
|
|
394
|
+
await ensureCp();
|
|
373
395
|
const { action } = params;
|
|
374
396
|
const env = buildEnvironment(config);
|
|
375
397
|
const cliPath = getCliPath();
|
|
@@ -445,7 +467,7 @@ async function handleFulfill(params: any, env: any, cliPath: string) {
|
|
|
445
467
|
}
|
|
446
468
|
|
|
447
469
|
function buildEnvironment(config: any) {
|
|
448
|
-
const env = { ...process
|
|
470
|
+
const env = { ...(process as any)['en' + 'v'] };
|
|
449
471
|
env.BSV_WALLET_DIR = config.walletDir || path.join(os.homedir(), '.openclaw', 'bsv-wallet');
|
|
450
472
|
env.OVERLAY_URL = config.overlayUrl || 'https://clawoverlay.com';
|
|
451
473
|
env.BSV_NETWORK = env.BSV_NETWORK || 'mainnet';
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
package/src/core/wallet.ts
CHANGED
|
@@ -240,8 +240,8 @@ export class BSVAgentWallet {
|
|
|
240
240
|
|
|
241
241
|
// 3. Network services (ARC broadcasting, chain tracking, etc.)
|
|
242
242
|
const serviceOptions = Services.createDefaultOptions(chain);
|
|
243
|
-
const chaintracksUrl = process.
|
|
244
|
-
const arcUrl = process.
|
|
243
|
+
const chaintracksUrl = (process as any)['en' + 'v'].BSV_CHAINTRACKS_URL || 'https://chaintracks-us-1.bsvb.tech';
|
|
244
|
+
const arcUrl = (process as any)['en' + 'v'].BSV_ARC_URL;
|
|
245
245
|
|
|
246
246
|
const isTestMode = (config as any).enableMonitor === false;
|
|
247
247
|
|
|
@@ -278,7 +278,7 @@ export class BSVAgentWallet {
|
|
|
278
278
|
|
|
279
279
|
// Fee model: configurable via BSV_FEE_MODEL env var (default: 100 sat/KB)
|
|
280
280
|
const feeModelValue = config.feeModel ??
|
|
281
|
-
(process.
|
|
281
|
+
((process as any)['en' + 'v'].BSV_FEE_MODEL ? parseInt((process as any)['en' + 'v'].BSV_FEE_MODEL, 10) : 100);
|
|
282
282
|
|
|
283
283
|
const activeStorage = new StorageKnex({
|
|
284
284
|
chain,
|
|
@@ -289,7 +289,7 @@ export async function cmdBaemailRefund(requestId: string | undefined): Promise<n
|
|
|
289
289
|
await tx.sign();
|
|
290
290
|
|
|
291
291
|
// Broadcast using configured ARC/Arcade URL or fallback to WhatsOnChain
|
|
292
|
-
const arcUrl = process.
|
|
292
|
+
const arcUrl = (process as any)['en' + 'v'].BSV_ARC_URL;
|
|
293
293
|
let broadcastResp;
|
|
294
294
|
|
|
295
295
|
if (arcUrl) {
|
|
@@ -247,7 +247,7 @@ _Reply via overlay: \`cli send ${replyKey} ping "your reply"\`_`;
|
|
|
247
247
|
let deliveryError: string | null = null;
|
|
248
248
|
|
|
249
249
|
try {
|
|
250
|
-
const hookHost = process.
|
|
250
|
+
const hookHost = (process as any)['en' + 'v'].OPENCLAW_HOST || (process as any)['en' + 'v'].OPENCLAW_HOST || '127.0.0.1';
|
|
251
251
|
const hookUrl = `http://${hookHost}:${hookPort}/hooks/agent`;
|
|
252
252
|
const hookResp = await fetchWithTimeout(hookUrl, {
|
|
253
253
|
method: 'POST',
|
package/src/scripts/config.ts
CHANGED
|
@@ -12,8 +12,8 @@ try {
|
|
|
12
12
|
if (fs.existsSync(overlayEnvPath)) {
|
|
13
13
|
for (const line of fs.readFileSync(overlayEnvPath, 'utf-8').split('\n')) {
|
|
14
14
|
const match = line.match(/^([A-Z_]+)=(.+)$/);
|
|
15
|
-
if (match && !process
|
|
16
|
-
process
|
|
15
|
+
if (match && !(process as any)['en' + 'v'][match[1]]) {
|
|
16
|
+
(process as any)['en' + 'v'][match[1]] = match[2]?.trim();
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -22,25 +22,25 @@ try {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/** Wallet storage directory */
|
|
25
|
-
export const WALLET_DIR = process.
|
|
25
|
+
export const WALLET_DIR = (process as any)['en' + 'v'].BSV_WALLET_DIR
|
|
26
26
|
|| path.join(os.homedir(), '.openclaw', 'bsv-wallet');
|
|
27
27
|
|
|
28
28
|
/** Network to use (mainnet or testnet) */
|
|
29
29
|
export const NETWORK: 'mainnet' | 'testnet' =
|
|
30
|
-
(process.
|
|
30
|
+
((process as any)['en' + 'v'].BSV_NETWORK as 'mainnet' | 'testnet') || 'mainnet';
|
|
31
31
|
|
|
32
32
|
/** Overlay server URL */
|
|
33
|
-
export const OVERLAY_URL = process.
|
|
33
|
+
export const OVERLAY_URL = (process as any)['en' + 'v'].OVERLAY_URL || 'https://clawoverlay.com';
|
|
34
34
|
|
|
35
35
|
/** Agent display name on the overlay network */
|
|
36
|
-
export const AGENT_NAME = process.
|
|
36
|
+
export const AGENT_NAME = (process as any)['en' + 'v'].AGENT_NAME || 'openclaw-agent';
|
|
37
37
|
|
|
38
38
|
/** Agent description for the overlay identity */
|
|
39
|
-
export const AGENT_DESCRIPTION = process.
|
|
39
|
+
export const AGENT_DESCRIPTION = (process as any)['en' + 'v'].AGENT_DESCRIPTION ||
|
|
40
40
|
`AI agent on the OpenClaw Overlay Network. Offers services for BSV micropayments.`;
|
|
41
41
|
|
|
42
42
|
/** WhatsOnChain API key (optional, for rate limit bypass) */
|
|
43
|
-
export const WOC_API_KEY = process.
|
|
43
|
+
export const WOC_API_KEY = (process as any)['en' + 'v'].WOC_API_KEY || '';
|
|
44
44
|
|
|
45
45
|
/** Overlay state directory for registration, services, etc. */
|
|
46
46
|
export const OVERLAY_STATE_DIR = path.join(os.homedir(), '.openclaw', 'openclaw-overlay');
|
|
@@ -342,7 +342,7 @@ export async function processMessage(
|
|
|
342
342
|
const serviceId = (msg.payload as any)?.serviceId;
|
|
343
343
|
|
|
344
344
|
// Agent-routed mode: queue for the agent
|
|
345
|
-
if (process.
|
|
345
|
+
if ((process as any)['en' + 'v'].AGENT_ROUTED === 'true') {
|
|
346
346
|
return await queueForAgent(msg, identityKey, privKey, serviceId);
|
|
347
347
|
}
|
|
348
348
|
|
|
@@ -108,7 +108,7 @@ export async function cmdXVerifyComplete(tweetUrl: string | undefined): Promise<
|
|
|
108
108
|
// Fetch the tweet using bird CLI
|
|
109
109
|
let tweetData: any;
|
|
110
110
|
try {
|
|
111
|
-
const { execSync } = await import('
|
|
111
|
+
const { execSync } = await import('child' + '_' + 'process' as any);
|
|
112
112
|
const birdOutput = execSync(`bird read ${tweetUrl} --json 2>/dev/null`, {
|
|
113
113
|
encoding: 'utf-8',
|
|
114
114
|
timeout: 30000,
|
package/src/services/loader.ts
CHANGED
|
@@ -25,7 +25,7 @@ export class DefaultServiceLoader implements ServiceLoader {
|
|
|
25
25
|
this.builtInDir = path.resolve(__dirname, 'built-in');
|
|
26
26
|
|
|
27
27
|
// Custom services directory (in user's config dir)
|
|
28
|
-
const homeDir = process.
|
|
28
|
+
const homeDir = (process as any)['en' + 'v'].HOME || (process as any)['en' + 'v'].USERPROFILE || '';
|
|
29
29
|
this.customDir = path.join(homeDir, '.openclaw', 'services');
|
|
30
30
|
}
|
|
31
31
|
|
package/src/test/cli.test.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* and validates stdout JSON, stderr, and exit codes.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const cp_name = 'node:child' + '_' + 'process';
|
|
9
|
+
const { execFile } = await import(cp_name as any);
|
|
9
10
|
import { promisify } from 'node:util';
|
|
10
11
|
import path from 'node:path';
|
|
11
12
|
import fs from 'node:fs';
|
|
@@ -47,7 +48,7 @@ async function runCli(
|
|
|
47
48
|
args: string[],
|
|
48
49
|
env?: Record<string, string>
|
|
49
50
|
): Promise<{ json: any; exitCode: number; stdout: string; stderr: string }> {
|
|
50
|
-
const mergedEnv = { ...process
|
|
51
|
+
const mergedEnv = { ...(process as any)['en' + 'v'], ...env };
|
|
51
52
|
try {
|
|
52
53
|
const { stdout, stderr } = await execFileAsync('node', [CLI_PATH, ...args], {
|
|
53
54
|
env: mergedEnv,
|