openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.22 kB
JavaScript
import{i as asOptionalObjectRecord}from"./record-coerce-BTbqdJ3-.mjs";import{n as normalizeAccountId}from"./account-id-3yqrEsRn.mjs";import{r as resolveChannelAccountEntry}from"./account-lookup-DXbrh7Os.mjs";import{a as maxBytesForKind}from"./constants-cCp4CBUF.mjs";import{r as STAGED_INPUT_MAX_BYTES}from"./staged-inputs-CPADsu98.mjs";import{t as MEDIA_MAX_BYTES}from"./store-wPqhY4JR.mjs";import{n as resolveChatAttachmentMaxBytes}from"./chat-attachment-policy-Dy6xYpfv.mjs";
//!src/media/configured-max-bytes.ts
const MB=1048576;const WEBCHAT_LOCAL_MEDIA_MAX_BYTES=4096*MB;const TELEGRAM_DEFAULT_MEDIA_MAX_MB=100;const GENERATED_IMAGE_DOWNLOAD_MAX_BYTES=64*MB;function resolveGeneratedMediaMaxBytes(e,t){const n=e?.agents?.defaults?.mediaMaxMb;return typeof n===`number`&&Number.isFinite(n)&&n>0?Math.floor(n*MB):maxBytesForKind(t)}function resolveGeneratedImageDownloadMaxBytes(e){return Math.max(resolveGeneratedMediaMaxBytes(e,`image`),GENERATED_IMAGE_DOWNLOAD_MAX_BYTES)}function resolveChannelAccountMediaMaxMb(e){const t=e.channel?.trim();const n=e.accountId?.trim();const r=t?e.cfg.channels?.[t]:void 0;const i=asOptionalObjectRecord(r);const a=typeof i?.mediaMaxMb===`number`?i.mediaMaxMb:void 0;const o=asOptionalObjectRecord(i?.accounts);const s=(n&&t?asOptionalObjectRecord(resolveChannelAccountEntry(o,n,t,normalizeAccountId)):void 0)?.mediaMaxMb;return(typeof s===`number`?s:void 0)??a}function resolveStagedInputMaxBytes(e,t,n){const r=resolveChannelAccountMediaMaxMb({cfg:e,channel:t,accountId:n});const i=typeof r===`number`&&Number.isFinite(r)&&r>0?Math.floor(r*1024*1024):0;return Math.min(Number.MAX_SAFE_INTEGER,Math.max(STAGED_INPUT_MAX_BYTES,resolveChatAttachmentMaxBytes(e),i))}function resolveOutboundMediaMaxBytes(e){const t=resolveChannelAccountMediaMaxMb(e)??e.cfg.agents?.defaults?.mediaMaxMb??(e.channel?.trim().toLowerCase()===`telegram`?TELEGRAM_DEFAULT_MEDIA_MAX_MB:void 0);return typeof t===`number`&&Number.isFinite(t)&&t>0?Math.floor(t*MB):MEDIA_MAX_BYTES}export{resolveOutboundMediaMaxBytes as a,resolveGeneratedMediaMaxBytes as i,resolveChannelAccountMediaMaxMb as n,resolveStagedInputMaxBytes as o,resolveGeneratedImageDownloadMaxBytes as r,WEBCHAT_LOCAL_MEDIA_MAX_BYTES as t};