openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 6.69 kB
JavaScript
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{C as t,O as n,S as r,c as i,f as a,g as o,p as s,y as c}from"./config-runtime-CgOgfOrG.js";var l,u;function d(){return(d=e((()=>{o(),l=i([`inspect`,`install`,`verify`]),u=t({action:l,target:t({kind:c(`local-host`),platform:i([`darwin`,`linux`,`win32`]),hostname:n().min(1).max(255),profile:n().regex(/^[a-z0-9][a-z0-9-]{0,63}$/),relayPort:r().int().min(1).max(65535)}),phase:i([`inspection_required`,`preparing`,`needs_browser_action`,`waiting_for_connection`,`ready`,`blocked`]),reason:n().regex(/^[a-z][a-z0-9_]{0,79}$/),installation:t({nativeHostRegistered:s(),installRequested:s(),installedProfiles:r().int().nonnegative(),discoveredProfiles:r().int().nonnegative(),awaitingApproval:s(),automaticBootstrapSupported:s()}),connection:t({state:i([`not_checked`,`unavailable`,`waiting_for_extension`,`connected`]),extensionVersion:n().max(128).optional()}),nextAction:i([`none`,`install`,`open_chrome`,`approve_extension`,`install_from_store`,`check_connection`,`repair_native_host`,`unsupported`])})})))()}function f(){if(typeof window>`u`)return null;let e=window,t=e.webkit?.messageHandlers?.openclawDeviceSettings;if(typeof t?.postMessage!=`function`)return null;let n=t.postMessage,r=n.bind(t),i=h.safeParse(e.__OPENCLAW_NATIVE_DEVICE_SETTINGS__),a=i.success?i.data:null,o=!1,s=()=>!o&&e.webkit?.messageHandlers?.openclawDeviceSettings===t&&t.postMessage===n,c=new Set,d=e=>a?.revision!==void 0&&(e.revision===void 0||e.revision<=a.revision)?!1:(a=e,!0),f=e=>{if(!(e instanceof CustomEvent))return;let t=h.safeParse(e.detail);t.success&&d(t.data)&&c.forEach(e=>e(t.data))},p=async(e,t)=>{try{let t=await r(e);if(o)return;if(e.type===`set`){let e=h.safeParse(t);if(!e.success)throw Error(`Native settings returned an invalid edit result`);d(e.data)}}catch(e){console.warn(`Native device settings request failed`,e)}if(!o&&e.type===`set`){t?.();let e=a;e&&c.forEach(t=>t(e))}},m=()=>void p({type:`status`});window.addEventListener(v,f),window.addEventListener(`focus`,m),m();let y=async e=>{if(!s()||a?.device.platform!==`macos`)throw Error(`Native device settings is unavailable`);let t=await r({type:e}),n=(e===`chrome-extension-status`?_:g).safeParse(t);if(!s()||a?.device.platform!==`macos`||!n.success)throw Error(`Native Chrome setup returned an invalid result`);return n.data};return{get snapshot(){return a},subscribe(e){return c.add(e),()=>c.delete(e)},set:(e,t,n)=>void p({type:`set`,key:e,value:t},n),requestPermission:e=>void p({type:`request-permission`,id:e}),openSystemSettings:e=>void p({type:`open-system-settings`,id:e}),openPanel:e=>void p({type:`open`,panel:e}),checkForUpdates:()=>void p({type:`check-for-updates`}),async setupChromeExtension(e){if(!s())throw Error(`Native device settings is unavailable`);if(!a?.browser?.chromeSetupActions?.includes(e))throw Error(`This native host does not advertise that Chrome setup action`);let t=a.device.platform,n={macos:`darwin`,linux:`linux`,windows:`win32`,ios:null}[t];if(!n)throw Error(`Native Chrome setup is unavailable on this device`);let i=l.parse(e),o=await r({type:`chrome-extension-setup`,action:i}),c=u.safeParse(o);if(!s()||!a?.browser?.chromeSetupActions?.includes(e)||!c.success||c.data.action!==e||a.device.platform!==t||c.data.target.platform!==n)throw Error(`Native Chrome setup returned an invalid result`);return c.data},installChromeExtension:()=>y(`install-chrome-extension`),chromeExtensionStatus:()=>y(`chrome-extension-status`),refresh:m,dispose(){o=!0,window.removeEventListener(v,f),window.removeEventListener(`focus`,m),c.clear()}}}var p,m,h,g,_,v;function y(){return(y=e((()=>{o(),d(),p=i([`notifications`,`accessibility`,`screenRecording`,`microphone`,`camera`,`speechRecognition`,`location`,`contacts`,`calendars`,`reminders`,`photos`]),m=a(t({id:n(),name:n()})),h=t({contract:c(1),revision:r().int().nonnegative().optional(),device:t({platform:i([`macos`,`ios`,`linux`,`windows`]),formFactor:i([`phone`,`pad`,`desktop`]).optional(),modelName:n().optional(),appVersion:n(),appBuild:n(),profileName:n().nullable()}),app:t({appearance:i([`system`,`light`,`dark`]).optional(),notificationsEnabled:s().optional(),showDockIcon:s().optional(),nativeExperienceEnabled:s().optional(),iconStyle:t({selectedId:n(),available:m}).optional(),iconAnimationsEnabled:s().optional(),launchAtLogin:s().optional(),launchAtLoginAvailable:s().optional(),quickChatEnabled:s().optional(),quickChatShortcut:n().nullable().optional(),debugPaneEnabled:s().optional()}).optional(),capabilities:t({canvasEnabled:s().optional(),cameraEnabled:s().optional(),keepAwakeEnabled:s().optional(),healthSummaryAvailable:s().optional(),healthSummaryEnabled:s().optional(),computerControlEnabled:s().optional(),desktopSharingEnabled:s().optional(),computerControlProvider:i([`peekaboo`,`cua`]).optional(),cuaDriverBundled:s().optional(),peekabooBridgeEnabled:s().optional(),activeComputerPresenceEnabled:s().optional(),unattendedDesktopEnabled:s().optional()}).optional(),desktopAvailability:t({state:i([`locked`,`unlocked`,`unknown`])}).optional(),desktopSharing:t({state:i([`off`,`starting`,`running`,`error`]),detail:n().optional()}).optional(),browser:t({chromeSetupActions:a(l).optional(),importAvailable:s().optional(),cookieSync:t({available:s(),enabled:s(),domains:a(n()),targetProfile:n(),state:i([`off`,`idle`,`running`,`error`]),detail:n().nullable()}).optional()}).optional(),permissions:t({entries:a(t({id:p.or(c(`automation`)),status:i([`granted`,`denied`,`notDetermined`,`unavailable`,`limited`])})).refine(e=>new Set(e.map(e=>e.id)).size===e.length).transform(e=>e.flatMap(({id:e,status:t})=>e===`automation`?[]:[{id:e,status:t}])),location:t({mode:i([`off`,`whileUsing`,`always`]),precise:s(),preciseEditable:s().optional()}).optional()}),voice:t({supported:s(),wakeEnabled:s(),wakeTriggersTalkMode:s().optional(),pushToTalkEnabled:s().optional(),talkPhaseSoundsEnabled:s().optional(),talkShiftToStopEnabled:s().optional(),realtimeRelayEnabled:s().optional(),triggerChime:s().optional(),sendChime:s().optional(),talkEnabled:s().optional(),talkButtonEnabled:s().optional(),talkBackgroundEnabled:s().optional(),speakerphoneEnabled:s().optional(),microphone:t({selectedId:n().nullable(),devices:m}).optional(),locale:t({primary:n(),additional:a(n()),available:m}).optional()}),updates:t({available:s(),automatic:s(),unavailableReason:n().nullable()}).optional()}),g=t({nativeHostRegistered:s(),installRequested:s(),installedProfiles:r().int().nonnegative().optional(),discoveredProfiles:r().int().nonnegative()}),_=g.required({installedProfiles:!0}),v=`openclaw:native-device-settings-changed`})))()}y();export{f as createNativeDeviceSettingsCapability};