openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.6 kB
JavaScript
import{r as asNullableRecord}from"./record-coerce-BTbqdJ3-.mjs";
//!packages/gateway-protocol/src/schema/background-preferences.ts
const USER_BACKGROUND_MAX_INPUT_BYTES=8388608;const USER_BACKGROUND_MAX_OUTPUT_BYTES=2097152;const USER_BACKGROUND_PREFERENCE_KEY=`ui.background`;const BACKGROUND_VISIBILITY_MIN=0;const BACKGROUND_VISIBILITY_MAX=1;const DEFAULT_BACKGROUND_PREFERENCE={source:{kind:`theme`},showOnNewSession:true,showInSessions:true,visibility:.5};function isBackgroundAssetId(e){return typeof e===`string`&&/^[A-Za-z0-9_-]{1,128}$/.test(e)}function normalizeBackgroundPreference(e){const t=asNullableRecord(e);const n=asNullableRecord(t?.source);if(!t||!n)return;let r;if(n.kind===`none`||n.kind===`theme`)r={kind:n.kind};else if(n.kind===`custom`&&isBackgroundAssetId(n.assetId))r={kind:`custom`,assetId:n.assetId};else return;const{presentation:i,showOnNewSession:a,showInSessions:o,visibility:s}=t;if(Object.hasOwn(t,`presentation`)&&i!==`faded`&&i!==`full-bleed`||typeof a!==`boolean`||typeof o!==`boolean`||typeof s!==`number`||!Number.isFinite(s)||s<BACKGROUND_VISIBILITY_MIN||s>BACKGROUND_VISIBILITY_MAX)return;return{source:r,...i===`faded`||i===`full-bleed`?{presentation:i}:{},showOnNewSession:a,showInSessions:o,visibility:s}}function selectBackgroundSource(e,t){return{...t??DEFAULT_BACKGROUND_PREFERENCE,...!t&&e.kind===`custom`?{showInSessions:false}:{},source:e}}export{normalizeBackgroundPreference as a,isBackgroundAssetId as i,USER_BACKGROUND_MAX_OUTPUT_BYTES as n,selectBackgroundSource as o,USER_BACKGROUND_PREFERENCE_KEY as r,USER_BACKGROUND_MAX_INPUT_BYTES as t};