@grackle-ai/web 0.128.0 → 0.129.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{KnowledgePage-BwNjMXpr.js → KnowledgePage-DHgL33sT.js} +1 -1
- package/dist/assets/{McpAppWidget-BeYsqA1A.js → McpAppWidget-BkeYEdnS.js} +1 -1
- package/dist/assets/{grpc-B-DAfHJ_.js → grpc-CSEitK46.js} +5 -5
- package/dist/assets/{index-DDUrxnZo.js → index-B_z-CpZl.js} +6 -6
- package/dist/index.html +2 -2
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as nt,l as rt,b as A,z as it,s as T,m as st,n as X,j as N}from"./dagview-B70jDsRo.js";import{u as at,s as ot,t as ct,a as lt,B as ut,K as ft}from"./index-DDUrxnZo.js";import"./grpc-B-DAfHJ_.js";import"./markdown-CPoGw-1N.js";function ht(t,e){var n,o=1;t==null&&(t=0),e==null&&(e=0);function s(){var r,c=n.length,d,y=0,i=0;for(r=0;r<c;++r)d=n[r],y+=d.x,i+=d.y;for(y=(y/c-t)*o,i=(i/c-e)*o,r=0;r<c;++r)d=n[r],d.x-=y,d.y-=i}return s.initialize=function(r){n=r},s.x=function(r){return arguments.length?(t=+r,s):t},s.y=function(r){return arguments.length?(e=+r,s):e},s.strength=function(r){return arguments.length?(o=+r,s):o},s}function dt(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return q(this.cover(e,n),e,n,t)}function q(t,e,n,o){if(isNaN(e)||isNaN(n))return t;var s,r=t._root,c={data:o},d=t._x0,y=t._y0,i=t._x1,v=t._y1,w,_,h,p,l,a,u,f;if(!r)return t._root=c,t;for(;r.length;)if((l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_,s=r,!(r=r[u=a<<1|l]))return s[u]=c,t;if(h=+t._x.call(null,r.data),p=+t._y.call(null,r.data),e===h&&n===p)return c.next=r,s?s[u]=c:t._root=c,t;do s=s?s[u]=new Array(4):t._root=new Array(4),(l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_;while((u=a<<1|l)===(f=(p>=_)<<1|h>=w));return s[f]=r,s[u]=c,t}function gt(t){var e,n,o=t.length,s,r,c=new Array(o),d=new Array(o),y=1/0,i=1/0,v=-1/0,w=-1/0;for(n=0;n<o;++n)isNaN(s=+this._x.call(null,e=t[n]))||isNaN(r=+this._y.call(null,e))||(c[n]=s,d[n]=r,s<y&&(y=s),s>v&&(v=s),r<i&&(i=r),r>w&&(w=r));if(y>v||i>w)return this;for(this.cover(y,i).cover(v,w),n=0;n<o;++n)q(this,c[n],d[n],t[n]);return this}function xt(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,o=this._y0,s=this._x1,r=this._y1;if(isNaN(n))s=(n=Math.floor(t))+1,r=(o=Math.floor(e))+1;else{for(var c=s-n||1,d=this._root,y,i;n>t||t>=s||o>e||e>=r;)switch(i=(e<o)<<1|t<n,y=new Array(4),y[i]=d,d=y,c*=2,i){case 0:s=n+c,r=o+c;break;case 1:n=s-c,r=o+c;break;case 2:s=n+c,o=r-c;break;case 3:n=s-c,o=r-c;break}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=o,this._x1=s,this._y1=r,this}function _t(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function yt(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function L(t,e,n,o,s){this.node=t,this.x0=e,this.y0=n,this.x1=o,this.y1=s}function vt(t,e,n){var o,s=this._x0,r=this._y0,c,d,y,i,v=this._x1,w=this._y1,_=[],h=this._root,p,l;for(h&&_.push(new L(h,s,r,v,w)),n==null?n=1/0:(s=t-n,r=e-n,v=t+n,w=e+n,n*=n);p=_.pop();)if(!(!(h=p.node)||(c=p.x0)>v||(d=p.y0)>w||(y=p.x1)<s||(i=p.y1)<r))if(h.length){var a=(c+y)/2,u=(d+i)/2;_.push(new L(h[3],a,u,y,i),new L(h[2],c,u,a,i),new L(h[1],a,d,y,u),new L(h[0],c,d,a,u)),(l=(e>=u)<<1|t>=a)&&(p=_[_.length-1],_[_.length-1]=_[_.length-1-l],_[_.length-1-l]=p)}else{var f=t-+this._x.call(null,h.data),m=e-+this._y.call(null,h.data),x=f*f+m*m;if(x<n){var b=Math.sqrt(n=x);s=t-b,r=e-b,v=t+b,w=e+b,o=h.data}}return o}function mt(t){if(isNaN(v=+this._x.call(null,t))||isNaN(w=+this._y.call(null,t)))return this;var e,n=this._root,o,s,r,c=this._x0,d=this._y0,y=this._x1,i=this._y1,v,w,_,h,p,l,a,u;if(!n)return this;if(n.length)for(;;){if((p=v>=(_=(c+y)/2))?c=_:y=_,(l=w>=(h=(d+i)/2))?d=h:i=h,e=n,!(n=n[a=l<<1|p]))return this;if(!n.length)break;(e[a+1&3]||e[a+2&3]||e[a+3&3])&&(o=e,u=a)}for(;n.data!==t;)if(s=n,!(n=n.next))return this;return(r=n.next)&&delete n.next,s?(r?s.next=r:delete s.next,this):e?(r?e[a]=r:delete e[a],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(o?o[u]=n:this._root=n),this):(this._root=r,this)}function pt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function wt(){return this._root}function Nt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function bt(t){var e=[],n,o=this._root,s,r,c,d,y;for(o&&e.push(new L(o,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(o=n.node,r=n.x0,c=n.y0,d=n.x1,y=n.y1)&&o.length){var i=(r+d)/2,v=(c+y)/2;(s=o[3])&&e.push(new L(s,i,v,d,y)),(s=o[2])&&e.push(new L(s,r,v,i,y)),(s=o[1])&&e.push(new L(s,i,c,d,v)),(s=o[0])&&e.push(new L(s,r,c,i,v))}return this}function kt(t){var e=[],n=[],o;for(this._root&&e.push(new L(this._root,this._x0,this._y0,this._x1,this._y1));o=e.pop();){var s=o.node;if(s.length){var r,c=o.x0,d=o.y0,y=o.x1,i=o.y1,v=(c+y)/2,w=(d+i)/2;(r=s[0])&&e.push(new L(r,c,d,v,w)),(r=s[1])&&e.push(new L(r,v,d,y,w)),(r=s[2])&&e.push(new L(r,c,w,v,i)),(r=s[3])&&e.push(new L(r,v,w,y,i))}n.push(o)}for(;o=n.pop();)t(o.node,o.x0,o.y0,o.x1,o.y1);return this}function jt(t){return t[0]}function At(t){return arguments.length?(this._x=t,this):this._x}function Mt(t){return t[1]}function Ct(t){return arguments.length?(this._y=t,this):this._y}function P(t,e,n){var o=new U(e??jt,n??Mt,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function U(t,e,n,o,s,r){this._x=t,this._y=e,this._x0=n,this._y0=o,this._x1=s,this._y1=r,this._root=void 0}function Y(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var R=P.prototype=U.prototype;R.copy=function(){var t=new U(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,o;if(!e)return t;if(!e.length)return t._root=Y(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var s=0;s<4;++s)(o=e.source[s])&&(o.length?n.push({source:o,target:e.target[s]=new Array(4)}):e.target[s]=Y(o));return t};R.add=dt;R.addAll=gt;R.cover=xt;R.data=_t;R.extent=yt;R.find=vt;R.remove=mt;R.removeAll=pt;R.root=wt;R.size=Nt;R.visit=bt;R.visitAfter=kt;R.x=At;R.y=Ct;function O(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function It(t){return t.x+t.vx}function Lt(t){return t.y+t.vy}function Rt(t){var e,n,o,s=1,r=1;typeof t!="function"&&(t=O(t==null?1:+t));function c(){for(var i,v=e.length,w,_,h,p,l,a,u=0;u<r;++u)for(w=P(e,It,Lt).visitAfter(d),i=0;i<v;++i)_=e[i],l=n[_.index],a=l*l,h=_.x+_.vx,p=_.y+_.vy,w.visit(f);function f(m,x,b,M,I){var k=m.data,D=m.r,g=l+D;if(k){if(k.index>_.index){var j=h-k.x-k.vx,z=p-k.y-k.vy,B=j*j+z*z;B<g*g&&(j===0&&(j=S(o),B+=j*j),z===0&&(z=S(o),B+=z*z),B=(g-(B=Math.sqrt(B)))/B*s,_.vx+=(j*=B)*(g=(D*=D)/(a+D)),_.vy+=(z*=B)*g,k.vx-=j*(g=1-g),k.vy-=z*g)}return}return x>h+g||M<h-g||b>p+g||I<p-g}}function d(i){if(i.data)return i.r=n[i.data.index];for(var v=i.r=0;v<4;++v)i[v]&&i[v].r>i.r&&(i.r=i[v].r)}function y(){if(e){var i,v=e.length,w;for(n=new Array(v),i=0;i<v;++i)w=e[i],n[w.index]=+t(w,i,e)}}return c.initialize=function(i,v){e=i,o=v,y()},c.iterations=function(i){return arguments.length?(r=+i,c):r},c.strength=function(i){return arguments.length?(s=+i,c):s},c.radius=function(i){return arguments.length?(t=typeof i=="function"?i:O(+i),y(),c):t},c}function Et(t){return t.index}function W(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Dt(t){var e=Et,n=w,o,s=O(30),r,c,d,y,i,v=1;t==null&&(t=[]);function w(a){return 1/Math.min(d[a.source.index],d[a.target.index])}function _(a){for(var u=0,f=t.length;u<v;++u)for(var m=0,x,b,M,I,k,D,g;m<f;++m)x=t[m],b=x.source,M=x.target,I=M.x+M.vx-b.x-b.vx||S(i),k=M.y+M.vy-b.y-b.vy||S(i),D=Math.sqrt(I*I+k*k),D=(D-r[m])/D*a*o[m],I*=D,k*=D,M.vx-=I*(g=y[m]),M.vy-=k*g,b.vx+=I*(g=1-g),b.vy+=k*g}function h(){if(c){var a,u=c.length,f=t.length,m=new Map(c.map((b,M)=>[e(b,M,c),b])),x;for(a=0,d=new Array(u);a<f;++a)x=t[a],x.index=a,typeof x.source!="object"&&(x.source=W(m,x.source)),typeof x.target!="object"&&(x.target=W(m,x.target)),d[x.source.index]=(d[x.source.index]||0)+1,d[x.target.index]=(d[x.target.index]||0)+1;for(a=0,y=new Array(f);a<f;++a)x=t[a],y[a]=d[x.source.index]/(d[x.source.index]+d[x.target.index]);o=new Array(f),p(),r=new Array(f),l()}}function p(){if(c)for(var a=0,u=t.length;a<u;++a)o[a]=+n(t[a],a,t)}function l(){if(c)for(var a=0,u=t.length;a<u;++a)r[a]=+s(t[a],a,t)}return _.initialize=function(a,u){c=a,i=u,h()},_.links=function(a){return arguments.length?(t=a,h(),_):t},_.id=function(a){return arguments.length?(e=a,_):e},_.iterations=function(a){return arguments.length?(v=+a,_):v},_.strength=function(a){return arguments.length?(n=typeof a=="function"?a:O(+a),p(),_):n},_.distance=function(a){return arguments.length?(s=typeof a=="function"?a:O(+a),l(),_):s},_}const Bt=1664525,zt=1013904223,Q=4294967296;function Tt(){let t=1;return()=>(t=(Bt*t+zt)%Q)/Q}function St(t){return t.x}function $t(t){return t.y}var Gt=10,Ot=Math.PI*(3-Math.sqrt(5));function Ft(t){var e,n=1,o=.001,s=1-Math.pow(o,1/300),r=0,c=.6,d=new Map,y=nt(w),i=rt("tick","end"),v=Tt();t==null&&(t=[]);function w(){_(),i.call("tick",e),n<o&&(y.stop(),i.call("end",e))}function _(l){var a,u=t.length,f;l===void 0&&(l=1);for(var m=0;m<l;++m)for(n+=(r-n)*s,d.forEach(function(x){x(n)}),a=0;a<u;++a)f=t[a],f.fx==null?f.x+=f.vx*=c:(f.x=f.fx,f.vx=0),f.fy==null?f.y+=f.vy*=c:(f.y=f.fy,f.vy=0);return e}function h(){for(var l=0,a=t.length,u;l<a;++l){if(u=t[l],u.index=l,u.fx!=null&&(u.x=u.fx),u.fy!=null&&(u.y=u.fy),isNaN(u.x)||isNaN(u.y)){var f=Gt*Math.sqrt(.5+l),m=l*Ot;u.x=f*Math.cos(m),u.y=f*Math.sin(m)}(isNaN(u.vx)||isNaN(u.vy))&&(u.vx=u.vy=0)}}function p(l){return l.initialize&&l.initialize(t,v),l}return h(),e={tick:_,restart:function(){return y.restart(w),e},stop:function(){return y.stop(),e},nodes:function(l){return arguments.length?(t=l,h(),d.forEach(p),e):t},alpha:function(l){return arguments.length?(n=+l,e):n},alphaMin:function(l){return arguments.length?(o=+l,e):o},alphaDecay:function(l){return arguments.length?(s=+l,e):+s},alphaTarget:function(l){return arguments.length?(r=+l,e):r},velocityDecay:function(l){return arguments.length?(c=1-l,e):1-c},randomSource:function(l){return arguments.length?(v=l,d.forEach(p),e):v},force:function(l,a){return arguments.length>1?(a==null?d.delete(l):d.set(l,p(a)),e):d.get(l)},find:function(l,a,u){var f=0,m=t.length,x,b,M,I,k;for(u==null?u=1/0:u*=u,f=0;f<m;++f)I=t[f],x=l-I.x,b=a-I.y,M=x*x+b*b,M<u&&(k=I,u=M);return k},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Kt(){var t,e,n,o,s=O(-30),r,c=1,d=1/0,y=.81;function i(h){var p,l=t.length,a=P(t,St,$t).visitAfter(w);for(o=h,p=0;p<l;++p)e=t[p],a.visit(_)}function v(){if(t){var h,p=t.length,l;for(r=new Array(p),h=0;h<p;++h)l=t[h],r[l.index]=+s(l,h,t)}}function w(h){var p=0,l,a,u=0,f,m,x;if(h.length){for(f=m=x=0;x<4;++x)(l=h[x])&&(a=Math.abs(l.value))&&(p+=l.value,u+=a,f+=a*l.x,m+=a*l.y);h.x=f/u,h.y=m/u}else{l=h,l.x=l.data.x,l.y=l.data.y;do p+=r[l.data.index];while(l=l.next)}h.value=p}function _(h,p,l,a){if(!h.value)return!0;var u=h.x-e.x,f=h.y-e.y,m=a-p,x=u*u+f*f;if(m*m/y<x)return x<d&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)),e.vx+=u*h.value*o/x,e.vy+=f*h.value*o/x),!0;if(h.length||x>=d)return;(h.data!==e||h.next)&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)));do h.data!==e&&(m=r[h.data.index]*o/x,e.vx+=u*m,e.vy+=f*m);while(h=h.next)}return i.initialize=function(h,p){t=h,n=p,v()},i.strength=function(h){return arguments.length?(s=typeof h=="function"?h:O(+h),v(),i):s},i.distanceMin=function(h){return arguments.length?(c=h*h,i):Math.sqrt(c)},i.distanceMax=function(h){return arguments.length?(d=h*h,i):Math.sqrt(d)},i.theta=function(h){return arguments.length?(y=h*h,i):Math.sqrt(y)},i}const Ht="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Ut="_link_13vy2_18",Xt="_node_13vy2_30",Yt="_nodeCard_13vy2_37",Wt="_nodeLabel_13vy2_43",Qt="_selected_13vy2_47",Vt="_dimmed_13vy2_54",Zt="_dimmedLink_13vy2_59",Jt="_nodeIndicator_13vy2_71",qt="_nodeBadge_13vy2_85",E={graphContainer:Ht,svg:Pt,link:Ut,node:Xt,nodeCard:Yt,nodeLabel:Wt,selected:Qt,dimmed:Vt,dimmedLink:Zt,nodeIndicator:Jt,nodeBadge:qt},K={reference:"#4A9EFF",decision:"#22C55E",insight:"#EAB308",concept:"#A855F7",snippet:"#6B7280"};function V(t){return t.kind==="reference"?K.reference:K[t.category??"insight"]??K.insight}const $=200,G=52,Z=12,F=40,J=3;function te(t,e){if(e.width<=0||e.height<=0)return;let n=1/0,o=-1/0,s=1/0,r=-1/0;for(const l of t){const a=l.x??0,u=l.y??0;a<n&&(n=a),a>o&&(o=a),u<s&&(s=u),u>r&&(r=u)}const c=n-$/2-F,d=o+$/2+F,y=s-G/2-F,i=r+G/2+F,v=d-c,w=i-y,_=Math.min(e.width/v,e.height/w,1),h=(c+d)/2,p=(y+i)/2;return{translateX:e.width/2-h*_,translateY:e.height/2-p*_,scale:_}}function ee({graphData:t,selectedNodeId:e,onNodeClick:n,onNodeDoubleClick:o}){const s=A.useRef(null),r=A.useRef(null),c=A.useRef(void 0),d=A.useRef(void 0),y=A.useRef(void 0),i=A.useRef(void 0),v=A.useRef(e);v.current=e;const w=A.useRef(!1),[_,h]=A.useState({width:800,height:600}),p=A.useRef(0);A.useEffect(()=>{var x;const f=((x=s.current)==null?void 0:x.parentElement)??null;if(!f)return;const m=new ResizeObserver(b=>{for(const M of b)h({width:M.contentRect.width,height:M.contentRect.height})});return m.observe(f),h({width:f.clientWidth,height:f.clientHeight}),()=>{m.disconnect()}},[]),A.useEffect(()=>{if(!s.current||!r.current)return;const f=s.current,m=r.current,x=it().scaleExtent([.1,4]).filter(b=>b.type!=="dblclick").on("zoom",b=>{T(m).attr("transform",String(b.transform))});return T(f).call(x),d.current=x,()=>{T(f).on(".zoom",null)}},[]);const l=A.useRef(n);l.current=n;const a=A.useRef(o);a.current=o,A.useEffect(()=>{if(!r.current)return;const f=r.current;if(c.current&&(c.current.stop(),c.current=void 0),w.current=!1,t.nodes.length===0){T(f).selectAll("*").remove();return}const m=t.nodes.map(g=>({...g})),x=new Map(m.map(g=>[g.id,g])),b=t.links.filter(g=>x.has(g.source)&&x.has(g.target)).map(g=>({source:g.source,target:g.target,type:g.type}));T(f).selectAll("*").remove();const M=T(f).selectAll("line").data(b).enter().append("line").attr("class",E.link);M.append("title").text(g=>g.type),y.current=M;const I=T(f).selectAll("g.kg-node").data(m).enter().append("g").attr("class",`kg-node ${E.node}`).on("click",(g,j)=>{p.current>J||l.current(j.id)}).on("dblclick",(g,j)=>{a.current(j.id)});i.current=I,I.append("rect").attr("class",E.nodeCard).attr("width",$).attr("height",G).attr("rx",Z).attr("ry",Z).style("--node-color",g=>V(g)),I.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",G).attr("rx",2).attr("fill",g=>V(g)),I.append("text").attr("class",E.nodeLabel).attr("x",$/2).attr("y",G/2-4).attr("text-anchor","middle").attr("dominant-baseline","central").text(g=>g.label.length>26?g.label.substring(0,24)+"...":g.label),I.append("text").attr("class",E.nodeBadge).attr("x",$/2).attr("y",G-8).attr("text-anchor","middle").text(g=>(g.kind==="reference"?g.sourceType??"ref":g.category??"").toUpperCase());const k=Ft(m).force("link",Dt(b).id(g=>g.id).distance(140)).force("charge",Kt().strength(-400)).force("center",ht(_.width/2,_.height/2)).force("collide",Rt($/2+16)).on("tick",()=>{M.attr("x1",g=>g.source.x??0).attr("y1",g=>g.source.y??0).attr("x2",g=>g.target.x??0).attr("y2",g=>g.target.y??0),I.attr("transform",g=>`translate(${(g.x??0)-$/2},${(g.y??0)-G/2})`)});c.current=k;const D=st().on("start",(g,j)=>{j.fx=j.x,j.fy=j.y,p.current=0}).on("drag",(g,j)=>{j.fx=g.x,j.fy=g.y,p.current+=Math.abs(g.dx)+Math.abs(g.dy),p.current>J&&k.alphaTarget()===0&&k.alphaTarget(.3).restart()}).on("end",(g,j)=>{g.active||k.alphaTarget(0),j.fx=void 0,j.fy=void 0});return I.call(D),k.on("end",()=>{if(s.current&&d.current&&m.length>0&&!w.current&&!v.current){w.current=!0;const g=te(m,_);if(!g)return;const{translateX:j,translateY:z,scale:B}=g,tt=d.current,et=X.translate(j,z).scale(B);T(s.current).transition().duration(500).call(tt.transform,et)}}),()=>{k.stop()}},[t,_]),A.useEffect(()=>{if(!r.current||!i.current||!y.current)return;if(!e){i.current.classed(E.dimmed,!1).classed(E.selected,!1),y.current.classed(E.dimmedLink,!1);return}const f=new Set([e]);y.current.each(m=>{const x=m.source.id,b=m.target.id;(x===e||b===e)&&(f.add(x),f.add(b))}),i.current.classed(E.selected,m=>m.id===e).classed(E.dimmed,m=>!f.has(m.id)),y.current.classed(E.dimmedLink,m=>{const x=m.source.id,b=m.target.id;return!f.has(x)||!f.has(b)})},[e,t]);const u=A.useCallback(()=>{if(!e||!c.current||!s.current||!d.current)return;const f=c.current.nodes().find(m=>m.id===e);if(f&&Number.isFinite(f.x)&&Number.isFinite(f.y)){const m=d.current,x=X.translate(_.width/2,_.height/2).scale(1.2).translate(-(f.x??0),-(f.y??0));T(s.current).transition().duration(500).call(m.transform,x)}},[e,_]);return A.useEffect(()=>{u()},[u]),N.jsx("div",{className:E.graphContainer,"data-testid":"knowledge-graph",children:N.jsxs("svg",{ref:s,width:_.width,height:_.height,className:E.svg,children:[N.jsx("defs",{children:N.jsxs("filter",{id:"glow",children:[N.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),N.jsxs("feMerge",{children:[N.jsx("feMergeNode",{in:"coloredBlur"}),N.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),N.jsx("g",{ref:r})]})})}const ne="_panel_1ml6r_1",re="_header_1ml6r_24",ie="_title_1ml6r_32",se="_closeButton_1ml6r_42",ae="_body_1ml6r_55",oe="_badge_1ml6r_61",ce="_section_1ml6r_72",le="_sectionLabel_1ml6r_76",ue="_content_1ml6r_84",fe="_tags_1ml6r_92",he="_tag_1ml6r_92",de="_viewLink_1ml6r_107",ge="_edgeList_1ml6r_121",xe="_edgeItem_1ml6r_127",_e="_edgeType_1ml6r_136",ye="_edgeNodeLink_1ml6r_142",ve="_timestamps_1ml6r_154",C={panel:ne,header:re,title:ie,closeButton:se,body:ae,badge:oe,section:ce,sectionLabel:le,content:ue,tags:fe,tag:he,viewLink:de,edgeList:ge,edgeItem:xe,edgeType:_e,edgeNodeLink:ye,timestamps:ve};function me({detail:t,nodes:e,onClose:n,onSelectNode:o}){const s=at(),{node:r,edges:c}=t,d=A.useMemo(()=>new Map(e.map(i=>[i.id,i])),[e]);function y(){if(!(r.kind!=="reference"||!r.sourceId))switch(r.sourceType){case"task":s(ct(r.sourceId));break;case"session":s(ot(r.sourceId));break}}return N.jsxs("div",{className:C.panel,"data-testid":"knowledge-detail-panel",children:[N.jsxs("div",{className:C.header,children:[N.jsx("h3",{className:C.title,children:r.label}),N.jsx("button",{className:C.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),N.jsxs("div",{className:C.body,children:[N.jsx("div",{className:C.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&N.jsxs("div",{className:C.section,children:[N.jsx("div",{className:C.sectionLabel,children:"Content"}),N.jsx("p",{className:C.content,children:r.content})]}),r.tags&&r.tags.length>0&&N.jsxs("div",{className:C.section,children:[N.jsx("div",{className:C.sectionLabel,children:"Tags"}),N.jsx("div",{className:C.tags,children:r.tags.map(i=>N.jsx("span",{className:C.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&N.jsx("div",{className:C.section,children:N.jsx("button",{className:C.viewLink,onClick:y,children:"View in Grackle →"})}),c.length>0&&N.jsxs("div",{className:C.section,children:[N.jsxs("div",{className:C.sectionLabel,children:["Edges (",c.length,")"]}),N.jsx("ul",{className:C.edgeList,children:c.map(i=>{var _;const v=i.fromId===r.id?i.toId:i.fromId,w=`${i.fromId}:${i.toId}:${i.type}`;return N.jsxs("li",{className:C.edgeItem,"data-testid":"edge-item",children:[N.jsx("span",{className:C.edgeType,"data-testid":"edge-type",children:i.type}),N.jsx("button",{className:C.edgeNodeLink,"data-testid":"edge-node-link",onClick:()=>{o(v)},children:((_=d.get(v))==null?void 0:_.label)??`${v.substring(0,8)}...`})]},w)})})]}),N.jsxs("div",{className:C.timestamps,children:[r.createdAt&&N.jsxs("div",{children:["Created: ",new Date(r.createdAt).toLocaleDateString()]}),r.updatedAt&&N.jsxs("div",{children:["Updated: ",new Date(r.updatedAt).toLocaleDateString()]})]})]})]})}const pe="_layout_n9vg6_1",we="_graphArea_n9vg6_8",Ne="_empty_n9vg6_15",H={layout:pe,graphArea:we,empty:Ne};function Me(){const{knowledge:t}=lt();A.useEffect(()=>{t.loadRecent().catch(()=>{})},[t]);const e=A.useCallback(r=>{t.selectNode(r).catch(()=>{})},[t]),n=A.useCallback(r=>{t.expandNode(r).catch(()=>{})},[t]),o=A.useCallback(()=>{t.clearSelection()},[t]),s=[{label:"Knowledge",url:ft}];return N.jsxs("div",{className:H.layout,"data-testid":"knowledge-page",children:[N.jsx(ut,{segments:s}),N.jsxs("div",{className:H.graphArea,children:[t.graphData.nodes.length===0&&!t.loading?N.jsxs("div",{className:H.empty,children:[N.jsx("p",{children:"No knowledge nodes found."}),N.jsx("p",{children:"Create knowledge via MCP tools or let agents discover it during tasks."})]}):N.jsx(ee,{graphData:t.graphData,selectedNodeId:t.selectedId,onNodeClick:e,onNodeDoubleClick:n}),t.selectedNode&&t.selectedId&&N.jsx(me,{detail:t.selectedNode,nodes:t.graphData.nodes,onClose:o,onSelectNode:e})]})]})}export{Me as KnowledgePage};
|
|
1
|
+
import{t as nt,l as rt,b as A,z as it,s as T,m as st,n as X,j as N}from"./dagview-B70jDsRo.js";import{u as at,s as ot,t as ct,a as lt,B as ut,K as ft}from"./index-B_z-CpZl.js";import"./grpc-CSEitK46.js";import"./markdown-CPoGw-1N.js";function ht(t,e){var n,o=1;t==null&&(t=0),e==null&&(e=0);function s(){var r,c=n.length,d,y=0,i=0;for(r=0;r<c;++r)d=n[r],y+=d.x,i+=d.y;for(y=(y/c-t)*o,i=(i/c-e)*o,r=0;r<c;++r)d=n[r],d.x-=y,d.y-=i}return s.initialize=function(r){n=r},s.x=function(r){return arguments.length?(t=+r,s):t},s.y=function(r){return arguments.length?(e=+r,s):e},s.strength=function(r){return arguments.length?(o=+r,s):o},s}function dt(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return q(this.cover(e,n),e,n,t)}function q(t,e,n,o){if(isNaN(e)||isNaN(n))return t;var s,r=t._root,c={data:o},d=t._x0,y=t._y0,i=t._x1,v=t._y1,w,_,h,p,l,a,u,f;if(!r)return t._root=c,t;for(;r.length;)if((l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_,s=r,!(r=r[u=a<<1|l]))return s[u]=c,t;if(h=+t._x.call(null,r.data),p=+t._y.call(null,r.data),e===h&&n===p)return c.next=r,s?s[u]=c:t._root=c,t;do s=s?s[u]=new Array(4):t._root=new Array(4),(l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_;while((u=a<<1|l)===(f=(p>=_)<<1|h>=w));return s[f]=r,s[u]=c,t}function gt(t){var e,n,o=t.length,s,r,c=new Array(o),d=new Array(o),y=1/0,i=1/0,v=-1/0,w=-1/0;for(n=0;n<o;++n)isNaN(s=+this._x.call(null,e=t[n]))||isNaN(r=+this._y.call(null,e))||(c[n]=s,d[n]=r,s<y&&(y=s),s>v&&(v=s),r<i&&(i=r),r>w&&(w=r));if(y>v||i>w)return this;for(this.cover(y,i).cover(v,w),n=0;n<o;++n)q(this,c[n],d[n],t[n]);return this}function xt(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,o=this._y0,s=this._x1,r=this._y1;if(isNaN(n))s=(n=Math.floor(t))+1,r=(o=Math.floor(e))+1;else{for(var c=s-n||1,d=this._root,y,i;n>t||t>=s||o>e||e>=r;)switch(i=(e<o)<<1|t<n,y=new Array(4),y[i]=d,d=y,c*=2,i){case 0:s=n+c,r=o+c;break;case 1:n=s-c,r=o+c;break;case 2:s=n+c,o=r-c;break;case 3:n=s-c,o=r-c;break}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=o,this._x1=s,this._y1=r,this}function _t(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function yt(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function L(t,e,n,o,s){this.node=t,this.x0=e,this.y0=n,this.x1=o,this.y1=s}function vt(t,e,n){var o,s=this._x0,r=this._y0,c,d,y,i,v=this._x1,w=this._y1,_=[],h=this._root,p,l;for(h&&_.push(new L(h,s,r,v,w)),n==null?n=1/0:(s=t-n,r=e-n,v=t+n,w=e+n,n*=n);p=_.pop();)if(!(!(h=p.node)||(c=p.x0)>v||(d=p.y0)>w||(y=p.x1)<s||(i=p.y1)<r))if(h.length){var a=(c+y)/2,u=(d+i)/2;_.push(new L(h[3],a,u,y,i),new L(h[2],c,u,a,i),new L(h[1],a,d,y,u),new L(h[0],c,d,a,u)),(l=(e>=u)<<1|t>=a)&&(p=_[_.length-1],_[_.length-1]=_[_.length-1-l],_[_.length-1-l]=p)}else{var f=t-+this._x.call(null,h.data),m=e-+this._y.call(null,h.data),x=f*f+m*m;if(x<n){var b=Math.sqrt(n=x);s=t-b,r=e-b,v=t+b,w=e+b,o=h.data}}return o}function mt(t){if(isNaN(v=+this._x.call(null,t))||isNaN(w=+this._y.call(null,t)))return this;var e,n=this._root,o,s,r,c=this._x0,d=this._y0,y=this._x1,i=this._y1,v,w,_,h,p,l,a,u;if(!n)return this;if(n.length)for(;;){if((p=v>=(_=(c+y)/2))?c=_:y=_,(l=w>=(h=(d+i)/2))?d=h:i=h,e=n,!(n=n[a=l<<1|p]))return this;if(!n.length)break;(e[a+1&3]||e[a+2&3]||e[a+3&3])&&(o=e,u=a)}for(;n.data!==t;)if(s=n,!(n=n.next))return this;return(r=n.next)&&delete n.next,s?(r?s.next=r:delete s.next,this):e?(r?e[a]=r:delete e[a],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(o?o[u]=n:this._root=n),this):(this._root=r,this)}function pt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function wt(){return this._root}function Nt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function bt(t){var e=[],n,o=this._root,s,r,c,d,y;for(o&&e.push(new L(o,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(o=n.node,r=n.x0,c=n.y0,d=n.x1,y=n.y1)&&o.length){var i=(r+d)/2,v=(c+y)/2;(s=o[3])&&e.push(new L(s,i,v,d,y)),(s=o[2])&&e.push(new L(s,r,v,i,y)),(s=o[1])&&e.push(new L(s,i,c,d,v)),(s=o[0])&&e.push(new L(s,r,c,i,v))}return this}function kt(t){var e=[],n=[],o;for(this._root&&e.push(new L(this._root,this._x0,this._y0,this._x1,this._y1));o=e.pop();){var s=o.node;if(s.length){var r,c=o.x0,d=o.y0,y=o.x1,i=o.y1,v=(c+y)/2,w=(d+i)/2;(r=s[0])&&e.push(new L(r,c,d,v,w)),(r=s[1])&&e.push(new L(r,v,d,y,w)),(r=s[2])&&e.push(new L(r,c,w,v,i)),(r=s[3])&&e.push(new L(r,v,w,y,i))}n.push(o)}for(;o=n.pop();)t(o.node,o.x0,o.y0,o.x1,o.y1);return this}function jt(t){return t[0]}function At(t){return arguments.length?(this._x=t,this):this._x}function Mt(t){return t[1]}function Ct(t){return arguments.length?(this._y=t,this):this._y}function P(t,e,n){var o=new U(e??jt,n??Mt,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function U(t,e,n,o,s,r){this._x=t,this._y=e,this._x0=n,this._y0=o,this._x1=s,this._y1=r,this._root=void 0}function Y(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var R=P.prototype=U.prototype;R.copy=function(){var t=new U(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,o;if(!e)return t;if(!e.length)return t._root=Y(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var s=0;s<4;++s)(o=e.source[s])&&(o.length?n.push({source:o,target:e.target[s]=new Array(4)}):e.target[s]=Y(o));return t};R.add=dt;R.addAll=gt;R.cover=xt;R.data=_t;R.extent=yt;R.find=vt;R.remove=mt;R.removeAll=pt;R.root=wt;R.size=Nt;R.visit=bt;R.visitAfter=kt;R.x=At;R.y=Ct;function O(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function It(t){return t.x+t.vx}function Lt(t){return t.y+t.vy}function Rt(t){var e,n,o,s=1,r=1;typeof t!="function"&&(t=O(t==null?1:+t));function c(){for(var i,v=e.length,w,_,h,p,l,a,u=0;u<r;++u)for(w=P(e,It,Lt).visitAfter(d),i=0;i<v;++i)_=e[i],l=n[_.index],a=l*l,h=_.x+_.vx,p=_.y+_.vy,w.visit(f);function f(m,x,b,M,I){var k=m.data,D=m.r,g=l+D;if(k){if(k.index>_.index){var j=h-k.x-k.vx,z=p-k.y-k.vy,B=j*j+z*z;B<g*g&&(j===0&&(j=S(o),B+=j*j),z===0&&(z=S(o),B+=z*z),B=(g-(B=Math.sqrt(B)))/B*s,_.vx+=(j*=B)*(g=(D*=D)/(a+D)),_.vy+=(z*=B)*g,k.vx-=j*(g=1-g),k.vy-=z*g)}return}return x>h+g||M<h-g||b>p+g||I<p-g}}function d(i){if(i.data)return i.r=n[i.data.index];for(var v=i.r=0;v<4;++v)i[v]&&i[v].r>i.r&&(i.r=i[v].r)}function y(){if(e){var i,v=e.length,w;for(n=new Array(v),i=0;i<v;++i)w=e[i],n[w.index]=+t(w,i,e)}}return c.initialize=function(i,v){e=i,o=v,y()},c.iterations=function(i){return arguments.length?(r=+i,c):r},c.strength=function(i){return arguments.length?(s=+i,c):s},c.radius=function(i){return arguments.length?(t=typeof i=="function"?i:O(+i),y(),c):t},c}function Et(t){return t.index}function W(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Dt(t){var e=Et,n=w,o,s=O(30),r,c,d,y,i,v=1;t==null&&(t=[]);function w(a){return 1/Math.min(d[a.source.index],d[a.target.index])}function _(a){for(var u=0,f=t.length;u<v;++u)for(var m=0,x,b,M,I,k,D,g;m<f;++m)x=t[m],b=x.source,M=x.target,I=M.x+M.vx-b.x-b.vx||S(i),k=M.y+M.vy-b.y-b.vy||S(i),D=Math.sqrt(I*I+k*k),D=(D-r[m])/D*a*o[m],I*=D,k*=D,M.vx-=I*(g=y[m]),M.vy-=k*g,b.vx+=I*(g=1-g),b.vy+=k*g}function h(){if(c){var a,u=c.length,f=t.length,m=new Map(c.map((b,M)=>[e(b,M,c),b])),x;for(a=0,d=new Array(u);a<f;++a)x=t[a],x.index=a,typeof x.source!="object"&&(x.source=W(m,x.source)),typeof x.target!="object"&&(x.target=W(m,x.target)),d[x.source.index]=(d[x.source.index]||0)+1,d[x.target.index]=(d[x.target.index]||0)+1;for(a=0,y=new Array(f);a<f;++a)x=t[a],y[a]=d[x.source.index]/(d[x.source.index]+d[x.target.index]);o=new Array(f),p(),r=new Array(f),l()}}function p(){if(c)for(var a=0,u=t.length;a<u;++a)o[a]=+n(t[a],a,t)}function l(){if(c)for(var a=0,u=t.length;a<u;++a)r[a]=+s(t[a],a,t)}return _.initialize=function(a,u){c=a,i=u,h()},_.links=function(a){return arguments.length?(t=a,h(),_):t},_.id=function(a){return arguments.length?(e=a,_):e},_.iterations=function(a){return arguments.length?(v=+a,_):v},_.strength=function(a){return arguments.length?(n=typeof a=="function"?a:O(+a),p(),_):n},_.distance=function(a){return arguments.length?(s=typeof a=="function"?a:O(+a),l(),_):s},_}const Bt=1664525,zt=1013904223,Q=4294967296;function Tt(){let t=1;return()=>(t=(Bt*t+zt)%Q)/Q}function St(t){return t.x}function $t(t){return t.y}var Gt=10,Ot=Math.PI*(3-Math.sqrt(5));function Ft(t){var e,n=1,o=.001,s=1-Math.pow(o,1/300),r=0,c=.6,d=new Map,y=nt(w),i=rt("tick","end"),v=Tt();t==null&&(t=[]);function w(){_(),i.call("tick",e),n<o&&(y.stop(),i.call("end",e))}function _(l){var a,u=t.length,f;l===void 0&&(l=1);for(var m=0;m<l;++m)for(n+=(r-n)*s,d.forEach(function(x){x(n)}),a=0;a<u;++a)f=t[a],f.fx==null?f.x+=f.vx*=c:(f.x=f.fx,f.vx=0),f.fy==null?f.y+=f.vy*=c:(f.y=f.fy,f.vy=0);return e}function h(){for(var l=0,a=t.length,u;l<a;++l){if(u=t[l],u.index=l,u.fx!=null&&(u.x=u.fx),u.fy!=null&&(u.y=u.fy),isNaN(u.x)||isNaN(u.y)){var f=Gt*Math.sqrt(.5+l),m=l*Ot;u.x=f*Math.cos(m),u.y=f*Math.sin(m)}(isNaN(u.vx)||isNaN(u.vy))&&(u.vx=u.vy=0)}}function p(l){return l.initialize&&l.initialize(t,v),l}return h(),e={tick:_,restart:function(){return y.restart(w),e},stop:function(){return y.stop(),e},nodes:function(l){return arguments.length?(t=l,h(),d.forEach(p),e):t},alpha:function(l){return arguments.length?(n=+l,e):n},alphaMin:function(l){return arguments.length?(o=+l,e):o},alphaDecay:function(l){return arguments.length?(s=+l,e):+s},alphaTarget:function(l){return arguments.length?(r=+l,e):r},velocityDecay:function(l){return arguments.length?(c=1-l,e):1-c},randomSource:function(l){return arguments.length?(v=l,d.forEach(p),e):v},force:function(l,a){return arguments.length>1?(a==null?d.delete(l):d.set(l,p(a)),e):d.get(l)},find:function(l,a,u){var f=0,m=t.length,x,b,M,I,k;for(u==null?u=1/0:u*=u,f=0;f<m;++f)I=t[f],x=l-I.x,b=a-I.y,M=x*x+b*b,M<u&&(k=I,u=M);return k},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Kt(){var t,e,n,o,s=O(-30),r,c=1,d=1/0,y=.81;function i(h){var p,l=t.length,a=P(t,St,$t).visitAfter(w);for(o=h,p=0;p<l;++p)e=t[p],a.visit(_)}function v(){if(t){var h,p=t.length,l;for(r=new Array(p),h=0;h<p;++h)l=t[h],r[l.index]=+s(l,h,t)}}function w(h){var p=0,l,a,u=0,f,m,x;if(h.length){for(f=m=x=0;x<4;++x)(l=h[x])&&(a=Math.abs(l.value))&&(p+=l.value,u+=a,f+=a*l.x,m+=a*l.y);h.x=f/u,h.y=m/u}else{l=h,l.x=l.data.x,l.y=l.data.y;do p+=r[l.data.index];while(l=l.next)}h.value=p}function _(h,p,l,a){if(!h.value)return!0;var u=h.x-e.x,f=h.y-e.y,m=a-p,x=u*u+f*f;if(m*m/y<x)return x<d&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)),e.vx+=u*h.value*o/x,e.vy+=f*h.value*o/x),!0;if(h.length||x>=d)return;(h.data!==e||h.next)&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)));do h.data!==e&&(m=r[h.data.index]*o/x,e.vx+=u*m,e.vy+=f*m);while(h=h.next)}return i.initialize=function(h,p){t=h,n=p,v()},i.strength=function(h){return arguments.length?(s=typeof h=="function"?h:O(+h),v(),i):s},i.distanceMin=function(h){return arguments.length?(c=h*h,i):Math.sqrt(c)},i.distanceMax=function(h){return arguments.length?(d=h*h,i):Math.sqrt(d)},i.theta=function(h){return arguments.length?(y=h*h,i):Math.sqrt(y)},i}const Ht="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Ut="_link_13vy2_18",Xt="_node_13vy2_30",Yt="_nodeCard_13vy2_37",Wt="_nodeLabel_13vy2_43",Qt="_selected_13vy2_47",Vt="_dimmed_13vy2_54",Zt="_dimmedLink_13vy2_59",Jt="_nodeIndicator_13vy2_71",qt="_nodeBadge_13vy2_85",E={graphContainer:Ht,svg:Pt,link:Ut,node:Xt,nodeCard:Yt,nodeLabel:Wt,selected:Qt,dimmed:Vt,dimmedLink:Zt,nodeIndicator:Jt,nodeBadge:qt},K={reference:"#4A9EFF",decision:"#22C55E",insight:"#EAB308",concept:"#A855F7",snippet:"#6B7280"};function V(t){return t.kind==="reference"?K.reference:K[t.category??"insight"]??K.insight}const $=200,G=52,Z=12,F=40,J=3;function te(t,e){if(e.width<=0||e.height<=0)return;let n=1/0,o=-1/0,s=1/0,r=-1/0;for(const l of t){const a=l.x??0,u=l.y??0;a<n&&(n=a),a>o&&(o=a),u<s&&(s=u),u>r&&(r=u)}const c=n-$/2-F,d=o+$/2+F,y=s-G/2-F,i=r+G/2+F,v=d-c,w=i-y,_=Math.min(e.width/v,e.height/w,1),h=(c+d)/2,p=(y+i)/2;return{translateX:e.width/2-h*_,translateY:e.height/2-p*_,scale:_}}function ee({graphData:t,selectedNodeId:e,onNodeClick:n,onNodeDoubleClick:o}){const s=A.useRef(null),r=A.useRef(null),c=A.useRef(void 0),d=A.useRef(void 0),y=A.useRef(void 0),i=A.useRef(void 0),v=A.useRef(e);v.current=e;const w=A.useRef(!1),[_,h]=A.useState({width:800,height:600}),p=A.useRef(0);A.useEffect(()=>{var x;const f=((x=s.current)==null?void 0:x.parentElement)??null;if(!f)return;const m=new ResizeObserver(b=>{for(const M of b)h({width:M.contentRect.width,height:M.contentRect.height})});return m.observe(f),h({width:f.clientWidth,height:f.clientHeight}),()=>{m.disconnect()}},[]),A.useEffect(()=>{if(!s.current||!r.current)return;const f=s.current,m=r.current,x=it().scaleExtent([.1,4]).filter(b=>b.type!=="dblclick").on("zoom",b=>{T(m).attr("transform",String(b.transform))});return T(f).call(x),d.current=x,()=>{T(f).on(".zoom",null)}},[]);const l=A.useRef(n);l.current=n;const a=A.useRef(o);a.current=o,A.useEffect(()=>{if(!r.current)return;const f=r.current;if(c.current&&(c.current.stop(),c.current=void 0),w.current=!1,t.nodes.length===0){T(f).selectAll("*").remove();return}const m=t.nodes.map(g=>({...g})),x=new Map(m.map(g=>[g.id,g])),b=t.links.filter(g=>x.has(g.source)&&x.has(g.target)).map(g=>({source:g.source,target:g.target,type:g.type}));T(f).selectAll("*").remove();const M=T(f).selectAll("line").data(b).enter().append("line").attr("class",E.link);M.append("title").text(g=>g.type),y.current=M;const I=T(f).selectAll("g.kg-node").data(m).enter().append("g").attr("class",`kg-node ${E.node}`).on("click",(g,j)=>{p.current>J||l.current(j.id)}).on("dblclick",(g,j)=>{a.current(j.id)});i.current=I,I.append("rect").attr("class",E.nodeCard).attr("width",$).attr("height",G).attr("rx",Z).attr("ry",Z).style("--node-color",g=>V(g)),I.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",G).attr("rx",2).attr("fill",g=>V(g)),I.append("text").attr("class",E.nodeLabel).attr("x",$/2).attr("y",G/2-4).attr("text-anchor","middle").attr("dominant-baseline","central").text(g=>g.label.length>26?g.label.substring(0,24)+"...":g.label),I.append("text").attr("class",E.nodeBadge).attr("x",$/2).attr("y",G-8).attr("text-anchor","middle").text(g=>(g.kind==="reference"?g.sourceType??"ref":g.category??"").toUpperCase());const k=Ft(m).force("link",Dt(b).id(g=>g.id).distance(140)).force("charge",Kt().strength(-400)).force("center",ht(_.width/2,_.height/2)).force("collide",Rt($/2+16)).on("tick",()=>{M.attr("x1",g=>g.source.x??0).attr("y1",g=>g.source.y??0).attr("x2",g=>g.target.x??0).attr("y2",g=>g.target.y??0),I.attr("transform",g=>`translate(${(g.x??0)-$/2},${(g.y??0)-G/2})`)});c.current=k;const D=st().on("start",(g,j)=>{j.fx=j.x,j.fy=j.y,p.current=0}).on("drag",(g,j)=>{j.fx=g.x,j.fy=g.y,p.current+=Math.abs(g.dx)+Math.abs(g.dy),p.current>J&&k.alphaTarget()===0&&k.alphaTarget(.3).restart()}).on("end",(g,j)=>{g.active||k.alphaTarget(0),j.fx=void 0,j.fy=void 0});return I.call(D),k.on("end",()=>{if(s.current&&d.current&&m.length>0&&!w.current&&!v.current){w.current=!0;const g=te(m,_);if(!g)return;const{translateX:j,translateY:z,scale:B}=g,tt=d.current,et=X.translate(j,z).scale(B);T(s.current).transition().duration(500).call(tt.transform,et)}}),()=>{k.stop()}},[t,_]),A.useEffect(()=>{if(!r.current||!i.current||!y.current)return;if(!e){i.current.classed(E.dimmed,!1).classed(E.selected,!1),y.current.classed(E.dimmedLink,!1);return}const f=new Set([e]);y.current.each(m=>{const x=m.source.id,b=m.target.id;(x===e||b===e)&&(f.add(x),f.add(b))}),i.current.classed(E.selected,m=>m.id===e).classed(E.dimmed,m=>!f.has(m.id)),y.current.classed(E.dimmedLink,m=>{const x=m.source.id,b=m.target.id;return!f.has(x)||!f.has(b)})},[e,t]);const u=A.useCallback(()=>{if(!e||!c.current||!s.current||!d.current)return;const f=c.current.nodes().find(m=>m.id===e);if(f&&Number.isFinite(f.x)&&Number.isFinite(f.y)){const m=d.current,x=X.translate(_.width/2,_.height/2).scale(1.2).translate(-(f.x??0),-(f.y??0));T(s.current).transition().duration(500).call(m.transform,x)}},[e,_]);return A.useEffect(()=>{u()},[u]),N.jsx("div",{className:E.graphContainer,"data-testid":"knowledge-graph",children:N.jsxs("svg",{ref:s,width:_.width,height:_.height,className:E.svg,children:[N.jsx("defs",{children:N.jsxs("filter",{id:"glow",children:[N.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),N.jsxs("feMerge",{children:[N.jsx("feMergeNode",{in:"coloredBlur"}),N.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),N.jsx("g",{ref:r})]})})}const ne="_panel_1ml6r_1",re="_header_1ml6r_24",ie="_title_1ml6r_32",se="_closeButton_1ml6r_42",ae="_body_1ml6r_55",oe="_badge_1ml6r_61",ce="_section_1ml6r_72",le="_sectionLabel_1ml6r_76",ue="_content_1ml6r_84",fe="_tags_1ml6r_92",he="_tag_1ml6r_92",de="_viewLink_1ml6r_107",ge="_edgeList_1ml6r_121",xe="_edgeItem_1ml6r_127",_e="_edgeType_1ml6r_136",ye="_edgeNodeLink_1ml6r_142",ve="_timestamps_1ml6r_154",C={panel:ne,header:re,title:ie,closeButton:se,body:ae,badge:oe,section:ce,sectionLabel:le,content:ue,tags:fe,tag:he,viewLink:de,edgeList:ge,edgeItem:xe,edgeType:_e,edgeNodeLink:ye,timestamps:ve};function me({detail:t,nodes:e,onClose:n,onSelectNode:o}){const s=at(),{node:r,edges:c}=t,d=A.useMemo(()=>new Map(e.map(i=>[i.id,i])),[e]);function y(){if(!(r.kind!=="reference"||!r.sourceId))switch(r.sourceType){case"task":s(ct(r.sourceId));break;case"session":s(ot(r.sourceId));break}}return N.jsxs("div",{className:C.panel,"data-testid":"knowledge-detail-panel",children:[N.jsxs("div",{className:C.header,children:[N.jsx("h3",{className:C.title,children:r.label}),N.jsx("button",{className:C.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),N.jsxs("div",{className:C.body,children:[N.jsx("div",{className:C.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&N.jsxs("div",{className:C.section,children:[N.jsx("div",{className:C.sectionLabel,children:"Content"}),N.jsx("p",{className:C.content,children:r.content})]}),r.tags&&r.tags.length>0&&N.jsxs("div",{className:C.section,children:[N.jsx("div",{className:C.sectionLabel,children:"Tags"}),N.jsx("div",{className:C.tags,children:r.tags.map(i=>N.jsx("span",{className:C.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&N.jsx("div",{className:C.section,children:N.jsx("button",{className:C.viewLink,onClick:y,children:"View in Grackle →"})}),c.length>0&&N.jsxs("div",{className:C.section,children:[N.jsxs("div",{className:C.sectionLabel,children:["Edges (",c.length,")"]}),N.jsx("ul",{className:C.edgeList,children:c.map(i=>{var _;const v=i.fromId===r.id?i.toId:i.fromId,w=`${i.fromId}:${i.toId}:${i.type}`;return N.jsxs("li",{className:C.edgeItem,"data-testid":"edge-item",children:[N.jsx("span",{className:C.edgeType,"data-testid":"edge-type",children:i.type}),N.jsx("button",{className:C.edgeNodeLink,"data-testid":"edge-node-link",onClick:()=>{o(v)},children:((_=d.get(v))==null?void 0:_.label)??`${v.substring(0,8)}...`})]},w)})})]}),N.jsxs("div",{className:C.timestamps,children:[r.createdAt&&N.jsxs("div",{children:["Created: ",new Date(r.createdAt).toLocaleDateString()]}),r.updatedAt&&N.jsxs("div",{children:["Updated: ",new Date(r.updatedAt).toLocaleDateString()]})]})]})]})}const pe="_layout_n9vg6_1",we="_graphArea_n9vg6_8",Ne="_empty_n9vg6_15",H={layout:pe,graphArea:we,empty:Ne};function Me(){const{knowledge:t}=lt();A.useEffect(()=>{t.loadRecent().catch(()=>{})},[t]);const e=A.useCallback(r=>{t.selectNode(r).catch(()=>{})},[t]),n=A.useCallback(r=>{t.expandNode(r).catch(()=>{})},[t]),o=A.useCallback(()=>{t.clearSelection()},[t]),s=[{label:"Knowledge",url:ft}];return N.jsxs("div",{className:H.layout,"data-testid":"knowledge-page",children:[N.jsx(ut,{segments:s}),N.jsxs("div",{className:H.graphArea,children:[t.graphData.nodes.length===0&&!t.loading?N.jsxs("div",{className:H.empty,children:[N.jsx("p",{children:"No knowledge nodes found."}),N.jsx("p",{children:"Create knowledge via MCP tools or let agents discover it during tasks."})]}):N.jsx(ee,{graphData:t.graphData,selectedNodeId:t.selectedId,onNodeClick:e,onNodeDoubleClick:n}),t.selectedNode&&t.selectedId&&N.jsx(me,{detail:t.selectedNode,nodes:t.graphData.nodes,onClose:o,onSelectNode:e})]})]})}export{Me as KnowledgePage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Mt=Object.defineProperty;var Nt=(l,o,e)=>o in l?Mt(l,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[o]=e;var m=(l,o,e)=>Nt(l,typeof o!="symbol"?o+"":o,e);import{b as K,j as Lt}from"./dagview-B70jDsRo.js";import{l as a,k as x,r as S,m as h,u as f,o as r,s as n,n as v,q as p,_ as $,v as z,x as At,y as q,z as zt,B as Xe,E as et,F as Ut,H as tt,I as Ot,J as we,K as Je}from"./grpc-B-DAfHJ_.js";const Dt={"--color-background-primary":"light-dark(#ffffff, #1a1a1a)","--color-background-secondary":"light-dark(#f5f5f5, #2d2d2d)","--color-background-tertiary":"light-dark(#e5e5e5, #404040)","--color-background-inverse":"light-dark(#1a1a1a, #ffffff)","--color-background-ghost":"light-dark(rgba(255,255,255,0), rgba(26,26,26,0))","--color-background-info":"light-dark(#eff6ff, #1e3a5f)","--color-background-danger":"light-dark(#fef2f2, #7f1d1d)","--color-background-success":"light-dark(#f0fdf4, #14532d)","--color-background-warning":"light-dark(#fefce8, #713f12)","--color-background-disabled":"light-dark(rgba(255,255,255,0.5), rgba(26,26,26,0.5))","--color-text-primary":"light-dark(#1f2937, #f3f4f6)","--color-text-secondary":"light-dark(#6b7280, #9ca3af)","--color-text-tertiary":"light-dark(#9ca3af, #6b7280)","--color-text-inverse":"light-dark(#f3f4f6, #1f2937)","--color-text-ghost":"light-dark(rgba(107,114,128,0.5), rgba(156,163,175,0.5))","--color-text-info":"light-dark(#1d4ed8, #60a5fa)","--color-text-danger":"light-dark(#b91c1c, #f87171)","--color-text-success":"light-dark(#15803d, #4ade80)","--color-text-warning":"light-dark(#a16207, #fbbf24)","--color-text-disabled":"light-dark(rgba(31,41,55,0.5), rgba(243,244,246,0.5))","--color-border-primary":"light-dark(#e5e7eb, #404040)","--color-border-secondary":"light-dark(#d1d5db, #525252)","--color-border-tertiary":"light-dark(#f3f4f6, #374151)","--color-border-inverse":"light-dark(rgba(255,255,255,0.3), rgba(0,0,0,0.3))","--color-border-ghost":"light-dark(rgba(229,231,235,0), rgba(64,64,64,0))","--color-border-info":"light-dark(#93c5fd, #1e40af)","--color-border-danger":"light-dark(#fca5a5, #991b1b)","--color-border-success":"light-dark(#86efac, #166534)","--color-border-warning":"light-dark(#fde047, #854d0e)","--color-border-disabled":"light-dark(rgba(229,231,235,0.5), rgba(64,64,64,0.5))","--color-ring-primary":"light-dark(#3b82f6, #60a5fa)","--color-ring-secondary":"light-dark(#6b7280, #9ca3af)","--color-ring-inverse":"light-dark(#ffffff, #1f2937)","--color-ring-info":"light-dark(#2563eb, #3b82f6)","--color-ring-danger":"light-dark(#dc2626, #ef4444)","--color-ring-success":"light-dark(#16a34a, #22c55e)","--color-ring-warning":"light-dark(#ca8a04, #eab308)","--font-sans":"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif","--font-mono":"ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', monospace","--font-weight-normal":"400","--font-weight-medium":"500","--font-weight-semibold":"600","--font-weight-bold":"700","--font-text-xs-size":"0.75rem","--font-text-sm-size":"0.875rem","--font-text-md-size":"1rem","--font-text-lg-size":"1.125rem","--font-heading-xs-size":"0.75rem","--font-heading-sm-size":"0.875rem","--font-heading-md-size":"1rem","--font-heading-lg-size":"1.25rem","--font-heading-xl-size":"1.5rem","--font-heading-2xl-size":"1.875rem","--font-heading-3xl-size":"2.25rem","--font-text-xs-line-height":"1.4","--font-text-sm-line-height":"1.4","--font-text-md-line-height":"1.5","--font-text-lg-line-height":"1.5","--font-heading-xs-line-height":"1.4","--font-heading-sm-line-height":"1.4","--font-heading-md-line-height":"1.4","--font-heading-lg-line-height":"1.3","--font-heading-xl-line-height":"1.25","--font-heading-2xl-line-height":"1.2","--font-heading-3xl-line-height":"1.1","--border-radius-xs":"2px","--border-radius-sm":"4px","--border-radius-md":"6px","--border-radius-lg":"8px","--border-radius-xl":"12px","--border-radius-full":"9999px","--border-width-regular":"1px","--shadow-hairline":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--shadow-sm":"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)","--shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)","--shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)"},$t={"--color-background-primary":"--bg-base","--color-background-secondary":"--bg-surface","--color-background-tertiary":"--bg-elevated","--color-text-primary":"--text-primary","--color-text-secondary":"--text-secondary","--color-text-tertiary":"--text-tertiary","--color-border-primary":"--border-primary","--color-border-secondary":"--border-subtle","--font-sans":"--font-sans","--font-mono":"--font-mono","--border-radius-sm":"--radius-sm","--border-radius-md":"--radius-md","--border-radius-lg":"--radius-lg","--border-radius-full":"--radius-full"};function Ve(){const l={...Dt};if(typeof window>"u"||typeof document>"u")return l;const o=window.getComputedStyle(document.documentElement),e=l;for(const[t,s]of Object.entries($t)){const i=o.getPropertyValue(s).trim();i&&(e[t]=i)}return l}const Y="io.modelcontextprotocol/related-task",ye="2.0",H=At(l=>l!==null&&(typeof l=="object"||typeof l=="function")),st=f([n(),p().int()]),ot=n();z({ttl:p().optional(),pollInterval:p().optional()});const Ft=r({ttl:p().optional()}),jt=r({taskId:n()}),xe=z({progressToken:st.optional(),[Y]:jt.optional()}),U=r({_meta:xe.optional()}),ne=U.extend({task:Ft.optional()}),Bt=l=>ne.safeParse(l).success,N=r({method:n(),params:U.loose().optional()}),F=r({_meta:xe.optional()}),j=r({method:n(),params:F.loose().optional()}),L=z({_meta:xe.optional()}),re=f([n(),p().int()]),at=r({jsonrpc:a(ye),id:re,...N.shape}).strict(),Qe=l=>at.safeParse(l).success,nt=r({jsonrpc:a(ye),...j.shape}).strict(),Jt=l=>nt.safeParse(l).success,Re=r({jsonrpc:a(ye),id:re,result:L}).strict(),fe=l=>Re.safeParse(l).success;var k;(function(l){l[l.ConnectionClosed=-32e3]="ConnectionClosed",l[l.RequestTimeout=-32001]="RequestTimeout",l[l.ParseError=-32700]="ParseError",l[l.InvalidRequest=-32600]="InvalidRequest",l[l.MethodNotFound=-32601]="MethodNotFound",l[l.InvalidParams=-32602]="InvalidParams",l[l.InternalError=-32603]="InternalError",l[l.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(k||(k={}));const ve=r({jsonrpc:a(ye),id:re.optional(),error:r({code:p().int(),message:n(),data:v().optional()})}).strict(),Vt=l=>ve.safeParse(l).success,Qt=f([at,nt,Re,ve]);f([Re,ve]);const rt=L.strict(),Wt=F.extend({requestId:re.optional(),reason:n().optional()}),Te=j.extend({method:a("notifications/cancelled"),params:Wt}),Kt=r({src:n(),mimeType:n().optional(),sizes:h(n()).optional(),theme:$(["light","dark"]).optional()}),ie=r({icons:h(Kt).optional()}),Z=r({name:n(),title:n().optional()}),Se=Z.extend({...Z.shape,...ie.shape,version:n(),websiteUrl:n().optional(),description:n().optional()}),Gt=Xe(r({applyDefaults:x().optional()}),S(n(),v())),Yt=et(l=>l&&typeof l=="object"&&!Array.isArray(l)&&Object.keys(l).length===0?{form:{}}:l,Xe(r({form:Gt.optional(),url:H.optional()}),S(n(),v()).optional())),Zt=z({list:H.optional(),cancel:H.optional(),requests:z({sampling:z({createMessage:H.optional()}).optional(),elicitation:z({create:H.optional()}).optional()}).optional()}),Xt=z({list:H.optional(),cancel:H.optional(),requests:z({tools:z({call:H.optional()}).optional()}).optional()}),es=r({experimental:S(n(),H).optional(),sampling:r({context:H.optional(),tools:H.optional()}).optional(),elicitation:Yt.optional(),roots:r({listChanged:x().optional()}).optional(),tasks:Zt.optional(),extensions:S(n(),H).optional()}),ts=U.extend({protocolVersion:n(),capabilities:es,clientInfo:Se}),ss=N.extend({method:a("initialize"),params:ts}),os=r({experimental:S(n(),H).optional(),logging:H.optional(),completions:H.optional(),prompts:r({listChanged:x().optional()}).optional(),resources:r({subscribe:x().optional(),listChanged:x().optional()}).optional(),tools:r({listChanged:x().optional()}).optional(),tasks:Xt.optional(),extensions:S(n(),H).optional()}),as=L.extend({protocolVersion:n(),capabilities:os,serverInfo:Se,instructions:n().optional()}),ns=j.extend({method:a("notifications/initialized"),params:F.optional()}),ke=N.extend({method:a("ping"),params:U.optional()}),rs=r({progress:p(),total:q(p()),message:q(n())}),is=r({...F.shape,...rs.shape,progressToken:st}),qe=j.extend({method:a("notifications/progress"),params:is}),ls=U.extend({cursor:ot.optional()}),le=N.extend({params:ls.optional()}),ce=L.extend({nextCursor:ot.optional()}),cs=$(["working","input_required","completed","failed","cancelled"]),de=r({taskId:n(),status:cs,ttl:f([p(),zt()]),createdAt:n(),lastUpdatedAt:n(),pollInterval:q(p()),statusMessage:q(n())}),Ce=L.extend({task:de}),ds=F.merge(de),ge=j.extend({method:a("notifications/tasks/status"),params:ds}),Ie=N.extend({method:a("tasks/get"),params:U.extend({taskId:n()})}),Pe=L.merge(de),He=N.extend({method:a("tasks/result"),params:U.extend({taskId:n()})});L.loose();const Ee=le.extend({method:a("tasks/list")}),Me=ce.extend({tasks:h(de)}),Ne=N.extend({method:a("tasks/cancel"),params:U.extend({taskId:n()})}),us=L.merge(de),it=r({uri:n(),mimeType:q(n()),_meta:S(n(),v()).optional()}),lt=it.extend({text:n()}),Le=n().refine(l=>{try{return atob(l),!0}catch{return!1}},{message:"Invalid Base64 string"}),ct=it.extend({blob:Le}),ue=$(["user","assistant"]),X=r({audience:h(ue).optional(),priority:p().min(0).max(1).optional(),lastModified:Ut({offset:!0}).optional()}),dt=r({...Z.shape,...ie.shape,uri:n(),description:q(n()),mimeType:q(n()),size:q(p()),annotations:X.optional(),_meta:q(z({}))}),hs=r({...Z.shape,...ie.shape,uriTemplate:n(),description:q(n()),mimeType:q(n()),annotations:X.optional(),_meta:q(z({}))}),ut=le.extend({method:a("resources/list")}),ht=ce.extend({resources:h(dt)}),pt=le.extend({method:a("resources/templates/list")}),mt=ce.extend({resourceTemplates:h(hs)}),Ae=U.extend({uri:n()}),ps=Ae,ft=N.extend({method:a("resources/read"),params:ps}),gt=L.extend({contents:h(f([lt,ct]))}),bt=j.extend({method:a("notifications/resources/list_changed"),params:F.optional()}),ms=Ae,fs=N.extend({method:a("resources/subscribe"),params:ms}),gs=Ae,bs=N.extend({method:a("resources/unsubscribe"),params:gs}),ys=F.extend({uri:n()}),Ss=j.extend({method:a("notifications/resources/updated"),params:ys}),ks=r({name:n(),description:q(n()),required:q(x())}),_s=r({...Z.shape,...ie.shape,description:q(n()),arguments:q(h(ks)),_meta:q(z({}))}),yt=le.extend({method:a("prompts/list")}),St=ce.extend({prompts:h(_s)}),ws=U.extend({name:n(),arguments:S(n(),n()).optional()}),xs=N.extend({method:a("prompts/get"),params:ws}),ze=r({type:a("text"),text:n(),annotations:X.optional(),_meta:S(n(),v()).optional()}),Ue=r({type:a("image"),data:Le,mimeType:n(),annotations:X.optional(),_meta:S(n(),v()).optional()}),Oe=r({type:a("audio"),data:Le,mimeType:n(),annotations:X.optional(),_meta:S(n(),v()).optional()}),Rs=r({type:a("tool_use"),name:n(),id:n(),input:S(n(),v()),_meta:S(n(),v()).optional()}),kt=r({type:a("resource"),resource:f([lt,ct]),annotations:X.optional(),_meta:S(n(),v()).optional()}),_t=dt.extend({type:a("resource_link")}),he=f([ze,Ue,Oe,_t,kt]),vs=r({role:ue,content:he}),Ts=L.extend({description:n().optional(),messages:h(vs)}),wt=j.extend({method:a("notifications/prompts/list_changed"),params:F.optional()}),qs=r({title:n().optional(),readOnlyHint:x().optional(),destructiveHint:x().optional(),idempotentHint:x().optional(),openWorldHint:x().optional()}),Cs=r({taskSupport:$(["required","optional","forbidden"]).optional()}),De=r({...Z.shape,...ie.shape,description:n().optional(),inputSchema:r({type:a("object"),properties:S(n(),H).optional(),required:h(n()).optional()}).catchall(v()),outputSchema:r({type:a("object"),properties:S(n(),H).optional(),required:h(n()).optional()}).catchall(v()).optional(),annotations:qs.optional(),execution:Cs.optional(),_meta:S(n(),v()).optional()}),Is=le.extend({method:a("tools/list")}),xt=ce.extend({tools:h(De)}),oe=L.extend({content:h(he).default([]),structuredContent:S(n(),v()).optional(),isError:x().optional()});oe.or(L.extend({toolResult:v()}));const Ps=ne.extend({name:n(),arguments:S(n(),v()).optional()}),Rt=N.extend({method:a("tools/call"),params:Ps}),vt=j.extend({method:a("notifications/tools/list_changed"),params:F.optional()});r({autoRefresh:x().default(!0),debounceMs:p().int().nonnegative().default(300)});const Tt=$(["debug","info","notice","warning","error","critical","alert","emergency"]),Hs=U.extend({level:Tt}),Es=N.extend({method:a("logging/setLevel"),params:Hs}),Ms=F.extend({level:Tt,logger:n().optional(),data:v()}),qt=j.extend({method:a("notifications/message"),params:Ms}),Ns=r({name:n().optional()}),Ls=r({hints:h(Ns).optional(),costPriority:p().min(0).max(1).optional(),speedPriority:p().min(0).max(1).optional(),intelligencePriority:p().min(0).max(1).optional()}),As=r({mode:$(["auto","required","none"]).optional()}),zs=r({type:a("tool_result"),toolUseId:n().describe("The unique identifier for the corresponding tool call."),content:h(he).default([]),structuredContent:r({}).loose().optional(),isError:x().optional(),_meta:S(n(),v()).optional()}),Us=tt("type",[ze,Ue,Oe]),be=tt("type",[ze,Ue,Oe,Rs,zs]),Os=r({role:ue,content:f([be,h(be)]),_meta:S(n(),v()).optional()}),Ds=ne.extend({messages:h(Os),modelPreferences:Ls.optional(),systemPrompt:n().optional(),includeContext:$(["none","thisServer","allServers"]).optional(),temperature:p().optional(),maxTokens:p().int(),stopSequences:h(n()).optional(),metadata:H.optional(),tools:h(De).optional(),toolChoice:As.optional()}),Ct=N.extend({method:a("sampling/createMessage"),params:Ds}),$s=L.extend({model:n(),stopReason:q($(["endTurn","stopSequence","maxTokens"]).or(n())),role:ue,content:Us}),Fs=L.extend({model:n(),stopReason:q($(["endTurn","stopSequence","maxTokens","toolUse"]).or(n())),role:ue,content:f([be,h(be)])}),js=r({type:a("boolean"),title:n().optional(),description:n().optional(),default:x().optional()}),Bs=r({type:a("string"),title:n().optional(),description:n().optional(),minLength:p().optional(),maxLength:p().optional(),format:$(["email","uri","date","date-time"]).optional(),default:n().optional()}),Js=r({type:$(["number","integer"]),title:n().optional(),description:n().optional(),minimum:p().optional(),maximum:p().optional(),default:p().optional()}),Vs=r({type:a("string"),title:n().optional(),description:n().optional(),enum:h(n()),default:n().optional()}),Qs=r({type:a("string"),title:n().optional(),description:n().optional(),oneOf:h(r({const:n(),title:n()})),default:n().optional()}),Ws=r({type:a("string"),title:n().optional(),description:n().optional(),enum:h(n()),enumNames:h(n()).optional(),default:n().optional()}),Ks=f([Vs,Qs]),Gs=r({type:a("array"),title:n().optional(),description:n().optional(),minItems:p().optional(),maxItems:p().optional(),items:r({type:a("string"),enum:h(n())}),default:h(n()).optional()}),Ys=r({type:a("array"),title:n().optional(),description:n().optional(),minItems:p().optional(),maxItems:p().optional(),items:r({anyOf:h(r({const:n(),title:n()}))}),default:h(n()).optional()}),Zs=f([Gs,Ys]),Xs=f([Ws,Ks,Zs]),eo=f([Xs,js,Bs,Js]),to=ne.extend({mode:a("form").optional(),message:n(),requestedSchema:r({type:a("object"),properties:S(n(),eo),required:h(n()).optional()})}),so=ne.extend({mode:a("url"),message:n(),elicitationId:n(),url:n().url()}),oo=f([to,so]),ao=N.extend({method:a("elicitation/create"),params:oo}),no=F.extend({elicitationId:n()}),ro=j.extend({method:a("notifications/elicitation/complete"),params:no}),io=L.extend({action:$(["accept","decline","cancel"]),content:et(l=>l===null?void 0:l,S(n(),f([n(),p(),x(),h(n())])).optional())}),lo=r({type:a("ref/resource"),uri:n()}),co=r({type:a("ref/prompt"),name:n()}),uo=U.extend({ref:f([co,lo]),argument:r({name:n(),value:n()}),context:r({arguments:S(n(),n()).optional()}).optional()}),ho=N.extend({method:a("completion/complete"),params:uo}),po=L.extend({completion:z({values:h(n()).max(100),total:q(p().int()),hasMore:q(x())})}),mo=r({uri:n().startsWith("file://"),name:n().optional(),_meta:S(n(),v()).optional()}),fo=N.extend({method:a("roots/list"),params:U.optional()}),go=L.extend({roots:h(mo)}),bo=j.extend({method:a("notifications/roots/list_changed"),params:F.optional()});f([ke,ss,ho,Es,xs,yt,ut,pt,ft,fs,bs,Rt,Is,Ie,He,Ee,Ne]);f([Te,qe,ns,bo,ge]);f([rt,$s,Fs,io,go,Pe,Me,Ce]);f([ke,Ct,ao,fo,Ie,He,Ee,Ne]);f([Te,qe,qt,Ss,bt,vt,wt,ge,ro]);f([rt,as,po,Ts,St,ht,mt,gt,oe,xt,Pe,Me,Ce]);class y extends Error{constructor(o,e,t){super(`MCP error ${o}: ${e}`),this.code=o,this.data=t,this.name="McpError"}static fromError(o,e,t){if(o===k.UrlElicitationRequired&&t){const s=t;if(s.elicitations)return new yo(s.elicitations,e)}return new y(o,e,t)}}class yo extends y{constructor(o,e=`URL elicitation${o.length>1?"s":""} required`){super(k.UrlElicitationRequired,e,{elicitations:o})}get elicitations(){var o;return((o=this.data)==null?void 0:o.elicitations)??[]}}function $e(l){return!!l._zod}function It(l,o){return $e(l)?Ot(l,o):l.safeParse(o)}function So(l){var e,t;if(!l)return;let o;if($e(l)?o=(t=(e=l._zod)==null?void 0:e.def)==null?void 0:t.shape:o=l.shape,!!o){if(typeof o=="function")try{return o()}catch{return}return o}}function ko(l){var s;if($e(l)){const c=(s=l._zod)==null?void 0:s.def;if(c){if(c.value!==void 0)return c.value;if(Array.isArray(c.values)&&c.values.length>0)return c.values[0]}}const e=l._def;if(e){if(e.value!==void 0)return e.value;if(Array.isArray(e.values)&&e.values.length>0)return e.values[0]}const t=l.value;if(t!==void 0)return t}function G(l){return l==="completed"||l==="failed"||l==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function We(l){const o=So(l),e=o==null?void 0:o.method;if(!e)throw new Error("Schema is missing a method literal");const t=ko(e);if(typeof t!="string")throw new Error("Schema method literal must be a string");return t}function Ke(l,o){const e=It(l,o);if(!e.success)throw e.error;return e.data}const _o=6e4;class wo{constructor(o){this._options=o,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Te,e=>{this._oncancel(e)}),this.setNotificationHandler(qe,e=>{this._onprogress(e)}),this.setRequestHandler(ke,e=>({})),this._taskStore=o==null?void 0:o.taskStore,this._taskMessageQueue=o==null?void 0:o.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ie,async(e,t)=>{const s=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!s)throw new y(k.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(He,async(e,t)=>{const s=async()=>{var u;const i=e.params.taskId;if(this._taskMessageQueue){let d;for(;d=await this._taskMessageQueue.dequeue(i,t.sessionId);){if(d.type==="response"||d.type==="error"){const g=d.message,w=g.id,_=this._requestResolvers.get(w);if(_)if(this._requestResolvers.delete(w),d.type==="response")_(g);else{const b=g,P=new y(b.error.code,b.error.message,b.error.data);_(P)}else{const b=d.type==="response"?"Response":"Error";this._onerror(new Error(`${b} handler missing for request ${w}`))}continue}await((u=this._transport)==null?void 0:u.send(d.message,{relatedRequestId:t.requestId}))}}const c=await this._taskStore.getTask(i,t.sessionId);if(!c)throw new y(k.InvalidParams,`Task not found: ${i}`);if(!G(c.status))return await this._waitForTaskUpdate(i,t.signal),await s();if(G(c.status)){const d=await this._taskStore.getTaskResult(i,t.sessionId);return this._clearTaskQueue(i),{...d,_meta:{...d._meta,[Y]:{taskId:i}}}}return await s()};return await s()}),this.setRequestHandler(Ee,async(e,t)=>{var s;try{const{tasks:i,nextCursor:c}=await this._taskStore.listTasks((s=e.params)==null?void 0:s.cursor,t.sessionId);return{tasks:i,nextCursor:c,_meta:{}}}catch(i){throw new y(k.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(Ne,async(e,t)=>{try{const s=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!s)throw new y(k.InvalidParams,`Task not found: ${e.params.taskId}`);if(G(s.status))throw new y(k.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,"cancelled","Client cancelled task execution.",t.sessionId),this._clearTaskQueue(e.params.taskId);const i=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!i)throw new y(k.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...i}}catch(s){throw s instanceof y?s:new y(k.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(o){if(!o.params.requestId)return;const e=this._requestHandlerAbortControllers.get(o.params.requestId);e==null||e.abort(o.params.reason)}_setupTimeout(o,e,t,s,i=!1){this._timeoutInfo.set(o,{timeoutId:setTimeout(s,e),startTime:Date.now(),timeout:e,maxTotalTimeout:t,resetTimeoutOnProgress:i,onTimeout:s})}_resetTimeout(o){const e=this._timeoutInfo.get(o);if(!e)return!1;const t=Date.now()-e.startTime;if(e.maxTotalTimeout&&t>=e.maxTotalTimeout)throw this._timeoutInfo.delete(o),y.fromError(k.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:e.maxTotalTimeout,totalElapsed:t});return clearTimeout(e.timeoutId),e.timeoutId=setTimeout(e.onTimeout,e.timeout),!0}_cleanupTimeout(o){const e=this._timeoutInfo.get(o);e&&(clearTimeout(e.timeoutId),this._timeoutInfo.delete(o))}async connect(o){var i,c,u;if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=o;const e=(i=this.transport)==null?void 0:i.onclose;this._transport.onclose=()=>{e==null||e(),this._onclose()};const t=(c=this.transport)==null?void 0:c.onerror;this._transport.onerror=d=>{t==null||t(d),this._onerror(d)};const s=(u=this._transport)==null?void 0:u.onmessage;this._transport.onmessage=(d,g)=>{s==null||s(d,g),fe(d)||Vt(d)?this._onresponse(d):Qe(d)?this._onrequest(d,g):Jt(d)?this._onnotification(d):this._onerror(new Error(`Unknown message type: ${JSON.stringify(d)}`))},await this._transport.start()}_onclose(){var t;const o=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const e=y.fromError(k.ConnectionClosed,"Connection closed");this._transport=void 0,(t=this.onclose)==null||t.call(this);for(const s of o.values())s(e)}_onerror(o){var e;(e=this.onerror)==null||e.call(this,o)}_onnotification(o){const e=this._notificationHandlers.get(o.method)??this.fallbackNotificationHandler;e!==void 0&&Promise.resolve().then(()=>e(o)).catch(t=>this._onerror(new Error(`Uncaught error in notification handler: ${t}`)))}_onrequest(o,e){var w,_,b,P;const t=this._requestHandlers.get(o.method)??this.fallbackRequestHandler,s=this._transport,i=(b=(_=(w=o.params)==null?void 0:w._meta)==null?void 0:_[Y])==null?void 0:b.taskId;if(t===void 0){const R={jsonrpc:"2.0",id:o.id,error:{code:k.MethodNotFound,message:"Method not found"}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:R,timestamp:Date.now()},s==null?void 0:s.sessionId).catch(C=>this._onerror(new Error(`Failed to enqueue error response: ${C}`))):s==null||s.send(R).catch(C=>this._onerror(new Error(`Failed to send an error response: ${C}`)));return}const c=new AbortController;this._requestHandlerAbortControllers.set(o.id,c);const u=Bt(o.params)?o.params.task:void 0,d=this._taskStore?this.requestTaskStore(o,s==null?void 0:s.sessionId):void 0,g={signal:c.signal,sessionId:s==null?void 0:s.sessionId,_meta:(P=o.params)==null?void 0:P._meta,sendNotification:async R=>{if(c.signal.aborted)return;const C={relatedRequestId:o.id};i&&(C.relatedTask={taskId:i}),await this.notification(R,C)},sendRequest:async(R,C,V)=>{var D;if(c.signal.aborted)throw new y(k.ConnectionClosed,"Request was cancelled");const O={...V,relatedRequestId:o.id};i&&!O.relatedTask&&(O.relatedTask={taskId:i});const Q=((D=O.relatedTask)==null?void 0:D.taskId)??i;return Q&&d&&await d.updateTaskStatus(Q,"input_required"),await this.request(R,C,O)},authInfo:e==null?void 0:e.authInfo,requestId:o.id,requestInfo:e==null?void 0:e.requestInfo,taskId:i,taskStore:d,taskRequestedTtl:u==null?void 0:u.ttl,closeSSEStream:e==null?void 0:e.closeSSEStream,closeStandaloneSSEStream:e==null?void 0:e.closeStandaloneSSEStream};Promise.resolve().then(()=>{u&&this.assertTaskHandlerCapability(o.method)}).then(()=>t(o,g)).then(async R=>{if(c.signal.aborted)return;const C={result:R,jsonrpc:"2.0",id:o.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:C,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(C))},async R=>{if(c.signal.aborted)return;const C={jsonrpc:"2.0",id:o.id,error:{code:Number.isSafeInteger(R.code)?R.code:k.InternalError,message:R.message??"Internal error",...R.data!==void 0&&{data:R.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"error",message:C,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(C))}).catch(R=>this._onerror(new Error(`Failed to send response: ${R}`))).finally(()=>{this._requestHandlerAbortControllers.get(o.id)===c&&this._requestHandlerAbortControllers.delete(o.id)})}_onprogress(o){const{progressToken:e,...t}=o.params,s=Number(e),i=this._progressHandlers.get(s);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(o)}`));return}const c=this._responseHandlers.get(s),u=this._timeoutInfo.get(s);if(u&&c&&u.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(d){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),c(d);return}i(t)}_onresponse(o){const e=Number(o.id),t=this._requestResolvers.get(e);if(t){if(this._requestResolvers.delete(e),fe(o))t(o);else{const c=new y(o.error.code,o.error.message,o.error.data);t(c)}return}const s=this._responseHandlers.get(e);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(o)}`));return}this._responseHandlers.delete(e),this._cleanupTimeout(e);let i=!1;if(fe(o)&&o.result&&typeof o.result=="object"){const c=o.result;if(c.task&&typeof c.task=="object"){const u=c.task;typeof u.taskId=="string"&&(i=!0,this._taskProgressTokens.set(u.taskId,e))}}if(i||this._progressHandlers.delete(e),fe(o))s(o);else{const c=y.fromError(o.error.code,o.error.message,o.error.data);s(c)}}get transport(){return this._transport}async close(){var o;await((o=this._transport)==null?void 0:o.close())}async*requestStream(o,e,t){var c,u;const{task:s}=t??{};if(!s){try{yield{type:"result",result:await this.request(o,e,t)}}catch(d){yield{type:"error",error:d instanceof y?d:new y(k.InternalError,String(d))}}return}let i;try{const d=await this.request(o,Ce,t);if(d.task)i=d.task.taskId,yield{type:"taskCreated",task:d.task};else throw new y(k.InternalError,"Task creation did not return a task");for(;;){const g=await this.getTask({taskId:i},t);if(yield{type:"taskStatus",task:g},G(g.status)){g.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:i},e,t)}:g.status==="failed"?yield{type:"error",error:new y(k.InternalError,`Task ${i} failed`)}:g.status==="cancelled"&&(yield{type:"error",error:new y(k.InternalError,`Task ${i} was cancelled`)});return}if(g.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:i},e,t)};return}const w=g.pollInterval??((c=this._options)==null?void 0:c.defaultTaskPollInterval)??1e3;await new Promise(_=>setTimeout(_,w)),(u=t==null?void 0:t.signal)==null||u.throwIfAborted()}}catch(d){yield{type:"error",error:d instanceof y?d:new y(k.InternalError,String(d))}}}request(o,e,t){const{relatedRequestId:s,resumptionToken:i,onresumptiontoken:c,task:u,relatedTask:d}=t??{};return new Promise((g,w)=>{var Q,D,pe,me,I;const _=T=>{w(T)};if(!this._transport){_(new Error("Not connected"));return}if(((Q=this._options)==null?void 0:Q.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(o.method),u&&this.assertTaskCapability(o.method)}catch(T){_(T);return}(D=t==null?void 0:t.signal)==null||D.throwIfAborted();const b=this._requestMessageId++,P={...o,jsonrpc:"2.0",id:b};t!=null&&t.onprogress&&(this._progressHandlers.set(b,t.onprogress),P.params={...o.params,_meta:{...((pe=o.params)==null?void 0:pe._meta)||{},progressToken:b}}),u&&(P.params={...P.params,task:u}),d&&(P.params={...P.params,_meta:{...((me=P.params)==null?void 0:me._meta)||{},[Y]:d}});const R=T=>{var A;this._responseHandlers.delete(b),this._progressHandlers.delete(b),this._cleanupTimeout(b),(A=this._transport)==null||A.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:b,reason:String(T)}},{relatedRequestId:s,resumptionToken:i,onresumptiontoken:c}).catch(ee=>this._onerror(new Error(`Failed to send cancellation: ${ee}`)));const B=T instanceof y?T:new y(k.RequestTimeout,String(T));w(B)};this._responseHandlers.set(b,T=>{var B;if(!((B=t==null?void 0:t.signal)!=null&&B.aborted)){if(T instanceof Error)return w(T);try{const A=It(e,T.result);A.success?g(A.data):w(A.error)}catch(A){w(A)}}}),(I=t==null?void 0:t.signal)==null||I.addEventListener("abort",()=>{var T;R((T=t==null?void 0:t.signal)==null?void 0:T.reason)});const C=(t==null?void 0:t.timeout)??_o,V=()=>R(y.fromError(k.RequestTimeout,"Request timed out",{timeout:C}));this._setupTimeout(b,C,t==null?void 0:t.maxTotalTimeout,V,(t==null?void 0:t.resetTimeoutOnProgress)??!1);const O=d==null?void 0:d.taskId;if(O){const T=B=>{const A=this._responseHandlers.get(b);A?A(B):this._onerror(new Error(`Response handler missing for side-channeled request ${b}`))};this._requestResolvers.set(b,T),this._enqueueTaskMessage(O,{type:"request",message:P,timestamp:Date.now()}).catch(B=>{this._cleanupTimeout(b),w(B)})}else this._transport.send(P,{relatedRequestId:s,resumptionToken:i,onresumptiontoken:c}).catch(T=>{this._cleanupTimeout(b),w(T)})})}async getTask(o,e){return this.request({method:"tasks/get",params:o},Pe,e)}async getTaskResult(o,e,t){return this.request({method:"tasks/result",params:o},e,t)}async listTasks(o,e){return this.request({method:"tasks/list",params:o},Me,e)}async cancelTask(o,e){return this.request({method:"tasks/cancel",params:o},us,e)}async notification(o,e){var u,d,g,w;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(o.method);const t=(u=e==null?void 0:e.relatedTask)==null?void 0:u.taskId;if(t){const _={...o,jsonrpc:"2.0",params:{...o.params,_meta:{...((d=o.params)==null?void 0:d._meta)||{},[Y]:e.relatedTask}}};await this._enqueueTaskMessage(t,{type:"notification",message:_,timestamp:Date.now()});return}if((((g=this._options)==null?void 0:g.debouncedNotificationMethods)??[]).includes(o.method)&&!o.params&&!(e!=null&&e.relatedRequestId)&&!(e!=null&&e.relatedTask)){if(this._pendingDebouncedNotifications.has(o.method))return;this._pendingDebouncedNotifications.add(o.method),Promise.resolve().then(()=>{var b,P;if(this._pendingDebouncedNotifications.delete(o.method),!this._transport)return;let _={...o,jsonrpc:"2.0"};e!=null&&e.relatedTask&&(_={..._,params:{..._.params,_meta:{...((b=_.params)==null?void 0:b._meta)||{},[Y]:e.relatedTask}}}),(P=this._transport)==null||P.send(_,e).catch(R=>this._onerror(R))});return}let c={...o,jsonrpc:"2.0"};e!=null&&e.relatedTask&&(c={...c,params:{...c.params,_meta:{...((w=c.params)==null?void 0:w._meta)||{},[Y]:e.relatedTask}}}),await this._transport.send(c,e)}setRequestHandler(o,e){const t=We(o);this.assertRequestHandlerCapability(t),this._requestHandlers.set(t,(s,i)=>{const c=Ke(o,s);return Promise.resolve(e(c,i))})}removeRequestHandler(o){this._requestHandlers.delete(o)}assertCanSetRequestHandler(o){if(this._requestHandlers.has(o))throw new Error(`A request handler for ${o} already exists, which would be overridden`)}setNotificationHandler(o,e){const t=We(o);this._notificationHandlers.set(t,s=>{const i=Ke(o,s);return Promise.resolve(e(i))})}removeNotificationHandler(o){this._notificationHandlers.delete(o)}_cleanupTaskProgressHandler(o){const e=this._taskProgressTokens.get(o);e!==void 0&&(this._progressHandlers.delete(e),this._taskProgressTokens.delete(o))}async _enqueueTaskMessage(o,e,t){var i;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const s=(i=this._options)==null?void 0:i.maxTaskQueueSize;await this._taskMessageQueue.enqueue(o,e,t,s)}async _clearTaskQueue(o,e){if(this._taskMessageQueue){const t=await this._taskMessageQueue.dequeueAll(o,e);for(const s of t)if(s.type==="request"&&Qe(s.message)){const i=s.message.id,c=this._requestResolvers.get(i);c?(c(new y(k.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${o} cleanup`))}}}async _waitForTaskUpdate(o,e){var s,i;let t=((s=this._options)==null?void 0:s.defaultTaskPollInterval)??1e3;try{const c=await((i=this._taskStore)==null?void 0:i.getTask(o));c!=null&&c.pollInterval&&(t=c.pollInterval)}catch{}return new Promise((c,u)=>{if(e.aborted){u(new y(k.InvalidRequest,"Request cancelled"));return}const d=setTimeout(c,t);e.addEventListener("abort",()=>{clearTimeout(d),u(new y(k.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(o,e){const t=this._taskStore;if(!t)throw new Error("No task store configured");return{createTask:async s=>{if(!o)throw new Error("No request provided");return await t.createTask(s,o.id,{method:o.method,params:o.params},e)},getTask:async s=>{const i=await t.getTask(s,e);if(!i)throw new y(k.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(s,i,c)=>{await t.storeTaskResult(s,i,c,e);const u=await t.getTask(s,e);if(u){const d=ge.parse({method:"notifications/tasks/status",params:u});await this.notification(d),G(u.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>t.getTaskResult(s,e),updateTaskStatus:async(s,i,c)=>{const u=await t.getTask(s,e);if(!u)throw new y(k.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(G(u.status))throw new y(k.InvalidParams,`Cannot update task "${s}" from terminal status "${u.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await t.updateTaskStatus(s,i,c,e);const d=await t.getTask(s,e);if(d){const g=ge.parse({method:"notifications/tasks/status",params:d});await this.notification(g),G(d.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>t.listTasks(s,e)}}}(l=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(l,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):l)(function(l){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+l+'" is not supported')});class xo extends wo{constructor(){super(...arguments);m(this,"_registeredMethods",new Set);m(this,"_eventSlots",new Map);m(this,"setRequestHandler",(e,t)=>{this._assertMethodNotRegistered(e,"setRequestHandler"),super.setRequestHandler(e,t)});m(this,"setNotificationHandler",(e,t)=>{this._assertMethodNotRegistered(e,"setNotificationHandler"),super.setNotificationHandler(e,t)});m(this,"replaceRequestHandler",(e,t)=>{let s=e.shape.method.value;this._registeredMethods.add(s),super.setRequestHandler(e,t)})}onEventDispatch(e,t){}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t){let s=this.eventSchemas[e];if(!s)throw Error(`Unknown event: ${String(e)}`);t={listeners:[]},this._eventSlots.set(e,t);let i=s.shape.method.value;this._registeredMethods.add(i);let c=t;super.setNotificationHandler(s,u=>{var g;let d=u.params;this.onEventDispatch(e,d),(g=c.onHandler)==null||g.call(c,d);for(let w of[...c.listeners])w(d)})}return t}setEventHandler(e,t){let s=this._ensureEventSlot(e);s.onHandler&&t&&console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`),s.onHandler=t}getEventHandler(e){var t;return(t=this._eventSlots.get(e))==null?void 0:t.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let s=this._eventSlots.get(e);if(!s)return;let i=s.listeners.indexOf(t);i!==-1&&s.listeners.splice(i,1)}warnIfRequestHandlerReplaced(e,t,s){t&&s&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}_assertMethodNotRegistered(e,t){let s=e.shape.method.value;if(this._registeredMethods.has(s))throw Error(`Handler for "${s}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(s)}}var Pt="2026-01-26",Ro="ui/notifications/tool-input-partial",vo=f([a("light"),a("dark")]).describe("Color theme preference for the host environment."),ae=f([a("inline"),a("fullscreen"),a("pip")]).describe("Display mode for UI presentation."),To=f([a("--color-background-primary"),a("--color-background-secondary"),a("--color-background-tertiary"),a("--color-background-inverse"),a("--color-background-ghost"),a("--color-background-info"),a("--color-background-danger"),a("--color-background-success"),a("--color-background-warning"),a("--color-background-disabled"),a("--color-text-primary"),a("--color-text-secondary"),a("--color-text-tertiary"),a("--color-text-inverse"),a("--color-text-ghost"),a("--color-text-info"),a("--color-text-danger"),a("--color-text-success"),a("--color-text-warning"),a("--color-text-disabled"),a("--color-border-primary"),a("--color-border-secondary"),a("--color-border-tertiary"),a("--color-border-inverse"),a("--color-border-ghost"),a("--color-border-info"),a("--color-border-danger"),a("--color-border-success"),a("--color-border-warning"),a("--color-border-disabled"),a("--color-ring-primary"),a("--color-ring-secondary"),a("--color-ring-inverse"),a("--color-ring-info"),a("--color-ring-danger"),a("--color-ring-success"),a("--color-ring-warning"),a("--font-sans"),a("--font-mono"),a("--font-weight-normal"),a("--font-weight-medium"),a("--font-weight-semibold"),a("--font-weight-bold"),a("--font-text-xs-size"),a("--font-text-sm-size"),a("--font-text-md-size"),a("--font-text-lg-size"),a("--font-heading-xs-size"),a("--font-heading-sm-size"),a("--font-heading-md-size"),a("--font-heading-lg-size"),a("--font-heading-xl-size"),a("--font-heading-2xl-size"),a("--font-heading-3xl-size"),a("--font-text-xs-line-height"),a("--font-text-sm-line-height"),a("--font-text-md-line-height"),a("--font-text-lg-line-height"),a("--font-heading-xs-line-height"),a("--font-heading-sm-line-height"),a("--font-heading-md-line-height"),a("--font-heading-lg-line-height"),a("--font-heading-xl-line-height"),a("--font-heading-2xl-line-height"),a("--font-heading-3xl-line-height"),a("--border-radius-xs"),a("--border-radius-sm"),a("--border-radius-md"),a("--border-radius-lg"),a("--border-radius-xl"),a("--border-radius-full"),a("--border-width-regular"),a("--shadow-hairline"),a("--shadow-sm"),a("--shadow-md"),a("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),qo=S(To.describe(`Style variables for theming MCP apps.
|
|
1
|
+
var Mt=Object.defineProperty;var Nt=(l,o,e)=>o in l?Mt(l,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[o]=e;var m=(l,o,e)=>Nt(l,typeof o!="symbol"?o+"":o,e);import{b as K,j as Lt}from"./dagview-B70jDsRo.js";import{l as a,k as x,r as S,m as h,u as f,o as r,s as n,n as v,q as p,_ as $,v as z,x as At,y as q,z as zt,B as Xe,E as et,F as Ut,H as tt,I as Ot,J as we,K as Je}from"./grpc-CSEitK46.js";const Dt={"--color-background-primary":"light-dark(#ffffff, #1a1a1a)","--color-background-secondary":"light-dark(#f5f5f5, #2d2d2d)","--color-background-tertiary":"light-dark(#e5e5e5, #404040)","--color-background-inverse":"light-dark(#1a1a1a, #ffffff)","--color-background-ghost":"light-dark(rgba(255,255,255,0), rgba(26,26,26,0))","--color-background-info":"light-dark(#eff6ff, #1e3a5f)","--color-background-danger":"light-dark(#fef2f2, #7f1d1d)","--color-background-success":"light-dark(#f0fdf4, #14532d)","--color-background-warning":"light-dark(#fefce8, #713f12)","--color-background-disabled":"light-dark(rgba(255,255,255,0.5), rgba(26,26,26,0.5))","--color-text-primary":"light-dark(#1f2937, #f3f4f6)","--color-text-secondary":"light-dark(#6b7280, #9ca3af)","--color-text-tertiary":"light-dark(#9ca3af, #6b7280)","--color-text-inverse":"light-dark(#f3f4f6, #1f2937)","--color-text-ghost":"light-dark(rgba(107,114,128,0.5), rgba(156,163,175,0.5))","--color-text-info":"light-dark(#1d4ed8, #60a5fa)","--color-text-danger":"light-dark(#b91c1c, #f87171)","--color-text-success":"light-dark(#15803d, #4ade80)","--color-text-warning":"light-dark(#a16207, #fbbf24)","--color-text-disabled":"light-dark(rgba(31,41,55,0.5), rgba(243,244,246,0.5))","--color-border-primary":"light-dark(#e5e7eb, #404040)","--color-border-secondary":"light-dark(#d1d5db, #525252)","--color-border-tertiary":"light-dark(#f3f4f6, #374151)","--color-border-inverse":"light-dark(rgba(255,255,255,0.3), rgba(0,0,0,0.3))","--color-border-ghost":"light-dark(rgba(229,231,235,0), rgba(64,64,64,0))","--color-border-info":"light-dark(#93c5fd, #1e40af)","--color-border-danger":"light-dark(#fca5a5, #991b1b)","--color-border-success":"light-dark(#86efac, #166534)","--color-border-warning":"light-dark(#fde047, #854d0e)","--color-border-disabled":"light-dark(rgba(229,231,235,0.5), rgba(64,64,64,0.5))","--color-ring-primary":"light-dark(#3b82f6, #60a5fa)","--color-ring-secondary":"light-dark(#6b7280, #9ca3af)","--color-ring-inverse":"light-dark(#ffffff, #1f2937)","--color-ring-info":"light-dark(#2563eb, #3b82f6)","--color-ring-danger":"light-dark(#dc2626, #ef4444)","--color-ring-success":"light-dark(#16a34a, #22c55e)","--color-ring-warning":"light-dark(#ca8a04, #eab308)","--font-sans":"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif","--font-mono":"ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', monospace","--font-weight-normal":"400","--font-weight-medium":"500","--font-weight-semibold":"600","--font-weight-bold":"700","--font-text-xs-size":"0.75rem","--font-text-sm-size":"0.875rem","--font-text-md-size":"1rem","--font-text-lg-size":"1.125rem","--font-heading-xs-size":"0.75rem","--font-heading-sm-size":"0.875rem","--font-heading-md-size":"1rem","--font-heading-lg-size":"1.25rem","--font-heading-xl-size":"1.5rem","--font-heading-2xl-size":"1.875rem","--font-heading-3xl-size":"2.25rem","--font-text-xs-line-height":"1.4","--font-text-sm-line-height":"1.4","--font-text-md-line-height":"1.5","--font-text-lg-line-height":"1.5","--font-heading-xs-line-height":"1.4","--font-heading-sm-line-height":"1.4","--font-heading-md-line-height":"1.4","--font-heading-lg-line-height":"1.3","--font-heading-xl-line-height":"1.25","--font-heading-2xl-line-height":"1.2","--font-heading-3xl-line-height":"1.1","--border-radius-xs":"2px","--border-radius-sm":"4px","--border-radius-md":"6px","--border-radius-lg":"8px","--border-radius-xl":"12px","--border-radius-full":"9999px","--border-width-regular":"1px","--shadow-hairline":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--shadow-sm":"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)","--shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)","--shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)"},$t={"--color-background-primary":"--bg-base","--color-background-secondary":"--bg-surface","--color-background-tertiary":"--bg-elevated","--color-text-primary":"--text-primary","--color-text-secondary":"--text-secondary","--color-text-tertiary":"--text-tertiary","--color-border-primary":"--border-primary","--color-border-secondary":"--border-subtle","--font-sans":"--font-sans","--font-mono":"--font-mono","--border-radius-sm":"--radius-sm","--border-radius-md":"--radius-md","--border-radius-lg":"--radius-lg","--border-radius-full":"--radius-full"};function Ve(){const l={...Dt};if(typeof window>"u"||typeof document>"u")return l;const o=window.getComputedStyle(document.documentElement),e=l;for(const[t,s]of Object.entries($t)){const i=o.getPropertyValue(s).trim();i&&(e[t]=i)}return l}const Y="io.modelcontextprotocol/related-task",ye="2.0",H=At(l=>l!==null&&(typeof l=="object"||typeof l=="function")),st=f([n(),p().int()]),ot=n();z({ttl:p().optional(),pollInterval:p().optional()});const Ft=r({ttl:p().optional()}),jt=r({taskId:n()}),xe=z({progressToken:st.optional(),[Y]:jt.optional()}),U=r({_meta:xe.optional()}),ne=U.extend({task:Ft.optional()}),Bt=l=>ne.safeParse(l).success,N=r({method:n(),params:U.loose().optional()}),F=r({_meta:xe.optional()}),j=r({method:n(),params:F.loose().optional()}),L=z({_meta:xe.optional()}),re=f([n(),p().int()]),at=r({jsonrpc:a(ye),id:re,...N.shape}).strict(),Qe=l=>at.safeParse(l).success,nt=r({jsonrpc:a(ye),...j.shape}).strict(),Jt=l=>nt.safeParse(l).success,Re=r({jsonrpc:a(ye),id:re,result:L}).strict(),fe=l=>Re.safeParse(l).success;var k;(function(l){l[l.ConnectionClosed=-32e3]="ConnectionClosed",l[l.RequestTimeout=-32001]="RequestTimeout",l[l.ParseError=-32700]="ParseError",l[l.InvalidRequest=-32600]="InvalidRequest",l[l.MethodNotFound=-32601]="MethodNotFound",l[l.InvalidParams=-32602]="InvalidParams",l[l.InternalError=-32603]="InternalError",l[l.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(k||(k={}));const ve=r({jsonrpc:a(ye),id:re.optional(),error:r({code:p().int(),message:n(),data:v().optional()})}).strict(),Vt=l=>ve.safeParse(l).success,Qt=f([at,nt,Re,ve]);f([Re,ve]);const rt=L.strict(),Wt=F.extend({requestId:re.optional(),reason:n().optional()}),Te=j.extend({method:a("notifications/cancelled"),params:Wt}),Kt=r({src:n(),mimeType:n().optional(),sizes:h(n()).optional(),theme:$(["light","dark"]).optional()}),ie=r({icons:h(Kt).optional()}),Z=r({name:n(),title:n().optional()}),Se=Z.extend({...Z.shape,...ie.shape,version:n(),websiteUrl:n().optional(),description:n().optional()}),Gt=Xe(r({applyDefaults:x().optional()}),S(n(),v())),Yt=et(l=>l&&typeof l=="object"&&!Array.isArray(l)&&Object.keys(l).length===0?{form:{}}:l,Xe(r({form:Gt.optional(),url:H.optional()}),S(n(),v()).optional())),Zt=z({list:H.optional(),cancel:H.optional(),requests:z({sampling:z({createMessage:H.optional()}).optional(),elicitation:z({create:H.optional()}).optional()}).optional()}),Xt=z({list:H.optional(),cancel:H.optional(),requests:z({tools:z({call:H.optional()}).optional()}).optional()}),es=r({experimental:S(n(),H).optional(),sampling:r({context:H.optional(),tools:H.optional()}).optional(),elicitation:Yt.optional(),roots:r({listChanged:x().optional()}).optional(),tasks:Zt.optional(),extensions:S(n(),H).optional()}),ts=U.extend({protocolVersion:n(),capabilities:es,clientInfo:Se}),ss=N.extend({method:a("initialize"),params:ts}),os=r({experimental:S(n(),H).optional(),logging:H.optional(),completions:H.optional(),prompts:r({listChanged:x().optional()}).optional(),resources:r({subscribe:x().optional(),listChanged:x().optional()}).optional(),tools:r({listChanged:x().optional()}).optional(),tasks:Xt.optional(),extensions:S(n(),H).optional()}),as=L.extend({protocolVersion:n(),capabilities:os,serverInfo:Se,instructions:n().optional()}),ns=j.extend({method:a("notifications/initialized"),params:F.optional()}),ke=N.extend({method:a("ping"),params:U.optional()}),rs=r({progress:p(),total:q(p()),message:q(n())}),is=r({...F.shape,...rs.shape,progressToken:st}),qe=j.extend({method:a("notifications/progress"),params:is}),ls=U.extend({cursor:ot.optional()}),le=N.extend({params:ls.optional()}),ce=L.extend({nextCursor:ot.optional()}),cs=$(["working","input_required","completed","failed","cancelled"]),de=r({taskId:n(),status:cs,ttl:f([p(),zt()]),createdAt:n(),lastUpdatedAt:n(),pollInterval:q(p()),statusMessage:q(n())}),Ce=L.extend({task:de}),ds=F.merge(de),ge=j.extend({method:a("notifications/tasks/status"),params:ds}),Ie=N.extend({method:a("tasks/get"),params:U.extend({taskId:n()})}),Pe=L.merge(de),He=N.extend({method:a("tasks/result"),params:U.extend({taskId:n()})});L.loose();const Ee=le.extend({method:a("tasks/list")}),Me=ce.extend({tasks:h(de)}),Ne=N.extend({method:a("tasks/cancel"),params:U.extend({taskId:n()})}),us=L.merge(de),it=r({uri:n(),mimeType:q(n()),_meta:S(n(),v()).optional()}),lt=it.extend({text:n()}),Le=n().refine(l=>{try{return atob(l),!0}catch{return!1}},{message:"Invalid Base64 string"}),ct=it.extend({blob:Le}),ue=$(["user","assistant"]),X=r({audience:h(ue).optional(),priority:p().min(0).max(1).optional(),lastModified:Ut({offset:!0}).optional()}),dt=r({...Z.shape,...ie.shape,uri:n(),description:q(n()),mimeType:q(n()),size:q(p()),annotations:X.optional(),_meta:q(z({}))}),hs=r({...Z.shape,...ie.shape,uriTemplate:n(),description:q(n()),mimeType:q(n()),annotations:X.optional(),_meta:q(z({}))}),ut=le.extend({method:a("resources/list")}),ht=ce.extend({resources:h(dt)}),pt=le.extend({method:a("resources/templates/list")}),mt=ce.extend({resourceTemplates:h(hs)}),Ae=U.extend({uri:n()}),ps=Ae,ft=N.extend({method:a("resources/read"),params:ps}),gt=L.extend({contents:h(f([lt,ct]))}),bt=j.extend({method:a("notifications/resources/list_changed"),params:F.optional()}),ms=Ae,fs=N.extend({method:a("resources/subscribe"),params:ms}),gs=Ae,bs=N.extend({method:a("resources/unsubscribe"),params:gs}),ys=F.extend({uri:n()}),Ss=j.extend({method:a("notifications/resources/updated"),params:ys}),ks=r({name:n(),description:q(n()),required:q(x())}),_s=r({...Z.shape,...ie.shape,description:q(n()),arguments:q(h(ks)),_meta:q(z({}))}),yt=le.extend({method:a("prompts/list")}),St=ce.extend({prompts:h(_s)}),ws=U.extend({name:n(),arguments:S(n(),n()).optional()}),xs=N.extend({method:a("prompts/get"),params:ws}),ze=r({type:a("text"),text:n(),annotations:X.optional(),_meta:S(n(),v()).optional()}),Ue=r({type:a("image"),data:Le,mimeType:n(),annotations:X.optional(),_meta:S(n(),v()).optional()}),Oe=r({type:a("audio"),data:Le,mimeType:n(),annotations:X.optional(),_meta:S(n(),v()).optional()}),Rs=r({type:a("tool_use"),name:n(),id:n(),input:S(n(),v()),_meta:S(n(),v()).optional()}),kt=r({type:a("resource"),resource:f([lt,ct]),annotations:X.optional(),_meta:S(n(),v()).optional()}),_t=dt.extend({type:a("resource_link")}),he=f([ze,Ue,Oe,_t,kt]),vs=r({role:ue,content:he}),Ts=L.extend({description:n().optional(),messages:h(vs)}),wt=j.extend({method:a("notifications/prompts/list_changed"),params:F.optional()}),qs=r({title:n().optional(),readOnlyHint:x().optional(),destructiveHint:x().optional(),idempotentHint:x().optional(),openWorldHint:x().optional()}),Cs=r({taskSupport:$(["required","optional","forbidden"]).optional()}),De=r({...Z.shape,...ie.shape,description:n().optional(),inputSchema:r({type:a("object"),properties:S(n(),H).optional(),required:h(n()).optional()}).catchall(v()),outputSchema:r({type:a("object"),properties:S(n(),H).optional(),required:h(n()).optional()}).catchall(v()).optional(),annotations:qs.optional(),execution:Cs.optional(),_meta:S(n(),v()).optional()}),Is=le.extend({method:a("tools/list")}),xt=ce.extend({tools:h(De)}),oe=L.extend({content:h(he).default([]),structuredContent:S(n(),v()).optional(),isError:x().optional()});oe.or(L.extend({toolResult:v()}));const Ps=ne.extend({name:n(),arguments:S(n(),v()).optional()}),Rt=N.extend({method:a("tools/call"),params:Ps}),vt=j.extend({method:a("notifications/tools/list_changed"),params:F.optional()});r({autoRefresh:x().default(!0),debounceMs:p().int().nonnegative().default(300)});const Tt=$(["debug","info","notice","warning","error","critical","alert","emergency"]),Hs=U.extend({level:Tt}),Es=N.extend({method:a("logging/setLevel"),params:Hs}),Ms=F.extend({level:Tt,logger:n().optional(),data:v()}),qt=j.extend({method:a("notifications/message"),params:Ms}),Ns=r({name:n().optional()}),Ls=r({hints:h(Ns).optional(),costPriority:p().min(0).max(1).optional(),speedPriority:p().min(0).max(1).optional(),intelligencePriority:p().min(0).max(1).optional()}),As=r({mode:$(["auto","required","none"]).optional()}),zs=r({type:a("tool_result"),toolUseId:n().describe("The unique identifier for the corresponding tool call."),content:h(he).default([]),structuredContent:r({}).loose().optional(),isError:x().optional(),_meta:S(n(),v()).optional()}),Us=tt("type",[ze,Ue,Oe]),be=tt("type",[ze,Ue,Oe,Rs,zs]),Os=r({role:ue,content:f([be,h(be)]),_meta:S(n(),v()).optional()}),Ds=ne.extend({messages:h(Os),modelPreferences:Ls.optional(),systemPrompt:n().optional(),includeContext:$(["none","thisServer","allServers"]).optional(),temperature:p().optional(),maxTokens:p().int(),stopSequences:h(n()).optional(),metadata:H.optional(),tools:h(De).optional(),toolChoice:As.optional()}),Ct=N.extend({method:a("sampling/createMessage"),params:Ds}),$s=L.extend({model:n(),stopReason:q($(["endTurn","stopSequence","maxTokens"]).or(n())),role:ue,content:Us}),Fs=L.extend({model:n(),stopReason:q($(["endTurn","stopSequence","maxTokens","toolUse"]).or(n())),role:ue,content:f([be,h(be)])}),js=r({type:a("boolean"),title:n().optional(),description:n().optional(),default:x().optional()}),Bs=r({type:a("string"),title:n().optional(),description:n().optional(),minLength:p().optional(),maxLength:p().optional(),format:$(["email","uri","date","date-time"]).optional(),default:n().optional()}),Js=r({type:$(["number","integer"]),title:n().optional(),description:n().optional(),minimum:p().optional(),maximum:p().optional(),default:p().optional()}),Vs=r({type:a("string"),title:n().optional(),description:n().optional(),enum:h(n()),default:n().optional()}),Qs=r({type:a("string"),title:n().optional(),description:n().optional(),oneOf:h(r({const:n(),title:n()})),default:n().optional()}),Ws=r({type:a("string"),title:n().optional(),description:n().optional(),enum:h(n()),enumNames:h(n()).optional(),default:n().optional()}),Ks=f([Vs,Qs]),Gs=r({type:a("array"),title:n().optional(),description:n().optional(),minItems:p().optional(),maxItems:p().optional(),items:r({type:a("string"),enum:h(n())}),default:h(n()).optional()}),Ys=r({type:a("array"),title:n().optional(),description:n().optional(),minItems:p().optional(),maxItems:p().optional(),items:r({anyOf:h(r({const:n(),title:n()}))}),default:h(n()).optional()}),Zs=f([Gs,Ys]),Xs=f([Ws,Ks,Zs]),eo=f([Xs,js,Bs,Js]),to=ne.extend({mode:a("form").optional(),message:n(),requestedSchema:r({type:a("object"),properties:S(n(),eo),required:h(n()).optional()})}),so=ne.extend({mode:a("url"),message:n(),elicitationId:n(),url:n().url()}),oo=f([to,so]),ao=N.extend({method:a("elicitation/create"),params:oo}),no=F.extend({elicitationId:n()}),ro=j.extend({method:a("notifications/elicitation/complete"),params:no}),io=L.extend({action:$(["accept","decline","cancel"]),content:et(l=>l===null?void 0:l,S(n(),f([n(),p(),x(),h(n())])).optional())}),lo=r({type:a("ref/resource"),uri:n()}),co=r({type:a("ref/prompt"),name:n()}),uo=U.extend({ref:f([co,lo]),argument:r({name:n(),value:n()}),context:r({arguments:S(n(),n()).optional()}).optional()}),ho=N.extend({method:a("completion/complete"),params:uo}),po=L.extend({completion:z({values:h(n()).max(100),total:q(p().int()),hasMore:q(x())})}),mo=r({uri:n().startsWith("file://"),name:n().optional(),_meta:S(n(),v()).optional()}),fo=N.extend({method:a("roots/list"),params:U.optional()}),go=L.extend({roots:h(mo)}),bo=j.extend({method:a("notifications/roots/list_changed"),params:F.optional()});f([ke,ss,ho,Es,xs,yt,ut,pt,ft,fs,bs,Rt,Is,Ie,He,Ee,Ne]);f([Te,qe,ns,bo,ge]);f([rt,$s,Fs,io,go,Pe,Me,Ce]);f([ke,Ct,ao,fo,Ie,He,Ee,Ne]);f([Te,qe,qt,Ss,bt,vt,wt,ge,ro]);f([rt,as,po,Ts,St,ht,mt,gt,oe,xt,Pe,Me,Ce]);class y extends Error{constructor(o,e,t){super(`MCP error ${o}: ${e}`),this.code=o,this.data=t,this.name="McpError"}static fromError(o,e,t){if(o===k.UrlElicitationRequired&&t){const s=t;if(s.elicitations)return new yo(s.elicitations,e)}return new y(o,e,t)}}class yo extends y{constructor(o,e=`URL elicitation${o.length>1?"s":""} required`){super(k.UrlElicitationRequired,e,{elicitations:o})}get elicitations(){var o;return((o=this.data)==null?void 0:o.elicitations)??[]}}function $e(l){return!!l._zod}function It(l,o){return $e(l)?Ot(l,o):l.safeParse(o)}function So(l){var e,t;if(!l)return;let o;if($e(l)?o=(t=(e=l._zod)==null?void 0:e.def)==null?void 0:t.shape:o=l.shape,!!o){if(typeof o=="function")try{return o()}catch{return}return o}}function ko(l){var s;if($e(l)){const c=(s=l._zod)==null?void 0:s.def;if(c){if(c.value!==void 0)return c.value;if(Array.isArray(c.values)&&c.values.length>0)return c.values[0]}}const e=l._def;if(e){if(e.value!==void 0)return e.value;if(Array.isArray(e.values)&&e.values.length>0)return e.values[0]}const t=l.value;if(t!==void 0)return t}function G(l){return l==="completed"||l==="failed"||l==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function We(l){const o=So(l),e=o==null?void 0:o.method;if(!e)throw new Error("Schema is missing a method literal");const t=ko(e);if(typeof t!="string")throw new Error("Schema method literal must be a string");return t}function Ke(l,o){const e=It(l,o);if(!e.success)throw e.error;return e.data}const _o=6e4;class wo{constructor(o){this._options=o,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Te,e=>{this._oncancel(e)}),this.setNotificationHandler(qe,e=>{this._onprogress(e)}),this.setRequestHandler(ke,e=>({})),this._taskStore=o==null?void 0:o.taskStore,this._taskMessageQueue=o==null?void 0:o.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ie,async(e,t)=>{const s=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!s)throw new y(k.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(He,async(e,t)=>{const s=async()=>{var u;const i=e.params.taskId;if(this._taskMessageQueue){let d;for(;d=await this._taskMessageQueue.dequeue(i,t.sessionId);){if(d.type==="response"||d.type==="error"){const g=d.message,w=g.id,_=this._requestResolvers.get(w);if(_)if(this._requestResolvers.delete(w),d.type==="response")_(g);else{const b=g,P=new y(b.error.code,b.error.message,b.error.data);_(P)}else{const b=d.type==="response"?"Response":"Error";this._onerror(new Error(`${b} handler missing for request ${w}`))}continue}await((u=this._transport)==null?void 0:u.send(d.message,{relatedRequestId:t.requestId}))}}const c=await this._taskStore.getTask(i,t.sessionId);if(!c)throw new y(k.InvalidParams,`Task not found: ${i}`);if(!G(c.status))return await this._waitForTaskUpdate(i,t.signal),await s();if(G(c.status)){const d=await this._taskStore.getTaskResult(i,t.sessionId);return this._clearTaskQueue(i),{...d,_meta:{...d._meta,[Y]:{taskId:i}}}}return await s()};return await s()}),this.setRequestHandler(Ee,async(e,t)=>{var s;try{const{tasks:i,nextCursor:c}=await this._taskStore.listTasks((s=e.params)==null?void 0:s.cursor,t.sessionId);return{tasks:i,nextCursor:c,_meta:{}}}catch(i){throw new y(k.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(Ne,async(e,t)=>{try{const s=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!s)throw new y(k.InvalidParams,`Task not found: ${e.params.taskId}`);if(G(s.status))throw new y(k.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,"cancelled","Client cancelled task execution.",t.sessionId),this._clearTaskQueue(e.params.taskId);const i=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!i)throw new y(k.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...i}}catch(s){throw s instanceof y?s:new y(k.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(o){if(!o.params.requestId)return;const e=this._requestHandlerAbortControllers.get(o.params.requestId);e==null||e.abort(o.params.reason)}_setupTimeout(o,e,t,s,i=!1){this._timeoutInfo.set(o,{timeoutId:setTimeout(s,e),startTime:Date.now(),timeout:e,maxTotalTimeout:t,resetTimeoutOnProgress:i,onTimeout:s})}_resetTimeout(o){const e=this._timeoutInfo.get(o);if(!e)return!1;const t=Date.now()-e.startTime;if(e.maxTotalTimeout&&t>=e.maxTotalTimeout)throw this._timeoutInfo.delete(o),y.fromError(k.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:e.maxTotalTimeout,totalElapsed:t});return clearTimeout(e.timeoutId),e.timeoutId=setTimeout(e.onTimeout,e.timeout),!0}_cleanupTimeout(o){const e=this._timeoutInfo.get(o);e&&(clearTimeout(e.timeoutId),this._timeoutInfo.delete(o))}async connect(o){var i,c,u;if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=o;const e=(i=this.transport)==null?void 0:i.onclose;this._transport.onclose=()=>{e==null||e(),this._onclose()};const t=(c=this.transport)==null?void 0:c.onerror;this._transport.onerror=d=>{t==null||t(d),this._onerror(d)};const s=(u=this._transport)==null?void 0:u.onmessage;this._transport.onmessage=(d,g)=>{s==null||s(d,g),fe(d)||Vt(d)?this._onresponse(d):Qe(d)?this._onrequest(d,g):Jt(d)?this._onnotification(d):this._onerror(new Error(`Unknown message type: ${JSON.stringify(d)}`))},await this._transport.start()}_onclose(){var t;const o=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const e=y.fromError(k.ConnectionClosed,"Connection closed");this._transport=void 0,(t=this.onclose)==null||t.call(this);for(const s of o.values())s(e)}_onerror(o){var e;(e=this.onerror)==null||e.call(this,o)}_onnotification(o){const e=this._notificationHandlers.get(o.method)??this.fallbackNotificationHandler;e!==void 0&&Promise.resolve().then(()=>e(o)).catch(t=>this._onerror(new Error(`Uncaught error in notification handler: ${t}`)))}_onrequest(o,e){var w,_,b,P;const t=this._requestHandlers.get(o.method)??this.fallbackRequestHandler,s=this._transport,i=(b=(_=(w=o.params)==null?void 0:w._meta)==null?void 0:_[Y])==null?void 0:b.taskId;if(t===void 0){const R={jsonrpc:"2.0",id:o.id,error:{code:k.MethodNotFound,message:"Method not found"}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:R,timestamp:Date.now()},s==null?void 0:s.sessionId).catch(C=>this._onerror(new Error(`Failed to enqueue error response: ${C}`))):s==null||s.send(R).catch(C=>this._onerror(new Error(`Failed to send an error response: ${C}`)));return}const c=new AbortController;this._requestHandlerAbortControllers.set(o.id,c);const u=Bt(o.params)?o.params.task:void 0,d=this._taskStore?this.requestTaskStore(o,s==null?void 0:s.sessionId):void 0,g={signal:c.signal,sessionId:s==null?void 0:s.sessionId,_meta:(P=o.params)==null?void 0:P._meta,sendNotification:async R=>{if(c.signal.aborted)return;const C={relatedRequestId:o.id};i&&(C.relatedTask={taskId:i}),await this.notification(R,C)},sendRequest:async(R,C,V)=>{var D;if(c.signal.aborted)throw new y(k.ConnectionClosed,"Request was cancelled");const O={...V,relatedRequestId:o.id};i&&!O.relatedTask&&(O.relatedTask={taskId:i});const Q=((D=O.relatedTask)==null?void 0:D.taskId)??i;return Q&&d&&await d.updateTaskStatus(Q,"input_required"),await this.request(R,C,O)},authInfo:e==null?void 0:e.authInfo,requestId:o.id,requestInfo:e==null?void 0:e.requestInfo,taskId:i,taskStore:d,taskRequestedTtl:u==null?void 0:u.ttl,closeSSEStream:e==null?void 0:e.closeSSEStream,closeStandaloneSSEStream:e==null?void 0:e.closeStandaloneSSEStream};Promise.resolve().then(()=>{u&&this.assertTaskHandlerCapability(o.method)}).then(()=>t(o,g)).then(async R=>{if(c.signal.aborted)return;const C={result:R,jsonrpc:"2.0",id:o.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:C,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(C))},async R=>{if(c.signal.aborted)return;const C={jsonrpc:"2.0",id:o.id,error:{code:Number.isSafeInteger(R.code)?R.code:k.InternalError,message:R.message??"Internal error",...R.data!==void 0&&{data:R.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"error",message:C,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send(C))}).catch(R=>this._onerror(new Error(`Failed to send response: ${R}`))).finally(()=>{this._requestHandlerAbortControllers.get(o.id)===c&&this._requestHandlerAbortControllers.delete(o.id)})}_onprogress(o){const{progressToken:e,...t}=o.params,s=Number(e),i=this._progressHandlers.get(s);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(o)}`));return}const c=this._responseHandlers.get(s),u=this._timeoutInfo.get(s);if(u&&c&&u.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(d){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),c(d);return}i(t)}_onresponse(o){const e=Number(o.id),t=this._requestResolvers.get(e);if(t){if(this._requestResolvers.delete(e),fe(o))t(o);else{const c=new y(o.error.code,o.error.message,o.error.data);t(c)}return}const s=this._responseHandlers.get(e);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(o)}`));return}this._responseHandlers.delete(e),this._cleanupTimeout(e);let i=!1;if(fe(o)&&o.result&&typeof o.result=="object"){const c=o.result;if(c.task&&typeof c.task=="object"){const u=c.task;typeof u.taskId=="string"&&(i=!0,this._taskProgressTokens.set(u.taskId,e))}}if(i||this._progressHandlers.delete(e),fe(o))s(o);else{const c=y.fromError(o.error.code,o.error.message,o.error.data);s(c)}}get transport(){return this._transport}async close(){var o;await((o=this._transport)==null?void 0:o.close())}async*requestStream(o,e,t){var c,u;const{task:s}=t??{};if(!s){try{yield{type:"result",result:await this.request(o,e,t)}}catch(d){yield{type:"error",error:d instanceof y?d:new y(k.InternalError,String(d))}}return}let i;try{const d=await this.request(o,Ce,t);if(d.task)i=d.task.taskId,yield{type:"taskCreated",task:d.task};else throw new y(k.InternalError,"Task creation did not return a task");for(;;){const g=await this.getTask({taskId:i},t);if(yield{type:"taskStatus",task:g},G(g.status)){g.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:i},e,t)}:g.status==="failed"?yield{type:"error",error:new y(k.InternalError,`Task ${i} failed`)}:g.status==="cancelled"&&(yield{type:"error",error:new y(k.InternalError,`Task ${i} was cancelled`)});return}if(g.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:i},e,t)};return}const w=g.pollInterval??((c=this._options)==null?void 0:c.defaultTaskPollInterval)??1e3;await new Promise(_=>setTimeout(_,w)),(u=t==null?void 0:t.signal)==null||u.throwIfAborted()}}catch(d){yield{type:"error",error:d instanceof y?d:new y(k.InternalError,String(d))}}}request(o,e,t){const{relatedRequestId:s,resumptionToken:i,onresumptiontoken:c,task:u,relatedTask:d}=t??{};return new Promise((g,w)=>{var Q,D,pe,me,I;const _=T=>{w(T)};if(!this._transport){_(new Error("Not connected"));return}if(((Q=this._options)==null?void 0:Q.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(o.method),u&&this.assertTaskCapability(o.method)}catch(T){_(T);return}(D=t==null?void 0:t.signal)==null||D.throwIfAborted();const b=this._requestMessageId++,P={...o,jsonrpc:"2.0",id:b};t!=null&&t.onprogress&&(this._progressHandlers.set(b,t.onprogress),P.params={...o.params,_meta:{...((pe=o.params)==null?void 0:pe._meta)||{},progressToken:b}}),u&&(P.params={...P.params,task:u}),d&&(P.params={...P.params,_meta:{...((me=P.params)==null?void 0:me._meta)||{},[Y]:d}});const R=T=>{var A;this._responseHandlers.delete(b),this._progressHandlers.delete(b),this._cleanupTimeout(b),(A=this._transport)==null||A.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:b,reason:String(T)}},{relatedRequestId:s,resumptionToken:i,onresumptiontoken:c}).catch(ee=>this._onerror(new Error(`Failed to send cancellation: ${ee}`)));const B=T instanceof y?T:new y(k.RequestTimeout,String(T));w(B)};this._responseHandlers.set(b,T=>{var B;if(!((B=t==null?void 0:t.signal)!=null&&B.aborted)){if(T instanceof Error)return w(T);try{const A=It(e,T.result);A.success?g(A.data):w(A.error)}catch(A){w(A)}}}),(I=t==null?void 0:t.signal)==null||I.addEventListener("abort",()=>{var T;R((T=t==null?void 0:t.signal)==null?void 0:T.reason)});const C=(t==null?void 0:t.timeout)??_o,V=()=>R(y.fromError(k.RequestTimeout,"Request timed out",{timeout:C}));this._setupTimeout(b,C,t==null?void 0:t.maxTotalTimeout,V,(t==null?void 0:t.resetTimeoutOnProgress)??!1);const O=d==null?void 0:d.taskId;if(O){const T=B=>{const A=this._responseHandlers.get(b);A?A(B):this._onerror(new Error(`Response handler missing for side-channeled request ${b}`))};this._requestResolvers.set(b,T),this._enqueueTaskMessage(O,{type:"request",message:P,timestamp:Date.now()}).catch(B=>{this._cleanupTimeout(b),w(B)})}else this._transport.send(P,{relatedRequestId:s,resumptionToken:i,onresumptiontoken:c}).catch(T=>{this._cleanupTimeout(b),w(T)})})}async getTask(o,e){return this.request({method:"tasks/get",params:o},Pe,e)}async getTaskResult(o,e,t){return this.request({method:"tasks/result",params:o},e,t)}async listTasks(o,e){return this.request({method:"tasks/list",params:o},Me,e)}async cancelTask(o,e){return this.request({method:"tasks/cancel",params:o},us,e)}async notification(o,e){var u,d,g,w;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(o.method);const t=(u=e==null?void 0:e.relatedTask)==null?void 0:u.taskId;if(t){const _={...o,jsonrpc:"2.0",params:{...o.params,_meta:{...((d=o.params)==null?void 0:d._meta)||{},[Y]:e.relatedTask}}};await this._enqueueTaskMessage(t,{type:"notification",message:_,timestamp:Date.now()});return}if((((g=this._options)==null?void 0:g.debouncedNotificationMethods)??[]).includes(o.method)&&!o.params&&!(e!=null&&e.relatedRequestId)&&!(e!=null&&e.relatedTask)){if(this._pendingDebouncedNotifications.has(o.method))return;this._pendingDebouncedNotifications.add(o.method),Promise.resolve().then(()=>{var b,P;if(this._pendingDebouncedNotifications.delete(o.method),!this._transport)return;let _={...o,jsonrpc:"2.0"};e!=null&&e.relatedTask&&(_={..._,params:{..._.params,_meta:{...((b=_.params)==null?void 0:b._meta)||{},[Y]:e.relatedTask}}}),(P=this._transport)==null||P.send(_,e).catch(R=>this._onerror(R))});return}let c={...o,jsonrpc:"2.0"};e!=null&&e.relatedTask&&(c={...c,params:{...c.params,_meta:{...((w=c.params)==null?void 0:w._meta)||{},[Y]:e.relatedTask}}}),await this._transport.send(c,e)}setRequestHandler(o,e){const t=We(o);this.assertRequestHandlerCapability(t),this._requestHandlers.set(t,(s,i)=>{const c=Ke(o,s);return Promise.resolve(e(c,i))})}removeRequestHandler(o){this._requestHandlers.delete(o)}assertCanSetRequestHandler(o){if(this._requestHandlers.has(o))throw new Error(`A request handler for ${o} already exists, which would be overridden`)}setNotificationHandler(o,e){const t=We(o);this._notificationHandlers.set(t,s=>{const i=Ke(o,s);return Promise.resolve(e(i))})}removeNotificationHandler(o){this._notificationHandlers.delete(o)}_cleanupTaskProgressHandler(o){const e=this._taskProgressTokens.get(o);e!==void 0&&(this._progressHandlers.delete(e),this._taskProgressTokens.delete(o))}async _enqueueTaskMessage(o,e,t){var i;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const s=(i=this._options)==null?void 0:i.maxTaskQueueSize;await this._taskMessageQueue.enqueue(o,e,t,s)}async _clearTaskQueue(o,e){if(this._taskMessageQueue){const t=await this._taskMessageQueue.dequeueAll(o,e);for(const s of t)if(s.type==="request"&&Qe(s.message)){const i=s.message.id,c=this._requestResolvers.get(i);c?(c(new y(k.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${o} cleanup`))}}}async _waitForTaskUpdate(o,e){var s,i;let t=((s=this._options)==null?void 0:s.defaultTaskPollInterval)??1e3;try{const c=await((i=this._taskStore)==null?void 0:i.getTask(o));c!=null&&c.pollInterval&&(t=c.pollInterval)}catch{}return new Promise((c,u)=>{if(e.aborted){u(new y(k.InvalidRequest,"Request cancelled"));return}const d=setTimeout(c,t);e.addEventListener("abort",()=>{clearTimeout(d),u(new y(k.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(o,e){const t=this._taskStore;if(!t)throw new Error("No task store configured");return{createTask:async s=>{if(!o)throw new Error("No request provided");return await t.createTask(s,o.id,{method:o.method,params:o.params},e)},getTask:async s=>{const i=await t.getTask(s,e);if(!i)throw new y(k.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(s,i,c)=>{await t.storeTaskResult(s,i,c,e);const u=await t.getTask(s,e);if(u){const d=ge.parse({method:"notifications/tasks/status",params:u});await this.notification(d),G(u.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>t.getTaskResult(s,e),updateTaskStatus:async(s,i,c)=>{const u=await t.getTask(s,e);if(!u)throw new y(k.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(G(u.status))throw new y(k.InvalidParams,`Cannot update task "${s}" from terminal status "${u.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await t.updateTaskStatus(s,i,c,e);const d=await t.getTask(s,e);if(d){const g=ge.parse({method:"notifications/tasks/status",params:d});await this.notification(g),G(d.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>t.listTasks(s,e)}}}(l=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(l,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):l)(function(l){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+l+'" is not supported')});class xo extends wo{constructor(){super(...arguments);m(this,"_registeredMethods",new Set);m(this,"_eventSlots",new Map);m(this,"setRequestHandler",(e,t)=>{this._assertMethodNotRegistered(e,"setRequestHandler"),super.setRequestHandler(e,t)});m(this,"setNotificationHandler",(e,t)=>{this._assertMethodNotRegistered(e,"setNotificationHandler"),super.setNotificationHandler(e,t)});m(this,"replaceRequestHandler",(e,t)=>{let s=e.shape.method.value;this._registeredMethods.add(s),super.setRequestHandler(e,t)})}onEventDispatch(e,t){}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t){let s=this.eventSchemas[e];if(!s)throw Error(`Unknown event: ${String(e)}`);t={listeners:[]},this._eventSlots.set(e,t);let i=s.shape.method.value;this._registeredMethods.add(i);let c=t;super.setNotificationHandler(s,u=>{var g;let d=u.params;this.onEventDispatch(e,d),(g=c.onHandler)==null||g.call(c,d);for(let w of[...c.listeners])w(d)})}return t}setEventHandler(e,t){let s=this._ensureEventSlot(e);s.onHandler&&t&&console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`),s.onHandler=t}getEventHandler(e){var t;return(t=this._eventSlots.get(e))==null?void 0:t.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let s=this._eventSlots.get(e);if(!s)return;let i=s.listeners.indexOf(t);i!==-1&&s.listeners.splice(i,1)}warnIfRequestHandlerReplaced(e,t,s){t&&s&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}_assertMethodNotRegistered(e,t){let s=e.shape.method.value;if(this._registeredMethods.has(s))throw Error(`Handler for "${s}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(s)}}var Pt="2026-01-26",Ro="ui/notifications/tool-input-partial",vo=f([a("light"),a("dark")]).describe("Color theme preference for the host environment."),ae=f([a("inline"),a("fullscreen"),a("pip")]).describe("Display mode for UI presentation."),To=f([a("--color-background-primary"),a("--color-background-secondary"),a("--color-background-tertiary"),a("--color-background-inverse"),a("--color-background-ghost"),a("--color-background-info"),a("--color-background-danger"),a("--color-background-success"),a("--color-background-warning"),a("--color-background-disabled"),a("--color-text-primary"),a("--color-text-secondary"),a("--color-text-tertiary"),a("--color-text-inverse"),a("--color-text-ghost"),a("--color-text-info"),a("--color-text-danger"),a("--color-text-success"),a("--color-text-warning"),a("--color-text-disabled"),a("--color-border-primary"),a("--color-border-secondary"),a("--color-border-tertiary"),a("--color-border-inverse"),a("--color-border-ghost"),a("--color-border-info"),a("--color-border-danger"),a("--color-border-success"),a("--color-border-warning"),a("--color-border-disabled"),a("--color-ring-primary"),a("--color-ring-secondary"),a("--color-ring-inverse"),a("--color-ring-info"),a("--color-ring-danger"),a("--color-ring-success"),a("--color-ring-warning"),a("--font-sans"),a("--font-mono"),a("--font-weight-normal"),a("--font-weight-medium"),a("--font-weight-semibold"),a("--font-weight-bold"),a("--font-text-xs-size"),a("--font-text-sm-size"),a("--font-text-md-size"),a("--font-text-lg-size"),a("--font-heading-xs-size"),a("--font-heading-sm-size"),a("--font-heading-md-size"),a("--font-heading-lg-size"),a("--font-heading-xl-size"),a("--font-heading-2xl-size"),a("--font-heading-3xl-size"),a("--font-text-xs-line-height"),a("--font-text-sm-line-height"),a("--font-text-md-line-height"),a("--font-text-lg-line-height"),a("--font-heading-xs-line-height"),a("--font-heading-sm-line-height"),a("--font-heading-md-line-height"),a("--font-heading-lg-line-height"),a("--font-heading-xl-line-height"),a("--font-heading-2xl-line-height"),a("--font-heading-3xl-line-height"),a("--border-radius-xs"),a("--border-radius-sm"),a("--border-radius-md"),a("--border-radius-lg"),a("--border-radius-xl"),a("--border-radius-full"),a("--border-width-regular"),a("--shadow-hairline"),a("--shadow-sm"),a("--shadow-md"),a("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),qo=S(To.describe(`Style variables for theming MCP apps.
|
|
2
2
|
|
|
3
3
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
4
4
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|