mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 17:51:24 +00:00
refactor(shared): share entry requirements evaluation
This commit is contained in:
committed by
Shadow
parent
a5b87338e5
commit
137079fc21
@@ -1,7 +1,6 @@
|
||||
import path from "node:path";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resolveEmojiAndHomepage } from "../shared/entry-metadata.js";
|
||||
import { evaluateRequirementsFromMetadataWithRemote } from "../shared/requirements.js";
|
||||
import { evaluateEntryMetadataRequirements } from "../shared/entry-status.js";
|
||||
import { CONFIG_DIR } from "../utils.js";
|
||||
import {
|
||||
hasBinary,
|
||||
@@ -184,34 +183,27 @@ function buildSkillStatus(
|
||||
const allowBundled = resolveBundledAllowlist(config);
|
||||
const blockedByAllowlist = !isBundledSkillAllowed(entry, allowBundled);
|
||||
const always = entry.metadata?.always === true;
|
||||
const { emoji, homepage } = resolveEmojiAndHomepage({
|
||||
metadata: entry.metadata,
|
||||
frontmatter: entry.frontmatter,
|
||||
});
|
||||
const bundled =
|
||||
bundledNames && bundledNames.size > 0
|
||||
? bundledNames.has(entry.skill.name)
|
||||
: entry.skill.source === "openclaw-bundled";
|
||||
|
||||
const {
|
||||
required,
|
||||
missing,
|
||||
eligible: requirementsSatisfied,
|
||||
configChecks,
|
||||
} = evaluateRequirementsFromMetadataWithRemote({
|
||||
always,
|
||||
metadata: entry.metadata,
|
||||
hasLocalBin: hasBinary,
|
||||
localPlatform: process.platform,
|
||||
remote: eligibility?.remote,
|
||||
isEnvSatisfied: (envName) =>
|
||||
Boolean(
|
||||
process.env[envName] ||
|
||||
skillConfig?.env?.[envName] ||
|
||||
(skillConfig?.apiKey && entry.metadata?.primaryEnv === envName),
|
||||
),
|
||||
isConfigSatisfied: (pathStr) => isConfigPathTruthy(config, pathStr),
|
||||
});
|
||||
const { emoji, homepage, required, missing, requirementsSatisfied, configChecks } =
|
||||
evaluateEntryMetadataRequirements({
|
||||
always,
|
||||
metadata: entry.metadata,
|
||||
frontmatter: entry.frontmatter,
|
||||
hasLocalBin: hasBinary,
|
||||
localPlatform: process.platform,
|
||||
remote: eligibility?.remote,
|
||||
isEnvSatisfied: (envName) =>
|
||||
Boolean(
|
||||
process.env[envName] ||
|
||||
skillConfig?.env?.[envName] ||
|
||||
(skillConfig?.apiKey && entry.metadata?.primaryEnv === envName),
|
||||
),
|
||||
isConfigSatisfied: (pathStr) => isConfigPathTruthy(config, pathStr),
|
||||
});
|
||||
const eligible = !disabled && !blockedByAllowlist && requirementsSatisfied;
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user