openclaw-overlay-plugin 0.8.9 → 0.8.10

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 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;
@@ -300,6 +302,7 @@ export function register(api) {
300
302
  }
301
303
  async function executeOverlayAction(params, config, api) {
302
304
  const { action } = params;
305
+ log('Executing action: %s with params: %O', action, params);
303
306
  applyConfigToEnv(config);
304
307
  switch (action) {
305
308
  case "request": {
@@ -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();
@@ -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 log = { event: 'connected', identity: identityKey, overlay: OVERLAY_URL };
67
+ const logMsg = { event: 'connected', identity: identityKey, overlay: OVERLAY_URL };
64
68
  if (onMessage)
65
- onMessage(log);
69
+ onMessage(logMsg);
66
70
  else
67
- console.error(JSON.stringify(log));
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;
@@ -306,6 +309,7 @@ export function register(api: any) {
306
309
 
307
310
  async function executeOverlayAction(params: any, config: any, api: any) {
308
311
  const { action } = params;
312
+ log('Executing action: %s with params: %O', action, params);
309
313
  applyConfigToEnv(config);
310
314
 
311
315
  switch (action) {
@@ -2,7 +2,7 @@
2
2
  "id": "openclaw-overlay-plugin",
3
3
  "name": "BSV Overlay Network",
4
4
  "description": "OpenClaw Overlay — decentralized agent marketplace with BSV micropayments",
5
- "version": "0.8.9",
5
+ "version": "0.8.10",
6
6
  "skills": [
7
7
  "./SKILL.md"
8
8
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-overlay-plugin",
3
- "version": "0.8.9",
3
+ "version": "0.8.10",
4
4
  "description": "Openclaw BSV Overlay — agent discovery, service marketplace, and micropayments on the BSV blockchain",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -31,10 +31,12 @@
31
31
  "@bsv/sdk": "^2.0.13",
32
32
  "@bsv/wallet-toolbox": "^2.1.18",
33
33
  "better-sqlite3": "^11.0.0",
34
+ "debug": "^4.4.0",
34
35
  "dotenv": "^17.3.1",
35
36
  "knex": "^3.1.0"
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",
@@ -0,0 +1 @@
1
+ declare module "debug";
@@ -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);
@@ -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 log = { event: 'connected', identity: identityKey, overlay: OVERLAY_URL };
65
- if (onMessage) onMessage(log);
66
- else console.error(JSON.stringify(log));
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));