@callbag-recharge/callbag-recharge 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/dist/adapters/http.cjs +4 -4
  2. package/dist/adapters/http.js +1 -1
  3. package/dist/adapters/index.cjs +11 -11
  4. package/dist/adapters/index.d.cts +1 -0
  5. package/dist/adapters/index.d.ts +1 -0
  6. package/dist/adapters/index.js +1 -1
  7. package/dist/adapters/mcp.cjs +5 -5
  8. package/dist/adapters/mcp.d.cts +4 -4
  9. package/dist/adapters/mcp.d.ts +4 -4
  10. package/dist/adapters/mcp.js +1 -1
  11. package/dist/adapters/sse.cjs +10 -10
  12. package/dist/adapters/sse.d.cts +3 -2
  13. package/dist/adapters/sse.d.ts +3 -2
  14. package/dist/adapters/sse.js +1 -1
  15. package/dist/adapters/webhook.cjs +4 -4
  16. package/dist/adapters/webhook.d.cts +3 -2
  17. package/dist/adapters/webhook.d.ts +3 -2
  18. package/dist/adapters/webhook.js +1 -1
  19. package/dist/ai/agentLoop/index.cjs +4 -4
  20. package/dist/ai/agentLoop/index.js +1 -1
  21. package/dist/ai/chatStream/index.cjs +4 -4
  22. package/dist/ai/chatStream/index.d.cts +4 -3
  23. package/dist/ai/chatStream/index.d.ts +4 -3
  24. package/dist/ai/chatStream/index.js +1 -1
  25. package/dist/ai/conversationSummary/index.d.cts +2 -1
  26. package/dist/ai/conversationSummary/index.d.ts +2 -1
  27. package/dist/ai/docIndex/index.cjs +4 -4
  28. package/dist/ai/docIndex/index.js +1 -1
  29. package/dist/ai/embeddingIndex/index.cjs +4 -4
  30. package/dist/ai/embeddingIndex/index.js +1 -1
  31. package/dist/ai/fromLLM.cjs +5 -5
  32. package/dist/ai/fromLLM.js +1 -1
  33. package/dist/ai/index.cjs +39 -13
  34. package/dist/ai/index.d.cts +390 -8
  35. package/dist/ai/index.d.ts +390 -8
  36. package/dist/ai/index.js +27 -1
  37. package/dist/ai/memoryStore/index.cjs +3 -3
  38. package/dist/ai/memoryStore/index.d.cts +1 -1
  39. package/dist/ai/memoryStore/index.d.ts +1 -1
  40. package/dist/ai/memoryStore/index.js +1 -1
  41. package/dist/ai/ragPipeline/index.cjs +1 -1
  42. package/dist/ai/ragPipeline/index.d.cts +1 -1
  43. package/dist/ai/ragPipeline/index.d.ts +1 -1
  44. package/dist/ai/ragPipeline/index.js +1 -1
  45. package/dist/ai/toolCallState/index.cjs +4 -4
  46. package/dist/ai/toolCallState/index.d.cts +1 -1
  47. package/dist/ai/toolCallState/index.d.ts +1 -1
  48. package/dist/ai/toolCallState/index.js +1 -1
  49. package/dist/{checkpoint-Bycg2nWZ.d.ts → checkpoint-CC4tKs36.d.ts} +7 -6
  50. package/dist/{checkpoint-pDVUAV4-.d.cts → checkpoint-uaYS0fN4.d.cts} +7 -6
  51. package/dist/chunk-2DNXE5W2.js +1 -0
  52. package/dist/chunk-3ORARRVS.js +1 -0
  53. package/dist/chunk-4PAUY5AJ.js +1 -0
  54. package/dist/chunk-565W67EU.js +11 -0
  55. package/dist/chunk-5UIA6BIQ.js +1 -0
  56. package/dist/chunk-6WZQIJIW.js +2 -0
  57. package/dist/chunk-AA2V6B63.js +1 -0
  58. package/dist/chunk-BBWZHYCT.js +1 -0
  59. package/dist/chunk-CDEQNFFU.js +1 -0
  60. package/dist/chunk-DTYSGTF4.js +1 -0
  61. package/dist/chunk-FJ2VN2O3.js +1 -0
  62. package/dist/chunk-FJMF46AF.js +1 -0
  63. package/dist/chunk-IB56FLRE.js +1 -0
  64. package/dist/chunk-J2E7GAMR.js +1 -0
  65. package/dist/chunk-JWQFJJJB.js +2 -0
  66. package/dist/chunk-LMR6RVT4.js +1 -0
  67. package/dist/chunk-O2PONDZT.js +1 -0
  68. package/dist/{chunk-2PBFMNE3.js → chunk-S67PXKAL.js} +1 -1
  69. package/dist/chunk-T5LUMTB7.js +1 -0
  70. package/dist/chunk-VHVYJSLE.js +1 -0
  71. package/dist/chunk-X2LL44CL.js +1 -0
  72. package/dist/chunk-XD4BHZSL.js +1 -0
  73. package/dist/chunk-Y72LPOTS.js +1 -0
  74. package/dist/chunk-YCYCWSXF.js +1 -0
  75. package/dist/{chunk-K56FIBDL.js → chunk-Z6NJHBGT.js} +1 -1
  76. package/dist/data/index.js +1 -1
  77. package/dist/{executionLog-CREljpYk.d.cts → executionLog-BIdo4sqy.d.cts} +7 -6
  78. package/dist/{executionLog-cGvVp5Ha.d.ts → executionLog-EPbLbbSd.d.ts} +7 -6
  79. package/dist/extra/fromPromise.js +1 -1
  80. package/dist/extra/index.cjs +1 -1
  81. package/dist/extra/index.d.cts +2 -1
  82. package/dist/extra/index.d.ts +2 -1
  83. package/dist/extra/index.js +1 -1
  84. package/dist/index.js +1 -1
  85. package/dist/memory/index.cjs +1 -1
  86. package/dist/memory/index.d.cts +2 -2
  87. package/dist/memory/index.d.ts +2 -2
  88. package/dist/memory/index.js +1 -1
  89. package/dist/messaging/index.cjs +6 -6
  90. package/dist/messaging/index.d.cts +8 -297
  91. package/dist/messaging/index.d.ts +8 -297
  92. package/dist/messaging/index.js +3 -3
  93. package/dist/orchestrate/executionLogAdapters.node.cjs +6 -6
  94. package/dist/orchestrate/executionLogAdapters.node.d.cts +3 -2
  95. package/dist/orchestrate/executionLogAdapters.node.d.ts +3 -2
  96. package/dist/orchestrate/executionLogAdapters.node.js +3 -3
  97. package/dist/orchestrate/index.cjs +6 -6
  98. package/dist/orchestrate/index.d.cts +14 -10
  99. package/dist/orchestrate/index.d.ts +14 -10
  100. package/dist/orchestrate/index.js +3 -3
  101. package/dist/patterns/pagination/index.cjs +4 -4
  102. package/dist/patterns/pagination/index.js +1 -1
  103. package/dist/patterns/textEditor/index.cjs +15 -15
  104. package/dist/patterns/textEditor/index.d.cts +5 -3
  105. package/dist/patterns/textEditor/index.d.ts +5 -3
  106. package/dist/patterns/textEditor/index.js +7 -7
  107. package/dist/{rateLimiter-DMeuSBxF.d.ts → rateLimiter-C9FDu1n0.d.cts} +4 -2
  108. package/dist/{rateLimiter-DMeuSBxF.d.cts → rateLimiter-nMWFRXZi.d.ts} +4 -2
  109. package/dist/subscribe-BHH8VVDm.d.cts +4 -0
  110. package/dist/subscribe-BHH8VVDm.d.ts +4 -0
  111. package/dist/{tokenTracker-BYan5lb-.d.ts → tokenTracker-BRFP4C1K.d.ts} +2 -2
  112. package/dist/{tokenTracker-DGkjfZtH.d.cts → tokenTracker-C1y5zB38.d.cts} +2 -2
  113. package/dist/types-CJKW4Ae9.d.ts +298 -0
  114. package/dist/{types-DtkjWIED.d.ts → types-ClmMSIr-.d.ts} +7 -1
  115. package/dist/{types-BwBbIZux.d.cts → types-DbCdOVbw.d.cts} +7 -1
  116. package/dist/types-XRfOHCPC.d.cts +298 -0
  117. package/dist/utils/checkpointAdapters.node.cjs +1 -1
  118. package/dist/utils/checkpointAdapters.node.d.cts +3 -2
  119. package/dist/utils/checkpointAdapters.node.d.ts +3 -2
  120. package/dist/utils/checkpointAdapters.node.js +1 -1
  121. package/dist/utils/index.cjs +9 -9
  122. package/dist/utils/index.d.cts +28 -30
  123. package/dist/utils/index.d.ts +28 -30
  124. package/dist/utils/index.js +6 -6
  125. package/package.json +1 -1
  126. package/dist/chunk-4AGPQIMR.js +0 -1
  127. package/dist/chunk-4VPAGOLZ.js +0 -1
  128. package/dist/chunk-7B4DHRG6.js +0 -1
  129. package/dist/chunk-7LEA46F2.js +0 -1
  130. package/dist/chunk-EPTXIJMZ.js +0 -1
  131. package/dist/chunk-F5EXEEZL.js +0 -1
  132. package/dist/chunk-GGTHKVOX.js +0 -1
  133. package/dist/chunk-GMHR7NSQ.js +0 -1
  134. package/dist/chunk-I3EB4ACM.js +0 -1
  135. package/dist/chunk-LCCRCFKU.js +0 -1
  136. package/dist/chunk-LJ4NZDHS.js +0 -1
  137. package/dist/chunk-OLSVNROW.js +0 -1
  138. package/dist/chunk-PLIRVTP4.js +0 -11
  139. package/dist/chunk-Q5DHO5II.js +0 -2
  140. package/dist/chunk-RC3JWVKF.js +0 -1
  141. package/dist/chunk-USLFDJX2.js +0 -1
  142. package/dist/chunk-VESAQ43T.js +0 -2
  143. package/dist/chunk-WQAE4SFB.js +0 -1
  144. package/dist/chunk-YOXJZ2O5.js +0 -1
  145. package/dist/chunk-ZDGVUX5G.js +0 -1
