@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.
@@ -1,129 +1,104 @@
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
- }
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",
3
+ "version": "1.0.5",
4
4
  "description": "OpenClaw plugin for MemWyre persistent memory.",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "type": "module",
7
6
  "files": [
8
- "dist",
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
- "@memwyre/openclaw-plugin": "openclaw.plugin.json"
34
- }
22
+ "extensions": [
23
+ "./index.ts"
24
+ ]
35
25
  }
36
26
  }
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- interface PluginConfig {
2
- apiKey: string;
3
- hostUrl: string;
4
- }
5
- export default function setup(register: any, config: PluginConfig): Promise<void>;
6
- export {};