Files

12 lines
8.4 KiB
JavaScript

import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{er as t,wn as n}from"./control-ui-foundation-CeFMP1Ly.js";import{dc as r,dr as i,fl as a,fr as o,fs as s,ml as c,ms as l,pr as u,uc as d,vr as f,yr as p}from"./control-ui-core-pH6nakZ-.js";import{G as m,J as h,W as g,Z as _,rt as v}from"./lit-runtime-BEtFSUCp.js";import{Cn as y,ln as b,m as x,p as S}from"./control-ui-core-DGVkFhVB.js";import{Ht as C,qt as w}from"./control-ui-core-Br5DB0Zj.js";import{In as T,Ln as E}from"./control-ui-boot-wpHCbPL9.js";import{Sn as D,cn as O,gn as k,hn as A,mn as j,on as M,vn as N}from"./control-ui-boot-Cdpgu1Gm.js";import{n as P,t as F}from"./settings-workspace-Bo4nqRhI.js";import{n as I,t as L}from"./gateway-page-controller-bzyUg03c.js";function R(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 z(e,t){let r=e;for(let e of t){if(!n(r))return;r=r[e]}return r}function B(e){let t=z(e,[`agents`,`defaults`,`model`]);if(typeof t==`string`)return t;if(!n(t))return;let r=t.primary;return typeof r==`string`?r:void 0}function V(e,t){if(t.id!==J)return!1;let n=z(e,Y);return typeof n==`string`&&B(e)===n&&z(e,t.configPath)===!0}function H(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 U(e,t){let r=t.configPath.slice(0,-1),i=t.configPath.at(-1),a=z(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 W(e,t){let r=e??{};if(V(r,t))return{enabled:!0,defaultEnabled:!0,overridden:!1};let i=t.configPath.slice(0,-1),a=t.configPath.at(-1),o=z(r,i),s=U(r,t),c=o;return s?.length===i.length?c=void 0:s&&a&&n(o)&&(c={...o},delete c[a]),{enabled:H(t,o),defaultEnabled:H(t,c),overridden:s!==null}}function G(e,t,n){let r={[t.configPath.at(-1)]:n?t.onValue:t.offValue,...n?t.enableAlso:null};for(let e of t.configPath.slice(0,-1).toReversed())r={[e]:r};return K(e,t,r)}function K(e,t,n){return t.id!==J||z(e??{},Y)===void 0?n:{...n,wizard:{localModelLeanAutoModel:null}}}function q(e,t){let n=U(e??{},t);if(!n?.length)return null;let r=null;for(let e of n.toReversed())r={[e]:r};return K(e,t,r)}var J,Y,X;function Z(){return(Z=e((()=>{C(),J=`localModelLean`,Y=[`wizard`,`localModelLeanAutoModel`],X=[{id:`codeMode`,title:()=>w(`labsPage.codeMode.title`),description:()=>w(`labsPage.codeMode.description`),docsUrl:`https://docs.openclaw.ai/tools/code-mode`,configPath:[`tools`,`codeMode`,`enabled`],onValue:`auto`,offValue:!1,activeValues:[!0,`auto`],readEnabled:null,enableAlso:null,resetScope:`gate`,restartHint:null},{id:`swarm`,title:()=>w(`labsPage.swarm.title`),description:()=>w(`labsPage.swarm.description`),docsUrl:`https://docs.openclaw.ai/tools/swarm`,configPath:[`tools`,`swarm`,`enabled`],onValue:!0,offValue:!1,activeValues:[!0],readEnabled:null,enableAlso:null,resetScope:`gate`,restartHint:null},{id:`toolSearch`,title:()=>w(`labsPage.toolSearch.title`),description:()=>w(`labsPage.toolSearch.description`),docsUrl:`https://docs.openclaw.ai/tools/tool-search`,configPath:[`tools`,`toolSearch`,`enabled`],onValue:!0,offValue:!1,activeValues:[!0],readEnabled:e=>R(e,[!0]),enableAlso:{mode:`directory`},resetScope:`parent`,restartHint:null},{id:`loopDetection`,title:()=>w(`labsPage.loopDetection.title`),description:()=>w(`labsPage.loopDetection.description`),docsUrl:`https://docs.openclaw.ai/tools/loop-detection`,configPath:[`tools`,`loopDetection`,`enabled`],onValue:!0,offValue:!1,activeValues:[!0],readEnabled:null,enableAlso:null,resetScope:`gate`,restartHint:null},{id:`localModelLean`,title:()=>w(`labsPage.localModelLean.title`),description:()=>w(`labsPage.localModelLean.description`),docsUrl:`https://docs.openclaw.ai/gateway/local-models`,configPath:[`agents`,`defaults`,`experimental`,`localModelLean`],onValue:!0,offValue:!1,activeValues:[!0],readEnabled:null,enableAlso:null,resetScope:`gate`,restartHint:null},{id:`cliAgents`,title:()=>w(`labsPage.cliAgents.title`),description:()=>w(`labsPage.cliAgents.description`),docsUrl:`https://docs.openclaw.ai/gateway/configuration-reference#gateway`,configPath:[`gateway`,`cliAgents`,`enabled`],onValue:!0,offValue:!1,activeValues:[!0],readEnabled:null,enableAlso:null,resetScope:`gate`,restartHint:null},{id:`auditMessages`,title:()=>w(`labsPage.auditMessages.title`),description:()=>w(`labsPage.auditMessages.description`),docsUrl:`https://docs.openclaw.ai/gateway/audit`,configPath:[`logging`,`audit`,`messages`],onValue:`direct`,offValue:`off`,activeValues:[`direct`,`all`],readEnabled:null,enableAlso:null,resetScope:`gate`,restartHint:()=>w(`labsPage.restartRequired`)},{id:`hostDesktop`,title:()=>w(`labsPage.hostDesktop.title`),description:()=>w(`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:`gate`,restartHint:()=>w(`labsPage.restartRequired`)},{id:`workerDesktop`,title:()=>w(`labsPage.workerDesktop.title`),description:()=>w(`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`,restartHint:()=>w(`labsPage.restartRequired`)}]})))()}var Q;function $(){return($=e((()=>{E(),g(),_(),b(),x(),M(),F(),C(),d(),u(),l(),I(),c(),p(),Z(),Q=class extends a{constructor(...e){super(...e),this.busyFeatureId=null,this.pendingValues={},this.saveError=null,this.gateway=new L(this,{getGateway:()=>this.context?.gateway,invalidateRequests:()=>{this.busyFeatureId=null,this.pendingValues={},this.saveError=null}}),this.subscriptions=new f(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 r(e)}featureEnabled(e){let t=this.pendingValues[e.id];return t===void 0?W(this.editableConfig(),e).enabled:t}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 updateFeature(e,t,n){let r=this.gateway.capture(),i=this.context.runtimeConfig;if(!r||!this.canToggle())return;let a=()=>this.gateway.isCurrent(r)&&this.context.runtimeConfig===i;this.busyFeatureId=e.id,this.pendingValues={...this.pendingValues,[e.id]:t},this.saveError=null;try{let t=await i.patch({raw:n,note:`labs: update ${e.id}`});a()&&!t&&(this.saveError=i.state.lastError??w(`labsPage.saveFailed`))}catch(e){a()&&(this.saveError=s(e))}finally{a()&&(this.clearPendingValue(e.id),this.busyFeatureId===e.id&&(this.busyFeatureId=null))}}setFeatureEnabled(e,t){let n=this.editableConfig(),r=t===W(n,e).defaultEnabled?q(n,e):null;this.updateFeature(e,t,r??G(n,e,t))}renderFeature(e){let t=e.title(),n=W(this.editableConfig(),e),r=this.canToggle(),a=w(n.overridden?`configForm.defaultValue`:`configForm.usingDefault`,{value:n.defaultEnabled?w(`common.enabled`):w(`common.disabled`)}),s=h`
${e.description()}
<a href=${e.docsUrl} target=${i} rel=${o()}
>${w(`labsPage.documentation`)}</a
>${e.restartHint?h` <span>${e.restartHint()}</span>`:m}
<span>${a}</span>
`;return D({title:t,description:s,checked:this.featureEnabled(e),disabled:!r,onChange:t=>this.setFeatureEnabled(e,t)})}render(){let e=[...X.map(e=>this.renderFeature(e)),this.saveError?k({title:w(`labsPage.saveErrorTitle`),description:h`<span role="alert">${this.saveError}</span>`}):m],t=j(N({title:w(`labsPage.sectionTitle`),description:w(`labsPage.sectionDescription`)},e));return h`
${A({title:y(`labs`),subtitle:h`${w(`labsPage.intro`)}
${O(`https://docs.openclaw.ai/concepts/experimental-features`)}`})}
${P(t)}
`}},t([T({context:S,subscribe:!0})],Q.prototype,`context`,void 0),t([v()],Q.prototype,`busyFeatureId`,void 0),t([v()],Q.prototype,`pendingValues`,void 0),t([v()],Q.prototype,`saveError`,void 0),customElements.get(`openclaw-labs-page`)||customElements.define(`openclaw-labs-page`,Q)})))()}$();
//# sourceMappingURL=labs-page-t7t8f2zd.js.map