@@ -1,4 +1,4 @@
1
- "use strict";var te=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Oe=Object.prototype.hasOwnProperty;var Le=(t,e)=>{for(var i in e)te(t,i,{get:e[i],enumerable:!0})},Ae=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of we(e))!Oe.call(t,s)&&s!==i&&te(t,s,{get:()=>e[s],enumerable:!(n=Re(e,s))||n.enumerable});return t};var Ie=t=>Ae(te({},"__esModule",{value:!0}),t);var je={};Le(je,{fromHTTP:()=>Me});module.exports=Ie(je);var D=Symbol("DIRTY"),M=Symbol("RESOLVED"),le=Symbol("SINGLE_DEP"),P=Symbol("RESET"),se=Symbol("PAUSE"),ie=Symbol("RESUME"),re=Symbol("TEARDOWN");function ue(t){return t===P||t===se||t===ie||t===re}var ce=0,fe=1,de=2,pe=3,ge=4,he=5,R=7,oe=7<<R,$e=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function Te(t){return $e[(t&oe)>>>R]}var h=0,_=1,g=2,S=3,H=0,q=[],ne=!1;function j(t){H++;try{return t()}finally{if(H--,H===0&&!ne){ne=!0;for(let e=0;e<q.length;e++)q[e]();q.length=0,ne=!1}}}function $(){return H>0}function z(t){q.push(t)}var G=0,B=[];function Se(){G++}function _e(){if(G--,G===0){for(let t=0;t<B.length;t++)B[t]();B.length=0}}function me(t){G>0?B.push(t):t()}var A=class t{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static _annotations=new WeakMap;static _traceLog=[];static _traceHead=0;static _traceFull=!1;static maxTraceEntries=1e3;static get enabled(){if(t._explicitEnabled!==null)return t._explicitEnabled;if(t._cachedDefault!==null)return t._cachedDefault;try{t._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{t._cachedDefault=!0}return t._cachedDefault}static set enabled(e){t._explicitEnabled=e}static _depSuffix(e){if(!e?.length)return;let n=e.map(s=>t._names.get(s)??"?").join(",");return n.length>40?`${n.slice(0,37)}...`:n}static _resolveKey(e){let i=t._keys.get(e)??t._names.get(e);if(i)return i;let n=`anonymous_${t._nextId++}`;return t._keys.set(e,n),n}static register(e,i){if(!t.enabled)return;i?.name&&t._names.set(e,i.name),i?.kind&&t._kinds.set(e,i.kind);let n=t._nextId++,s=i?.name;if(!(s&&!t._usedKeys.has(s)))if(s){let r=t._depSuffix(i?.deps);s=r?`${s}(${r})`:`${s}_${n}`,t._usedKeys.has(s)&&(s=`${s}_${n}`)}else{let r=i?.kind??"store",a=t._depSuffix(i?.deps);s=a?`${r}(${a})`:`${r}_${n}`,t._usedKeys.has(s)&&(s=`${s}_${n}`)}t._usedKeys.add(s),t._keys.set(e,s),t._stores.add(new WeakRef(e))}static registerEdge(e,i){if(!t.enabled)return;let n=t._resolveKey(e),s=t._resolveKey(i),r=t._edges.get(n);r?r.includes(s)||r.push(s):t._edges.set(n,[s])}static getEdges(){return new Map(t._edges)}static getName(e){if(t.enabled)return t._names.get(e)}static getKind(e){return t._kinds.get(e)}static inspect(e){return{name:t._names.get(e),kind:t._kinds.get(e)??"unknown",value:typeof e.get=="function"?e.get():void 0,status:e._status}}static graph(){let e=new Map,i=new Set;for(let n of t._stores){let s=n.deref();if(!s){t._stores.delete(n);continue}let r=t._resolveKey(s);i.add(r),e.set(r,t.inspect(s))}for(let[n,s]of t._edges){if(!i.has(n)){t._edges.delete(n),t._usedKeys.delete(n);continue}let r=s.filter(a=>i.has(a));r.length===0?t._edges.delete(n):r.length!==s.length&&t._edges.set(n,r)}return e}static trace(e,i){let n=null,s=e.get();return e.source(h,(r,a)=>{if(r===h&&(n=a),r===g){n=null;return}if(r===1){let l=a;if(!Object.is(l,s)){let u=s;s=l,i(l,u)}}}),()=>n?.(g)}static dumpGraph(){let e=t.graph(),i=t.getEdges(),n=new Map;for(let[a,l]of i)for(let u of l){let f=n.get(u);f?f.includes(a)||f.push(a):n.set(u,[a])}let s=[];for(let[a,l]of e){let u=n.get(a),f=i.get(a),o=u?.length?` \u2190 [${u.join(", ")}]`:"",c=f?.length?` \u2192 [${f.join(", ")}]`:"";s.push(` ${a} (${l.kind}) = ${JSON.stringify(l.value)} [${l.status??"?"}]${o}${c}`)}return[`Store Graph (${e.size} nodes):`,...s].join(`
2
- `)}static _signalLabel(e){return e===D?"DIRTY":e===M?"RESOLVED":typeof e=="symbol"?e.description??String(e):String(e)}static _observe(e,i,n){let s=null,r=!1,a=i??t.getName(e),l=[],u={values:[],signals:[],events:[],ended:!1,endError:void 0,get completedCleanly(){return u.ended&&!r},get errored(){return u.ended&&r},dirtyCount:0,resolvedCount:0,name:a,get eventLog(){return l},dispose:()=>s?.(g),reconnect:()=>(s?.(g),t._observe(e,i,n))};return e.source(h,(f,o)=>{if(f===h){s=o;return}let c=$();f===_?(u.values.push(o),u.events.push({type:"data",data:o,inBatch:c}),l.push(o),n&&n(`[${a}] DATA:`,o)):f===S?(u.signals.push(o),u.events.push({type:"signal",data:o,inBatch:c}),l.push(t._signalLabel(o)),o===D?u.dirtyCount++:o===M&&u.resolvedCount++,n&&n(`[${a}] STATE:`,o)):f===g&&(u.ended=!0,u.endError=o,r=o!==void 0,u.events.push({type:"end",data:o,inBatch:c}),l.push(r?["END",o]:"END"),n&&n(`[${a}] END`,o!==void 0?o:""),s=null)}),u}static observe(e){return t._observe(e)}static activate(e){let i=null;return e.source(h,(n,s)=>{n===h&&(i=s),n===g&&(i=null)}),()=>i?.(g)}static tap(e,i){let n=i??`tap(${t.getName(e)??"anon"})`,s={get:()=>e.get(),source:e.source};return t.register(s,{name:n,kind:"tap"}),t.registerEdge(e,s),s}static spy(e,i){let n=i?.name??t.getName(e)??"spy",s=i?.log??console.log;return t._observe(e,n,s)}static snapshot(){let e=t.graph(),i=t.getEdges(),n=new Map;for(let a of t._stores){let l=a.deref();if(!l)continue;let u=t._annotations.get(l);u!==void 0&&n.set(t._resolveKey(l),u)}let s=[];for(let[a,l]of e){let u={name:a,kind:l.kind,value:l.value,status:l.status},f=n.get(a);f!==void 0&&(u.annotation=f),s.push(u)}let r=[];for(let[a,l]of i)for(let u of l)r.push({from:a,to:u});return{nodes:s,edges:r,trace:t.traceLog()}}static toMermaid(e){let i=e?.direction??"TD",n=t.snapshot(),s=[`graph ${i}`],r={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},a=new Map;function l(o){let c=o.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(c);return d===void 0?(a.set(c,1),c):(a.set(c,d+1),`${c}__${d}`)}let u=new Map;function f(o){let c=JSON.stringify(o);return c&&c.length>30?`${c.slice(0,27)}...`:c??"undefined"}for(let o of n.nodes){let c=l(o.name);u.set(o.name,c);let d=`${o.name} (${o.kind}) = ${f(o.value)}`,p=r[o.status??""]??"";s.push(` ${c}["${d}"]${p}`)}for(let o of n.edges){let c=u.get(o.from)??l(o.from),d=u.get(o.to)??l(o.to);s.push(` ${c} --> ${d}`)}return s.push(""),s.push(" classDef settled fill:#d4edda,stroke:#28a745"),s.push(" classDef dirty fill:#fff3cd,stroke:#ffc107"),s.push(" classDef errored fill:#f8d7da,stroke:#dc3545"),s.push(" classDef completed fill:#cce5ff,stroke:#007bff"),s.join(`
3
- `)}static toD2(e){let i=e?.direction??"down",n=t.snapshot(),s=[`direction: ${i}`,""],r={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},a=new Map;function l(o){let c=o.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(c);return d===void 0?(a.set(c,1),c):(a.set(c,d+1),`${c}__${d}`)}let u=new Map;function f(o){let c=JSON.stringify(o);return c&&c.length>30?`${c.slice(0,27)}...`:c??"undefined"}for(let o of n.nodes){let c=l(o.name);u.set(o.name,c);let d=r[o.kind]??"rectangle",p=`${o.name} (${o.kind}) = ${f(o.value)}`,y=o.status?` [${o.status}]`:"";s.push(`${c}: "${p}${y}" { shape: ${d} }`)}n.edges.length>0&&s.push("");for(let o of n.edges){let c=u.get(o.from)??l(o.from),d=u.get(o.to)??l(o.to);s.push(`${c} -> ${d}`)}return s.join(`
4
- `)}static annotate(e,i){if(!t.enabled)return;t._annotations.set(e,i);let n={node:t._resolveKey(e),reason:i,timestamp:Date.now()},s=t.maxTraceEntries;s<=0||(t._traceLog.length<s?t._traceLog.push(n):(t._traceLog[t._traceHead]=n,t._traceFull=!0),t._traceHead=(t._traceHead+1)%s)}static getAnnotation(e){return t._annotations.get(e)}static traceLog(){return t._traceFull?[...t._traceLog.slice(t._traceHead),...t._traceLog.slice(0,t._traceHead)]:t._traceLog.slice(0,t._traceHead||t._traceLog.length)}static clearTrace(){t._traceLog=[],t._traceHead=0,t._traceFull=!1}static timeline(e){let i=null,n=[];return e.source(h,(s,r)=>{if(s===h){i=r;return}let a={timestamp:Date.now(),type:s===_?"data":s===S?"signal":"end",data:r,inBatch:$()};n.push(a),s===g&&(i=null)}),{entries:n,dispose:()=>i?.(g)}}static observeDerived(e){let i=[],n=e,s=n._fn;if(typeof s!="function"||!Array.isArray(n._deps))return{...t.observe(e),evaluations:i};n._fn=()=>{let u=n._deps.map(o=>o.get()),f=s();return i.push({result:f,depValues:u,timestamp:Date.now()}),f};let r=t._observe(e),a=r.dispose;return{...r,evaluations:i,dispose:()=>{n._fn=s,a()},reconnect:()=>(n._fn=s,a(),t.observeDerived(e))}}static observeTaskState(e){let i=e.status.get(),n=[],s=null;return e.status.source(h,(r,a)=>{if(r===h){s=a;return}if(r===_){let l=a;if(l!==i){let u={from:i,to:l,timestamp:Date.now()};l==="error"&&(u.error=e.error.get()),n.push(u),i=l}}r===g&&(s=null)}),{transitions:n,get currentStatus(){return e.status.get()},dispose:()=>{s?.(g)}}}static causalityTrace(e){let i=[],n=e,s=n._fn;if(typeof s!="function"||!Array.isArray(n._deps))return{...t.observe(e),causality:i};let r=n._deps,a=r.map(o=>o.get());n._fn=()=>{let o=r.map(p=>p.get()),c=s(),d=-1;for(let p=0;p<r.length;p++)if(!Object.is(o[p],a[p])){d=p;break}return i.push({result:c,triggerDepIndex:d,triggerDepName:d>=0?t.getName(r[d]):void 0,depValues:o,timestamp:Date.now()}),a=o,c};let l=t._observe(e),u=l.dispose;return{...l,causality:i,dispose:()=>{n._fn=s,u()},reconnect:()=>(n._fn=s,u(),t.causalityTrace(e))}}static _reset(){t._names=new WeakMap,t._kinds=new WeakMap,t._keys=new WeakMap,t._stores=new Set,t._edges=new Map,t._usedKeys=new Set,t._nextId=0,t._explicitEnabled=null,t._cachedDefault=null,t._annotations=new WeakMap,t._traceLog=[],t._traceHead=0,t._traceFull=!1,t.maxTraceEntries=1e3}};var J=1,E=64,m=2,N=4,ye=8,be=16,I=32,k=1024,T=oe,C=fe<<R,W=de<<R,Z=ce<<R,Pe=ge<<R,Ne=he<<R,Ce=pe<<R,F=class{_value;_output=null;_flags;get _status(){return Te(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;_onLifecycleSignal;constructor(e,i){this._value=i?.initial,this._fn=e,this._eqFn=i?.equals,this._getterFn=i?.getter,this._initial=i?.initial;let n=0;i?.autoDirty!==!1&&(n|=N),i?.resetOnTeardown&&(n|=ye),i?.resubscribable&&(n|=be),this._flags=n,this.source=this.source.bind(this),this.emit=this.emit.bind(this),i?._skipInspect||A.register(this,{kind:"producer",...i})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(e,i){let n=this._output;if(n)if(this._flags&E)for(let s of n)s(e,i);else n(e,i)}emit(e){this._flags&m||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&($()?this._flags&I||(this._flags|=I,this._flags&N&&(this._flags=this._flags&~T|C,this._dispatch(S,D)),z(()=>{this._flags&=~I,this._flags=this._flags&~T|W,this._dispatch(_,this._value)})):(this._flags&N&&!(this._flags&k)&&(this._flags=this._flags&~T|C,this._dispatch(S,D)),this._flags=this._flags&~T|W,this._dispatch(_,this._value))))}signal(e){this._flags&m||!this._output||(e===D?this._flags=this._flags&~T|C:e===M&&(this._flags=this._flags&~T|Ce),this._dispatch(S,e))}complete(){if(this._flags&m)return;this._flags=(this._flags|m)&~T|Pe;let e=this._output,i=this._flags&E;if(this._output=null,this._flags&=~(E|k),this._singleDepCount=0,this._stop(),e)if(i)for(let n of e)n(g);else e(g)}error(e){if(this._flags&m)return;this._flags=(this._flags|m)&~T|Ne;let i=this._output,n=this._flags&E;if(this._output=null,this._flags&=~(E|k),this._singleDepCount=0,this._stop(),i)if(n)for(let s of i)s(g,e);else i(g,e)}_start(){if(this._flags&J||!this._fn)return;this._flags|=J,this._onLifecycleSignal=void 0;let e=this._fn({emit:this.emit,signal:i=>this.signal(i),complete:()=>this.complete(),error:i=>this.error(i),onSignal:i=>{this._onLifecycleSignal=i}});this._cleanup=typeof e=="function"?e:void 0}_stop(){this._flags&J&&(this._flags&=~J,this._onLifecycleSignal=void 0,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&ye&&(this._value=this._initial),this._flags&m||(this._flags=this._flags&~T|Z))}_handleLifecycleSignal(e){if(!(this._flags&m)){if(e===re){this._onLifecycleSignal?.(e),this.complete();return}e===P&&(this._value=this._initial,this._flags&=~I),this._onLifecycleSignal?.(e),e===P&&this.emit(this._initial)}}source(e,i){if(e===h){let n=i;if(this._flags&m)if(this._flags&be&&this._output===null)this._flags=this._flags&~(m|T)|Z;else{n(h,r=>{}),n(g);return}if(this._output===null)this._output=n;else if(this._flags&E)this._output.add(n);else{let r=new Set;r.add(this._output),r.add(n),this._output=r,this._flags=(this._flags|E)&~k}let s=!1;n(h,(r,a)=>{if(r===_&&n(_,this._value),r===S){a===le&&!s?(s=!0,this._singleDepCount++,this._flags&E||(this._flags|=k)):ue(a)&&this._handleLifecycleSignal(a);return}if(r===g){if(s&&(s=!1,this._singleDepCount--),this._output===null)return;if(this._flags&E){let l=this._output;l.delete(n),l.size===1?(this._output=l.values().next().value,this._flags&=~E,this._singleDepCount>0&&(this._flags|=k)):l.size===0&&(this._output=null,this._flags&=~(E|k),this._singleDepCount=0,this._flags=this._flags&~T|Z,this._stop())}else this._output===n&&(this._output=null,this._flags&=~k,this._singleDepCount=0,this._flags=this._flags&~T|Z,this._stop())}}),me(()=>this._start())}}};function Q(t,e){return new F(t,e)}var ae=class extends F{constructor(e,i){super(void 0,{initial:e,autoDirty:!0,equals:i?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),A.register(this,{kind:"state",...i})}get(){return this._value}set(e){this._flags&m||this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&($()?this._flags&I||(this._flags|=I,this._flags&N&&(this._flags=this._flags&~T|C,this._dispatch(S,D)),z(()=>{this._flags&=~I,this._flags=this._flags&~T|W,this._dispatch(_,this._value)})):(this._flags&N&&!(this._flags&k)&&(this._flags=this._flags&~T|C,this._dispatch(S,D)),this._flags=this._flags&~T|W,this._dispatch(_,this._value))))}update(e){this.set(e(this._value))}};function K(t,e){return new ae(t,e)}function ve(t,e,i){let n=null;Se(),t.source(h,(r,a)=>{if(r===h&&(n=a),r===g){n=null,i?.onEnd?.(a);return}if(r===1){let l=a,u=s;s=l,e(l,u)}});let s;try{s=t.get()}catch{}return _e(),{unsubscribe(){n?.(g),n=null},signal(r){n?.(S,r)}}}function Ee(t,e){let i=e?.initialStatus??"pending",n=K(i,{name:"withStatus:status",equals:Object.is}),s=K(void 0,{name:"withStatus:error",equals:Object.is}),r=Q(({emit:l,complete:u,error:f})=>{n.set(i),s.set(void 0);let o=ve(t,c=>{n.get()==="errored"?j(()=>{s.set(void 0),n.set("active")}):n.set("active"),l(c)},{onEnd:c=>{if(c!==void 0){let d=c instanceof Error?c:new Error(String(c));j(()=>{s.set(d),n.set("errored")}),f(c)}else n.set("completed"),u()}});return()=>{o.unsubscribe()}},{initial:t.get(),resubscribable:!0}),a={get:()=>t.get(),source:(l,u)=>r.source(l,u),get _status(){return r._status},status:n,error:s};return A.register(a,{kind:"withStatus"}),a}function Me(t,e){let i=e?.name??"http",n=e?.method??"GET",s=e?.headers,r=e?.body,a=e?.poll??0,l=e?.transform??(w=>w.json()),u=e?.timeout??3e4,f=K(0,{name:`${i}:fetchCount`}),o=null,c=null,d=null,p=null,y=null,b=!1;async function V(){if(!b||!o)return;y=new AbortController;let w=[y.signal];e?.signal&&w.push(e.signal);let O=new AbortController;for(let v of w){if(v.aborted){O.abort(v.reason);break}v.addEventListener("abort",()=>O.abort(v.reason),{once:!0})}let ee=setTimeout(()=>O.abort(new Error("Request timeout")),u);try{let v=r!==void 0?typeof r=="string"?r:JSON.stringify(r):void 0,L=await fetch(t,{method:n,headers:s,body:v,signal:O.signal});if(!b)return;if(!L.ok)throw new Error(`HTTP ${L.status}: ${L.statusText}`);let ke=await l(L);if(!b)return;j(()=>{f.update(xe=>xe+1),o?.(ke)})}catch(v){if(!b||v?.name==="AbortError")return;c?.(v)}finally{clearTimeout(ee),y=null}}function U(){!b||x||a<=0||(p=setTimeout(()=>{p=null,V().then(()=>{b&&!x&&U()}).catch(()=>{})},a))}let X=null,x=!1,De=Q(({emit:w,error:O,complete:ee,onSignal:v})=>(o=w,c=O,d=ee,b=!0,x=!1,X=()=>{V()},v(L=>{L===se?(x=!0,p!==null&&(clearTimeout(p),p=null)):L===ie?(x=!1,U()):L===P&&(y?.abort(),y=null,p!==null&&(clearTimeout(p),p=null),f.set(0),x=!1,V().then(()=>{b&&!x&&U()}))}),V().then(()=>{b&&!x&&U()}),()=>{b=!1,x=!1,o=null,c=null,d=null,X=null,y?.abort(),y=null,p!==null&&(clearTimeout(p),p=null)}),{name:i,kind:"http"}),Y=Ee(De);return{get:()=>Y.get(),source:(w,O)=>Y.source(w,O),status:Y.status,error:Y.error,fetchCount:f,refetch(){X?.()},stop(){b=!1,y?.abort(),y=null,p!==null&&(clearTimeout(p),p=null),d?.()}}}0&&(module.exports={fromHTTP});
1
+ "use strict";var te=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Pe=Object.prototype.hasOwnProperty;var Ce=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},$e=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Oe(t))!Pe.call(e,s)&&s!==r&&te(e,s,{get:()=>t[s],enumerable:!(n=Ie(t,s))||n.enumerable});return e};var Ne=e=>$e(te({},"__esModule",{value:!0}),e);var He={};Ce(He,{fromHTTP:()=>Ye});module.exports=Ne(He);var E=Symbol("DIRTY"),j=Symbol("RESOLVED"),fe=Symbol("SINGLE_DEP"),C=Symbol("RESET"),se=Symbol("PAUSE"),re=Symbol("RESUME"),ie=Symbol("TEARDOWN");function de(e){return e===C||e===se||e===re||e===ie}var pe=0,ge=1,he=2,Te=3,me=4,Se=5,x=7,oe=7<<x,Me=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function _e(e){return Me[(e&oe)>>>x]}var h=0,y=1,g=2,_=3,H=0,q=[],ne=!1;function F(e){H++;try{return e()}finally{if(H--,H===0&&!ne){ne=!0;for(let t=0;t<q.length;t++)q[t]();q.length=0,ne=!1}}}function O(){return H>0}function z(e){q.push(e)}var G=0,B=[];function ye(){G++}function be(){if(G--,G===0){for(let e=0;e<B.length;e++)B[e]();B.length=0}}function ve(e){G>0?B.push(e):e()}var A=class e{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static _annotations=new WeakMap;static _traceLog=[];static _traceHead=0;static _traceFull=!1;static maxTraceEntries=1e3;static get enabled(){if(e._explicitEnabled!==null)return e._explicitEnabled;if(e._cachedDefault!==null)return e._cachedDefault;try{e._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{e._cachedDefault=!0}return e._cachedDefault}static set enabled(t){e._explicitEnabled=t}static _depSuffix(t){if(!t?.length)return;let n=t.map(s=>e._names.get(s)??"?").join(",");return n.length>40?`${n.slice(0,37)}...`:n}static _resolveKey(t){let r=e._keys.get(t)??e._names.get(t);if(r)return r;let n=`anonymous_${e._nextId++}`;return e._keys.set(t,n),n}static register(t,r){if(!e.enabled)return;r?.name&&e._names.set(t,r.name),r?.kind&&e._kinds.set(t,r.kind);let n=e._nextId++,s=r?.name;if(!(s&&!e._usedKeys.has(s)))if(s){let i=e._depSuffix(r?.deps);s=i?`${s}(${i})`:`${s}_${n}`,e._usedKeys.has(s)&&(s=`${s}_${n}`)}else{let i=r?.kind??"store",a=e._depSuffix(r?.deps);s=a?`${i}(${a})`:`${i}_${n}`,e._usedKeys.has(s)&&(s=`${s}_${n}`)}e._usedKeys.add(s),e._keys.set(t,s),e._stores.add(new WeakRef(t))}static registerEdge(t,r){if(!e.enabled)return;let n=e._resolveKey(t),s=e._resolveKey(r),i=e._edges.get(n);i?i.includes(s)||i.push(s):e._edges.set(n,[s])}static getEdges(){return new Map(e._edges)}static getName(t){if(e.enabled)return e._names.get(t)}static getKind(t){return e._kinds.get(t)}static inspect(t){return{name:e._names.get(t),kind:e._kinds.get(t)??"unknown",value:typeof t.get=="function"?t.get():void 0,status:t._status}}static graph(){let t=new Map,r=new Set;for(let n of e._stores){let s=n.deref();if(!s){e._stores.delete(n);continue}let i=e._resolveKey(s);r.add(i),t.set(i,e.inspect(s))}for(let[n,s]of e._edges){if(!r.has(n)){e._edges.delete(n),e._usedKeys.delete(n);continue}let i=s.filter(a=>r.has(a));i.length===0?e._edges.delete(n):i.length!==s.length&&e._edges.set(n,i)}return t}static trace(t,r){let n=null,s=t.get();return t.source(h,(i,a)=>{if(i===h&&(n=a),i===g){n=null;return}if(i===1){let u=a;if(!Object.is(u,s)){let l=s;s=u,r(u,l)}}}),()=>n?.(g)}static dumpGraph(){let t=e.graph(),r=e.getEdges(),n=new Map;for(let[a,u]of r)for(let l of u){let f=n.get(l);f?f.includes(a)||f.push(a):n.set(l,[a])}let s=[];for(let[a,u]of t){let l=n.get(a),f=r.get(a),o=l?.length?` \u2190 [${l.join(", ")}]`:"",c=f?.length?` \u2192 [${f.join(", ")}]`:"";s.push(` ${a} (${u.kind}) = ${JSON.stringify(u.value)} [${u.status??"?"}]${o}${c}`)}return[`Store Graph (${t.size} nodes):`,...s].join(`
2
+ `)}static _signalLabel(t){return t===E?"DIRTY":t===j?"RESOLVED":typeof t=="symbol"?t.description??String(t):String(t)}static _observe(t,r,n){let s=null,i=!1,a=r??e.getName(t),u=[],l={values:[],signals:[],events:[],ended:!1,endError:void 0,get completedCleanly(){return l.ended&&!i},get errored(){return l.ended&&i},dirtyCount:0,resolvedCount:0,name:a,get eventLog(){return u},dispose:()=>s?.(g),reconnect:()=>(s?.(g),e._observe(t,r,n))};return t.source(h,(f,o)=>{if(f===h){s=o;return}let c=O();f===y?(l.values.push(o),l.events.push({type:"data",data:o,inBatch:c}),u.push(o),n&&n(`[${a}] DATA:`,o)):f===_?(l.signals.push(o),l.events.push({type:"signal",data:o,inBatch:c}),u.push(e._signalLabel(o)),o===E?l.dirtyCount++:o===j&&l.resolvedCount++,n&&n(`[${a}] STATE:`,o)):f===g&&(l.ended=!0,l.endError=o,i=o!==void 0,l.events.push({type:"end",data:o,inBatch:c}),u.push(i?["END",o]:"END"),n&&n(`[${a}] END`,o!==void 0?o:""),s=null)}),l}static observe(t){return e._observe(t)}static activate(t){let r=null;return t.source(h,(n,s)=>{n===h&&(r=s),n===g&&(r=null)}),()=>r?.(g)}static tap(t,r){let n=r??`tap(${e.getName(t)??"anon"})`,s={get:()=>t.get(),source:t.source};return e.register(s,{name:n,kind:"tap"}),e.registerEdge(t,s),s}static spy(t,r){let n=r?.name??e.getName(t)??"spy",s=r?.log??console.log;return e._observe(t,n,s)}static snapshot(){let t=e.graph(),r=e.getEdges(),n=new Map;for(let a of e._stores){let u=a.deref();if(!u)continue;let l=e._annotations.get(u);l!==void 0&&n.set(e._resolveKey(u),l)}let s=[];for(let[a,u]of t){let l={name:a,kind:u.kind,value:u.value,status:u.status},f=n.get(a);f!==void 0&&(l.annotation=f),s.push(l)}let i=[];for(let[a,u]of r)for(let l of u)i.push({from:a,to:l});return{nodes:s,edges:i,trace:e.traceLog()}}static toMermaid(t){let r=t?.direction??"TD",n=e.snapshot(),s=[`graph ${r}`],i={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},a=new Map;function u(o){let c=o.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(c);return d===void 0?(a.set(c,1),c):(a.set(c,d+1),`${c}__${d}`)}let l=new Map;function f(o){let c=JSON.stringify(o);return c&&c.length>30?`${c.slice(0,27)}...`:c??"undefined"}for(let o of n.nodes){let c=u(o.name);l.set(o.name,c);let d=`${o.name} (${o.kind}) = ${f(o.value)}`,p=i[o.status??""]??"";s.push(` ${c}["${d}"]${p}`)}for(let o of n.edges){let c=l.get(o.from)??u(o.from),d=l.get(o.to)??u(o.to);s.push(` ${c} --> ${d}`)}return s.push(""),s.push(" classDef settled fill:#d4edda,stroke:#28a745"),s.push(" classDef dirty fill:#fff3cd,stroke:#ffc107"),s.push(" classDef errored fill:#f8d7da,stroke:#dc3545"),s.push(" classDef completed fill:#cce5ff,stroke:#007bff"),s.join(`
3
+ `)}static toD2(t){let r=t?.direction??"down",n=e.snapshot(),s=[`direction: ${r}`,""],i={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},a=new Map;function u(o){let c=o.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(c);return d===void 0?(a.set(c,1),c):(a.set(c,d+1),`${c}__${d}`)}let l=new Map;function f(o){let c=JSON.stringify(o);return c&&c.length>30?`${c.slice(0,27)}...`:c??"undefined"}for(let o of n.nodes){let c=u(o.name);l.set(o.name,c);let d=i[o.kind]??"rectangle",p=`${o.name} (${o.kind}) = ${f(o.value)}`,S=o.status?` [${o.status}]`:"";s.push(`${c}: "${p}${S}" { shape: ${d} }`)}n.edges.length>0&&s.push("");for(let o of n.edges){let c=l.get(o.from)??u(o.from),d=l.get(o.to)??u(o.to);s.push(`${c} -> ${d}`)}return s.join(`
4
+ `)}static annotate(t,r){if(!e.enabled)return;e._annotations.set(t,r);let n={node:e._resolveKey(t),reason:r,timestamp:Date.now()},s=e.maxTraceEntries;s<=0||(e._traceLog.length<s?e._traceLog.push(n):(e._traceLog[e._traceHead]=n,e._traceFull=!0),e._traceHead=(e._traceHead+1)%s)}static getAnnotation(t){return e._annotations.get(t)}static traceLog(){return e._traceFull?[...e._traceLog.slice(e._traceHead),...e._traceLog.slice(0,e._traceHead)]:e._traceLog.slice(0,e._traceHead||e._traceLog.length)}static clearTrace(){e._traceLog=[],e._traceHead=0,e._traceFull=!1}static timeline(t){let r=null,n=[];return t.source(h,(s,i)=>{if(s===h){r=i;return}let a={timestamp:Date.now(),type:s===y?"data":s===_?"signal":"end",data:i,inBatch:O()};n.push(a),s===g&&(r=null)}),{entries:n,dispose:()=>r?.(g)}}static observeDerived(t){let r=[],n=t,s=n._fn;if(typeof s!="function"||!Array.isArray(n._deps))return{...e.observe(t),evaluations:r};n._fn=()=>{let l=n._deps.map(o=>o.get()),f=s();return r.push({result:f,depValues:l,timestamp:Date.now()}),f};let i=e._observe(t),a=i.dispose;return{...i,evaluations:r,dispose:()=>{n._fn=s,a()},reconnect:()=>(n._fn=s,a(),e.observeDerived(t))}}static observeTaskState(t){let r=t.status.get(),n=[],s=null;return t.status.source(h,(i,a)=>{if(i===h){s=a;return}if(i===y){let u=a;if(u!==r){let l={from:r,to:u,timestamp:Date.now()};u==="error"&&(l.error=t.error.get()),n.push(l),r=u}}i===g&&(s=null)}),{transitions:n,get currentStatus(){return t.status.get()},dispose:()=>{s?.(g)}}}static causalityTrace(t){let r=[],n=t,s=n._fn;if(typeof s!="function"||!Array.isArray(n._deps))return{...e.observe(t),causality:r};let i=n._deps,a=i.map(o=>o.get());n._fn=()=>{let o=i.map(p=>p.get()),c=s(),d=-1;for(let p=0;p<i.length;p++)if(!Object.is(o[p],a[p])){d=p;break}return r.push({result:c,triggerDepIndex:d,triggerDepName:d>=0?e.getName(i[d]):void 0,depValues:o,timestamp:Date.now()}),a=o,c};let u=e._observe(t),l=u.dispose;return{...u,causality:r,dispose:()=>{n._fn=s,l()},reconnect:()=>(n._fn=s,l(),e.causalityTrace(t))}}static _reset(){e._names=new WeakMap,e._kinds=new WeakMap,e._keys=new WeakMap,e._stores=new Set,e._edges=new Map,e._usedKeys=new Set,e._nextId=0,e._explicitEnabled=null,e._cachedDefault=null,e._annotations=new WeakMap,e._traceLog=[],e._traceHead=0,e._traceFull=!1,e.maxTraceEntries=1e3}};var J=1,v=64,b=2,$=4,Ee=8,De=16,L=32,D=1024,m=oe,N=ge<<x,W=he<<x,Z=pe<<x,je=me<<x,Fe=Se<<x,We=Te<<x,K=class{_value;_output=null;_flags;get _status(){return _e(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;_onLifecycleSignal;constructor(t,r){this._value=r?.initial,this._fn=t,this._eqFn=r?.equals,this._getterFn=r?.getter,this._initial=r?.initial;let n=0;r?.autoDirty!==!1&&(n|=$),r?.resetOnTeardown&&(n|=Ee),r?.resubscribable&&(n|=De),this._flags=n,this.source=this.source.bind(this),this.emit=this.emit.bind(this),r?._skipInspect||A.register(this,{kind:"producer",...r})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,r){let n=this._output;if(n)if(this._flags&v)for(let s of n)s(t,r);else n(t,r)}emit(t){this._flags&b||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(O()?this._flags&L||(this._flags|=L,this._flags&$&&(this._flags=this._flags&~m|N,this._dispatch(_,E)),z(()=>{this._flags&=~L,this._flags=this._flags&~m|W,this._dispatch(y,this._value)})):(this._flags&$&&!(this._flags&D)&&(this._flags=this._flags&~m|N,this._dispatch(_,E)),this._flags=this._flags&~m|W,this._dispatch(y,this._value))))}signal(t){this._flags&b||!this._output||(t===E?this._flags=this._flags&~m|N:t===j&&(this._flags=this._flags&~m|We),this._dispatch(_,t))}complete(){if(this._flags&b)return;this._flags=(this._flags|b)&~m|je;let t=this._output,r=this._flags&v;if(this._output=null,this._flags&=~(v|D),this._singleDepCount=0,this._stop(),t)if(r)for(let n of t)n(g);else t(g)}error(t){if(this._flags&b)return;this._flags=(this._flags|b)&~m|Fe;let r=this._output,n=this._flags&v;if(this._output=null,this._flags&=~(v|D),this._singleDepCount=0,this._stop(),r)if(n)for(let s of r)s(g,t);else r(g,t)}_start(){if(this._flags&J||!this._fn)return;this._flags|=J,this._onLifecycleSignal=void 0;let t=this._fn({emit:this.emit,signal:r=>this.signal(r),complete:()=>this.complete(),error:r=>this.error(r),onSignal:r=>{this._onLifecycleSignal=r}});this._cleanup=typeof t=="function"?t:void 0}_stop(){this._flags&J&&(this._flags&=~J,this._onLifecycleSignal=void 0,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&Ee&&(this._value=this._initial),this._flags&b||(this._flags=this._flags&~m|Z))}_handleLifecycleSignal(t){if(!(this._flags&b)){if(t===ie){this._onLifecycleSignal?.(t),this.complete();return}t===C&&(this._value=this._initial,this._flags&=~L),this._onLifecycleSignal?.(t),t===C&&this.emit(this._initial)}}source(t,r){if(t===h){let n=r;if(this._flags&b)if(this._flags&De&&this._output===null)this._flags=this._flags&~(b|m)|Z;else{n(h,i=>{}),n(g);return}if(this._output===null)this._output=n;else if(this._flags&v)this._output.add(n);else{let i=new Set;i.add(this._output),i.add(n),this._output=i,this._flags=(this._flags|v)&~D}let s=!1;n(h,(i,a)=>{if(i===y&&n(y,this._value),i===_){a===fe&&!s?(s=!0,this._singleDepCount++,this._flags&v||(this._flags|=D)):de(a)&&this._handleLifecycleSignal(a);return}if(i===g){if(s&&(s=!1,this._singleDepCount--),this._output===null)return;if(this._flags&v){let u=this._output;u.delete(n),u.size===1?(this._output=u.values().next().value,this._flags&=~v,this._singleDepCount>0&&(this._flags|=D)):u.size===0&&(this._output=null,this._flags&=~(v|D),this._singleDepCount=0,this._flags=this._flags&~m|Z,this._stop())}else this._output===n&&(this._output=null,this._flags&=~D,this._singleDepCount=0,this._flags=this._flags&~m|Z,this._stop())}}),ve(()=>this._start())}}};function Q(e,t){return new K(e,t)}var ae=class extends K{constructor(t,r){super(void 0,{initial:t,autoDirty:!0,equals:r?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),A.register(this,{kind:"state",...r})}get(){return this._value}set(t){this._flags&b||this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(O()?this._flags&L||(this._flags|=L,this._flags&$&&(this._flags=this._flags&~m|N,this._dispatch(_,E)),z(()=>{this._flags&=~L,this._flags=this._flags&~m|W,this._dispatch(y,this._value)})):(this._flags&$&&!(this._flags&D)&&(this._flags=this._flags&~m|N,this._dispatch(_,E)),this._flags=this._flags&~m|W,this._dispatch(y,this._value))))}update(t){this.set(t(this._value))}};function V(e,t){return new ae(e,t)}function ke(e){return(t,r)=>{if(t!==0)return;let n=new AbortController,s=n.signal,i=!1,a,u;try{a=typeof e=="function"?e():e,u=a[Symbol.asyncIterator]()}catch(f){r(0,()=>{}),r(2,f);return}r(0,f=>{f===2&&!i&&(i=!0,n.abort(),Promise.resolve(u.return?.()).catch(()=>{}))});async function l(){try{for(;!i&&!s.aborted;){let f=await u.next();if(i||s.aborted)break;if(f.done){i=!0,r(2);return}r(1,f.value)}}catch(f){!i&&!s.aborted&&(i=!0,r(2,f))}}l()}}function xe(e){return(t,r)=>{if(t!==0)return;let n=!1;r(0,s=>{s===2&&(n=!0)}),e.then(s=>{n||(r(1,s),n||r(2))},s=>{n||r(2,s)})}}function Ke(e){return e!=null&&typeof e.then=="function"}function Ve(e){return e!=null&&typeof e[Symbol.asyncIterator]=="function"}function Ue(e){return e!=null&&typeof e[Symbol.iterator]=="function"}function ue(e){return Ke(e)?xe(e):Ve(e)?ke(e):typeof e!="string"&&Ue(e)?(t,r)=>{if(t!==0)return;let n=!1;r(0,s=>{s===2&&(n=!0)});for(let s of e){if(n)return;r(1,s)}n||r(2)}:(t,r)=>{if(t!==0)return;let n=!1;r(0,s=>{s===2&&(n=!0)}),n||r(1,e),n||r(2)}}function le(e,t,r){let n=null;return e(0,(s,i)=>{if(s===0){n=i;return}if(s===2){n=null,r?.onEnd?.(i);return}s===1&&t(i)}),{unsubscribe(){n?.(2),n=null}}}function we(e,t,r){let n=null;ye(),e.source(h,(i,a)=>{if(i===h&&(n=a),i===g){n=null,r?.onEnd?.(a);return}if(i===1){let u=a,l=s;s=u,t(u,l)}});let s;try{s=e.get()}catch{}return be(),{unsubscribe(){n?.(g),n=null},signal(i){n?.(_,i)}}}function Re(e,t){let r=t?.initialStatus??"pending",n=V(r,{name:"withStatus:status",equals:Object.is}),s=V(void 0,{name:"withStatus:error",equals:Object.is}),i=Q(({emit:u,complete:l,error:f})=>{n.set(r),s.set(void 0);let o=we(e,c=>{n.get()==="errored"?F(()=>{s.set(void 0),n.set("active")}):n.set("active"),u(c)},{onEnd:c=>{if(c!==void 0){let d=c instanceof Error?c:new Error(String(c));F(()=>{s.set(d),n.set("errored")}),f(c)}else n.set("completed"),l()}});return()=>{o.unsubscribe()}},{initial:e.get(),resubscribable:!0}),a={get:()=>e.get(),source:(u,l)=>i.source(u,l),get _status(){return i._status},status:n,error:s};return A.register(a,{kind:"withStatus"}),a}function Ye(e,t){let r=t?.name??"http",n=t?.method??"GET",s=t?.headers,i=t?.body,a=t?.poll??0,u=t?.transform??(w=>w.json()),l=t?.timeout??3e4,f=V(0,{name:`${r}:fetchCount`}),o=null,c=null,d=null,p=null,S=null,k=!1;function U(){if(!k||!o)return;S=new AbortController;let w=[S.signal];t?.signal&&w.push(t.signal);let R=new AbortController;for(let T of w){if(T.aborted){R.abort(T.reason);break}T.addEventListener("abort",()=>R.abort(T.reason),{once:!0})}let I=setTimeout(()=>R.abort(new Error("Request timeout")),l),ee=i!==void 0?typeof i=="string"?i:JSON.stringify(i):void 0;le(ue(fetch(e,{method:n,headers:s,body:ee,signal:R.signal})),T=>{if(!k){clearTimeout(I),S=null;return}if(!T.ok){clearTimeout(I),S=null,c?.(new Error(`HTTP ${T.status}: ${T.statusText}`));return}le(ue(u(T)),M=>{clearTimeout(I),S=null,k&&(F(()=>{f.update(Le=>Le+1),o?.(M)}),ce())},{onEnd:M=>{if(clearTimeout(I),S=null,M!==void 0){if(!k||M?.name==="AbortError")return;c?.(M)}}})},{onEnd:T=>{if(clearTimeout(I),S=null,T!==void 0){if(!k||T?.name==="AbortError")return;c?.(T)}}})}function ce(){!k||P||a<=0||(p=setTimeout(()=>{p=null,U()},a))}let X=null,P=!1,Ae=Q(({emit:w,error:R,complete:I,onSignal:ee})=>(o=w,c=R,d=I,k=!0,P=!1,X=()=>{U()},ee(T=>{T===se?(P=!0,p!==null&&(clearTimeout(p),p=null)):T===re?(P=!1,ce()):T===C&&(S?.abort(),S=null,p!==null&&(clearTimeout(p),p=null),f.set(0),P=!1,U())}),U(),()=>{k=!1,P=!1,o=null,c=null,d=null,X=null,S?.abort(),S=null,p!==null&&(clearTimeout(p),p=null)}),{name:r,kind:"http"}),Y=Re(Ae);return{get:()=>Y.get(),source:(w,R)=>Y.source(w,R),status:Y.status,error:Y.error,fetchCount:f,refetch(){X?.()},stop(){k=!1,S?.abort(),S=null,p!==null&&(clearTimeout(p),p=null),d?.()}}}0&&(module.exports={fromHTTP});
@@ -1 +1 @@
1
- import{a}from"../chunk-ZDGVUX5G.js";import"../chunk-5LLYKN4X.js";import"../chunk-GMLWTZFM.js";import"../chunk-EAK2HKAD.js";import"../chunk-2F6QWERG.js";import"../chunk-2L6223KN.js";import"../chunk-TUPD47IE.js";import"../chunk-I7AUKTXE.js";export{a as fromHTTP};
1
+ import{a}from"../chunk-FJ2VN2O3.js";import"../chunk-5LLYKN4X.js";import"../chunk-GMLWTZFM.js";import"../chunk-O2PONDZT.js";import"../chunk-J2E7GAMR.js";import"../chunk-4ILN4V4C.js";import"../chunk-Q3HIBGHR.js";import"../chunk-EAK2HKAD.js";import"../chunk-2F6QWERG.js";import"../chunk-2L6223KN.js";import"../chunk-TUPD47IE.js";import"../chunk-I7AUKTXE.js";export{a as fromHTTP};
@@ -1,15 +1,15 @@
1
- "use strict";var Fe=Object.create;var te=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty;var Ue=(t,e)=>{for(var o in e)te(t,o,{get:e[o],enumerable:!0})},he=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Be(e))!qe.call(t,r)&&r!==o&&te(t,r,{get:()=>e[r],enumerable:!(n=He(e,r))||n.enumerable});return t};var Ke=(t,e,o)=>(o=t!=null?Fe(Ve(t)):{},he(e||!t||!t.__esModule?te(o,"default",{value:t,enumerable:!0}):o,t)),ze=t=>he(te({},"__esModule",{value:!0}),t);var Ze={};Ue(Ze,{fromHTTP:()=>Pe,fromMCP:()=>Ae,fromWebSocket:()=>$e,fromWebhook:()=>Ie,toSSE:()=>We,toWebSocket:()=>Me});module.exports=ze(Ze);var M=Symbol("DIRTY"),Z=Symbol("RESOLVED"),Se=Symbol("SINGLE_DEP"),N=Symbol("RESET"),U=Symbol("PAUSE"),K=Symbol("RESUME"),pe=Symbol("TEARDOWN");function Te(t){return t===N||t===U||t===K||t===pe}var ye=0,be=1,_e=2,ve=3,Ee=4,ke=5,H=7,ge=7<<H,Ye=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function we(t){return Ye[(t&ge)>>>H]}var D=0,L=1,E=2,A=3,ne=0,re=[],de=!1;function j(t){ne++;try{return t()}finally{if(ne--,ne===0&&!de){de=!0;for(let e=0;e<re.length;e++)re[e]();re.length=0,de=!1}}}function z(){return ne>0}function ie(t){re.push(t)}var se=0,oe=[];function xe(){se++}function De(){if(se--,se===0){for(let t=0;t<oe.length;t++)oe[t]();oe.length=0}}function Re(t){se>0?oe.push(t):t()}var P=class t{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static _annotations=new WeakMap;static _traceLog=[];static _traceHead=0;static _traceFull=!1;static maxTraceEntries=1e3;static get enabled(){if(t._explicitEnabled!==null)return t._explicitEnabled;if(t._cachedDefault!==null)return t._cachedDefault;try{t._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{t._cachedDefault=!0}return t._cachedDefault}static set enabled(e){t._explicitEnabled=e}static _depSuffix(e){if(!e?.length)return;let n=e.map(r=>t._names.get(r)??"?").join(",");return n.length>40?`${n.slice(0,37)}...`:n}static _resolveKey(e){let o=t._keys.get(e)??t._names.get(e);if(o)return o;let n=`anonymous_${t._nextId++}`;return t._keys.set(e,n),n}static register(e,o){if(!t.enabled)return;o?.name&&t._names.set(e,o.name),o?.kind&&t._kinds.set(e,o.kind);let n=t._nextId++,r=o?.name;if(!(r&&!t._usedKeys.has(r)))if(r){let s=t._depSuffix(o?.deps);r=s?`${r}(${s})`:`${r}_${n}`,t._usedKeys.has(r)&&(r=`${r}_${n}`)}else{let s=o?.kind??"store",u=t._depSuffix(o?.deps);r=u?`${s}(${u})`:`${s}_${n}`,t._usedKeys.has(r)&&(r=`${r}_${n}`)}t._usedKeys.add(r),t._keys.set(e,r),t._stores.add(new WeakRef(e))}static registerEdge(e,o){if(!t.enabled)return;let n=t._resolveKey(e),r=t._resolveKey(o),s=t._edges.get(n);s?s.includes(r)||s.push(r):t._edges.set(n,[r])}static getEdges(){return new Map(t._edges)}static getName(e){if(t.enabled)return t._names.get(e)}static getKind(e){return t._kinds.get(e)}static inspect(e){return{name:t._names.get(e),kind:t._kinds.get(e)??"unknown",value:typeof e.get=="function"?e.get():void 0,status:e._status}}static graph(){let e=new Map,o=new Set;for(let n of t._stores){let r=n.deref();if(!r){t._stores.delete(n);continue}let s=t._resolveKey(r);o.add(s),e.set(s,t.inspect(r))}for(let[n,r]of t._edges){if(!o.has(n)){t._edges.delete(n),t._usedKeys.delete(n);continue}let s=r.filter(u=>o.has(u));s.length===0?t._edges.delete(n):s.length!==r.length&&t._edges.set(n,s)}return e}static trace(e,o){let n=null,r=e.get();return e.source(D,(s,u)=>{if(s===D&&(n=u),s===E){n=null;return}if(s===1){let a=u;if(!Object.is(a,r)){let c=r;r=a,o(a,c)}}}),()=>n?.(E)}static dumpGraph(){let e=t.graph(),o=t.getEdges(),n=new Map;for(let[u,a]of o)for(let c of a){let f=n.get(c);f?f.includes(u)||f.push(u):n.set(c,[u])}let r=[];for(let[u,a]of e){let c=n.get(u),f=o.get(u),i=c?.length?` \u2190 [${c.join(", ")}]`:"",l=f?.length?` \u2192 [${f.join(", ")}]`:"";r.push(` ${u} (${a.kind}) = ${JSON.stringify(a.value)} [${a.status??"?"}]${i}${l}`)}return[`Store Graph (${e.size} nodes):`,...r].join(`
2
- `)}static _signalLabel(e){return e===M?"DIRTY":e===Z?"RESOLVED":typeof e=="symbol"?e.description??String(e):String(e)}static _observe(e,o,n){let r=null,s=!1,u=o??t.getName(e),a=[],c={values:[],signals:[],events:[],ended:!1,endError:void 0,get completedCleanly(){return c.ended&&!s},get errored(){return c.ended&&s},dirtyCount:0,resolvedCount:0,name:u,get eventLog(){return a},dispose:()=>r?.(E),reconnect:()=>(r?.(E),t._observe(e,o,n))};return e.source(D,(f,i)=>{if(f===D){r=i;return}let l=z();f===L?(c.values.push(i),c.events.push({type:"data",data:i,inBatch:l}),a.push(i),n&&n(`[${u}] DATA:`,i)):f===A?(c.signals.push(i),c.events.push({type:"signal",data:i,inBatch:l}),a.push(t._signalLabel(i)),i===M?c.dirtyCount++:i===Z&&c.resolvedCount++,n&&n(`[${u}] STATE:`,i)):f===E&&(c.ended=!0,c.endError=i,s=i!==void 0,c.events.push({type:"end",data:i,inBatch:l}),a.push(s?["END",i]:"END"),n&&n(`[${u}] END`,i!==void 0?i:""),r=null)}),c}static observe(e){return t._observe(e)}static activate(e){let o=null;return e.source(D,(n,r)=>{n===D&&(o=r),n===E&&(o=null)}),()=>o?.(E)}static tap(e,o){let n=o??`tap(${t.getName(e)??"anon"})`,r={get:()=>e.get(),source:e.source};return t.register(r,{name:n,kind:"tap"}),t.registerEdge(e,r),r}static spy(e,o){let n=o?.name??t.getName(e)??"spy",r=o?.log??console.log;return t._observe(e,n,r)}static snapshot(){let e=t.graph(),o=t.getEdges(),n=new Map;for(let u of t._stores){let a=u.deref();if(!a)continue;let c=t._annotations.get(a);c!==void 0&&n.set(t._resolveKey(a),c)}let r=[];for(let[u,a]of e){let c={name:u,kind:a.kind,value:a.value,status:a.status},f=n.get(u);f!==void 0&&(c.annotation=f),r.push(c)}let s=[];for(let[u,a]of o)for(let c of a)s.push({from:u,to:c});return{nodes:r,edges:s,trace:t.traceLog()}}static toMermaid(e){let o=e?.direction??"TD",n=t.snapshot(),r=[`graph ${o}`],s={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},u=new Map;function a(i){let l=i.replace(/[^a-zA-Z0-9_]/g,"_"),d=u.get(l);return d===void 0?(u.set(l,1),l):(u.set(l,d+1),`${l}__${d}`)}let c=new Map;function f(i){let l=JSON.stringify(i);return l&&l.length>30?`${l.slice(0,27)}...`:l??"undefined"}for(let i of n.nodes){let l=a(i.name);c.set(i.name,l);let d=`${i.name} (${i.kind}) = ${f(i.value)}`,m=s[i.status??""]??"";r.push(` ${l}["${d}"]${m}`)}for(let i of n.edges){let l=c.get(i.from)??a(i.from),d=c.get(i.to)??a(i.to);r.push(` ${l} --> ${d}`)}return r.push(""),r.push(" classDef settled fill:#d4edda,stroke:#28a745"),r.push(" classDef dirty fill:#fff3cd,stroke:#ffc107"),r.push(" classDef errored fill:#f8d7da,stroke:#dc3545"),r.push(" classDef completed fill:#cce5ff,stroke:#007bff"),r.join(`
3
- `)}static toD2(e){let o=e?.direction??"down",n=t.snapshot(),r=[`direction: ${o}`,""],s={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},u=new Map;function a(i){let l=i.replace(/[^a-zA-Z0-9_]/g,"_"),d=u.get(l);return d===void 0?(u.set(l,1),l):(u.set(l,d+1),`${l}__${d}`)}let c=new Map;function f(i){let l=JSON.stringify(i);return l&&l.length>30?`${l.slice(0,27)}...`:l??"undefined"}for(let i of n.nodes){let l=a(i.name);c.set(i.name,l);let d=s[i.kind]??"rectangle",m=`${i.name} (${i.kind}) = ${f(i.value)}`,b=i.status?` [${i.status}]`:"";r.push(`${l}: "${m}${b}" { shape: ${d} }`)}n.edges.length>0&&r.push("");for(let i of n.edges){let l=c.get(i.from)??a(i.from),d=c.get(i.to)??a(i.to);r.push(`${l} -> ${d}`)}return r.join(`
4
- `)}static annotate(e,o){if(!t.enabled)return;t._annotations.set(e,o);let n={node:t._resolveKey(e),reason:o,timestamp:Date.now()},r=t.maxTraceEntries;r<=0||(t._traceLog.length<r?t._traceLog.push(n):(t._traceLog[t._traceHead]=n,t._traceFull=!0),t._traceHead=(t._traceHead+1)%r)}static getAnnotation(e){return t._annotations.get(e)}static traceLog(){return t._traceFull?[...t._traceLog.slice(t._traceHead),...t._traceLog.slice(0,t._traceHead)]:t._traceLog.slice(0,t._traceHead||t._traceLog.length)}static clearTrace(){t._traceLog=[],t._traceHead=0,t._traceFull=!1}static timeline(e){let o=null,n=[];return e.source(D,(r,s)=>{if(r===D){o=s;return}let u={timestamp:Date.now(),type:r===L?"data":r===A?"signal":"end",data:s,inBatch:z()};n.push(u),r===E&&(o=null)}),{entries:n,dispose:()=>o?.(E)}}static observeDerived(e){let o=[],n=e,r=n._fn;if(typeof r!="function"||!Array.isArray(n._deps))return{...t.observe(e),evaluations:o};n._fn=()=>{let c=n._deps.map(i=>i.get()),f=r();return o.push({result:f,depValues:c,timestamp:Date.now()}),f};let s=t._observe(e),u=s.dispose;return{...s,evaluations:o,dispose:()=>{n._fn=r,u()},reconnect:()=>(n._fn=r,u(),t.observeDerived(e))}}static observeTaskState(e){let o=e.status.get(),n=[],r=null;return e.status.source(D,(s,u)=>{if(s===D){r=u;return}if(s===L){let a=u;if(a!==o){let c={from:o,to:a,timestamp:Date.now()};a==="error"&&(c.error=e.error.get()),n.push(c),o=a}}s===E&&(r=null)}),{transitions:n,get currentStatus(){return e.status.get()},dispose:()=>{r?.(E)}}}static causalityTrace(e){let o=[],n=e,r=n._fn;if(typeof r!="function"||!Array.isArray(n._deps))return{...t.observe(e),causality:o};let s=n._deps,u=s.map(i=>i.get());n._fn=()=>{let i=s.map(m=>m.get()),l=r(),d=-1;for(let m=0;m<s.length;m++)if(!Object.is(i[m],u[m])){d=m;break}return o.push({result:l,triggerDepIndex:d,triggerDepName:d>=0?t.getName(s[d]):void 0,depValues:i,timestamp:Date.now()}),u=i,l};let a=t._observe(e),c=a.dispose;return{...a,causality:o,dispose:()=>{n._fn=r,c()},reconnect:()=>(n._fn=r,c(),t.causalityTrace(e))}}static _reset(){t._names=new WeakMap,t._kinds=new WeakMap,t._keys=new WeakMap,t._stores=new Set,t._edges=new Map,t._usedKeys=new Set,t._nextId=0,t._explicitEnabled=null,t._cachedDefault=null,t._annotations=new WeakMap,t._traceLog=[],t._traceHead=0,t._traceFull=!1,t.maxTraceEntries=1e3}};var ae=1,I=64,W=2,Y=4,Ce=8,Oe=16,B=32,F=1024,R=ge,J=be<<H,X=_e<<H,ue=ye<<H,Je=Ee<<H,Ge=ke<<H,Qe=ve<<H,ee=class{_value;_output=null;_flags;get _status(){return we(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;_onLifecycleSignal;constructor(e,o){this._value=o?.initial,this._fn=e,this._eqFn=o?.equals,this._getterFn=o?.getter,this._initial=o?.initial;let n=0;o?.autoDirty!==!1&&(n|=Y),o?.resetOnTeardown&&(n|=Ce),o?.resubscribable&&(n|=Oe),this._flags=n,this.source=this.source.bind(this),this.emit=this.emit.bind(this),o?._skipInspect||P.register(this,{kind:"producer",...o})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(e,o){let n=this._output;if(n)if(this._flags&I)for(let r of n)r(e,o);else n(e,o)}emit(e){this._flags&W||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&(z()?this._flags&B||(this._flags|=B,this._flags&Y&&(this._flags=this._flags&~R|J,this._dispatch(A,M)),ie(()=>{this._flags&=~B,this._flags=this._flags&~R|X,this._dispatch(L,this._value)})):(this._flags&Y&&!(this._flags&F)&&(this._flags=this._flags&~R|J,this._dispatch(A,M)),this._flags=this._flags&~R|X,this._dispatch(L,this._value))))}signal(e){this._flags&W||!this._output||(e===M?this._flags=this._flags&~R|J:e===Z&&(this._flags=this._flags&~R|Qe),this._dispatch(A,e))}complete(){if(this._flags&W)return;this._flags=(this._flags|W)&~R|Je;let e=this._output,o=this._flags&I;if(this._output=null,this._flags&=~(I|F),this._singleDepCount=0,this._stop(),e)if(o)for(let n of e)n(E);else e(E)}error(e){if(this._flags&W)return;this._flags=(this._flags|W)&~R|Ge;let o=this._output,n=this._flags&I;if(this._output=null,this._flags&=~(I|F),this._singleDepCount=0,this._stop(),o)if(n)for(let r of o)r(E,e);else o(E,e)}_start(){if(this._flags&ae||!this._fn)return;this._flags|=ae,this._onLifecycleSignal=void 0;let e=this._fn({emit:this.emit,signal:o=>this.signal(o),complete:()=>this.complete(),error:o=>this.error(o),onSignal:o=>{this._onLifecycleSignal=o}});this._cleanup=typeof e=="function"?e:void 0}_stop(){this._flags&ae&&(this._flags&=~ae,this._onLifecycleSignal=void 0,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&Ce&&(this._value=this._initial),this._flags&W||(this._flags=this._flags&~R|ue))}_handleLifecycleSignal(e){if(!(this._flags&W)){if(e===pe){this._onLifecycleSignal?.(e),this.complete();return}e===N&&(this._value=this._initial,this._flags&=~B),this._onLifecycleSignal?.(e),e===N&&this.emit(this._initial)}}source(e,o){if(e===D){let n=o;if(this._flags&W)if(this._flags&Oe&&this._output===null)this._flags=this._flags&~(W|R)|ue;else{n(D,s=>{}),n(E);return}if(this._output===null)this._output=n;else if(this._flags&I)this._output.add(n);else{let s=new Set;s.add(this._output),s.add(n),this._output=s,this._flags=(this._flags|I)&~F}let r=!1;n(D,(s,u)=>{if(s===L&&n(L,this._value),s===A){u===Se&&!r?(r=!0,this._singleDepCount++,this._flags&I||(this._flags|=F)):Te(u)&&this._handleLifecycleSignal(u);return}if(s===E){if(r&&(r=!1,this._singleDepCount--),this._output===null)return;if(this._flags&I){let a=this._output;a.delete(n),a.size===1?(this._output=a.values().next().value,this._flags&=~I,this._singleDepCount>0&&(this._flags|=F)):a.size===0&&(this._output=null,this._flags&=~(I|F),this._singleDepCount=0,this._flags=this._flags&~R|ue,this._stop())}else this._output===n&&(this._output=null,this._flags&=~F,this._singleDepCount=0,this._flags=this._flags&~R|ue,this._stop())}}),Re(()=>this._start())}}};function V(t,e){return new ee(t,e)}var me=class extends ee{constructor(e,o){super(void 0,{initial:e,autoDirty:!0,equals:o?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),P.register(this,{kind:"state",...o})}get(){return this._value}set(e){this._flags&W||this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&(z()?this._flags&B||(this._flags|=B,this._flags&Y&&(this._flags=this._flags&~R|J,this._dispatch(A,M)),ie(()=>{this._flags&=~B,this._flags=this._flags&~R|X,this._dispatch(L,this._value)})):(this._flags&Y&&!(this._flags&F)&&(this._flags=this._flags&~R|J,this._dispatch(A,M)),this._flags=this._flags&~R|X,this._dispatch(L,this._value))))}update(e){this.set(e(this._value))}};function w(t,e){return new me(t,e)}function G(t,e,o){let n=null;xe(),t.source(D,(s,u)=>{if(s===D&&(n=u),s===E){n=null,o?.onEnd?.(u);return}if(s===1){let a=u,c=r;r=a,e(a,c)}});let r;try{r=t.get()}catch{}return De(),{unsubscribe(){n?.(E),n=null},signal(s){n?.(A,s)}}}function Q(t,e){let o=e?.initialStatus??"pending",n=w(o,{name:"withStatus:status",equals:Object.is}),r=w(void 0,{name:"withStatus:error",equals:Object.is}),s=V(({emit:a,complete:c,error:f})=>{n.set(o),r.set(void 0);let i=G(t,l=>{n.get()==="errored"?j(()=>{r.set(void 0),n.set("active")}):n.set("active"),a(l)},{onEnd:l=>{if(l!==void 0){let d=l instanceof Error?l:new Error(String(l));j(()=>{r.set(d),n.set("errored")}),f(l)}else n.set("completed"),c()}});return()=>{i.unsubscribe()}},{initial:t.get(),resubscribable:!0}),u={get:()=>t.get(),source:(a,c)=>s.source(a,c),get _status(){return s._status},status:n,error:r};return P.register(u,{kind:"withStatus"}),u}function Pe(t,e){let o=e?.name??"http",n=e?.method??"GET",r=e?.headers,s=e?.body,u=e?.poll??0,a=e?.transform??(x=>x.json()),c=e?.timeout??3e4,f=w(0,{name:`${o}:fetchCount`}),i=null,l=null,d=null,m=null,b=null,T=!1;async function C(){if(!T||!i)return;b=new AbortController;let x=[b.signal];e?.signal&&x.push(e.signal);let _=new AbortController;for(let k of x){if(k.aborted){_.abort(k.reason);break}k.addEventListener("abort",()=>_.abort(k.reason),{once:!0})}let v=setTimeout(()=>_.abort(new Error("Request timeout")),c);try{let k=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0,O=await fetch(t,{method:n,headers:r,body:k,signal:_.signal});if(!T)return;if(!O.ok)throw new Error(`HTTP ${O.status}: ${O.statusText}`);let q=await a(O);if(!T)return;j(()=>{f.update($=>$+1),i?.(q)})}catch(k){if(!T||k?.name==="AbortError")return;l?.(k)}finally{clearTimeout(v),b=null}}function S(){!T||g||u<=0||(m=setTimeout(()=>{m=null,C().then(()=>{T&&!g&&S()}).catch(()=>{})},u))}let p=null,g=!1,h=V(({emit:x,error:_,complete:v,onSignal:k})=>(i=x,l=_,d=v,T=!0,g=!1,p=()=>{C()},k(O=>{O===U?(g=!0,m!==null&&(clearTimeout(m),m=null)):O===K?(g=!1,S()):O===N&&(b?.abort(),b=null,m!==null&&(clearTimeout(m),m=null),f.set(0),g=!1,C().then(()=>{T&&!g&&S()}))}),C().then(()=>{T&&!g&&S()}),()=>{T=!1,g=!1,i=null,l=null,d=null,p=null,b?.abort(),b=null,m!==null&&(clearTimeout(m),m=null)}),{name:o,kind:"http"}),y=Q(h);return{get:()=>y.get(),source:(x,_)=>y.source(x,_),status:y.status,error:y.error,fetchCount:f,refetch(){p?.()},stop(){T=!1,b?.abort(),b=null,m!==null&&(clearTimeout(m),m=null),d?.()}}}function Ae(t){let e=t.name??"mcp",o=t.client,n=w([],{name:`${e}.tools`}),r=w([],{name:`${e}.resources`}),s=w(void 0,{name:`${e}.refreshError`});function u(f){s.set(f);let i=t.onRefreshError;if(i==="warn")console.warn(`[${e}] refresh error:`,f);else{if(i==="error")throw f;typeof i=="function"&&i(f)}}async function a(){if(s.set(void 0),o.listTools)try{let f=await o.listTools();n.set(f.tools)}catch(f){u(f)}if(o.listResources)try{let f=await o.listResources();r.set(f.resources)}catch(f){u(f)}}function c(f){let i=`${e}:${f}`,l=w(void 0,{name:`${i}.result`}),d=w("idle",{name:`${i}.status`}),m=w(void 0,{name:`${i}.error`}),b=w(void 0,{name:`${i}.lastArgs`}),T=w(void 0,{name:`${i}.duration`}),C=!1;async function S(p){if(C)return;C=!0,j(()=>{b.set(p),m.set(void 0),d.set("active")});let g=Date.now();try{let h=await o.callTool({name:f,arguments:p}),y=Date.now()-g;if(h.isError){let v=h.content.filter(O=>O.type==="text").map(O=>O.text??"").join(`
5
- `),k=new Error(v||"MCP tool returned error");j(()=>{T.set(y),m.set(k),d.set("errored")});return}let x=h.content.filter(v=>v.type==="text"),_;if(x.length===1){let v=x[0].text;if(v!==void 0)try{_=JSON.parse(v)}catch{_=v}}else x.length>1?_=x.map(v=>v.text??""):_=h.content;j(()=>{T.set(y),l.set(_),d.set("completed")})}catch(h){let y=Date.now()-g;j(()=>{T.set(y),m.set(h),d.set("errored")})}finally{C=!1}}return{get:()=>l.get(),source:(p,g)=>l.source(p,g),status:d,error:m,call:S,lastArgs:b,duration:T}}return{tool:c,tools:n,resources:r,refresh:a,refreshError:s}}function Le(t,e,o){let n=null;return t(0,(r,s)=>{if(r===0){n=s;return}if(r===2){n=null,o?.onEnd?.(s);return}r===1&&e(s)}),{unsubscribe(){n?.(2),n=null}}}function le(t,e){let o=e?.predicate,n=e?.signal;return new Promise((r,s)=>{if(n?.aborted){s(n.reason??new DOMException("The operation was aborted.","AbortError"));return}let u=!1,a=Le(t,i=>{(!o||o(i))&&(u=!0,f(),a.unsubscribe(),r(i))},{onEnd:i=>{u||(u=!0,f(),s(i??new Error("source completed without matching value")))}});function c(){u||(u=!0,f(),a.unsubscribe(),s(n.reason??new DOMException("The operation was aborted.","AbortError")))}function f(){n?.removeEventListener("abort",c)}n?.addEventListener("abort",c)})}function ce(t){return(e,o)=>{if(e!==0)return;let n=!1,r;o(0,s=>{s===2&&!n&&(n=!0,r?.())});try{r=t(s=>{n||(n=!0,o(1,s),o(2))},s=>{n||(n=!0,o(2,s))})}catch(s){n||(n=!0,o(2,s))}}}function We(t,e){let o=e?.path??"/",n=e?.name??"sse",r=e?.hostname??"0.0.0.0",s=e?.serialize??JSON.stringify,u=e?.eventName??"message",a=e?.pingInterval??3e4,c=w(0,{name:`${n}:connections`}),f=new Set,i=new Map,l=null;function d(){l||(l=G(t,p=>{let g=s(p),h=`event: ${u}
6
- data: ${g}
1
+ "use strict";var Be=Object.create;var re=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty;var ze=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},he=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ue(t))!Ke.call(e,o)&&o!==r&&re(e,o,{get:()=>t[o],enumerable:!(n=qe(t,o))||n.enumerable});return e};var Ye=(e,t,r)=>(r=e!=null?Be(Ve(e)):{},he(t||!e||!e.__esModule?re(r,"default",{value:e,enumerable:!0}):r,e)),Je=e=>he(re({},"__esModule",{value:!0}),e);var rt={};ze(rt,{fromHTTP:()=>Le,fromMCP:()=>We,fromWebSocket:()=>Me,fromWebhook:()=>Ne,toSSE:()=>$e,toWebSocket:()=>je});module.exports=Je(rt);var M=Symbol("DIRTY"),ee=Symbol("RESOLVED"),Te=Symbol("SINGLE_DEP"),j=Symbol("RESET"),z=Symbol("PAUSE"),Y=Symbol("RESUME"),ge=Symbol("TEARDOWN");function be(e){return e===j||e===z||e===Y||e===ge}var ye=0,_e=1,ve=2,Ee=3,ke=4,we=5,q=7,me=7<<q,Ge=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function xe(e){return Ge[(e&me)>>>q]}var R=0,I=1,w=2,P=3,oe=0,se=[],pe=!1;function F(e){oe++;try{return e()}finally{if(oe--,oe===0&&!pe){pe=!0;for(let t=0;t<se.length;t++)se[t]();se.length=0,pe=!1}}}function J(){return oe>0}function ue(e){se.push(e)}var ae=0,ie=[];function Re(){ae++}function De(){if(ae--,ae===0){for(let e=0;e<ie.length;e++)ie[e]();ie.length=0}}function Ce(e){ae>0?ie.push(e):e()}var A=class e{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static _annotations=new WeakMap;static _traceLog=[];static _traceHead=0;static _traceFull=!1;static maxTraceEntries=1e3;static get enabled(){if(e._explicitEnabled!==null)return e._explicitEnabled;if(e._cachedDefault!==null)return e._cachedDefault;try{e._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{e._cachedDefault=!0}return e._cachedDefault}static set enabled(t){e._explicitEnabled=t}static _depSuffix(t){if(!t?.length)return;let n=t.map(o=>e._names.get(o)??"?").join(",");return n.length>40?`${n.slice(0,37)}...`:n}static _resolveKey(t){let r=e._keys.get(t)??e._names.get(t);if(r)return r;let n=`anonymous_${e._nextId++}`;return e._keys.set(t,n),n}static register(t,r){if(!e.enabled)return;r?.name&&e._names.set(t,r.name),r?.kind&&e._kinds.set(t,r.kind);let n=e._nextId++,o=r?.name;if(!(o&&!e._usedKeys.has(o)))if(o){let s=e._depSuffix(r?.deps);o=s?`${o}(${s})`:`${o}_${n}`,e._usedKeys.has(o)&&(o=`${o}_${n}`)}else{let s=r?.kind??"store",u=e._depSuffix(r?.deps);o=u?`${s}(${u})`:`${s}_${n}`,e._usedKeys.has(o)&&(o=`${o}_${n}`)}e._usedKeys.add(o),e._keys.set(t,o),e._stores.add(new WeakRef(t))}static registerEdge(t,r){if(!e.enabled)return;let n=e._resolveKey(t),o=e._resolveKey(r),s=e._edges.get(n);s?s.includes(o)||s.push(o):e._edges.set(n,[o])}static getEdges(){return new Map(e._edges)}static getName(t){if(e.enabled)return e._names.get(t)}static getKind(t){return e._kinds.get(t)}static inspect(t){return{name:e._names.get(t),kind:e._kinds.get(t)??"unknown",value:typeof t.get=="function"?t.get():void 0,status:t._status}}static graph(){let t=new Map,r=new Set;for(let n of e._stores){let o=n.deref();if(!o){e._stores.delete(n);continue}let s=e._resolveKey(o);r.add(s),t.set(s,e.inspect(o))}for(let[n,o]of e._edges){if(!r.has(n)){e._edges.delete(n),e._usedKeys.delete(n);continue}let s=o.filter(u=>r.has(u));s.length===0?e._edges.delete(n):s.length!==o.length&&e._edges.set(n,s)}return t}static trace(t,r){let n=null,o=t.get();return t.source(R,(s,u)=>{if(s===R&&(n=u),s===w){n=null;return}if(s===1){let i=u;if(!Object.is(i,o)){let f=o;o=i,r(i,f)}}}),()=>n?.(w)}static dumpGraph(){let t=e.graph(),r=e.getEdges(),n=new Map;for(let[u,i]of r)for(let f of i){let c=n.get(f);c?c.includes(u)||c.push(u):n.set(f,[u])}let o=[];for(let[u,i]of t){let f=n.get(u),c=r.get(u),a=f?.length?` \u2190 [${f.join(", ")}]`:"",l=c?.length?` \u2192 [${c.join(", ")}]`:"";o.push(` ${u} (${i.kind}) = ${JSON.stringify(i.value)} [${i.status??"?"}]${a}${l}`)}return[`Store Graph (${t.size} nodes):`,...o].join(`
2
+ `)}static _signalLabel(t){return t===M?"DIRTY":t===ee?"RESOLVED":typeof t=="symbol"?t.description??String(t):String(t)}static _observe(t,r,n){let o=null,s=!1,u=r??e.getName(t),i=[],f={values:[],signals:[],events:[],ended:!1,endError:void 0,get completedCleanly(){return f.ended&&!s},get errored(){return f.ended&&s},dirtyCount:0,resolvedCount:0,name:u,get eventLog(){return i},dispose:()=>o?.(w),reconnect:()=>(o?.(w),e._observe(t,r,n))};return t.source(R,(c,a)=>{if(c===R){o=a;return}let l=J();c===I?(f.values.push(a),f.events.push({type:"data",data:a,inBatch:l}),i.push(a),n&&n(`[${u}] DATA:`,a)):c===P?(f.signals.push(a),f.events.push({type:"signal",data:a,inBatch:l}),i.push(e._signalLabel(a)),a===M?f.dirtyCount++:a===ee&&f.resolvedCount++,n&&n(`[${u}] STATE:`,a)):c===w&&(f.ended=!0,f.endError=a,s=a!==void 0,f.events.push({type:"end",data:a,inBatch:l}),i.push(s?["END",a]:"END"),n&&n(`[${u}] END`,a!==void 0?a:""),o=null)}),f}static observe(t){return e._observe(t)}static activate(t){let r=null;return t.source(R,(n,o)=>{n===R&&(r=o),n===w&&(r=null)}),()=>r?.(w)}static tap(t,r){let n=r??`tap(${e.getName(t)??"anon"})`,o={get:()=>t.get(),source:t.source};return e.register(o,{name:n,kind:"tap"}),e.registerEdge(t,o),o}static spy(t,r){let n=r?.name??e.getName(t)??"spy",o=r?.log??console.log;return e._observe(t,n,o)}static snapshot(){let t=e.graph(),r=e.getEdges(),n=new Map;for(let u of e._stores){let i=u.deref();if(!i)continue;let f=e._annotations.get(i);f!==void 0&&n.set(e._resolveKey(i),f)}let o=[];for(let[u,i]of t){let f={name:u,kind:i.kind,value:i.value,status:i.status},c=n.get(u);c!==void 0&&(f.annotation=c),o.push(f)}let s=[];for(let[u,i]of r)for(let f of i)s.push({from:u,to:f});return{nodes:o,edges:s,trace:e.traceLog()}}static toMermaid(t){let r=t?.direction??"TD",n=e.snapshot(),o=[`graph ${r}`],s={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},u=new Map;function i(a){let l=a.replace(/[^a-zA-Z0-9_]/g,"_"),g=u.get(l);return g===void 0?(u.set(l,1),l):(u.set(l,g+1),`${l}__${g}`)}let f=new Map;function c(a){let l=JSON.stringify(a);return l&&l.length>30?`${l.slice(0,27)}...`:l??"undefined"}for(let a of n.nodes){let l=i(a.name);f.set(a.name,l);let g=`${a.name} (${a.kind}) = ${c(a.value)}`,m=s[a.status??""]??"";o.push(` ${l}["${g}"]${m}`)}for(let a of n.edges){let l=f.get(a.from)??i(a.from),g=f.get(a.to)??i(a.to);o.push(` ${l} --> ${g}`)}return o.push(""),o.push(" classDef settled fill:#d4edda,stroke:#28a745"),o.push(" classDef dirty fill:#fff3cd,stroke:#ffc107"),o.push(" classDef errored fill:#f8d7da,stroke:#dc3545"),o.push(" classDef completed fill:#cce5ff,stroke:#007bff"),o.join(`
3
+ `)}static toD2(t){let r=t?.direction??"down",n=e.snapshot(),o=[`direction: ${r}`,""],s={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},u=new Map;function i(a){let l=a.replace(/[^a-zA-Z0-9_]/g,"_"),g=u.get(l);return g===void 0?(u.set(l,1),l):(u.set(l,g+1),`${l}__${g}`)}let f=new Map;function c(a){let l=JSON.stringify(a);return l&&l.length>30?`${l.slice(0,27)}...`:l??"undefined"}for(let a of n.nodes){let l=i(a.name);f.set(a.name,l);let g=s[a.kind]??"rectangle",m=`${a.name} (${a.kind}) = ${c(a.value)}`,T=a.status?` [${a.status}]`:"";o.push(`${l}: "${m}${T}" { shape: ${g} }`)}n.edges.length>0&&o.push("");for(let a of n.edges){let l=f.get(a.from)??i(a.from),g=f.get(a.to)??i(a.to);o.push(`${l} -> ${g}`)}return o.join(`
4
+ `)}static annotate(t,r){if(!e.enabled)return;e._annotations.set(t,r);let n={node:e._resolveKey(t),reason:r,timestamp:Date.now()},o=e.maxTraceEntries;o<=0||(e._traceLog.length<o?e._traceLog.push(n):(e._traceLog[e._traceHead]=n,e._traceFull=!0),e._traceHead=(e._traceHead+1)%o)}static getAnnotation(t){return e._annotations.get(t)}static traceLog(){return e._traceFull?[...e._traceLog.slice(e._traceHead),...e._traceLog.slice(0,e._traceHead)]:e._traceLog.slice(0,e._traceHead||e._traceLog.length)}static clearTrace(){e._traceLog=[],e._traceHead=0,e._traceFull=!1}static timeline(t){let r=null,n=[];return t.source(R,(o,s)=>{if(o===R){r=s;return}let u={timestamp:Date.now(),type:o===I?"data":o===P?"signal":"end",data:s,inBatch:J()};n.push(u),o===w&&(r=null)}),{entries:n,dispose:()=>r?.(w)}}static observeDerived(t){let r=[],n=t,o=n._fn;if(typeof o!="function"||!Array.isArray(n._deps))return{...e.observe(t),evaluations:r};n._fn=()=>{let f=n._deps.map(a=>a.get()),c=o();return r.push({result:c,depValues:f,timestamp:Date.now()}),c};let s=e._observe(t),u=s.dispose;return{...s,evaluations:r,dispose:()=>{n._fn=o,u()},reconnect:()=>(n._fn=o,u(),e.observeDerived(t))}}static observeTaskState(t){let r=t.status.get(),n=[],o=null;return t.status.source(R,(s,u)=>{if(s===R){o=u;return}if(s===I){let i=u;if(i!==r){let f={from:r,to:i,timestamp:Date.now()};i==="error"&&(f.error=t.error.get()),n.push(f),r=i}}s===w&&(o=null)}),{transitions:n,get currentStatus(){return t.status.get()},dispose:()=>{o?.(w)}}}static causalityTrace(t){let r=[],n=t,o=n._fn;if(typeof o!="function"||!Array.isArray(n._deps))return{...e.observe(t),causality:r};let s=n._deps,u=s.map(a=>a.get());n._fn=()=>{let a=s.map(m=>m.get()),l=o(),g=-1;for(let m=0;m<s.length;m++)if(!Object.is(a[m],u[m])){g=m;break}return r.push({result:l,triggerDepIndex:g,triggerDepName:g>=0?e.getName(s[g]):void 0,depValues:a,timestamp:Date.now()}),u=a,l};let i=e._observe(t),f=i.dispose;return{...i,causality:r,dispose:()=>{n._fn=o,f()},reconnect:()=>(n._fn=o,f(),e.causalityTrace(t))}}static _reset(){e._names=new WeakMap,e._kinds=new WeakMap,e._keys=new WeakMap,e._stores=new Set,e._edges=new Map,e._usedKeys=new Set,e._nextId=0,e._explicitEnabled=null,e._cachedDefault=null,e._annotations=new WeakMap,e._traceLog=[],e._traceHead=0,e._traceFull=!1,e.maxTraceEntries=1e3}};var le=1,$=64,L=2,G=4,Ae=8,Oe=16,V=32,H=1024,C=me,Q=_e<<q,te=ve<<q,ce=ye<<q,Qe=ke<<q,Ze=we<<q,Xe=Ee<<q,ne=class{_value;_output=null;_flags;get _status(){return xe(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;_onLifecycleSignal;constructor(t,r){this._value=r?.initial,this._fn=t,this._eqFn=r?.equals,this._getterFn=r?.getter,this._initial=r?.initial;let n=0;r?.autoDirty!==!1&&(n|=G),r?.resetOnTeardown&&(n|=Ae),r?.resubscribable&&(n|=Oe),this._flags=n,this.source=this.source.bind(this),this.emit=this.emit.bind(this),r?._skipInspect||A.register(this,{kind:"producer",...r})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,r){let n=this._output;if(n)if(this._flags&$)for(let o of n)o(t,r);else n(t,r)}emit(t){this._flags&L||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(J()?this._flags&V||(this._flags|=V,this._flags&G&&(this._flags=this._flags&~C|Q,this._dispatch(P,M)),ue(()=>{this._flags&=~V,this._flags=this._flags&~C|te,this._dispatch(I,this._value)})):(this._flags&G&&!(this._flags&H)&&(this._flags=this._flags&~C|Q,this._dispatch(P,M)),this._flags=this._flags&~C|te,this._dispatch(I,this._value))))}signal(t){this._flags&L||!this._output||(t===M?this._flags=this._flags&~C|Q:t===ee&&(this._flags=this._flags&~C|Xe),this._dispatch(P,t))}complete(){if(this._flags&L)return;this._flags=(this._flags|L)&~C|Qe;let t=this._output,r=this._flags&$;if(this._output=null,this._flags&=~($|H),this._singleDepCount=0,this._stop(),t)if(r)for(let n of t)n(w);else t(w)}error(t){if(this._flags&L)return;this._flags=(this._flags|L)&~C|Ze;let r=this._output,n=this._flags&$;if(this._output=null,this._flags&=~($|H),this._singleDepCount=0,this._stop(),r)if(n)for(let o of r)o(w,t);else r(w,t)}_start(){if(this._flags&le||!this._fn)return;this._flags|=le,this._onLifecycleSignal=void 0;let t=this._fn({emit:this.emit,signal:r=>this.signal(r),complete:()=>this.complete(),error:r=>this.error(r),onSignal:r=>{this._onLifecycleSignal=r}});this._cleanup=typeof t=="function"?t:void 0}_stop(){this._flags&le&&(this._flags&=~le,this._onLifecycleSignal=void 0,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&Ae&&(this._value=this._initial),this._flags&L||(this._flags=this._flags&~C|ce))}_handleLifecycleSignal(t){if(!(this._flags&L)){if(t===ge){this._onLifecycleSignal?.(t),this.complete();return}t===j&&(this._value=this._initial,this._flags&=~V),this._onLifecycleSignal?.(t),t===j&&this.emit(this._initial)}}source(t,r){if(t===R){let n=r;if(this._flags&L)if(this._flags&Oe&&this._output===null)this._flags=this._flags&~(L|C)|ce;else{n(R,s=>{}),n(w);return}if(this._output===null)this._output=n;else if(this._flags&$)this._output.add(n);else{let s=new Set;s.add(this._output),s.add(n),this._output=s,this._flags=(this._flags|$)&~H}let o=!1;n(R,(s,u)=>{if(s===I&&n(I,this._value),s===P){u===Te&&!o?(o=!0,this._singleDepCount++,this._flags&$||(this._flags|=H)):be(u)&&this._handleLifecycleSignal(u);return}if(s===w){if(o&&(o=!1,this._singleDepCount--),this._output===null)return;if(this._flags&$){let i=this._output;i.delete(n),i.size===1?(this._output=i.values().next().value,this._flags&=~$,this._singleDepCount>0&&(this._flags|=H)):i.size===0&&(this._output=null,this._flags&=~($|H),this._singleDepCount=0,this._flags=this._flags&~C|ce,this._stop())}else this._output===n&&(this._output=null,this._flags&=~H,this._singleDepCount=0,this._flags=this._flags&~C|ce,this._stop())}}),Ce(()=>this._start())}}};function K(e,t){return new ne(e,t)}var Se=class extends ne{constructor(t,r){super(void 0,{initial:t,autoDirty:!0,equals:r?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),A.register(this,{kind:"state",...r})}get(){return this._value}set(t){this._flags&L||this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(J()?this._flags&V||(this._flags|=V,this._flags&G&&(this._flags=this._flags&~C|Q,this._dispatch(P,M)),ue(()=>{this._flags&=~V,this._flags=this._flags&~C|te,this._dispatch(I,this._value)})):(this._flags&G&&!(this._flags&H)&&(this._flags=this._flags&~C|Q,this._dispatch(P,M)),this._flags=this._flags&~C|te,this._dispatch(I,this._value))))}update(t){this.set(t(this._value))}};function x(e,t){return new Se(e,t)}function Pe(e){return(t,r)=>{if(t!==0)return;let n=new AbortController,o=n.signal,s=!1,u,i;try{u=typeof e=="function"?e():e,i=u[Symbol.asyncIterator]()}catch(c){r(0,()=>{}),r(2,c);return}r(0,c=>{c===2&&!s&&(s=!0,n.abort(),Promise.resolve(i.return?.()).catch(()=>{}))});async function f(){try{for(;!s&&!o.aborted;){let c=await i.next();if(s||o.aborted)break;if(c.done){s=!0,r(2);return}r(1,c.value)}}catch(c){!s&&!o.aborted&&(s=!0,r(2,c))}}f()}}function Ie(e){return(t,r)=>{if(t!==0)return;let n=!1;r(0,o=>{o===2&&(n=!0)}),e.then(o=>{n||(r(1,o),n||r(2))},o=>{n||r(2,o)})}}function et(e){return e!=null&&typeof e.then=="function"}function tt(e){return e!=null&&typeof e[Symbol.asyncIterator]=="function"}function nt(e){return e!=null&&typeof e[Symbol.iterator]=="function"}function U(e){return et(e)?Ie(e):tt(e)?Pe(e):typeof e!="string"&&nt(e)?(t,r)=>{if(t!==0)return;let n=!1;r(0,o=>{o===2&&(n=!0)});for(let o of e){if(n)return;r(1,o)}n||r(2)}:(t,r)=>{if(t!==0)return;let n=!1;r(0,o=>{o===2&&(n=!0)}),n||r(1,e),n||r(2)}}function B(e,t,r){let n=null;return e(0,(o,s)=>{if(o===0){n=s;return}if(o===2){n=null,r?.onEnd?.(s);return}o===1&&t(s)}),{unsubscribe(){n?.(2),n=null}}}function Z(e,t,r){let n=null;Re(),e.source(R,(s,u)=>{if(s===R&&(n=u),s===w){n=null,r?.onEnd?.(u);return}if(s===1){let i=u,f=o;o=i,t(i,f)}});let o;try{o=e.get()}catch{}return De(),{unsubscribe(){n?.(w),n=null},signal(s){n?.(P,s)}}}function X(e,t){let r=t?.initialStatus??"pending",n=x(r,{name:"withStatus:status",equals:Object.is}),o=x(void 0,{name:"withStatus:error",equals:Object.is}),s=K(({emit:i,complete:f,error:c})=>{n.set(r),o.set(void 0);let a=Z(e,l=>{n.get()==="errored"?F(()=>{o.set(void 0),n.set("active")}):n.set("active"),i(l)},{onEnd:l=>{if(l!==void 0){let g=l instanceof Error?l:new Error(String(l));F(()=>{o.set(g),n.set("errored")}),c(l)}else n.set("completed"),f()}});return()=>{a.unsubscribe()}},{initial:e.get(),resubscribable:!0}),u={get:()=>e.get(),source:(i,f)=>s.source(i,f),get _status(){return s._status},status:n,error:o};return A.register(u,{kind:"withStatus"}),u}function Le(e,t){let r=t?.name??"http",n=t?.method??"GET",o=t?.headers,s=t?.body,u=t?.poll??0,i=t?.transform??(E=>E.json()),f=t?.timeout??3e4,c=x(0,{name:`${r}:fetchCount`}),a=null,l=null,g=null,m=null,T=null,_=!1;function D(){if(!_||!a)return;T=new AbortController;let E=[T.signal];t?.signal&&E.push(t.signal);let v=new AbortController;for(let k of E){if(k.aborted){v.abort(k.reason);break}k.addEventListener("abort",()=>v.abort(k.reason),{once:!0})}let y=setTimeout(()=>v.abort(new Error("Request timeout")),f),O=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0;B(U(fetch(e,{method:n,headers:o,body:O,signal:v.signal})),k=>{if(!_){clearTimeout(y),T=null;return}if(!k.ok){clearTimeout(y),T=null,l?.(new Error(`HTTP ${k.status}: ${k.statusText}`));return}B(U(i(k)),W=>{clearTimeout(y),T=null,_&&(F(()=>{c.update(N=>N+1),a?.(W)}),h())},{onEnd:W=>{if(clearTimeout(y),T=null,W!==void 0){if(!_||W?.name==="AbortError")return;l?.(W)}}})},{onEnd:k=>{if(clearTimeout(y),T=null,k!==void 0){if(!_||k?.name==="AbortError")return;l?.(k)}}})}function h(){!_||p||u<=0||(m=setTimeout(()=>{m=null,D()},u))}let d=null,p=!1,S=K(({emit:E,error:v,complete:y,onSignal:O})=>(a=E,l=v,g=y,_=!0,p=!1,d=()=>{D()},O(k=>{k===z?(p=!0,m!==null&&(clearTimeout(m),m=null)):k===Y?(p=!1,h()):k===j&&(T?.abort(),T=null,m!==null&&(clearTimeout(m),m=null),c.set(0),p=!1,D())}),D(),()=>{_=!1,p=!1,a=null,l=null,g=null,d=null,T?.abort(),T=null,m!==null&&(clearTimeout(m),m=null)}),{name:r,kind:"http"}),b=X(S);return{get:()=>b.get(),source:(E,v)=>b.source(E,v),status:b.status,error:b.error,fetchCount:c,refetch(){d?.()},stop(){_=!1,T?.abort(),T=null,m!==null&&(clearTimeout(m),m=null),g?.()}}}function We(e){let t=e.name??"mcp",r=e.client,n=x([],{name:`${t}.tools`}),o=x([],{name:`${t}.resources`}),s=x(void 0,{name:`${t}.refreshError`});function u(c){s.set(c);let a=e.onRefreshError;if(a==="warn")console.warn(`[${t}] refresh error:`,c);else{if(a==="error")throw c;typeof a=="function"&&a(c)}}function i(){s.set(void 0),r.listTools&&B(U(r.listTools()),c=>{n.set(c.tools)},{onEnd:c=>{c!==void 0&&u(c)}}),r.listResources&&B(U(r.listResources()),c=>{o.set(c.resources)},{onEnd:c=>{c!==void 0&&u(c)}})}function f(c){let a=`${t}:${c}`,l=x(void 0,{name:`${a}.result`}),g=x("idle",{name:`${a}.status`}),m=x(void 0,{name:`${a}.error`}),T=x(void 0,{name:`${a}.lastArgs`}),_=x(void 0,{name:`${a}.duration`}),D=!1;function h(d){if(D)return;D=!0,F(()=>{T.set(d),m.set(void 0),g.set("active")});let p=Date.now();B(U(r.callTool({name:c,arguments:d})),S=>{D=!1;let b=Date.now()-p;if(S.isError){let y=S.content.filter(k=>k.type==="text").map(k=>k.text??"").join(`
5
+ `),O=new Error(y||"MCP tool returned error");F(()=>{_.set(b),m.set(O),g.set("errored")});return}let E=S.content.filter(y=>y.type==="text"),v;if(E.length===1){let y=E[0].text;if(y!==void 0)try{v=JSON.parse(y)}catch{v=y}}else E.length>1?v=E.map(y=>y.text??""):v=S.content;F(()=>{_.set(b),l.set(v),g.set("completed")})},{onEnd:S=>{if(D=!1,S===void 0)return;let b=Date.now()-p;F(()=>{_.set(b),m.set(S),g.set("errored")})}})}return{get:()=>l.get(),source:(d,p)=>l.source(d,p),status:g,error:m,call:h,lastArgs:T,duration:_}}return{tool:f,tools:n,resources:o,refresh:i,refreshError:s}}function fe(e){return(t,r)=>{if(t!==0)return;let n=!1,o;r(0,s=>{s===2&&!n&&(n=!0,o?.())});try{o=e(s=>{n||(n=!0,r(1,s),r(2))},s=>{n||(n=!0,r(2,s))})}catch(s){n||(n=!0,r(2,s))}}}function $e(e,t){let r=t?.path??"/",n=t?.name??"sse",o=t?.hostname??"0.0.0.0",s=t?.serialize??JSON.stringify,u=t?.eventName??"message",i=t?.pingInterval??3e4,f=x(0,{name:`${n}:connections`}),c=new Set,a=new Map,l=null;function g(){l||(l=Z(e,d=>{let p=s(d),S=`event: ${u}
6
+ data: ${p}
7
7
 
8
- `;for(let y of f)try{y.write(h)}catch{m(y)}}))}function m(p){f.delete(p);let g=i.get(p);g&&(clearInterval(g),i.delete(p)),c.set(f.size),f.size===0&&l&&(l.unsubscribe(),l=null)}function b(p,g){let h=p.method?.toUpperCase();if((p.url??"/").split("?")[0]!==o){g.writeHead(404,{"Content-Type":"text/plain"}),g.end("Not found");return}if(h==="OPTIONS"){g.writeHead(204,{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET","Access-Control-Allow-Headers":"Cache-Control"}),g.end();return}if(h!=="GET"){g.writeHead(405,{"Content-Type":"text/plain"}),g.end("Method not allowed");return}g.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive","Access-Control-Allow-Origin":"*"}),g.write(`:ok
8
+ `;for(let b of c)try{b.write(S)}catch{m(b)}}))}function m(d){c.delete(d);let p=a.get(d);p&&(clearInterval(p),a.delete(d)),f.set(c.size),c.size===0&&l&&(l.unsubscribe(),l=null)}function T(d,p){let S=d.method?.toUpperCase();if((d.url??"/").split("?")[0]!==r){p.writeHead(404,{"Content-Type":"text/plain"}),p.end("Not found");return}if(S==="OPTIONS"){p.writeHead(204,{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET","Access-Control-Allow-Headers":"Cache-Control"}),p.end();return}if(S!=="GET"){p.writeHead(405,{"Content-Type":"text/plain"}),p.end("Method not allowed");return}p.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive","Access-Control-Allow-Origin":"*"}),p.write(`:ok
9
9
 
10
- `),f.add(g),c.set(f.size);try{let _=t.get();if(_!==void 0){let v=s(_);g.write(`event: ${u}
11
- data: ${v}
10
+ `),c.add(p),f.set(c.size);try{let v=e.get();if(v!==void 0){let y=s(v);p.write(`event: ${u}
11
+ data: ${y}
12
12
 
13
- `)}}catch{}if(a>0){let _=setInterval(()=>{try{g.write(`:ping
13
+ `)}}catch{}if(i>0){let v=setInterval(()=>{try{p.write(`:ping
14
14
 
15
- `)}catch{m(g)}},a);i.set(g,_)}p.on("close",()=>m(g)),d()}let T=null;async function C(){if(!e?.port)throw new Error("toSSE: port is required for listen()");if(T)throw new Error("toSSE: already listening. Call close() first.");let p=await import("http");return le(ce((g,h)=>{T=p.createServer(b),T.once("listening",()=>g()),T.once("error",y=>{T=null,h(y)}),T.listen(e.port,r)}))}function S(){for(let p of f)try{p.end()}catch{}f.clear();for(let p of i.values())clearInterval(p);i.clear(),c.set(0),l?.unsubscribe(),l=null,T?.close(),T=null}return P.register(c,{kind:"sse"}),{connectionCount:c,handler:b,listen:C,close:S}}function Ie(t){let e=t?.path??"/",o=t?.parse??JSON.parse,n=t?.name??"webhook",r=t?.hostname??"0.0.0.0",s=t?.maxBodySize??1024*1024,u=t?.responseTimeout??3e4,a=w(0,{name:`${n}:count`}),c=null,f=!1,i=V(({emit:S,onSignal:p})=>(c=S,f=!1,p(g=>{g===U?f=!0:g===K?f=!1:g===N&&(f=!1,a.set(0))}),()=>{c=null,f=!1}),{name:n,kind:"webhook"});P.register(i,{kind:"webhook"});let l=Q(i),d=null,m=new Set;function b(S,p){let g=S.method?.toUpperCase(),y=(S.url??"/").split("?")[0];if(g!=="POST"||y!==e){p.writeHead(404,{"Content-Type":"application/json"}),p.end(JSON.stringify({error:"Not found"}));return}if(f){p.writeHead(503,{"Content-Type":"application/json"}),p.end(JSON.stringify({error:"Service paused"}));return}let x=[],_=0,v=!1;S.on("error",()=>{v=!0,p.headersSent||(p.writeHead(400,{"Content-Type":"application/json"}),p.end(JSON.stringify({error:"Request aborted"})))}),S.on("data",k=>{if(!v){if(_+=k.length,_>s){v=!0,p.writeHead(413,{"Content-Type":"application/json"}),p.end(JSON.stringify({error:"Payload too large"})),S.destroy?.();return}x.push(k)}}),S.on("end",()=>{if(!v)try{let k=Buffer.concat(x).toString("utf-8"),O=k.length>0?o(k):void 0;a.update(fe=>fe+1);let q=!1,$=null,Ne={body:O,get responded(){return q},respond(fe,je=200){q||(q=!0,$!==null&&(clearTimeout($),m.delete($),$=null),p.writeHead(je,{"Content-Type":"application/json"}),p.end(JSON.stringify(fe)))}};$=setTimeout(()=>{m.delete($),$=null,q||(q=!0,p.writeHead(504,{"Content-Type":"application/json"}),p.end(JSON.stringify({error:"Response timeout"})))},u),m.add($),c?.(Ne)}catch(k){p.writeHead(400,{"Content-Type":"application/json"}),p.end(JSON.stringify({error:k?.message??"Parse error"}))}})}function T(){return t?.port?d?Promise.reject(new Error("fromWebhook: already listening. Call close() first.")):le(ce((S,p)=>{try{d=require("http").createServer(b),d.once("listening",()=>S()),d.once("error",h=>{d=null,p(h)}),d.listen(t.port,r);return}catch(g){p(g);return}})):Promise.reject(new Error("fromWebhook: port is required for listen()"))}function C(){for(let S of m)clearTimeout(S);m.clear(),d?.close(),d=null}return{get:()=>l.get(),source:(S,p)=>l.source(S,p),status:l.status,error:l.error,requestCount:a,handler:b,listen:T,close:C}}function $e(t,e){let o=e?.name??"websocket",n=e?.parse??(h=>h),r=e?.reconnect??!1,s=e?.onParseError??"warn",u=w("connecting",{name:`${o}:connectionState`,equals:()=>!1}),a=null,c=null,f=null,i=null,l=null,d=!1,m=null,b=[];function T(){for(;b.length>0&&a?.readyState===WebSocket.OPEN;)a.send(b.shift())}function C(){d=!1,u.set("connecting");try{a=new WebSocket(t,e?.protocols)}catch(h){u.set("closed"),f?.(h);return}a.onopen=()=>{u.set("open"),T()},a.onmessage=h=>{if(!S)try{let y=n(h.data);c?.(y)}catch(y){s==="error"?f?.(y):s==="warn"&&console.warn(`[${o}] parse error:`,y)}},a.onerror=()=>{m=new Error(`WebSocket error on ${t}`)},a.onclose=()=>{u.set("closed"),a=null;let h=m;m=null,!d&&r!==!1?l=setTimeout(()=>{l=null,c&&C()},r):h&&!d?f?.(h):i?.()}}let S=!1,p=V(({emit:h,error:y,complete:x,onSignal:_})=>(c=h,f=y,i=x,S=!1,C(),_(v=>{v===U?S=!0:v===K?S=!1:v===N&&(S=!1,b.length=0,l!==null&&(clearTimeout(l),l=null),a&&(d=!0,a.onopen=null,a.onmessage=null,a.onerror=null,a.onclose=null,a.close(),a=null),u.set("closed"),C())}),()=>{c=null,f=null,i=null,S=!1,d=!0,b.length=0,l!==null&&(clearTimeout(l),l=null),a&&(a.onopen=null,a.onmessage=null,a.onerror=null,a.onclose=null,a.close(),a=null),u.set("closed")}),{name:o,kind:"websocket"});P.register(p,{kind:"websocket"});let g=Q(p);return{get:()=>g.get(),source:(h,y)=>g.source(h,y),status:g.status,error:g.error,connectionState:u,send(h){a?.readyState===WebSocket.OPEN?a.send(h):b.push(h)},close(h,y){d=!0,b.length=0,l!==null&&(clearTimeout(l),l=null),a?.close(h,y)}}}function Me(t,e,o){let n=u=>typeof u=="string"?u:JSON.stringify(u),r=o?.serialize??n,s="send"in t&&typeof t.send=="function"?t.send.bind(t):null;if(!s)throw new Error("toWebSocket: invalid WebSocket target");return G(e,u=>{try{let a=r(u);s(a)}catch{}})}0&&(module.exports={fromHTTP,fromMCP,fromWebSocket,fromWebhook,toSSE,toWebSocket});
15
+ `)}catch{m(p)}},i);a.set(p,v)}d.on("close",()=>m(p)),g()}let _=null;function D(){return t?.port?_?(d,p)=>{d===0&&(p(0,()=>{}),p(2,new Error("toSSE: already listening. Call close() first.")))}:(d,p)=>{if(d!==0)return;let S=!1;p(0,b=>{b===2&&(S=!0)}),B(U(import("http")),b=>{S||B(fe((E,v)=>{_=b.createServer(T),_.once("listening",()=>E()),_.once("error",y=>{_=null,v(y)}),_.listen(t.port,o)}),()=>{S||(p(1,void 0),p(2))},{onEnd:E=>{E!==void 0&&!S&&p(2,E)}})})}:(d,p)=>{d===0&&(p(0,()=>{}),p(2,new Error("toSSE: port is required for listen()")))}}function h(){for(let d of c)try{d.end()}catch{}c.clear();for(let d of a.values())clearInterval(d);a.clear(),f.set(0),l?.unsubscribe(),l=null,_?.close(),_=null}return A.register(f,{kind:"sse"}),{connectionCount:f,handler:T,listen:D,close:h}}function Ne(e){let t=e?.path??"/",r=e?.parse??JSON.parse,n=e?.name??"webhook",o=e?.hostname??"0.0.0.0",s=e?.maxBodySize??1024*1024,u=e?.responseTimeout??3e4,i=x(0,{name:`${n}:count`}),f=null,c=!1,a=K(({emit:h,onSignal:d})=>(f=h,c=!1,d(p=>{p===z?c=!0:p===Y?c=!1:p===j&&(c=!1,i.set(0))}),()=>{f=null,c=!1}),{name:n,kind:"webhook"});A.register(a,{kind:"webhook"});let l=X(a),g=null,m=new Set;function T(h,d){let p=h.method?.toUpperCase(),b=(h.url??"/").split("?")[0];if(p!=="POST"||b!==t){d.writeHead(404,{"Content-Type":"application/json"}),d.end(JSON.stringify({error:"Not found"}));return}if(c){d.writeHead(503,{"Content-Type":"application/json"}),d.end(JSON.stringify({error:"Service paused"}));return}let E=[],v=0,y=!1;h.on("error",()=>{y=!0,d.headersSent||(d.writeHead(400,{"Content-Type":"application/json"}),d.end(JSON.stringify({error:"Request aborted"})))}),h.on("data",O=>{if(!y){if(v+=O.length,v>s){y=!0,d.writeHead(413,{"Content-Type":"application/json"}),d.end(JSON.stringify({error:"Payload too large"})),h.destroy?.();return}E.push(O)}}),h.on("end",()=>{if(!y)try{let O=Buffer.concat(E).toString("utf-8"),k=O.length>0?r(O):void 0;i.update(de=>de+1);let W=!1,N=null,Fe={body:k,get responded(){return W},respond(de,He=200){W||(W=!0,N!==null&&(clearTimeout(N),m.delete(N),N=null),d.writeHead(He,{"Content-Type":"application/json"}),d.end(JSON.stringify(de)))}};N=setTimeout(()=>{m.delete(N),N=null,W||(W=!0,d.writeHead(504,{"Content-Type":"application/json"}),d.end(JSON.stringify({error:"Response timeout"})))},u),m.add(N),f?.(Fe)}catch(O){d.writeHead(400,{"Content-Type":"application/json"}),d.end(JSON.stringify({error:O?.message??"Parse error"}))}})}function _(){return e?.port?g?(h,d)=>{h===0&&(d(0,()=>{}),d(2,new Error("fromWebhook: already listening. Call close() first.")))}:fe((h,d)=>{try{g=require("http").createServer(T),g.once("listening",()=>h()),g.once("error",S=>{g=null,d(S)}),g.listen(e.port,o);return}catch(p){d(p);return}}):(h,d)=>{h===0&&(d(0,()=>{}),d(2,new Error("fromWebhook: port is required for listen()")))}}function D(){for(let h of m)clearTimeout(h);m.clear(),g?.close(),g=null}return{get:()=>l.get(),source:(h,d)=>l.source(h,d),status:l.status,error:l.error,requestCount:i,handler:T,listen:_,close:D}}function Me(e,t){let r=t?.name??"websocket",n=t?.parse??(S=>S),o=t?.reconnect??!1,s=t?.onParseError??"warn",u=x("connecting",{name:`${r}:connectionState`,equals:()=>!1}),i=null,f=null,c=null,a=null,l=null,g=!1,m=null,T=[];function _(){for(;T.length>0&&i?.readyState===WebSocket.OPEN;)i.send(T.shift())}function D(){g=!1,u.set("connecting");try{i=new WebSocket(e,t?.protocols)}catch(S){u.set("closed"),c?.(S);return}i.onopen=()=>{u.set("open"),_()},i.onmessage=S=>{if(!h)try{let b=n(S.data);f?.(b)}catch(b){s==="error"?c?.(b):s==="warn"&&console.warn(`[${r}] parse error:`,b)}},i.onerror=()=>{m=new Error(`WebSocket error on ${e}`)},i.onclose=()=>{u.set("closed"),i=null;let S=m;m=null,!g&&o!==!1?l=setTimeout(()=>{l=null,f&&D()},o):S&&!g?c?.(S):a?.()}}let h=!1,d=K(({emit:S,error:b,complete:E,onSignal:v})=>(f=S,c=b,a=E,h=!1,D(),v(y=>{y===z?h=!0:y===Y?h=!1:y===j&&(h=!1,T.length=0,l!==null&&(clearTimeout(l),l=null),i&&(g=!0,i.onopen=null,i.onmessage=null,i.onerror=null,i.onclose=null,i.close(),i=null),u.set("closed"),D())}),()=>{f=null,c=null,a=null,h=!1,g=!0,T.length=0,l!==null&&(clearTimeout(l),l=null),i&&(i.onopen=null,i.onmessage=null,i.onerror=null,i.onclose=null,i.close(),i=null),u.set("closed")}),{name:r,kind:"websocket"});A.register(d,{kind:"websocket"});let p=X(d);return{get:()=>p.get(),source:(S,b)=>p.source(S,b),status:p.status,error:p.error,connectionState:u,send(S){i?.readyState===WebSocket.OPEN?i.send(S):T.push(S)},close(S,b){g=!0,T.length=0,l!==null&&(clearTimeout(l),l=null),i?.close(S,b)}}}function je(e,t,r){let n=u=>typeof u=="string"?u:JSON.stringify(u),o=r?.serialize??n,s="send"in e&&typeof e.send=="function"?e.send.bind(e):null;if(!s)throw new Error("toWebSocket: invalid WebSocket target");return Z(t,u=>{try{let i=o(u);s(i)}catch{}})}0&&(module.exports={fromHTTP,fromMCP,fromWebSocket,fromWebhook,toSSE,toWebSocket});
@@ -6,3 +6,4 @@ export { FromWebSocketOptions, ToWebSocketOptions, WebSocketConnectionState, Web
6
6
  import '../types-BohB8jJr.cjs';
7
7
  import '../protocol-fwiQ1TAS.cjs';
8
8
  import '../withStatus-ByT_R2Rz.cjs';
9
+ import '../subscribe-BHH8VVDm.cjs';
@@ -6,3 +6,4 @@ export { FromWebSocketOptions, ToWebSocketOptions, WebSocketConnectionState, Web
6
6
  import '../types-CB1htCM8.js';
7
7
  import '../protocol-fwiQ1TAS.js';
8
8
  import '../withStatus---CFNir7.js';
9
+ import '../subscribe-BHH8VVDm.js';
@@ -1 +1 @@
1
- import{a as o}from"../chunk-ZDGVUX5G.js";import{a as e}from"../chunk-Q5DHO5II.js";import{a as t}from"../chunk-PLIRVTP4.js";import{a as r}from"../chunk-7B4DHRG6.js";import"../chunk-XEU7KSEO.js";import"../chunk-4VPAGOLZ.js";import"../chunk-4ILN4V4C.js";import{a as p,b as S}from"../chunk-U3FGSR3I.js";import"../chunk-5LLYKN4X.js";import"../chunk-GMLWTZFM.js";import"../chunk-EAK2HKAD.js";import"../chunk-2F6QWERG.js";import"../chunk-2L6223KN.js";import"../chunk-TUPD47IE.js";import"../chunk-I7AUKTXE.js";export{o as fromHTTP,e as fromMCP,p as fromWebSocket,r as fromWebhook,t as toSSE,S as toWebSocket};
1
+ import{a as o}from"../chunk-FJ2VN2O3.js";import{a as e}from"../chunk-6WZQIJIW.js";import{a as t}from"../chunk-565W67EU.js";import{a as r}from"../chunk-YCYCWSXF.js";import"../chunk-XEU7KSEO.js";import{a as p,b as S}from"../chunk-U3FGSR3I.js";import"../chunk-5LLYKN4X.js";import"../chunk-GMLWTZFM.js";import"../chunk-O2PONDZT.js";import"../chunk-J2E7GAMR.js";import"../chunk-4ILN4V4C.js";import"../chunk-Q3HIBGHR.js";import"../chunk-EAK2HKAD.js";import"../chunk-2F6QWERG.js";import"../chunk-2L6223KN.js";import"../chunk-TUPD47IE.js";import"../chunk-I7AUKTXE.js";export{o as fromHTTP,e as fromMCP,p as fromWebSocket,r as fromWebhook,t as toSSE,S as toWebSocket};
@@ -1,5 +1,5 @@
1
- "use strict";var Z=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var me=(t,e)=>{for(var i in e)Z(t,i,{get:e[i],enumerable:!0})},ye=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of _e(e))!Se.call(t,s)&&s!==i&&Z(t,s,{get:()=>e[s],enumerable:!(n=Te(e,s))||n.enumerable});return t};var ve=t=>ye(Z({},"__esModule",{value:!0}),t);var Le={};me(Le,{fromMCP:()=>Ae});module.exports=ve(Le);var v=Symbol("DIRTY"),$=Symbol("RESOLVED"),ne=Symbol("SINGLE_DEP"),U=Symbol("RESET"),Ee=Symbol("PAUSE"),be=Symbol("RESUME"),X=Symbol("TEARDOWN");function se(t){return t===U||t===Ee||t===be||t===X}var ie=0,re=1,oe=2,ae=3,ue=4,le=5,D=7,ee=7<<D,De=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function ce(t){return De[(t&ee)>>>D]}var T=0,_=1,g=2,m=3,W=0,Y=[],Q=!1;function I(t){W++;try{return t()}finally{if(W--,W===0&&!Q){Q=!0;for(let e=0;e<Y.length;e++)Y[e]();Y.length=0,Q=!1}}}function x(){return W>0}function B(t){Y.push(t)}var ke=0,Re=[];function fe(t){ke>0?Re.push(t):t()}var O=class t{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static _annotations=new WeakMap;static _traceLog=[];static _traceHead=0;static _traceFull=!1;static maxTraceEntries=1e3;static get enabled(){if(t._explicitEnabled!==null)return t._explicitEnabled;if(t._cachedDefault!==null)return t._cachedDefault;try{t._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{t._cachedDefault=!0}return t._cachedDefault}static set enabled(e){t._explicitEnabled=e}static _depSuffix(e){if(!e?.length)return;let n=e.map(s=>t._names.get(s)??"?").join(",");return n.length>40?`${n.slice(0,37)}...`:n}static _resolveKey(e){let i=t._keys.get(e)??t._names.get(e);if(i)return i;let n=`anonymous_${t._nextId++}`;return t._keys.set(e,n),n}static register(e,i){if(!t.enabled)return;i?.name&&t._names.set(e,i.name),i?.kind&&t._kinds.set(e,i.kind);let n=t._nextId++,s=i?.name;if(!(s&&!t._usedKeys.has(s)))if(s){let o=t._depSuffix(i?.deps);s=o?`${s}(${o})`:`${s}_${n}`,t._usedKeys.has(s)&&(s=`${s}_${n}`)}else{let o=i?.kind??"store",a=t._depSuffix(i?.deps);s=a?`${o}(${a})`:`${o}_${n}`,t._usedKeys.has(s)&&(s=`${s}_${n}`)}t._usedKeys.add(s),t._keys.set(e,s),t._stores.add(new WeakRef(e))}static registerEdge(e,i){if(!t.enabled)return;let n=t._resolveKey(e),s=t._resolveKey(i),o=t._edges.get(n);o?o.includes(s)||o.push(s):t._edges.set(n,[s])}static getEdges(){return new Map(t._edges)}static getName(e){if(t.enabled)return t._names.get(e)}static getKind(e){return t._kinds.get(e)}static inspect(e){return{name:t._names.get(e),kind:t._kinds.get(e)??"unknown",value:typeof e.get=="function"?e.get():void 0,status:e._status}}static graph(){let e=new Map,i=new Set;for(let n of t._stores){let s=n.deref();if(!s){t._stores.delete(n);continue}let o=t._resolveKey(s);i.add(o),e.set(o,t.inspect(s))}for(let[n,s]of t._edges){if(!i.has(n)){t._edges.delete(n),t._usedKeys.delete(n);continue}let o=s.filter(a=>i.has(a));o.length===0?t._edges.delete(n):o.length!==s.length&&t._edges.set(n,o)}return e}static trace(e,i){let n=null,s=e.get();return e.source(T,(o,a)=>{if(o===T&&(n=a),o===g){n=null;return}if(o===1){let u=a;if(!Object.is(u,s)){let l=s;s=u,i(u,l)}}}),()=>n?.(g)}static dumpGraph(){let e=t.graph(),i=t.getEdges(),n=new Map;for(let[a,u]of i)for(let l of u){let f=n.get(l);f?f.includes(a)||f.push(a):n.set(l,[a])}let s=[];for(let[a,u]of e){let l=n.get(a),f=i.get(a),r=l?.length?` \u2190 [${l.join(", ")}]`:"",c=f?.length?` \u2192 [${f.join(", ")}]`:"";s.push(` ${a} (${u.kind}) = ${JSON.stringify(u.value)} [${u.status??"?"}]${r}${c}`)}return[`Store Graph (${e.size} nodes):`,...s].join(`
2
- `)}static _signalLabel(e){return e===v?"DIRTY":e===$?"RESOLVED":typeof e=="symbol"?e.description??String(e):String(e)}static _observe(e,i,n){let s=null,o=!1,a=i??t.getName(e),u=[],l={values:[],signals:[],events:[],ended:!1,endError:void 0,get completedCleanly(){return l.ended&&!o},get errored(){return l.ended&&o},dirtyCount:0,resolvedCount:0,name:a,get eventLog(){return u},dispose:()=>s?.(g),reconnect:()=>(s?.(g),t._observe(e,i,n))};return e.source(T,(f,r)=>{if(f===T){s=r;return}let c=x();f===_?(l.values.push(r),l.events.push({type:"data",data:r,inBatch:c}),u.push(r),n&&n(`[${a}] DATA:`,r)):f===m?(l.signals.push(r),l.events.push({type:"signal",data:r,inBatch:c}),u.push(t._signalLabel(r)),r===v?l.dirtyCount++:r===$&&l.resolvedCount++,n&&n(`[${a}] STATE:`,r)):f===g&&(l.ended=!0,l.endError=r,o=r!==void 0,l.events.push({type:"end",data:r,inBatch:c}),u.push(o?["END",r]:"END"),n&&n(`[${a}] END`,r!==void 0?r:""),s=null)}),l}static observe(e){return t._observe(e)}static activate(e){let i=null;return e.source(T,(n,s)=>{n===T&&(i=s),n===g&&(i=null)}),()=>i?.(g)}static tap(e,i){let n=i??`tap(${t.getName(e)??"anon"})`,s={get:()=>e.get(),source:e.source};return t.register(s,{name:n,kind:"tap"}),t.registerEdge(e,s),s}static spy(e,i){let n=i?.name??t.getName(e)??"spy",s=i?.log??console.log;return t._observe(e,n,s)}static snapshot(){let e=t.graph(),i=t.getEdges(),n=new Map;for(let a of t._stores){let u=a.deref();if(!u)continue;let l=t._annotations.get(u);l!==void 0&&n.set(t._resolveKey(u),l)}let s=[];for(let[a,u]of e){let l={name:a,kind:u.kind,value:u.value,status:u.status},f=n.get(a);f!==void 0&&(l.annotation=f),s.push(l)}let o=[];for(let[a,u]of i)for(let l of u)o.push({from:a,to:l});return{nodes:s,edges:o,trace:t.traceLog()}}static toMermaid(e){let i=e?.direction??"TD",n=t.snapshot(),s=[`graph ${i}`],o={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},a=new Map;function u(r){let c=r.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(c);return d===void 0?(a.set(c,1),c):(a.set(c,d+1),`${c}__${d}`)}let l=new Map;function f(r){let c=JSON.stringify(r);return c&&c.length>30?`${c.slice(0,27)}...`:c??"undefined"}for(let r of n.nodes){let c=u(r.name);l.set(r.name,c);let d=`${r.name} (${r.kind}) = ${f(r.value)}`,h=o[r.status??""]??"";s.push(` ${c}["${d}"]${h}`)}for(let r of n.edges){let c=l.get(r.from)??u(r.from),d=l.get(r.to)??u(r.to);s.push(` ${c} --> ${d}`)}return s.push(""),s.push(" classDef settled fill:#d4edda,stroke:#28a745"),s.push(" classDef dirty fill:#fff3cd,stroke:#ffc107"),s.push(" classDef errored fill:#f8d7da,stroke:#dc3545"),s.push(" classDef completed fill:#cce5ff,stroke:#007bff"),s.join(`
3
- `)}static toD2(e){let i=e?.direction??"down",n=t.snapshot(),s=[`direction: ${i}`,""],o={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},a=new Map;function u(r){let c=r.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(c);return d===void 0?(a.set(c,1),c):(a.set(c,d+1),`${c}__${d}`)}let l=new Map;function f(r){let c=JSON.stringify(r);return c&&c.length>30?`${c.slice(0,27)}...`:c??"undefined"}for(let r of n.nodes){let c=u(r.name);l.set(r.name,c);let d=o[r.kind]??"rectangle",h=`${r.name} (${r.kind}) = ${f(r.value)}`,M=r.status?` [${r.status}]`:"";s.push(`${c}: "${h}${M}" { shape: ${d} }`)}n.edges.length>0&&s.push("");for(let r of n.edges){let c=l.get(r.from)??u(r.from),d=l.get(r.to)??u(r.to);s.push(`${c} -> ${d}`)}return s.join(`
4
- `)}static annotate(e,i){if(!t.enabled)return;t._annotations.set(e,i);let n={node:t._resolveKey(e),reason:i,timestamp:Date.now()},s=t.maxTraceEntries;s<=0||(t._traceLog.length<s?t._traceLog.push(n):(t._traceLog[t._traceHead]=n,t._traceFull=!0),t._traceHead=(t._traceHead+1)%s)}static getAnnotation(e){return t._annotations.get(e)}static traceLog(){return t._traceFull?[...t._traceLog.slice(t._traceHead),...t._traceLog.slice(0,t._traceHead)]:t._traceLog.slice(0,t._traceHead||t._traceLog.length)}static clearTrace(){t._traceLog=[],t._traceHead=0,t._traceFull=!1}static timeline(e){let i=null,n=[];return e.source(T,(s,o)=>{if(s===T){i=o;return}let a={timestamp:Date.now(),type:s===_?"data":s===m?"signal":"end",data:o,inBatch:x()};n.push(a),s===g&&(i=null)}),{entries:n,dispose:()=>i?.(g)}}static observeDerived(e){let i=[],n=e,s=n._fn;if(typeof s!="function"||!Array.isArray(n._deps))return{...t.observe(e),evaluations:i};n._fn=()=>{let l=n._deps.map(r=>r.get()),f=s();return i.push({result:f,depValues:l,timestamp:Date.now()}),f};let o=t._observe(e),a=o.dispose;return{...o,evaluations:i,dispose:()=>{n._fn=s,a()},reconnect:()=>(n._fn=s,a(),t.observeDerived(e))}}static observeTaskState(e){let i=e.status.get(),n=[],s=null;return e.status.source(T,(o,a)=>{if(o===T){s=a;return}if(o===_){let u=a;if(u!==i){let l={from:i,to:u,timestamp:Date.now()};u==="error"&&(l.error=e.error.get()),n.push(l),i=u}}o===g&&(s=null)}),{transitions:n,get currentStatus(){return e.status.get()},dispose:()=>{s?.(g)}}}static causalityTrace(e){let i=[],n=e,s=n._fn;if(typeof s!="function"||!Array.isArray(n._deps))return{...t.observe(e),causality:i};let o=n._deps,a=o.map(r=>r.get());n._fn=()=>{let r=o.map(h=>h.get()),c=s(),d=-1;for(let h=0;h<o.length;h++)if(!Object.is(r[h],a[h])){d=h;break}return i.push({result:c,triggerDepIndex:d,triggerDepName:d>=0?t.getName(o[d]):void 0,depValues:r,timestamp:Date.now()}),a=r,c};let u=t._observe(e),l=u.dispose;return{...u,causality:i,dispose:()=>{n._fn=s,l()},reconnect:()=>(n._fn=s,l(),t.causalityTrace(e))}}static _reset(){t._names=new WeakMap,t._kinds=new WeakMap,t._keys=new WeakMap,t._stores=new Set,t._edges=new Map,t._usedKeys=new Set,t._nextId=0,t._explicitEnabled=null,t._cachedDefault=null,t._annotations=new WeakMap,t._traceLog=[],t._traceHead=0,t._traceFull=!1,t.maxTraceEntries=1e3}};var H=1,y=64,S=2,A=4,de=8,ge=16,R=32,E=1024,p=ee,L=re<<D,C=oe<<D,q=ie<<D,xe=ue<<D,we=le<<D,Oe=ae<<D,G=class{_value;_output=null;_flags;get _status(){return ce(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;_onLifecycleSignal;constructor(e,i){this._value=i?.initial,this._fn=e,this._eqFn=i?.equals,this._getterFn=i?.getter,this._initial=i?.initial;let n=0;i?.autoDirty!==!1&&(n|=A),i?.resetOnTeardown&&(n|=de),i?.resubscribable&&(n|=ge),this._flags=n,this.source=this.source.bind(this),this.emit=this.emit.bind(this),i?._skipInspect||O.register(this,{kind:"producer",...i})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(e,i){let n=this._output;if(n)if(this._flags&y)for(let s of n)s(e,i);else n(e,i)}emit(e){this._flags&S||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&(x()?this._flags&R||(this._flags|=R,this._flags&A&&(this._flags=this._flags&~p|L,this._dispatch(m,v)),B(()=>{this._flags&=~R,this._flags=this._flags&~p|C,this._dispatch(_,this._value)})):(this._flags&A&&!(this._flags&E)&&(this._flags=this._flags&~p|L,this._dispatch(m,v)),this._flags=this._flags&~p|C,this._dispatch(_,this._value))))}signal(e){this._flags&S||!this._output||(e===v?this._flags=this._flags&~p|L:e===$&&(this._flags=this._flags&~p|Oe),this._dispatch(m,e))}complete(){if(this._flags&S)return;this._flags=(this._flags|S)&~p|xe;let e=this._output,i=this._flags&y;if(this._output=null,this._flags&=~(y|E),this._singleDepCount=0,this._stop(),e)if(i)for(let n of e)n(g);else e(g)}error(e){if(this._flags&S)return;this._flags=(this._flags|S)&~p|we;let i=this._output,n=this._flags&y;if(this._output=null,this._flags&=~(y|E),this._singleDepCount=0,this._stop(),i)if(n)for(let s of i)s(g,e);else i(g,e)}_start(){if(this._flags&H||!this._fn)return;this._flags|=H,this._onLifecycleSignal=void 0;let e=this._fn({emit:this.emit,signal:i=>this.signal(i),complete:()=>this.complete(),error:i=>this.error(i),onSignal:i=>{this._onLifecycleSignal=i}});this._cleanup=typeof e=="function"?e:void 0}_stop(){this._flags&H&&(this._flags&=~H,this._onLifecycleSignal=void 0,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&de&&(this._value=this._initial),this._flags&S||(this._flags=this._flags&~p|q))}_handleLifecycleSignal(e){if(!(this._flags&S)){if(e===X){this._onLifecycleSignal?.(e),this.complete();return}e===U&&(this._value=this._initial,this._flags&=~R),this._onLifecycleSignal?.(e),e===U&&this.emit(this._initial)}}source(e,i){if(e===T){let n=i;if(this._flags&S)if(this._flags&ge&&this._output===null)this._flags=this._flags&~(S|p)|q;else{n(T,o=>{}),n(g);return}if(this._output===null)this._output=n;else if(this._flags&y)this._output.add(n);else{let o=new Set;o.add(this._output),o.add(n),this._output=o,this._flags=(this._flags|y)&~E}let s=!1;n(T,(o,a)=>{if(o===_&&n(_,this._value),o===m){a===ne&&!s?(s=!0,this._singleDepCount++,this._flags&y||(this._flags|=E)):se(a)&&this._handleLifecycleSignal(a);return}if(o===g){if(s&&(s=!1,this._singleDepCount--),this._output===null)return;if(this._flags&y){let u=this._output;u.delete(n),u.size===1?(this._output=u.values().next().value,this._flags&=~y,this._singleDepCount>0&&(this._flags|=E)):u.size===0&&(this._output=null,this._flags&=~(y|E),this._singleDepCount=0,this._flags=this._flags&~p|q,this._stop())}else this._output===n&&(this._output=null,this._flags&=~E,this._singleDepCount=0,this._flags=this._flags&~p|q,this._stop())}}),fe(()=>this._start())}}};var te=class extends G{constructor(e,i){super(void 0,{initial:e,autoDirty:!0,equals:i?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),O.register(this,{kind:"state",...i})}get(){return this._value}set(e){this._flags&S||this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&(x()?this._flags&R||(this._flags|=R,this._flags&A&&(this._flags=this._flags&~p|L,this._dispatch(m,v)),B(()=>{this._flags&=~R,this._flags=this._flags&~p|C,this._dispatch(_,this._value)})):(this._flags&A&&!(this._flags&E)&&(this._flags=this._flags&~p|L,this._dispatch(m,v)),this._flags=this._flags&~p|C,this._dispatch(_,this._value))))}update(e){this.set(e(this._value))}};function k(t,e){return new te(t,e)}function Ae(t){let e=t.name??"mcp",i=t.client,n=k([],{name:`${e}.tools`}),s=k([],{name:`${e}.resources`}),o=k(void 0,{name:`${e}.refreshError`});function a(f){o.set(f);let r=t.onRefreshError;if(r==="warn")console.warn(`[${e}] refresh error:`,f);else{if(r==="error")throw f;typeof r=="function"&&r(f)}}async function u(){if(o.set(void 0),i.listTools)try{let f=await i.listTools();n.set(f.tools)}catch(f){a(f)}if(i.listResources)try{let f=await i.listResources();s.set(f.resources)}catch(f){a(f)}}function l(f){let r=`${e}:${f}`,c=k(void 0,{name:`${r}.result`}),d=k("idle",{name:`${r}.status`}),h=k(void 0,{name:`${r}.error`}),M=k(void 0,{name:`${r}.lastArgs`}),N=k(void 0,{name:`${r}.duration`}),z=!1;async function pe(j){if(z)return;z=!0,I(()=>{M.set(j),h.set(void 0),d.set("active")});let F=Date.now();try{let w=await i.callTool({name:f,arguments:j}),K=Date.now()-F;if(w.isError){let b=w.content.filter(J=>J.type==="text").map(J=>J.text??"").join(`
5
- `),he=new Error(b||"MCP tool returned error");I(()=>{N.set(K),h.set(he),d.set("errored")});return}let V=w.content.filter(b=>b.type==="text"),P;if(V.length===1){let b=V[0].text;if(b!==void 0)try{P=JSON.parse(b)}catch{P=b}}else V.length>1?P=V.map(b=>b.text??""):P=w.content;I(()=>{N.set(K),c.set(P),d.set("completed")})}catch(w){let K=Date.now()-F;I(()=>{N.set(K),h.set(w),d.set("errored")})}finally{z=!1}}return{get:()=>c.get(),source:(j,F)=>c.source(j,F),status:d,error:h,call:pe,lastArgs:M,duration:N}}return{tool:l,tools:n,resources:s,refresh:u,refreshError:o}}0&&(module.exports={fromMCP});
1
+ "use strict";var X=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var ve=Object.prototype.hasOwnProperty;var Ee=(e,t)=>{for(var r in t)X(e,r,{get:t[r],enumerable:!0})},De=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of be(t))!ve.call(e,s)&&s!==r&&X(e,s,{get:()=>t[s],enumerable:!(n=ye(t,s))||n.enumerable});return e};var ke=e=>De(X({},"__esModule",{value:!0}),e);var je={};Ee(je,{fromMCP:()=>Ne});module.exports=ke(je);var b=Symbol("DIRTY"),O=Symbol("RESOLVED"),re=Symbol("SINGLE_DEP"),B=Symbol("RESET"),xe=Symbol("PAUSE"),Re=Symbol("RESUME"),te=Symbol("TEARDOWN");function ie(e){return e===B||e===xe||e===Re||e===te}var oe=0,ae=1,ue=2,le=3,ce=4,fe=5,D=7,ne=7<<D,we=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function de(e){return we[(e&ne)>>>D]}var T=0,m=1,g=2,S=3,Y=0,U=[],ee=!1;function C(e){Y++;try{return e()}finally{if(Y--,Y===0&&!ee){ee=!0;for(let t=0;t<U.length;t++)U[t]();U.length=0,ee=!1}}}function w(){return Y>0}function H(e){U.push(e)}var Ae=0,Ie=[];function ge(e){Ae>0?Ie.push(e):e()}var A=class e{static _names=new WeakMap;static _kinds=new WeakMap;static _keys=new WeakMap;static _stores=new Set;static _edges=new Map;static _nextId=0;static _usedKeys=new Set;static _explicitEnabled=null;static _cachedDefault=null;static _annotations=new WeakMap;static _traceLog=[];static _traceHead=0;static _traceFull=!1;static maxTraceEntries=1e3;static get enabled(){if(e._explicitEnabled!==null)return e._explicitEnabled;if(e._cachedDefault!==null)return e._cachedDefault;try{e._cachedDefault=globalThis.process?.env?.NODE_ENV!=="production"}catch{e._cachedDefault=!0}return e._cachedDefault}static set enabled(t){e._explicitEnabled=t}static _depSuffix(t){if(!t?.length)return;let n=t.map(s=>e._names.get(s)??"?").join(",");return n.length>40?`${n.slice(0,37)}...`:n}static _resolveKey(t){let r=e._keys.get(t)??e._names.get(t);if(r)return r;let n=`anonymous_${e._nextId++}`;return e._keys.set(t,n),n}static register(t,r){if(!e.enabled)return;r?.name&&e._names.set(t,r.name),r?.kind&&e._kinds.set(t,r.kind);let n=e._nextId++,s=r?.name;if(!(s&&!e._usedKeys.has(s)))if(s){let i=e._depSuffix(r?.deps);s=i?`${s}(${i})`:`${s}_${n}`,e._usedKeys.has(s)&&(s=`${s}_${n}`)}else{let i=r?.kind??"store",a=e._depSuffix(r?.deps);s=a?`${i}(${a})`:`${i}_${n}`,e._usedKeys.has(s)&&(s=`${s}_${n}`)}e._usedKeys.add(s),e._keys.set(t,s),e._stores.add(new WeakRef(t))}static registerEdge(t,r){if(!e.enabled)return;let n=e._resolveKey(t),s=e._resolveKey(r),i=e._edges.get(n);i?i.includes(s)||i.push(s):e._edges.set(n,[s])}static getEdges(){return new Map(e._edges)}static getName(t){if(e.enabled)return e._names.get(t)}static getKind(t){return e._kinds.get(t)}static inspect(t){return{name:e._names.get(t),kind:e._kinds.get(t)??"unknown",value:typeof t.get=="function"?t.get():void 0,status:t._status}}static graph(){let t=new Map,r=new Set;for(let n of e._stores){let s=n.deref();if(!s){e._stores.delete(n);continue}let i=e._resolveKey(s);r.add(i),t.set(i,e.inspect(s))}for(let[n,s]of e._edges){if(!r.has(n)){e._edges.delete(n),e._usedKeys.delete(n);continue}let i=s.filter(a=>r.has(a));i.length===0?e._edges.delete(n):i.length!==s.length&&e._edges.set(n,i)}return t}static trace(t,r){let n=null,s=t.get();return t.source(T,(i,a)=>{if(i===T&&(n=a),i===g){n=null;return}if(i===1){let u=a;if(!Object.is(u,s)){let l=s;s=u,r(u,l)}}}),()=>n?.(g)}static dumpGraph(){let t=e.graph(),r=e.getEdges(),n=new Map;for(let[a,u]of r)for(let l of u){let c=n.get(l);c?c.includes(a)||c.push(a):n.set(l,[a])}let s=[];for(let[a,u]of t){let l=n.get(a),c=r.get(a),o=l?.length?` \u2190 [${l.join(", ")}]`:"",f=c?.length?` \u2192 [${c.join(", ")}]`:"";s.push(` ${a} (${u.kind}) = ${JSON.stringify(u.value)} [${u.status??"?"}]${o}${f}`)}return[`Store Graph (${t.size} nodes):`,...s].join(`
2
+ `)}static _signalLabel(t){return t===b?"DIRTY":t===O?"RESOLVED":typeof t=="symbol"?t.description??String(t):String(t)}static _observe(t,r,n){let s=null,i=!1,a=r??e.getName(t),u=[],l={values:[],signals:[],events:[],ended:!1,endError:void 0,get completedCleanly(){return l.ended&&!i},get errored(){return l.ended&&i},dirtyCount:0,resolvedCount:0,name:a,get eventLog(){return u},dispose:()=>s?.(g),reconnect:()=>(s?.(g),e._observe(t,r,n))};return t.source(T,(c,o)=>{if(c===T){s=o;return}let f=w();c===m?(l.values.push(o),l.events.push({type:"data",data:o,inBatch:f}),u.push(o),n&&n(`[${a}] DATA:`,o)):c===S?(l.signals.push(o),l.events.push({type:"signal",data:o,inBatch:f}),u.push(e._signalLabel(o)),o===b?l.dirtyCount++:o===O&&l.resolvedCount++,n&&n(`[${a}] STATE:`,o)):c===g&&(l.ended=!0,l.endError=o,i=o!==void 0,l.events.push({type:"end",data:o,inBatch:f}),u.push(i?["END",o]:"END"),n&&n(`[${a}] END`,o!==void 0?o:""),s=null)}),l}static observe(t){return e._observe(t)}static activate(t){let r=null;return t.source(T,(n,s)=>{n===T&&(r=s),n===g&&(r=null)}),()=>r?.(g)}static tap(t,r){let n=r??`tap(${e.getName(t)??"anon"})`,s={get:()=>t.get(),source:t.source};return e.register(s,{name:n,kind:"tap"}),e.registerEdge(t,s),s}static spy(t,r){let n=r?.name??e.getName(t)??"spy",s=r?.log??console.log;return e._observe(t,n,s)}static snapshot(){let t=e.graph(),r=e.getEdges(),n=new Map;for(let a of e._stores){let u=a.deref();if(!u)continue;let l=e._annotations.get(u);l!==void 0&&n.set(e._resolveKey(u),l)}let s=[];for(let[a,u]of t){let l={name:a,kind:u.kind,value:u.value,status:u.status},c=n.get(a);c!==void 0&&(l.annotation=c),s.push(l)}let i=[];for(let[a,u]of r)for(let l of u)i.push({from:a,to:l});return{nodes:s,edges:i,trace:e.traceLog()}}static toMermaid(t){let r=t?.direction??"TD",n=e.snapshot(),s=[`graph ${r}`],i={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},a=new Map;function u(o){let f=o.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(f);return d===void 0?(a.set(f,1),f):(a.set(f,d+1),`${f}__${d}`)}let l=new Map;function c(o){let f=JSON.stringify(o);return f&&f.length>30?`${f.slice(0,27)}...`:f??"undefined"}for(let o of n.nodes){let f=u(o.name);l.set(o.name,f);let d=`${o.name} (${o.kind}) = ${c(o.value)}`,h=i[o.status??""]??"";s.push(` ${f}["${d}"]${h}`)}for(let o of n.edges){let f=l.get(o.from)??u(o.from),d=l.get(o.to)??u(o.to);s.push(` ${f} --> ${d}`)}return s.push(""),s.push(" classDef settled fill:#d4edda,stroke:#28a745"),s.push(" classDef dirty fill:#fff3cd,stroke:#ffc107"),s.push(" classDef errored fill:#f8d7da,stroke:#dc3545"),s.push(" classDef completed fill:#cce5ff,stroke:#007bff"),s.join(`
3
+ `)}static toD2(t){let r=t?.direction??"down",n=e.snapshot(),s=[`direction: ${r}`,""],i={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},a=new Map;function u(o){let f=o.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(f);return d===void 0?(a.set(f,1),f):(a.set(f,d+1),`${f}__${d}`)}let l=new Map;function c(o){let f=JSON.stringify(o);return f&&f.length>30?`${f.slice(0,27)}...`:f??"undefined"}for(let o of n.nodes){let f=u(o.name);l.set(o.name,f);let d=i[o.kind]??"rectangle",h=`${o.name} (${o.kind}) = ${c(o.value)}`,M=o.status?` [${o.status}]`:"";s.push(`${f}: "${h}${M}" { shape: ${d} }`)}n.edges.length>0&&s.push("");for(let o of n.edges){let f=l.get(o.from)??u(o.from),d=l.get(o.to)??u(o.to);s.push(`${f} -> ${d}`)}return s.join(`
4
+ `)}static annotate(t,r){if(!e.enabled)return;e._annotations.set(t,r);let n={node:e._resolveKey(t),reason:r,timestamp:Date.now()},s=e.maxTraceEntries;s<=0||(e._traceLog.length<s?e._traceLog.push(n):(e._traceLog[e._traceHead]=n,e._traceFull=!0),e._traceHead=(e._traceHead+1)%s)}static getAnnotation(t){return e._annotations.get(t)}static traceLog(){return e._traceFull?[...e._traceLog.slice(e._traceHead),...e._traceLog.slice(0,e._traceHead)]:e._traceLog.slice(0,e._traceHead||e._traceLog.length)}static clearTrace(){e._traceLog=[],e._traceHead=0,e._traceFull=!1}static timeline(t){let r=null,n=[];return t.source(T,(s,i)=>{if(s===T){r=i;return}let a={timestamp:Date.now(),type:s===m?"data":s===S?"signal":"end",data:i,inBatch:w()};n.push(a),s===g&&(r=null)}),{entries:n,dispose:()=>r?.(g)}}static observeDerived(t){let r=[],n=t,s=n._fn;if(typeof s!="function"||!Array.isArray(n._deps))return{...e.observe(t),evaluations:r};n._fn=()=>{let l=n._deps.map(o=>o.get()),c=s();return r.push({result:c,depValues:l,timestamp:Date.now()}),c};let i=e._observe(t),a=i.dispose;return{...i,evaluations:r,dispose:()=>{n._fn=s,a()},reconnect:()=>(n._fn=s,a(),e.observeDerived(t))}}static observeTaskState(t){let r=t.status.get(),n=[],s=null;return t.status.source(T,(i,a)=>{if(i===T){s=a;return}if(i===m){let u=a;if(u!==r){let l={from:r,to:u,timestamp:Date.now()};u==="error"&&(l.error=t.error.get()),n.push(l),r=u}}i===g&&(s=null)}),{transitions:n,get currentStatus(){return t.status.get()},dispose:()=>{s?.(g)}}}static causalityTrace(t){let r=[],n=t,s=n._fn;if(typeof s!="function"||!Array.isArray(n._deps))return{...e.observe(t),causality:r};let i=n._deps,a=i.map(o=>o.get());n._fn=()=>{let o=i.map(h=>h.get()),f=s(),d=-1;for(let h=0;h<i.length;h++)if(!Object.is(o[h],a[h])){d=h;break}return r.push({result:f,triggerDepIndex:d,triggerDepName:d>=0?e.getName(i[d]):void 0,depValues:o,timestamp:Date.now()}),a=o,f};let u=e._observe(t),l=u.dispose;return{...u,causality:r,dispose:()=>{n._fn=s,l()},reconnect:()=>(n._fn=s,l(),e.causalityTrace(t))}}static _reset(){e._names=new WeakMap,e._kinds=new WeakMap,e._keys=new WeakMap,e._stores=new Set,e._edges=new Map,e._usedKeys=new Set,e._nextId=0,e._explicitEnabled=null,e._cachedDefault=null,e._annotations=new WeakMap,e._traceLog=[],e._traceHead=0,e._traceFull=!1,e.maxTraceEntries=1e3}};var q=1,y=64,_=2,I=4,pe=8,he=16,x=32,v=1024,p=ne,L=ae<<D,$=ue<<D,G=oe<<D,Le=ce<<D,Pe=fe<<D,Oe=le<<D,z=class{_value;_output=null;_flags;get _status(){return de(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;_onLifecycleSignal;constructor(t,r){this._value=r?.initial,this._fn=t,this._eqFn=r?.equals,this._getterFn=r?.getter,this._initial=r?.initial;let n=0;r?.autoDirty!==!1&&(n|=I),r?.resetOnTeardown&&(n|=pe),r?.resubscribable&&(n|=he),this._flags=n,this.source=this.source.bind(this),this.emit=this.emit.bind(this),r?._skipInspect||A.register(this,{kind:"producer",...r})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,r){let n=this._output;if(n)if(this._flags&y)for(let s of n)s(t,r);else n(t,r)}emit(t){this._flags&_||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(w()?this._flags&x||(this._flags|=x,this._flags&I&&(this._flags=this._flags&~p|L,this._dispatch(S,b)),H(()=>{this._flags&=~x,this._flags=this._flags&~p|$,this._dispatch(m,this._value)})):(this._flags&I&&!(this._flags&v)&&(this._flags=this._flags&~p|L,this._dispatch(S,b)),this._flags=this._flags&~p|$,this._dispatch(m,this._value))))}signal(t){this._flags&_||!this._output||(t===b?this._flags=this._flags&~p|L:t===O&&(this._flags=this._flags&~p|Oe),this._dispatch(S,t))}complete(){if(this._flags&_)return;this._flags=(this._flags|_)&~p|Le;let t=this._output,r=this._flags&y;if(this._output=null,this._flags&=~(y|v),this._singleDepCount=0,this._stop(),t)if(r)for(let n of t)n(g);else t(g)}error(t){if(this._flags&_)return;this._flags=(this._flags|_)&~p|Pe;let r=this._output,n=this._flags&y;if(this._output=null,this._flags&=~(y|v),this._singleDepCount=0,this._stop(),r)if(n)for(let s of r)s(g,t);else r(g,t)}_start(){if(this._flags&q||!this._fn)return;this._flags|=q,this._onLifecycleSignal=void 0;let t=this._fn({emit:this.emit,signal:r=>this.signal(r),complete:()=>this.complete(),error:r=>this.error(r),onSignal:r=>{this._onLifecycleSignal=r}});this._cleanup=typeof t=="function"?t:void 0}_stop(){this._flags&q&&(this._flags&=~q,this._onLifecycleSignal=void 0,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&pe&&(this._value=this._initial),this._flags&_||(this._flags=this._flags&~p|G))}_handleLifecycleSignal(t){if(!(this._flags&_)){if(t===te){this._onLifecycleSignal?.(t),this.complete();return}t===B&&(this._value=this._initial,this._flags&=~x),this._onLifecycleSignal?.(t),t===B&&this.emit(this._initial)}}source(t,r){if(t===T){let n=r;if(this._flags&_)if(this._flags&he&&this._output===null)this._flags=this._flags&~(_|p)|G;else{n(T,i=>{}),n(g);return}if(this._output===null)this._output=n;else if(this._flags&y)this._output.add(n);else{let i=new Set;i.add(this._output),i.add(n),this._output=i,this._flags=(this._flags|y)&~v}let s=!1;n(T,(i,a)=>{if(i===m&&n(m,this._value),i===S){a===re&&!s?(s=!0,this._singleDepCount++,this._flags&y||(this._flags|=v)):ie(a)&&this._handleLifecycleSignal(a);return}if(i===g){if(s&&(s=!1,this._singleDepCount--),this._output===null)return;if(this._flags&y){let u=this._output;u.delete(n),u.size===1?(this._output=u.values().next().value,this._flags&=~y,this._singleDepCount>0&&(this._flags|=v)):u.size===0&&(this._output=null,this._flags&=~(y|v),this._singleDepCount=0,this._flags=this._flags&~p|G,this._stop())}else this._output===n&&(this._output=null,this._flags&=~v,this._singleDepCount=0,this._flags=this._flags&~p|G,this._stop())}}),ge(()=>this._start())}}};var se=class extends z{constructor(t,r){super(void 0,{initial:t,autoDirty:!0,equals:r?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),A.register(this,{kind:"state",...r})}get(){return this._value}set(t){this._flags&_||this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(w()?this._flags&x||(this._flags|=x,this._flags&I&&(this._flags=this._flags&~p|L,this._dispatch(S,b)),H(()=>{this._flags&=~x,this._flags=this._flags&~p|$,this._dispatch(m,this._value)})):(this._flags&I&&!(this._flags&v)&&(this._flags=this._flags&~p|L,this._dispatch(S,b)),this._flags=this._flags&~p|$,this._dispatch(m,this._value))))}update(t){this.set(t(this._value))}};function k(e,t){return new se(e,t)}function Te(e){return(t,r)=>{if(t!==0)return;let n=new AbortController,s=n.signal,i=!1,a,u;try{a=typeof e=="function"?e():e,u=a[Symbol.asyncIterator]()}catch(c){r(0,()=>{}),r(2,c);return}r(0,c=>{c===2&&!i&&(i=!0,n.abort(),Promise.resolve(u.return?.()).catch(()=>{}))});async function l(){try{for(;!i&&!s.aborted;){let c=await u.next();if(i||s.aborted)break;if(c.done){i=!0,r(2);return}r(1,c.value)}}catch(c){!i&&!s.aborted&&(i=!0,r(2,c))}}l()}}function me(e){return(t,r)=>{if(t!==0)return;let n=!1;r(0,s=>{s===2&&(n=!0)}),e.then(s=>{n||(r(1,s),n||r(2))},s=>{n||r(2,s)})}}function Ce(e){return e!=null&&typeof e.then=="function"}function $e(e){return e!=null&&typeof e[Symbol.asyncIterator]=="function"}function Me(e){return e!=null&&typeof e[Symbol.iterator]=="function"}function J(e){return Ce(e)?me(e):$e(e)?Te(e):typeof e!="string"&&Me(e)?(t,r)=>{if(t!==0)return;let n=!1;r(0,s=>{s===2&&(n=!0)});for(let s of e){if(n)return;r(1,s)}n||r(2)}:(t,r)=>{if(t!==0)return;let n=!1;r(0,s=>{s===2&&(n=!0)}),n||r(1,e),n||r(2)}}function Z(e,t,r){let n=null;return e(0,(s,i)=>{if(s===0){n=i;return}if(s===2){n=null,r?.onEnd?.(i);return}s===1&&t(i)}),{unsubscribe(){n?.(2),n=null}}}function Ne(e){let t=e.name??"mcp",r=e.client,n=k([],{name:`${t}.tools`}),s=k([],{name:`${t}.resources`}),i=k(void 0,{name:`${t}.refreshError`});function a(c){i.set(c);let o=e.onRefreshError;if(o==="warn")console.warn(`[${t}] refresh error:`,c);else{if(o==="error")throw c;typeof o=="function"&&o(c)}}function u(){i.set(void 0),r.listTools&&Z(J(r.listTools()),c=>{n.set(c.tools)},{onEnd:c=>{c!==void 0&&a(c)}}),r.listResources&&Z(J(r.listResources()),c=>{s.set(c.resources)},{onEnd:c=>{c!==void 0&&a(c)}})}function l(c){let o=`${t}:${c}`,f=k(void 0,{name:`${o}.result`}),d=k("idle",{name:`${o}.status`}),h=k(void 0,{name:`${o}.error`}),M=k(void 0,{name:`${o}.lastArgs`}),N=k(void 0,{name:`${o}.duration`}),j=!1;function _e(F){if(j)return;j=!0,C(()=>{M.set(F),h.set(void 0),d.set("active")});let K=Date.now();Z(J(r.callTool({name:c,arguments:F})),R=>{j=!1;let V=Date.now()-K;if(R.isError){let E=R.content.filter(Q=>Q.type==="text").map(Q=>Q.text??"").join(`
5
+ `),Se=new Error(E||"MCP tool returned error");C(()=>{N.set(V),h.set(Se),d.set("errored")});return}let W=R.content.filter(E=>E.type==="text"),P;if(W.length===1){let E=W[0].text;if(E!==void 0)try{P=JSON.parse(E)}catch{P=E}}else W.length>1?P=W.map(E=>E.text??""):P=R.content;C(()=>{N.set(V),f.set(P),d.set("completed")})},{onEnd:R=>{if(j=!1,R===void 0)return;let V=Date.now()-K;C(()=>{N.set(V),h.set(R),d.set("errored")})}})}return{get:()=>f.get(),source:(F,K)=>f.source(F,K),status:d,error:h,call:_e,lastArgs:M,duration:N}}return{tool:l,tools:n,resources:s,refresh:u,refreshError:i}}0&&(module.exports={fromMCP});
@@ -53,8 +53,8 @@ interface MCPToolStore<TArgs = Record<string, unknown>, TResult = unknown> exten
53
53
  status: Store<WithStatusStatus>;
54
54
  /** Last error, if any. */
55
55
  error: Store<unknown | undefined>;
56
- /** Call the tool with arguments. */
57
- call: (args: TArgs) => Promise<void>;
56
+ /** Call the tool with arguments. Results tracked via stores. */
57
+ call: (args: TArgs) => void;
58
58
  /** Last arguments passed to call(). */
59
59
  lastArgs: Store<TArgs | undefined>;
60
60
  /** Duration of last call in ms. */
@@ -75,8 +75,8 @@ interface MCPResult {
75
75
  tools: Store<MCPToolInfo[]>;
76
76
  /** Available resources (populated after refresh). */
77
77
  resources: Store<MCPResource[]>;
78
- /** Refresh the tools and resources lists. */
79
- refresh: () => Promise<void>;
78
+ /** Refresh the tools and resources lists. Results tracked via stores. */
79
+ refresh: () => void;
80
80
  /** Last refresh error, if any. */
81
81
  refreshError: Store<unknown | undefined>;
82
82
  }
@@ -53,8 +53,8 @@ interface MCPToolStore<TArgs = Record<string, unknown>, TResult = unknown> exten
53
53
  status: Store<WithStatusStatus>;
54
54
  /** Last error, if any. */
55
55
  error: Store<unknown | undefined>;
56
- /** Call the tool with arguments. */
57
- call: (args: TArgs) => Promise<void>;
56
+ /** Call the tool with arguments. Results tracked via stores. */
57
+ call: (args: TArgs) => void;
58
58
  /** Last arguments passed to call(). */
59
59
  lastArgs: Store<TArgs | undefined>;
60
60
  /** Duration of last call in ms. */
@@ -75,8 +75,8 @@ interface MCPResult {
75
75
  tools: Store<MCPToolInfo[]>;
76
76
  /** Available resources (populated after refresh). */
77
77
  resources: Store<MCPResource[]>;
78
- /** Refresh the tools and resources lists. */
79
- refresh: () => Promise<void>;
78
+ /** Refresh the tools and resources lists. Results tracked via stores. */
79
+ refresh: () => void;
80
80
  /** Last refresh error, if any. */
81
81
  refreshError: Store<unknown | undefined>;
82
82
  }
@@ -1 +1 @@
1
- import{a}from"../chunk-Q5DHO5II.js";import"../chunk-EAK2HKAD.js";import"../chunk-2F6QWERG.js";import"../chunk-2L6223KN.js";import"../chunk-TUPD47IE.js";import"../chunk-I7AUKTXE.js";export{a as fromMCP};
1
+ import{a}from"../chunk-6WZQIJIW.js";import"../chunk-O2PONDZT.js";import"../chunk-J2E7GAMR.js";import"../chunk-4ILN4V4C.js";import"../chunk-Q3HIBGHR.js";import"../chunk-EAK2HKAD.js";import"../chunk-2F6QWERG.js";import"../chunk-2L6223KN.js";import"../chunk-TUPD47IE.js";import"../chunk-I7AUKTXE.js";export{a as fromMCP};