mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-13 02:01:16 +00:00
21 lines
562 B
TypeScript
21 lines
562 B
TypeScript
import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js";
|
|
|
|
/** Read loose boolean params from tool input that may arrive as booleans or "true"/"false" strings. */
|
|
export function readBooleanParam(
|
|
params: Record<string, unknown>,
|
|
key: string,
|
|
): boolean | undefined {
|
|
const raw = params[key];
|
|
if (typeof raw === "boolean") {
|
|
return raw;
|
|
}
|
|
const normalized = normalizeOptionalLowercaseString(raw);
|
|
if (normalized === "true") {
|
|
return true;
|
|
}
|
|
if (normalized === "false") {
|
|
return false;
|
|
}
|
|
return undefined;
|
|
}
|