mr-memory 1.0.1 → 1.0.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/index.ts +9 -1
- package/package.json +1 -1
- package/upload.ts +19 -2
package/index.ts
CHANGED
|
@@ -190,7 +190,15 @@ const memoryRouterPlugin = {
|
|
|
190
190
|
const stateDir = opts.brain ? path.resolve(opts.brain) : path.join(os.homedir(), ".openclaw");
|
|
191
191
|
const workspacePath = opts.workspace ? path.resolve(opts.workspace) : process.cwd();
|
|
192
192
|
const { runUpload } = await import("./upload.js");
|
|
193
|
-
await runUpload({
|
|
193
|
+
await runUpload({
|
|
194
|
+
memoryKey,
|
|
195
|
+
endpoint,
|
|
196
|
+
targetPath,
|
|
197
|
+
stateDir,
|
|
198
|
+
workspacePath,
|
|
199
|
+
hasWorkspaceFlag: !!opts.workspace,
|
|
200
|
+
hasBrainFlag: !!opts.brain,
|
|
201
|
+
});
|
|
194
202
|
});
|
|
195
203
|
|
|
196
204
|
mr.command("delete")
|
package/package.json
CHANGED
package/upload.ts
CHANGED
|
@@ -118,7 +118,7 @@ async function exists(p: string): Promise<boolean> {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
async function
|
|
121
|
+
async function discoverWorkspaceFiles(workspacePath: string): Promise<string[]> {
|
|
122
122
|
const files: string[] = [];
|
|
123
123
|
|
|
124
124
|
const memoryMd = path.join(workspacePath, "MEMORY.md");
|
|
@@ -136,6 +136,12 @@ async function discoverFiles(workspacePath: string, stateDir: string): Promise<s
|
|
|
136
136
|
if (await exists(p)) files.push(p);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
return files;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function discoverBrainFiles(stateDir: string): Promise<string[]> {
|
|
143
|
+
const files: string[] = [];
|
|
144
|
+
|
|
139
145
|
const sessionsDir = path.join(stateDir, "agents", "main", "sessions");
|
|
140
146
|
if (await exists(sessionsDir)) {
|
|
141
147
|
const allSessionFiles = await fs.readdir(sessionsDir);
|
|
@@ -171,6 +177,8 @@ export async function runUpload(params: {
|
|
|
171
177
|
targetPath?: string;
|
|
172
178
|
stateDir: string;
|
|
173
179
|
workspacePath?: string;
|
|
180
|
+
hasWorkspaceFlag?: boolean;
|
|
181
|
+
hasBrainFlag?: boolean;
|
|
174
182
|
}): Promise<void> {
|
|
175
183
|
const { memoryKey, endpoint, targetPath, stateDir } = params;
|
|
176
184
|
const uploadUrl = `${endpoint}/v1/memory/upload`;
|
|
@@ -198,8 +206,17 @@ export async function runUpload(params: {
|
|
|
198
206
|
} else {
|
|
199
207
|
files = [resolved];
|
|
200
208
|
}
|
|
209
|
+
} else if (params.hasBrainFlag && !params.hasWorkspaceFlag) {
|
|
210
|
+
// --brain only: upload sessions from brain path
|
|
211
|
+
files = await discoverBrainFiles(stateDir);
|
|
212
|
+
} else if (params.hasWorkspaceFlag && !params.hasBrainFlag) {
|
|
213
|
+
// --workspace only: upload workspace files only
|
|
214
|
+
files = await discoverWorkspaceFiles(workspacePath);
|
|
201
215
|
} else {
|
|
202
|
-
|
|
216
|
+
// No flags or both flags: upload both workspace + sessions
|
|
217
|
+
const wsFiles = await discoverWorkspaceFiles(workspacePath);
|
|
218
|
+
const brainFiles = await discoverBrainFiles(stateDir);
|
|
219
|
+
files = [...wsFiles, ...brainFiles];
|
|
203
220
|
}
|
|
204
221
|
|
|
205
222
|
if (files.length === 0) {
|