openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
65 lines • 12.8 kB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./home-session.runtime-DbtjHZUv.js","./rolldown-runtime-DkW27tQK.js","./control-ui-foundation-Cydpkyqa.js","./control-ui-core-Rwzhj6nO.js","./lit-runtime-CV_MH99K.js","./control-ui-core-YphAl4aM.js","./control-ui-core-vvcQQV2m.js","./gateway-runtime-Bqqcp9-I.js","./control-ui-core-ClxHIvNM.css","./control-ui-boot-shared-CXVvK2AW.js","./control-ui-boot-shared-BYq7Cchl.js","./control-ui-boot-shared-Deak_Sjt.js","./control-ui-boot-shared-gfE6fZcA.js","./markdown-runtime-Bn6OdBVq.js","./control-ui-boot-shared-DfZ39Yj9.js","./control-ui-boot-shared-3juXI2I2.js","./control-ui-boot-shared-BVNXvWX-.js","./control-ui-boot-shared-KspYIvAF.css","./control-ui-boot-chat-Bia0O-uD.js","./control-ui-boot-chat-_QSl8fbH.js","./control-ui-boot-chat-Cgwe4GEM.js","./config-runtime-D-5ybyEi.js","./control-ui-boot-chat-CMe3QBDk.js","./control-ui-boot-chat-CazDfK3O.js","./control-ui-boot-chat-BhPddYSI.js","./control-ui-boot-chat-C2G5RI6S.css","./control-ui-boot-chat-D85X0PFX.js"])))=>i.map(i=>d[i]);
import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{Ii as t,R as n,Vn as r,ii as i,ri as a,wr as o,z as s}from"./control-ui-foundation-Cydpkyqa.js";import{As as c,Bi as l,Cc as u,Hs as d,Sc as f,Ts as p,Us as m,Vs as ee,Wi as h,bc as g,os as te,ss as ne,ws as re}from"./control-ui-core-Rwzhj6nO.js";import{$ as ie,K as ae,X as _,at as v,q as y,st as b}from"./lit-runtime-CV_MH99K.js";import{Bt as x,Lt as S,_ as C,cr as w,g as T,ur as E,zt as D}from"./control-ui-core-YphAl4aM.js";import{At as O,Ft as k,Gt as A,I as j,N as M,Nt as N,Ot as P,Pt as F,V as I,Wt as L,Yt as R,d as z,en as B,p as V}from"./control-ui-core-vvcQQV2m.js";import{ir as H,rr as U}from"./control-ui-boot-shared-DfZ39Yj9.js";import{Or as W,kr as G}from"./control-ui-boot-chat-_QSl8fbH.js";import{i as K,r as q,t as J}from"./custodian-surface-B8--KKtk.js";import{S as oe,T as se,w as Y,x as ce,y as le}from"./control-ui-boot-chat-Bia0O-uD.js";import{r as X,t as ue}from"./dock-layout-controller-DJtLlZ8p.js";var Z,Q;function $(){return($=e((()=>{s(),ae(),ie(),k(),G(),C(),D(),E(),H(),R(),te(),l(),c(),f(),se(),ce(),K(),X(),V(),A(),P(),N(),I(),J(),i(),Z={tagName:`openclaw-home-session`,get label(){return B(`assistantPanel.home`)},loadModule:()=>a(()=>import(`./home-session.runtime-DbtjHZUv.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]),import.meta.url)},Q=class extends g{constructor(...e){super(...e),this.custodianAvailable=!1,this.homeAvailable=!1,this.custodianSuppressed=!1,this.pageSessionKey=``,this.pageAgentId=``,this.pageRouteId=`chat`,this.pageRouteFailed=!1,this.homeStarted=!1,this.pendingPrimaryPane=null,this.destination=`custodian`,this.homeLoader=new S(this),this.minimizeRequestId=0,this.store=q,this.dockLayout=new ue(this,{layout:z,reservationPrefix:`assistant`,isAvailable:()=>this.available}),this.onToggleRequest=e=>this.handleToggleRequest(e),this.handledMinimizeRequestId=0,this.targetScope=``,this.homeDefaults={},this.contextCleanup=null,this.subscribedStore=null,this.storeCleanup=null,this.startHomeAfterPrimaryChat=()=>{if(this.homeStarted||!this.dockLayout.open||this.destination!==`home`)return;if(this.pageRouteId!==`chat`||this.pageRouteFailed){this.homeStarted=!0;return}let e=this.primaryChatPane();if(!e?.transcriptReady||this.pendingPrimaryPane===e)return;this.pendingPrimaryPane=e;let t=this.context;Promise.resolve().then(()=>e.updateComplete).then(()=>{this.pendingPrimaryPane===e&&(this.pendingPrimaryPane=null,this.isConnected&&this.context===t&&this.primaryChatPane()===e&&e.transcriptReady&&(this.homeStarted=!0))})}}connectedCallback(){super.connectedCallback(),this.subscribeToStore(),document.addEventListener(U,this.startHomeAfterPrimaryChat),document.addEventListener(Y,this.startHomeAfterPrimaryChat),window.addEventListener(M,this.onToggleRequest),window.addEventListener(j,this.onToggleRequest),this.dockLayout.setSuppressed(this.suppressed),this.refreshCustodianTranscript(this.dockLayout.open)}disconnectedCallback(){document.removeEventListener(U,this.startHomeAfterPrimaryChat),document.removeEventListener(Y,this.startHomeAfterPrimaryChat),this.pendingPrimaryPane=null,window.removeEventListener(M,this.onToggleRequest),window.removeEventListener(j,this.onToggleRequest),this.claimInput(`page`),this.contextCleanup?.(),this.contextCleanup=null,this.storeCleanup?.(),this.storeCleanup=null,this.subscribedStore=null,super.disconnectedCallback()}willUpdate(e){let t=this.dockLayout.open;if(e.has(`context`)&&this.context){this.contextCleanup?.();let e=[oe(this.context,()=>this.requestUpdate()),this.context.agentSelection.subscribe(()=>this.requestUpdate()),this.context.sessions.subscribe(()=>this.requestUpdate()),this.context.agents.subscribe(()=>this.requestUpdate()),this.context.gateway.subscribe(()=>this.requestUpdate())];this.contextCleanup=()=>{for(let t of e)t()}}let n=this.context?.gateway.connection.gatewayUrl??``;if(n!==this.targetScope){this.targetScope=n,this.homeStarted=!1,this.pendingPrimaryPane=null,this.homeDefaults={};let e=null;try{e=r(JSON.parse(u()?.getItem(this.targetStorageKey)??`null`))}catch{}this.destination=e?.destination===`home`?`home`:`custodian`}this.context?.gateway.snapshot.phase===`connected`&&(this.homeDefaults={agentsList:this.context.agents.state.agentsList??this.homeDefaults.agentsList,hello:this.context.gateway.snapshot.hello}),e.has(`store`)&&this.subscribeToStore(),this.dockLayout.setSuppressed(this.suppressed),this.minimizeRequestId>0&&this.minimizeRequestId!==this.handledMinimizeRequestId&&this.custodianAvailable&&(this.handledMinimizeRequestId=this.minimizeRequestId,this.store.hasRealUserTurn()&&this.openDestination(`custodian`)),this.available?this.dockLayout.restoreOpenState():this.dockLayout.hideWithoutPersisting(),this.refreshCustodianTranscript(!t&&this.dockLayout.open),t&&!this.dockLayout.open&&this.claimInput(`page`),this.startHomeAfterPrimaryChat(),this.homeLoader.requestWhileActive(Z,this.dockLayout.open&&this.destination===`home`&&this.homeStarted),this.dockLayout.syncReservation()}primaryChatPane(){return[...(this.closest(`openclaw-app-shell`)??this.parentElement)?.querySelectorAll(`openclaw-chat-pane.chat-pane-cache__pane--active`)??[]].find(e=>e.presented!==!1&&e.sessionKey&&re(e.sessionKey,this.pageSessionKey))}get targetStorageKey(){return`openclaw.assistant.panel.target.v1:${this.targetScope}`}persistTarget(){try{u()?.setItem(this.targetStorageKey,JSON.stringify({destination:this.destination}))}catch{}}get homeTarget(){let e=this.homeDefaults,n=ne(e.agentsList?.agents??[]),r=m(e),i=this.context?.agentSelection.state.selectedId,a=i?t(i):``,o=n.find(e=>e.id===a)?.id??n.find(e=>e.id===r)?.id??n[0]?.id??r;return{...d(e,p({agentId:o,mainKey:ee(e)}),o),agentId:o}}refreshCustodianTranscript(e){e&&this.destination===`custodian`&&this.store.refreshTranscriptIfIdle()}availableFor(e){return e===`home`?this.homeAvailable:this.custodianAvailable}get available(){return this.availableFor(this.destination)}get suppressed(){if(this.destination===`custodian`)return this.custodianSuppressed;if(!this.context||this.pageRouteId!==`chat`)return!1;let e=d(this.homeDefaults,this.pageSessionKey,this.pageAgentId),n=this.homeTarget;return e.sessionKey===n.sessionKey&&t(e.agentId)===n.agentId}claimInput(e){this.context&&W(this.context).claim(e)}openDestination(e){this.destination=e,this.dockLayout.setSuppressed(this.suppressed),this.available&&(this.setOpen(!0),this.suppressed&&(this.dockLayout.hideWithoutPersisting(),this.claimInput(`page`),e===`home`&&this.openHomePage()))}subscribeToStore(){!this.isConnected||this.subscribedStore===this.store||(this.storeCleanup?.(),this.subscribedStore=this.store,this.storeCleanup=this.store.subscribe(()=>this.requestUpdate()))}openHomePage(){if(this.context){let{sessionKey:e,agentId:t}=this.homeTarget,n=h({context:this.context,face:`chat`,sessionKey:e,agentId:t,focusComposer:!0});this.context.navigate(`chat`,n.options)}}setDock(e){this.dockLayout.setDock(e)}setOpen(e){e&&this.destination===`home`&&(this.homeStarted=!0),this.persistTarget(),this.dockLayout.setOpen(e),this.claimInput(e?`dock`:`page`),this.refreshCustodianTranscript(e)}toggle(){if(this.available){if(this.suppressed){this.destination===`home`&&this.openHomePage();return}this.setOpen(!this.dockLayout.open)}}handleToggleRequest(e){let t=e.type===`openclaw:home-toggle`?`home`:`custodian`;if(!this.availableFor(t))return;let n=r(e instanceof CustomEvent?e.detail:null),i=n?.dock;(i===`right`||i===`bottom`)&&this.dockLayout.setDock(i,!1),n?.open===!1?this.destination===t&&this.setOpen(!1):this.destination!==t||n?.open===!0?this.openDestination(t):this.toggle()}get assistantPanelOpen(){return this.dockLayout.open}render(){if(!this.available||!this.dockLayout.open)return y;let e=this.dockLayout.dock,t=this.homeTarget,n=this.homeLoader.visibleState,r=this.context?le(this.context,this.pageRouteId,this.pageSessionKey,this.pageAgentId):void 0,i=e===`bottom`?`height:${this.dockLayout.height}px`:`width:${this.dockLayout.width}px`;return _`
<section
class="assistant-panel assistant-panel--${e}"
style=${i}
aria-label=${B(`assistantPanel.title`)}
=${()=>this.claimInput(`dock`)}
=${()=>this.claimInput(`dock`)}
>
${this.dockLayout.renderResizer(`assistant-panel`,B(`assistantPanel.resize`))}
<header class="rail-header assistant-panel-header" =${w}>
<div class="assistant-panel-title">
<openclaw-mascot
.mood=${this.destination===`custodian`&&this.store.sending?`thinking`:`idle`}
.size=${16}
></openclaw-mascot>
${[`home`,`custodian`].map(e=>(e===`home`?this.homeAvailable:this.custodianAvailable)?_`<button
type="button"
class="assistant-panel-tab"
aria-pressed=${this.destination===e}
=${()=>this.openDestination(e)}
>
${B(e===`home`?`assistantPanel.home`:`nav.askOpenClaw`)}
</button>`:y)}
</div>
<div class="rail-header__actions assistant-panel-actions">
${this.destination===`home`?_`<button
class="rail-header__action assistant-panel-icon"
type="button"
aria-label=${B(`assistantPanel.openHome`)}
=${()=>this.openHomePage()}
>
${L.maximize}
</button>`:y}
<button
class="rail-header__action assistant-panel-icon"
type="button"
aria-label=${B(e===`bottom`?`assistantPanel.dockRight`:`assistantPanel.dockBottom`)}
=${()=>this.setDock(e===`bottom`?`right`:`bottom`)}
>
${e===`bottom`?L.panelRightOpen:L.panelBottomOpen}
</button>
<button
class="rail-header__action assistant-panel-icon"
type="button"
aria-label=${B(`assistantPanel.close`)}
=${()=>this.setOpen(!1)}
>
${L.x}
</button>
</div>
</header>
${this.destination===`home`?_`${this.homeStarted?x(Z)?_`<openclaw-home-session
.sessionKey=${t.sessionKey}
.agentId=${t.agentId}
.workContext=${r}
></openclaw-home-session>`:n?O(n,()=>this.homeLoader.retry(),()=>this.setOpen(!1)):y:F()}`:_`<openclaw-custodian-surface
.store=${this.store}
.onboarding=${this.store.activeVariant===`onboarding`}
.newAgentIntent=${this.store.activeVariant===`new-agent`}
compact
></openclaw-custodian-surface>`}
</section>
`}},o([n({context:T,subscribe:!0}),b({attribute:!1})],Q.prototype,`context`,void 0),o([b({type:Boolean})],Q.prototype,`custodianAvailable`,void 0),o([b({type:Boolean})],Q.prototype,`homeAvailable`,void 0),o([b({type:Boolean})],Q.prototype,`custodianSuppressed`,void 0),o([b()],Q.prototype,`pageSessionKey`,void 0),o([b()],Q.prototype,`pageAgentId`,void 0),o([b()],Q.prototype,`pageRouteId`,void 0),o([b({type:Boolean})],Q.prototype,`pageRouteFailed`,void 0),o([v()],Q.prototype,`homeStarted`,void 0),o([v()],Q.prototype,`destination`,void 0),o([b({type:Number})],Q.prototype,`minimizeRequestId`,void 0),o([b({attribute:!1})],Q.prototype,`store`,void 0),customElements.get(`openclaw-assistant-panel`)||customElements.define(`openclaw-assistant-panel`,Q)})))()}$();export{Q as OpenClawAssistantPanel};
//# sourceMappingURL=assistant-panel-Ph0p7Cpg.js.map