(res: http.ServerResponse, urlPath: string)
| 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]; |
no test coverage detected