UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

28 lines • 9.48 kB
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Gu as t,Ic as n,Lc as r,Nu as i,Pu as a,Sl as o,Wu as s,bl as c,ju as l,xl as u,xu as ee,yu as d,zu as f}from"./control-ui-core-CBJ5efDh.js";import{Aa as te,Ai as p,Ba as m,ki as h}from"./control-ui-core-DtLivg_r.js";import{G as g,J as _,W as v,Z as y,rt as b}from"./lit-runtime-IOnANfcZ.js";import{At as x,jt as S,kt as C}from"./control-ui-boot-shared-UG5ko-VG.js";import{Ur as ne,Wr as re,Zr as w,wa as T}from"./ui-CmSP4d14.js";import{G as E,I as D,K as O,R as k,Y as A,et as j,l as M,q as N,u as P,z as F}from"./control-ui-boot-shared-XreXSF7h.js";import{Ml as I,Nl as L}from"./control-ui-boot-shared-dOnP4mAA.js";import{n as R,t as z}from"./settings-select-row-D5tjxm-Z.js";var B,V;function H(){return(H=e((()=>{t(),B={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.`}}},V=Object.assign(()=>Object.assign(s.labsPage,B.labsPage),{catalog:B})})))()}function U(e,t){let n=e;for(let e of t){if(!T(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):!T(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:T(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&&T(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((()=>{a(),H(),V(),Y={onValue:!0,offValue:!1,activeValues:[!0],readEnabled:null,enableAlso:null,resetScope:`gate`},X=[{...Y,id:`decisionAssistance`,docsUrl:`https://docs.openclaw.ai/concepts/experimental-features#decision-assistance`,configPath:[`agents`,`defaults`,`experimental`,`decisionAssistance`]},{...Y,id:`codeMode`,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`||T(e)&&(e.enabled===!0||e.enabled===`auto`)},{...Y,id:`toolSearch`,docsUrl:`https://docs.openclaw.ai/tools/tool-search`,configPath:[`tools`,`toolSearch`,`enabled`],readEnabled:e=>e===void 0||e===!0||T(e)&&(typeof e.enabled==`boolean`||typeof e.enabled==`string`?e.enabled===!0:Object.keys(e).some(e=>e!==`enabled`)),enableAlso:{mode:`tools`},resetScope:`parent`},{...Y,id:`customPluginUi`,docsUrl:`https://docs.openclaw.ai/plugins/feature-plugins`,configPath:[`gateway`,`controlUi`,`experimental`,`customPlugins`]},{...Y,id:`hostDesktop`,docsUrl:`https://docs.openclaw.ai/gateway/configuration-reference#desktop`,configPath:[`desktop`,`host`,`enabled`],resetScope:null},{...Y,id:`workerDesktop`,docsUrl:`https://docs.openclaw.ai/gateway/cloud-workers#desktop-interactive`,configPath:[`cloudWorkers`,`desktop`]}].map(e=>Object.assign({},e,{title:()=>f(`labsPage.${e.id}.title`),description:()=>f(`labsPage.${e.id}.description`)}))})))()}var Q;function $(){return($=e((()=>{re(),v(),y(),te(),p(),D(),M(),a(),u(),S(),ee(),L(),i(),r(),z(),Z(),Q=class extends l{constructor(){super(),this.pending=null,this.saveError=null,this.gateway=new I(this,{getGateway:()=>this.context?.gateway,invalidateRequests:()=>{this.pending=null,this.saveError=null}}),new n(this).effect(()=>this.context?.runtimeConfig,e=>(e.ensureLoaded(),e.subscribe(()=>this.requestUpdate())))}editableConfig(){let e=this.context?.runtimeConfig.state.configSnapshot;return o(e)}decisionPreferenceKnown(){let e=this.context?.runtimeConfig.state;return e?.connected&&!e.configLoading&&!e.lastError&&e.configSnapshot?.valid!==!1&&c(e)!==null&&this.editableConfig()!==null}canToggle(){let e=this.context?.runtimeConfig.state;return!!(e?.connected&&e.configSnapshot?.hash&&!e.configLoading&&this.pending===null)}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.pending={featureId:e,value:t},this.saveError=null;try{let t=await i.patch({raw:n,note:`labs: update ${e}`});a()&&!t&&(this.saveError=i.state.lastError??f(`labsPage.saveFailed`))}catch(e){a()&&(this.saveError=d(e))}finally{a()&&(this.pending=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 T(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.pending?.featureId===`codeModeExecutor`?this.pending.value:void 0,n=typeof t==`string`?t:T(e)?e.executor:null;return R({title:f(`labsPage.codeMode.executor`),description:f(`labsPage.codeMode.executorDescription`),value:n===`quickjs`?`quickjs`:`node`,options:[{value:`node`,label:f(`labsPage.codeMode.executorNode`)},{value:`quickjs`,label:f(`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 N({title:t,description:_` ${e.description()} <br /> <span role="status" >${n.configLoading?f(`labsPage.decisionAssistance.loading`):f(`labsPage.decisionAssistance.unavailable`)}</span > <button class="btn btn--sm" ?disabled=${!n.connected||n.configLoading} @click=${()=>void this.context.runtimeConfig.refresh()} > ${f(`labsPage.decisionAssistance.refresh`)} </button> `})}let n=K(this.editableConfig(),e),r=this.pending?.featureId===e.id?this.pending.value:void 0,i=this.canToggle(),a=F(n.defaultEnabled?f(`common.enabled`):f(`common.disabled`),n.overridden),o=_` ${e.description()} ${e.id===`decisionAssistance`&&n.enabled?_`<br />${f(`labsPage.decisionAssistance.optedIn`)}`:g} <a href=${e.docsUrl} target=${C} rel=${x()} >${f(`labsPage.documentation`)}</a > ${a?_`<br />${a}`:g} `;return _` ${j({title:t,description:o,checked:typeof r==`boolean`?r:n.enabled,disabled:!i,onChange:t=>this.setFeatureEnabled(e,t)})} ${e.id===`codeMode`?this.renderCodeModeExecutor():g} `}render(){let e=[...X.map(e=>this.renderFeature(e)),this.saveError?N({title:f(`labsPage.saveErrorTitle`),description:_`<span role="alert">${this.saveError}</span>`}):g],t=E(A({title:f(`labsPage.sectionTitle`),description:f(`labsPage.sectionDescription`)},e));return _` ${O({title:m(`labs`),subtitle:_`${f(`labsPage.intro`)} ${k(`https://docs.openclaw.ai/concepts/experimental-features`)}`})} ${P(t)} `}},w([ne({context:h,subscribe:!0})],Q.prototype,`context`,void 0),w([b()],Q.prototype,`pending`,void 0),w([b()],Q.prototype,`saveError`,void 0),customElements.get(`openclaw-labs-page`)||customElements.define(`openclaw-labs-page`,Q)})))()}$();