openclaw-overlay-plugin 0.7.44 → 0.7.46
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 +21 -10
- package/dist/src/core/wallet.d.ts +3 -1
- package/dist/src/core/wallet.js +11 -2
- package/dist/src/test/wallet.test.js +1 -1
- package/index.ts +21 -10
- package/package.json +3 -3
- package/src/core/wallet.ts +12 -3
- package/src/test/wallet.test.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -7,6 +7,17 @@ import fs from 'node:fs';
|
|
|
7
7
|
import { initializeServiceSystem, serviceManager } from './src/services/index.js';
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
10
|
+
/**
|
|
11
|
+
* Helper to correctly locate the CLI script.
|
|
12
|
+
* If running from dist/index.js, CLI is in ./src/cli.js
|
|
13
|
+
* If running from index.ts, CLI is in ./dist/src/cli.js
|
|
14
|
+
*/
|
|
15
|
+
function getCliPath() {
|
|
16
|
+
const localCli = path.join(__dirname, 'src', 'cli.js');
|
|
17
|
+
if (fs.existsSync(localCli))
|
|
18
|
+
return localCli;
|
|
19
|
+
return path.join(__dirname, 'dist', 'src', 'cli.js');
|
|
20
|
+
}
|
|
10
21
|
const execFileAsync = promisify(execFile);
|
|
11
22
|
// Track background process for proper lifecycle management
|
|
12
23
|
let backgroundProcess = null;
|
|
@@ -555,7 +566,7 @@ export default function register(api) {
|
|
|
555
566
|
try {
|
|
556
567
|
api.logger.info("Starting BSV overlay WebSocket relay...");
|
|
557
568
|
const env = buildEnvironment(pluginConfig);
|
|
558
|
-
const cliPath =
|
|
569
|
+
const cliPath = getCliPath();
|
|
559
570
|
// Initialize the service system if available
|
|
560
571
|
try {
|
|
561
572
|
await initializeServiceSystem();
|
|
@@ -584,7 +595,7 @@ export default function register(api) {
|
|
|
584
595
|
(async () => {
|
|
585
596
|
try {
|
|
586
597
|
const env = buildEnvironment(pluginConfig);
|
|
587
|
-
const cliPath =
|
|
598
|
+
const cliPath = getCliPath();
|
|
588
599
|
const regPath = path.join(process.env.HOME || '', '.openclaw', 'openclaw-overlay', 'registration.json');
|
|
589
600
|
const onboardSentFile = path.join(process.env.HOME || '', '.openclaw', 'openclaw-overlay', 'onboarding-sent.flag');
|
|
590
601
|
if (!fs.existsSync(regPath) && !fs.existsSync(onboardSentFile)) {
|
|
@@ -629,7 +640,7 @@ export default function register(api) {
|
|
|
629
640
|
.action(async () => {
|
|
630
641
|
try {
|
|
631
642
|
const env = buildEnvironment(pluginConfig);
|
|
632
|
-
const cliPath =
|
|
643
|
+
const cliPath = getCliPath();
|
|
633
644
|
const result = await handleStatus(env, cliPath);
|
|
634
645
|
console.log(JSON.stringify(result, null, 2));
|
|
635
646
|
}
|
|
@@ -643,7 +654,7 @@ export default function register(api) {
|
|
|
643
654
|
.action(async () => {
|
|
644
655
|
try {
|
|
645
656
|
const env = buildEnvironment(pluginConfig);
|
|
646
|
-
const cliPath =
|
|
657
|
+
const cliPath = getCliPath();
|
|
647
658
|
const result = await handleBalance(env, cliPath);
|
|
648
659
|
console.log(JSON.stringify(result, null, 2));
|
|
649
660
|
}
|
|
@@ -657,7 +668,7 @@ export default function register(api) {
|
|
|
657
668
|
.action(async () => {
|
|
658
669
|
try {
|
|
659
670
|
const env = buildEnvironment(pluginConfig);
|
|
660
|
-
const cliPath =
|
|
671
|
+
const cliPath = getCliPath();
|
|
661
672
|
const result = await handleAddress(env, cliPath);
|
|
662
673
|
console.log(JSON.stringify(result, null, 2));
|
|
663
674
|
}
|
|
@@ -673,7 +684,7 @@ export default function register(api) {
|
|
|
673
684
|
.action(async (options) => {
|
|
674
685
|
try {
|
|
675
686
|
const env = buildEnvironment(pluginConfig);
|
|
676
|
-
const cliPath =
|
|
687
|
+
const cliPath = getCliPath();
|
|
677
688
|
const result = await handleDiscover(options, env, cliPath);
|
|
678
689
|
if (result.agents) {
|
|
679
690
|
console.log("\nAgents:");
|
|
@@ -700,7 +711,7 @@ export default function register(api) {
|
|
|
700
711
|
.action(async () => {
|
|
701
712
|
try {
|
|
702
713
|
const env = buildEnvironment(pluginConfig);
|
|
703
|
-
const cliPath =
|
|
714
|
+
const cliPath = getCliPath();
|
|
704
715
|
const result = await handleRegister(env, cliPath);
|
|
705
716
|
console.log(JSON.stringify(result, null, 2));
|
|
706
717
|
}
|
|
@@ -716,7 +727,7 @@ export default function register(api) {
|
|
|
716
727
|
.action(async (options) => {
|
|
717
728
|
try {
|
|
718
729
|
const env = buildEnvironment(pluginConfig);
|
|
719
|
-
const cliPath =
|
|
730
|
+
const cliPath = getCliPath();
|
|
720
731
|
const result = await handleOnboard(options, env, cliPath);
|
|
721
732
|
console.log(JSON.stringify(result, null, 2));
|
|
722
733
|
}
|
|
@@ -730,7 +741,7 @@ export default function register(api) {
|
|
|
730
741
|
.action(async () => {
|
|
731
742
|
try {
|
|
732
743
|
const env = buildEnvironment(pluginConfig);
|
|
733
|
-
const cliPath =
|
|
744
|
+
const cliPath = getCliPath();
|
|
734
745
|
const result = await handlePendingRequests(env, cliPath);
|
|
735
746
|
console.log(JSON.stringify(result, null, 2));
|
|
736
747
|
}
|
|
@@ -743,7 +754,7 @@ export default function register(api) {
|
|
|
743
754
|
async function executeOverlayAction(params, config, api) {
|
|
744
755
|
const { action } = params;
|
|
745
756
|
const env = buildEnvironment(config);
|
|
746
|
-
const cliPath =
|
|
757
|
+
const cliPath = getCliPath();
|
|
747
758
|
switch (action) {
|
|
748
759
|
case "request":
|
|
749
760
|
return await handleServiceRequest(params, env, cliPath, config, api);
|
|
@@ -41,7 +41,9 @@ export declare class BSVAgentWallet {
|
|
|
41
41
|
* Load an existing agent wallet from its storage directory.
|
|
42
42
|
* Reads the persisted identity file and re-initializes the wallet.
|
|
43
43
|
*/
|
|
44
|
-
static load(config: WalletConfig
|
|
44
|
+
static load(config: WalletConfig & {
|
|
45
|
+
createIfMissing?: boolean;
|
|
46
|
+
}): Promise<BSVAgentWallet>;
|
|
45
47
|
/**
|
|
46
48
|
* Get this wallet's public identity key (compressed hex, 33 bytes).
|
|
47
49
|
* This is the key other agents use to send payments to you.
|
package/dist/src/core/wallet.js
CHANGED
|
@@ -53,7 +53,7 @@ export class BSVAgentWallet {
|
|
|
53
53
|
// Generate a new root key (or use one provided in config)
|
|
54
54
|
const rootKeyHex = config.rootKeyHex ?? PrivateKey.fromRandom().toHex();
|
|
55
55
|
const rootKey = PrivateKey.fromHex(rootKeyHex);
|
|
56
|
-
const identityKey = rootKey.toPublicKey().toString();
|
|
56
|
+
const identityKey = rootKey.toPublicKey().toString(); // toString() defaults to compressed hex
|
|
57
57
|
// Ensure the storage directory exists
|
|
58
58
|
fs.mkdirSync(config.storageDir, { recursive: true });
|
|
59
59
|
// Persist identity for later loading
|
|
@@ -75,6 +75,9 @@ export class BSVAgentWallet {
|
|
|
75
75
|
static async load(config) {
|
|
76
76
|
const identityPath = path.join(config.storageDir, IDENTITY_FILE);
|
|
77
77
|
if (!fs.existsSync(identityPath)) {
|
|
78
|
+
if (config.createIfMissing === false) {
|
|
79
|
+
throw new Error(`No wallet found in ${config.storageDir}`);
|
|
80
|
+
}
|
|
78
81
|
return this.create(config);
|
|
79
82
|
}
|
|
80
83
|
const identity = JSON.parse(fs.readFileSync(identityPath, 'utf-8'));
|
|
@@ -106,7 +109,13 @@ export class BSVAgentWallet {
|
|
|
106
109
|
* stopping the background monitor.
|
|
107
110
|
*/
|
|
108
111
|
async destroy() {
|
|
109
|
-
|
|
112
|
+
if (this._setup.monitor) {
|
|
113
|
+
await this._setup.monitor.destroy();
|
|
114
|
+
}
|
|
115
|
+
if (this._setup.wallet) {
|
|
116
|
+
await this._setup.wallet.destroy();
|
|
117
|
+
}
|
|
118
|
+
await this._setup.storage.destroy();
|
|
110
119
|
}
|
|
111
120
|
// ---------------------------------------------------------------------------
|
|
112
121
|
// Payment creation (sender/payer side)
|
|
@@ -103,7 +103,7 @@ async function run() {
|
|
|
103
103
|
await test('BSVAgentWallet.load throws for missing wallet', async () => {
|
|
104
104
|
const tmpDir = path.join(os.tmpdir(), 'a2a-nonexistent-' + Date.now());
|
|
105
105
|
try {
|
|
106
|
-
await BSVAgentWallet.load({ network: 'testnet', storageDir: tmpDir });
|
|
106
|
+
await BSVAgentWallet.load({ network: 'testnet', storageDir: tmpDir, createIfMissing: false });
|
|
107
107
|
throw new Error('Should have thrown');
|
|
108
108
|
}
|
|
109
109
|
catch (err) {
|
package/index.ts
CHANGED
|
@@ -8,6 +8,17 @@ import { initializeServiceSystem, serviceManager } from './src/services/index.js
|
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Helper to correctly locate the CLI script.
|
|
13
|
+
* If running from dist/index.js, CLI is in ./src/cli.js
|
|
14
|
+
* If running from index.ts, CLI is in ./dist/src/cli.js
|
|
15
|
+
*/
|
|
16
|
+
function getCliPath(): string {
|
|
17
|
+
const localCli = path.join(__dirname, 'src', 'cli.js');
|
|
18
|
+
if (fs.existsSync(localCli)) return localCli;
|
|
19
|
+
return path.join(__dirname, 'dist', 'src', 'cli.js');
|
|
20
|
+
}
|
|
21
|
+
|
|
11
22
|
const execFileAsync = promisify(execFile);
|
|
12
23
|
|
|
13
24
|
// Track background process for proper lifecycle management
|
|
@@ -601,7 +612,7 @@ export default function register(api: any) {
|
|
|
601
612
|
try {
|
|
602
613
|
api.logger.info("Starting BSV overlay WebSocket relay...");
|
|
603
614
|
const env = buildEnvironment(pluginConfig);
|
|
604
|
-
const cliPath =
|
|
615
|
+
const cliPath = getCliPath();
|
|
605
616
|
|
|
606
617
|
// Initialize the service system if available
|
|
607
618
|
try {
|
|
@@ -633,7 +644,7 @@ export default function register(api: any) {
|
|
|
633
644
|
(async () => {
|
|
634
645
|
try {
|
|
635
646
|
const env = buildEnvironment(pluginConfig);
|
|
636
|
-
const cliPath =
|
|
647
|
+
const cliPath = getCliPath();
|
|
637
648
|
|
|
638
649
|
const regPath = path.join(process.env.HOME || '', '.openclaw', 'openclaw-overlay', 'registration.json');
|
|
639
650
|
const onboardSentFile = path.join(process.env.HOME || '', '.openclaw', 'openclaw-overlay', 'onboarding-sent.flag');
|
|
@@ -682,7 +693,7 @@ export default function register(api: any) {
|
|
|
682
693
|
.action(async () => {
|
|
683
694
|
try {
|
|
684
695
|
const env = buildEnvironment(pluginConfig);
|
|
685
|
-
const cliPath =
|
|
696
|
+
const cliPath = getCliPath();
|
|
686
697
|
const result = await handleStatus(env, cliPath);
|
|
687
698
|
console.log(JSON.stringify(result, null, 2));
|
|
688
699
|
} catch (error: any) {
|
|
@@ -696,7 +707,7 @@ export default function register(api: any) {
|
|
|
696
707
|
.action(async () => {
|
|
697
708
|
try {
|
|
698
709
|
const env = buildEnvironment(pluginConfig);
|
|
699
|
-
const cliPath =
|
|
710
|
+
const cliPath = getCliPath();
|
|
700
711
|
const result = await handleBalance(env, cliPath);
|
|
701
712
|
console.log(JSON.stringify(result, null, 2));
|
|
702
713
|
} catch (error: any) {
|
|
@@ -710,7 +721,7 @@ export default function register(api: any) {
|
|
|
710
721
|
.action(async () => {
|
|
711
722
|
try {
|
|
712
723
|
const env = buildEnvironment(pluginConfig);
|
|
713
|
-
const cliPath =
|
|
724
|
+
const cliPath = getCliPath();
|
|
714
725
|
const result = await handleAddress(env, cliPath);
|
|
715
726
|
console.log(JSON.stringify(result, null, 2));
|
|
716
727
|
} catch (error: any) {
|
|
@@ -726,7 +737,7 @@ export default function register(api: any) {
|
|
|
726
737
|
.action(async (options: any) => {
|
|
727
738
|
try {
|
|
728
739
|
const env = buildEnvironment(pluginConfig);
|
|
729
|
-
const cliPath =
|
|
740
|
+
const cliPath = getCliPath();
|
|
730
741
|
const result = await handleDiscover(options, env, cliPath);
|
|
731
742
|
|
|
732
743
|
if (result.agents) {
|
|
@@ -755,7 +766,7 @@ export default function register(api: any) {
|
|
|
755
766
|
.action(async () => {
|
|
756
767
|
try {
|
|
757
768
|
const env = buildEnvironment(pluginConfig);
|
|
758
|
-
const cliPath =
|
|
769
|
+
const cliPath = getCliPath();
|
|
759
770
|
const result = await handleRegister(env, cliPath);
|
|
760
771
|
console.log(JSON.stringify(result, null, 2));
|
|
761
772
|
} catch (error: any) {
|
|
@@ -771,7 +782,7 @@ export default function register(api: any) {
|
|
|
771
782
|
.action(async (options: any) => {
|
|
772
783
|
try {
|
|
773
784
|
const env = buildEnvironment(pluginConfig);
|
|
774
|
-
const cliPath =
|
|
785
|
+
const cliPath = getCliPath();
|
|
775
786
|
const result = await handleOnboard(options, env, cliPath);
|
|
776
787
|
console.log(JSON.stringify(result, null, 2));
|
|
777
788
|
} catch (error: any) {
|
|
@@ -785,7 +796,7 @@ export default function register(api: any) {
|
|
|
785
796
|
.action(async () => {
|
|
786
797
|
try {
|
|
787
798
|
const env = buildEnvironment(pluginConfig);
|
|
788
|
-
const cliPath =
|
|
799
|
+
const cliPath = getCliPath();
|
|
789
800
|
const result = await handlePendingRequests(env, cliPath);
|
|
790
801
|
console.log(JSON.stringify(result, null, 2));
|
|
791
802
|
} catch (error: any) {
|
|
@@ -798,7 +809,7 @@ export default function register(api: any) {
|
|
|
798
809
|
async function executeOverlayAction(params: any, config: any, api: any) {
|
|
799
810
|
const { action } = params;
|
|
800
811
|
const env = buildEnvironment(config);
|
|
801
|
-
const cliPath =
|
|
812
|
+
const cliPath = getCliPath();
|
|
802
813
|
|
|
803
814
|
switch (action) {
|
|
804
815
|
case "request":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-overlay-plugin",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.46",
|
|
4
4
|
"description": "Openclaw BSV Overlay — agent discovery, service marketplace, and micropayments on the BSV blockchain",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"cli": "node dist/cli.js",
|
|
25
25
|
"test": "npx tsx src/**/*.test.ts",
|
|
26
26
|
"lint": "eslint src/**/*.ts",
|
|
27
|
-
"postinstall": "node-
|
|
27
|
+
"postinstall": "node -e \"try{require('better-sqlite3')}catch{console.log('Note: better-sqlite3 requires build tools. If install failed, ensure python3 and a C++ compiler are available.')}\""
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@bsv/sdk": "^2.0.13",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"./dist/index.js"
|
|
72
72
|
],
|
|
73
73
|
"hooks": [
|
|
74
|
-
"./"
|
|
74
|
+
"./dist/index.js"
|
|
75
75
|
],
|
|
76
76
|
"compat": {
|
|
77
77
|
"pluginApi": "1",
|
package/src/core/wallet.ts
CHANGED
|
@@ -79,7 +79,7 @@ export class BSVAgentWallet {
|
|
|
79
79
|
// Generate a new root key (or use one provided in config)
|
|
80
80
|
const rootKeyHex = config.rootKeyHex ?? PrivateKey.fromRandom().toHex();
|
|
81
81
|
const rootKey = PrivateKey.fromHex(rootKeyHex);
|
|
82
|
-
const identityKey = rootKey.toPublicKey().toString();
|
|
82
|
+
const identityKey = rootKey.toPublicKey().toString(); // toString() defaults to compressed hex
|
|
83
83
|
|
|
84
84
|
// Ensure the storage directory exists
|
|
85
85
|
fs.mkdirSync(config.storageDir, { recursive: true });
|
|
@@ -103,9 +103,12 @@ export class BSVAgentWallet {
|
|
|
103
103
|
* Load an existing agent wallet from its storage directory.
|
|
104
104
|
* Reads the persisted identity file and re-initializes the wallet.
|
|
105
105
|
*/
|
|
106
|
-
static async load(config: WalletConfig): Promise<BSVAgentWallet> {
|
|
106
|
+
static async load(config: WalletConfig & { createIfMissing?: boolean }): Promise<BSVAgentWallet> {
|
|
107
107
|
const identityPath = path.join(config.storageDir, IDENTITY_FILE);
|
|
108
108
|
if (!fs.existsSync(identityPath)) {
|
|
109
|
+
if (config.createIfMissing === false) {
|
|
110
|
+
throw new Error(`No wallet found in ${config.storageDir}`);
|
|
111
|
+
}
|
|
109
112
|
return this.create(config);
|
|
110
113
|
}
|
|
111
114
|
|
|
@@ -146,7 +149,13 @@ export class BSVAgentWallet {
|
|
|
146
149
|
* stopping the background monitor.
|
|
147
150
|
*/
|
|
148
151
|
async destroy(): Promise<void> {
|
|
149
|
-
|
|
152
|
+
if (this._setup.monitor) {
|
|
153
|
+
await this._setup.monitor.destroy();
|
|
154
|
+
}
|
|
155
|
+
if (this._setup.wallet) {
|
|
156
|
+
await this._setup.wallet.destroy();
|
|
157
|
+
}
|
|
158
|
+
await this._setup.storage.destroy();
|
|
150
159
|
}
|
|
151
160
|
|
|
152
161
|
// ---------------------------------------------------------------------------
|
package/src/test/wallet.test.ts
CHANGED
|
@@ -121,7 +121,7 @@ async function run() {
|
|
|
121
121
|
await test('BSVAgentWallet.load throws for missing wallet', async () => {
|
|
122
122
|
const tmpDir = path.join(os.tmpdir(), 'a2a-nonexistent-' + Date.now());
|
|
123
123
|
try {
|
|
124
|
-
await BSVAgentWallet.load({ network: 'testnet', storageDir: tmpDir });
|
|
124
|
+
await BSVAgentWallet.load({ network: 'testnet', storageDir: tmpDir, createIfMissing: false } as any);
|
|
125
125
|
throw new Error('Should have thrown');
|
|
126
126
|
} catch (err: unknown) {
|
|
127
127
|
const msg = err instanceof Error ? err.message : String(err);
|