@memwyre/openclaw-plugin 1.0.3 → 1.0.5
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 → index.ts} +104 -129
- package/package.json +6 -16
- package/dist/index.d.ts +0 -6
|
@@ -1,129 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
}
|
|
1
|
+
// Note: This relies on OpenClaw's internal plugin loading system.
|
|
2
|
+
// We export a default setup function that takes the register parameter.
|
|
3
|
+
|
|
4
|
+
interface PluginConfig {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
hostUrl: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default async function setup(register: any, config: PluginConfig) {
|
|
10
|
+
const hostUrl = config.hostUrl.replace(/\/$/, "");
|
|
11
|
+
const headers = {
|
|
12
|
+
"Authorization": `Bearer ${config.apiKey}`,
|
|
13
|
+
"Content-Type": "application/json",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
register.tool({
|
|
17
|
+
name: "save_memory",
|
|
18
|
+
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.",
|
|
19
|
+
parameters: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
text: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "The content of the memory or note to save."
|
|
25
|
+
},
|
|
26
|
+
tags: {
|
|
27
|
+
type: "array",
|
|
28
|
+
items: { type: "string" },
|
|
29
|
+
description: "Optional list of tags."
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
required: ["text"]
|
|
33
|
+
},
|
|
34
|
+
execute: async (args: { text: string; tags?: string[] }) => {
|
|
35
|
+
try {
|
|
36
|
+
const fetch = (await import("node-fetch")).default;
|
|
37
|
+
const response = await fetch(`${hostUrl}/api/v1/llm/save_memory`, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers,
|
|
40
|
+
body: JSON.stringify({
|
|
41
|
+
content: args.text,
|
|
42
|
+
source_llm: "openclaw",
|
|
43
|
+
model_name: "openclaw-agent",
|
|
44
|
+
url: "openclaw CLI",
|
|
45
|
+
tags: args.tags || []
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
const err = await response.text();
|
|
51
|
+
throw new Error(`Failed to save memory: ${response.status} ${err}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const data = (await response.json()) as any;
|
|
55
|
+
return `Memory saved successfully to MemWyre Inbox with ID: ${data.id}`;
|
|
56
|
+
} catch (error: any) {
|
|
57
|
+
return `Error saving memory: ${error.message}`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
register.tool({
|
|
63
|
+
name: "search_memwyre",
|
|
64
|
+
description: "Search MemWyre for context or previous memories. Use this to retrieve notes, project specs, or any personal context before answering questions.",
|
|
65
|
+
parameters: {
|
|
66
|
+
type: "object",
|
|
67
|
+
properties: {
|
|
68
|
+
query: {
|
|
69
|
+
type: "string",
|
|
70
|
+
description: "The semantic search query."
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
required: ["query"]
|
|
74
|
+
},
|
|
75
|
+
execute: async (args: { query: string }) => {
|
|
76
|
+
try {
|
|
77
|
+
const fetch = (await import("node-fetch")).default;
|
|
78
|
+
const response = await fetch(`${hostUrl}/api/v1/llm/retrieve_context`, {
|
|
79
|
+
method: "POST",
|
|
80
|
+
headers,
|
|
81
|
+
body: JSON.stringify({
|
|
82
|
+
query: args.query,
|
|
83
|
+
limit_tokens: 2000
|
|
84
|
+
}),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
const err = await response.text();
|
|
89
|
+
throw new Error(`Failed to search MemWyre: ${response.status} ${err}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const data = (await response.json()) as any;
|
|
93
|
+
if (!data.context_text || data.context_text.trim() === "") {
|
|
94
|
+
return "No relevant memories found in MemWyre for this query.";
|
|
95
|
+
}
|
|
96
|
+
return `Found in MemWyre:\n${data.context_text}`;
|
|
97
|
+
} catch (error: any) {
|
|
98
|
+
return `Error searching MemWyre: ${error.message}`;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
console.log("[MemWyre] OpenClaw plugin initialized successfully.");
|
|
104
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memwyre/openclaw-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "OpenClaw plugin for MemWyre persistent memory.",
|
|
5
|
-
"
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
5
|
+
"type": "module",
|
|
7
6
|
"files": [
|
|
8
|
-
"
|
|
7
|
+
"index.ts",
|
|
9
8
|
"openclaw.plugin.json"
|
|
10
9
|
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsc",
|
|
13
|
-
"prepare": "npm run build",
|
|
14
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
15
|
-
},
|
|
16
10
|
"keywords": [
|
|
17
11
|
"openclaw",
|
|
18
12
|
"plugin",
|
|
@@ -24,13 +18,9 @@
|
|
|
24
18
|
"dependencies": {
|
|
25
19
|
"node-fetch": "^3.3.2"
|
|
26
20
|
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@types/node": "^20.0.0",
|
|
29
|
-
"typescript": "^5.0.0"
|
|
30
|
-
},
|
|
31
21
|
"openclaw": {
|
|
32
|
-
"extensions":
|
|
33
|
-
"
|
|
34
|
-
|
|
22
|
+
"extensions": [
|
|
23
|
+
"./index.ts"
|
|
24
|
+
]
|
|
35
25
|
}
|
|
36
26
|
}
|