openclaw-overlay-plugin 0.8.9 → 0.8.11
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 +6 -1
- package/dist/src/compatibility.test.js +1 -12
- package/dist/src/core/wallet.js +7 -1
- package/dist/src/scripts/messaging/connect.js +10 -3
- package/index.ts +7 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +6 -4
- package/src/ambient.d.ts +1 -0
- package/src/compatibility.test.ts +1 -12
- package/src/core/wallet.ts +8 -1
- package/src/scripts/messaging/connect.ts +11 -3
package/dist/index.js
CHANGED
|
@@ -12,6 +12,8 @@ import { cmdServiceQueue } from './src/scripts/services/queue.js';
|
|
|
12
12
|
import { cmdRespondService } from './src/scripts/services/respond.js';
|
|
13
13
|
import { cmdConnect } from './src/scripts/messaging/connect.js';
|
|
14
14
|
import { setNoExit } from './src/scripts/output.js';
|
|
15
|
+
import debug from 'debug';
|
|
16
|
+
const log = debug('openclaw:plugin:overlay');
|
|
15
17
|
// Track background service state
|
|
16
18
|
let serviceRunning = false;
|
|
17
19
|
let abortController = null;
|
|
@@ -251,7 +253,9 @@ export function register(api) {
|
|
|
251
253
|
acceptsArgs: true,
|
|
252
254
|
handler: async (ctx) => {
|
|
253
255
|
try {
|
|
254
|
-
|
|
256
|
+
api.logger?.info?.(`[openclaw-overlay] Command received with args: ${JSON.stringify(ctx.args)} (type: ${typeof ctx.args})`);
|
|
257
|
+
const args = Array.isArray(ctx.args) ? ctx.args : (typeof ctx.args === 'string' ? ctx.args.split(' ').filter(Boolean) : []);
|
|
258
|
+
const action = args[0] || 'status';
|
|
255
259
|
const result = await executeOverlayAction({ action }, pluginConfig, api);
|
|
256
260
|
return { text: `**Overlay ${action.toUpperCase()}**\n\n${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}` };
|
|
257
261
|
}
|
|
@@ -300,6 +304,7 @@ export function register(api) {
|
|
|
300
304
|
}
|
|
301
305
|
async function executeOverlayAction(params, config, api) {
|
|
302
306
|
const { action } = params;
|
|
307
|
+
log('Executing action: %s with params: %O', action, params);
|
|
303
308
|
applyConfigToEnv(config);
|
|
304
309
|
switch (action) {
|
|
305
310
|
case "request": {
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compatibility Test for Node 24 and OpenClaw SDK
|
|
3
3
|
*/
|
|
4
|
-
import sqlite3 from 'sqlite3';
|
|
5
4
|
import { plugin } from '../index.js';
|
|
6
5
|
async function testCompatibility() {
|
|
7
6
|
console.log('--- Overlay Compatibility Test ---');
|
|
8
|
-
// 1. Verify
|
|
9
|
-
try {
|
|
10
|
-
const db = new sqlite3.Database(':memory:');
|
|
11
|
-
console.log('✓ SQLite3 native bindings loaded successfully.');
|
|
12
|
-
db.close();
|
|
13
|
-
}
|
|
14
|
-
catch (err) {
|
|
15
|
-
console.error('✗ SQLite3 failed to load bindings:', err.message);
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
// 2. Verify Plugin Registration (SDK Descriptors)
|
|
7
|
+
// 1. Verify Plugin Registration (SDK Descriptors)
|
|
19
8
|
let registeredCli = false;
|
|
20
9
|
let hasDescriptors = false;
|
|
21
10
|
const mockApi = {
|
package/dist/src/core/wallet.js
CHANGED
|
@@ -10,6 +10,8 @@ import { Wallet, WalletStorageManager, Services, Monitor, StorageKnex, randomByt
|
|
|
10
10
|
import knexLib from 'knex';
|
|
11
11
|
import * as path from 'node:path';
|
|
12
12
|
import * as fs from 'node:fs';
|
|
13
|
+
import debug from 'debug';
|
|
14
|
+
const log = debug('openclaw:plugin:overlay:wallet');
|
|
13
15
|
import { toChain, DEFAULT_TAAL_API_KEYS, DEFAULT_DB_NAME } from './config.js';
|
|
14
16
|
import { buildPayment } from './payment.js';
|
|
15
17
|
import { verifyPayment, acceptPayment } from './verify.js';
|
|
@@ -50,6 +52,7 @@ export class BSVAgentWallet {
|
|
|
50
52
|
* The SQLite database and identity file are written to `config.storageDir`.
|
|
51
53
|
*/
|
|
52
54
|
static async create(config) {
|
|
55
|
+
log('Creating new wallet in: %s', config.storageDir);
|
|
53
56
|
// Generate a new root key (or use one provided in config)
|
|
54
57
|
const rootKeyHex = config.rootKeyHex ?? PrivateKey.fromRandom().toHex();
|
|
55
58
|
const rootKey = PrivateKey.fromHex(rootKeyHex);
|
|
@@ -73,9 +76,11 @@ export class BSVAgentWallet {
|
|
|
73
76
|
* Reads the persisted identity file and re-initializes the wallet.
|
|
74
77
|
*/
|
|
75
78
|
static async load(config) {
|
|
79
|
+
log('Loading wallet from: %s', config.storageDir);
|
|
76
80
|
const identityPath = path.join(config.storageDir, IDENTITY_FILE);
|
|
77
81
|
if (!fs.existsSync(identityPath)) {
|
|
78
82
|
if (config.createIfMissing === false) {
|
|
83
|
+
log('Wallet not found and createIfMissing is false');
|
|
79
84
|
throw new Error(`No wallet found in ${config.storageDir}`);
|
|
80
85
|
}
|
|
81
86
|
return this.create(config);
|
|
@@ -182,6 +187,7 @@ export class BSVAgentWallet {
|
|
|
182
187
|
*/
|
|
183
188
|
static async buildSetup(config, rootKeyHex) {
|
|
184
189
|
const chain = toChain(config.network);
|
|
190
|
+
log('Building setup for chain: %s (network: %s)', chain, config.network);
|
|
185
191
|
const taalApiKey = config.taalApiKey ?? DEFAULT_TAAL_API_KEYS[chain];
|
|
186
192
|
const rootKey = PrivateKey.fromHex(rootKeyHex);
|
|
187
193
|
const identityKey = rootKey.toPublicKey().toString();
|
|
@@ -217,7 +223,7 @@ export class BSVAgentWallet {
|
|
|
217
223
|
// 6. SQLite storage via knex
|
|
218
224
|
const filePath = path.join(config.storageDir, `${DEFAULT_DB_NAME}.sqlite`);
|
|
219
225
|
const knex = knexLib({
|
|
220
|
-
client: '
|
|
226
|
+
client: 'sqlite3',
|
|
221
227
|
connection: { filename: filePath },
|
|
222
228
|
useNullAsDefault: true,
|
|
223
229
|
});
|
|
@@ -7,6 +7,8 @@ import { fail } from '../output.js';
|
|
|
7
7
|
import { loadIdentity } from '../wallet/identity.js';
|
|
8
8
|
import { processMessage } from './handlers.js';
|
|
9
9
|
import { ensureStateDir } from '../utils/storage.js';
|
|
10
|
+
import debug from 'debug';
|
|
11
|
+
const log = debug('openclaw:plugin:overlay:connect');
|
|
10
12
|
/**
|
|
11
13
|
* Connect command: establish WebSocket connection for real-time messaging.
|
|
12
14
|
* Supports being used as a library with onMessage callback and AbortSignal.
|
|
@@ -22,6 +24,7 @@ export async function cmdConnect(onMessage, signal) {
|
|
|
22
24
|
}
|
|
23
25
|
const { identityKey, privKey } = await loadIdentity();
|
|
24
26
|
const wsUrl = OVERLAY_URL.replace(/^http/, 'ws') + '/relay/subscribe?identity=' + identityKey;
|
|
27
|
+
log('Connecting to WebSocket relay: %s', wsUrl);
|
|
25
28
|
let reconnectDelay = 1000;
|
|
26
29
|
let shouldReconnect = true;
|
|
27
30
|
let currentWs = null;
|
|
@@ -59,18 +62,22 @@ export async function cmdConnect(onMessage, signal) {
|
|
|
59
62
|
const ws = new WebSocketClient(wsUrl);
|
|
60
63
|
currentWs = ws;
|
|
61
64
|
ws.on('open', () => {
|
|
65
|
+
log('WebSocket connection established!');
|
|
62
66
|
reconnectDelay = 1000; // reset on successful connect
|
|
63
|
-
const
|
|
67
|
+
const logMsg = { event: 'connected', identity: identityKey, overlay: OVERLAY_URL };
|
|
64
68
|
if (onMessage)
|
|
65
|
-
onMessage(
|
|
69
|
+
onMessage(logMsg);
|
|
66
70
|
else
|
|
67
|
-
console.error(JSON.stringify(
|
|
71
|
+
console.error(JSON.stringify(logMsg));
|
|
68
72
|
});
|
|
69
73
|
ws.on('message', async (data) => {
|
|
74
|
+
log('Incoming WebSocket message received');
|
|
70
75
|
try {
|
|
71
76
|
const envelope = JSON.parse(data.toString());
|
|
77
|
+
log('Message type: %s', envelope.type);
|
|
72
78
|
if (envelope.type === 'message') {
|
|
73
79
|
const result = await processMessage(envelope.message, identityKey, privKey);
|
|
80
|
+
log('Processed message: %s', result.id);
|
|
74
81
|
if (onMessage)
|
|
75
82
|
onMessage(result);
|
|
76
83
|
else
|
package/index.ts
CHANGED
|
@@ -13,6 +13,9 @@ import { cmdServiceQueue } from './src/scripts/services/queue.js';
|
|
|
13
13
|
import { cmdRespondService } from './src/scripts/services/respond.js';
|
|
14
14
|
import { cmdConnect } from './src/scripts/messaging/connect.js';
|
|
15
15
|
import { setNoExit } from './src/scripts/output.js';
|
|
16
|
+
import debug from 'debug';
|
|
17
|
+
|
|
18
|
+
const log = debug('openclaw:plugin:overlay');
|
|
16
19
|
|
|
17
20
|
// Track background service state
|
|
18
21
|
let serviceRunning = false;
|
|
@@ -260,7 +263,9 @@ export function register(api: any) {
|
|
|
260
263
|
acceptsArgs: true,
|
|
261
264
|
handler: async (ctx: any) => {
|
|
262
265
|
try {
|
|
263
|
-
|
|
266
|
+
api.logger?.info?.(`[openclaw-overlay] Command received with args: ${JSON.stringify(ctx.args)} (type: ${typeof ctx.args})`);
|
|
267
|
+
const args = Array.isArray(ctx.args) ? ctx.args : (typeof ctx.args === 'string' ? ctx.args.split(' ').filter(Boolean) : []);
|
|
268
|
+
const action = args[0] || 'status';
|
|
264
269
|
const result = await executeOverlayAction({ action }, pluginConfig, api);
|
|
265
270
|
return { text: `**Overlay ${action.toUpperCase()}**\n\n${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}` };
|
|
266
271
|
} catch (error: any) {
|
|
@@ -306,6 +311,7 @@ export function register(api: any) {
|
|
|
306
311
|
|
|
307
312
|
async function executeOverlayAction(params: any, config: any, api: any) {
|
|
308
313
|
const { action } = params;
|
|
314
|
+
log('Executing action: %s with params: %O', action, params);
|
|
309
315
|
applyConfigToEnv(config);
|
|
310
316
|
|
|
311
317
|
switch (action) {
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-overlay-plugin",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.11",
|
|
4
4
|
"description": "Openclaw BSV Overlay — agent discovery, service marketplace, and micropayments on the BSV blockchain",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,16 +25,18 @@
|
|
|
25
25
|
"test": "npx tsx src/test/cli.test.ts && npx tsx src/test/taskflow.test.ts && npx tsx src/test/key-derivation.test.ts",
|
|
26
26
|
"postversion": "node ../sync_versions.js",
|
|
27
27
|
"lint": "eslint src/**/*.ts",
|
|
28
|
-
"postinstall": "node -e \"try{require('
|
|
28
|
+
"postinstall": "node -e \"try{require('sqlite3')}catch{console.log('Note: sqlite3 requires build tools. If install failed, ensure python3 and a C++ compiler are available.')}\""
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@bsv/sdk": "^2.0.13",
|
|
32
32
|
"@bsv/wallet-toolbox": "^2.1.18",
|
|
33
|
-
"
|
|
33
|
+
"debug": "^4.4.0",
|
|
34
34
|
"dotenv": "^17.3.1",
|
|
35
|
-
"knex": "^3.1.0"
|
|
35
|
+
"knex": "^3.1.0",
|
|
36
|
+
"sqlite3": "^5.1.7"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
39
|
+
"@types/debug": "^4.1.12",
|
|
38
40
|
"@types/node": "^22.10.0",
|
|
39
41
|
"@types/ws": "^8.18.1",
|
|
40
42
|
"@typescript-eslint/eslint-plugin": "^8.58.0",
|
package/src/ambient.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "debug";
|
|
@@ -2,23 +2,12 @@
|
|
|
2
2
|
* Compatibility Test for Node 24 and OpenClaw SDK
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import sqlite3 from 'sqlite3';
|
|
6
5
|
import { plugin } from '../index.js';
|
|
7
6
|
|
|
8
7
|
async function testCompatibility() {
|
|
9
8
|
console.log('--- Overlay Compatibility Test ---');
|
|
10
9
|
|
|
11
|
-
// 1. Verify
|
|
12
|
-
try {
|
|
13
|
-
const db = new sqlite3.Database(':memory:');
|
|
14
|
-
console.log('✓ SQLite3 native bindings loaded successfully.');
|
|
15
|
-
db.close();
|
|
16
|
-
} catch (err: any) {
|
|
17
|
-
console.error('✗ SQLite3 failed to load bindings:', err.message);
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// 2. Verify Plugin Registration (SDK Descriptors)
|
|
10
|
+
// 1. Verify Plugin Registration (SDK Descriptors)
|
|
22
11
|
let registeredCli = false;
|
|
23
12
|
let hasDescriptors = false;
|
|
24
13
|
|
package/src/core/wallet.ts
CHANGED
|
@@ -20,6 +20,9 @@ import type { SetupWallet } from '@bsv/wallet-toolbox';
|
|
|
20
20
|
import knexLib from 'knex';
|
|
21
21
|
import * as path from 'node:path';
|
|
22
22
|
import * as fs from 'node:fs';
|
|
23
|
+
import debug from 'debug';
|
|
24
|
+
|
|
25
|
+
const log = debug('openclaw:plugin:overlay:wallet');
|
|
23
26
|
|
|
24
27
|
import type {
|
|
25
28
|
WalletConfig,
|
|
@@ -76,6 +79,7 @@ export class BSVAgentWallet {
|
|
|
76
79
|
* The SQLite database and identity file are written to `config.storageDir`.
|
|
77
80
|
*/
|
|
78
81
|
private static async create(config: WalletConfig): Promise<BSVAgentWallet> {
|
|
82
|
+
log('Creating new wallet in: %s', config.storageDir);
|
|
79
83
|
// Generate a new root key (or use one provided in config)
|
|
80
84
|
const rootKeyHex = config.rootKeyHex ?? PrivateKey.fromRandom().toHex();
|
|
81
85
|
const rootKey = PrivateKey.fromHex(rootKeyHex);
|
|
@@ -104,9 +108,11 @@ export class BSVAgentWallet {
|
|
|
104
108
|
* Reads the persisted identity file and re-initializes the wallet.
|
|
105
109
|
*/
|
|
106
110
|
static async load(config: WalletConfig & { createIfMissing?: boolean }): Promise<BSVAgentWallet> {
|
|
111
|
+
log('Loading wallet from: %s', config.storageDir);
|
|
107
112
|
const identityPath = path.join(config.storageDir, IDENTITY_FILE);
|
|
108
113
|
if (!fs.existsSync(identityPath)) {
|
|
109
114
|
if (config.createIfMissing === false) {
|
|
115
|
+
log('Wallet not found and createIfMissing is false');
|
|
110
116
|
throw new Error(`No wallet found in ${config.storageDir}`);
|
|
111
117
|
}
|
|
112
118
|
return this.create(config);
|
|
@@ -235,6 +241,7 @@ export class BSVAgentWallet {
|
|
|
235
241
|
rootKeyHex: string,
|
|
236
242
|
): Promise<SetupWallet> {
|
|
237
243
|
const chain = toChain(config.network);
|
|
244
|
+
log('Building setup for chain: %s (network: %s)', chain, config.network);
|
|
238
245
|
const taalApiKey = config.taalApiKey ?? DEFAULT_TAAL_API_KEYS[chain];
|
|
239
246
|
|
|
240
247
|
const rootKey = PrivateKey.fromHex(rootKeyHex);
|
|
@@ -279,7 +286,7 @@ export class BSVAgentWallet {
|
|
|
279
286
|
// 6. SQLite storage via knex
|
|
280
287
|
const filePath = path.join(config.storageDir, `${DEFAULT_DB_NAME}.sqlite`);
|
|
281
288
|
const knex = knexLib({
|
|
282
|
-
client: '
|
|
289
|
+
client: 'sqlite3',
|
|
283
290
|
connection: { filename: filePath },
|
|
284
291
|
useNullAsDefault: true,
|
|
285
292
|
});
|
|
@@ -8,6 +8,9 @@ import { fail } from '../output.js';
|
|
|
8
8
|
import { loadIdentity } from '../wallet/identity.js';
|
|
9
9
|
import { processMessage } from './handlers.js';
|
|
10
10
|
import { ensureStateDir } from '../utils/storage.js';
|
|
11
|
+
import debug from 'debug';
|
|
12
|
+
|
|
13
|
+
const log = debug('openclaw:plugin:overlay:connect');
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Connect command: establish WebSocket connection for real-time messaging.
|
|
@@ -24,6 +27,7 @@ export async function cmdConnect(onMessage?: (data: any) => void, signal?: Abort
|
|
|
24
27
|
|
|
25
28
|
const { identityKey, privKey } = await loadIdentity();
|
|
26
29
|
const wsUrl = OVERLAY_URL.replace(/^http/, 'ws') + '/relay/subscribe?identity=' + identityKey;
|
|
30
|
+
log('Connecting to WebSocket relay: %s', wsUrl);
|
|
27
31
|
|
|
28
32
|
let reconnectDelay = 1000;
|
|
29
33
|
let shouldReconnect = true;
|
|
@@ -60,17 +64,21 @@ export async function cmdConnect(onMessage?: (data: any) => void, signal?: Abort
|
|
|
60
64
|
currentWs = ws;
|
|
61
65
|
|
|
62
66
|
ws.on('open', () => {
|
|
67
|
+
log('WebSocket connection established!');
|
|
63
68
|
reconnectDelay = 1000; // reset on successful connect
|
|
64
|
-
const
|
|
65
|
-
if (onMessage) onMessage(
|
|
66
|
-
else console.error(JSON.stringify(
|
|
69
|
+
const logMsg = { event: 'connected', identity: identityKey, overlay: OVERLAY_URL };
|
|
70
|
+
if (onMessage) onMessage(logMsg);
|
|
71
|
+
else console.error(JSON.stringify(logMsg));
|
|
67
72
|
});
|
|
68
73
|
|
|
69
74
|
ws.on('message', async (data: any) => {
|
|
75
|
+
log('Incoming WebSocket message received');
|
|
70
76
|
try {
|
|
71
77
|
const envelope = JSON.parse(data.toString());
|
|
78
|
+
log('Message type: %s', envelope.type);
|
|
72
79
|
if (envelope.type === 'message') {
|
|
73
80
|
const result = await processMessage(envelope.message, identityKey, privKey);
|
|
81
|
+
log('Processed message: %s', result.id);
|
|
74
82
|
|
|
75
83
|
if (onMessage) onMessage(result);
|
|
76
84
|
else console.log(JSON.stringify(result));
|