mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
* refactor: extract media and acp core packages * refactor: remove relocated media and acp sources * build: wire new core packages into dependency checks * test: alias new core packages in vitest * build: keep media sniffer runtime dependency * docs: refresh plugin sdk api baseline * fix: keep normalized proposal queries non-empty * test: keep channel timer tests isolated * fix: keep rebased plugin checks green * fix: preserve sms numeric allowlist entries * test: harden exec foreground timeout failure * test: remove duplicate skill workshop assertion * fix: remove channel config lint suppression * test: refresh lint suppression allowlist
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
export const MAX_IMAGE_BYTES = 6 * 1024 * 1024; // 6MB
|
|
export const MAX_AUDIO_BYTES = 16 * 1024 * 1024; // 16MB
|
|
export const MAX_VIDEO_BYTES = 16 * 1024 * 1024; // 16MB
|
|
export const MAX_DOCUMENT_BYTES = 100 * 1024 * 1024; // 100MB
|
|
|
|
export type MediaKind = "image" | "audio" | "video" | "document";
|
|
|
|
export function mediaKindFromMime(mime?: string | null): MediaKind | undefined {
|
|
if (!mime) {
|
|
return undefined;
|
|
}
|
|
if (mime.startsWith("image/")) {
|
|
return "image";
|
|
}
|
|
if (mime.startsWith("audio/")) {
|
|
return "audio";
|
|
}
|
|
if (mime.startsWith("video/")) {
|
|
return "video";
|
|
}
|
|
if (mime === "application/pdf") {
|
|
return "document";
|
|
}
|
|
if (mime.startsWith("text/")) {
|
|
return "document";
|
|
}
|
|
if (mime.startsWith("application/")) {
|
|
return "document";
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
export function maxBytesForKind(kind: MediaKind): number {
|
|
switch (kind) {
|
|
case "image":
|
|
return MAX_IMAGE_BYTES;
|
|
case "audio":
|
|
return MAX_AUDIO_BYTES;
|
|
case "video":
|
|
return MAX_VIDEO_BYTES;
|
|
case "document":
|
|
return MAX_DOCUMENT_BYTES;
|
|
default:
|
|
return MAX_DOCUMENT_BYTES;
|
|
}
|
|
}
|