mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 08:31:10 +00:00
refactor(agents): dedupe config and truncation guards
This commit is contained in:
@@ -48,14 +48,16 @@ export type RuntimeRequires = {
|
||||
config?: string[];
|
||||
};
|
||||
|
||||
export function evaluateRuntimeRequires(params: {
|
||||
type RuntimeRequirementEvalParams = {
|
||||
requires?: RuntimeRequires;
|
||||
hasBin: (bin: string) => boolean;
|
||||
hasAnyRemoteBin?: (bins: string[]) => boolean;
|
||||
hasRemoteBin?: (bin: string) => boolean;
|
||||
hasEnv: (envName: string) => boolean;
|
||||
isConfigPathTruthy: (pathStr: string) => boolean;
|
||||
}): boolean {
|
||||
};
|
||||
|
||||
export function evaluateRuntimeRequires(params: RuntimeRequirementEvalParams): boolean {
|
||||
const requires = params.requires;
|
||||
if (!requires) {
|
||||
return true;
|
||||
@@ -103,6 +105,35 @@ export function evaluateRuntimeRequires(params: {
|
||||
return true;
|
||||
}
|
||||
|
||||
export function evaluateRuntimeEligibility(
|
||||
params: {
|
||||
os?: string[];
|
||||
remotePlatforms?: string[];
|
||||
always?: boolean;
|
||||
} & RuntimeRequirementEvalParams,
|
||||
): boolean {
|
||||
const osList = params.os ?? [];
|
||||
const remotePlatforms = params.remotePlatforms ?? [];
|
||||
if (
|
||||
osList.length > 0 &&
|
||||
!osList.includes(resolveRuntimePlatform()) &&
|
||||
!remotePlatforms.some((platform) => osList.includes(platform))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (params.always === true) {
|
||||
return true;
|
||||
}
|
||||
return evaluateRuntimeRequires({
|
||||
requires: params.requires,
|
||||
hasBin: params.hasBin,
|
||||
hasRemoteBin: params.hasRemoteBin,
|
||||
hasAnyRemoteBin: params.hasAnyRemoteBin,
|
||||
hasEnv: params.hasEnv,
|
||||
isConfigPathTruthy: params.isConfigPathTruthy,
|
||||
});
|
||||
}
|
||||
|
||||
export function resolveRuntimePlatform(): string {
|
||||
return process.platform;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user