UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

28 lines • 10.8 kB
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Br as t,Ji as n,qr as r,zr as i}from"./control-ui-foundation-ZY_Flbbd.js";import{Gl as a,Jc as o,Yc as s,bu as c,cc as l,hu as u,lu as d,qc as ee,ql as f,sc as p,su as m,uu as h,xu as g}from"./control-ui-core-3P365fbR.js";import{Ma as _,va as v,vi as y,yi as b}from"./control-ui-core-CFW9Qtjn.js";import{$ as x,X as S,Y as te,ct as C,nt as ne}from"./lit-runtime-P5vbNq6b.js";import{bi as re,no as w,ro as T,xi as E,yi as D}from"./control-ui-boot-shared-DoKu-5Ju.js";import{At as O,Dt as k,Et as A,Ft as j,Ot as M,_t as N,bt as P,yt as F}from"./control-ui-boot-shared-CG9HtEG-.js";import{n as I,t as L}from"./settings-workspace-whxhPRxQ.js";import{n as R,t as z}from"./settings-select-row-YlQk8ZwW.js";var B,V;function H(){return(H=e((()=>{g(),B={labsPage:{decisionAssistance:{title:`Decision assistance`,description:`Enable experimental features powered by Decision models. Requires a Decision model, set globally or per agent. No features use this setting yet.`,optedIn:`Preference saved.`,loading:`Loading setting…`,unavailable:`Couldn’t load this setting. Reconnect or refresh to try again.`,refresh:`Refresh configuration`},codeMode:{title:`Code Mode`,description:`Set the global default for compact JavaScript tool workflows. On selects Auto for evaluated models; Off disables the default. Per-model Code Mode overrides are in Agent Defaults → Models (Advanced).`,executor:`Code Mode executor`,executorDescription:`Node.js is for trusted code; its VM is not a security sandbox. QuickJS runs code in an isolated WebAssembly runtime. Calls through OpenClaw tools use the same permissions. Applies to new runs; agent overrides take precedence.`,executorNode:`Node.js (default)`,executorQuickjs:`QuickJS (isolated)`},toolSearch:{title:`Tool Search for all models`,description:`Defer tool schemas and discover tools on demand. Enabled by default with structured tool calls; turning it off disables the global default.`},customPluginUi:{title:`Custom plugin UI`,description:`Let installed plugins add pages, widgets, and custom views. Their JavaScript runs with your signed-in permissions, so enable only plugins you trust. Bundled plugin views remain available. Reload this tab to clear previously loaded plugin code.`},hostDesktop:{title:`Host Desktop`,description:`Watch and control this Gateway machine from the Desktop panel through its existing VNC or Screen Sharing server.`},workerDesktop:{title:`Cloud Worker Desktop`,description:`Watch and control node-carried desktops from capable Crabbox AWS, Azure, or Hetzner profiles with desktop: true.`}}},V=Object.assign(()=>Object.assign(c.labsPage,B.labsPage),{catalog:B})})))()}function U(e,t){if(typeof e==`boolean`||typeof e==`string`)return t.includes(e);if(!n(e))return!1;let r=e.enabled;return typeof r==`boolean`||typeof r==`string`?t.includes(r):Object.keys(e).some(e=>e!==`enabled`)}function W(e,t){let r=e;for(let e of t){if(!n(r))return;r=r[e]}return r}function G(e,t){let r=e.configPath.at(-1);return e.readEnabled?e.readEnabled(t):r===`enabled`&&(typeof t==`boolean`||typeof t==`string`)?e.activeValues.includes(t):!n(t)||!r?!1:e.activeValues.includes(t[r])}function K(e,t){let r=t.configPath.slice(0,-1),i=t.configPath.at(-1),a=W(e,r);return i?t.resetScope===`parent`?a===void 0?null:r:i===`enabled`&&a!==void 0&&(typeof a!=`object`||!a)?r:n(a)&&Object.hasOwn(a,i)?t.configPath:null:null}function q(e,t){let r=e??{},i=t.configPath.slice(0,-1),a=t.configPath.at(-1),o=W(r,i),s=K(r,t),c=o;if(s?.length===i.length)c=void 0;else if(s&&a&&n(o)){let{[a]:e,...t}=o;c=t}return{enabled:G(t,o),defaultEnabled:G(t,c),overridden:s!==null}}function J(e,t){let n={[e.configPath.at(-1)]:t?e.onValue:e.offValue,...t?e.enableAlso:null};for(let t of e.configPath.slice(0,-1).toReversed())n={[t]:n};return n}function Y(e,t){if(t.resetScope===null)return null;let n=K(e??{},t);if(!n?.length)return null;let r=null;for(let e of n.toReversed())r={[e]:r};return r}var X;function Z(){return(Z=e((()=>{h(),H(),V(),X=[{id:`decisionAssistance`,title:()=>u(`labsPage.decisionAssistance.title`),description:()=>u(`labsPage.decisionAssistance.description`),docsUrl:`https://docs.openclaw.ai/concepts/experimental-features#decision-assistance`,configPath:[`agents`,`defaults`,`experimental`,`decisionAssistance`],onValue:!0,offValue:!1,activeValues:[!0],readEnabled:null,enableAlso:null,resetScope:`gate`},{id:`codeMode`,title:()=>u(`labsPage.codeMode.title`),description:()=>u(`labsPage.codeMode.description`),docsUrl:`https://docs.openclaw.ai/tools/code-mode`,configPath:[`tools`,`codeMode`,`enabled`],onValue:`auto`,offValue:!1,activeValues:[!0,`auto`],readEnabled:e=>e===void 0||e===!0||e===`auto`||n(e)&&(e.enabled===!0||e.enabled===`auto`),enableAlso:null,resetScope:`gate`},{id:`toolSearch`,title:()=>u(`labsPage.toolSearch.title`),description:()=>u(`labsPage.toolSearch.description`),docsUrl:`https://docs.openclaw.ai/tools/tool-search`,configPath:[`tools`,`toolSearch`,`enabled`],onValue:!0,offValue:!1,activeValues:[!0],readEnabled:e=>e===void 0||U(e,[!0]),enableAlso:{mode:`tools`},resetScope:`parent`},{id:`customPluginUi`,title:()=>u(`labsPage.customPluginUi.title`),description:()=>u(`labsPage.customPluginUi.description`),docsUrl:`https://docs.openclaw.ai/plugins/feature-plugins`,configPath:[`gateway`,`controlUi`,`experimental`,`customPlugins`],onValue:!0,offValue:!1,activeValues:[!0],readEnabled:null,enableAlso:null,resetScope:`gate`},{id:`hostDesktop`,title:()=>u(`labsPage.hostDesktop.title`),description:()=>u(`labsPage.hostDesktop.description`),docsUrl:`https://docs.openclaw.ai/gateway/configuration-reference#desktop`,configPath:[`desktop`,`host`,`enabled`],onValue:!0,offValue:!1,activeValues:[!0],readEnabled:null,enableAlso:null,resetScope:null},{id:`workerDesktop`,title:()=>u(`labsPage.workerDesktop.title`),description:()=>u(`labsPage.workerDesktop.description`),docsUrl:`https://docs.openclaw.ai/gateway/cloud-workers#desktop-interactive`,configPath:[`cloudWorkers`,`desktop`],onValue:!0,offValue:!1,activeValues:[!0],readEnabled:null,enableAlso:null,resetScope:`gate`}]})))()}var Q;function $(){return($=e((()=>{t(),te(),ne(),v(),b(),N(),L(),h(),o(),E(),f(),T(),d(),l(),z(),Z(),Q=class extends m{constructor(...e){super(...e),this.busyFeatureId=null,this.pendingValues={},this.saveError=null,this.gateway=new w(this,{getGateway:()=>this.context?.gateway,invalidateRequests:()=>{this.busyFeatureId=null,this.pendingValues={},this.saveError=null}}),this.subscriptions=new p(this).effect(()=>this.context?.runtimeConfig,e=>(e.ensureLoaded(),e.subscribe(()=>this.requestUpdate())))}disconnectedCallback(){this.subscriptions.clear(),super.disconnectedCallback()}editableConfig(){let e=this.context?.runtimeConfig.state.configSnapshot;return s(e)}featureEnabled(e){let t=this.pendingValues[e.id];return typeof t==`boolean`?t:q(this.editableConfig(),e).enabled}decisionPreferenceKnown(){let e=this.context?.runtimeConfig.state;return e?.connected&&!e.configLoading&&!e.lastError&&e.configSnapshot?.valid!==!1&&ee(e)!==null&&this.editableConfig()!==null}canToggle(){let e=this.context?.runtimeConfig.state;return!!(e?.connected&&e.configSnapshot?.hash&&!e.configLoading&&this.busyFeatureId===null)}clearPendingValue(e){let t={...this.pendingValues};delete t[e],this.pendingValues=t}async updateSetting(e,t,n){let r=this.gateway.capture(),i=this.context.runtimeConfig;if(!r||!this.canToggle()||e===`decisionAssistance`&&!this.decisionPreferenceKnown())return;let o=()=>this.gateway.isCurrent(r)&&this.context.runtimeConfig===i;this.busyFeatureId=e,this.pendingValues={...this.pendingValues,[e]:t},this.saveError=null;try{let t=await i.patch({raw:n,note:`labs: update ${e}`});o()&&!t&&(this.saveError=i.state.lastError??u(`labsPage.saveFailed`))}catch(e){o()&&(this.saveError=a(e))}finally{o()&&(this.clearPendingValue(e),this.busyFeatureId===e&&(this.busyFeatureId=null))}}setFeatureEnabled(e,t){let n=this.editableConfig(),r=t===q(n,e).defaultEnabled?Y(n,e):null;this.updateSetting(e.id,t,r??J(e,t))}codeModeConfig(){let e=this.editableConfig()?.tools;return n(e)?e.codeMode:void 0}setCodeModeExecutor(e){if(e!==`node`&&e!==`quickjs`)return;let t=this.codeModeConfig();this.updateSetting(`codeModeExecutor`,e,{tools:{codeMode:{...t===void 0?{enabled:`auto`}:typeof t==`boolean`||t===`auto`?{enabled:t}:{},executor:e===`node`?null:e}}})}renderCodeModeExecutor(){let e=this.codeModeConfig(),t=this.pendingValues.codeModeExecutor,r=typeof t==`string`?t:n(e)?e.executor:null;return R({title:u(`labsPage.codeMode.executor`),description:u(`labsPage.codeMode.executorDescription`),value:r===`quickjs`?`quickjs`:`node`,options:[{value:`node`,label:u(`labsPage.codeMode.executorNode`)},{value:`quickjs`,label:u(`labsPage.codeMode.executorQuickjs`)}],disabled:!this.canToggle(),onChange:e=>this.setCodeModeExecutor(e)})}renderFeature(e){let t=e.title();if(e.id===`decisionAssistance`&&!this.decisionPreferenceKnown()){let n=this.context.runtimeConfig.state;return M({title:t,description:x` ${e.description()} <br /> <span role="status" >${n.configLoading?u(`labsPage.decisionAssistance.loading`):u(`labsPage.decisionAssistance.unavailable`)}</span > <button class="btn btn--sm" ?disabled=${!n.connected||n.configLoading} @click=${()=>void this.context.runtimeConfig.refresh()} > ${u(`labsPage.decisionAssistance.refresh`)} </button> `})}let n=q(this.editableConfig(),e),r=this.canToggle(),i=P(n.defaultEnabled?u(`common.enabled`):u(`common.disabled`),n.overridden),a=x` ${e.description()} ${e.id===`decisionAssistance`&&n.enabled?x`<br />${u(`labsPage.decisionAssistance.optedIn`)}`:S} <a href=${e.docsUrl} target=${D} rel=${re()} >${u(`labsPage.documentation`)}</a > ${i?x`<br />${i}`:S} `;return x` ${j({title:t,description:a,checked:this.featureEnabled(e),disabled:!r,onChange:t=>this.setFeatureEnabled(e,t)})} ${e.id===`codeMode`?this.renderCodeModeExecutor():S} `}render(){let e=[...X.map(e=>this.renderFeature(e)),this.saveError?M({title:u(`labsPage.saveErrorTitle`),description:x`<span role="alert">${this.saveError}</span>`}):S],t=A(O({title:u(`labsPage.sectionTitle`),description:u(`labsPage.sectionDescription`)},e));return x` ${k({title:_(`labs`),subtitle:x`${u(`labsPage.intro`)} ${F(`https://docs.openclaw.ai/concepts/experimental-features`)}`})} ${I(t)} `}},r([i({context:y,subscribe:!0})],Q.prototype,`context`,void 0),r([C()],Q.prototype,`busyFeatureId`,void 0),r([C()],Q.prototype,`pendingValues`,void 0),r([C()],Q.prototype,`saveError`,void 0),customElements.get(`openclaw-labs-page`)||customElements.define(`openclaw-labs-page`,Q)})))()}$();