@callbag-recharge/callbag-recharge 0.14.0 → 0.16.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 +10 -10
- package/dist/adapters/index.js +1 -1
- package/dist/adapters/llm.cjs +5 -5
- package/dist/adapters/llm.js +1 -1
- package/dist/adapters/mcp.cjs +5 -5
- package/dist/adapters/mcp.js +1 -1
- package/dist/adapters/sse.cjs +8 -8
- package/dist/adapters/sse.js +1 -1
- package/dist/adapters/webhook.cjs +4 -4
- package/dist/adapters/webhook.js +1 -1
- package/dist/adapters/websocket.cjs +4 -4
- package/dist/adapters/websocket.js +1 -1
- package/dist/backoff-BXsH2Ago.d.cts +25 -0
- package/dist/backoff-BXsH2Ago.d.ts +25 -0
- package/dist/checkpoint-Bycg2nWZ.d.ts +70 -0
- package/dist/checkpoint-pDVUAV4-.d.cts +70 -0
- package/dist/{chunk-HDPUS5OO.js → chunk-2IUCXBY7.js} +1 -1
- package/dist/{chunk-F4CU5CTA.js → chunk-2JMVH3GO.js} +1 -1
- package/dist/{chunk-EE6I3ASX.js → chunk-44EYVDK3.js} +1 -1
- package/dist/{chunk-T4VDAIVN.js → chunk-4KVPJXBF.js} +1 -1
- package/dist/{chunk-SVCEBPU2.js → chunk-4NQIEZ33.js} +1 -1
- package/dist/{chunk-VO7NNLTJ.js → chunk-4TVMJG2B.js} +1 -1
- package/dist/{chunk-CCB7OSCT.js → chunk-56MXCPRP.js} +1 -1
- package/dist/{chunk-O3PSGN2O.js → chunk-5ULT22VV.js} +1 -1
- package/dist/{chunk-SD5J4GZV.js → chunk-6OLBRXMG.js} +1 -1
- package/dist/chunk-6WXC33WR.js +1 -0
- package/dist/{chunk-WUG5FVJK.js → chunk-6X7HQUZI.js} +1 -1
- package/dist/{chunk-KYY5ZPIG.js → chunk-7FX2AO6N.js} +1 -1
- package/dist/{chunk-RQAJX7IG.js → chunk-7FZVRQD6.js} +1 -1
- package/dist/{chunk-I2PZF4K6.js → chunk-7XK265LH.js} +1 -1
- package/dist/{chunk-7IW7ADDI.js → chunk-AEY2TDOX.js} +1 -1
- package/dist/{chunk-HILO5AS5.js → chunk-BR63MTNP.js} +1 -1
- package/dist/{chunk-UY6CC6LO.js → chunk-CNOFRRHZ.js} +1 -1
- package/dist/{chunk-LXMAXJR5.js → chunk-CTSKV2CN.js} +1 -1
- package/dist/{chunk-LJNELNJP.js → chunk-CZBLKO6T.js} +1 -1
- package/dist/{chunk-UC4T2SXM.js → chunk-DQVIVUSC.js} +1 -1
- package/dist/{chunk-AQFWFFHP.js → chunk-DXSHVZHS.js} +1 -1
- package/dist/{chunk-BQOJYKJT.js → chunk-E4FSSIC6.js} +1 -1
- package/dist/{chunk-WWRDVOBH.js → chunk-EINLCORW.js} +1 -1
- package/dist/{chunk-NJEXVXD4.js → chunk-EXDWEL6X.js} +1 -1
- package/dist/{chunk-FCEJOYU4.js → chunk-FJYFNUBJ.js} +1 -1
- package/dist/{chunk-AJJTUL2L.js → chunk-FP4IGNQK.js} +1 -1
- package/dist/{chunk-6ZKDN5EW.js → chunk-GKPIYIW2.js} +1 -1
- package/dist/chunk-GO4JTIJI.js +1 -0
- package/dist/{chunk-UQTRJP46.js → chunk-GXBPIPK5.js} +1 -1
- package/dist/{chunk-N2NDQCQO.js → chunk-HIKTBIQS.js} +1 -1
- package/dist/{chunk-I3BXIZVS.js → chunk-HKKF37VH.js} +1 -1
- package/dist/{chunk-UZUDFSE5.js → chunk-HVBJTUBY.js} +1 -1
- package/dist/{chunk-ZOWERC3D.js → chunk-I54FHPCO.js} +1 -1
- package/dist/{chunk-ER32MJVM.js → chunk-IEGBHQQI.js} +1 -1
- package/dist/{chunk-6L3J4GGT.js → chunk-IMVCIYVC.js} +1 -1
- package/dist/{chunk-EGJGBVCR.js → chunk-INHXATTB.js} +1 -1
- package/dist/{chunk-BERYVZLY.js → chunk-JFJC5QME.js} +1 -1
- package/dist/chunk-JJ6PHYH4.js +1 -0
- package/dist/{chunk-6AITKURG.js → chunk-L3ZTIVH6.js} +1 -1
- package/dist/{chunk-R363TL2A.js → chunk-L4HKWJB7.js} +1 -1
- package/dist/{chunk-G7XILF6J.js → chunk-LN2UGCTK.js} +1 -1
- package/dist/{chunk-A3YLDNEZ.js → chunk-LYNZX3UN.js} +1 -1
- package/dist/{chunk-KQDEYS2F.js → chunk-LYOCP7L4.js} +1 -1
- package/dist/{chunk-7D7FHBCO.js → chunk-MENCMIG7.js} +1 -1
- package/dist/{chunk-O2MPU5AE.js → chunk-MGXREBEX.js} +1 -1
- package/dist/{chunk-LUIHMMPZ.js → chunk-NE372A6P.js} +1 -1
- package/dist/chunk-NEYVAVAH.js +1 -0
- package/dist/{chunk-C45X5AKN.js → chunk-NNNXS2D4.js} +1 -1
- package/dist/{chunk-XUYHR7J6.js → chunk-PFMEQCU6.js} +1 -1
- package/dist/{chunk-BO6RJZ2Z.js → chunk-QQG3L5XP.js} +1 -1
- package/dist/{chunk-UEV5KYZK.js → chunk-R3QYN4IJ.js} +1 -1
- package/dist/{chunk-ULFYO3TG.js → chunk-RTXA6LFA.js} +1 -1
- package/dist/{chunk-3AE6AS32.js → chunk-RWZ3CCF6.js} +1 -1
- package/dist/{chunk-CV6GBX5N.js → chunk-RX4JY356.js} +1 -1
- package/dist/{chunk-GWRUTGV5.js → chunk-S2U5T7BO.js} +1 -1
- package/dist/{chunk-UQF6RSKP.js → chunk-SG4NXKP5.js} +1 -1
- package/dist/chunk-SOIVZBGE.js +4 -0
- package/dist/chunk-T2RGZ54Y.js +1 -0
- package/dist/{chunk-O6DCBOUE.js → chunk-T6LJTPKW.js} +1 -1
- package/dist/{chunk-UMSWDYDW.js → chunk-TLGNAGQV.js} +1 -1
- package/dist/{chunk-FV76ERZO.js → chunk-U5WIJOXK.js} +1 -1
- package/dist/{chunk-D6NMIIMQ.js → chunk-UA3L7KUP.js} +1 -1
- package/dist/{chunk-ATMRBZH2.js → chunk-ULQ5NNM4.js} +1 -1
- package/dist/{chunk-GPHUNLET.js → chunk-UZFZ4IZM.js} +1 -1
- package/dist/chunk-VD74HJ6V.js +1 -0
- package/dist/{chunk-3CHC2PEC.js → chunk-VFN2CV32.js} +1 -1
- package/dist/{chunk-4CRFPOTP.js → chunk-VO4IUQZE.js} +1 -1
- package/dist/{chunk-KUPHN4EE.js → chunk-XQ2NZAPZ.js} +1 -1
- package/dist/{chunk-S7ZMYSVO.js → chunk-Y7KZXCQE.js} +1 -1
- package/dist/{chunk-FJNLQSK3.js → chunk-YEUF4R7R.js} +1 -1
- package/dist/{chunk-ODY2WVV5.js → chunk-ZPIHW4HI.js} +1 -1
- package/dist/chunk-ZWFSO5A4.js +1 -0
- package/dist/compat/jotai/index.cjs +4 -4
- package/dist/compat/jotai/index.js +1 -1
- package/dist/compat/nanostores/index.cjs +4 -4
- package/dist/compat/nanostores/index.js +1 -1
- package/dist/compat/signals/index.cjs +4 -4
- package/dist/compat/signals/index.js +1 -1
- package/dist/compat/zustand/index.cjs +4 -4
- package/dist/compat/zustand/index.js +1 -1
- package/dist/data/index.cjs +4 -4
- package/dist/data/index.js +1 -1
- package/dist/extra/buffer.cjs +4 -4
- package/dist/extra/buffer.js +1 -1
- package/dist/extra/bufferTime.cjs +4 -4
- package/dist/extra/bufferTime.js +1 -1
- package/dist/extra/combine.cjs +4 -4
- package/dist/extra/combine.js +1 -1
- package/dist/extra/concat.cjs +4 -4
- package/dist/extra/concat.js +1 -1
- package/dist/extra/concatMap.cjs +4 -4
- package/dist/extra/concatMap.js +1 -1
- package/dist/extra/debounce.cjs +4 -4
- package/dist/extra/debounce.js +1 -1
- package/dist/extra/delay.cjs +4 -4
- package/dist/extra/delay.js +1 -1
- package/dist/extra/distinctUntilChanged.cjs +4 -4
- package/dist/extra/distinctUntilChanged.js +1 -1
- package/dist/extra/elementAt.cjs +4 -4
- package/dist/extra/elementAt.js +1 -1
- package/dist/extra/empty.cjs +4 -4
- package/dist/extra/empty.js +1 -1
- package/dist/extra/exhaustMap.cjs +4 -4
- package/dist/extra/exhaustMap.js +1 -1
- package/dist/extra/filter.cjs +4 -4
- package/dist/extra/filter.js +1 -1
- package/dist/extra/find.cjs +4 -4
- package/dist/extra/find.js +1 -1
- package/dist/extra/first.cjs +4 -4
- package/dist/extra/first.js +1 -1
- package/dist/extra/flat.cjs +4 -4
- package/dist/extra/flat.js +1 -1
- package/dist/extra/fromEvent.cjs +4 -4
- package/dist/extra/fromEvent.js +1 -1
- package/dist/extra/fromIter.cjs +4 -4
- package/dist/extra/fromIter.js +1 -1
- package/dist/extra/fromObs.cjs +4 -4
- package/dist/extra/fromObs.js +1 -1
- package/dist/extra/fromPromise.cjs +4 -4
- package/dist/extra/fromPromise.js +1 -1
- package/dist/extra/index.cjs +4 -4
- package/dist/extra/index.d.cts +77 -1
- package/dist/extra/index.d.ts +77 -1
- package/dist/extra/index.js +1 -1
- package/dist/extra/interval.cjs +4 -4
- package/dist/extra/interval.js +1 -1
- package/dist/extra/last.cjs +4 -4
- package/dist/extra/last.js +1 -1
- package/dist/extra/map.cjs +4 -4
- package/dist/extra/map.js +1 -1
- package/dist/extra/merge.cjs +4 -4
- package/dist/extra/merge.js +1 -1
- package/dist/extra/never.cjs +4 -4
- package/dist/extra/never.js +1 -1
- package/dist/extra/of.cjs +4 -4
- package/dist/extra/of.js +1 -1
- package/dist/extra/pairwise.cjs +4 -4
- package/dist/extra/pairwise.js +1 -1
- package/dist/extra/partition.cjs +4 -4
- package/dist/extra/partition.js +1 -1
- package/dist/extra/pipeRaw.cjs +4 -4
- package/dist/extra/pipeRaw.js +1 -1
- package/dist/extra/remember.cjs +4 -4
- package/dist/extra/remember.js +1 -1
- package/dist/extra/repeat.cjs +4 -4
- package/dist/extra/repeat.js +1 -1
- package/dist/extra/rescue.cjs +4 -4
- package/dist/extra/rescue.js +1 -1
- package/dist/extra/sample.cjs +4 -4
- package/dist/extra/sample.js +1 -1
- package/dist/extra/scan.cjs +4 -4
- package/dist/extra/scan.js +1 -1
- package/dist/extra/skip.cjs +4 -4
- package/dist/extra/skip.js +1 -1
- package/dist/extra/startWith.cjs +4 -4
- package/dist/extra/startWith.js +1 -1
- package/dist/extra/streamParse.cjs +4 -4
- package/dist/extra/streamParse.js +1 -1
- package/dist/extra/subject.cjs +4 -4
- package/dist/extra/subject.js +1 -1
- package/dist/extra/switchMap.cjs +4 -4
- package/dist/extra/switchMap.js +1 -1
- package/dist/extra/take.cjs +4 -4
- package/dist/extra/take.js +1 -1
- package/dist/extra/takeUntil.cjs +4 -4
- package/dist/extra/takeUntil.js +1 -1
- package/dist/extra/takeWhile.cjs +4 -4
- package/dist/extra/takeWhile.js +1 -1
- package/dist/extra/tap.cjs +4 -4
- package/dist/extra/tap.js +1 -1
- package/dist/extra/throttle.cjs +4 -4
- package/dist/extra/throttle.js +1 -1
- package/dist/extra/throwError.cjs +4 -4
- package/dist/extra/throwError.js +1 -1
- package/dist/extra/timeout.cjs +4 -4
- package/dist/extra/timeout.js +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +1 -1
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.js +1 -1
- package/dist/messaging/index.cjs +6 -0
- package/dist/messaging/index.d.cts +415 -0
- package/dist/messaging/index.d.ts +415 -0
- package/dist/messaging/index.js +3 -0
- package/dist/orchestrate/index.cjs +8 -8
- package/dist/orchestrate/index.d.cts +2 -1
- package/dist/orchestrate/index.d.ts +2 -1
- package/dist/orchestrate/index.js +3 -3
- package/dist/patterns/agentLoop/index.cjs +4 -4
- package/dist/patterns/agentLoop/index.js +1 -1
- package/dist/patterns/chatStream/index.cjs +4 -4
- package/dist/patterns/chatStream/index.js +1 -1
- package/dist/patterns/createStore/index.cjs +4 -4
- package/dist/patterns/createStore/index.js +1 -1
- package/dist/patterns/formField/index.cjs +4 -4
- package/dist/patterns/formField/index.js +1 -1
- package/dist/patterns/hybridRoute/index.cjs +4 -4
- package/dist/patterns/hybridRoute/index.js +1 -1
- package/dist/patterns/memoryStore/index.cjs +4 -4
- package/dist/patterns/memoryStore/index.js +1 -1
- package/dist/patterns/pagination/index.cjs +4 -4
- package/dist/patterns/pagination/index.js +1 -1
- package/dist/patterns/rateLimiter/index.cjs +4 -4
- package/dist/patterns/rateLimiter/index.js +1 -1
- package/dist/patterns/textBuffer/index.cjs +8 -8
- package/dist/patterns/textBuffer/index.js +1 -1
- package/dist/patterns/textEditor/index.cjs +11 -11
- package/dist/patterns/textEditor/index.js +1 -1
- package/dist/patterns/toolCallState/index.cjs +4 -4
- package/dist/patterns/toolCallState/index.js +1 -1
- package/dist/patterns/undoRedo/index.cjs +4 -4
- package/dist/patterns/undoRedo/index.js +1 -1
- package/dist/{retry-BLWpwKES.d.cts → retry-CFYCmi5U.d.cts} +2 -25
- package/dist/{retry-KAgppYVn.d.ts → retry-uvt4L9x2.d.ts} +2 -25
- package/dist/utils/index.cjs +4 -4
- package/dist/utils/index.d.cts +137 -57
- package/dist/utils/index.d.ts +137 -57
- package/dist/utils/index.js +1 -1
- package/package.json +11 -1
- package/dist/chunk-6HLLZVDR.js +0 -1
- package/dist/chunk-7MY7DDET.js +0 -4
- package/dist/chunk-IDTXL7PH.js +0 -1
- package/dist/chunk-PP6QV2U4.js +0 -1
- package/dist/chunk-VZ5VR7ON.js +0 -1
- package/dist/chunk-Z47453CJ.js +0 -1
package/dist/adapters/http.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var et=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var
|
|
2
|
-
`)}static _observe(e,i,n){let s=null,
|
|
3
|
-
`)}static toD2(e){let i=e?.direction??"down",n=t.snapshot(),s=[`direction: ${i}`,""],
|
|
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 _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,b=64,T=2,P=4,yt=8,Et=16,I=32,
|
|
1
|
+
"use strict";var et=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var Lt=Object.getOwnPropertyNames;var wt=Object.prototype.hasOwnProperty;var Ot=(t,e)=>{for(var i in e)et(t,i,{get:e[i],enumerable:!0})},At=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Lt(e))!wt.call(t,s)&&s!==i&&et(t,s,{get:()=>e[s],enumerable:!(n=Rt(e,s))||n.enumerable});return t};var It=t=>At(et({},"__esModule",{value:!0}),t);var jt={};Ot(jt,{fromHTTP:()=>Ct});module.exports=It(jt);var v=Symbol("DIRTY"),M=Symbol("RESOLVED"),lt=Symbol("SINGLE_DEP"),$=Symbol("RESET"),st=Symbol("PAUSE"),it=Symbol("RESUME"),rt=Symbol("TEARDOWN");function ut(t){return t===$||t===st||t===it||t===rt}var ct=0,ft=1,dt=2,pt=3,gt=4,ht=5,R=7,ot=7<<R,$t=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function _t(t){return $t[(t&ot)>>>R]}var _=0,D=1,g=2,S=3,H=0,V=[],nt=!1;function C(t){H++;try{return t()}finally{if(H--,H===0&&!nt){nt=!0;for(let e=0;e<V.length;e++)V[e]();V.length=0,nt=!1}}}function z(){return H>0}function B(t){V.push(t)}var G=0,q=[];function St(){G++}function Tt(){if(G--,G===0){for(let t=0;t<q.length;t++)q[t]();q.length=0}}function mt(t){G>0?q.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 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(_,(o,a)=>{if(o===_&&(n=a),o===g){n=null;return}if(o===1){let l=a;if(!Object.is(l,s)){let c=s;s=l,i(l,c)}}}),()=>n?.(g)}static dumpGraph(){let e=t.graph(),i=t.getEdges(),n=new Map;for(let[a,l]of i)for(let c of l){let f=n.get(c);f?f.includes(a)||f.push(a):n.set(c,[a])}let s=[];for(let[a,l]of e){let c=n.get(a),f=i.get(a),r=c?.length?` \u2190 [${c.join(", ")}]`:"",u=f?.length?` \u2192 [${f.join(", ")}]`:"";s.push(` ${a} (${l.kind}) = ${JSON.stringify(l.value)} [${l.status??"?"}]${r}${u}`)}return[`Store Graph (${e.size} nodes):`,...s].join(`
|
|
2
|
+
`)}static _signalLabel(e){return e===v?"DIRTY":e===M?"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),l=[],c={values:[],signals:[],events:[],ended:!1,endError:void 0,get completedCleanly(){return c.ended&&!o},get errored(){return c.ended&&o},dirtyCount:0,resolvedCount:0,name:a,get eventLog(){return l},dispose:()=>s?.(g),reconnect:()=>(s?.(g),t._observe(e,i,n))};return e.source(_,(f,r)=>{if(f===_){s=r;return}f===D?(c.values.push(r),c.events.push({type:"data",data:r}),l.push(r),n&&n(`[${a}] DATA:`,r)):f===S?(c.signals.push(r),c.events.push({type:"signal",data:r}),l.push(t._signalLabel(r)),r===v?c.dirtyCount++:r===M&&c.resolvedCount++,n&&n(`[${a}] STATE:`,r)):f===g&&(c.ended=!0,c.endError=r,o=r!==void 0,c.events.push({type:"end",data:r}),l.push(o?["END",r]:"END"),n&&n(`[${a}] END`,r!==void 0?r:""),s=null)}),c}static observe(e){return t._observe(e)}static activate(e){let i=null;return e.source(_,(n,s)=>{n===_&&(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 c=t._annotations.get(l);c!==void 0&&n.set(t._resolveKey(l),c)}let s=[];for(let[a,l]of e){let c={name:a,kind:l.kind,value:l.value,status:l.status},f=n.get(a);f!==void 0&&(c.annotation=f),s.push(c)}let o=[];for(let[a,l]of i)for(let c of l)o.push({from:a,to:c});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 l(r){let u=r.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(u);return d===void 0?(a.set(u,1),u):(a.set(u,d+1),`${u}__${d}`)}let c=new Map;function f(r){let u=JSON.stringify(r);return u&&u.length>30?`${u.slice(0,27)}...`:u??"undefined"}for(let r of n.nodes){let u=l(r.name);c.set(r.name,u);let d=`${r.name} (${r.kind}) = ${f(r.value)}`,p=o[r.status??""]??"";s.push(` ${u}["${d}"]${p}`)}for(let r of n.edges){let u=c.get(r.from)??l(r.from),d=c.get(r.to)??l(r.to);s.push(` ${u} --> ${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 l(r){let u=r.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(u);return d===void 0?(a.set(u,1),u):(a.set(u,d+1),`${u}__${d}`)}let c=new Map;function f(r){let u=JSON.stringify(r);return u&&u.length>30?`${u.slice(0,27)}...`:u??"undefined"}for(let r of n.nodes){let u=l(r.name);c.set(r.name,u);let d=o[r.kind]??"rectangle",p=`${r.name} (${r.kind}) = ${f(r.value)}`,m=r.status?` [${r.status}]`:"";s.push(`${u}: "${p}${m}" { shape: ${d} }`)}n.edges.length>0&&s.push("");for(let r of n.edges){let u=c.get(r.from)??l(r.from),d=c.get(r.to)??l(r.to);s.push(`${u} -> ${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 _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,b=64,T=2,P=4,yt=8,Et=16,I=32,k=1024,h=ot,N=ft<<R,j=dt<<R,Z=ct<<R,Pt=gt<<R,Nt=ht<<R,Mt=pt<<R,W=class{_value;_output=null;_flags;get _status(){return _t(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|=P),i?.resetOnTeardown&&(n|=yt),i?.resubscribable&&(n|=Et),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&b)for(let s of n)s(e,i);else n(e,i)}emit(e){this._flags&T||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&(z()?this._flags&I||(this._flags|=I,this._flags&P&&(this._flags=this._flags&~h|N,this._dispatch(S,v)),B(()=>{this._flags&=~I,this._flags=this._flags&~h|j,this._dispatch(D,this._value)})):(this._flags&P&&!(this._flags&k)&&(this._flags=this._flags&~h|N,this._dispatch(S,v)),this._flags=this._flags&~h|j,this._dispatch(D,this._value))))}signal(e){this._flags&T||!this._output||(e===v?this._flags=this._flags&~h|N:e===M&&(this._flags=this._flags&~h|Mt),this._dispatch(S,e))}complete(){if(this._flags&T)return;this._flags=(this._flags|T)&~h|Pt;let e=this._output,i=this._flags&b;if(this._output=null,this._flags&=~(b|k),this._singleDepCount=0,this._stop(),e)if(i)for(let n of e)n(g);else e(g)}error(e){if(this._flags&T)return;this._flags=(this._flags|T)&~h|Nt;let i=this._output,n=this._flags&b;if(this._output=null,this._flags&=~(b|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&yt&&(this._value=this._initial),this._flags&T||(this._flags=this._flags&~h|Z))}_handleLifecycleSignal(e){if(!(this._flags&T)){if(e===rt){this._onLifecycleSignal?.(e),this.complete();return}e===$&&(this._value=this._initial,this._flags&=~I),this._onLifecycleSignal?.(e),e===$&&this.emit(this._initial)}}source(e,i){if(e===_){let n=i;if(this._flags&T)if(this._flags&Et&&this._output===null)this._flags=this._flags&~(T|h)|Z;else{n(_,o=>{}),n(g);return}if(this._output===null)this._output=n;else if(this._flags&b)this._output.add(n);else{let o=new Set;o.add(this._output),o.add(n),this._output=o,this._flags=(this._flags|b)&~k}let s=!1;n(_,(o,a)=>{if(o===D&&n(D,this._value),o===S){a===lt&&!s?(s=!0,this._singleDepCount++,this._flags&b||(this._flags|=k)):ut(a)&&this._handleLifecycleSignal(a);return}if(o===g){if(s&&(s=!1,this._singleDepCount--),this._output===null)return;if(this._flags&b){let l=this._output;l.delete(n),l.size===1?(this._output=l.values().next().value,this._flags&=~b,this._singleDepCount>0&&(this._flags|=k)):l.size===0&&(this._output=null,this._flags&=~(b|k),this._singleDepCount=0,this._flags=this._flags&~h|Z,this._stop())}else this._output===n&&(this._output=null,this._flags&=~k,this._singleDepCount=0,this._flags=this._flags&~h|Z,this._stop())}}),mt(()=>this._start())}}};function Q(t,e){return new W(t,e)}var at=class extends W{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&T||this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&(z()?this._flags&I||(this._flags|=I,this._flags&P&&(this._flags=this._flags&~h|N,this._dispatch(S,v)),B(()=>{this._flags&=~I,this._flags=this._flags&~h|j,this._dispatch(D,this._value)})):(this._flags&P&&!(this._flags&k)&&(this._flags=this._flags&~h|N,this._dispatch(S,v)),this._flags=this._flags&~h|j,this._dispatch(D,this._value))))}update(e){this.set(e(this._value))}};function F(t,e){return new at(t,e)}function bt(t,e,i){let n=null;St(),t.source(_,(o,a)=>{if(o===_&&(n=a),o===g){n=null,i?.onEnd?.(a);return}if(o===1){let l=a,c=s;s=l,e(l,c)}});let s;try{s=t.get()}catch{}return Tt(),{unsubscribe(){n?.(g),n=null},signal(o){n?.(S,o)}}}function vt(t,e){let i=e?.initialStatus??"pending",n=F(i,{name:"withStatus:status",equals:Object.is}),s=F(void 0,{name:"withStatus:error",equals:Object.is}),o=Q(({emit:l,complete:c,error:f})=>{n.set(i),s.set(void 0);let r=bt(t,u=>{n.get()==="errored"?C(()=>{s.set(void 0),n.set("active")}):n.set("active"),l(u)},{onEnd:u=>{if(u!==void 0){let d=u instanceof Error?u:new Error(String(u));C(()=>{s.set(d),n.set("errored")}),f(u)}else n.set("completed"),c()}});return()=>{r.unsubscribe()}},{initial:t.get(),resubscribable:!0}),a={get:()=>t.get(),source:(l,c)=>o.source(l,c),get _status(){return o._status},status:n,error:s};return A.register(a,{kind:"withStatus"}),a}function Ct(t,e){let i=e?.name??"http",n=e?.method??"GET",s=e?.headers,o=e?.body,a=e?.poll??0,l=e?.transform??(L=>L.json()),c=e?.timeout??3e4,f=F(0,{name:`${i}:fetchCount`}),r=null,u=null,d=null,p=null,m=null,y=!1;async function K(){if(!y||!r)return;m=new AbortController;let L=[m.signal];e?.signal&&L.push(e.signal);let w=new AbortController;for(let E of L){if(E.aborted){w.abort(E.reason);break}E.addEventListener("abort",()=>w.abort(E.reason),{once:!0})}let tt=setTimeout(()=>w.abort(new Error("Request timeout")),c);try{let E=o!==void 0?typeof o=="string"?o:JSON.stringify(o):void 0,O=await fetch(t,{method:n,headers:s,body:E,signal:w.signal});if(!y)return;if(!O.ok)throw new Error(`HTTP ${O.status}: ${O.statusText}`);let kt=await l(O);if(!y)return;C(()=>{f.update(xt=>xt+1),r?.(kt)})}catch(E){if(!y||E?.name==="AbortError")return;u?.(E)}finally{clearTimeout(tt),m=null}}function U(){!y||x||a<=0||(p=setTimeout(()=>{p=null,K().then(()=>{y&&!x&&U()}).catch(()=>{})},a))}let X=null,x=!1,Dt=Q(({emit:L,error:w,complete:tt,onSignal:E})=>(r=L,u=w,d=tt,y=!0,x=!1,X=()=>{K()},E(O=>{O===st?(x=!0,p!==null&&(clearTimeout(p),p=null)):O===it?(x=!1,U()):O===$&&(m?.abort(),m=null,p!==null&&(clearTimeout(p),p=null),f.set(0),x=!1,K().then(()=>{y&&!x&&U()}))}),K().then(()=>{y&&!x&&U()}),()=>{y=!1,x=!1,r=null,u=null,d=null,X=null,m?.abort(),m=null,p!==null&&(clearTimeout(p),p=null)}),{name:i,kind:"http"}),Y=vt(Dt);return{get:()=>Y.get(),source:(L,w)=>Y.source(L,w),status:Y.status,error:Y.error,fetchCount:f,refetch(){X?.()},stop(){y=!1,m?.abort(),m=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-RWZ3CCF6.js";import"../chunk-S2U5T7BO.js";import"../chunk-GMLWTZFM.js";import"../chunk-7FX2AO6N.js";import"../chunk-VFN2CV32.js";import"../chunk-SOIVZBGE.js";import"../chunk-TUPD47IE.js";import"../chunk-I7AUKTXE.js";export{a as fromHTTP};
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";var Ne=Object.create;var
|
|
2
|
-
`)}static _observe(t,n,r){let o=null,a=n??e.getName(t),i={values:[],signals:[],events:[],ended:!1,endError:void 0,dirtyCount:0,resolvedCount:0,name:
|
|
3
|
-
`)}static toD2(t){let n=t?.direction??"down",r=e.snapshot(),o=[`direction: ${n}`,""],a={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},
|
|
4
|
-
`)}static annotate(t,n){if(!e.enabled)return;e._annotations.set(t,n);let r={node:e._resolveKey(t),reason:n,timestamp:Date.now()},o=e.maxTraceEntries;o<=0||(e._traceLog.length<o?e._traceLog.push(r):(e._traceLog[e._traceHead]=r,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 _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 ce=1,I=64,W=2,
|
|
5
|
-
`);w=E.pop()??"";for(let
|
|
6
|
-
`),E=new Error(k||"MCP tool returned error");
|
|
1
|
+
"use strict";var Ne=Object.create;var re=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty;var qe=(e,t)=>{for(var n in t)re(e,n,{get:t[n],enumerable:!0})},he=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ue(t))!Fe.call(e,o)&&o!==n&&re(e,o,{get:()=>t[o],enumerable:!(r=je(t,o))||r.enumerable});return e};var Be=(e,t,n)=>(n=e!=null?Ne(He(e)):{},he(t||!e||!e.__esModule?re(n,"default",{value:e,enumerable:!0}):n,e)),Ke=e=>he(re({},"__esModule",{value:!0}),e);var rt={};qe(rt,{fromHTTP:()=>Ce,fromLLM:()=>Ae,fromMCP:()=>Oe,fromWebSocket:()=>We,fromWebhook:()=>$e,toSSE:()=>Me,toWebSocket:()=>Ie});module.exports=Ke(rt);var N=Symbol("DIRTY"),Z=Symbol("RESOLVED"),Se=Symbol("SINGLE_DEP"),j=Symbol("RESET"),K=Symbol("PAUSE"),z=Symbol("RESUME"),pe=Symbol("TEARDOWN");function Te(e){return e===j||e===K||e===z||e===pe}var ye=0,be=1,_e=2,ke=3,ve=4,Ee=5,F=7,ge=7<<F,ze=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function we(e){return ze[(e&ge)>>>F]}var P=0,U=1,R=2,$=3,oe=0,se=[],de=!1;function C(e){oe++;try{return e()}finally{if(oe--,oe===0&&!de){de=!0;for(let t=0;t<se.length;t++)se[t]();se.length=0,de=!1}}}function le(){return oe>0}function ue(e){se.push(e)}var ae=0,ie=[];function xe(){ae++}function Re(){if(ae--,ae===0){for(let e=0;e<ie.length;e++)ie[e]();ie.length=0}}function Le(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 r=t.map(o=>e._names.get(o)??"?").join(",");return r.length>40?`${r.slice(0,37)}...`:r}static _resolveKey(t){let n=e._keys.get(t)??e._names.get(t);if(n)return n;let r=`anonymous_${e._nextId++}`;return e._keys.set(t,r),r}static register(t,n){if(!e.enabled)return;n?.name&&e._names.set(t,n.name),n?.kind&&e._kinds.set(t,n.kind);let r=e._nextId++,o=n?.name;if(!(o&&!e._usedKeys.has(o)))if(o){let a=e._depSuffix(n?.deps);o=a?`${o}(${a})`:`${o}_${r}`,e._usedKeys.has(o)&&(o=`${o}_${r}`)}else{let a=n?.kind??"store",l=e._depSuffix(n?.deps);o=l?`${a}(${l})`:`${a}_${r}`,e._usedKeys.has(o)&&(o=`${o}_${r}`)}e._usedKeys.add(o),e._keys.set(t,o),e._stores.add(new WeakRef(t))}static registerEdge(t,n){if(!e.enabled)return;let r=e._resolveKey(t),o=e._resolveKey(n),a=e._edges.get(r);a?a.includes(o)||a.push(o):e._edges.set(r,[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,n=new Set;for(let r of e._stores){let o=r.deref();if(!o){e._stores.delete(r);continue}let a=e._resolveKey(o);n.add(a),t.set(a,e.inspect(o))}for(let[r,o]of e._edges){if(!n.has(r)){e._edges.delete(r),e._usedKeys.delete(r);continue}let a=o.filter(l=>n.has(l));a.length===0?e._edges.delete(r):a.length!==o.length&&e._edges.set(r,a)}return t}static trace(t,n){let r=null,o=t.get();return t.source(P,(a,l)=>{if(a===P&&(r=l),a===R){r=null;return}if(a===1){let i=l;if(!Object.is(i,o)){let c=o;o=i,n(i,c)}}}),()=>r?.(R)}static dumpGraph(){let t=e.graph(),n=e.getEdges(),r=new Map;for(let[l,i]of n)for(let c of i){let f=r.get(c);f?f.includes(l)||f.push(l):r.set(c,[l])}let o=[];for(let[l,i]of t){let c=r.get(l),f=n.get(l),s=c?.length?` \u2190 [${c.join(", ")}]`:"",u=f?.length?` \u2192 [${f.join(", ")}]`:"";o.push(` ${l} (${i.kind}) = ${JSON.stringify(i.value)} [${i.status??"?"}]${s}${u}`)}return[`Store Graph (${t.size} nodes):`,...o].join(`
|
|
2
|
+
`)}static _signalLabel(t){return t===N?"DIRTY":t===Z?"RESOLVED":typeof t=="symbol"?t.description??String(t):String(t)}static _observe(t,n,r){let o=null,a=!1,l=n??e.getName(t),i=[],c={values:[],signals:[],events:[],ended:!1,endError:void 0,get completedCleanly(){return c.ended&&!a},get errored(){return c.ended&&a},dirtyCount:0,resolvedCount:0,name:l,get eventLog(){return i},dispose:()=>o?.(R),reconnect:()=>(o?.(R),e._observe(t,n,r))};return t.source(P,(f,s)=>{if(f===P){o=s;return}f===U?(c.values.push(s),c.events.push({type:"data",data:s}),i.push(s),r&&r(`[${l}] DATA:`,s)):f===$?(c.signals.push(s),c.events.push({type:"signal",data:s}),i.push(e._signalLabel(s)),s===N?c.dirtyCount++:s===Z&&c.resolvedCount++,r&&r(`[${l}] STATE:`,s)):f===R&&(c.ended=!0,c.endError=s,a=s!==void 0,c.events.push({type:"end",data:s}),i.push(a?["END",s]:"END"),r&&r(`[${l}] END`,s!==void 0?s:""),o=null)}),c}static observe(t){return e._observe(t)}static activate(t){let n=null;return t.source(P,(r,o)=>{r===P&&(n=o),r===R&&(n=null)}),()=>n?.(R)}static tap(t,n){let r=n??`tap(${e.getName(t)??"anon"})`,o={get:()=>t.get(),source:t.source};return e.register(o,{name:r,kind:"tap"}),e.registerEdge(t,o),o}static spy(t,n){let r=n?.name??e.getName(t)??"spy",o=n?.log??console.log;return e._observe(t,r,o)}static snapshot(){let t=e.graph(),n=e.getEdges(),r=new Map;for(let l of e._stores){let i=l.deref();if(!i)continue;let c=e._annotations.get(i);c!==void 0&&r.set(e._resolveKey(i),c)}let o=[];for(let[l,i]of t){let c={name:l,kind:i.kind,value:i.value,status:i.status},f=r.get(l);f!==void 0&&(c.annotation=f),o.push(c)}let a=[];for(let[l,i]of n)for(let c of i)a.push({from:l,to:c});return{nodes:o,edges:a,trace:e.traceLog()}}static toMermaid(t){let n=t?.direction??"TD",r=e.snapshot(),o=[`graph ${n}`],a={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},l=new Map;function i(s){let u=s.replace(/[^a-zA-Z0-9_]/g,"_"),g=l.get(u);return g===void 0?(l.set(u,1),u):(l.set(u,g+1),`${u}__${g}`)}let c=new Map;function f(s){let u=JSON.stringify(s);return u&&u.length>30?`${u.slice(0,27)}...`:u??"undefined"}for(let s of r.nodes){let u=i(s.name);c.set(s.name,u);let g=`${s.name} (${s.kind}) = ${f(s.value)}`,m=a[s.status??""]??"";o.push(` ${u}["${g}"]${m}`)}for(let s of r.edges){let u=c.get(s.from)??i(s.from),g=c.get(s.to)??i(s.to);o.push(` ${u} --> ${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 n=t?.direction??"down",r=e.snapshot(),o=[`direction: ${n}`,""],a={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},l=new Map;function i(s){let u=s.replace(/[^a-zA-Z0-9_]/g,"_"),g=l.get(u);return g===void 0?(l.set(u,1),u):(l.set(u,g+1),`${u}__${g}`)}let c=new Map;function f(s){let u=JSON.stringify(s);return u&&u.length>30?`${u.slice(0,27)}...`:u??"undefined"}for(let s of r.nodes){let u=i(s.name);c.set(s.name,u);let g=a[s.kind]??"rectangle",m=`${s.name} (${s.kind}) = ${f(s.value)}`,y=s.status?` [${s.status}]`:"";o.push(`${u}: "${m}${y}" { shape: ${g} }`)}r.edges.length>0&&o.push("");for(let s of r.edges){let u=c.get(s.from)??i(s.from),g=c.get(s.to)??i(s.to);o.push(`${u} -> ${g}`)}return o.join(`
|
|
4
|
+
`)}static annotate(t,n){if(!e.enabled)return;e._annotations.set(t,n);let r={node:e._resolveKey(t),reason:n,timestamp:Date.now()},o=e.maxTraceEntries;o<=0||(e._traceLog.length<o?e._traceLog.push(r):(e._traceLog[e._traceHead]=r,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 _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 ce=1,I=64,W=2,Y=4,De=8,Pe=16,q=32,H=1024,L=ge,J=be<<F,X=_e<<F,fe=ye<<F,Ve=ve<<F,Ye=Ee<<F,Je=ke<<F,ee=class{_value;_output=null;_flags;get _status(){return we(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;_onLifecycleSignal;constructor(t,n){this._value=n?.initial,this._fn=t,this._eqFn=n?.equals,this._getterFn=n?.getter,this._initial=n?.initial;let r=0;n?.autoDirty!==!1&&(r|=Y),n?.resetOnTeardown&&(r|=De),n?.resubscribable&&(r|=Pe),this._flags=r,this.source=this.source.bind(this),this.emit=this.emit.bind(this),n?._skipInspect||A.register(this,{kind:"producer",...n})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,n){let r=this._output;if(r)if(this._flags&I)for(let o of r)o(t,n);else r(t,n)}emit(t){this._flags&W||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(le()?this._flags&q||(this._flags|=q,this._flags&Y&&(this._flags=this._flags&~L|J,this._dispatch($,N)),ue(()=>{this._flags&=~q,this._flags=this._flags&~L|X,this._dispatch(U,this._value)})):(this._flags&Y&&!(this._flags&H)&&(this._flags=this._flags&~L|J,this._dispatch($,N)),this._flags=this._flags&~L|X,this._dispatch(U,this._value))))}signal(t){this._flags&W||!this._output||(t===N?this._flags=this._flags&~L|J:t===Z&&(this._flags=this._flags&~L|Je),this._dispatch($,t))}complete(){if(this._flags&W)return;this._flags=(this._flags|W)&~L|Ve;let t=this._output,n=this._flags&I;if(this._output=null,this._flags&=~(I|H),this._singleDepCount=0,this._stop(),t)if(n)for(let r of t)r(R);else t(R)}error(t){if(this._flags&W)return;this._flags=(this._flags|W)&~L|Ye;let n=this._output,r=this._flags&I;if(this._output=null,this._flags&=~(I|H),this._singleDepCount=0,this._stop(),n)if(r)for(let o of n)o(R,t);else n(R,t)}_start(){if(this._flags&ce||!this._fn)return;this._flags|=ce,this._onLifecycleSignal=void 0;let t=this._fn({emit:this.emit,signal:n=>this.signal(n),complete:()=>this.complete(),error:n=>this.error(n),onSignal:n=>{this._onLifecycleSignal=n}});this._cleanup=typeof t=="function"?t:void 0}_stop(){this._flags&ce&&(this._flags&=~ce,this._onLifecycleSignal=void 0,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&De&&(this._value=this._initial),this._flags&W||(this._flags=this._flags&~L|fe))}_handleLifecycleSignal(t){if(!(this._flags&W)){if(t===pe){this._onLifecycleSignal?.(t),this.complete();return}t===j&&(this._value=this._initial,this._flags&=~q),this._onLifecycleSignal?.(t),t===j&&this.emit(this._initial)}}source(t,n){if(t===P){let r=n;if(this._flags&W)if(this._flags&Pe&&this._output===null)this._flags=this._flags&~(W|L)|fe;else{r(P,a=>{}),r(R);return}if(this._output===null)this._output=r;else if(this._flags&I)this._output.add(r);else{let a=new Set;a.add(this._output),a.add(r),this._output=a,this._flags=(this._flags|I)&~H}let o=!1;r(P,(a,l)=>{if(a===U&&r(U,this._value),a===$){l===Se&&!o?(o=!0,this._singleDepCount++,this._flags&I||(this._flags|=H)):Te(l)&&this._handleLifecycleSignal(l);return}if(a===R){if(o&&(o=!1,this._singleDepCount--),this._output===null)return;if(this._flags&I){let i=this._output;i.delete(r),i.size===1?(this._output=i.values().next().value,this._flags&=~I,this._singleDepCount>0&&(this._flags|=H)):i.size===0&&(this._output=null,this._flags&=~(I|H),this._singleDepCount=0,this._flags=this._flags&~L|fe,this._stop())}else this._output===r&&(this._output=null,this._flags&=~H,this._singleDepCount=0,this._flags=this._flags&~L|fe,this._stop())}}),Le(()=>this._start())}}};function B(e,t){return new ee(e,t)}var me=class extends ee{constructor(t,n){super(void 0,{initial:t,autoDirty:!0,equals:n?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),A.register(this,{kind:"state",...n})}get(){return this._value}set(t){this._flags&W||this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(le()?this._flags&q||(this._flags|=q,this._flags&Y&&(this._flags=this._flags&~L|J,this._dispatch($,N)),ue(()=>{this._flags&=~q,this._flags=this._flags&~L|X,this._dispatch(U,this._value)})):(this._flags&Y&&!(this._flags&H)&&(this._flags=this._flags&~L|J,this._dispatch($,N)),this._flags=this._flags&~L|X,this._dispatch(U,this._value))))}update(t){this.set(t(this._value))}};function v(e,t){return new me(e,t)}function G(e,t,n){let r=null;xe(),e.source(P,(a,l)=>{if(a===P&&(r=l),a===R){r=null,n?.onEnd?.(l);return}if(a===1){let i=l,c=o;o=i,t(i,c)}});let o;try{o=e.get()}catch{}return Re(),{unsubscribe(){r?.(R),r=null},signal(a){r?.($,a)}}}function Q(e,t){let n=t?.initialStatus??"pending",r=v(n,{name:"withStatus:status",equals:Object.is}),o=v(void 0,{name:"withStatus:error",equals:Object.is}),a=B(({emit:i,complete:c,error:f})=>{r.set(n),o.set(void 0);let s=G(e,u=>{r.get()==="errored"?C(()=>{o.set(void 0),r.set("active")}):r.set("active"),i(u)},{onEnd:u=>{if(u!==void 0){let g=u instanceof Error?u:new Error(String(u));C(()=>{o.set(g),r.set("errored")}),f(u)}else r.set("completed"),c()}});return()=>{s.unsubscribe()}},{initial:e.get(),resubscribable:!0}),l={get:()=>e.get(),source:(i,c)=>a.source(i,c),get _status(){return a._status},status:r,error:o};return A.register(l,{kind:"withStatus"}),l}function Ce(e,t){let n=t?.name??"http",r=t?.method??"GET",o=t?.headers,a=t?.body,l=t?.poll??0,i=t?.transform??(w=>w.json()),c=t?.timeout??3e4,f=v(0,{name:`${n}:fetchCount`}),s=null,u=null,g=null,m=null,y=null,T=!1;async function x(){if(!T||!s)return;y=new AbortController;let w=[y.signal];t?.signal&&w.push(t.signal);let _=new AbortController;for(let E of w){if(E.aborted){_.abort(E.reason);break}E.addEventListener("abort",()=>_.abort(E.reason),{once:!0})}let k=setTimeout(()=>_.abort(new Error("Request timeout")),c);try{let E=a!==void 0?typeof a=="string"?a:JSON.stringify(a):void 0,D=await fetch(e,{method:r,headers:o,body:E,signal:_.signal});if(!T)return;if(!D.ok)throw new Error(`HTTP ${D.status}: ${D.statusText}`);let M=await i(D);if(!T)return;C(()=>{f.update(O=>O+1),s?.(M)})}catch(E){if(!T||E?.name==="AbortError")return;u?.(E)}finally{clearTimeout(k),y=null}}function h(){!T||p||l<=0||(m=setTimeout(()=>{m=null,x().then(()=>{T&&!p&&h()}).catch(()=>{})},l))}let d=null,p=!1,S=B(({emit:w,error:_,complete:k,onSignal:E})=>(s=w,u=_,g=k,T=!0,p=!1,d=()=>{x()},E(D=>{D===K?(p=!0,m!==null&&(clearTimeout(m),m=null)):D===z?(p=!1,h()):D===j&&(y?.abort(),y=null,m!==null&&(clearTimeout(m),m=null),f.set(0),p=!1,x().then(()=>{T&&!p&&h()}))}),x().then(()=>{T&&!p&&h()}),()=>{T=!1,p=!1,s=null,u=null,g=null,d=null,y?.abort(),y=null,m!==null&&(clearTimeout(m),m=null)}),{name:n,kind:"http"}),b=Q(S);return{get:()=>b.get(),source:(w,_)=>b.source(w,_),status:b.status,error:b.error,fetchCount:f,refetch(){d?.()},stop(){T=!1,y?.abort(),y=null,m!==null&&(clearTimeout(m),m=null),g?.()}}}function Ge(e){switch(e){case"openai":return"https://api.openai.com/v1";case"ollama":return"http://localhost:11434";default:return""}}function Qe(e,t){switch(e){case"openai":case"custom":return`${t}/chat/completions`;case"ollama":return`${t}/api/chat`;default:return`${t}/chat/completions`}}function Ze(e,t,n,r){let o={model:t,messages:n,stream:!0};return r?.temperature!==void 0&&(o.temperature=r.temperature),r?.maxTokens!==void 0&&(e==="ollama"?o.options={num_predict:r.maxTokens}:o.max_tokens=r.maxTokens),r?.stop&&(o.stop=r.stop),o}function Xe(e,t){let n={"Content-Type":"application/json"};return t&&(n.Authorization=`Bearer ${t}`),n}function Ae(e){let t=e.name??"llm",n=e.provider,r=e.baseURL??Ge(n),o=e.model??"",a=e.fetch??globalThis.fetch,l=v("",{name:`${t}.store`}),i=v({},{name:`${t}.tokens`}),c=v("pending",{name:`${t}.status`}),f=v(void 0,{name:`${t}.error`}),s=null;function u(){s&&(s.abort(),s=null),c.get()==="active"&&C(()=>{l.set(""),c.set("pending")})}function g(y,T){u(),s=new AbortController;let x=T?.signal?nt(s.signal,T.signal):s.signal;C(()=>{l.set(""),i.set({}),f.set(void 0),c.set("active")});let h=Qe(n,r),d=Ze(n,o,y,T),p=Xe(n,e.apiKey);m(h,p,d,x).catch(()=>{})}async function m(y,T,x,h){try{let d=await a(y,{method:"POST",headers:T,body:JSON.stringify(x),signal:h});if(!d.ok){let _=await d.text().catch(()=>"");throw new Error(`LLM API error ${d.status}: ${_}`)}let p=d.body?.getReader();if(!p)throw new Error("No response body");let S=new TextDecoder,b="",w="";for(;;){if(h.aborted)return;let{done:_,value:k}=await p.read();if(_)break;w+=S.decode(k,{stream:!0});let E=w.split(`
|
|
5
|
+
`);w=E.pop()??"";for(let D of E){if(h.aborted)return;let M=D.trim();if(!M||M.startsWith(":")||!M.startsWith("data: "))continue;let O=M.slice(6);if(O!=="[DONE]")try{let te=JSON.parse(O),V=et(n,te);V&&(b+=V,l.set(b));let ne=tt(n,te);ne&&i.set(ne)}catch{}}}if(S.decode(),h.aborted)return;c.set("completed"),s=null}catch(d){if(h.aborted)return;C(()=>{f.set(d),c.set("errored")}),s=null}finally{h._cleanup?.()}}return{get:()=>l.get(),source:(y,T)=>l.source(y,T),tokens:i,status:c,error:f,generate:g,abort:u}}function et(e,t){return e==="ollama"?t?.message?.content:t?.choices?.[0]?.delta?.content}function tt(e,t){let n=e==="ollama"?t:t?.usage;if(n){if(e==="ollama")return t.eval_count!==void 0||t.prompt_eval_count!==void 0?{promptTokens:t.prompt_eval_count,completionTokens:t.eval_count,totalTokens:(t.prompt_eval_count??0)+(t.eval_count??0)}:void 0;if(n.prompt_tokens!==void 0||n.completion_tokens!==void 0)return{promptTokens:n.prompt_tokens,completionTokens:n.completion_tokens,totalTokens:n.total_tokens}}}function nt(e,t){let n=new AbortController,r=()=>{e.removeEventListener("abort",o),t.removeEventListener("abort",o)},o=()=>{n.abort(),r()};e.addEventListener("abort",o,{once:!0}),t.addEventListener("abort",o,{once:!0});let a=n.signal;return a._cleanup=r,a}function Oe(e){let t=e.name??"mcp",n=e.client,r=v([],{name:`${t}.tools`}),o=v([],{name:`${t}.resources`}),a=v(void 0,{name:`${t}.refreshError`});function l(f){a.set(f);let s=e.onRefreshError;if(s==="warn")console.warn(`[${t}] refresh error:`,f);else{if(s==="error")throw f;typeof s=="function"&&s(f)}}async function i(){if(a.set(void 0),n.listTools)try{let f=await n.listTools();r.set(f.tools)}catch(f){l(f)}if(n.listResources)try{let f=await n.listResources();o.set(f.resources)}catch(f){l(f)}}function c(f){let s=`${t}:${f}`,u=v(void 0,{name:`${s}.result`}),g=v("idle",{name:`${s}.status`}),m=v(void 0,{name:`${s}.error`}),y=v(void 0,{name:`${s}.lastArgs`}),T=v(void 0,{name:`${s}.duration`}),x=!1;async function h(d){if(x)return;x=!0,C(()=>{y.set(d),m.set(void 0),g.set("active")});let p=Date.now();try{let S=await n.callTool({name:f,arguments:d}),b=Date.now()-p;if(S.isError){let k=S.content.filter(D=>D.type==="text").map(D=>D.text??"").join(`
|
|
6
|
+
`),E=new Error(k||"MCP tool returned error");C(()=>{T.set(b),m.set(E),g.set("errored")});return}let w=S.content.filter(k=>k.type==="text"),_;if(w.length===1){let k=w[0].text;if(k!==void 0)try{_=JSON.parse(k)}catch{_=k}}else w.length>1?_=w.map(k=>k.text??""):_=S.content;C(()=>{T.set(b),u.set(_),g.set("completed")})}catch(S){let b=Date.now()-p;C(()=>{T.set(b),m.set(S),g.set("errored")})}finally{x=!1}}return{get:()=>u.get(),source:(d,p)=>u.source(d,p),status:g,error:m,call:h,lastArgs:y,duration:T}}return{tool:c,tools:r,resources:o,refresh:i,refreshError:a}}function Me(e,t){let n=t?.path??"/",r=t?.name??"sse",o=t?.hostname??"0.0.0.0",a=t?.serialize??JSON.stringify,l=t?.eventName??"message",i=t?.pingInterval??3e4,c=v(0,{name:`${r}:connections`}),f=new Set,s=new Map,u=null;function g(){u||(u=G(e,d=>{let p=a(d),S=`event: ${l}
|
|
7
7
|
data: ${p}
|
|
8
8
|
|
|
9
|
-
`;for(let b of f)try{b.write(S)}catch{m(b)}}))}function m(d){f.delete(d);let p=
|
|
9
|
+
`;for(let b of f)try{b.write(S)}catch{m(b)}}))}function m(d){f.delete(d);let p=s.get(d);p&&(clearInterval(p),s.delete(d)),c.set(f.size),f.size===0&&u&&(u.unsubscribe(),u=null)}function y(d,p){let S=d.method?.toUpperCase();if((d.url??"/").split("?")[0]!==n){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
|
|
10
10
|
|
|
11
|
-
`),f.add(p),c.set(f.size);try{let _=e.get();if(_!==void 0){let k=a(_);p.write(`event: ${
|
|
11
|
+
`),f.add(p),c.set(f.size);try{let _=e.get();if(_!==void 0){let k=a(_);p.write(`event: ${l}
|
|
12
12
|
data: ${k}
|
|
13
13
|
|
|
14
|
-
`)}}catch{}if(
|
|
14
|
+
`)}}catch{}if(i>0){let _=setInterval(()=>{try{p.write(`:ping
|
|
15
15
|
|
|
16
|
-
`)}catch{m(p)}},
|
|
16
|
+
`)}catch{m(p)}},i);s.set(p,_)}d.on("close",()=>m(p)),g()}let T=null;async function x(){if(!t?.port)throw new Error("toSSE: port is required for listen()");if(T)throw new Error("toSSE: already listening. Call close() first.");let d=await import("http");return new Promise((p,S)=>{T=d.createServer(y),T.once("listening",()=>p()),T.once("error",b=>{T=null,S(b)}),T.listen(t.port,o)})}function h(){for(let d of f)try{d.end()}catch{}f.clear();for(let d of s.values())clearInterval(d);s.clear(),c.set(0),u?.unsubscribe(),u=null,T?.close(),T=null}return A.register(c,{kind:"sse"}),{connectionCount:c,handler:y,listen:x,close:h}}function $e(e){let t=e?.path??"/",n=e?.parse??JSON.parse,r=e?.name??"webhook",o=e?.hostname??"0.0.0.0",a=e?.maxBodySize??1024*1024,l=e?.responseTimeout??3e4,i=v(0,{name:`${r}:count`}),c=null,f=!1,s=B(({emit:h,onSignal:d})=>(c=h,f=!1,d(p=>{p===K?f=!0:p===z?f=!1:p===j&&(f=!1,i.set(0))}),()=>{c=null,f=!1}),{name:r,kind:"webhook"});A.register(s,{kind:"webhook"});let u=Q(s),g=null,m=new Set;function y(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(f){d.writeHead(503,{"Content-Type":"application/json"}),d.end(JSON.stringify({error:"Service paused"}));return}let w=[],_=0,k=!1;h.on("error",()=>{k=!0,d.headersSent||(d.writeHead(400,{"Content-Type":"application/json"}),d.end(JSON.stringify({error:"Request aborted"})))}),h.on("data",E=>{if(!k){if(_+=E.length,_>a){k=!0,d.writeHead(413,{"Content-Type":"application/json"}),d.end(JSON.stringify({error:"Payload too large"})),h.destroy?.();return}w.push(E)}}),h.on("end",()=>{if(!k)try{let E=Buffer.concat(w).toString("utf-8"),D=E.length>0?n(E):void 0;i.update(V=>V+1);let M=!1,O=null,te={body:D,get responded(){return M},respond(V,ne=200){M||(M=!0,O!==null&&(clearTimeout(O),m.delete(O),O=null),d.writeHead(ne,{"Content-Type":"application/json"}),d.end(JSON.stringify(V)))}};O=setTimeout(()=>{m.delete(O),O=null,M||(M=!0,d.writeHead(504,{"Content-Type":"application/json"}),d.end(JSON.stringify({error:"Response timeout"})))},l),m.add(O),c?.(te)}catch(E){d.writeHead(400,{"Content-Type":"application/json"}),d.end(JSON.stringify({error:E?.message??"Parse error"}))}})}function T(){return e?.port?g?Promise.reject(new Error("fromWebhook: already listening. Call close() first.")):new Promise((h,d)=>{try{g=require("http").createServer(y),g.once("listening",()=>h()),g.once("error",S=>{g=null,d(S)}),g.listen(e.port,o)}catch(p){d(p)}}):Promise.reject(new Error("fromWebhook: port is required for listen()"))}function x(){for(let h of m)clearTimeout(h);m.clear(),g?.close(),g=null}return{get:()=>u.get(),source:(h,d)=>u.source(h,d),status:u.status,error:u.error,requestCount:i,handler:y,listen:T,close:x}}function We(e,t){let n=t?.name??"websocket",r=t?.parse??(S=>S),o=t?.reconnect??!1,a=t?.onParseError??"warn",l=v("connecting",{name:`${n}:connectionState`,equals:()=>!1}),i=null,c=null,f=null,s=null,u=null,g=!1,m=null,y=[];function T(){for(;y.length>0&&i?.readyState===WebSocket.OPEN;)i.send(y.shift())}function x(){g=!1,l.set("connecting");try{i=new WebSocket(e,t?.protocols)}catch(S){l.set("closed"),f?.(S);return}i.onopen=()=>{l.set("open"),T()},i.onmessage=S=>{if(!h)try{let b=r(S.data);c?.(b)}catch(b){a==="error"?f?.(b):a==="warn"&&console.warn(`[${n}] parse error:`,b)}},i.onerror=()=>{m=new Error(`WebSocket error on ${e}`)},i.onclose=()=>{l.set("closed"),i=null;let S=m;m=null,!g&&o!==!1?u=setTimeout(()=>{u=null,c&&x()},o):S&&!g?f?.(S):s?.()}}let h=!1,d=B(({emit:S,error:b,complete:w,onSignal:_})=>(c=S,f=b,s=w,h=!1,x(),_(k=>{k===K?h=!0:k===z?h=!1:k===j&&(h=!1,y.length=0,u!==null&&(clearTimeout(u),u=null),i&&(g=!0,i.onopen=null,i.onmessage=null,i.onerror=null,i.onclose=null,i.close(),i=null),l.set("closed"),x())}),()=>{c=null,f=null,s=null,h=!1,g=!0,y.length=0,u!==null&&(clearTimeout(u),u=null),i&&(i.onopen=null,i.onmessage=null,i.onerror=null,i.onclose=null,i.close(),i=null),l.set("closed")}),{name:n,kind:"websocket"});A.register(d,{kind:"websocket"});let p=Q(d);return{get:()=>p.get(),source:(S,b)=>p.source(S,b),status:p.status,error:p.error,connectionState:l,send(S){i?.readyState===WebSocket.OPEN?i.send(S):y.push(S)},close(S,b){g=!0,y.length=0,u!==null&&(clearTimeout(u),u=null),i?.close(S,b)}}}function Ie(e,t,n){let r=l=>typeof l=="string"?l:JSON.stringify(l),o=n?.serialize??r,a="send"in e&&typeof e.send=="function"?e.send.bind(e):null;if(!a)throw new Error("toWebSocket: invalid WebSocket target");return G(t,l=>{try{let i=o(l);a(i)}catch{}})}0&&(module.exports={fromHTTP,fromLLM,fromMCP,fromWebSocket,fromWebhook,toSSE,toWebSocket});
|
package/dist/adapters/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"../chunk-
|
|
1
|
+
import{a as o}from"../chunk-RWZ3CCF6.js";import{a as e}from"../chunk-U5WIJOXK.js";import{a as t}from"../chunk-RX4JY356.js";import{a as r}from"../chunk-EXDWEL6X.js";import{a as p}from"../chunk-UA3L7KUP.js";import{a as m,b as S}from"../chunk-CZBLKO6T.js";import"../chunk-S2U5T7BO.js";import"../chunk-GMLWTZFM.js";import"../chunk-7FX2AO6N.js";import"../chunk-VFN2CV32.js";import"../chunk-SOIVZBGE.js";import"../chunk-TUPD47IE.js";import"../chunk-I7AUKTXE.js";export{o as fromHTTP,e as fromLLM,t as fromMCP,m as fromWebSocket,p as fromWebhook,r as toSSE,S as toWebSocket};
|
package/dist/adapters/llm.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var B=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var
|
|
2
|
-
`)}static _observe(
|
|
3
|
-
`)}static toD2(
|
|
4
|
-
`)}static annotate(
|
|
5
|
-
`);q=ne.pop()??"";for(let ye of ne){if(
|
|
1
|
+
"use strict";var B=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var Ee=Object.prototype.hasOwnProperty;var De=(t,e)=>{for(var n in e)B(t,n,{get:e[n],enumerable:!0})},ke=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of be(e))!Ee.call(t,i)&&i!==n&&B(t,i,{get:()=>e[i],enumerable:!(s=ve(e,i))||s.enumerable});return t};var Le=t=>ke(B({},"__esModule",{value:!0}),t);var Ye={};De(Ye,{fromLLM:()=>Ue});module.exports=Le(Ye);var T=Symbol("DIRTY"),O=Symbol("RESOLVED"),ae=Symbol("SINGLE_DEP"),U=Symbol("RESET"),xe=Symbol("PAUSE"),Re=Symbol("RESUME"),Z=Symbol("TEARDOWN");function ce(t){return t===U||t===xe||t===Re||t===Z}var le=0,ue=1,fe=2,de=3,ge=4,pe=5,b=7,Q=7<<b,we=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function he(t){return we[(t&Q)>>>b]}var _=0,m=1,p=2,y=3,C=0,j=[],J=!1;function K(t){C++;try{return t()}finally{if(C--,C===0&&!J){J=!0;for(let e=0;e<j.length;e++)j[e]();j.length=0,J=!1}}}function F(){return C>0}function W(t){j.push(t)}var Ae=0,$e=[];function _e(t){Ae>0?$e.push(t):t()}var R=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 s=e.map(i=>t._names.get(i)??"?").join(",");return s.length>40?`${s.slice(0,37)}...`:s}static _resolveKey(e){let n=t._keys.get(e)??t._names.get(e);if(n)return n;let s=`anonymous_${t._nextId++}`;return t._keys.set(e,s),s}static register(e,n){if(!t.enabled)return;n?.name&&t._names.set(e,n.name),n?.kind&&t._kinds.set(e,n.kind);let s=t._nextId++,i=n?.name;if(!(i&&!t._usedKeys.has(i)))if(i){let o=t._depSuffix(n?.deps);i=o?`${i}(${o})`:`${i}_${s}`,t._usedKeys.has(i)&&(i=`${i}_${s}`)}else{let o=n?.kind??"store",a=t._depSuffix(n?.deps);i=a?`${o}(${a})`:`${o}_${s}`,t._usedKeys.has(i)&&(i=`${i}_${s}`)}t._usedKeys.add(i),t._keys.set(e,i),t._stores.add(new WeakRef(e))}static registerEdge(e,n){if(!t.enabled)return;let s=t._resolveKey(e),i=t._resolveKey(n),o=t._edges.get(s);o?o.includes(i)||o.push(i):t._edges.set(s,[i])}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,n=new Set;for(let s of t._stores){let i=s.deref();if(!i){t._stores.delete(s);continue}let o=t._resolveKey(i);n.add(o),e.set(o,t.inspect(i))}for(let[s,i]of t._edges){if(!n.has(s)){t._edges.delete(s),t._usedKeys.delete(s);continue}let o=i.filter(a=>n.has(a));o.length===0?t._edges.delete(s):o.length!==i.length&&t._edges.set(s,o)}return e}static trace(e,n){let s=null,i=e.get();return e.source(_,(o,a)=>{if(o===_&&(s=a),o===p){s=null;return}if(o===1){let l=a;if(!Object.is(l,i)){let c=i;i=l,n(l,c)}}}),()=>s?.(p)}static dumpGraph(){let e=t.graph(),n=t.getEdges(),s=new Map;for(let[a,l]of n)for(let c of l){let f=s.get(c);f?f.includes(a)||f.push(a):s.set(c,[a])}let i=[];for(let[a,l]of e){let c=s.get(a),f=n.get(a),r=c?.length?` \u2190 [${c.join(", ")}]`:"",u=f?.length?` \u2192 [${f.join(", ")}]`:"";i.push(` ${a} (${l.kind}) = ${JSON.stringify(l.value)} [${l.status??"?"}]${r}${u}`)}return[`Store Graph (${e.size} nodes):`,...i].join(`
|
|
2
|
+
`)}static _signalLabel(e){return e===T?"DIRTY":e===O?"RESOLVED":typeof e=="symbol"?e.description??String(e):String(e)}static _observe(e,n,s){let i=null,o=!1,a=n??t.getName(e),l=[],c={values:[],signals:[],events:[],ended:!1,endError:void 0,get completedCleanly(){return c.ended&&!o},get errored(){return c.ended&&o},dirtyCount:0,resolvedCount:0,name:a,get eventLog(){return l},dispose:()=>i?.(p),reconnect:()=>(i?.(p),t._observe(e,n,s))};return e.source(_,(f,r)=>{if(f===_){i=r;return}f===m?(c.values.push(r),c.events.push({type:"data",data:r}),l.push(r),s&&s(`[${a}] DATA:`,r)):f===y?(c.signals.push(r),c.events.push({type:"signal",data:r}),l.push(t._signalLabel(r)),r===T?c.dirtyCount++:r===O&&c.resolvedCount++,s&&s(`[${a}] STATE:`,r)):f===p&&(c.ended=!0,c.endError=r,o=r!==void 0,c.events.push({type:"end",data:r}),l.push(o?["END",r]:"END"),s&&s(`[${a}] END`,r!==void 0?r:""),i=null)}),c}static observe(e){return t._observe(e)}static activate(e){let n=null;return e.source(_,(s,i)=>{s===_&&(n=i),s===p&&(n=null)}),()=>n?.(p)}static tap(e,n){let s=n??`tap(${t.getName(e)??"anon"})`,i={get:()=>e.get(),source:e.source};return t.register(i,{name:s,kind:"tap"}),t.registerEdge(e,i),i}static spy(e,n){let s=n?.name??t.getName(e)??"spy",i=n?.log??console.log;return t._observe(e,s,i)}static snapshot(){let e=t.graph(),n=t.getEdges(),s=new Map;for(let a of t._stores){let l=a.deref();if(!l)continue;let c=t._annotations.get(l);c!==void 0&&s.set(t._resolveKey(l),c)}let i=[];for(let[a,l]of e){let c={name:a,kind:l.kind,value:l.value,status:l.status},f=s.get(a);f!==void 0&&(c.annotation=f),i.push(c)}let o=[];for(let[a,l]of n)for(let c of l)o.push({from:a,to:c});return{nodes:i,edges:o,trace:t.traceLog()}}static toMermaid(e){let n=e?.direction??"TD",s=t.snapshot(),i=[`graph ${n}`],o={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},a=new Map;function l(r){let u=r.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(u);return d===void 0?(a.set(u,1),u):(a.set(u,d+1),`${u}__${d}`)}let c=new Map;function f(r){let u=JSON.stringify(r);return u&&u.length>30?`${u.slice(0,27)}...`:u??"undefined"}for(let r of s.nodes){let u=l(r.name);c.set(r.name,u);let d=`${r.name} (${r.kind}) = ${f(r.value)}`,$=o[r.status??""]??"";i.push(` ${u}["${d}"]${$}`)}for(let r of s.edges){let u=c.get(r.from)??l(r.from),d=c.get(r.to)??l(r.to);i.push(` ${u} --> ${d}`)}return i.push(""),i.push(" classDef settled fill:#d4edda,stroke:#28a745"),i.push(" classDef dirty fill:#fff3cd,stroke:#ffc107"),i.push(" classDef errored fill:#f8d7da,stroke:#dc3545"),i.push(" classDef completed fill:#cce5ff,stroke:#007bff"),i.join(`
|
|
3
|
+
`)}static toD2(e){let n=e?.direction??"down",s=t.snapshot(),i=[`direction: ${n}`,""],o={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},a=new Map;function l(r){let u=r.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(u);return d===void 0?(a.set(u,1),u):(a.set(u,d+1),`${u}__${d}`)}let c=new Map;function f(r){let u=JSON.stringify(r);return u&&u.length>30?`${u.slice(0,27)}...`:u??"undefined"}for(let r of s.nodes){let u=l(r.name);c.set(r.name,u);let d=o[r.kind]??"rectangle",$=`${r.name} (${r.kind}) = ${f(r.value)}`,L=r.status?` [${r.status}]`:"";i.push(`${u}: "${$}${L}" { shape: ${d} }`)}s.edges.length>0&&i.push("");for(let r of s.edges){let u=c.get(r.from)??l(r.from),d=c.get(r.to)??l(r.to);i.push(`${u} -> ${d}`)}return i.join(`
|
|
4
|
+
`)}static annotate(e,n){if(!t.enabled)return;t._annotations.set(e,n);let s={node:t._resolveKey(e),reason:n,timestamp:Date.now()},i=t.maxTraceEntries;i<=0||(t._traceLog.length<i?t._traceLog.push(s):(t._traceLog[t._traceHead]=s,t._traceFull=!0),t._traceHead=(t._traceHead+1)%i)}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 _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 Y=1,S=64,h=2,w=4,Se=8,Te=16,k=32,v=1024,g=Q,A=ue<<b,M=fe<<b,V=le<<b,Oe=ge<<b,Me=pe<<b,Ie=de<<b,G=class{_value;_output=null;_flags;get _status(){return he(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;_onLifecycleSignal;constructor(e,n){this._value=n?.initial,this._fn=e,this._eqFn=n?.equals,this._getterFn=n?.getter,this._initial=n?.initial;let s=0;n?.autoDirty!==!1&&(s|=w),n?.resetOnTeardown&&(s|=Se),n?.resubscribable&&(s|=Te),this._flags=s,this.source=this.source.bind(this),this.emit=this.emit.bind(this),n?._skipInspect||R.register(this,{kind:"producer",...n})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(e,n){let s=this._output;if(s)if(this._flags&S)for(let i of s)i(e,n);else s(e,n)}emit(e){this._flags&h||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&(F()?this._flags&k||(this._flags|=k,this._flags&w&&(this._flags=this._flags&~g|A,this._dispatch(y,T)),W(()=>{this._flags&=~k,this._flags=this._flags&~g|M,this._dispatch(m,this._value)})):(this._flags&w&&!(this._flags&v)&&(this._flags=this._flags&~g|A,this._dispatch(y,T)),this._flags=this._flags&~g|M,this._dispatch(m,this._value))))}signal(e){this._flags&h||!this._output||(e===T?this._flags=this._flags&~g|A:e===O&&(this._flags=this._flags&~g|Ie),this._dispatch(y,e))}complete(){if(this._flags&h)return;this._flags=(this._flags|h)&~g|Oe;let e=this._output,n=this._flags&S;if(this._output=null,this._flags&=~(S|v),this._singleDepCount=0,this._stop(),e)if(n)for(let s of e)s(p);else e(p)}error(e){if(this._flags&h)return;this._flags=(this._flags|h)&~g|Me;let n=this._output,s=this._flags&S;if(this._output=null,this._flags&=~(S|v),this._singleDepCount=0,this._stop(),n)if(s)for(let i of n)i(p,e);else n(p,e)}_start(){if(this._flags&Y||!this._fn)return;this._flags|=Y,this._onLifecycleSignal=void 0;let e=this._fn({emit:this.emit,signal:n=>this.signal(n),complete:()=>this.complete(),error:n=>this.error(n),onSignal:n=>{this._onLifecycleSignal=n}});this._cleanup=typeof e=="function"?e:void 0}_stop(){this._flags&Y&&(this._flags&=~Y,this._onLifecycleSignal=void 0,this._cleanup&&this._cleanup(),this._cleanup=void 0,this._flags&Se&&(this._value=this._initial),this._flags&h||(this._flags=this._flags&~g|V))}_handleLifecycleSignal(e){if(!(this._flags&h)){if(e===Z){this._onLifecycleSignal?.(e),this.complete();return}e===U&&(this._value=this._initial,this._flags&=~k),this._onLifecycleSignal?.(e),e===U&&this.emit(this._initial)}}source(e,n){if(e===_){let s=n;if(this._flags&h)if(this._flags&Te&&this._output===null)this._flags=this._flags&~(h|g)|V;else{s(_,o=>{}),s(p);return}if(this._output===null)this._output=s;else if(this._flags&S)this._output.add(s);else{let o=new Set;o.add(this._output),o.add(s),this._output=o,this._flags=(this._flags|S)&~v}let i=!1;s(_,(o,a)=>{if(o===m&&s(m,this._value),o===y){a===ae&&!i?(i=!0,this._singleDepCount++,this._flags&S||(this._flags|=v)):ce(a)&&this._handleLifecycleSignal(a);return}if(o===p){if(i&&(i=!1,this._singleDepCount--),this._output===null)return;if(this._flags&S){let l=this._output;l.delete(s),l.size===1?(this._output=l.values().next().value,this._flags&=~S,this._singleDepCount>0&&(this._flags|=v)):l.size===0&&(this._output=null,this._flags&=~(S|v),this._singleDepCount=0,this._flags=this._flags&~g|V,this._stop())}else this._output===s&&(this._output=null,this._flags&=~v,this._singleDepCount=0,this._flags=this._flags&~g|V,this._stop())}}),_e(()=>this._start())}}};var X=class extends G{constructor(e,n){super(void 0,{initial:e,autoDirty:!0,equals:n?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),R.register(this,{kind:"state",...n})}get(){return this._value}set(e){this._flags&h||this._value!==void 0&&this._eqFn(this._value,e)||(this._value=e,this._output&&(F()?this._flags&k||(this._flags|=k,this._flags&w&&(this._flags=this._flags&~g|A,this._dispatch(y,T)),W(()=>{this._flags&=~k,this._flags=this._flags&~g|M,this._dispatch(m,this._value)})):(this._flags&w&&!(this._flags&v)&&(this._flags=this._flags&~g|A,this._dispatch(y,T)),this._flags=this._flags&~g|M,this._dispatch(m,this._value))))}update(e){this.set(e(this._value))}};function I(t,e){return new X(t,e)}function Pe(t){switch(t){case"openai":return"https://api.openai.com/v1";case"ollama":return"http://localhost:11434";default:return""}}function Ne(t,e){switch(t){case"openai":case"custom":return`${e}/chat/completions`;case"ollama":return`${e}/api/chat`;default:return`${e}/chat/completions`}}function Ce(t,e,n,s){let i={model:e,messages:n,stream:!0};return s?.temperature!==void 0&&(i.temperature=s.temperature),s?.maxTokens!==void 0&&(t==="ollama"?i.options={num_predict:s.maxTokens}:i.max_tokens=s.maxTokens),s?.stop&&(i.stop=s.stop),i}function je(t,e){let n={"Content-Type":"application/json"};return e&&(n.Authorization=`Bearer ${e}`),n}function Ue(t){let e=t.name??"llm",n=t.provider,s=t.baseURL??Pe(n),i=t.model??"",o=t.fetch??globalThis.fetch,a=I("",{name:`${e}.store`}),l=I({},{name:`${e}.tokens`}),c=I("pending",{name:`${e}.status`}),f=I(void 0,{name:`${e}.error`}),r=null;function u(){r&&(r.abort(),r=null),c.get()==="active"&&K(()=>{a.set(""),c.set("pending")})}function d(L,x){u(),r=new AbortController;let H=x?.signal?We(r.signal,x.signal):r.signal;K(()=>{a.set(""),l.set({}),f.set(void 0),c.set("active")});let E=Ne(n,s),D=Ce(n,i,L,x),P=je(n,t.apiKey);$(E,P,D,H).catch(()=>{})}async function $(L,x,H,E){try{let D=await o(L,{method:"POST",headers:x,body:JSON.stringify(H),signal:E});if(!D.ok){let z=await D.text().catch(()=>"");throw new Error(`LLM API error ${D.status}: ${z}`)}let P=D.body?.getReader();if(!P)throw new Error("No response body");let ee=new TextDecoder,te="",q="";for(;;){if(E.aborted)return;let{done:z,value:me}=await P.read();if(z)break;q+=ee.decode(me,{stream:!0});let ne=q.split(`
|
|
5
|
+
`);q=ne.pop()??"";for(let ye of ne){if(E.aborted)return;let N=ye.trim();if(!N||N.startsWith(":")||!N.startsWith("data: "))continue;let se=N.slice(6);if(se!=="[DONE]")try{let ie=JSON.parse(se),re=Ke(n,ie);re&&(te+=re,a.set(te));let oe=Fe(n,ie);oe&&l.set(oe)}catch{}}}if(ee.decode(),E.aborted)return;c.set("completed"),r=null}catch(D){if(E.aborted)return;K(()=>{f.set(D),c.set("errored")}),r=null}finally{E._cleanup?.()}}return{get:()=>a.get(),source:(L,x)=>a.source(L,x),tokens:l,status:c,error:f,generate:d,abort:u}}function Ke(t,e){return t==="ollama"?e?.message?.content:e?.choices?.[0]?.delta?.content}function Fe(t,e){let n=t==="ollama"?e:e?.usage;if(n){if(t==="ollama")return e.eval_count!==void 0||e.prompt_eval_count!==void 0?{promptTokens:e.prompt_eval_count,completionTokens:e.eval_count,totalTokens:(e.prompt_eval_count??0)+(e.eval_count??0)}:void 0;if(n.prompt_tokens!==void 0||n.completion_tokens!==void 0)return{promptTokens:n.prompt_tokens,completionTokens:n.completion_tokens,totalTokens:n.total_tokens}}}function We(t,e){let n=new AbortController,s=()=>{t.removeEventListener("abort",i),e.removeEventListener("abort",i)},i=()=>{n.abort(),s()};t.addEventListener("abort",i,{once:!0}),e.addEventListener("abort",i,{once:!0});let o=n.signal;return o._cleanup=s,o}0&&(module.exports={fromLLM});
|
package/dist/adapters/llm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-U5WIJOXK.js";import"../chunk-7FX2AO6N.js";import"../chunk-VFN2CV32.js";import"../chunk-SOIVZBGE.js";import"../chunk-TUPD47IE.js";import"../chunk-I7AUKTXE.js";export{a as fromLLM};
|
package/dist/adapters/mcp.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var Z=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var me=(e,t)=>{for(var i in t)Z(e,i,{get:t[i],enumerable:!0})},ye=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Te(t))!Se.call(e,s)&&s!==i&&Z(e,s,{get:()=>t[s],enumerable:!(n=_e(t,s))||n.enumerable});return e};var Ee=e=>ye(Z({},"__esModule",{value:!0}),e);var
|
|
2
|
-
`)}static _observe(t,i,n){let s=null,o=i??e.getName(t),
|
|
3
|
-
`)}static toD2(t){let i=t?.direction??"down",n=e.snapshot(),s=[`direction: ${i}`,""],o={state:"rectangle",derived:"hexagon",effect:"oval",producer:"rectangle",operator:"parallelogram","pipeline-step":"rectangle","pipeline-status":"diamond",checkpoint:"cylinder"},
|
|
4
|
-
`)}static annotate(t,i){if(!e.enabled)return;e._annotations.set(t,i);let n={node:e._resolveKey(t),reason:i,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 _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,
|
|
5
|
-
`),he=new Error(
|
|
1
|
+
"use strict";var Z=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var me=(e,t)=>{for(var i in t)Z(e,i,{get:t[i],enumerable:!0})},ye=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Te(t))!Se.call(e,s)&&s!==i&&Z(e,s,{get:()=>t[s],enumerable:!(n=_e(t,s))||n.enumerable});return e};var Ee=e=>ye(Z({},"__esModule",{value:!0}),e);var Ae={};me(Ae,{fromMCP:()=>Pe});module.exports=Ee(Ae);var S=Symbol("DIRTY"),$=Symbol("RESOLVED"),ne=Symbol("SINGLE_DEP"),U=Symbol("RESET"),ve=Symbol("PAUSE"),be=Symbol("RESUME"),X=Symbol("TEARDOWN");function se(e){return e===U||e===ve||e===be||e===X}var ie=0,re=1,oe=2,ae=3,le=4,ce=5,b=7,ee=7<<b,De=["DISCONNECTED","DIRTY","SETTLED","RESOLVED","COMPLETED","ERRORED"];function ue(e){return De[(e&ee)>>>b]}var _=0,m=1,p=2,y=3,W=0,Y=[],Q=!1;function O(e){W++;try{return e()}finally{if(W--,W===0&&!Q){Q=!0;for(let t=0;t<Y.length;t++)Y[t]();Y.length=0,Q=!1}}}function V(){return W>0}function H(e){Y.push(e)}var Re=0,ke=[];function fe(e){Re>0?ke.push(e):e()}var w=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 i=e._keys.get(t)??e._names.get(t);if(i)return i;let n=`anonymous_${e._nextId++}`;return e._keys.set(t,n),n}static register(t,i){if(!e.enabled)return;i?.name&&e._names.set(t,i.name),i?.kind&&e._kinds.set(t,i.kind);let n=e._nextId++,s=i?.name;if(!(s&&!e._usedKeys.has(s)))if(s){let o=e._depSuffix(i?.deps);s=o?`${s}(${o})`:`${s}_${n}`,e._usedKeys.has(s)&&(s=`${s}_${n}`)}else{let o=i?.kind??"store",a=e._depSuffix(i?.deps);s=a?`${o}(${a})`:`${o}_${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,i){if(!e.enabled)return;let n=e._resolveKey(t),s=e._resolveKey(i),o=e._edges.get(n);o?o.includes(s)||o.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,i=new Set;for(let n of e._stores){let s=n.deref();if(!s){e._stores.delete(n);continue}let o=e._resolveKey(s);i.add(o),t.set(o,e.inspect(s))}for(let[n,s]of e._edges){if(!i.has(n)){e._edges.delete(n),e._usedKeys.delete(n);continue}let o=s.filter(a=>i.has(a));o.length===0?e._edges.delete(n):o.length!==s.length&&e._edges.set(n,o)}return t}static trace(t,i){let n=null,s=t.get();return t.source(_,(o,a)=>{if(o===_&&(n=a),o===p){n=null;return}if(o===1){let l=a;if(!Object.is(l,s)){let c=s;s=l,i(l,c)}}}),()=>n?.(p)}static dumpGraph(){let t=e.graph(),i=e.getEdges(),n=new Map;for(let[a,l]of i)for(let c of l){let f=n.get(c);f?f.includes(a)||f.push(a):n.set(c,[a])}let s=[];for(let[a,l]of t){let c=n.get(a),f=i.get(a),r=c?.length?` \u2190 [${c.join(", ")}]`:"",u=f?.length?` \u2192 [${f.join(", ")}]`:"";s.push(` ${a} (${l.kind}) = ${JSON.stringify(l.value)} [${l.status??"?"}]${r}${u}`)}return[`Store Graph (${t.size} nodes):`,...s].join(`
|
|
2
|
+
`)}static _signalLabel(t){return t===S?"DIRTY":t===$?"RESOLVED":typeof t=="symbol"?t.description??String(t):String(t)}static _observe(t,i,n){let s=null,o=!1,a=i??e.getName(t),l=[],c={values:[],signals:[],events:[],ended:!1,endError:void 0,get completedCleanly(){return c.ended&&!o},get errored(){return c.ended&&o},dirtyCount:0,resolvedCount:0,name:a,get eventLog(){return l},dispose:()=>s?.(p),reconnect:()=>(s?.(p),e._observe(t,i,n))};return t.source(_,(f,r)=>{if(f===_){s=r;return}f===m?(c.values.push(r),c.events.push({type:"data",data:r}),l.push(r),n&&n(`[${a}] DATA:`,r)):f===y?(c.signals.push(r),c.events.push({type:"signal",data:r}),l.push(e._signalLabel(r)),r===S?c.dirtyCount++:r===$&&c.resolvedCount++,n&&n(`[${a}] STATE:`,r)):f===p&&(c.ended=!0,c.endError=r,o=r!==void 0,c.events.push({type:"end",data:r}),l.push(o?["END",r]:"END"),n&&n(`[${a}] END`,r!==void 0?r:""),s=null)}),c}static observe(t){return e._observe(t)}static activate(t){let i=null;return t.source(_,(n,s)=>{n===_&&(i=s),n===p&&(i=null)}),()=>i?.(p)}static tap(t,i){let n=i??`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,i){let n=i?.name??e.getName(t)??"spy",s=i?.log??console.log;return e._observe(t,n,s)}static snapshot(){let t=e.graph(),i=e.getEdges(),n=new Map;for(let a of e._stores){let l=a.deref();if(!l)continue;let c=e._annotations.get(l);c!==void 0&&n.set(e._resolveKey(l),c)}let s=[];for(let[a,l]of t){let c={name:a,kind:l.kind,value:l.value,status:l.status},f=n.get(a);f!==void 0&&(c.annotation=f),s.push(c)}let o=[];for(let[a,l]of i)for(let c of l)o.push({from:a,to:c});return{nodes:s,edges:o,trace:e.traceLog()}}static toMermaid(t){let i=t?.direction??"TD",n=e.snapshot(),s=[`graph ${i}`],o={SETTLED:":::settled",DIRTY:":::dirty",ERRORED:":::errored",COMPLETED:":::completed"},a=new Map;function l(r){let u=r.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(u);return d===void 0?(a.set(u,1),u):(a.set(u,d+1),`${u}__${d}`)}let c=new Map;function f(r){let u=JSON.stringify(r);return u&&u.length>30?`${u.slice(0,27)}...`:u??"undefined"}for(let r of n.nodes){let u=l(r.name);c.set(r.name,u);let d=`${r.name} (${r.kind}) = ${f(r.value)}`,R=o[r.status??""]??"";s.push(` ${u}["${d}"]${R}`)}for(let r of n.edges){let u=c.get(r.from)??l(r.from),d=c.get(r.to)??l(r.to);s.push(` ${u} --> ${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 i=t?.direction??"down",n=e.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 l(r){let u=r.replace(/[^a-zA-Z0-9_]/g,"_"),d=a.get(u);return d===void 0?(a.set(u,1),u):(a.set(u,d+1),`${u}__${d}`)}let c=new Map;function f(r){let u=JSON.stringify(r);return u&&u.length>30?`${u.slice(0,27)}...`:u??"undefined"}for(let r of n.nodes){let u=l(r.name);c.set(r.name,u);let d=o[r.kind]??"rectangle",R=`${r.name} (${r.kind}) = ${f(r.value)}`,M=r.status?` [${r.status}]`:"";s.push(`${u}: "${R}${M}" { shape: ${d} }`)}n.edges.length>0&&s.push("");for(let r of n.edges){let u=c.get(r.from)??l(r.from),d=c.get(r.to)??l(r.to);s.push(`${u} -> ${d}`)}return s.join(`
|
|
4
|
+
`)}static annotate(t,i){if(!e.enabled)return;e._annotations.set(t,i);let n={node:e._resolveKey(t),reason:i,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 _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,T=64,h=2,L=4,de=8,ge=16,k=32,E=1024,g=ee,P=re<<b,I=oe<<b,G=ie<<b,xe=le<<b,we=ce<<b,Le=ae<<b,z=class{_value;_output=null;_flags;get _status(){return ue(this._flags)}_cleanup;_fn;_eqFn;_getterFn;_initial;_singleDepCount=0;_onLifecycleSignal;constructor(t,i){this._value=i?.initial,this._fn=t,this._eqFn=i?.equals,this._getterFn=i?.getter,this._initial=i?.initial;let n=0;i?.autoDirty!==!1&&(n|=L),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||w.register(this,{kind:"producer",...i})}get(){return this._getterFn?this._getterFn(this._value):this._value}_dispatch(t,i){let n=this._output;if(n)if(this._flags&T)for(let s of n)s(t,i);else n(t,i)}emit(t){this._flags&h||this._eqFn&&this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(V()?this._flags&k||(this._flags|=k,this._flags&L&&(this._flags=this._flags&~g|P,this._dispatch(y,S)),H(()=>{this._flags&=~k,this._flags=this._flags&~g|I,this._dispatch(m,this._value)})):(this._flags&L&&!(this._flags&E)&&(this._flags=this._flags&~g|P,this._dispatch(y,S)),this._flags=this._flags&~g|I,this._dispatch(m,this._value))))}signal(t){this._flags&h||!this._output||(t===S?this._flags=this._flags&~g|P:t===$&&(this._flags=this._flags&~g|Le),this._dispatch(y,t))}complete(){if(this._flags&h)return;this._flags=(this._flags|h)&~g|xe;let t=this._output,i=this._flags&T;if(this._output=null,this._flags&=~(T|E),this._singleDepCount=0,this._stop(),t)if(i)for(let n of t)n(p);else t(p)}error(t){if(this._flags&h)return;this._flags=(this._flags|h)&~g|we;let i=this._output,n=this._flags&T;if(this._output=null,this._flags&=~(T|E),this._singleDepCount=0,this._stop(),i)if(n)for(let s of i)s(p,t);else i(p,t)}_start(){if(this._flags&q||!this._fn)return;this._flags|=q,this._onLifecycleSignal=void 0;let t=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 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&de&&(this._value=this._initial),this._flags&h||(this._flags=this._flags&~g|G))}_handleLifecycleSignal(t){if(!(this._flags&h)){if(t===X){this._onLifecycleSignal?.(t),this.complete();return}t===U&&(this._value=this._initial,this._flags&=~k),this._onLifecycleSignal?.(t),t===U&&this.emit(this._initial)}}source(t,i){if(t===_){let n=i;if(this._flags&h)if(this._flags&ge&&this._output===null)this._flags=this._flags&~(h|g)|G;else{n(_,o=>{}),n(p);return}if(this._output===null)this._output=n;else if(this._flags&T)this._output.add(n);else{let o=new Set;o.add(this._output),o.add(n),this._output=o,this._flags=(this._flags|T)&~E}let s=!1;n(_,(o,a)=>{if(o===m&&n(m,this._value),o===y){a===ne&&!s?(s=!0,this._singleDepCount++,this._flags&T||(this._flags|=E)):se(a)&&this._handleLifecycleSignal(a);return}if(o===p){if(s&&(s=!1,this._singleDepCount--),this._output===null)return;if(this._flags&T){let l=this._output;l.delete(n),l.size===1?(this._output=l.values().next().value,this._flags&=~T,this._singleDepCount>0&&(this._flags|=E)):l.size===0&&(this._output=null,this._flags&=~(T|E),this._singleDepCount=0,this._flags=this._flags&~g|G,this._stop())}else this._output===n&&(this._output=null,this._flags&=~E,this._singleDepCount=0,this._flags=this._flags&~g|G,this._stop())}}),fe(()=>this._start())}}};var te=class extends z{constructor(t,i){super(void 0,{initial:t,autoDirty:!0,equals:i?.equals??Object.is,_skipInspect:!0}),this.set=this.set.bind(this),w.register(this,{kind:"state",...i})}get(){return this._value}set(t){this._flags&h||this._value!==void 0&&this._eqFn(this._value,t)||(this._value=t,this._output&&(V()?this._flags&k||(this._flags|=k,this._flags&L&&(this._flags=this._flags&~g|P,this._dispatch(y,S)),H(()=>{this._flags&=~k,this._flags=this._flags&~g|I,this._dispatch(m,this._value)})):(this._flags&L&&!(this._flags&E)&&(this._flags=this._flags&~g|P,this._dispatch(y,S)),this._flags=this._flags&~g|I,this._dispatch(m,this._value))))}update(t){this.set(t(this._value))}};function D(e,t){return new te(e,t)}function Pe(e){let t=e.name??"mcp",i=e.client,n=D([],{name:`${t}.tools`}),s=D([],{name:`${t}.resources`}),o=D(void 0,{name:`${t}.refreshError`});function a(f){o.set(f);let r=e.onRefreshError;if(r==="warn")console.warn(`[${t}] refresh error:`,f);else{if(r==="error")throw f;typeof r=="function"&&r(f)}}async function l(){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 c(f){let r=`${t}:${f}`,u=D(void 0,{name:`${r}.result`}),d=D("idle",{name:`${r}.status`}),R=D(void 0,{name:`${r}.error`}),M=D(void 0,{name:`${r}.lastArgs`}),C=D(void 0,{name:`${r}.duration`}),B=!1;async function pe(N){if(B)return;B=!0,O(()=>{M.set(N),R.set(void 0),d.set("active")});let j=Date.now();try{let x=await i.callTool({name:f,arguments:N}),K=Date.now()-j;if(x.isError){let v=x.content.filter(J=>J.type==="text").map(J=>J.text??"").join(`
|
|
5
|
+
`),he=new Error(v||"MCP tool returned error");O(()=>{C.set(K),R.set(he),d.set("errored")});return}let F=x.content.filter(v=>v.type==="text"),A;if(F.length===1){let v=F[0].text;if(v!==void 0)try{A=JSON.parse(v)}catch{A=v}}else F.length>1?A=F.map(v=>v.text??""):A=x.content;O(()=>{C.set(K),u.set(A),d.set("completed")})}catch(x){let K=Date.now()-j;O(()=>{C.set(K),R.set(x),d.set("errored")})}finally{B=!1}}return{get:()=>u.get(),source:(N,j)=>u.source(N,j),status:d,error:R,call:pe,lastArgs:M,duration:C}}return{tool:c,tools:n,resources:s,refresh:l,refreshError:o}}0&&(module.exports={fromMCP});
|
package/dist/adapters/mcp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-RX4JY356.js";import"../chunk-7FX2AO6N.js";import"../chunk-VFN2CV32.js";import"../chunk-SOIVZBGE.js";import"../chunk-TUPD47IE.js";import"../chunk-I7AUKTXE.js";export{a as fromMCP};
|