/SKILL.md` frontmatter),
+ 运行中不变;返 name + description 给 UI 渲染。排序按 name 升序(registry 已 sorted)。
+ """
+ reg = getattr(app.state, "skill_registry", None)
+ skills = list(reg.skills.values()) if reg else []
+ return {
+ "skills": [
+ {"name": s.name, "description": s.description}
+ for s in skills
+ ]
+ }
+
@app.delete("/v1/tasks/{task_id}", status_code=204, tags=["tasks"])
def delete_task(task_id: str, user_id: UUID = Depends(require_user)):
"""硬删除:DELETE DB 行(messages / runs CASCADE)。**FS task_dir 不动**
diff --git a/web/static/dev.html b/web/static/dev.html
index a33c00b..816fd07 100644
--- a/web/static/dev.html
+++ b/web/static/dev.html
@@ -345,8 +345,10 @@
-
-
+
+
@@ -1065,7 +1067,7 @@ $("hd-new").onclick = async () => {
$("nt-err").textContent = "";
$("nt-wd-hint").textContent = "";
$("new-task-modal").classList.add("show");
- await loadFolderSuggestions(); // 拉已有目录填 datalist
+ await Promise.all([loadFolderSuggestions(), loadSkillOptions()]);
$("nt-name").focus();
};
$("nt-cancel").onclick = () => $("new-task-modal").classList.remove("show");
@@ -1073,7 +1075,7 @@ $("nt-go").onclick = async () => {
const name = $("nt-name").value.trim();
const working_dir = $("nt-wd").value.trim();
const desc = $("nt-desc").value.trim();
- const skill = $("nt-skill").value.trim();
+ const skill = $("nt-skill").value;
$("nt-err").textContent = "";
if (!name) { $("nt-err").textContent = "任务名为必填项"; return; }
try {
@@ -1101,6 +1103,27 @@ async function loadFolderSuggestions() {
}
}
+// 智能体类型下拉:skill registry 服务器端静态,首次加载后缓存到 state.skills
+async function loadSkillOptions() {
+ const sel = $("nt-skill");
+ if (!state.skills) {
+ try {
+ const data = await api("GET", "/v1/skills");
+ state.skills = data.skills || [];
+ } catch (e) {
+ state.skills = []; // 静默兜底,select 仍保留"(默认)"项
+ }
+ }
+ // 渲染:第一项固定为"默认"(空 value),其后逐 skill 一项
+ const opts = [''];
+ for (const s of state.skills) {
+ const label = `${s.name}${s.description ? " — " + s.description : ""}`;
+ opts.push(``);
+ }
+ sel.innerHTML = opts.join("");
+ sel.value = ""; // hd-new 已清空,这里幂等再保一次
+}
+
$("nt-wd").addEventListener("input", () => {
const v = $("nt-wd").value.trim();
const hint = $("nt-wd-hint");