mirror of https://github.com/openclaw/openclaw.git
21 lines
511 B
TypeScript
21 lines
511 B
TypeScript
/** 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;
|
|
}
|
|
if (typeof raw === "string") {
|
|
const trimmed = raw.trim().toLowerCase();
|
|
if (trimmed === "true") {
|
|
return true;
|
|
}
|
|
if (trimmed === "false") {
|
|
return false;
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|