@callbag-recharge/callbag-recharge 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/http.cjs +4 -4
- package/dist/adapters/http.js +1 -1
- package/dist/adapters/index.cjs +11 -11
- package/dist/adapters/index.d.cts +1 -0
- package/dist/adapters/index.d.ts +1 -0
- package/dist/adapters/index.js +1 -1
- package/dist/adapters/mcp.cjs +5 -5
- package/dist/adapters/mcp.d.cts +4 -4
- package/dist/adapters/mcp.d.ts +4 -4
- package/dist/adapters/mcp.js +1 -1
- package/dist/adapters/sse.cjs +10 -10
- package/dist/adapters/sse.d.cts +3 -2
- package/dist/adapters/sse.d.ts +3 -2
- package/dist/adapters/sse.js +1 -1
- package/dist/adapters/webhook.cjs +4 -4
- package/dist/adapters/webhook.d.cts +3 -2
- package/dist/adapters/webhook.d.ts +3 -2
- package/dist/adapters/webhook.js +1 -1
- package/dist/ai/agentLoop/index.cjs +4 -4
- package/dist/ai/agentLoop/index.js +1 -1
- package/dist/ai/chatStream/index.cjs +4 -4
- package/dist/ai/chatStream/index.d.cts +4 -3
- package/dist/ai/chatStream/index.d.ts +4 -3
- package/dist/ai/chatStream/index.js +1 -1
- package/dist/ai/conversationSummary/index.d.cts +2 -1
- package/dist/ai/conversationSummary/index.d.ts +2 -1
- package/dist/ai/docIndex/index.cjs +4 -4
- package/dist/ai/docIndex/index.js +1 -1
- package/dist/ai/embeddingIndex/index.cjs +4 -4
- package/dist/ai/embeddingIndex/index.js +1 -1
- package/dist/ai/fromLLM.cjs +5 -5
- package/dist/ai/fromLLM.d.cts +60 -12
- package/dist/ai/fromLLM.d.ts +60 -12
- package/dist/ai/fromLLM.js +1 -1
- package/dist/ai/index.cjs +43 -14
- package/dist/ai/index.d.cts +494 -9
- package/dist/ai/index.d.ts +494 -9
- package/dist/ai/index.js +30 -1
- package/dist/ai/memoryStore/index.cjs +3 -3
- package/dist/ai/memoryStore/index.d.cts +1 -1
- package/dist/ai/memoryStore/index.d.ts +1 -1
- package/dist/ai/memoryStore/index.js +1 -1
- package/dist/ai/ragPipeline/index.cjs +1 -1
- package/dist/ai/ragPipeline/index.d.cts +1 -1
- package/dist/ai/ragPipeline/index.d.ts +1 -1
- package/dist/ai/ragPipeline/index.js +1 -1
- package/dist/ai/toolCallState/index.cjs +4 -4
- package/dist/ai/toolCallState/index.d.cts +1 -1
- package/dist/ai/toolCallState/index.d.ts +1 -1
- package/dist/ai/toolCallState/index.js +1 -1
- package/dist/{checkpoint-Bycg2nWZ.d.ts → checkpoint-CC4tKs36.d.ts} +7 -6
- package/dist/{checkpoint-pDVUAV4-.d.cts → checkpoint-uaYS0fN4.d.cts} +7 -6
- package/dist/chunk-2DNXE5W2.js +1 -0
- package/dist/chunk-3ORARRVS.js +1 -0
- package/dist/chunk-4PAUY5AJ.js +1 -0
- package/dist/chunk-565W67EU.js +11 -0
- package/dist/chunk-5UIA6BIQ.js +1 -0
- package/dist/chunk-6WZQIJIW.js +2 -0
- package/dist/chunk-AA2V6B63.js +1 -0
- package/dist/chunk-BBWZHYCT.js +1 -0
- package/dist/chunk-CDEQNFFU.js +1 -0
- package/dist/chunk-DTTBQCH3.js +1 -0
- package/dist/chunk-DTYSGTF4.js +1 -0
- package/dist/chunk-FJ2VN2O3.js +1 -0
- package/dist/chunk-FJMF46AF.js +1 -0
- package/dist/chunk-IB56FLRE.js +1 -0
- package/dist/chunk-J2E7GAMR.js +1 -0
- package/dist/chunk-LMR6RVT4.js +1 -0
- package/dist/chunk-O2PONDZT.js +1 -0
- package/dist/chunk-QAHR7EMX.js +2 -0
- package/dist/{chunk-2PBFMNE3.js → chunk-S67PXKAL.js} +1 -1
- package/dist/chunk-VHVYJSLE.js +1 -0
- package/dist/chunk-X2LL44CL.js +1 -0
- package/dist/chunk-XD4BHZSL.js +1 -0
- package/dist/chunk-Y72LPOTS.js +1 -0
- package/dist/chunk-YCYCWSXF.js +1 -0
- package/dist/{chunk-K56FIBDL.js → chunk-Z6NJHBGT.js} +1 -1
- package/dist/data/index.js +1 -1
- package/dist/{executionLog-CREljpYk.d.cts → executionLog-BIdo4sqy.d.cts} +7 -6
- package/dist/{executionLog-cGvVp5Ha.d.ts → executionLog-EPbLbbSd.d.ts} +7 -6
- package/dist/extra/fromPromise.js +1 -1
- package/dist/extra/index.cjs +1 -1
- package/dist/extra/index.d.cts +2 -1
- package/dist/extra/index.d.ts +2 -1
- package/dist/extra/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/memory/index.cjs +1 -1
- package/dist/memory/index.d.cts +2 -2
- package/dist/memory/index.d.ts +2 -2
- package/dist/memory/index.js +1 -1
- package/dist/messaging/index.cjs +6 -6
- package/dist/messaging/index.d.cts +8 -297
- package/dist/messaging/index.d.ts +8 -297
- package/dist/messaging/index.js +3 -3
- package/dist/orchestrate/executionLogAdapters.node.cjs +6 -6
- package/dist/orchestrate/executionLogAdapters.node.d.cts +3 -2
- package/dist/orchestrate/executionLogAdapters.node.d.ts +3 -2
- package/dist/orchestrate/executionLogAdapters.node.js +3 -3
- package/dist/orchestrate/index.cjs +6 -6
- package/dist/orchestrate/index.d.cts +14 -10
- package/dist/orchestrate/index.d.ts +14 -10
- package/dist/orchestrate/index.js +3 -3
- package/dist/patterns/pagination/index.cjs +4 -4
- package/dist/patterns/pagination/index.js +1 -1
- package/dist/patterns/textEditor/index.cjs +15 -15
- package/dist/patterns/textEditor/index.d.cts +5 -3
- package/dist/patterns/textEditor/index.d.ts +5 -3
- package/dist/patterns/textEditor/index.js +7 -7
- package/dist/{rateLimiter-DMeuSBxF.d.ts → rateLimiter-C9FDu1n0.d.cts} +4 -2
- package/dist/{rateLimiter-DMeuSBxF.d.cts → rateLimiter-nMWFRXZi.d.ts} +4 -2
- package/dist/subscribe-BHH8VVDm.d.cts +4 -0
- package/dist/subscribe-BHH8VVDm.d.ts +4 -0
- package/dist/{tokenTracker-BYan5lb-.d.ts → tokenTracker-BRFP4C1K.d.ts} +2 -2
- package/dist/{tokenTracker-DGkjfZtH.d.cts → tokenTracker-C1y5zB38.d.cts} +2 -2
- package/dist/types-CJKW4Ae9.d.ts +298 -0
- package/dist/{types-DtkjWIED.d.ts → types-ClmMSIr-.d.ts} +7 -1
- package/dist/{types-BwBbIZux.d.cts → types-DbCdOVbw.d.cts} +7 -1
- package/dist/types-XRfOHCPC.d.cts +298 -0
- package/dist/utils/checkpointAdapters.node.cjs +1 -1
- package/dist/utils/checkpointAdapters.node.d.cts +3 -2
- package/dist/utils/checkpointAdapters.node.d.ts +3 -2
- package/dist/utils/checkpointAdapters.node.js +1 -1
- package/dist/utils/index.cjs +9 -9
- package/dist/utils/index.d.cts +28 -30
- package/dist/utils/index.d.ts +28 -30
- package/dist/utils/index.js +6 -6
- package/package.json +6 -2
- package/dist/chunk-4AGPQIMR.js +0 -1
- package/dist/chunk-4VPAGOLZ.js +0 -1
- package/dist/chunk-7B4DHRG6.js +0 -1
- package/dist/chunk-7LEA46F2.js +0 -1
- package/dist/chunk-EPTXIJMZ.js +0 -1
- package/dist/chunk-F5EXEEZL.js +0 -1
- package/dist/chunk-GGTHKVOX.js +0 -1
- package/dist/chunk-GMHR7NSQ.js +0 -1
- package/dist/chunk-I3EB4ACM.js +0 -1
- package/dist/chunk-LCCRCFKU.js +0 -1
- package/dist/chunk-LJ4NZDHS.js +0 -1
- package/dist/chunk-OLSVNROW.js +0 -1
- package/dist/chunk-PLIRVTP4.js +0 -11
- package/dist/chunk-Q5DHO5II.js +0 -2
- package/dist/chunk-RC3JWVKF.js +0 -1
- package/dist/chunk-USLFDJX2.js +0 -1
- package/dist/chunk-VESAQ43T.js +0 -2
- package/dist/chunk-WQAE4SFB.js +0 -1
- package/dist/chunk-YOXJZ2O5.js +0 -1
- package/dist/chunk-ZDGVUX5G.js +0 -1
package/dist/adapters/http.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var te=Object.defineProperty;var
|
|
2
|
-
`)}static _signalLabel(
|
|
3
|
-
`)}static toD2(
|
|
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});
|
package/dist/adapters/http.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
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};
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)}static _signalLabel(
|
|
3
|
-
`)}static toD2(
|
|
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
|
-
`),
|
|
6
|
-
data: ${
|
|
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
|
|
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
|
-
`),
|
|
11
|
-
data: ${
|
|
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(
|
|
13
|
+
`)}}catch{}if(i>0){let v=setInterval(()=>{try{p.write(`:ping
|
|
14
14
|
|
|
15
|
-
`)}catch{m(
|
|
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});
|
package/dist/adapters/index.d.ts
CHANGED
package/dist/adapters/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"../chunk-
|
|
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};
|
package/dist/adapters/mcp.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)}static _signalLabel(
|
|
3
|
-
`)}static toD2(
|
|
4
|
-
`)}static annotate(
|
|
5
|
-
`),
|
|
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});
|
package/dist/adapters/mcp.d.cts
CHANGED
|
@@ -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) =>
|
|
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: () =>
|
|
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
|
}
|
package/dist/adapters/mcp.d.ts
CHANGED
|
@@ -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) =>
|
|
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: () =>
|
|
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
|
}
|
package/dist/adapters/mcp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
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};
|