openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
39 lines (38 loc) • 1.68 kB
JavaScript
import { n as resolvePreferredOpenClawTmpDir } from "./tmp-openclaw-dir-Bf0oU1Cn.mjs";
import { l as inspectTarArchive, n as ArchiveLimitError, t as ARCHIVE_LIMIT_ERROR_CODE } from "./archive-xLn9WKtS.mjs";
import { n as withTempWorkspace } from "./fs-safe-compat-Cbx7s6au.mjs";
import "./archive-CjZHeh-7.mjs";
import "./temp-path-CW7QMeae.mjs";
//#region extensions/file-transfer/src/shared/dir-fetch-limits.ts
const DIR_FETCH_DEFAULT_MAX_BYTES = 8388608;
const DIR_FETCH_HARD_MAX_BYTES = 16777216;
const DIR_FETCH_MAX_ENTRIES = 5e3;
const DIR_FETCH_ARCHIVE_LIMITS = {
maxArchiveBytes: DIR_FETCH_HARD_MAX_BYTES,
maxEntries: 5001,
maxExtractedBytes: 67108864,
maxEntryBytes: 16777216
};
//#endregion
//#region extensions/file-transfer/src/shared/dir-fetch-archive.ts
const DIR_FETCH_ARCHIVE_POLICY = {
limits: DIR_FETCH_ARCHIVE_LIMITS,
entryFilter: ({ kind: e }) => e === "file" || e === "directory" ? "extract" : "skip",
onFiltered: "reject-archive"
};
async function inspectDirFetchArchive(e, t) {
if (e.byteLength > DIR_FETCH_ARCHIVE_LIMITS.maxArchiveBytes) throw new ArchiveLimitError(ARCHIVE_LIMIT_ERROR_CODE.ARCHIVE_SIZE_EXCEEDS_LIMIT);
return await withTempWorkspace({
rootDir: resolvePreferredOpenClawTmpDir(),
prefix: "openclaw-dir-fetch-"
}, async (n) => {
const r = await n.write("archive.tar.gz", e);
return (await inspectTarArchive({
archivePath: r,
timeoutMs: t,
...DIR_FETCH_ARCHIVE_POLICY
})).map((e) => e.path).toSorted((e, t) => e.localeCompare(t));
});
}
//#endregion
export { DIR_FETCH_MAX_ENTRIES as a, DIR_FETCH_HARD_MAX_BYTES as i, inspectDirFetchArchive as n, DIR_FETCH_DEFAULT_MAX_BYTES as r, DIR_FETCH_ARCHIVE_POLICY as t };