MCPcopy Create free account
hub / github.com/MemTensor/MemOS / handleUpdate

Method handleUpdate

packages/memos-core/src/viewer/server.ts:1504–1522  ·  view source on GitHub ↗
(req: http.IncomingMessage, res: http.ServerResponse, urlPath: string)

Source from the content-addressed store, hash-verified

1502 }
1503
1504 private handleUpdate(req: http.IncomingMessage, res: http.ServerResponse, urlPath: string): void {
1505 const chunkId = urlPath.replace("/api/memory/", "");
1506 this.readBody(req, (body) => {
1507 try {
1508 const data = JSON.parse(body);
1509 if (data.content !== undefined && (typeof data.content !== "string" || !data.content.trim())) {
1510 res.writeHead(400, { "Content-Type": "application/json" });
1511 res.end(JSON.stringify({ error: "content must be a non-empty string" }));
1512 return;
1513 }
1514 const ok = this.store.updateChunk(chunkId, { summary: data.summary, content: data.content, role: data.role, owner: data.owner });
1515 if (ok) this.jsonResponse(res, { ok: true, message: "Memory updated" });
1516 else { res.writeHead(404, { "Content-Type": "application/json" }); res.end(JSON.stringify({ error: "Not found" })); }
1517 } catch (err) {
1518 res.writeHead(400, { "Content-Type": "application/json" });
1519 res.end(JSON.stringify({ error: String(err) }));
1520 }
1521 });
1522 }
1523
1524 private handleDelete(res: http.ServerResponse, urlPath: string): void {
1525 const chunkId = urlPath.replace("/api/memory/", "");

Callers 1

handleRequestMethod · 0.95

Calls 5

readBodyMethod · 0.95
jsonResponseMethod · 0.95
endMethod · 0.80
parseMethod · 0.45
updateChunkMethod · 0.45

Tested by

no test coverage detected