UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 1.97 kB
import{t as e}from"./openclaw-state-read-record-coerce-D1s3ReAs.mjs";import{a as t}from"./openclaw-state-read-sqlite-transaction-V1rK3HH2.mjs";import{o as n}from"./openclaw-state-read-openclaw-state-db-schema-helpers-BkqUYEFY.mjs";import{i as r,r as i,t as a}from"./openclaw-state-read-user-preferences.store-CzrRAUJG.mjs";import{s as o}from"./openclaw-state-read-user-profiles-internal-D1K1kSBE.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,t){let r=i(e,t),o=n(e,`user_preferences`)?a(e,t,[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,t){return n(e,`user_profiles`)?o(e,t)?.id:void 0}function readUserBackgroundCommand(e,n){return t(e,()=>{let t=resolveProfile(e,n.profileId);if(n.type===`userBackground.snapshot`)return{type:n.type,result:t?readSnapshot(e,t):{status:`no_durable_identity`}};if(!n.includeBytes){let r=t?i(e,t):void 0;return{type:n.type,image:void 0,byteLength:r?.asset_id===n.assetId?r.byte_length:void 0}}let a=t?r(e,t,n.assetId):void 0;return{type:n.type,image:a?.image,byteLength:a?.image.byteLength}})}export{readUserBackgroundCommand};