openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
66 lines (65 loc) • 2.34 kB
JavaScript
import { o as normalizeLowercaseStringOrEmpty } from "./string-coerce-CCIiB4H7.mjs";
import { P as resolveIntegerOption } from "./number-coercion-D6u-4YD8.mjs";
//#region packages/memory-host-sdk/src/host/multimodal.ts
const MEMORY_MULTIMODAL_SPECS = {
image: {
labelPrefix: "Image file",
extensions: [
".jpg",
".jpeg",
".png",
".webp",
".gif",
".heic",
".heif"
]
},
audio: {
labelPrefix: "Audio file",
extensions: [
".mp3",
".wav",
".ogg",
".opus",
".m4a",
".m2a",
".aac",
".flac"
]
}
};
/** All supported multimodal memory modalities in stable config order. */
const MEMORY_MULTIMODAL_MODALITIES = Object.keys(MEMORY_MULTIMODAL_SPECS);
/** Default max bytes for one multimodal memory file. */
const DEFAULT_MEMORY_MULTIMODAL_MAX_FILE_BYTES = 10485760;
/** Normalize user modality selections to supported modalities. */
function normalizeMemoryMultimodalModalities(e) {
if (e === void 0 || e.includes("all")) return [...MEMORY_MULTIMODAL_MODALITIES];
return [...new Set(e.filter((e) => e === "image" || e === "audio"))];
}
/** Normalize user multimodal settings, including disabled-state empty modality list. */
function normalizeMemoryMultimodalSettings(e) {
const t = e.enabled === true;
const n = resolveIntegerOption(e.maxFileBytes, DEFAULT_MEMORY_MULTIMODAL_MAX_FILE_BYTES, { min: 1 });
return {
enabled: t,
modalities: t ? normalizeMemoryMultimodalModalities(e.modalities) : [],
maxFileBytes: n
};
}
/** Return true when multimodal memory ingestion has at least one enabled modality. */
function isMemoryMultimodalEnabled(e) {
return e.enabled && e.modalities.length > 0;
}
/** Build the text label that accompanies embedded multimodal file content. */
function buildMemoryMultimodalLabel(e, t) {
return `${MEMORY_MULTIMODAL_SPECS[e].labelPrefix}: ${t}`;
}
/** Classify a file path into a supported multimodal modality under current settings. */
function classifyMemoryMultimodalPath(e, t) {
if (!isMemoryMultimodalEnabled(t)) return null;
const n = normalizeLowercaseStringOrEmpty(e);
return t.modalities.find((e) => MEMORY_MULTIMODAL_SPECS[e].extensions.some((e) => n.endsWith(e))) ?? null;
}
//#endregion
export { normalizeMemoryMultimodalSettings as i, classifyMemoryMultimodalPath as n, isMemoryMultimodalEnabled as r, buildMemoryMultimodalLabel as t };