UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

106 lines (105 loc) 10.3 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{Bn as i,Sc as a,bc as o,hn as s,k as c,vn as l,w as u,zn as d}from"./control-ui-core-Rwzhj6nO.js";import{$ as f,K as p,X as m,at as h,q as g,st as _}from"./lit-runtime-CV_MH99K.js";import{_ as v,g as y}from"./control-ui-core-YphAl4aM.js";import{Ft as b,Yt as x,en as S}from"./control-ui-core-vvcQQV2m.js";import{a as C,r as w}from"./gateway-runtime-Bqqcp9-I.js";import{L as T,W as E}from"./control-ui-boot-chat-_QSl8fbH.js";import{i as D,r as O,t as k}from"./custodian-surface-B8--KKtk.js";import"./settings-1mlSrEck.js";function A(e){switch(e){case`system-agent`:return S(`custodian.history.sources.systemAgent`);case`doctor`:return S(`custodian.history.sources.doctor`);case`config-rpc`:return S(`custodian.history.sources.settings`);case`external`:return S(`custodian.history.sources.manualEdit`);case`cli`:return S(`custodian.history.sources.cli`);case`plugin-install`:return S(`custodian.history.sources.pluginInstall`);case`unknown`:return S(`custodian.history.sources.unknown`)}return e}function j(e){return m` <article class="custodian__change-card ${e.invalid?`is-invalid`:``}"> <div class="custodian__change-meta"> <span class="custodian__change-source">${A(e.source)}</span> <time datetime=${new Date(e.at).toISOString()} >${u(e.at)}</time > </div> <div class="custodian__change-summary">${e.summary}</div> ${e.invalid?m`<div class="custodian__change-warning">${S(`custodian.history.invalidEdit`)}</div>`:g} ${e.opaqueChange?m`<div class="custodian__change-note">${S(`custodian.history.opaqueChange`)}</div>`:g} ${e.changedPaths?.length?m`<details class="custodian__change-paths"> <summary> ${S(`custodian.history.changedPaths`,{count:String(e.changedPaths.length)})} </summary> <ul> ${e.changedPaths.map(e=>m`<li><code>${e}</code></li>`)} </ul> </details>`:g} </article> `}function M(e){return m` <section class="custodian__history" aria-label=${S(`custodian.history.title`)}> <div class="custodian__history-heading"> <strong>${S(`custodian.history.title`)}</strong> <span>${S(`custodian.history.description`)}</span> </div> ${e.error?m`<div class="custodian__history-error" role="alert"> <span>${e.error}</span> <button class="btn btn--sm" type="button" @click=${()=>e.onLoad(!0)}> ${S(`common.retry`)} </button> </div>`:g} ${e.loading&&e.entries.length===0?E({label:S(`custodian.history.loading`)}):m`<div class="custodian__change-list"> ${e.entries.map(j)} ${e.loading?m`<div class="custodian__history-state" role="status" aria-label=${S(`custodian.history.loading`)} > <span class="custodian__history-spinner" aria-hidden="true"></span> </div>`:e.loaded&&e.entries.length===0&&!e.error?m`<div class="custodian__history-state" role="status"> ${S(`custodian.history.empty`)} </div>`:g} </div>`} ${e.nextCursor?m`<button class="btn btn--ghost custodian__history-more" type="button" ?disabled=${e.loadingMore} @click=${()=>e.onLoad(!1)} > ${e.loadingMore?S(`custodian.history.loadingMore`):S(`custodian.history.loadMore`)} </button>`:g} </section> `}function N(){return(N=e((()=>{p(),T(),x(),c()})))()}var P,F;function I(){return(I=e((()=>{r(),p(),f(),v(),b(),x(),l(),w(),a(),i(),N(),D(),k(),P=50,F=class extends o{constructor(...e){super(...e),this.onboarding=!1,this.newAgentIntent=!1,this.store=O,this.historyAvailable=!1,this.historyOpen=!1,this.historyEntries=[],this.historyNextCursor=null,this.historyLoading=!1,this.historyLoadingMore=!1,this.historyError=null,this.historyLoaded=!1,this.historyClient=null,this.historyRequestEpoch=0,this.subscribedStore=null,this.storeCleanup=null,this.channelsSource=null,this.subscriptions=new d(this).effect(()=>this.context?.channels,e=>{this.channelsSource=e;let t=e.subscribe(()=>{this.ensureOnboardingChannelStatus(),this.requestUpdate()});return this.ensureOnboardingChannelStatus(),()=>{t(),this.channelsSource===e&&(this.channelsSource=null)}})}connectedCallback(){super.connectedCallback(),this.subscribeToStore()}disconnectedCallback(){this.storeCleanup?.(),this.storeCleanup=null,this.subscribedStore=null,this.subscriptions.clear(),super.disconnectedCallback()}async getUpdateComplete(){let e=await super.getUpdateComplete();return await this.querySelector(`openclaw-custodian-surface`)?.updateComplete,e}willUpdate(e){e.has(`store`)&&this.subscribeToStore(),this.synchronizeHistoryClient(),this.ensureOnboardingChannelStatus()}ensureOnboardingChannelStatus(){let e=this.channelsSource;if(!this.onboarding||this.store.channelOnboardingNudgeClosed||!e)return;let t=e.state;!t.connected||t.channelsSnapshot||t.channelsLoading||t.channelsError||e.refresh(!1)}subscribeToStore(){!this.isConnected||this.subscribedStore===this.store||(this.storeCleanup?.(),this.subscribedStore=this.store,this.storeCleanup=this.store.subscribe(()=>this.requestUpdate()),this.store.refreshTranscriptIfIdle())}synchronizeHistoryClient(){let e=this.context.gateway.snapshot,t=e.phase===`connected`?e.client:null,n=t!==null&&C(e,`openclaw.changes.list`)===!0;(t!==this.historyClient||n!==this.historyAvailable)&&(this.historyClient=t,this.historyAvailable=n,this.historyOpen=!1,this.resetHistory())}resetHistory(){this.historyRequestEpoch+=1,this.historyEntries=[],this.historyNextCursor=null,this.historyLoading=!1,this.historyLoadingMore=!1,this.historyError=null,this.historyLoaded=!1}toggleHistory(){this.historyOpen=!this.historyOpen,this.historyOpen&&!this.historyLoading&&!this.historyLoadingMore&&this.loadHistory(!0)}async loadHistory(e){let t=this.historyClient,n=e?void 0:this.historyNextCursor??void 0;if(!t||!this.historyAvailable||this.historyLoading||this.historyLoadingMore||!e&&!n)return;let r=++this.historyRequestEpoch;e?this.historyLoading=!0:this.historyLoadingMore=!0,this.historyError=null;let i=()=>this.isConnected&&this.historyClient===t&&this.historyRequestEpoch===r&&this.historyAvailable;try{let r=await t.request(`openclaw.changes.list`,{limit:P,...n?{beforeCursor:n}:{}});if(!i())return;this.historyEntries=e?r.entries:[...this.historyEntries,...r.entries],this.historyNextCursor=r.nextCursor??null,this.historyLoaded=!0}catch{i()&&(this.historyError=S(`custodian.history.requestFailed`),this.historyLoaded=!0)}finally{i()&&(this.historyLoading=!1,this.historyLoadingMore=!1)}}render(){let e=this.channelsSource?.state,t=e?.channelsSnapshot??null,n=this.onboarding&&!this.store.channelOnboardingNudgeClosed&&e?.connected?e?.channelsError??null:null,r=this.onboarding&&!this.store.channelOnboardingNudgeClosed&&e?.connected&&!e.channelsLoading&&n===null&&t!==null&&t.partial!==!0&&!s(t),i=this.historyOpen&&this.historyAvailable?M({entries:this.historyEntries,error:this.historyError,loaded:this.historyLoaded,loading:this.historyLoading,loadingMore:this.historyLoadingMore,nextCursor:this.historyNextCursor,onLoad:e=>void this.loadHistory(e)}):g;return m` <section class="custodian custodian--page ${this.store.setupRequired?`custodian--setup-required`:``}" > <header class="custodian__header custodian__column ${this.onboarding?`custodian__header--minimal`:``}" > ${this.onboarding?g:m`<div class="custodian__identity"> <div class="custodian__mark" aria-hidden="true"> <openclaw-mascot .mood=${this.store.sending?`thinking`:`idle`} .size=${38} ></openclaw-mascot> </div> <div> <h1>${S(`custodian.title`)}</h1> <p>${S(`custodian.subtitleCaretaker`)}</p> </div> </div>`} <div class="custodian__header-actions"> ${this.onboarding?m`<openclaw-sidebar-attention></openclaw-sidebar-attention>`:g} ${this.historyAvailable?m`<button class="btn btn--ghost custodian__history-toggle" type="button" aria-expanded=${this.historyOpen?`true`:`false`} @click=${()=>this.toggleHistory()} > ${S(`custodian.history.button`)} </button>`:g} ${this.onboarding?m`<button class="btn btn--ghost" type="button" @click=${()=>this.store.exitSetup()} > ${S(`custodian.exitSetup`)} </button>`:g} </div> </header> <openclaw-custodian-surface class="custodian__column" .store=${this.store} .onboarding=${this.onboarding} .newAgentIntent=${this.newAgentIntent} .showChannelOnboardingNudge=${r} .channelOnboardingError=${n} .channelOnboardingRetrying=${e?.channelsLoading??!1} .onRetryChannelOnboarding=${()=>void this.channelsSource?.refresh(!1)} .historyContent=${i} ></openclaw-custodian-surface> </section> `}},n([t({context:y,subscribe:!0})],F.prototype,`context`,void 0),n([_({attribute:!1})],F.prototype,`onboarding`,void 0),n([_({attribute:!1})],F.prototype,`newAgentIntent`,void 0),n([_({attribute:!1})],F.prototype,`store`,void 0),n([h()],F.prototype,`historyAvailable`,void 0),n([h()],F.prototype,`historyOpen`,void 0),n([h()],F.prototype,`historyEntries`,void 0),n([h()],F.prototype,`historyNextCursor`,void 0),n([h()],F.prototype,`historyLoading`,void 0),n([h()],F.prototype,`historyLoadingMore`,void 0),n([h()],F.prototype,`historyError`,void 0),customElements.get(`openclaw-custodian-page`)||customElements.define(`openclaw-custodian-page`,F)})))()}I(); //# sourceMappingURL=custodian-page-04d5od29.js.map