UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.24 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{FN as t,GN as n,JN as r,PN as i,ak as a,fN as o,iT as s,ok as c,pN as l,sT as u}from"./_2_____________________________.js";import{B as d,C as f,L as p,O as m,U as h,d as g,g as _,gt as v,j as y,l as b,s as x,u as S,x as C,yt as w}from"./_6____________________.js";import{dn as T,fn as E,mn as D,pn as O,un as k}from"./control-ui-boot-chat-CqvkfPXD.js";import{n as A,t as j}from"./mcp-app-operation-error-BNu6i_FW.js";function M(e){let n=t(),i=u(n.gateway),[s,c]=d(),l=()=>{let e=s();return e?.current()?e:void 0},[h,x]=p({}),S=!1;v(()=>(S=!0,()=>{S=!1}));let C=w(function*(e,t,n){t()&&x(n=>{n[e]=t}),yield n});async function k(t,r){let o=n.gateway.snapshot.client,s=t.state;if(!o||!s||n.gateway.snapshot.phase!==`connected`)return;let l=a(n.gateway).key,u=e.sessionKey,d=e.agentId,f=()=>(i.read(),S&&n.gateway.snapshot.client===o&&a(n.gateway).key===l&&e.sessionKey===u&&e.agentId===d),p=(async()=>{try{let e=await o.request(`mcp.app.removeModelContext`,{sessionKey:t.sessionKey,agentId:t.agentId,viewId:t.viewId,updateId:s.updateId,...r===void 0?{}:{index:r}});f()&&D(o,u,d).find(e=>e.viewId===t.viewId)?.state?.updateId===s.updateId&&O(o,{...t,state:e.state})}catch(e){if(f())throw e}})(),m=p.then(()=>null);return m.catch(()=>{}),c({current:f,result:m}),await Promise.resolve(),f()?C(t.viewId,f,p).catch(()=>{}):p}var A=N(),M=A.firstChild,R=M.nextSibling;return g(A,y(f,{get each(){return e.entries},children:e=>(()=>{var t=F(),n=t.firstChild,i=n.nextSibling;return g(t,y(f,{get each(){return e.state?.content??[]},children:(t,n)=>{let i=t.type===`image`?`mcpApp.imageContent`:t.type===`text`?`mcpApp.textContent`:`mcpApp.resourceContent`,a=()=>T(t,`${e.title} · ${r(i)}`),s=E(t);var c=I(),l=c.firstChild,u=l.nextSibling;return g(c,s?(()=>{var e=L();return _(e,`src`,s),b(()=>({e:t.type===`resource_link`&&t.icons?.some(e=>e.src===s)===!0,t:a()}),({e:t,t:n},r)=>{t!==r?.e&&e.classList.toggle(`mcp-app-context__icon`,t),n!==r?.t&&_(e,`alt`,n)}),e})():y(o,{name:`fileText`}),l),g(l,a),u._$$click=()=>void k(e,n()),g(u,y(o,{name:`x`})),b(()=>({e:a(),t:h[e.viewId]?.(),a:r(`mcpApp.removeContext`,{title:a()})}),({e,t,a:n},r)=>{e!==r?.e&&_(l,`title`,e),t!==r?.t&&_(u,`disabled`,t),n!==r?.a&&_(u,`aria-label`,n)}),c}}),n),g(t,y(m,{get when(){return e.state?.structuredContent},get children(){var t=P(),n=t.firstChild,i=n.nextSibling;return g(n,()=>e.title),i._$$click=()=>void k(e),g(i,y(o,{name:`x`})),b(()=>({e:h[e.viewId]?.(),t:r(`mcpApp.removeContext`,{title:e.title})}),({e,t},n)=>{e!==n?.e&&_(i,`disabled`,e),t!==n?.t&&_(i,`aria-label`,t)}),t}}),i),t})()}),M),g(A,y(m,{get when(){return l()},keyed:!0,children:e=>y(j,{get result(){return e.result}})}),R),b(()=>r(`mcpApp.contextTitle`),e=>{_(A,`aria-label`,e)}),A}var N,P,F,I,L;function R(){return(R=e((()=>{S(),h(),c(),k(),s(),i(),n(),l(),A(),N=C(`<section class=mcp-app-context><!><!>`),P=C(`<div class=mcp-app-context__item><span></span><button type=button>`),F=C(`<div class=mcp-app-context__items><!><!>`),I=C(`<div class=mcp-app-context__item><span class=mcp-app-context__label></span><button type=button>`),L=C(`<img referrerpolicy=no-referrer loading=lazy>`,1),x([`click`])})))()}R();export{M as McpAppContextStripView};