refactor(agents): dedupe config and truncation guards

This commit is contained in:
Peter Steinberger
2026-02-22 17:54:42 +00:00
parent 409a02691f
commit 3286791316
12 changed files with 325 additions and 318 deletions

View File

@@ -1,6 +1,6 @@
import type { OpenClawConfig, SkillConfig } from "../../config/config.js";
import {
evaluateRuntimeRequires,
evaluateRuntimeEligibility,
hasBinary,
isConfigPathTruthyWithDefaults,
resolveConfigPath,
@@ -76,8 +76,6 @@ export function shouldIncludeSkill(params: {
const skillKey = resolveSkillKey(entry.skill, entry);
const skillConfig = resolveSkillConfig(config, skillKey);
const allowBundled = normalizeAllowlist(config?.skills?.allowBundled);
const osList = entry.metadata?.os ?? [];
const remotePlatforms = eligibility?.remote?.platforms ?? [];
if (skillConfig?.enabled === false) {
return false;
@@ -85,18 +83,10 @@ export function shouldIncludeSkill(params: {
if (!isBundledSkillAllowed(entry, allowBundled)) {
return false;
}
if (
osList.length > 0 &&
!osList.includes(resolveRuntimePlatform()) &&
!remotePlatforms.some((platform) => osList.includes(platform))
) {
return false;
}
if (entry.metadata?.always === true) {
return true;
}
return evaluateRuntimeRequires({
return evaluateRuntimeEligibility({
os: entry.metadata?.os,
remotePlatforms: eligibility?.remote?.platforms,
always: entry.metadata?.always,
requires: entry.metadata?.requires,
hasBin: hasBinary,
hasRemoteBin: eligibility?.remote?.hasBin,