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.
Files changed (2) hide show
  1. package/index.ts +66 -55
  2. 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
- export default definePluginEntry({
6
- setup: async (api) => {
7
- // Capture configuration
8
- const config = api.getConfig?.()?.plugins?.entries?.['openclaw-messagebox-plugin']?.config || {};
9
- const host = config.host || 'https://msg.bsv.direct';
10
- const walletDir = config.walletDir || path.join(os.homedir(), '.openclaw', 'bsv-wallet');
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
- api.logger.info(`Initializing MessageBox Plugin (host: ${host})`);
15
+ api.logger.info(`[messagebox] Initializing MessageBox Plugin (host: ${host})`);
13
16
 
14
- // Register the messagebox tool
15
- api.registerTool({
16
- name: "messagebox",
17
- description: "Secure P2P encrypted messaging and payments",
18
- parameters: {
19
- type: "object",
20
- properties: {
21
- action: {
22
- type: "string",
23
- enum: ["send", "inbox", "pay", "acknowledge", "status"],
24
- description: "Action to perform"
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
- required: ["action"]
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
- execute: async (id, params) => {
47
- // TODO: Implement execution logic using MessageBoxClient
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: `Action '${params.action}' received. (Implementation pending logic development)`
62
+ text: `Error: ${error.message}`
52
63
  }]
53
64
  };
54
65
  }
55
- });
66
+ }
67
+ });
56
68
 
57
- // Register background service for live message listening
58
- api.registerService({
59
- id: "messagebox-listener",
60
- start: async () => {
61
- api.logger.info("Starting MessageBox WebSocket listener...");
62
- // TODO: Implement WebSocket listener using MessageBoxClient.listenForLiveMessages
63
- },
64
- stop: async () => {
65
- api.logger.info("Stopping MessageBox WebSocket listener...");
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-messagebox-plugin",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "OpenClaw plugin for P2P encrypted messaging and payments via BSV MessageBox",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",