openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
29 lines (28 loc) • 1.18 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { m as asSafeIntegerInRange, s as asFiniteNumber } from "./number-coercion-D6u-4YD8.mjs";
//#region packages/acp-core/src/meta.ts
function readMetaValue(e, t, n) {
if (!e) return;
for (const r of t) {
const t = n(e[r]);
if (t !== void 0) return t;
}
}
/** Reads the first present string metadata value from a current-to-legacy key list. */
function readMetadataString(e, t) {
return readMetaValue(e, t, normalizeOptionalString);
}
/** Reads the first boolean metadata value without dropping false. */
function readBool(e, t) {
return readMetaValue(e, t, (e) => typeof e === "boolean" ? e : void 0);
}
/** Reads the first finite numeric metadata value from a current-to-legacy key list. */
function readMetadataNumber(e, t) {
return readMetaValue(e, t, asFiniteNumber);
}
/** Reads the first safe non-negative integer metadata value, preserving zero. */
function readNonNegativeInteger(e, t) {
return readMetaValue(e, t, (e) => asSafeIntegerInRange(e, { min: 0 }));
}
//#endregion
export { readNonNegativeInteger as i, readMetadataNumber as n, readMetadataString as r, readBool as t };