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

Method handleSkillEnable

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

Source from the content-addressed store, hash-verified

1457 }
1458
1459 private handleSkillEnable(res: http.ServerResponse, urlPath: string): void {
1460 const skillId = urlPath.split("/")[3];
1461 const skill = this.store.getSkill(skillId);
1462 if (!skill) { res.writeHead(404, { "Content-Type": "application/json" }); res.end(JSON.stringify({ error: "Skill not found" })); return; }
1463 if (skill.status !== "archived") { res.writeHead(400, { "Content-Type": "application/json" }); res.end(JSON.stringify({ error: "Only disabled (archived) skills can be enabled" })); return; }
1464
1465 this.store.enableSkill(skillId);
1466
1467 if (this.embedder) {
1468 const sv = this.store.getLatestSkillVersion(skillId);
1469 if (sv) {
1470 const text = `${skill.name}: ${skill.description}`;
1471 this.embedder.embed([text]).then((vecs: number[][]) => {
1472 if (vecs.length > 0) this.store.upsertSkillEmbedding(skillId, vecs[0]);
1473 }).catch(() => {});
1474 }
1475 }
1476
1477 this.jsonResponse(res, { ok: true, skillId });
1478 }
1479
1480 // ─── CRUD ───
1481

Callers 1

handleRequestMethod · 0.95

Calls 7

jsonResponseMethod · 0.95
endMethod · 0.80
getSkillMethod · 0.65
embedMethod · 0.65
enableSkillMethod · 0.45
getLatestSkillVersionMethod · 0.45
upsertSkillEmbeddingMethod · 0.45

Tested by

no test coverage detected