openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.96 kB
JavaScript
import{_t as e}from"./openclaw-state-read-subsystem-Dwoo5bcz.mjs";import{o as t}from"./openclaw-state-read-openclaw-state-db-schema-helpers-QFZd8aJI.mjs";import{a as n}from"./openclaw-state-read-sqlite-transaction-Bt-IwVhZ.mjs";import{i as r,r as i,t as a}from"./openclaw-state-read-user-preferences.store-Bfv_XrVt.mjs";import{o}from"./openclaw-state-read-user-profiles-internal-RPWRWaaD.mjs";import"node:crypto";import"node:util";function isBackgroundAssetId(e){return typeof e==`string`&&/^[A-Za-z0-9_-]{1,128}$/.test(e)}function normalizeBackgroundPreference(t){let n=e(t),r=e(n?.source);if(!n||!r)return;let i;if(r.kind===`none`||r.kind===`theme`)i={kind:r.kind};else if(r.kind===`custom`&&isBackgroundAssetId(r.assetId))i={kind:`custom`,assetId:r.assetId};else return;let{presentation:a,showOnNewSession:o,showInSessions:s,visibility:c}=n;if(!(Object.hasOwn(n,`presentation`)&&a!==`faded`&&a!==`full-bleed`||typeof o!=`boolean`||typeof s!=`boolean`||typeof c!=`number`||!Number.isFinite(c)||c<0||c>1))return{source:i,...a===`faded`||a===`full-bleed`?{presentation:a}:{},showOnNewSession:o,showInSessions:s,visibility:c}}const s=`ui.background`;function readSnapshot(e,n){let r=i(e,n),o=t(e,`user_preferences`)?a(e,n,[s])[s]:void 0;return{status:`ok`,asset:r?{assetId:r.asset_id,width:r.width,height:r.height,mime:`image/jpeg`,byteLength:r.byte_length}:null,preference:normalizeBackgroundPreference(o)??null}}function resolveProfile(e,n){return t(e,`user_profiles`)?o(e,n)?.id:void 0}function readUserBackgroundCommand(e,t){return n(e,()=>{let n=resolveProfile(e,t.profileId);if(t.type===`userBackground.snapshot`)return{type:t.type,result:n?readSnapshot(e,n):{status:`no_durable_identity`}};if(!t.includeBytes){let r=n?i(e,n):void 0;return{type:t.type,image:void 0,byteLength:r?.asset_id===t.assetId?r.byte_length:void 0}}let a=n?r(e,n,t.assetId):void 0;return{type:t.type,image:a?.image,byteLength:a?.image.byteLength}})}export{readUserBackgroundCommand};