UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

96 lines 10.4 kB
import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{R as t,wr as n,z as r}from"./control-ui-foundation-Cydpkyqa.js";import{Ai as i,Bi as a,Bn as o,Eo as s,Fa as c,Mi as ee,Oo as l,Sc as u,Wi as d,bc as f,ji as p,k as m,w as h,za as g,zn as _}from"./control-ui-core-Rwzhj6nO.js";import{$ as v,K as y,X as b,at as x,h as S,m as C,q as w,st as T}from"./lit-runtime-CV_MH99K.js";import{It as E,Rt as te,_ as ne,_n as re,g as ie,jn as D,zt as O}from"./control-ui-core-YphAl4aM.js";import{Gt as k,Wt as A,Yt as j,en as M}from"./control-ui-core-vvcQQV2m.js";import{Or as N,kr as P}from"./control-ui-boot-shared-DfZ39Yj9.js";import{$o as F,Qo as I}from"./control-ui-boot-shared-CXVvK2AW.js";import{n as L,t as R}from"./near-viewport-observer-BfnpDHlZ.js";import{n as z,t as B}from"./settings-workspace-Bseic8Tf.js";var V;function H(){return(H=e((()=>{y(),v(),L(),j(),u(),V=class extends f{constructor(...e){super(...e),this.sessionKey=``,this.error=null,this.visibility=new R(200,()=>this.requestUpdate()),this.observationFrame=0}connectedCallback(){super.connectedCallback(),window.cancelAnimationFrame(this.observationFrame),this.observationFrame=window.requestAnimationFrame(()=>this.visibility.observe(this))}disconnectedCallback(){window.cancelAnimationFrame(this.observationFrame),this.visibility.disconnect(),super.disconnectedCallback()}render(){return this.visibility.nearVisible?this.error?b`<div class="dashboard-preview__error"> ${M(`dashboardDocument.loadFailed`,{error:this.error})} </div>`:b`<openclaw-board-document .passive=${!0} .gatewaySnapshot=${this.gatewaySnapshot} .preparedSession=${{sessionKey:this.sessionKey,agentId:this.agentId}} ></openclaw-board-document>`:w}},n([T({attribute:!1})],V.prototype,`gatewaySnapshot`,void 0),n([T({attribute:!1})],V.prototype,`sessionKey`,void 0),n([T({attribute:!1})],V.prototype,`agentId`,void 0),n([T({attribute:!1})],V.prototype,`error`,void 0),customElements.get(`openclaw-dashboard-preview`)||customElements.define(`openclaw-dashboard-preview`,V)})))()}function U(e,t){let n=e.createdActor??e.owner?.actor,r=n?.id?.trim()||e.agentId?.trim()||t;return{id:r,label:n?.label?.trim()||r}}function W(e,t,n){return b`<div class="dashboard-preview" aria-hidden="true" inert> <openclaw-dashboard-preview .gatewaySnapshot=${t} .sessionKey=${e.key} .agentId=${e.agentId} .error=${n} ></openclaw-dashboard-preview> </div>`}function G(e,t){let n=t.query.trim().toLocaleLowerCase();return(e.result?.sessions??[]).filter(r=>{let i=U(r,e.fallbackAgentId);return t.ownerId&&i.id!==t.ownerId?!1:!n||[g(r.key,r),i.label,r.lastMessagePreview,r.key].filter(e=>typeof e==`string`).some(e=>e.toLocaleLowerCase().includes(n))}).toSorted((e,n)=>t.sort===`title`?g(e.key,e).localeCompare(g(n.key,n)):(n.updatedAt??0)-(e.updatedAt??0))}function K(e,t,n,r){let i=d({face:`chat`,sessionKey:t.key,fallbackAgentId:e.fallbackAgentId,basePath:e.basePath,row:t,mainKey:e.mainKey,dashboardExpanded:!0}),a=U(t,e.fallbackAgentId),o=g(t.key,t),s=a.label.trim().charAt(0).toLocaleUpperCase()||`?`;return b`<article class="dashboard-card" data-dashboard-session=${t.key}> <a class="dashboard-card__main" href=${i.href} aria-label=${o}> ${W(t,n,r)} <div class="dashboard-card__body"> <div class="dashboard-card__heading"> <h2>${o}</h2> ${t.status===`running`?b`<span class="dashboard-card__live"><i></i>${M(`dashboardsPage.live`)}</span>`:w} </div> <div class="dashboard-card__author"> <span class="dashboard-card__avatar" aria-hidden="true">${s}</span> <span>${M(`dashboardsPage.byAuthor`,{author:a.label})}</span> </div> </div> <footer class="dashboard-card__footer"> <span> ${t.updatedAt?M(`dashboardsPage.updated`,{time:h(t.updatedAt)}):M(`dashboardsPage.updatedUnknown`)} </span> <span class="dashboard-card__open" aria-hidden="true">${A.arrowUpRight}</span> </footer> </a> </article>`}function q(e,t,n,r,i){let a=e.result?.sessions??[];if(e.error&&!e.result)return w;if(a.length===0)return b`<section class="card stack" data-dashboards-empty role="status"> <div class="list-title">${M(`dashboardsPage.emptyTitle`)}</div> <div class="card-sub">${M(`dashboardsPage.emptyDescription`)}</div> </section>`;let o=Array.from(new Map(a.map(t=>{let n=U(t,e.fallbackAgentId);return[n.id,n]})).values()).toSorted((e,t)=>e.label.localeCompare(t.label)),s=G(e,t);return b`<section class="dashboards-gallery" aria-label=${D(`dashboards`)}> <div class="dashboards-toolbar"> <label class="dashboards-search"> <span aria-hidden="true">${A.search}</span> <span class="sr-only">${M(`dashboardsPage.searchLabel`)}</span> <input type="search" .value=${t.query} placeholder=${M(`dashboardsPage.searchPlaceholder`)} @input=${e=>{e.currentTarget instanceof HTMLInputElement&&n.onQueryChange(e.currentTarget.value)}} /> </label> <label class="dashboards-select"> <span>${M(`dashboardsPage.authorFilter`)}</span> <select .value=${t.ownerId} @change=${e=>{e.currentTarget instanceof HTMLSelectElement&&n.onOwnerChange(e.currentTarget.value)}} > <option value="">${M(`dashboardsPage.allAuthors`)}</option> ${o.map(e=>b`<option value=${e.id}>${e.label}</option>`)} </select> </label> <label class="dashboards-select"> <span>${M(`dashboardsPage.sortLabel`)}</span> <select .value=${t.sort} @change=${e=>{e.currentTarget instanceof HTMLSelectElement&&(e.currentTarget.value===`updated`||e.currentTarget.value===`title`)&&n.onSortChange(e.currentTarget.value)}} > <option value="updated">${M(`dashboardsPage.sortUpdated`)}</option> <option value="title">${M(`dashboardsPage.sortTitle`)}</option> </select> </label> </div> <div class="dashboards-results" role="status"> ${M(`dashboardsPage.resultCount`,{count:String(s.length)})} </div> ${s.length===0?b`<div class="dashboards-no-results" data-dashboards-no-results> <span aria-hidden="true">${A.search}</span> <strong>${M(`dashboardsPage.noResultsTitle`)}</strong> <span>${M(`dashboardsPage.noResultsDescription`)}</span> </div>`:b`<div class="dashboards-grid"> ${S(s,e=>e.key,t=>K(e,t,r,i))} </div>`} </section>`}function J(e,t,n=Y,r=X,i,a=null){let o=e?b` ${P({status:{error:e.error,hasLoaded:e.result!==null,stale:e.result!==null&&e.error!==null},errorMessage:e.error?M(`dashboardsPage.loadError`,{error:e.error}):void 0,onRetry:t})} ${q(e,n,r,i,a)} `:b`<section class="card" aria-busy="true">${M(`common.loading`)}</section>`;return b` <section class="content-header dashboards-header"> <div> <div class="page-title">${D(`dashboards`)}</div> <div class="page-subtitle">${M(`subtitles.dashboards`)}</div> </div> ${e?.result?b`<div class="dashboards-header__count"> <strong>${e.result.sessions.length}</strong> <span>${M(`dashboardsPage.totalLabel`)}</span> </div>`:w} </section> ${z(o)} `}var Y,X;function Z(){return(Z=e((()=>{y(),C(),re(),k(),N(),B(),j(),m(),c(),a(),H(),Y={query:``,ownerId:``,sort:`updated`},X={onQueryChange:()=>void 0,onOwnerChange:()=>void 0,onSortChange:()=>void 0}})))()}var Q;function $(){return($=e((()=>{r(),v(),ne(),O(),l(),F(),u(),o(),ee(),Z(),Q=class extends f{constructor(...e){super(...e),this.filters={query:``,ownerId:``,sort:`updated`},this.previewError=null,this.listGeneration=0,this.subscriptions=new _(this).effect(()=>this.context?.agentSelection,e=>(this.bindList(),e.subscribe(()=>this.bindList()))).watch(()=>this.context?.gateway,(e,t)=>e.subscribe(t))}connectedCallback(){super.connectedCallback(),te(E.tagName,E.loadModule).then(()=>this.requestUpdate()).catch(e=>{this.previewError=s(e)})}disconnectedCallback(){this.listGeneration+=1,this.unsubscribeList?.(),this.unsubscribeList=void 0,this.observedSessions=void 0,this.observedScopeId=void 0,this.subscriptions.clear(),super.disconnectedCallback()}willUpdate(e){e.has(`routeData`)&&(this.data=this.routeData),this.bindList()}bindList(){let e=this.context;if(!e)return;let t=e.sessions,n=e.agentSelection.state.scopeId?.trim()||null;if(t===this.observedSessions&&n===this.observedScopeId)return;this.unsubscribeList?.(),this.observedSessions=t,this.observedScopeId=n;let r=i(e),a=i=>{this.context!==e||this.observedSessions!==t||this.observedScopeId!==n||!i.result&&!i.error||(this.data=p(e,i),this.requestUpdate(),this.completeList(e,t,n,r,i))};this.unsubscribeList=t.subscribeList(r,a);let o=t.listSnapshot(r);a(o),!o.result&&!o.loading&&e.gateway.snapshot.phase===`connected`&&t.refreshList({...r,force:!0})}completeList(e,t,n,r,i){let a=i.result,o=++this.listGeneration;if(!a?.hasMore)return;let c=()=>this.context===e&&this.observedSessions===t&&this.observedScopeId===n&&this.listGeneration===o;I({initialResult:a,list:e=>t.list({...r,offset:e}),isCurrent:c,missingResultError:`dashboard enumeration returned no result`,stalledPaginationError:`dashboard enumeration did not advance`,incompletePaginationError:`dashboard enumeration was incomplete`}).then(t=>{!t||!c()||(this.data=p(e,{...i,result:{...a,count:t.length,hasMore:!1,nextOffset:null,sessions:t}}),this.requestUpdate())}).catch(t=>{c()&&(this.data=p(e,{...i,error:s(t)}),this.requestUpdate())})}render(){return J(this.data,()=>{let e=this.context;e?.gateway.snapshot.phase===`connected`&&e.sessions.refreshList({...i(e),force:!0})},this.filters,{onQueryChange:e=>{this.filters={...this.filters,query:e}},onOwnerChange:e=>{this.filters={...this.filters,ownerId:e}},onSortChange:e=>{this.filters={...this.filters,sort:e}}},this.context?.gateway.snapshot,this.previewError)}},n([t({context:ie,subscribe:!0})],Q.prototype,`context`,void 0),n([T({attribute:!1})],Q.prototype,`routeData`,void 0),n([x()],Q.prototype,`filters`,void 0),n([x()],Q.prototype,`previewError`,void 0),customElements.get(`openclaw-dashboards-page`)||customElements.define(`openclaw-dashboards-page`,Q)})))()}$(); //# sourceMappingURL=dashboards-page-ZkxB7TA3.js.map