openclaw-messagebox-plugin 0.1.0 → 0.1.1
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/index.ts +66 -55
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -1,69 +1,80 @@
|
|
|
1
|
-
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import os from "os";
|
|
3
|
+
import fs from "fs";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
/**
|
|
6
|
+
* OpenClaw MessageBox Plugin
|
|
7
|
+
* Enables secure P2P encrypted messaging and payments.
|
|
8
|
+
*/
|
|
9
|
+
export default function register(api) {
|
|
10
|
+
// Capture configuration from the gateway
|
|
11
|
+
const pluginConfig = api.getConfig?.()?.plugins?.entries?.['openclaw-messagebox-plugin']?.config || api.config || {};
|
|
12
|
+
const host = pluginConfig.host || 'https://msg.bsv.direct';
|
|
13
|
+
const walletDir = pluginConfig.walletDir || path.join(os.homedir(), '.openclaw', 'bsv-wallet');
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
api.logger.info(`[messagebox] Initializing MessageBox Plugin (host: ${host})`);
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
recipientKey: {
|
|
27
|
-
type: "string",
|
|
28
|
-
description: "Target identity public key (hex)"
|
|
29
|
-
},
|
|
30
|
-
body: {
|
|
31
|
-
type: "string",
|
|
32
|
-
description: "Message content (will be encrypted)"
|
|
33
|
-
},
|
|
34
|
-
sats: {
|
|
35
|
-
type: "number",
|
|
36
|
-
description: "Amount for P2P payment"
|
|
37
|
-
},
|
|
38
|
-
messageIds: {
|
|
39
|
-
type: "array",
|
|
40
|
-
items: { type: "string" },
|
|
41
|
-
description: "IDs of messages to acknowledge"
|
|
42
|
-
}
|
|
17
|
+
// Register the messagebox tool
|
|
18
|
+
api.registerTool({
|
|
19
|
+
name: "messagebox",
|
|
20
|
+
description: "Access secure P2P encrypted messaging and direct BSV payments",
|
|
21
|
+
parameters: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
action: {
|
|
25
|
+
type: "string",
|
|
26
|
+
enum: ["send", "inbox", "pay", "acknowledge", "status"],
|
|
27
|
+
description: "Action to perform"
|
|
43
28
|
},
|
|
44
|
-
|
|
29
|
+
recipientKey: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "Target identity public key (hex string)"
|
|
32
|
+
},
|
|
33
|
+
body: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "Message content (will be encrypted client-side)"
|
|
36
|
+
},
|
|
37
|
+
sats: {
|
|
38
|
+
type: "number",
|
|
39
|
+
description: "Amount in satoshis for direct P2P payment"
|
|
40
|
+
},
|
|
41
|
+
messageIds: {
|
|
42
|
+
type: "array",
|
|
43
|
+
items: { type: "string" },
|
|
44
|
+
description: "List of message IDs to acknowledge/clear from server"
|
|
45
|
+
}
|
|
45
46
|
},
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
required: ["action"]
|
|
48
|
+
},
|
|
49
|
+
async execute(id, params) {
|
|
50
|
+
try {
|
|
51
|
+
// Implementation logic will go here
|
|
52
|
+
return {
|
|
53
|
+
content: [{
|
|
54
|
+
type: "text",
|
|
55
|
+
text: `MessageBox action '${params.action}' received. (Logic implementation pending)`
|
|
56
|
+
}]
|
|
57
|
+
};
|
|
58
|
+
} catch (error) {
|
|
48
59
|
return {
|
|
49
60
|
content: [{
|
|
50
61
|
type: "text",
|
|
51
|
-
text: `
|
|
62
|
+
text: `Error: ${error.message}`
|
|
52
63
|
}]
|
|
53
64
|
};
|
|
54
65
|
}
|
|
55
|
-
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
56
68
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
69
|
+
// Register background service for live message listening
|
|
70
|
+
api.registerService({
|
|
71
|
+
id: "messagebox-listener",
|
|
72
|
+
start: async () => {
|
|
73
|
+
api.logger.info("[messagebox] Starting WebSocket listener...");
|
|
74
|
+
// Logic for client.listenForLiveMessages goes here
|
|
75
|
+
},
|
|
76
|
+
stop: async () => {
|
|
77
|
+
api.logger.info("[messagebox] Stopping WebSocket listener...");
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|