|
|
@@ -214,7 +214,11 @@ install_safe_gc() { # 范围受限的本地清理器;定时 wrapper 才带 --a
|
|
|
}
|
|
|
|
|
|
install_container_skills() { # 按清单把容器侧技能装进 $DST/skills/<scope>/<name>/
|
|
|
- # 清单就是唯一真源:新增/替换技能只改 container-skill-manifest.json,不改本脚本。
|
|
|
+ # 清单是唯一真源。v2 支持两种来源:
|
|
|
+ # source.type=local → 从宿主机仓库目录拷(离线,永远可用)
|
|
|
+ # source.type=repo → 从 skills-storage 仓库拉(容器可真源,但开通时宿主没有容器网络)
|
|
|
+ # 开通阶段宿主无法替容器 clone,所以 repo 型一律走宿主机侧 fallback 目录;
|
|
|
+ # 容器运行期再由 refresh 脚本(或 Hermes 自身)从仓库拉最新版。
|
|
|
local here manifest count=0
|
|
|
here=$(cd "$(dirname "$0")/.." && pwd)
|
|
|
manifest="$here/container-skill-manifest.json"
|
|
|
@@ -228,33 +232,52 @@ data = json.load(open(manifest))
|
|
|
for s in data.get("skills", []):
|
|
|
if s.get("disabled"):
|
|
|
continue
|
|
|
- src = os.path.join(root, os.path.basename(s["source"]))
|
|
|
- missing = [f for f in s.get("files", []) if not os.path.isfile(os.path.join(src, f))]
|
|
|
+ src_spec = s.get("source")
|
|
|
+ if isinstance(src_spec, dict):
|
|
|
+ # repo 型:开通阶段用宿主机 fallback;没有 fallback 则跳过(容器运行期再拉)
|
|
|
+ rel = src_spec.get("fallback")
|
|
|
+ src_kind = "repo"
|
|
|
+ if not rel:
|
|
|
+ print("SKIP\t%s\trepo-without-fallback" % s["name"])
|
|
|
+ continue
|
|
|
+ else:
|
|
|
+ rel = src_spec
|
|
|
+ src_kind = "local"
|
|
|
+ src = os.path.join(root, os.path.basename(rel) if src_kind == "local" else rel)
|
|
|
+ if not os.path.isdir(src):
|
|
|
+ print("MISSING\t%s\t目录不存在:%s" % (s["name"], src))
|
|
|
+ continue
|
|
|
+ files = s.get("files", [])
|
|
|
+ missing = [f for f in files if not os.path.isfile(os.path.join(src, f))]
|
|
|
if missing:
|
|
|
print("MISSING\t%s\t%s" % (s["name"], ",".join(missing)))
|
|
|
continue
|
|
|
- print("OK\t%s\t%s\t%s\t%s" % (s["name"], s.get("scope", "custom"), src,
|
|
|
- ",".join(s.get("files", []))))
|
|
|
+ print("OK\t%s\t%s\t%s\t%s\t%s" % (s["name"], s.get("scope", "custom"), src,
|
|
|
+ ",".join(files), src_kind))
|
|
|
PY
|
|
|
) || fail configure SKILL_MANIFEST_INVALID "技能清单解析失败"
|
|
|
|
|
|
while IFS=$'\t' read -r status name rest; do
|
|
|
[ -n "${status:-}" ] || continue
|
|
|
+ if [ "$status" = "SKIP" ]; then
|
|
|
+ echo "[SKIP] 技能 $name 仅提供远程源,容器运行期自行拉取($rest)"
|
|
|
+ continue
|
|
|
+ fi
|
|
|
if [ "$status" = "MISSING" ]; then
|
|
|
- # 必需技能缺文件 = 开通失败;可选技能只告警
|
|
|
local req
|
|
|
req=$(python3 -c 'import json,sys;d=json.load(open(sys.argv[1]));print(next((str(s.get("required",False)).lower() for s in d["skills"] if s["name"]==sys.argv[2]),"false"))' "$manifest" "$name")
|
|
|
if [ "$req" = "true" ]; then
|
|
|
- fail configure SKILL_FILE_MISSING "必需技能 $name 缺文件: $rest"
|
|
|
+ fail configure SKILL_FILE_MISSING "必需技能 $name: $rest"
|
|
|
fi
|
|
|
- echo "[WARN] 技能 $name 缺文件,跳过: $rest"
|
|
|
+ echo "[WARN] 技能 $name 跳过: $rest"
|
|
|
continue
|
|
|
fi
|
|
|
- # OK<TAB>name<TAB>scope<TAB>src<TAB>files
|
|
|
- local scope src files dest
|
|
|
+ # OK<TAB>name<TAB>scope<TAB>src<TAB>files<TAB>kind
|
|
|
+ local scope src files kind dest
|
|
|
scope=$(printf '%s' "$rest" | cut -f1)
|
|
|
src=$(printf '%s' "$rest" | cut -f2)
|
|
|
files=$(printf '%s' "$rest" | cut -f3)
|
|
|
+ kind=$(printf '%s' "$rest" | cut -f4)
|
|
|
dest="$DST/skills/$scope/$name"
|
|
|
install -d -o 10000 -g 10000 -m 0755 "$dest"
|
|
|
local IFS_OLD="$IFS"; IFS=','
|
|
|
@@ -262,10 +285,9 @@ PY
|
|
|
install -o 10000 -g 10000 -m 0644 "$src/$f" "$dest/$f"
|
|
|
done
|
|
|
IFS="$IFS_OLD"
|
|
|
- # 可执行脚本单独给权限(清单里不再逐个判断 .py,统一 +x 更稳)
|
|
|
chmod 0755 "$dest"/*.py 2>/dev/null || true
|
|
|
count=$((count + 1))
|
|
|
- echo "[SKILL] 已下发 $name -> $dest"
|
|
|
+ echo "[SKILL] 已下发 $name -> $dest (source=$kind)"
|
|
|
done <<< "$plan"
|
|
|
|
|
|
[ "$count" -gt 0 ] && step configure ok "容器技能已下发 $count 个" "" "manifest=$(basename "$manifest")"
|