@grackle-ai/web 0.132.2 → 0.133.1

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.
@@ -1 +1 @@
1
- ._graphContainer_13vy2_1{flex:1;width:100%;height:100%;position:relative;overflow:hidden;background:radial-gradient(circle at 50% 50%,rgba(var(--accent-blue-rgb, 74, 158, 255),.03) 0%,transparent 70%)}._svg_13vy2_10{display:block;cursor:grab}._svg_13vy2_10:active{cursor:grabbing}._link_13vy2_18{stroke:var(--text-disabled, rgba(255, 255, 255, .2));stroke-width:1.5;opacity:.7;transition:opacity .3s ease,stroke .3s ease}._link_13vy2_18:hover{opacity:1;stroke:var(--text-secondary, rgba(255, 255, 255, .5));stroke-width:2}._node_13vy2_30{cursor:grab;transition:opacity .4s ease}._node_13vy2_30:active{cursor:grabbing}._node_13vy2_30:hover ._nodeCard_13vy2_37{filter:url(#glow);stroke:var(--node-color, var(--accent-blue));stroke-width:1.5;fill-opacity:.95}._node_13vy2_30:hover ._nodeLabel_13vy2_43{fill-opacity:1}._selected_13vy2_47 ._nodeCard_13vy2_37{filter:url(#glow);stroke:var(--node-color, var(--accent-blue));stroke-width:2;fill-opacity:1}._dimmed_13vy2_54{opacity:.15;pointer-events:none}._dimmedLink_13vy2_59{opacity:.05}._nodeCard_13vy2_37{fill:var(--bg-surface, rgba(30, 30, 50, .85));stroke:var(--border-default, rgba(255, 255, 255, .06));stroke-width:1;fill-opacity:.8;transition:fill-opacity .3s ease,stroke .3s ease,stroke-width .2s ease}._nodeIndicator_13vy2_71{opacity:.9}._nodeLabel_13vy2_43{fill:var(--text-primary, #e0e0e0);font-family:var(--font-sans, system-ui, -apple-system, sans-serif);font-size:12px;font-weight:500;fill-opacity:.9;pointer-events:none;-webkit-user-select:none;user-select:none}._nodeBadge_13vy2_85{fill:var(--text-disabled, #666);font-family:var(--font-mono, monospace);font-size:9px;font-weight:400;text-transform:uppercase;letter-spacing:.5px;pointer-events:none;-webkit-user-select:none;user-select:none}._panel_1wumt_1{position:absolute;top:0;right:0;bottom:0;width:350px;background:var(--bg-surface, #1a1a2e);border-left:1px solid var(--border-default, #333);display:flex;flex-direction:column;overflow-y:auto;z-index:10;animation:_slideIn_1wumt_1 .2s ease-out}@keyframes _slideIn_1wumt_1{0%{transform:translate(100%)}to{transform:translate(0)}}._header_1wumt_24{display:flex;align-items:center;justify-content:space-between;padding:16px;border-bottom:1px solid var(--border-default, #333)}._title_1wumt_32{margin:0;font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}._closeButton_1wumt_42{background:none;border:none;color:var(--text-secondary, #999);font-size:24px;cursor:pointer;padding:0 4px;line-height:1}._closeButton_1wumt_42:hover{color:var(--text-primary, #fff)}._body_1wumt_55{padding:16px;flex:1;overflow-y:auto}._badge_1wumt_61{display:inline-block;padding:2px 8px;border-radius:4px;font-size:12px;font-weight:500;background:var(--bg-inset, #222);color:var(--text-secondary, #999);margin-bottom:12px}._section_1wumt_72{margin-bottom:16px}._sectionLabel_1wumt_76{font-size:11px;font-weight:600;text-transform:uppercase;color:var(--text-disabled, #666);margin-bottom:6px}._content_1wumt_84{font-size:14px;line-height:1.5;color:var(--text-primary, #eee);margin:0;white-space:pre-wrap}._tags_1wumt_92{display:flex;flex-wrap:wrap;gap:4px}._tag_1wumt_92{display:inline-block;padding:2px 8px;border-radius:12px;font-size:12px;background:var(--bg-inset, #222);color:var(--text-secondary, #aaa)}._viewLink_1wumt_107{background:none;border:1px solid var(--accent-blue, #4a9eff);color:var(--accent-blue, #4a9eff);padding:6px 12px;border-radius:6px;cursor:pointer;font-size:13px}._viewLink_1wumt_107:hover{background:var(--accent-blue, #4a9eff);color:#fff}._edgeList_1wumt_121{list-style:none;padding:0;margin:0}._edgeItem_1wumt_127{display:flex;align-items:center;gap:8px;padding:4px 0;border-bottom:1px solid var(--border-default, #2a2a2a);font-size:13px}._edgeType_1wumt_136{font-family:monospace;font-size:11px;color:var(--text-disabled, #666)}._edgeNodeLink_1wumt_142{background:none;border:none;color:var(--accent-blue, #4a9eff);cursor:pointer;font-size:12px;font-family:monospace}._edgeNodeLink_1wumt_142:hover{text-decoration:underline}._timestamps_1wumt_154{margin-top:16px;font-size:12px;color:var(--text-disabled, #666)}._layout_n9vg6_1{display:flex;flex-direction:column;height:100%;overflow:hidden}._graphArea_n9vg6_8{flex:1;min-height:0;position:relative;overflow:hidden}._empty_n9vg6_15{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--text-secondary);text-align:center;padding:32px}._empty_n9vg6_15 p{margin:4px 0;font-size:14px}
1
+ ._graphContainer_13vy2_1{flex:1;width:100%;height:100%;position:relative;overflow:hidden;background:radial-gradient(circle at 50% 50%,rgba(var(--accent-blue-rgb, 74, 158, 255),.03) 0%,transparent 70%)}._svg_13vy2_10{display:block;cursor:grab}._svg_13vy2_10:active{cursor:grabbing}._link_13vy2_18{stroke:var(--text-disabled, rgba(255, 255, 255, .2));stroke-width:1.5;opacity:.7;transition:opacity .3s ease,stroke .3s ease}._link_13vy2_18:hover{opacity:1;stroke:var(--text-secondary, rgba(255, 255, 255, .5));stroke-width:2}._node_13vy2_30{cursor:grab;transition:opacity .4s ease}._node_13vy2_30:active{cursor:grabbing}._node_13vy2_30:hover ._nodeCard_13vy2_37{filter:url(#glow);stroke:var(--node-color, var(--accent-blue));stroke-width:1.5;fill-opacity:.95}._node_13vy2_30:hover ._nodeLabel_13vy2_43{fill-opacity:1}._selected_13vy2_47 ._nodeCard_13vy2_37{filter:url(#glow);stroke:var(--node-color, var(--accent-blue));stroke-width:2;fill-opacity:1}._dimmed_13vy2_54{opacity:.15;pointer-events:none}._dimmedLink_13vy2_59{opacity:.05}._nodeCard_13vy2_37{fill:var(--bg-surface, rgba(30, 30, 50, .85));stroke:var(--border-default, rgba(255, 255, 255, .06));stroke-width:1;fill-opacity:.8;transition:fill-opacity .3s ease,stroke .3s ease,stroke-width .2s ease}._nodeIndicator_13vy2_71{opacity:.9}._nodeLabel_13vy2_43{fill:var(--text-primary, #e0e0e0);font-family:var(--font-sans, system-ui, -apple-system, sans-serif);font-size:12px;font-weight:500;fill-opacity:.9;pointer-events:none;-webkit-user-select:none;user-select:none}._nodeBadge_13vy2_85{fill:var(--text-disabled, #666);font-family:var(--font-mono, monospace);font-size:9px;font-weight:400;text-transform:uppercase;letter-spacing:.5px;pointer-events:none;-webkit-user-select:none;user-select:none}._panel_1wumt_1{position:absolute;top:0;right:0;bottom:0;width:350px;background:var(--bg-surface, #1a1a2e);border-left:1px solid var(--border-default, #333);display:flex;flex-direction:column;overflow-y:auto;z-index:10;animation:_slideIn_1wumt_1 .2s ease-out}@keyframes _slideIn_1wumt_1{0%{transform:translate(100%)}to{transform:translate(0)}}._header_1wumt_24{display:flex;align-items:center;justify-content:space-between;padding:16px;border-bottom:1px solid var(--border-default, #333)}._title_1wumt_32{margin:0;font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}._closeButton_1wumt_42{background:none;border:none;color:var(--text-secondary, #999);font-size:24px;cursor:pointer;padding:0 4px;line-height:1}._closeButton_1wumt_42:hover{color:var(--text-primary, #fff)}._body_1wumt_55{padding:16px;flex:1;overflow-y:auto}._badge_1wumt_61{display:inline-block;padding:2px 8px;border-radius:4px;font-size:12px;font-weight:500;background:var(--bg-inset, #222);color:var(--text-secondary, #999);margin-bottom:12px}._section_1wumt_72{margin-bottom:16px}._sectionLabel_1wumt_76{font-size:11px;font-weight:600;text-transform:uppercase;color:var(--text-disabled, #666);margin-bottom:6px}._content_1wumt_84{font-size:14px;line-height:1.5;color:var(--text-primary, #eee);margin:0;white-space:pre-wrap}._tags_1wumt_92{display:flex;flex-wrap:wrap;gap:4px}._tag_1wumt_92{display:inline-block;padding:2px 8px;border-radius:12px;font-size:12px;background:var(--bg-inset, #222);color:var(--text-secondary, #aaa)}._viewLink_1wumt_107{background:none;border:1px solid var(--accent-blue, #4a9eff);color:var(--accent-blue, #4a9eff);padding:6px 12px;border-radius:6px;cursor:pointer;font-size:13px}._viewLink_1wumt_107:hover{background:var(--accent-blue, #4a9eff);color:#fff}._edgeList_1wumt_121{list-style:none;padding:0;margin:0}._edgeItem_1wumt_127{display:flex;align-items:center;gap:8px;padding:4px 0;border-bottom:1px solid var(--border-default, #2a2a2a);font-size:13px}._edgeType_1wumt_136{font-family:monospace;font-size:11px;color:var(--text-disabled, #666)}._edgeNodeLink_1wumt_142{background:none;border:none;color:var(--accent-blue, #4a9eff);cursor:pointer;font-size:12px;font-family:monospace}._edgeNodeLink_1wumt_142:hover{text-decoration:underline}._timestamps_1wumt_154{margin-top:16px;font-size:12px;color:var(--text-disabled, #666)}._layout_1wp49_1{display:flex;flex-direction:column;height:100%;overflow:hidden}._graphArea_1wp49_8{flex:1;min-height:0;position:relative;overflow:hidden}._empty_1wp49_15{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--text-secondary);text-align:center;padding:32px}._empty_1wp49_15 p{margin:4px 0;font-size:14px}._retryButton_1wp49_30{background:var(--bg-surface);border:1px solid var(--border-input);color:var(--accent-green);border-radius:var(--radius-md);cursor:pointer;font-family:var(--font-ui);box-shadow:var(--shadow-xs);transition:background var(--transition-fast),border-color var(--transition-fast)}._retryButton_1wp49_30:hover{background:var(--bg-overlay)}._retryButton_1wp49_30:focus-visible{outline:2px solid var(--ring);outline-offset:2px}._retryButton_1wp49_30:disabled{opacity:.64;cursor:not-allowed;pointer-events:none}._retryButton_1wp49_30{margin-top:var(--space-md);padding:var(--space-xs) var(--space-md);font-size:14px}
@@ -0,0 +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 w}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-BYoJMBJg.js";import"./grpc-CHXyF1mC.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,_=0,i=0;for(r=0;r<c;++r)d=n[r],_+=d.x,i+=d.y;for(_=(_/c-t)*o,i=(i/c-e)*o,r=0;r<c;++r)d=n[r],d.x-=_,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,_=t._y0,i=t._x1,v=t._y1,N,g,f,p,l,a,u,h;if(!r)return t._root=c,t;for(;r.length;)if((l=e>=(N=(d+i)/2))?d=N:i=N,(a=n>=(g=(_+v)/2))?_=g:v=g,s=r,!(r=r[u=a<<1|l]))return s[u]=c,t;if(f=+t._x.call(null,r.data),p=+t._y.call(null,r.data),e===f&&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>=(N=(d+i)/2))?d=N:i=N,(a=n>=(g=(_+v)/2))?_=g:v=g;while((u=a<<1|l)===(h=(p>=g)<<1|f>=N));return s[h]=r,s[u]=c,t}function gt(t){var e,n,o=t.length,s,r,c=new Array(o),d=new Array(o),_=1/0,i=1/0,v=-1/0,N=-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<_&&(_=s),s>v&&(v=s),r<i&&(i=r),r>N&&(N=r));if(_>v||i>N)return this;for(this.cover(_,i).cover(v,N),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,_,i;n>t||t>=s||o>e||e>=r;)switch(i=(e<o)<<1|t<n,_=new Array(4),_[i]=d,d=_,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 yt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function _t(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,_,i,v=this._x1,N=this._y1,g=[],f=this._root,p,l;for(f&&g.push(new L(f,s,r,v,N)),n==null?n=1/0:(s=t-n,r=e-n,v=t+n,N=e+n,n*=n);p=g.pop();)if(!(!(f=p.node)||(c=p.x0)>v||(d=p.y0)>N||(_=p.x1)<s||(i=p.y1)<r))if(f.length){var a=(c+_)/2,u=(d+i)/2;g.push(new L(f[3],a,u,_,i),new L(f[2],c,u,a,i),new L(f[1],a,d,_,u),new L(f[0],c,d,a,u)),(l=(e>=u)<<1|t>=a)&&(p=g[g.length-1],g[g.length-1]=g[g.length-1-l],g[g.length-1-l]=p)}else{var h=t-+this._x.call(null,f.data),m=e-+this._y.call(null,f.data),y=h*h+m*m;if(y<n){var b=Math.sqrt(n=y);s=t-b,r=e-b,v=t+b,N=e+b,o=f.data}}return o}function mt(t){if(isNaN(v=+this._x.call(null,t))||isNaN(N=+this._y.call(null,t)))return this;var e,n=this._root,o,s,r,c=this._x0,d=this._y0,_=this._x1,i=this._y1,v,N,g,f,p,l,a,u;if(!n)return this;if(n.length)for(;;){if((p=v>=(g=(c+_)/2))?c=g:_=g,(l=N>=(f=(d+i)/2))?d=f:i=f,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,_;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,_=n.y1)&&o.length){var i=(r+d)/2,v=(c+_)/2;(s=o[3])&&e.push(new L(s,i,v,d,_)),(s=o[2])&&e.push(new L(s,r,v,i,_)),(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 jt(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,_=o.x1,i=o.y1,v=(c+_)/2,N=(d+i)/2;(r=s[0])&&e.push(new L(r,c,d,v,N)),(r=s[1])&&e.push(new L(r,v,d,_,N)),(r=s[2])&&e.push(new L(r,c,N,v,i)),(r=s[3])&&e.push(new L(r,v,N,_,i))}n.push(o)}for(;o=n.pop();)t(o.node,o.x0,o.y0,o.x1,o.y1);return this}function kt(t){return t[0]}function At(t){return arguments.length?(this._x=t,this):this._x}function Ct(t){return t[1]}function Mt(t){return arguments.length?(this._y=t,this):this._y}function P(t,e,n){var o=new U(e??kt,n??Ct,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=yt;R.extent=_t;R.find=vt;R.remove=mt;R.removeAll=pt;R.root=wt;R.size=Nt;R.visit=bt;R.visitAfter=jt;R.x=At;R.y=Mt;function G(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=G(t==null?1:+t));function c(){for(var i,v=e.length,N,g,f,p,l,a,u=0;u<r;++u)for(N=P(e,It,Lt).visitAfter(d),i=0;i<v;++i)g=e[i],l=n[g.index],a=l*l,f=g.x+g.vx,p=g.y+g.vy,N.visit(h);function h(m,y,b,C,I){var j=m.data,B=m.r,x=l+B;if(j){if(j.index>g.index){var k=f-j.x-j.vx,z=p-j.y-j.vy,D=k*k+z*z;D<x*x&&(k===0&&(k=S(o),D+=k*k),z===0&&(z=S(o),D+=z*z),D=(x-(D=Math.sqrt(D)))/D*s,g.vx+=(k*=D)*(x=(B*=B)/(a+B)),g.vy+=(z*=D)*x,j.vx-=k*(x=1-x),j.vy-=z*x)}return}return y>f+x||C<f-x||b>p+x||I<p-x}}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 _(){if(e){var i,v=e.length,N;for(n=new Array(v),i=0;i<v;++i)N=e[i],n[N.index]=+t(N,i,e)}}return c.initialize=function(i,v){e=i,o=v,_()},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:G(+i),_(),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 Bt(t){var e=Et,n=N,o,s=G(30),r,c,d,_,i,v=1;t==null&&(t=[]);function N(a){return 1/Math.min(d[a.source.index],d[a.target.index])}function g(a){for(var u=0,h=t.length;u<v;++u)for(var m=0,y,b,C,I,j,B,x;m<h;++m)y=t[m],b=y.source,C=y.target,I=C.x+C.vx-b.x-b.vx||S(i),j=C.y+C.vy-b.y-b.vy||S(i),B=Math.sqrt(I*I+j*j),B=(B-r[m])/B*a*o[m],I*=B,j*=B,C.vx-=I*(x=_[m]),C.vy-=j*x,b.vx+=I*(x=1-x),b.vy+=j*x}function f(){if(c){var a,u=c.length,h=t.length,m=new Map(c.map((b,C)=>[e(b,C,c),b])),y;for(a=0,d=new Array(u);a<h;++a)y=t[a],y.index=a,typeof y.source!="object"&&(y.source=W(m,y.source)),typeof y.target!="object"&&(y.target=W(m,y.target)),d[y.source.index]=(d[y.source.index]||0)+1,d[y.target.index]=(d[y.target.index]||0)+1;for(a=0,_=new Array(h);a<h;++a)y=t[a],_[a]=d[y.source.index]/(d[y.source.index]+d[y.target.index]);o=new Array(h),p(),r=new Array(h),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 g.initialize=function(a,u){c=a,i=u,f()},g.links=function(a){return arguments.length?(t=a,f(),g):t},g.id=function(a){return arguments.length?(e=a,g):e},g.iterations=function(a){return arguments.length?(v=+a,g):v},g.strength=function(a){return arguments.length?(n=typeof a=="function"?a:G(+a),p(),g):n},g.distance=function(a){return arguments.length?(s=typeof a=="function"?a:G(+a),l(),g):s},g}const Dt=1664525,zt=1013904223,Q=4294967296;function Tt(){let t=1;return()=>(t=(Dt*t+zt)%Q)/Q}function St(t){return t.x}function Ft(t){return t.y}var $t=10,Gt=Math.PI*(3-Math.sqrt(5));function Ot(t){var e,n=1,o=.001,s=1-Math.pow(o,1/300),r=0,c=.6,d=new Map,_=nt(N),i=rt("tick","end"),v=Tt();t==null&&(t=[]);function N(){g(),i.call("tick",e),n<o&&(_.stop(),i.call("end",e))}function g(l){var a,u=t.length,h;l===void 0&&(l=1);for(var m=0;m<l;++m)for(n+=(r-n)*s,d.forEach(function(y){y(n)}),a=0;a<u;++a)h=t[a],h.fx==null?h.x+=h.vx*=c:(h.x=h.fx,h.vx=0),h.fy==null?h.y+=h.vy*=c:(h.y=h.fy,h.vy=0);return e}function f(){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 h=$t*Math.sqrt(.5+l),m=l*Gt;u.x=h*Math.cos(m),u.y=h*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 f(),e={tick:g,restart:function(){return _.restart(N),e},stop:function(){return _.stop(),e},nodes:function(l){return arguments.length?(t=l,f(),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 h=0,m=t.length,y,b,C,I,j;for(u==null?u=1/0:u*=u,h=0;h<m;++h)I=t[h],y=l-I.x,b=a-I.y,C=y*y+b*b,C<u&&(j=I,u=C);return j},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Kt(){var t,e,n,o,s=G(-30),r,c=1,d=1/0,_=.81;function i(f){var p,l=t.length,a=P(t,St,Ft).visitAfter(N);for(o=f,p=0;p<l;++p)e=t[p],a.visit(g)}function v(){if(t){var f,p=t.length,l;for(r=new Array(p),f=0;f<p;++f)l=t[f],r[l.index]=+s(l,f,t)}}function N(f){var p=0,l,a,u=0,h,m,y;if(f.length){for(h=m=y=0;y<4;++y)(l=f[y])&&(a=Math.abs(l.value))&&(p+=l.value,u+=a,h+=a*l.x,m+=a*l.y);f.x=h/u,f.y=m/u}else{l=f,l.x=l.data.x,l.y=l.data.y;do p+=r[l.data.index];while(l=l.next)}f.value=p}function g(f,p,l,a){if(!f.value)return!0;var u=f.x-e.x,h=f.y-e.y,m=a-p,y=u*u+h*h;if(m*m/_<y)return y<d&&(u===0&&(u=S(n),y+=u*u),h===0&&(h=S(n),y+=h*h),y<c&&(y=Math.sqrt(c*y)),e.vx+=u*f.value*o/y,e.vy+=h*f.value*o/y),!0;if(f.length||y>=d)return;(f.data!==e||f.next)&&(u===0&&(u=S(n),y+=u*u),h===0&&(h=S(n),y+=h*h),y<c&&(y=Math.sqrt(c*y)));do f.data!==e&&(m=r[f.data.index]*o/y,e.vx+=u*m,e.vy+=h*m);while(f=f.next)}return i.initialize=function(f,p){t=f,n=p,v()},i.strength=function(f){return arguments.length?(s=typeof f=="function"?f:G(+f),v(),i):s},i.distanceMin=function(f){return arguments.length?(c=f*f,i):Math.sqrt(c)},i.distanceMax=function(f){return arguments.length?(d=f*f,i):Math.sqrt(d)},i.theta=function(f){return arguments.length?(_=f*f,i):Math.sqrt(_)},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},H={reference:"#4A9EFF",decision:"#22C55E",insight:"#EAB308",concept:"#A855F7",snippet:"#6B7280"};function V(t){return t.kind==="reference"?H.reference:H[t.category??"insight"]??H.insight}const F=200,$=52,Z=12,K=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-F/2-K,d=o+F/2+K,_=s-$/2-K,i=r+$/2+K,v=d-c,N=i-_,g=Math.min(e.width/v,e.height/N,1),f=(c+d)/2,p=(_+i)/2;return{translateX:e.width/2-f*g,translateY:e.height/2-p*g,scale:g}}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),_=A.useRef(void 0),i=A.useRef(void 0),v=A.useRef(e);v.current=e;const N=A.useRef(!1),[g,f]=A.useState({width:800,height:600}),p=A.useRef(0);A.useEffect(()=>{var y;const h=((y=s.current)==null?void 0:y.parentElement)??null;if(!h)return;const m=new ResizeObserver(b=>{for(const C of b)f({width:C.contentRect.width,height:C.contentRect.height})});return m.observe(h),f({width:h.clientWidth,height:h.clientHeight}),()=>{m.disconnect()}},[]),A.useEffect(()=>{if(!s.current||!r.current)return;const h=s.current,m=r.current,y=it().scaleExtent([.1,4]).filter(b=>b.type!=="dblclick").on("zoom",b=>{T(m).attr("transform",String(b.transform))});return T(h).call(y),d.current=y,()=>{T(h).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 h=r.current;if(c.current&&(c.current.stop(),c.current=void 0),N.current=!1,t.nodes.length===0){T(h).selectAll("*").remove();return}const m=t.nodes.map(x=>({...x})),y=new Map(m.map(x=>[x.id,x])),b=t.links.filter(x=>y.has(x.source)&&y.has(x.target)).map(x=>({source:x.source,target:x.target,type:x.type}));T(h).selectAll("*").remove();const C=T(h).selectAll("line").data(b).enter().append("line").attr("class",E.link);C.append("title").text(x=>x.type),_.current=C;const I=T(h).selectAll("g.kg-node").data(m).enter().append("g").attr("class",`kg-node ${E.node}`).on("click",(x,k)=>{p.current>J||l.current(k.id)}).on("dblclick",(x,k)=>{a.current(k.id)});i.current=I,I.append("rect").attr("class",E.nodeCard).attr("width",F).attr("height",$).attr("rx",Z).attr("ry",Z).style("--node-color",x=>V(x)),I.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",$).attr("rx",2).attr("fill",x=>V(x)),I.append("text").attr("class",E.nodeLabel).attr("x",F/2).attr("y",$/2-4).attr("text-anchor","middle").attr("dominant-baseline","central").text(x=>x.label.length>26?x.label.substring(0,24)+"...":x.label),I.append("text").attr("class",E.nodeBadge).attr("x",F/2).attr("y",$-8).attr("text-anchor","middle").text(x=>(x.kind==="reference"?x.sourceType??"ref":x.category??"").toUpperCase());const j=Ot(m).force("link",Bt(b).id(x=>x.id).distance(140)).force("charge",Kt().strength(-400)).force("center",ht(g.width/2,g.height/2)).force("collide",Rt(F/2+16)).on("tick",()=>{C.attr("x1",x=>x.source.x??0).attr("y1",x=>x.source.y??0).attr("x2",x=>x.target.x??0).attr("y2",x=>x.target.y??0),I.attr("transform",x=>`translate(${(x.x??0)-F/2},${(x.y??0)-$/2})`)});c.current=j;const B=st().on("start",(x,k)=>{k.fx=k.x,k.fy=k.y,p.current=0}).on("drag",(x,k)=>{k.fx=x.x,k.fy=x.y,p.current+=Math.abs(x.dx)+Math.abs(x.dy),p.current>J&&j.alphaTarget()===0&&j.alphaTarget(.3).restart()}).on("end",(x,k)=>{x.active||j.alphaTarget(0),k.fx=void 0,k.fy=void 0});return I.call(B),j.on("end",()=>{if(s.current&&d.current&&m.length>0&&!N.current&&!v.current){N.current=!0;const x=te(m,g);if(!x)return;const{translateX:k,translateY:z,scale:D}=x,tt=d.current,et=X.translate(k,z).scale(D);T(s.current).transition().duration(500).call(tt.transform,et)}}),()=>{j.stop()}},[t,g]),A.useEffect(()=>{if(!r.current||!i.current||!_.current)return;if(!e){i.current.classed(E.dimmed,!1).classed(E.selected,!1),_.current.classed(E.dimmedLink,!1);return}const h=new Set([e]);_.current.each(m=>{const y=m.source.id,b=m.target.id;(y===e||b===e)&&(h.add(y),h.add(b))}),i.current.classed(E.selected,m=>m.id===e).classed(E.dimmed,m=>!h.has(m.id)),_.current.classed(E.dimmedLink,m=>{const y=m.source.id,b=m.target.id;return!h.has(y)||!h.has(b)})},[e,t]);const u=A.useCallback(()=>{if(!e||!c.current||!s.current||!d.current)return;const h=c.current.nodes().find(m=>m.id===e);if(h&&Number.isFinite(h.x)&&Number.isFinite(h.y)){const m=d.current,y=X.translate(g.width/2,g.height/2).scale(1.2).translate(-(h.x??0),-(h.y??0));T(s.current).transition().duration(500).call(m.transform,y)}},[e,g]);return A.useEffect(()=>{u()},[u]),w.jsx("div",{className:E.graphContainer,"data-testid":"knowledge-graph",children:w.jsxs("svg",{ref:s,width:g.width,height:g.height,className:E.svg,children:[w.jsx("defs",{children:w.jsxs("filter",{id:"glow",children:[w.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),w.jsxs("feMerge",{children:[w.jsx("feMergeNode",{in:"coloredBlur"}),w.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),w.jsx("g",{ref:r})]})})}const ne="_panel_1wumt_1",re="_header_1wumt_24",ie="_title_1wumt_32",se="_closeButton_1wumt_42",ae="_body_1wumt_55",oe="_badge_1wumt_61",ce="_section_1wumt_72",le="_sectionLabel_1wumt_76",ue="_content_1wumt_84",fe="_tags_1wumt_92",he="_tag_1wumt_92",de="_viewLink_1wumt_107",ge="_edgeList_1wumt_121",xe="_edgeItem_1wumt_127",ye="_edgeType_1wumt_136",_e="_edgeNodeLink_1wumt_142",ve="_timestamps_1wumt_154",M={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:ye,edgeNodeLink:_e,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 _(){if(!(r.kind!=="reference"||!r.sourceId))switch(r.sourceType){case"task":s(ct(r.sourceId));break;case"session":s(ot(r.sourceId));break}}return w.jsxs("div",{className:M.panel,"data-testid":"knowledge-detail-panel",children:[w.jsxs("div",{className:M.header,children:[w.jsx("h3",{className:M.title,children:r.label}),w.jsx("button",{className:M.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),w.jsxs("div",{className:M.body,children:[w.jsx("div",{className:M.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&w.jsxs("div",{className:M.section,children:[w.jsx("div",{className:M.sectionLabel,children:"Content"}),w.jsx("p",{className:M.content,children:r.content})]}),r.tags&&r.tags.length>0&&w.jsxs("div",{className:M.section,children:[w.jsx("div",{className:M.sectionLabel,children:"Tags"}),w.jsx("div",{className:M.tags,children:r.tags.map(i=>w.jsx("span",{className:M.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&w.jsx("div",{className:M.section,children:w.jsx("button",{className:M.viewLink,onClick:_,children:"View in Grackle →"})}),c.length>0&&w.jsxs("div",{className:M.section,children:[w.jsxs("div",{className:M.sectionLabel,children:["Edges (",c.length,")"]}),w.jsx("ul",{className:M.edgeList,children:c.map(i=>{var g;const v=i.fromId===r.id?i.toId:i.fromId,N=`${i.fromId}:${i.toId}:${i.type}`;return w.jsxs("li",{className:M.edgeItem,"data-testid":"edge-item",children:[w.jsx("span",{className:M.edgeType,"data-testid":"edge-type",children:i.type}),w.jsx("button",{className:M.edgeNodeLink,"data-testid":"edge-node-link",onClick:()=>{o(v)},children:((g=d.get(v))==null?void 0:g.label)??`${v.substring(0,8)}...`})]},N)})})]}),w.jsxs("div",{className:M.timestamps,children:[r.createdAt&&w.jsxs("div",{children:["Created: ",new Date(r.createdAt).toLocaleDateString()]}),r.updatedAt&&w.jsxs("div",{children:["Updated: ",new Date(r.updatedAt).toLocaleDateString()]})]})]})]})}const pe="_layout_1wp49_1",we="_graphArea_1wp49_8",Ne="_empty_1wp49_15",be="_retryButton_1wp49_30",O={layout:pe,graphArea:we,empty:Ne,retryButton:be};function Me(){const{knowledge:t}=lt(),{loadRecent:e,loadError:n,loading:o,graphData:s,selectedId:r,selectedNode:c}=t,{selectNode:d,expandNode:_,clearSelection:i}=t;A.useEffect(()=>{e().catch(()=>{})},[e]);const v=A.useCallback(()=>{e().catch(()=>{})},[e]),N=A.useCallback(u=>{d(u).catch(()=>{})},[d]),g=A.useCallback(u=>{_(u).catch(()=>{})},[_]),f=A.useCallback(()=>{i()},[i]),p=[{label:"Knowledge",url:ft}],l=n!==void 0&&!o,a=!l&&s.nodes.length===0&&!o;return w.jsxs("div",{className:O.layout,"data-testid":"knowledge-page",children:[w.jsx(ut,{segments:p}),w.jsxs("div",{className:O.graphArea,children:[l?w.jsxs("div",{className:O.empty,"data-testid":"knowledge-error",children:[n==="unavailable"?w.jsxs(w.Fragment,{children:[w.jsx("p",{children:"Knowledge server can't be reached."}),w.jsx("p",{children:"The knowledge graph database (Neo4j) isn't running or is unreachable. Start it, then retry."})]}):w.jsxs(w.Fragment,{children:[w.jsx("p",{children:"Failed to load the knowledge graph."}),w.jsx("p",{children:"Something went wrong while loading knowledge nodes."})]}),w.jsx("button",{type:"button",className:O.retryButton,onClick:v,"data-testid":"knowledge-retry",children:"Retry"})]}):a?w.jsxs("div",{className:O.empty,children:[w.jsx("p",{children:"No knowledge nodes found."}),w.jsx("p",{children:"Create knowledge via MCP tools or let agents discover it during tasks."})]}):w.jsx(ee,{graphData:s,selectedNodeId:r,onNodeClick:N,onNodeDoubleClick:g}),c&&r&&w.jsx(me,{detail:c,nodes:s.nodes,onClose:f,onSelectNode:N})]})]})}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-D5yEdhAi.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-CHXyF1mC.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.).