openclaw-messagebox-plugin 0.1.1 → 0.1.2
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.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/src/client.d.ts +9 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +21 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/store.d.ts +10 -0
- package/dist/src/store.d.ts.map +1 -0
- package/dist/src/store.js +39 -0
- package/dist/src/store.js.map +1 -0
- package/dist/src/types.d.ts +15 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/index.ts +5 -5
- package/package.json +3 -2
- package/src/client.ts +6 -6
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,GAAG,EAAE,GAAG,QAuExC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import os from "os";
|
|
3
|
+
/**
|
|
4
|
+
* OpenClaw MessageBox Plugin
|
|
5
|
+
* Enables secure P2P encrypted messaging and payments.
|
|
6
|
+
*/
|
|
7
|
+
export default function register(api) {
|
|
8
|
+
// Capture configuration from the gateway
|
|
9
|
+
const pluginConfig = api.getConfig?.()?.plugins?.entries?.['openclaw-messagebox-plugin']?.config || api.config || {};
|
|
10
|
+
const host = pluginConfig.host || 'https://msg.bsv.direct';
|
|
11
|
+
const walletDir = pluginConfig.walletDir || path.join(os.homedir(), '.openclaw', 'bsv-wallet');
|
|
12
|
+
api.logger.info(`[messagebox] Initializing MessageBox Plugin (host: ${host})`);
|
|
13
|
+
// Register the messagebox tool
|
|
14
|
+
api.registerTool({
|
|
15
|
+
name: "messagebox",
|
|
16
|
+
description: "Access secure P2P encrypted messaging and direct BSV payments",
|
|
17
|
+
parameters: {
|
|
18
|
+
type: "object",
|
|
19
|
+
properties: {
|
|
20
|
+
action: {
|
|
21
|
+
type: "string",
|
|
22
|
+
enum: ["send", "inbox", "pay", "acknowledge", "status"],
|
|
23
|
+
description: "Action to perform"
|
|
24
|
+
},
|
|
25
|
+
recipientKey: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Target identity public key (hex string)"
|
|
28
|
+
},
|
|
29
|
+
body: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "Message content (will be encrypted client-side)"
|
|
32
|
+
},
|
|
33
|
+
sats: {
|
|
34
|
+
type: "number",
|
|
35
|
+
description: "Amount in satoshis for direct P2P payment"
|
|
36
|
+
},
|
|
37
|
+
messageIds: {
|
|
38
|
+
type: "array",
|
|
39
|
+
items: { type: "string" },
|
|
40
|
+
description: "List of message IDs to acknowledge/clear from server"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
required: ["action"]
|
|
44
|
+
},
|
|
45
|
+
async execute(_id, params) {
|
|
46
|
+
try {
|
|
47
|
+
// Implementation logic will go here
|
|
48
|
+
return {
|
|
49
|
+
content: [{
|
|
50
|
+
type: "text",
|
|
51
|
+
text: `MessageBox action '${params.action}' received. (Logic implementation pending)`
|
|
52
|
+
}]
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
return {
|
|
57
|
+
content: [{
|
|
58
|
+
type: "text",
|
|
59
|
+
text: `Error: ${error.message || String(error)}`
|
|
60
|
+
}]
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
// Register background service for live message listening
|
|
66
|
+
api.registerService({
|
|
67
|
+
id: "messagebox-listener",
|
|
68
|
+
start: async () => {
|
|
69
|
+
api.logger.info("[messagebox] Starting WebSocket listener...");
|
|
70
|
+
// Logic for client.listenForLiveMessages goes here
|
|
71
|
+
},
|
|
72
|
+
stop: async () => {
|
|
73
|
+
api.logger.info("[messagebox] Stopping MessageBox WebSocket listener...");
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,GAAQ;IACvC,yCAAyC;IACzC,MAAM,YAAY,GAAG,GAAG,CAAC,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,4BAA4B,CAAC,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC;IACrH,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,IAAI,wBAAwB,CAAC;IAC3D,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IAE/F,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,sDAAsD,IAAI,GAAG,CAAC,CAAC;IAE/E,+BAA+B;IAC/B,GAAG,CAAC,YAAY,CAAC;QACf,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,+DAA+D;QAC5E,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,CAAC;oBACvD,WAAW,EAAE,mBAAmB;iBACjC;gBACD,YAAY,EAAE;oBACZ,IAAI,EAAE,QAAQ;oB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types.js';
|
|
2
|
+
export declare class MessageBoxManager {
|
|
3
|
+
private client;
|
|
4
|
+
constructor(_config: MessageBoxConfig);
|
|
5
|
+
send(_recipientKey: string, _body: string, _box?: string): Promise<string>;
|
|
6
|
+
poll(_box?: string): Promise<MessageRecord[]>;
|
|
7
|
+
acknowledge(_messageIds: string[]): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7D,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAoB;gBAEtB,OAAO,EAAE,gBAAgB;IAK/B,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,MAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAMrF,IAAI,CAAC,IAAI,GAAE,MAAkB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAMxD,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE;CAGxC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class MessageBoxManager {
|
|
2
|
+
client;
|
|
3
|
+
constructor(_config) {
|
|
4
|
+
// Note: MessageBoxClient requires a WalletClient/Identity
|
|
5
|
+
// This will be initialized in an async init method or similar
|
|
6
|
+
}
|
|
7
|
+
async send(_recipientKey, _body, _box = 'default') {
|
|
8
|
+
// 1. Encrypt body for recipient
|
|
9
|
+
// 2. Call client.sendMessage
|
|
10
|
+
return "msg_id";
|
|
11
|
+
}
|
|
12
|
+
async poll(_box = 'default') {
|
|
13
|
+
// 1. Call client.listMessages
|
|
14
|
+
// 2. Decrypt and format
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
async acknowledge(_messageIds) {
|
|
18
|
+
// Call client.acknowledgeMessage
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,iBAAiB;IACpB,MAAM,CAAoB;IAElC,YAAY,OAAyB;QACnC,0DAA0D;QAC1D,8DAA8D;IAChE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,aAAqB,EAAE,KAAa,EAAE,OAAe,SAAS;QACvE,gCAAgC;QAChC,6BAA6B;QAC7B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAe,SAAS;QACjC,8BAA8B;QAC9B,wBAAwB;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,WAAqB;QACrC,iCAAiC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MessageRecord } from './types.js';
|
|
2
|
+
export declare class MessageStore {
|
|
3
|
+
private db;
|
|
4
|
+
constructor(dbPath: string);
|
|
5
|
+
init(): Promise<void>;
|
|
6
|
+
saveMessage(msg: MessageRecord): Promise<void>;
|
|
7
|
+
getInbox(limit?: number): Promise<any[]>;
|
|
8
|
+
markAcknowledged(ids: string[]): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,qBAAa,YAAY;IACvB,OAAO,CAAC,EAAE,CAAO;gBAEL,MAAM,EAAE,MAAM;IAWpB,IAAI;IAcJ,WAAW,CAAC,GAAG,EAAE,aAAa;IAI9B,QAAQ,CAAC,KAAK,GAAE,MAAW;IAI3B,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE;CAGrC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import knex from 'knex';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
export class MessageStore {
|
|
5
|
+
db;
|
|
6
|
+
constructor(dbPath) {
|
|
7
|
+
const dir = path.dirname(dbPath);
|
|
8
|
+
if (!fs.existsSync(dir))
|
|
9
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
10
|
+
this.db = knex({
|
|
11
|
+
client: 'better-sqlite3',
|
|
12
|
+
connection: { filename: dbPath },
|
|
13
|
+
useNullAsDefault: true
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async init() {
|
|
17
|
+
if (!(await this.db.schema.hasTable('messages'))) {
|
|
18
|
+
await this.db.schema.createTable('messages', (table) => {
|
|
19
|
+
table.string('id').primary();
|
|
20
|
+
table.string('senderKey');
|
|
21
|
+
table.string('recipientKey');
|
|
22
|
+
table.text('body');
|
|
23
|
+
table.string('box');
|
|
24
|
+
table.integer('ts');
|
|
25
|
+
table.boolean('acknowledged').defaultTo(false);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async saveMessage(msg) {
|
|
30
|
+
await this.db('messages').insert(msg).onConflict('id').ignore();
|
|
31
|
+
}
|
|
32
|
+
async getInbox(limit = 50) {
|
|
33
|
+
return this.db('messages').orderBy('ts', 'desc').limit(limit);
|
|
34
|
+
}
|
|
35
|
+
async markAcknowledged(ids) {
|
|
36
|
+
await this.db('messages').whereIn('id', ids).update({ acknowledged: true });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,IAAc,MAAM,MAAM,CAAC;AAClC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE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AAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAgB,EAAE;QAC/B,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,GAAa;QAClC,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface MessageRecord {
|
|
2
|
+
id: string;
|
|
3
|
+
senderKey: string;
|
|
4
|
+
recipientKey: string;
|
|
5
|
+
body: string;
|
|
6
|
+
box: string;
|
|
7
|
+
ts: number;
|
|
8
|
+
acknowledged: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface MessageBoxConfig {
|
|
11
|
+
host: string;
|
|
12
|
+
walletDir: string;
|
|
13
|
+
dbPath?: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import fs from "fs";
|
|
|
6
6
|
* OpenClaw MessageBox Plugin
|
|
7
7
|
* Enables secure P2P encrypted messaging and payments.
|
|
8
8
|
*/
|
|
9
|
-
export default function register(api) {
|
|
9
|
+
export default function register(api: any) {
|
|
10
10
|
// Capture configuration from the gateway
|
|
11
11
|
const pluginConfig = api.getConfig?.()?.plugins?.entries?.['openclaw-messagebox-plugin']?.config || api.config || {};
|
|
12
12
|
const host = pluginConfig.host || 'https://msg.bsv.direct';
|
|
@@ -46,7 +46,7 @@ export default function register(api) {
|
|
|
46
46
|
},
|
|
47
47
|
required: ["action"]
|
|
48
48
|
},
|
|
49
|
-
async execute(
|
|
49
|
+
async execute(_id: string, params: any) {
|
|
50
50
|
try {
|
|
51
51
|
// Implementation logic will go here
|
|
52
52
|
return {
|
|
@@ -55,11 +55,11 @@ export default function register(api) {
|
|
|
55
55
|
text: `MessageBox action '${params.action}' received. (Logic implementation pending)`
|
|
56
56
|
}]
|
|
57
57
|
};
|
|
58
|
-
} catch (error) {
|
|
58
|
+
} catch (error: any) {
|
|
59
59
|
return {
|
|
60
60
|
content: [{
|
|
61
61
|
type: "text",
|
|
62
|
-
text: `Error: ${error.message}`
|
|
62
|
+
text: `Error: ${error.message || String(error)}`
|
|
63
63
|
}]
|
|
64
64
|
};
|
|
65
65
|
}
|
|
@@ -74,7 +74,7 @@ export default function register(api) {
|
|
|
74
74
|
// Logic for client.listenForLiveMessages goes here
|
|
75
75
|
},
|
|
76
76
|
stop: async () => {
|
|
77
|
-
api.logger.info("[messagebox] Stopping WebSocket listener...");
|
|
77
|
+
api.logger.info("[messagebox] Stopping MessageBox WebSocket listener...");
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-messagebox-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "OpenClaw plugin for P2P encrypted messaging and payments via BSV MessageBox",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "tsc",
|
|
17
|
+
"prepublishOnly": "npm run build",
|
|
17
18
|
"lint": "eslint src/**/*.ts",
|
|
18
19
|
"test": "npx tsx src/**/*.test.ts"
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
22
|
"@bsv/sdk": "^2.0.13",
|
|
22
|
-
"@bsv/message-box-client": "^
|
|
23
|
+
"@bsv/message-box-client": "^2.0.4",
|
|
23
24
|
"better-sqlite3": "^12.8.0",
|
|
24
25
|
"knex": "^3.2.8",
|
|
25
26
|
"dotenv": "^17.3.1"
|
package/src/client.ts
CHANGED
|
@@ -2,26 +2,26 @@ import { MessageBoxClient } from '@bsv/message-box-client';
|
|
|
2
2
|
import { MessageBoxConfig, MessageRecord } from './types.js';
|
|
3
3
|
|
|
4
4
|
export class MessageBoxManager {
|
|
5
|
-
private client
|
|
5
|
+
private client!: MessageBoxClient;
|
|
6
6
|
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(_config: MessageBoxConfig) {
|
|
8
8
|
// Note: MessageBoxClient requires a WalletClient/Identity
|
|
9
|
-
// This will be initialized in
|
|
9
|
+
// This will be initialized in an async init method or similar
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
async send(
|
|
12
|
+
async send(_recipientKey: string, _body: string, _box: string = 'default'): Promise<string> {
|
|
13
13
|
// 1. Encrypt body for recipient
|
|
14
14
|
// 2. Call client.sendMessage
|
|
15
15
|
return "msg_id";
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async poll(
|
|
18
|
+
async poll(_box: string = 'default'): Promise<MessageRecord[]> {
|
|
19
19
|
// 1. Call client.listMessages
|
|
20
20
|
// 2. Decrypt and format
|
|
21
21
|
return [];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
async acknowledge(
|
|
24
|
+
async acknowledge(_messageIds: string[]) {
|
|
25
25
|
// Call client.acknowledgeMessage
|
|
26
26
|
}
|
|
27
27
|
}
|