UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

16 lines • 3.55 kB
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Br as t,et as n,qr as r,zr as i}from"./control-ui-foundation-ZY_Flbbd.js";import{Io as a,No as o,cc as s,dl as c,hu as l,lu as u,nl as d,sc as f,su as p,uu as m}from"./control-ui-core-3P365fbR.js";import{vi as h,yi as g}from"./control-ui-core-CFW9Qtjn.js";import{$ as _,X as v,Y as y,nt as b,ut as x}from"./lit-runtime-P5vbNq6b.js";import{Lt as S,Rt as C}from"./control-ui-boot-shared-DoKu-5Ju.js";import{Bt as w,K as T,U as E,zt as D}from"./control-ui-boot-shared-CG9HtEG-.js";function O(e,t){let n=e?.props?.sessionKey,r=typeof n==`string`?n.trim():``;return r?{sessionKey:r,agentId:c(r)?.agentId??t.agentId}:t}var k;function A(){return(A=e((()=>{t(),y(),b(),g(),w(),E(),m(),u(),s(),S(),d(),o(),k=class extends p{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 f(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,r=e?_`<div class=${t?`callout info`:`board-widget__plugin-loading`} data-test-id="session-progress-error" role="alert" > <span >${l(e===`access-denied`?`sessionProgressCard.widgetAccessDenied`:`sessionProgressCard.widgetUnavailable`)}</span > ${e===`unavailable`?_`<button class="btn btn--sm" type="button" @click=${this.progressCard.retry}> ${l(`common.retry`)} </button>`:null} </div>`:v;if(e&&!t)return r;if(this.progressCard.loading)return _`<p class="board-widget__plugin-loading"> ${l(`sessionProgressCard.widgetLoading`)} </p>`;if(t===null)return _`<p class="board-widget__plugin-loading"> ${l(`sessionProgressCard.widgetEmpty`)} </p>`;let i=C(this.context?.gateway.snapshot??{},O(this.widget,this.session)),o=a(i.agentId),s=this.context?.sessions.listSnapshot(o).result?.sessions.find(e=>e.key===i.sessionKey&&(e.agentId??c(e.key)?.agentId)===i.agentId);return _`${r}${T(t,`board`,void 0,s?.status,s?.startedAt,s?.endedAt,n(s??{}))}`}bindSessionList(){let e=this.context;if(!this.isConnected||!e)return;let t=e.sessions,n=C(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}},r([i({context:h,subscribe:!0})],k.prototype,`context`,void 0),r([x({attribute:!1})],k.prototype,`widget`,void 0),r([x({attribute:!1})],k.prototype,`session`,void 0),r([x({attribute:!1})],k.prototype,`active`,void 0),customElements.get(`openclaw-session-progress-widget`)||customElements.define(`openclaw-session-progress-widget`,k)})))()}A();