UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

109 lines (108 loc) • 4.79 kB
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs"; import { f as normalizeStringEntries } from "./string-normalization-DLmfYZXI.mjs"; import { o as hasConfiguredSecretInput } from "./types.secrets-BmNLLnHp.mjs"; import { t as isSessionSkillEnabled } from "./agent-filter-B8NbzRsF.mjs"; import { c as findActiveDegradedSecretOwner, m as listActiveDegradedSecretOwners } from "./runtime-degraded-state-BSnwk5PQ.mjs"; import { i as prepareBinaryAvailability, n as hasBinary, r as isConfigPathTruthyWithDefaults, t as evaluateRuntimeEligibility } from "./config-eval-nIkprN5m.mjs"; import { r as resolveSkillKey } from "./frontmatter-CetkUJdW.mjs"; import { t as resolveSkillSource } from "./source-CoV2hxdc.mjs"; //#region src/skills/loading/config.ts const DEFAULT_CONFIG_VALUES = { "browser.enabled": true, "browser.evaluateEnabled": true }; function resolveSkillsInstallPreferences(e) { return { preferBrew: e?.skills?.install?.preferBrew ?? true, nodeManager: e?.skills?.install?.nodeManager ?? "npm" }; } function isSkillConfigPathTruthy(e, t) { return isConfigPathTruthyWithDefaults(e, t, DEFAULT_CONFIG_VALUES); } function resolveSkillConfig(e, t) { return e?.skills?.entries?.[t]; } /** Returns whether cold startup isolated this exact skill's configured secret. */ function isSkillSecretOwnerUnavailable(e) { return Boolean(findActiveDegradedSecretOwner("capability", `skill:${e}`)); } /** Returns whether cold startup isolated any configured skill secret. */ function hasUnavailableSkillSecretOwners() { return listActiveDegradedSecretOwners().some((e) => e.degradationState !== "stale" && e.ownerKind === "capability" && e.ownerId.startsWith("skill:")); } function isSkillEnvRequirementSatisfied(e) { const { envName: t, skillConfig: n, primaryEnv: r } = e; return normalizeOptionalString(process.env[t]) !== void 0 || normalizeOptionalString(n?.env?.[t]) !== void 0 || r === t && hasConfiguredSecretInput(n?.apiKey); } const BUNDLED_SOURCES = /* @__PURE__ */ new Set(["openclaw-bundled", "openclaw-custodian"]); function resolveBundledAllowlist(e) { const t = e?.skills?.allowBundled; return t === void 0 ? void 0 : new Set(normalizeStringEntries(t)); } function isBundledSkillAllowed(e, t) { if (!t || !BUNDLED_SOURCES.has(resolveSkillSource(e.skill))) return true; const n = resolveSkillKey(e); return t.has(n) || t.has(e.skill.name); } /** Learned Workshop skills bypass agent allowlists and session toggles; archiving hides them. */ function isSkillEntrySelected(e, t, n) { return resolveSkillSource(e.skill) === "openclaw-workshop" || isSessionSkillEnabled(e.skill.name, t, n, resolveSkillKey(e)); } function shouldIncludeSkill(e) { const { entry: t, config: n, bundledAllowlist: r, eligibility: i } = e; const a = resolveSkillKey(t); const o = resolveSkillConfig(n, a); if (o?.enabled === false) return false; if (isSkillSecretOwnerUnavailable(a)) return false; if (!isBundledSkillAllowed(t, r)) return false; return evaluateRuntimeEligibility({ os: t.metadata?.os, platform: e.platform, remotePlatforms: i?.remote?.platforms, always: t.metadata?.always, requires: t.metadata?.requires, hasBin: e.hasBin ?? hasBinary, hasRemoteBin: i?.remote?.hasBin, hasAnyRemoteBin: i?.remote?.hasAnyBin, hasEnv: (e) => isSkillEnvRequirementSatisfied({ envName: e, skillConfig: o, primaryEnv: t.metadata?.primaryEnv }), isConfigPathTruthy: (e) => isSkillConfigPathTruthy(n, e) }); } async function prepareSkillBinaryProbe(e, t, n, r) { if (r) { const e = new Set(r.bins); return { hasBin: (t) => e.has(t) }; } const i = /* @__PURE__ */ new Set(); const a = resolveBundledAllowlist(t?.config); let o; const recordBinaryRequirement = () => { o = true; return true; }; for (const n of e) { if (!isSkillEntrySelected(n, t?.skillFilter, t?.skillOverrides)) continue; const e = n.metadata?.requires; if (!e?.bins?.length && !e?.anyBins?.length) continue; o = false; shouldIncludeSkill({ entry: n, config: t?.config, bundledAllowlist: a, eligibility: t?.eligibility, hasBin: recordBinaryRequirement }); if (o) for (const e of resolveSkillRequiredBins(n)) i.add(e); } return { hasBin: (await prepareBinaryAvailability(i, n)).hasBinary }; } function resolveSkillRequiredBins(e) { return (e.metadata?.requires?.bins ?? []).concat(e.metadata?.requires?.anyBins ?? []); } //#endregion export { isSkillEnvRequirementSatisfied as a, resolveBundledAllowlist as c, resolveSkillsInstallPreferences as d, shouldIncludeSkill as f, isSkillEntrySelected as i, resolveSkillConfig as l, isBundledSkillAllowed as n, isSkillSecretOwnerUnavailable as o, isSkillConfigPathTruthy as r, prepareSkillBinaryProbe as s, hasUnavailableSkillSecretOwners as t, resolveSkillRequiredBins as u };