openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
28 lines (27 loc) • 1.06 kB
JavaScript
import { o as resolveSafeInstallDir } from "./install-safe-path-DIFL0qYY.mjs";
import path from "node:path";
//#region src/skills/lifecycle/install-paths.ts
const VALID_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
/** Normalizes a tracked slug without accepting traversal or path separators. */
function normalizeTrackedSkillSlug(e) {
const t = e.trim();
if (!t || t.includes("/") || t.includes("\\") || t.includes("..")) throw new Error(`Invalid skill slug: ${e}`);
return t;
}
function validateRequestedSkillSlug(e) {
const t = normalizeTrackedSkillSlug(e);
if (!VALID_SLUG_PATTERN.test(t)) throw new Error(`Invalid skill slug: ${e}`);
return t;
}
function resolveWorkspaceSkillInstallDir(e, t) {
const n = path.join(path.resolve(e), "skills");
const r = resolveSafeInstallDir({
baseDir: n,
id: t,
invalidNameMessage: "invalid skill target path"
});
if (!r.ok) throw new Error(r.error);
return r.path;
}
//#endregion
export { resolveWorkspaceSkillInstallDir as n, validateRequestedSkillSlug as r, normalizeTrackedSkillSlug as t };