openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
21 lines (20 loc) • 1.08 kB
JavaScript
import { t as hasNonEmptyString } from "./string-coerce-CCIiB4H7.mjs";
import { _ as resolveDeliveryQueueMediaDir } from "./paths-DAcAg5aV.mjs";
import path from "node:path";
//#region src/infra/outbound/delivery-queue-media-paths.ts
const ARTIFACT_NAME_RE = /^(?:(?:g1|c1)-)?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?:\.[A-Za-z0-9]{1,10})?(?:\.part)?$/;
function spoolRelativePath(e, t) {
const n = path.resolve(resolveDeliveryQueueMediaDir(t));
const r = path.resolve(e);
const i = path.relative(n, r);
return i && !i.includes(path.sep) && ARTIFACT_NAME_RE.test(i) ? i : null;
}
function payloadMediaSources(e) {
return [e.mediaUrl, ...e.mediaUrls ?? []].filter(hasNonEmptyString);
}
/** Absolute spool paths a queue entry still needs in order to replay. */
function collectEntrySpoolPaths(e, t) {
return e.flatMap(payloadMediaSources).filter((e) => path.isAbsolute(e) && spoolRelativePath(e, t)).map((e) => path.resolve(e));
}
//#endregion
export { spoolRelativePath as i, collectEntrySpoolPaths as n, payloadMediaSources as r, ARTIFACT_NAME_RE as t };