openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
2 lines • 4.82 kB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./_1____________________________.css","./_0____________________________________.css"])))=>i.map(i=>d[i]);
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{$u as t,Gu as n,Qu as r}from"./_4____________________________.js";import{AN as i,EN as a,FN as o,GN as s,JN as c,PN as l,ak as u,fN as d,iT as f,ok as p,pN as m,sT as h}from"./_2_____________________________.js";import{B as g,C as _,Ct as v,F as y,O as b,S as x,St as S,U as C,W as w,_ as ee,d as T,f as E,g as D,gt as O,j as k,l as A,m as j,s as M,u as N,w as P,x as F}from"./_6____________________.js";import{gn as I}from"./control-ui-boot-chat-CqvkfPXD.js";function L(e){let t=o(),i=h(t.gateway),s=0,l,f;O(()=>()=>{s++});let p=y(()=>(i.read(),JSON.stringify([u(t.gateway).key,e.sessionKey,e.agentId]))),m=y(()=>({identity:p()})),[C,M]=g(!1),[N,F]=g(``),[I,L]=g(()=>(m(),s)),[W,G]=g(()=>(m(),null)),K=y(()=>e.catalog.snapshot().servers.filter(e=>e.mentionTool)),[q,J]=g((e=``)=>{let t=K();return t.length&&!t.some(t=>t.serverName===e)?t[0].serverName:e}),[Y,X]=g(e=>{let t=m(),n=K();return e?.scope===t&&n.some(t=>t.serverName===e.serverName)?e:void 0}),Z=y(()=>Y()?.promise),Q=()=>v(Y)?.generation===v(I)&&S(Z);function $(){return k(b,{get when(){return C()},get children(){return R()}})}function te(){let n=t.gateway.snapshot.client,r=f?.value??q();if(!n||!e.catalog.available()||!r)return;let i=++s,a=m(),o=()=>e.host().isConnected&&s===i&&v(Y)?.generation===i&&t.gateway.snapshot.client===n&&m()===a,c=n.request(`mcp.app.mention`,{sessionKey:e.sessionKey,agentId:e.agentId,serverName:r,query:l?.value??N()}).then(e=>o()?e:void 0,e=>{if(o())throw e});X({scope:a,serverName:r,generation:i,current:o,promise:c}),L(i),G(null)}function ne(n,r){t.gateway.snapshot.phase===`connected`&&r.current()&&(e.host().dispatchEvent(new CustomEvent(`openclaw-mcp-app-resource-mention`,{bubbles:!0,composed:!0,cancelable:!0,detail:{sessionKey:e.sessionKey,agentId:e.agentId,serverName:r.serverName,resource:n}}))?G(c(`mcpApp.errors.mountUnavailable`)):M(!1))}return k(b,{get when(){return K().length},get children(){var t=H(),i=t.firstChild,o=i.firstChild,u=o.nextSibling,p=i.nextSibling,m=p.nextSibling,h=m.nextSibling;return i._$$click=()=>M(e=>!e),T(i,k(d,{name:`link`}),o),T(i,()=>c(`mcpApp.resources`),u),T(t,k(b,{get when(){return C()},get children(){return[(()=>{var e=z();return T(e,()=>c(`mcpApp.resourceDescription`)),e})(),(()=>{var t=B(),n=t.firstChild,r=n.nextSibling,i=r.nextSibling;return t.addEventListener(`submit`,e=>{e.preventDefault(),te()}),n.addEventListener(`change`,e=>{J(e.currentTarget.value),L(++s)}),j(()=>e=>f=e,n),T(n,k(_,{get each(){return K()},keyed:e=>e.serverName,children:e=>(()=>{var t=U();return T(t,()=>e().label),A(()=>e().serverName,e=>{t.value=e}),t})()})),r._$$input=e=>{F(e.currentTarget.value),L(++s)},j(()=>e=>l=e,r),T(i,()=>c(`mcpApp.resourceSearch`)),A(()=>({e:c(`mcpApp.title`),t:q(),a:Q(),o:c(`mcpApp.resourceSearch`),i:c(`mcpApp.resourceQuery`),n:N(),s:Q()||!e.catalog.available()}),({e,t,a,o,i:s,n:c,s:l},u)=>{e!==u?.e&&D(n,`aria-label`,e),ee(n,`value`,t),a!==u?.a&&D(n,`disabled`,a),o!==u?.o&&D(r,`aria-label`,o),s!==u?.i&&D(r,`placeholder`,s),r.value=c??``,l!==u?.s&&D(i,`disabled`,l)}),t})()]}}),p),T(t,k(b,{get when(){return v(Y)},keyed:!0,get fallback(){return k($,{})},children:t=>{let i=y(()=>t.promise),o=w(()=>r(()=>import(`./mcp-app-resource-results-CO-Rpn4m.js`),__vite__mapDeps([0,1]),import.meta.url),{export:`McpAppResourceResults`},`src/components/mcp-app-resource-results.tsx`);return k(x,{fallback:e=>[k($,{}),(()=>{var t=V();return T(t,(()=>{var t=E(()=>n(n(e())?.details)?.code===`MCP_APP_UNSUPPORTED_MENTION_RESULT`);return()=>t()?c(`mcpApp.errors.unsupportedResources`):a(e())})()),t})()],get children(){return k(P,{get fallback(){return k($,{})},get children(){return k(b,{get when(){return i()},keyed:!0,get fallback(){return k($,{})},children:n=>k(b,{get when(){return C()},get children(){return k(b,{get when(){return t.generation===I()},get fallback(){return k($,{})},get children(){return k(o,{get resources(){return n.resources},get disabled(){return Q()||!e.catalog.available()},onAttach:e=>ne(e,t)})}})}})})}})}})}}),m),T(t,k(b,{get when(){return W()},get children(){var e=V();return T(e,W),e}}),h),A(()=>C()?`true`:`false`,e=>{D(i,`aria-expanded`,e)}),t}})}var R,z,B,V,H,U;function W(){return(W=e((()=>{N(),C(),p(),i(),f(),l(),s(),I(),m(),t(),R=F(`<div class=mcp-app-resources__results>`),z=F(`<p class=muted>`),B=F(`<form class=mcp-app-resources__search><select></select><input type=search><button class=btn type=submit>`),V=F(`<p role=alert>`),H=F(`<section class=mcp-app-resources><button type=button class="btn btn--sm"> <!></button><!><!><!>`),U=F(`<option>`),M([`click`,`input`])})))()}W();export{L as McpAppResourcesView};