Files
T

95 lines
10 KiB
JavaScript

import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{er as t}from"./control-ui-foundation-CeFMP1Ly.js";import{S as n,fl as r,fs as i,ml as a,ms as o,vr as s,w as c,yr as l}from"./control-ui-core-pH6nakZ-.js";import{G as u,J as d,W as f,Z as ee,i as p,n as m,rt as h}from"./lit-runtime-BEtFSUCp.js";import{Cn as g,ln as _,m as v,p as y}from"./control-ui-core-DGVkFhVB.js";import{Ht as te,qt as b}from"./control-ui-core-Br5DB0Zj.js";import{F as ne,I as re,In as x,L as S,Ln as C,z as w}from"./control-ui-boot-wpHCbPL9.js";import{Ns as T,Ps as E,bn as D,gn as O,mn as k,on as A,un as j,va as M,vn as N,ya as P}from"./control-ui-boot-Cdpgu1Gm.js";import{In as F,Ln as I,Rn as ie}from"./control-ui-boot-D1DWJlBr.js";import{n as L,t as R}from"./settings-workspace-Bo4nqRhI.js";import{n as z,t as B}from"./gateway-page-controller-bzyUg03c.js";import{i as V,s as H}from"./presenter-CKFufLDk.js";import{a as U,n as W,t as G}from"./lane-table-QMAsbx-S.js";function K(e,t){return O({title:e,stacked:!0,control:d`<pre class="code-block">
${p(M(JSON.stringify(t??{},null,2)))}</pre>`})}function q(e){let t=(e.status&&typeof e.status==`object`?e.status.securityAudit:null)?.summary??null;if(!t)return u;let n=t.critical??0,r=t.warn??0,i=t.info??0,a=n>0?`danger`:r>0?`warn`:`ok`,o=n>0?b(`debug.security.critical`,{count:String(n)}):r>0?b(`debug.security.warnings`,{count:String(r)}):b(`debug.security.noCriticalIssues`),s=i>0?` · ${b(`debug.security.info`,{count:String(i)})}`:``;return O({title:b(`debug.security.audit`),description:d`
${b(`debug.security.runPrefix`)}
<span class="mono">openclaw security audit --deep</span>
${b(`debug.security.runSuffix`)}
`,control:D({kind:a,label:`${o}${s}`})})}function J(e){return e?d`
<div class="settings-row" role="alert">
<div class="settings-row__text">
<span class="settings-row__title">
${D({kind:`danger`,label:b(`common.failed`)})}
</span>
<span class="settings-row__desc">${e}</span>
</div>
</div>
`:u}function Y(e){return O({title:e.event,description:n(e.ts,void 0,``),stacked:!0,control:d`<pre class="code-block">
${p(M(V(e.payload)))}</pre>`})}function ae(e){let t=N({title:b(`debug.snapshotsTitle`),description:b(`debug.snapshotsSubtitle`),actions:d`
<button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
${e.loading?b(`common.refreshing`):b(`common.refresh`)}
</button>
`},d`
${J(e.diagnosticsError)} ${q(e)}
${K(b(`debug.status`),e.status)}
${K(b(`debug.health`),e.health)}
${K(b(`debug.lastHeartbeat`),e.heartbeat)}
`),n=N({title:b(`debug.lanes.title`),description:b(`debug.lanes.subtitle`),actions:d`
<button class="btn" @click=${e.onOpenOverlay}>
${b(`debug.overlay.openWithShortcut`,{shortcut:F})}
</button>
`},d`
<div class="data-table-container command-lanes-table-wrap">
<table class="data-table command-lanes-table">
<thead>
<tr>
<th>${b(`debug.lanes.lane`)}</th>
<th>${b(`debug.lanes.active`)}</th>
<th>${b(`debug.lanes.queued`)}</th>
<th>${b(`debug.lanes.group`)}</th>
<th>${b(`debug.lanes.blocked`)}</th>
</tr>
</thead>
<tbody>
${W({lanes:e.lanes,dynamic:e.dynamic})}
</tbody>
</table>
</div>
`),r=N({title:b(`debug.manualRpcTitle`),description:b(`debug.manualRpcSubtitle`)},d`
${O({title:b(`debug.method`),control:d`
<select
class="settings-select"
aria-label=${b(`debug.method`)}
.value=${e.callMethod}
@change=${t=>e.onCallMethodChange(t.target.value)}
>
${e.callMethod?u:d` <option value="" disabled>${b(`debug.selectMethod`)}</option> `}
${e.methods.map(e=>d`<option value=${e}>${e}</option>`)}
</select>
`})}
${O({title:b(`debug.paramsJson`),stacked:!0,control:d`
<textarea
class="settings-input"
aria-label=${b(`debug.paramsJson`)}
.value=${e.callParams}
@input=${t=>e.onCallParamsChange(t.target.value)}
rows="6"
></textarea>
`})}
${O({title:b(`common.call`),control:d`
<button class="btn primary" @click=${e.onCall}>${b(`common.call`)}</button>
`})}
${e.callError?d`
<div class="settings-row settings-row--stacked">
${D({kind:`danger`,label:b(`debug.callFailed`)})}
<pre class="code-block">${e.callError}</pre>
</div>
`:u}
${e.callResult?d`
<div class="settings-row settings-row--stacked">
${D({kind:`ok`,label:b(`common.ok`)})}
<pre class="code-block">${p(M(e.callResult))}</pre>
</div>
`:u}
`),i=N({title:b(`debug.modelsTitle`),description:b(`debug.modelsSubtitle`)},d`
<div class="settings-row settings-row--stacked">
<pre class="code-block">
${p(M(JSON.stringify(e.models??[],null,2)))}</pre>
</div>
`),a=N({title:b(`debug.eventLogTitle`),description:b(`debug.eventLogSubtitle`)},e.eventLog.length===0?j(b(`debug.noEvents`)):e.eventLog.map(e=>Y(e)));return k(d`${t} ${n} ${r} ${i} ${a}`,{wide:!0})}function X(){return(X=e((()=>{f(),m(),P(),A(),te(),c(),H(),I(),G()})))()}var Z,Q;function $(){return($=e((()=>{C(),ne(),f(),ee(),_(),v(),R(),o(),z(),a(),E(),l(),I(),X(),Z=3e3,Q=class extends r{constructor(...e){super(...e),this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugLanes=[],this.debugDynamic=null,this.debugCallMethod=``,this.debugCallParams=`{}`,this.debugCallResult=null,this.debugCallError=null,this.debugDiagnosticsError=null,this.eventLog=[],this.polling=new T(this,Z,()=>{this.loadDiagnostics()},!1),this.callEpoch=0,this.diagnosticsTaskActiveClient=null,this.diagnosticsAgentId=null,this.diagnosticsTask=new re(this,{autoRun:!1,args:()=>[this.gateway.connected?this.gateway.client:null,this.context?.agentSelection.state.selectedId??null],task:([e,t],{signal:n})=>e?U(e,t,n):S,onComplete:e=>{this.diagnosticsTaskActiveClient=null,this.debugDiagnosticsError=null,this.debugStatus=e.status,this.debugHealth=e.health,this.debugModels=e.models,this.debugHeartbeat=e.heartbeat,this.debugLanes=e.lanes,this.debugDynamic=e.dynamic},onError:e=>{this.diagnosticsTaskActiveClient=null,this.debugDiagnosticsError=i(e)}}),this.gateway=new B(this,{getGateway:()=>this.context?.gateway,onIdentityChange:()=>{this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugLanes=[],this.debugDynamic=null,this.debugCallResult=null,this.debugCallError=null,this.debugDiagnosticsError=null},invalidateRequests:()=>{this.diagnosticsTask.run([null,null]),this.diagnosticsTaskActiveClient=null,this.callEpoch+=1},onSnapshot:()=>{this.syncPolling(),this.ensureInitialDebug()}}),this.subscriptions=new s(this).watch(()=>this.context?.gateway,(e,t)=>e.subscribeEventLog(t),e=>{this.eventLog=e.eventLog}).watch(()=>this.context?.agentSelection,(e,t)=>e.subscribe(t),e=>{let t=e.state.selectedId;t!==this.diagnosticsAgentId&&(this.diagnosticsAgentId=t,this.debugModels=[],this.diagnosticsTask.run([null,null]),this.diagnosticsTaskActiveClient=null,this.loadDiagnostics())})}disconnectedCallback(){this.subscriptions.clear(),this.diagnosticsTask.run([null,null]),this.diagnosticsTaskActiveClient=null,this.diagnosticsAgentId=null,this.callEpoch+=1,super.disconnectedCallback()}syncPolling(){if(!this.gateway.connected||!this.gateway.client){this.polling.stop();return}this.polling.start()}ensureInitialDebug(){!this.gateway.connected||!this.gateway.client||this.debugStatus||this.diagnosticsTaskActiveClient||this.loadDiagnostics()}loadDiagnostics(){let e=this.gateway.connected?this.gateway.client:null;return!e||this.diagnosticsTaskActiveClient?Promise.resolve():(this.diagnosticsTaskActiveClient=e,this.diagnosticsTask.run([e,this.context.agentSelection.state.selectedId]))}async callDebugMethod(){let e=this.gateway.connected?this.gateway.client:null;if(!e)return;this.debugCallError=null,this.debugCallResult=null;let t=this.gateway.gateway,n=++this.callEpoch,r=()=>this.gateway.connected&&this.gateway.client===e&&this.gateway.gateway===t&&this.context.gateway===t&&this.callEpoch===n;try{let t=this.debugCallParams.trim()?JSON.parse(this.debugCallParams):{},n=await e.request(this.debugCallMethod.trim(),t);r()&&(this.debugCallResult=JSON.stringify(n,null,2))}catch(e){r()&&(this.debugCallError=i(e))}}render(){let e=ae({loading:this.diagnosticsTask.status===w.PENDING,status:this.debugStatus,health:this.debugHealth,models:this.debugModels,heartbeat:this.debugHeartbeat,lanes:this.debugLanes,dynamic:this.debugDynamic,diagnosticsError:this.debugDiagnosticsError,eventLog:this.eventLog,methods:(this.context.gateway.snapshot.hello?.features?.methods??[]).toSorted(),callMethod:this.debugCallMethod,callParams:this.debugCallParams,callResult:this.debugCallResult,callError:this.debugCallError,onCallMethodChange:e=>this.debugCallMethod=e,onCallParamsChange:e=>this.debugCallParams=e,onRefresh:()=>void this.loadDiagnostics(),onOpenOverlay:ie,onCall:()=>void this.callDebugMethod()});return d`
<section class="content-header">
<div>
<div class="page-title">${g(`debug`)}</div>
</div>
</section>
${L(e)}
`}},t([x({context:y,subscribe:!0})],Q.prototype,`context`,void 0),t([h()],Q.prototype,`debugStatus`,void 0),t([h()],Q.prototype,`debugHealth`,void 0),t([h()],Q.prototype,`debugModels`,void 0),t([h()],Q.prototype,`debugHeartbeat`,void 0),t([h()],Q.prototype,`debugLanes`,void 0),t([h()],Q.prototype,`debugDynamic`,void 0),t([h()],Q.prototype,`debugCallMethod`,void 0),t([h()],Q.prototype,`debugCallParams`,void 0),t([h()],Q.prototype,`debugCallResult`,void 0),t([h()],Q.prototype,`debugCallError`,void 0),t([h()],Q.prototype,`debugDiagnosticsError`,void 0),t([h()],Q.prototype,`eventLog`,void 0),customElements.get(`openclaw-debug-page`)||customElements.define(`openclaw-debug-page`,Q)})))()}$();
//# sourceMappingURL=debug-page-Cs74mC6x.js.map