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

Method handleSkillDisable

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

Source from the content-addressed store, hash-verified

1426 }
1427
1428 private async handleSkillDisable(res: http.ServerResponse, urlPath: string): Promise<void> {
1429 const skillId = urlPath.split("/")[3];
1430 const skill = this.store.getSkill(skillId);
1431 if (!skill) { res.writeHead(404, { "Content-Type": "application/json" }); res.end(JSON.stringify({ error: "Skill not found" })); return; }
1432 if (skill.status === "archived") { this.jsonResponse(res, { ok: true, skillId, message: "already disabled" }); return; }
1433
1434 try {
1435 if (skill.visibility === "public") {
1436 this.store.setSkillVisibility(skillId, "private");
1437 }
1438 const hub = this.resolveHubConnection();
1439 if (hub) {
1440 await hubRequestJson(hub.hubUrl, hub.userToken, "/api/v1/hub/skills/unpublish", {
1441 method: "POST",
1442 body: JSON.stringify({ sourceSkillId: skillId }),
1443 }).catch(() => {});
1444 }
1445 } catch (_) {}
1446
1447 try {
1448 const workspaceSkillsDir = path.join(this.dataDir, "workspace", "skills");
1449 const installedDir = path.join(workspaceSkillsDir, skill.name);
1450 if (fs.existsSync(installedDir)) {
1451 fs.rmSync(installedDir, { recursive: true, force: true });
1452 }
1453 } catch (_) {}
1454
1455 this.store.disableSkill(skillId);
1456 this.jsonResponse(res, { ok: true, skillId });
1457 }
1458
1459 private handleSkillEnable(res: http.ServerResponse, urlPath: string): void {
1460 const skillId = urlPath.split("/")[3];

Callers 1

handleRequestMethod · 0.95

Calls 8

jsonResponseMethod · 0.95
resolveHubConnectionMethod · 0.95
hubRequestJsonFunction · 0.90
endMethod · 0.80
getSkillMethod · 0.65
setSkillVisibilityMethod · 0.45
joinMethod · 0.45
disableSkillMethod · 0.45

Tested by

no test coverage detected