openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
16 lines • 3.53 kB
JavaScript
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Ac as t,Cu as n,Eu as r,Sl as i,So as a,Tu as o,jl as s,ju as c,kc as l,yo as u}from"./control-ui-core-BncvAZjR.js";import{Ti as d,wi as f}from"./control-ui-core-9qYjK5B2.js";import{$ as p,X as m,Y as h,nt as g,ut as _}from"./lit-runtime-B8uOr6OX.js";import{Xr as v,Zr as y,_t as b,ii as x}from"./ui-DuRgK6kL.js";import{g as S,h as C}from"./control-ui-boot-chat-Ck7W_FPO.js";import{J as w,_ as T,b as E,q as D}from"./control-ui-boot-chat-C8hdsB2M.js";function O(e,t){let n=e?.props?.sessionKey,r=typeof n==`string`?n.trim():``;return r?{sessionKey:r,agentId:s(r)?.agentId??t.agentId}:t}var k;function A(){return(A=e((()=>{y(),h(),g(),d(),w(),T(),r(),o(),t(),C(),i(),u(),k=class extends n{constructor(){super(),this.session={sessionKey:``},this.active=!0,this.progressCard=new D(this,{gateway:()=>this.active&&O(this.widget,this.session).sessionKey?this.context?.gateway:void 0,target:()=>O(this.widget,this.session)}),new l(this).effect(()=>this.context?.agentSelection,e=>(this.bindSessionList(),e.subscribe(()=>this.bindSessionList())))}connectedCallback(){super.connectedCallback(),this.bindSessionList()}disconnectedCallback(){this.releaseSessionList(),super.disconnectedCallback()}willUpdate(){this.bindSessionList()}render(){let e=this.progressCard.error,t=this.progressCard.card,n=e?p`<div
class=${t?`callout info`:`board-widget__plugin-loading`}
data-test-id="session-progress-error"
role="alert"
>
<span
>${c(e===`access-denied`?`sessionProgressCard.widgetAccessDenied`:`sessionProgressCard.widgetUnavailable`)}</span
>
${e===`unavailable`?p`<button class="btn btn--sm" type="button" =${this.progressCard.retry}>
${c(`common.retry`)}
</button>`:null}
</div>`:m;if(e&&!t)return n;if(this.progressCard.loading)return p`<p class="board-widget__plugin-loading">
${c(`sessionProgressCard.widgetLoading`)}
</p>`;if(t===null)return p`<p class="board-widget__plugin-loading">
${c(`sessionProgressCard.widgetEmpty`)}
</p>`;let r=S(this.context?.gateway.snapshot??{},O(this.widget,this.session)),i=a(r.agentId),o=this.context?.sessions.listSnapshot(i).result?.sessions.find(e=>e.key===r.sessionKey&&(e.agentId??s(e.key)?.agentId)===r.agentId);return p`${n}${E(t,`board`,void 0,o?.status,o?.startedAt,o?.endedAt,b(o??{}))}`}bindSessionList(){let e=this.context;if(!this.isConnected||!e)return;let t=e.sessions,n=S(e.gateway.snapshot,O(this.widget,this.session)).agentId;if(!(this.active&&O(this.widget,this.session).sessionKey)){this.releaseSessionList();return}if(t===this.observedSessions&&n===this.observedTargetAgentId)return;this.releaseSessionList(),this.observedSessions=t,this.observedTargetAgentId=n;let r=a(n);this.unsubscribeList=t.subscribeList(r,()=>this.requestUpdate());let i=t.listSnapshot(r);this.requestUpdate(),!i.result&&!i.loading&&!i.error&&e.gateway.snapshot.phase===`connected`&&t.refreshList({...r,force:!0})}releaseSessionList(){this.unsubscribeList?.(),this.unsubscribeList=void 0,this.observedSessions=void 0,this.observedTargetAgentId=void 0}},x([v({context:f,subscribe:!0})],k.prototype,`context`,void 0),x([_({attribute:!1})],k.prototype,`widget`,void 0),x([_({attribute:!1})],k.prototype,`session`,void 0),x([_({attribute:!1})],k.prototype,`active`,void 0),customElements.get(`openclaw-session-progress-widget`)||customElements.define(`openclaw-session-progress-widget`,k)})))()}A();