openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
28 lines • 10.3 kB
JavaScript
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Ac as t,Cu as n,Eu as r,Iu as i,Lu as a,Tu as o,du as s,hl as c,ju as l,kc as u,ml as d,pl as f,pu as p}from"./control-ui-core-BncvAZjR.js";import{Ra as m,Ti as h,wa as g,wi as _}from"./control-ui-core-9qYjK5B2.js";import{$ as v,X as y,Y as b,ct as x,nt as S}from"./lit-runtime-B8uOr6OX.js";import{gn as ee,hn as te,mn as ne}from"./control-ui-boot-shared-DJkUdZmL.js";import{Xr as re,Zr as ie,_a as C,ii as w}from"./ui-DuRgK6kL.js";import{G as T,I as E,K as D,R as O,Y as k,et as A,l as j,q as M,u as N,z as P}from"./control-ui-boot-shared-xfDhIVun.js";import{Hc as F,Uc as I}from"./control-ui-boot-shared-D3oo_6Fq.js";import{n as L,t as R}from"./settings-select-row-C4LcPBBS.js";var z,B;function V(){return(V=e((()=>{a(),z={labsPage:{decisionAssistance:{title:`Decision assistance`,description:`Enable experimental assistance from your configured Decision model. See the documentation for supported uses, setup, and data handling.`,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.`}}},B=Object.assign(()=>Object.assign(i.labsPage,z.labsPage),{catalog:z})})))()}function H(e,t){if(typeof e==`boolean`||typeof e==`string`)return t.includes(e);if(!C(e))return!1;let n=e.enabled;return typeof n==`boolean`||typeof n==`string`?t.includes(n):Object.keys(e).some(e=>e!==`enabled`)}function U(e,t){let n=e;for(let e of t){if(!C(n))return;n=n[e]}return n}function W(e,t){let n=e.configPath.at(-1);return e.readEnabled?e.readEnabled(t):n===`enabled`&&(typeof t==`boolean`||typeof t==`string`)?e.activeValues.includes(t):!C(t)||!n?!1:e.activeValues.includes(t[n])}function G(e,t){let n=t.configPath.slice(0,-1),r=t.configPath.at(-1),i=U(e,n);return r?t.resetScope===`parent`?i===void 0?null:n:r===`enabled`&&i!==void 0&&(typeof i!=`object`||!i)?n:C(i)&&Object.hasOwn(i,r)?t.configPath:null:null}function K(e,t){let n=e??{},r=t.configPath.slice(0,-1),i=t.configPath.at(-1),a=U(n,r),o=G(n,t),s=a;if(o?.length===r.length)s=void 0;else if(o&&i&&C(a)){let{[i]:e,...t}=a;s=t}return{enabled:W(t,a),defaultEnabled:W(t,s),overridden:o!==null}}function q(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 J(e,t){if(t.resetScope===null)return null;let n=G(e??{},t);if(!n?.length)return null;let r=null;for(let e of n.toReversed())r={[e]:r};return r}var Y,X;function Z(){return(Z=e((()=>{r(),V(),B(),Y={onValue:!0,offValue:!1,activeValues:[!0],readEnabled:null,enableAlso:null,resetScope:`gate`},X=[{...Y,id:`decisionAssistance`,title:()=>l(`labsPage.decisionAssistance.title`),description:()=>l(`labsPage.decisionAssistance.description`),docsUrl:`https://docs.openclaw.ai/concepts/experimental-features#decision-assistance`,configPath:[`agents`,`defaults`,`experimental`,`decisionAssistance`]},{...Y,id:`codeMode`,title:()=>l(`labsPage.codeMode.title`),description:()=>l(`labsPage.codeMode.description`),docsUrl:`https://docs.openclaw.ai/tools/code-mode`,configPath:[`tools`,`codeMode`,`enabled`],onValue:`auto`,activeValues:[!0,`auto`],readEnabled:e=>e===void 0||e===!0||e===`auto`||C(e)&&(e.enabled===!0||e.enabled===`auto`)},{...Y,id:`toolSearch`,title:()=>l(`labsPage.toolSearch.title`),description:()=>l(`labsPage.toolSearch.description`),docsUrl:`https://docs.openclaw.ai/tools/tool-search`,configPath:[`tools`,`toolSearch`,`enabled`],readEnabled:e=>e===void 0||H(e,[!0]),enableAlso:{mode:`tools`},resetScope:`parent`},{...Y,id:`customPluginUi`,title:()=>l(`labsPage.customPluginUi.title`),description:()=>l(`labsPage.customPluginUi.description`),docsUrl:`https://docs.openclaw.ai/plugins/feature-plugins`,configPath:[`gateway`,`controlUi`,`experimental`,`customPlugins`]},{...Y,id:`hostDesktop`,title:()=>l(`labsPage.hostDesktop.title`),description:()=>l(`labsPage.hostDesktop.description`),docsUrl:`https://docs.openclaw.ai/gateway/configuration-reference#desktop`,configPath:[`desktop`,`host`,`enabled`],resetScope:null},{...Y,id:`workerDesktop`,title:()=>l(`labsPage.workerDesktop.title`),description:()=>l(`labsPage.workerDesktop.description`),docsUrl:`https://docs.openclaw.ai/gateway/cloud-workers#desktop-interactive`,configPath:[`cloudWorkers`,`desktop`]}]})))()}var Q;function $(){return($=e((()=>{ie(),b(),S(),g(),h(),E(),j(),r(),d(),ee(),p(),I(),o(),t(),R(),Z(),Q=class extends n{constructor(){super(),this.busyFeatureId=null,this.pendingValues={},this.saveError=null,this.gateway=new F(this,{getGateway:()=>this.context?.gateway,invalidateRequests:()=>{this.busyFeatureId=null,this.pendingValues={},this.saveError=null}}),new u(this).effect(()=>this.context?.runtimeConfig,e=>(e.ensureLoaded(),e.subscribe(()=>this.requestUpdate())))}editableConfig(){let e=this.context?.runtimeConfig.state.configSnapshot;return c(e)}decisionPreferenceKnown(){let e=this.context?.runtimeConfig.state;return e?.connected&&!e.configLoading&&!e.lastError&&e.configSnapshot?.valid!==!1&&f(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 a=()=>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}`});a()&&!t&&(this.saveError=i.state.lastError??l(`labsPage.saveFailed`))}catch(e){a()&&(this.saveError=s(e))}finally{a()&&(this.clearPendingValue(e),this.busyFeatureId===e&&(this.busyFeatureId=null))}}setFeatureEnabled(e,t){let n=this.editableConfig(),r=t===K(n,e).defaultEnabled?J(n,e):null;this.updateSetting(e.id,t,r??q(e,t))}codeModeConfig(){let e=this.editableConfig()?.tools;return C(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,n=typeof t==`string`?t:C(e)?e.executor:null;return L({title:l(`labsPage.codeMode.executor`),description:l(`labsPage.codeMode.executorDescription`),value:n===`quickjs`?`quickjs`:`node`,options:[{value:`node`,label:l(`labsPage.codeMode.executorNode`)},{value:`quickjs`,label:l(`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:v`
${e.description()}
<br />
<span role="status"
>${n.configLoading?l(`labsPage.decisionAssistance.loading`):l(`labsPage.decisionAssistance.unavailable`)}</span
>
<button
class="btn btn--sm"
?disabled=${!n.connected||n.configLoading}
@click=${()=>void this.context.runtimeConfig.refresh()}
>
${l(`labsPage.decisionAssistance.refresh`)}
</button>
`})}let n=K(this.editableConfig(),e),r=this.pendingValues[e.id],i=this.canToggle(),a=P(n.defaultEnabled?l(`common.enabled`):l(`common.disabled`),n.overridden),o=v`
${e.description()}
${e.id===`decisionAssistance`&&n.enabled?v`<br />${l(`labsPage.decisionAssistance.optedIn`)}`:y}
<a href=${e.docsUrl} target=${ne} rel=${te()}
>${l(`labsPage.documentation`)}</a
>
${a?v`<br />${a}`:y}
`;return v`
${A({title:t,description:o,checked:typeof r==`boolean`?r:n.enabled,disabled:!i,onChange:t=>this.setFeatureEnabled(e,t)})}
${e.id===`codeMode`?this.renderCodeModeExecutor():y}
`}render(){let e=[...X.map(e=>this.renderFeature(e)),this.saveError?M({title:l(`labsPage.saveErrorTitle`),description:v`<span role="alert">${this.saveError}</span>`}):y],t=T(k({title:l(`labsPage.sectionTitle`),description:l(`labsPage.sectionDescription`)},e));return v`
${D({title:m(`labs`),subtitle:v`${l(`labsPage.intro`)}
${O(`https://docs.openclaw.ai/concepts/experimental-features`)}`})}
${N(t)}
`}},w([re({context:_,subscribe:!0})],Q.prototype,`context`,void 0),w([x()],Q.prototype,`busyFeatureId`,void 0),w([x()],Q.prototype,`pendingValues`,void 0),w([x()],Q.prototype,`saveError`,void 0),customElements.get(`openclaw-labs-page`)||customElements.define(`openclaw-labs-page`,Q)})))()}$();