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