@memwyre/openclaw-plugin 1.0.0
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/README.md +42 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +129 -0
- package/openclaw.plugin.json +22 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# OpenClaw MemWyre Plugin
|
|
2
|
+
|
|
3
|
+
This plugin enables the OpenClaw autonomous agent to seamlessly use MemWyre as its persistent memory and context engine. It provides the agent with first-class tools to save notes and retrieve context from the MemWyre Vault.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Assuming you have OpenClaw installed, you can link or copy this directory into your OpenClaw plugins directory, or install it via the OpenClaw CLI using the local path.
|
|
8
|
+
|
|
9
|
+
1. Ensure dependencies are installed in this plugin folder:
|
|
10
|
+
```bash
|
|
11
|
+
cd openclaw-plugin
|
|
12
|
+
npm install
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
2. Register the plugin with OpenClaw:
|
|
16
|
+
```bash
|
|
17
|
+
openclaw plugins install /path/to/openclaw-plugin
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Configuration
|
|
21
|
+
|
|
22
|
+
You must configure the plugin in your OpenClaw settings (usually `~/.openclaw/config.json` or via OpenClaw's plugin management CLI) with your MemWyre API key.
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"plugins": {
|
|
27
|
+
"@memwyre/openclaw-plugin": {
|
|
28
|
+
"apiKey": "bv_sk_your_api_key_here",
|
|
29
|
+
"hostUrl": "http://localhost:8000"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- **`apiKey`**: Generate this from the MemWyre web interface under Settings > API Keys.
|
|
36
|
+
- **`hostUrl`**: The URL where your MemWyre backend is running. If deploying to production, change this to your live URL (e.g., `https://api.yourdomain.com`).
|
|
37
|
+
|
|
38
|
+
## Tools Provided
|
|
39
|
+
|
|
40
|
+
Once configured, the OpenClaw agent will have access to the following tools:
|
|
41
|
+
- **`save_memory(text, tags)`**: Saves a new memory/note directly into your MemWyre Inbox.
|
|
42
|
+
- **`search_memwyre(query)`**: Performs semantic search across your MemWyre Vault to retrieve past context.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Note: This relies on OpenClaw's internal plugin loading system.
|
|
3
|
+
// We export a default setup function that takes the register parameter.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function(o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
return ownKeys(o);
|
|
28
|
+
};
|
|
29
|
+
return function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.default = setup;
|
|
39
|
+
async function setup(register, config) {
|
|
40
|
+
const hostUrl = config.hostUrl.replace(/\/$/, "");
|
|
41
|
+
const headers = {
|
|
42
|
+
"Authorization": `Bearer ${config.apiKey}`,
|
|
43
|
+
"Content-Type": "application/json",
|
|
44
|
+
};
|
|
45
|
+
register.tool({
|
|
46
|
+
name: "save_memory",
|
|
47
|
+
description: "Save a new memory snippet to the MemWyre Vault. Use this tool when the user explicitly asks you to 'remember' something, 'save' a note, or when you encounter important information that should be persisted for future reference.",
|
|
48
|
+
parameters: {
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
text: {
|
|
52
|
+
type: "string",
|
|
53
|
+
description: "The content of the memory or note to save."
|
|
54
|
+
},
|
|
55
|
+
tags: {
|
|
56
|
+
type: "array",
|
|
57
|
+
items: { type: "string" },
|
|
58
|
+
description: "Optional list of tags."
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
required: ["text"]
|
|
62
|
+
},
|
|
63
|
+
execute: async (args) => {
|
|
64
|
+
try {
|
|
65
|
+
const fetch = (await Promise.resolve().then(() => __importStar(require("node-fetch")))).default;
|
|
66
|
+
const response = await fetch(`${hostUrl}/api/v1/llm/save_memory`, {
|
|
67
|
+
method: "POST",
|
|
68
|
+
headers,
|
|
69
|
+
body: JSON.stringify({
|
|
70
|
+
content: args.text,
|
|
71
|
+
source_llm: "openclaw",
|
|
72
|
+
model_name: "openclaw-agent",
|
|
73
|
+
url: "openclaw CLI",
|
|
74
|
+
tags: args.tags || []
|
|
75
|
+
}),
|
|
76
|
+
});
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
const err = await response.text();
|
|
79
|
+
throw new Error(`Failed to save memory: ${response.status} ${err}`);
|
|
80
|
+
}
|
|
81
|
+
const data = (await response.json());
|
|
82
|
+
return `Memory saved successfully to MemWyre Inbox with ID: ${data.id}`;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return `Error saving memory: ${error.message}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
register.tool({
|
|
90
|
+
name: "search_memwyre",
|
|
91
|
+
description: "Search MemWyre for context or previous memories. Use this to retrieve notes, project specs, or any personal context before answering questions.",
|
|
92
|
+
parameters: {
|
|
93
|
+
type: "object",
|
|
94
|
+
properties: {
|
|
95
|
+
query: {
|
|
96
|
+
type: "string",
|
|
97
|
+
description: "The semantic search query."
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
required: ["query"]
|
|
101
|
+
},
|
|
102
|
+
execute: async (args) => {
|
|
103
|
+
try {
|
|
104
|
+
const fetch = (await Promise.resolve().then(() => __importStar(require("node-fetch")))).default;
|
|
105
|
+
const response = await fetch(`${hostUrl}/api/v1/llm/retrieve_context`, {
|
|
106
|
+
method: "POST",
|
|
107
|
+
headers,
|
|
108
|
+
body: JSON.stringify({
|
|
109
|
+
query: args.query,
|
|
110
|
+
limit_tokens: 2000
|
|
111
|
+
}),
|
|
112
|
+
});
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
const err = await response.text();
|
|
115
|
+
throw new Error(`Failed to search MemWyre: ${response.status} ${err}`);
|
|
116
|
+
}
|
|
117
|
+
const data = (await response.json());
|
|
118
|
+
if (!data.context_text || data.context_text.trim() === "") {
|
|
119
|
+
return "No relevant memories found in MemWyre for this query.";
|
|
120
|
+
}
|
|
121
|
+
return `Found in MemWyre:\n${data.context_text}`;
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
return `Error searching MemWyre: ${error.message}`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
console.log("[MemWyre] OpenClaw plugin initialized successfully.");
|
|
129
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@memwyre/openclaw-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MemWyre plugin for OpenClaw. Provides persistent memory and context retrieval tools.",
|
|
5
|
+
"configSchema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"apiKey": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Your MemWyre API Key (starts with bv_sk_)"
|
|
11
|
+
},
|
|
12
|
+
"hostUrl": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "MemWyre server URL",
|
|
15
|
+
"default": "http://localhost:8000"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"required": [
|
|
19
|
+
"apiKey"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@memwyre/openclaw-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "OpenClaw plugin for MemWyre persistent memory.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"openclaw.plugin.json"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"prepare": "npm run build",
|
|
14
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"openclaw",
|
|
18
|
+
"plugin",
|
|
19
|
+
"memwyre",
|
|
20
|
+
"memory"
|
|
21
|
+
],
|
|
22
|
+
"author": "",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"node-fetch": "^3.3.2"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^20.0.0",
|
|
29
|
+
"typescript": "^5.0.0"
|
|
30
|
+
}
|
|
31
|
+
}
|