@graphrefly/graphrefly 0.40.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/{chunk-6XVD5TZV.js → chunk-2W553JJC.js} +1 -1
  2. package/dist/{chunk-WL6LFPJB.js → chunk-33N4TU3X.js} +1 -1
  3. package/dist/{chunk-RZJDIV2G.js → chunk-4MKL6Q3K.js} +1 -1
  4. package/dist/chunk-5B3JDG5F.js +1 -0
  5. package/dist/{chunk-K2Z7UENB.js → chunk-5QSXEMXG.js} +1 -1
  6. package/dist/{chunk-ECQRP2UT.js → chunk-5TEFC2ZX.js} +1 -1
  7. package/dist/{chunk-SVFKHUCW.js → chunk-5TOPVRN6.js} +1 -1
  8. package/dist/{chunk-XJLYLLIJ.js → chunk-5VEZLQFN.js} +1 -1
  9. package/dist/{chunk-32N3JALT.js → chunk-7PQLZMOG.js} +1 -1
  10. package/dist/{chunk-2QXRYP7Q.js → chunk-AI7QC7J6.js} +1 -1
  11. package/dist/{chunk-FHRBBHJN.js → chunk-AK5RHMC5.js} +1 -1
  12. package/dist/{chunk-B7LCDQEV.js → chunk-CGNOWGV6.js} +1 -1
  13. package/dist/{chunk-LCGAVGGV.js → chunk-CYOSWFT2.js} +1 -1
  14. package/dist/{chunk-VMF23LGB.js → chunk-EC2WNSZ7.js} +1 -1
  15. package/dist/{chunk-UWA6D7UF.js → chunk-ELAASRBT.js} +1 -1
  16. package/dist/{chunk-Z4F3DOWS.js → chunk-F7VUYPP6.js} +1 -1
  17. package/dist/{chunk-LYM4PBMV.js → chunk-G3M3IMEV.js} +1 -1
  18. package/dist/{chunk-SSCGRYJ2.js → chunk-GI4Q7PNY.js} +1 -1
  19. package/dist/{chunk-7Q4ZD3YW.js → chunk-H5SCWHWP.js} +1 -1
  20. package/dist/{chunk-6I726LZU.js → chunk-KNVCCBIU.js} +1 -1
  21. package/dist/{chunk-CKFQS2CJ.js → chunk-L77I47VU.js} +1 -1
  22. package/dist/{chunk-I2DEVPMU.js → chunk-M3FQSXEW.js} +1 -1
  23. package/dist/{chunk-WUT362QV.js → chunk-OLIKJUKI.js} +1 -1
  24. package/dist/{chunk-QSK3RRII.js → chunk-OV5AA6HJ.js} +1 -1
  25. package/dist/{chunk-2BX4NB34.js → chunk-POXANAJ6.js} +1 -1
  26. package/dist/chunk-RSMEXK53.js +43 -0
  27. package/dist/{chunk-MNZIKXK4.js → chunk-SC27WTSG.js} +1 -1
  28. package/dist/{chunk-YXDRGKXP.js → chunk-TT4C7DXW.js} +1 -1
  29. package/dist/{chunk-2DMKW2AD.js → chunk-UISPDFJ3.js} +1 -1
  30. package/dist/{chunk-J63M5U46.js → chunk-URJ2VFNC.js} +1 -1
  31. package/dist/{chunk-XW4YDF6G.js → chunk-VV62MIG4.js} +1 -1
  32. package/dist/{chunk-756D5TFD.js → chunk-VXPLLA4P.js} +1 -1
  33. package/dist/{chunk-PPUYQ66A.js → chunk-WZYB3JQS.js} +1 -1
  34. package/dist/{chunk-6VWBPSSY.js → chunk-X7QKTXXC.js} +1 -1
  35. package/dist/{chunk-JKBOIJ22.js → chunk-YQRN4CIV.js} +1 -1
  36. package/dist/chunk-Z6X7B6A4.js +61 -0
  37. package/dist/{chunk-N43XM7BM.js → chunk-ZAJ7J7TO.js} +1 -1
  38. package/dist/compat/index.js +1 -1
  39. package/dist/compat/nestjs/index.js +1 -1
  40. package/dist/compat/zustand/index.js +1 -1
  41. package/dist/extra/index.js +1 -1
  42. package/dist/extra/node.js +1 -1
  43. package/dist/extra/operators.js +1 -1
  44. package/dist/extra/reactive.js +1 -1
  45. package/dist/extra/sources.js +1 -1
  46. package/dist/graph/index.js +1 -1
  47. package/dist/{index-IUCY0OFN.d.ts → index-CG33HeBW.d.ts} +17 -2
  48. package/dist/{index-BTHOTC0Q.d.cts → index-DGD4_fj6.d.cts} +17 -2
  49. package/dist/{index-D1IEZUsj.d.ts → index-DfOK_oL5.d.ts} +204 -199
  50. package/dist/{index-DJ_MPOJ5.d.cts → index-DuRsN9ae.d.cts} +204 -199
  51. package/dist/index.cjs +46 -46
  52. package/dist/index.d.cts +2 -2
  53. package/dist/index.d.ts +2 -2
  54. package/dist/index.js +1 -1
  55. package/dist/patterns/ai/browser.js +1 -1
  56. package/dist/patterns/ai/index.cjs +11 -11
  57. package/dist/patterns/ai/index.js +1 -1
  58. package/dist/patterns/ai/node.js +1 -1
  59. package/dist/patterns/audit/index.js +1 -1
  60. package/dist/patterns/cqrs/index.js +1 -1
  61. package/dist/patterns/demo-shell/index.js +1 -1
  62. package/dist/patterns/domain-templates/index.js +1 -1
  63. package/dist/patterns/graphspec/index.js +1 -1
  64. package/dist/patterns/guarded-execution/index.js +1 -1
  65. package/dist/patterns/harness/index.cjs +8 -8
  66. package/dist/patterns/harness/index.d.cts +4 -4
  67. package/dist/patterns/harness/index.d.ts +4 -4
  68. package/dist/patterns/harness/index.js +1 -1
  69. package/dist/patterns/job-queue/index.cjs +3 -3
  70. package/dist/patterns/job-queue/index.d.cts +1 -1
  71. package/dist/patterns/job-queue/index.d.ts +1 -1
  72. package/dist/patterns/job-queue/index.js +1 -1
  73. package/dist/patterns/lens/index.js +1 -1
  74. package/dist/patterns/memory/index.js +1 -1
  75. package/dist/patterns/messaging/index.js +1 -1
  76. package/dist/patterns/orchestration/index.js +1 -1
  77. package/dist/patterns/process/index.js +1 -1
  78. package/dist/patterns/reactive-layout/index.js +1 -1
  79. package/dist/patterns/reduction/index.js +1 -1
  80. package/dist/patterns/refine-loop/index.js +1 -1
  81. package/dist/patterns/resilient-pipeline/index.js +1 -1
  82. package/dist/patterns/surface/index.js +1 -1
  83. package/dist/{resilience-S33JV6XC.js → resilience-JISHQD2F.js} +1 -1
  84. package/package.json +1 -1
  85. package/dist/chunk-INQFTVZA.js +0 -61
  86. package/dist/chunk-OSZ22J7O.js +0 -1
  87. package/dist/chunk-YKD7WUYJ.js +0 -43
@@ -1 +1 @@
1
- import{a as M}from"./chunk-L6NSJVJZ.js";import{i as l}from"./chunk-2BX4NB34.js";import{b as S}from"./chunk-YXDRGKXP.js";import{C as o}from"./chunk-CKFQS2CJ.js";import{D as P,E as v,G as _,m as N}from"./chunk-LYCLF26R.js";import{b as L,i as I}from"./chunk-CK2E7BTU.js";import{b as C}from"./chunk-QYADASLV.js";var U={};C(U,{MessagingHubGraph:()=>w,SubscriptionGraph:()=>T,TopicBridgeGraph:()=>y,TopicGraph:()=>m,TopicRegistry:()=>O,messagingHub:()=>H,subscription:()=>D,topic:()=>z,topicBridge:()=>F});var R=256;function c(i,e){if(!Number.isFinite(i)||!Number.isInteger(i)||i<0)throw new Error(`${e} must be a non-negative integer`);return i}function a(i,e){return M("messaging",i,e)}var B=1024,m=class extends l{_log;events;latest;hasLatest;constructor(e,s={}){super(e,s.graph),this._log=S([],{name:"events",maxSize:s.retainedLimit??B}),this._log.withLatest(),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=_([this.events],([t])=>{let n=t;return n.length===0?null:n[n.length-1]},{name:"latest",describeKind:"derived",meta:a("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(o(this.latest)),this.hasLatest=_([this.events],([t])=>t.length>0,{name:"hasLatest",describeKind:"derived",meta:a("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(o(this.hasLatest)),this.addDisposer(()=>{this.events.down([[I]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(e){if(e===void 0)throw new TypeError(`TopicGraph "${this.name}": publish(undefined) is not allowed (spec \xA75.12 SENTINEL).`);this._log.append(e)}attachEventStorage(e){return this._log.attachStorage(e)}retained(){return this.events.cache}get _logBundle(){return this._log}},T=class extends l{cursor;available;topic;_disposed=!1;constructor(e,s,t={}){super(e,t.graph),this.topic=s;let n;if(t.from!==void 0?t.from==="retained"?n=0:t.from==="now"?n=s.events.cache.length:n=c(t.from,"subscription from"):n=c(t.cursor??0,"subscription cursor"),this.cursor=v(n,{name:"cursor",describeKind:"state",meta:a("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=s._logBundle.view({kind:"fromCursor",cursor:this.cursor}),this.add(this.available,{name:"available"}),this.addDisposer(o(this.available)),t.advanceOn!==void 0){let r=t.advanceOn,b=!1,d=P([r],()=>{if(!b){b=!0;return}if(this._disposed)return;let p=this.available.cache;if(p.length===0)return;let g=this.cursor.cache+p.length;this.cursor.emit(g)},{name:"advancePump",describeKind:"effect",meta:a("subscription_advance_pump")});this.add(d,{name:"advancePump"}),this.addDisposer(o(d))}}ack(e){if(this._disposed)return this.cursor.cache;let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription ack count"),n=Math.min(t,s.length);if(n<=0)return this.cursor.cache;let r=this.cursor.cache+n;return this.cursor.emit(r),r}pull(e){if(this._disposed)return[];let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription pull limit");return s.slice(0,t)}pullAndAck(e){if(this._disposed)return{items:[],cursor:this.cursor.cache};let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription pullAndAck limit"),n=s.slice(0,t);if(n.length===0)return{items:n,cursor:this.cursor.cache};let r=this.cursor.cache+n.length;return this.cursor.emit(r),{items:n,cursor:r}}dispose(){this._disposed||(this._disposed=!0,this.cursor.down([[I]]),this.destroy())}},y=class extends l{_sourceSub;bridgedCount;output;constructor(e,s,t,n={}){super(e,n.graph),this._sourceSub=D(`${e}-subscription`,s,{cursor:n.cursor}),this.mount("subscription",this._sourceSub);let r=Math.max(1,c(n.maxPerPump??R,"topic bridge maxPerPump")),b=n.map??(u=>u);this.output=_([this._sourceSub.available],([u])=>{let f=u,h=[],k=Math.min(f.length,r);for(let x=0;x<k;x++){let A=b(f[x]);A!==void 0&&h.push(A)}return h},{name:"output",describeKind:"derived",meta:a("topic_bridge_output",{targetRef:t.name}),initial:[]}),this.add(this.output,{name:"output"}),this.addDisposer(o(this.output)),this.bridgedCount=v(0,{name:"bridgedCount",describeKind:"state",meta:a("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"}),this.addDisposer(o(this.bridgedCount));let d=this.output,p=this._sourceSub,g=this.bridgedCount,G=P([d],()=>{let u=d.cache;if(u.length===0)return;let f=p.available.cache.length,h=Math.min(f,r);if(h>0){p.ack(h);let k=g.cache??0;g.emit(k+u.length)}},{name:"ackPump",describeKind:"effect",meta:a("topic_bridge_ack_pump")});this.add(G,{name:"ackPump"}),this.addDisposer(o(G));let E=K(this.output,t);this.addDisposer(E)}};function K(i,e){return i.subscribe(s=>{for(let t of s){if(t[0]!==L)continue;let n=t[1];n.length!==0&&N(()=>{for(let r of n)e.publish(r)})}})}var O=class{_map=new Map;version;constructor(e){this.version=e}get size(){return this._map.size}has(e){return this._map.has(e)}get(e){return this._map.get(e)}set(e,s){this._map.set(e,s)}delete(e){return this._map.delete(e)}keys(){return this._map.keys()}},w=class extends l{_registry;version;_defaultTopicOptions;constructor(e,s={}){super(e,s.graph);let t=v(0,{name:"version",describeKind:"state",meta:a("hub_version")});this.add(t,{name:"version"}),this.version=t,this._registry=new O(t),this._defaultTopicOptions={...s.defaultTopicOptions??{}}}get size(){return this._registry.size}has(e){return this._registry.has(e)}topicNames(){return this._registry.keys()}topic(e,s){let t=this._registry.get(e);if(t===void 0){let n={...this._defaultTopicOptions,...s??{}};t=new m(e,n),this._registry.set(e,t),this.mount(e,t);let r=this.version.cache??0;this.version.emit(r+1)}return t}publish(e,s){this.topic(e).publish(s)}publishMany(e){N(()=>{for(let[s,t]of e)this.topic(s).publish(t)})}subscribe(e,s,t){let n=this.topic(s);return new T(e,n,t)}removeTopic(e){if(!this._registry.has(e))return!1;try{this.remove(e)}finally{this._registry.delete(e);let s=this.version.cache??0;this.version.emit(s+1)}return!0}};function z(i,e){return new m(i,e)}function H(i,e){return new w(i,e)}function D(i,e,s){return new T(i,e,s)}function F(i,e,s,t){return new y(i,e,s,t)}export{m as a,T as b,y as c,O as d,w as e,z as f,H as g,D as h,F as i,U as j};
1
+ import{a as M}from"./chunk-L6NSJVJZ.js";import{b as S}from"./chunk-TT4C7DXW.js";import{i as l}from"./chunk-POXANAJ6.js";import{C as o}from"./chunk-L77I47VU.js";import{D as P,E as v,G as _,m as N}from"./chunk-LYCLF26R.js";import{b as L,i as I}from"./chunk-CK2E7BTU.js";import{b as C}from"./chunk-QYADASLV.js";var U={};C(U,{MessagingHubGraph:()=>w,SubscriptionGraph:()=>T,TopicBridgeGraph:()=>y,TopicGraph:()=>m,TopicRegistry:()=>O,messagingHub:()=>H,subscription:()=>D,topic:()=>z,topicBridge:()=>F});var R=256;function c(i,e){if(!Number.isFinite(i)||!Number.isInteger(i)||i<0)throw new Error(`${e} must be a non-negative integer`);return i}function a(i,e){return M("messaging",i,e)}var B=1024,m=class extends l{_log;events;latest;hasLatest;constructor(e,s={}){super(e,s.graph),this._log=S([],{name:"events",maxSize:s.retainedLimit??B}),this._log.withLatest(),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=_([this.events],([t])=>{let n=t;return n.length===0?null:n[n.length-1]},{name:"latest",describeKind:"derived",meta:a("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(o(this.latest)),this.hasLatest=_([this.events],([t])=>t.length>0,{name:"hasLatest",describeKind:"derived",meta:a("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(o(this.hasLatest)),this.addDisposer(()=>{this.events.down([[I]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(e){if(e===void 0)throw new TypeError(`TopicGraph "${this.name}": publish(undefined) is not allowed (spec \xA75.12 SENTINEL).`);this._log.append(e)}attachEventStorage(e){return this._log.attachStorage(e)}retained(){return this.events.cache}get _logBundle(){return this._log}},T=class extends l{cursor;available;topic;_disposed=!1;constructor(e,s,t={}){super(e,t.graph),this.topic=s;let n;if(t.from!==void 0?t.from==="retained"?n=0:t.from==="now"?n=s.events.cache.length:n=c(t.from,"subscription from"):n=c(t.cursor??0,"subscription cursor"),this.cursor=v(n,{name:"cursor",describeKind:"state",meta:a("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=s._logBundle.view({kind:"fromCursor",cursor:this.cursor}),this.add(this.available,{name:"available"}),this.addDisposer(o(this.available)),t.advanceOn!==void 0){let r=t.advanceOn,b=!1,d=P([r],()=>{if(!b){b=!0;return}if(this._disposed)return;let p=this.available.cache;if(p.length===0)return;let g=this.cursor.cache+p.length;this.cursor.emit(g)},{name:"advancePump",describeKind:"effect",meta:a("subscription_advance_pump")});this.add(d,{name:"advancePump"}),this.addDisposer(o(d))}}ack(e){if(this._disposed)return this.cursor.cache;let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription ack count"),n=Math.min(t,s.length);if(n<=0)return this.cursor.cache;let r=this.cursor.cache+n;return this.cursor.emit(r),r}pull(e){if(this._disposed)return[];let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription pull limit");return s.slice(0,t)}pullAndAck(e){if(this._disposed)return{items:[],cursor:this.cursor.cache};let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription pullAndAck limit"),n=s.slice(0,t);if(n.length===0)return{items:n,cursor:this.cursor.cache};let r=this.cursor.cache+n.length;return this.cursor.emit(r),{items:n,cursor:r}}dispose(){this._disposed||(this._disposed=!0,this.cursor.down([[I]]),this.destroy())}},y=class extends l{_sourceSub;bridgedCount;output;constructor(e,s,t,n={}){super(e,n.graph),this._sourceSub=D(`${e}-subscription`,s,{cursor:n.cursor}),this.mount("subscription",this._sourceSub);let r=Math.max(1,c(n.maxPerPump??R,"topic bridge maxPerPump")),b=n.map??(u=>u);this.output=_([this._sourceSub.available],([u])=>{let f=u,h=[],k=Math.min(f.length,r);for(let x=0;x<k;x++){let A=b(f[x]);A!==void 0&&h.push(A)}return h},{name:"output",describeKind:"derived",meta:a("topic_bridge_output",{targetRef:t.name}),initial:[]}),this.add(this.output,{name:"output"}),this.addDisposer(o(this.output)),this.bridgedCount=v(0,{name:"bridgedCount",describeKind:"state",meta:a("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"}),this.addDisposer(o(this.bridgedCount));let d=this.output,p=this._sourceSub,g=this.bridgedCount,G=P([d],()=>{let u=d.cache;if(u.length===0)return;let f=p.available.cache.length,h=Math.min(f,r);if(h>0){p.ack(h);let k=g.cache??0;g.emit(k+u.length)}},{name:"ackPump",describeKind:"effect",meta:a("topic_bridge_ack_pump")});this.add(G,{name:"ackPump"}),this.addDisposer(o(G));let E=K(this.output,t);this.addDisposer(E)}};function K(i,e){return i.subscribe(s=>{for(let t of s){if(t[0]!==L)continue;let n=t[1];n.length!==0&&N(()=>{for(let r of n)e.publish(r)})}})}var O=class{_map=new Map;version;constructor(e){this.version=e}get size(){return this._map.size}has(e){return this._map.has(e)}get(e){return this._map.get(e)}set(e,s){this._map.set(e,s)}delete(e){return this._map.delete(e)}keys(){return this._map.keys()}},w=class extends l{_registry;version;_defaultTopicOptions;constructor(e,s={}){super(e,s.graph);let t=v(0,{name:"version",describeKind:"state",meta:a("hub_version")});this.add(t,{name:"version"}),this.version=t,this._registry=new O(t),this._defaultTopicOptions={...s.defaultTopicOptions??{}}}get size(){return this._registry.size}has(e){return this._registry.has(e)}topicNames(){return this._registry.keys()}topic(e,s){let t=this._registry.get(e);if(t===void 0){let n={...this._defaultTopicOptions,...s??{}};t=new m(e,n),this._registry.set(e,t),this.mount(e,t);let r=this.version.cache??0;this.version.emit(r+1)}return t}publish(e,s){this.topic(e).publish(s)}publishMany(e){N(()=>{for(let[s,t]of e)this.topic(s).publish(t)})}subscribe(e,s,t){let n=this.topic(s);return new T(e,n,t)}removeTopic(e){if(!this._registry.has(e))return!1;try{this.remove(e)}finally{this._registry.delete(e);let s=this.version.cache??0;this.version.emit(s+1)}return!0}};function z(i,e){return new m(i,e)}function H(i,e){return new w(i,e)}function D(i,e,s){return new T(i,e,s)}function F(i,e,s,t){return new y(i,e,s,t)}export{m as a,T as b,y as c,O as d,w as e,z as f,H as g,D as h,F as i,U as j};
@@ -1,4 +1,4 @@
1
- import{a as O,f as v,k as P}from"./chunk-2DMKW2AD.js";import{ba as _,k as A}from"./chunk-LCGAVGGV.js";import{d as E}from"./chunk-RZJDIV2G.js";import{m as U,x as T}from"./chunk-CKFQS2CJ.js";import{o as y}from"./chunk-LYCLF26R.js";function G(e={}){return e.sdk?V(e):H(e)}function b(e,t,o,r){let s=t?.model??o;if(!s)throw new Error("anthropicAdapter: model must be set via options.model or invokeOpts.model");let{system:n,chat:i}=J(e,t?.systemPrompt),a={model:s,messages:i.map(F),max_tokens:t?.maxTokens??4096};return n&&(a.system=n),t?.temperature!=null&&(a.temperature=t.temperature),t?.tools&&t.tools.length>0&&(a.tools=t.tools.map(Y)),t?.maxReasoningTokens!=null&&(a.thinking={type:"enabled",budget_tokens:t.maxReasoningTokens}),t?.cacheHint,r&&(a.stream=!0),t?.providerExtras&&Object.assign(a,t.providerExtras),a}function J(e,t){let o=[];t&&o.push(t);let r=[];for(let s of e)s.role==="system"?o.push(s.content):r.push(s);return{system:o.length>0?o.join(`
1
+ import{a as O,f as v,k as P}from"./chunk-UISPDFJ3.js";import{ba as _,k as A}from"./chunk-CYOSWFT2.js";import{d as E}from"./chunk-4MKL6Q3K.js";import{m as U,x as T}from"./chunk-L77I47VU.js";import{o as y}from"./chunk-LYCLF26R.js";function G(e={}){return e.sdk?V(e):H(e)}function b(e,t,o,r){let s=t?.model??o;if(!s)throw new Error("anthropicAdapter: model must be set via options.model or invokeOpts.model");let{system:n,chat:i}=J(e,t?.systemPrompt),a={model:s,messages:i.map(F),max_tokens:t?.maxTokens??4096};return n&&(a.system=n),t?.temperature!=null&&(a.temperature=t.temperature),t?.tools&&t.tools.length>0&&(a.tools=t.tools.map(Y)),t?.maxReasoningTokens!=null&&(a.thinking={type:"enabled",budget_tokens:t.maxReasoningTokens}),t?.cacheHint,r&&(a.stream=!0),t?.providerExtras&&Object.assign(a,t.providerExtras),a}function J(e,t){let o=[];t&&o.push(t);let r=[];for(let s of e)s.role==="system"?o.push(s.content):r.push(s);return{system:o.length>0?o.join(`
2
2
 
3
3
  `):void 0,chat:r}}function F(e){if(e.role==="tool")return{role:"user",content:[{type:"tool_result",tool_use_id:e.toolCallId,content:e.content}]};if(e.role==="assistant"&&e.toolCalls&&e.toolCalls.length>0){let t=[];e.content&&t.push({type:"text",text:e.content});for(let o of e.toolCalls)t.push({type:"tool_use",id:o.id,name:o.name,input:o.arguments});return{role:"assistant",content:t}}return{role:e.role,content:e.content}}function Y(e){return{name:e.name,description:e.description,input_schema:e.parameters}}function R(e,t){if(!e)return{...t};let o={...e};return t.input_tokens!=null&&(o.input_tokens=t.input_tokens),t.output_tokens!=null&&(o.output_tokens=t.output_tokens),t.cache_read_input_tokens!=null&&(o.cache_read_input_tokens=t.cache_read_input_tokens),t.cache_creation_input_tokens!=null&&(o.cache_creation_input_tokens=t.cache_creation_input_tokens),t.cache_creation&&(o.cache_creation={...e.cache_creation??{},...t.cache_creation}),t.server_tool_use&&(o.server_tool_use={...e.server_tool_use??{},...t.server_tool_use}),o}function x(e){let t={input:{regular:e?.input_tokens??0},output:{regular:e?.output_tokens??0},raw:e};return e?.cache_read_input_tokens&&(t.input.cacheRead=e.cache_read_input_tokens),e?.cache_creation?(e.cache_creation.ephemeral_5m_input_tokens&&(t.input.cacheWrite5m=e.cache_creation.ephemeral_5m_input_tokens),e.cache_creation.ephemeral_1h_input_tokens&&(t.input.cacheWrite1h=e.cache_creation.ephemeral_1h_input_tokens)):e?.cache_creation_input_tokens&&(t.input.cacheWrite5m=e.cache_creation_input_tokens),e?.server_tool_use?.web_search_requests&&(t.auxiliary={webSearchRequests:e.server_tool_use.web_search_requests}),t}function K(e,t){let o=[],r=[];for(let s of e.content)if(s.type==="text"&&typeof s.text=="string")o.push(s.text);else if(s.type==="tool_use"){let n=s;r.push({id:n.id,name:n.name,arguments:n.input??{}})}return{content:o.join(""),toolCalls:r.length>0?r:void 0,usage:x(e.usage),finishReason:e.stop_reason,latencyMs:t,model:e.model,provider:"anthropic"}}function H(e){let t=e.apiKey??globalThis.process?.env?.ANTHROPIC_API_KEY,o=e.baseURL??"https://api.anthropic.com",r=e.anthropicVersion??"2023-06-01",s=e.fetchImpl??fetch,n=()=>{if(!t)throw new Error("anthropicAdapter: apiKey required for invoke/stream (or provide opts.sdk)");return{"x-api-key":t,"anthropic-version":r,"content-type":"application/json",...e.headers??{}}};return{provider:"anthropic",model:e.model,async invoke(i,a){let d=b(i,a,e.model,!1),g=y(),l=await s(`${o}/v1/messages`,{method:"POST",headers:n(),body:JSON.stringify(d),signal:a?.signal});if(!l.ok)throw await _(l,"Anthropic");let c=await l.json(),p=Math.max(0,(y()-g)/1e6);return K(c,p)},async*stream(i,a){let d=b(i,a,e.model,!0),g=await s(`${o}/v1/messages`,{method:"POST",headers:{...n(),accept:"text/event-stream"},body:JSON.stringify(d),signal:a?.signal});if(!g.ok)throw await _(g,"Anthropic");if(!g.body)throw new Error("anthropicAdapter: streaming response has no body");let l,c,p=new Map;for await(let m of A(g.body,{signal:a?.signal})){let h=m.data;if(!h)continue;let k;try{k=JSON.parse(h)}catch{continue}switch(k.type){case"message_start":{l=R(l,k.message.usage);break}case"content_block_start":{let u=k,f=u.content_block;f.type==="tool_use"&&(p.set(u.index,{id:String(f.id??""),name:String(f.name??""),argBuf:""}),yield{type:"tool-call-delta",delta:{id:String(f.id??""),name:String(f.name??"")}});break}case"content_block_delta":{let u=k,f=u.delta;if(f.type==="text_delta"&&typeof f.text=="string")yield{type:"token",delta:f.text};else if(f.type==="input_json_delta"&&typeof f.partial_json=="string"){let S=p.get(u.index);S&&(S.argBuf+=f.partial_json),yield{type:"tool-call-delta",delta:{argumentsDelta:f.partial_json}}}else f.type==="thinking_delta"&&typeof f.thinking=="string"&&(yield{type:"thinking",delta:f.thinking});break}case"message_delta":{let u=k;u.delta.stop_reason&&(c=u.delta.stop_reason),u.delta.usage&&(l=R(l,u.delta.usage));break}case"message_stop":break}}l&&(yield{type:"usage",usage:x(l)}),yield{type:"finish",reason:c??"stop"}}}}function V(e){let t=e.sdk;if(!t)throw new Error("sdkBackedAnthropic: sdk instance required");return{provider:"anthropic",model:e.model,async invoke(o,r){let s=b(o,r,e.model,!1),n=y(),i=await t.messages.create(s,{signal:r?.signal}),a=Math.max(0,(y()-n)/1e6);return K(i,a)},async*stream(o,r){if(!t.messages.stream)throw new Error("sdkBackedAnthropic: SDK instance does not expose .messages.stream");let s=b(o,r,e.model,!0),n,i;for await(let a of t.messages.stream(s,{signal:r?.signal}))switch(a.type){case"message_start":n=R(n,a.message.usage);break;case"content_block_delta":{let d=a.delta;d?.type==="text_delta"&&typeof d.text=="string"?yield{type:"token",delta:d.text}:d?.type==="input_json_delta"&&typeof d.partial_json=="string"?yield{type:"tool-call-delta",delta:{argumentsDelta:d.partial_json}}:d?.type==="thinking_delta"&&typeof d.thinking=="string"&&(yield{type:"thinking",delta:d.thinking});break}case"message_delta":{let d=a;d.delta.stop_reason&&(i=d.delta.stop_reason),d.delta.usage&&(n=R(n,d.delta.usage));break}}n&&(yield{type:"usage",usage:x(n)}),yield{type:"finish",reason:i??"stop"}}}}function D(e={}){return e.sdk?X(e):Q(e)}function w(e,t){let o=[],r=[];t?.systemPrompt&&o.push(t.systemPrompt);for(let i of e){if(i.role==="system"){o.push(i.content);continue}if(i.role==="tool"){r.push({role:"user",parts:[{functionResponse:{name:i.name??i.toolCallId??"tool",response:{result:i.content}}}]});continue}if(i.role==="assistant"&&i.toolCalls&&i.toolCalls.length>0){let a=[];i.content&&a.push({text:i.content});for(let d of i.toolCalls)a.push({functionCall:{name:d.name,args:d.arguments}});r.push({role:"model",parts:a});continue}r.push({role:i.role==="assistant"?"model":"user",parts:[{text:i.content}]})}let s={contents:r};o.length>0&&(s.systemInstruction={role:"system",parts:[{text:o.join(`
4
4
 
@@ -1 +1 @@
1
- import{i as x}from"./chunk-2BX4NB34.js";import{b as y}from"./chunk-YXDRGKXP.js";import{E as T,m as A,p as f,t as b}from"./chunk-LYCLF26R.js";import{b as m,c as R}from"./chunk-CK2E7BTU.js";function N(r,e){let t=r.cache??0;return t>=e?!1:(r.down([[R],[m,t+1]]),!0)}var M=b((r,e)=>{r("observe"),r("signal"),e("write")});function q(r){let e=y([],{name:r.name,maxSize:r.retainedLimit??1024,guard:r.guard??M,...r.versioning!=null?{versioning:r.versioning}:{}});return e.withLatest(),r.graph&&r.graph.add(e.entries,{name:r.name}),e}function p(r){if(r===null||typeof r!="object"||Object.isFrozen(r))return r;for(let e of Object.keys(r))p(r[e]);return Object.freeze(r)}function w(r){let e=r.cache,u=(typeof e=="number"&&Number.isFinite(e)?e:0)+1;return r.down([[R],[m,u]]),u}function g(r,e,t,u,i,s){let o=e(t,u,i);if(o===void 0)return;let a=s!=null?{...o,handlerVersion:s}:o;r.append(a)}function z(r,e){let t=e.freeze??!0;return function(...i){let s=t?i.map(p):i,o=f(),a=e.seq?w(e.seq):void 0;try{let n=r(...s);return e.onSuccess&&g(e.audit,e.onSuccess,s,n,{t_ns:o,seq:a},e.handlerVersion),n}catch(n){if(e.onFailure){let d=n instanceof Error?n.name:typeof n;g(e.audit,e.onFailure,s,n,{t_ns:o,seq:a,errorType:d},e.handlerVersion)}throw n}}}function G(r,e){let t=e.freeze??!0;return function(...i){let s=t?i.map(p):i,o=f(),a,n,d=!1,l;try{A(()=>{e.seq&&(l=w(e.seq));try{a=r(...s),e.onSuccess&&g(e.audit,e.onSuccess,s,a,{t_ns:o,seq:l},e.handlerVersion)}catch(c){throw n=c,d=!0,c}})}catch(c){if(d&&e.onFailure){let h=n instanceof Error?n.name:typeof n;g(e.audit,e.onFailure,s,n,{t_ns:o,seq:l,errorType:h},e.handlerVersion)}throw d?n:c}return a}}function V(r,e,t=0){let u=T(t,{name:e,describeKind:"state"});return r.add(u,{name:e}),u}function _(r,e,t,u=0){let i={},s=new x(e);for(let o of t){let a=T(u,{name:o,describeKind:"state"});s.add(a,{name:o}),i[o]=a}return r.mount(e,s),i}export{N as a,M as b,q as c,w as d,g as e,z as f,G as g,V as h,_ as i};
1
+ import{b as y}from"./chunk-TT4C7DXW.js";import{i as x}from"./chunk-POXANAJ6.js";import{E as T,m as A,p as f,t as b}from"./chunk-LYCLF26R.js";import{b as m,c as R}from"./chunk-CK2E7BTU.js";function N(r,e){let t=r.cache??0;return t>=e?!1:(r.down([[R],[m,t+1]]),!0)}var M=b((r,e)=>{r("observe"),r("signal"),e("write")});function q(r){let e=y([],{name:r.name,maxSize:r.retainedLimit??1024,guard:r.guard??M,...r.versioning!=null?{versioning:r.versioning}:{}});return e.withLatest(),r.graph&&r.graph.add(e.entries,{name:r.name}),e}function p(r){if(r===null||typeof r!="object"||Object.isFrozen(r))return r;for(let e of Object.keys(r))p(r[e]);return Object.freeze(r)}function w(r){let e=r.cache,u=(typeof e=="number"&&Number.isFinite(e)?e:0)+1;return r.down([[R],[m,u]]),u}function g(r,e,t,u,i,s){let o=e(t,u,i);if(o===void 0)return;let a=s!=null?{...o,handlerVersion:s}:o;r.append(a)}function z(r,e){let t=e.freeze??!0;return function(...i){let s=t?i.map(p):i,o=f(),a=e.seq?w(e.seq):void 0;try{let n=r(...s);return e.onSuccess&&g(e.audit,e.onSuccess,s,n,{t_ns:o,seq:a},e.handlerVersion),n}catch(n){if(e.onFailure){let d=n instanceof Error?n.name:typeof n;g(e.audit,e.onFailure,s,n,{t_ns:o,seq:a,errorType:d},e.handlerVersion)}throw n}}}function G(r,e){let t=e.freeze??!0;return function(...i){let s=t?i.map(p):i,o=f(),a,n,d=!1,l;try{A(()=>{e.seq&&(l=w(e.seq));try{a=r(...s),e.onSuccess&&g(e.audit,e.onSuccess,s,a,{t_ns:o,seq:l},e.handlerVersion)}catch(c){throw n=c,d=!0,c}})}catch(c){if(d&&e.onFailure){let h=n instanceof Error?n.name:typeof n;g(e.audit,e.onFailure,s,n,{t_ns:o,seq:l,errorType:h},e.handlerVersion)}throw d?n:c}return a}}function V(r,e,t=0){let u=T(t,{name:e,describeKind:"state"});return r.add(u,{name:e}),u}function _(r,e,t,u=0){let i={},s=new x(e);for(let o of t){let a=T(u,{name:o,describeKind:"state"});s.add(a,{name:o}),i[o]=a}return r.mount(e,s),i}export{N as a,M as b,q as c,w as d,g as e,z as f,G as g,V as h,_ as i};
@@ -1 +1 @@
1
- import{t as I,x as w}from"./chunk-FHRBBHJN.js";import{c as O}from"./chunk-35JTVPOX.js";import{b as E}from"./chunk-TZQPPQEQ.js";import{m as d,s as g}from"./chunk-CKFQS2CJ.js";import{E as R,G as V,m as h}from"./chunk-LYCLF26R.js";import{b}from"./chunk-CK2E7BTU.js";function C(o){return typeof o=="object"&&o!==null&&"cache"in o&&typeof o.subscribe=="function"}function H(o,a,e){let r=d(o),t=r.v!=null,p=R(e?.initialVerified??null,{meta:{...O("verifiable"),...t?{sourceVersion:null}:{}}}),x=e?.trigger!==void 0&&e.trigger!==null,s=null;if(x&&e?.autoVerify?s=I(d(e.trigger),r):x?s=d(e.trigger):e?.autoVerify&&(s=r),s!==null){let y;if(s===r)y=w(r,c=>a(c));else{let c=r.cache;r.subscribe(f=>{for(let M of f)M[0]===b&&(c=M[1])}),y=w(s,()=>a(c))}g(y,c=>{h(()=>{if(p.down([[b,c]]),t){let f=r.v;f!=null&&p.meta.sourceVersion.down([[b,{id:f.id,version:f.version}]])}})})}return{node:r,verified:p,trigger:s}}function B(o){o.subscribe(()=>{})}function v(o){return o instanceof Map?o:new Map}function S(o,a){if(!Array.isArray(a.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");h(()=>{for(let{key:e,value:r}of a.upsert)o.set(e,r);for(let e of a.remove??[])o.delete(e)})}function J(o,a,e){let r=d(o),t=E(e.mapOptions??{}),p=e.budget??2e3,s=e.context!==void 0&&e.context!==null?d(e.context):R(null),y=v(t.entries.cache);t.entries.subscribe(i=>{for(let u of i)u[0]===b&&(y=v(u[1]))});let c=d(a(r,t.entries));if(g(c,i=>{S(t,i)}),e.evict){let i=new Map,u=V([t.entries],([l])=>{let m=[],N=v(l);for(let n of i.keys())N.has(n)||(i.get(n)(),i.delete(n));for(let[n,T]of N){let k=e.evict(n,T);if(C(k)){if(!i.has(n)){let D=g(k,z=>{z===!0&&t.has(n)&&t.delete(n)});i.set(n,D)}continue}if(typeof k=="boolean"){k&&m.push(n);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return m});g(u,l=>{for(let m of l)t.delete(m)})}let f=e.consolidateTrigger!==void 0&&e.consolidateTrigger!==null;if(e.consolidate&&f){let i=d(e.consolidateTrigger),u=w(i,()=>e.consolidate(y));g(u,l=>{S(t,l)})}let M=V([t.entries,s],([i,u])=>{let l=[...v(i).entries()].map(([n,T])=>({key:n,value:T,score:e.score(T,u),cost:e.cost(T)}));l.sort((n,T)=>T.score-n.score);let m=[],N=p;for(let n of l)n.cost<=N&&(m.push({key:n.key,value:n.value,score:n.score}),N-=n.cost);return m},{meta:{...O("distill",{budget:p})}}),A=V([t.entries],([i])=>v(i).size);return B(M),B(A),{store:t,compact:M,size:A}}export{H as a,J as b};
1
+ import{b as E}from"./chunk-TZQPPQEQ.js";import{t as I,x as w}from"./chunk-AK5RHMC5.js";import{m as d,s as g}from"./chunk-L77I47VU.js";import{c as O}from"./chunk-35JTVPOX.js";import{E as R,G as V,m as h}from"./chunk-LYCLF26R.js";import{b}from"./chunk-CK2E7BTU.js";function C(o){return typeof o=="object"&&o!==null&&"cache"in o&&typeof o.subscribe=="function"}function H(o,a,e){let r=d(o),t=r.v!=null,p=R(e?.initialVerified??null,{meta:{...O("verifiable"),...t?{sourceVersion:null}:{}}}),x=e?.trigger!==void 0&&e.trigger!==null,s=null;if(x&&e?.autoVerify?s=I(d(e.trigger),r):x?s=d(e.trigger):e?.autoVerify&&(s=r),s!==null){let y;if(s===r)y=w(r,c=>a(c));else{let c=r.cache;r.subscribe(f=>{for(let M of f)M[0]===b&&(c=M[1])}),y=w(s,()=>a(c))}g(y,c=>{h(()=>{if(p.down([[b,c]]),t){let f=r.v;f!=null&&p.meta.sourceVersion.down([[b,{id:f.id,version:f.version}]])}})})}return{node:r,verified:p,trigger:s}}function B(o){o.subscribe(()=>{})}function v(o){return o instanceof Map?o:new Map}function S(o,a){if(!Array.isArray(a.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");h(()=>{for(let{key:e,value:r}of a.upsert)o.set(e,r);for(let e of a.remove??[])o.delete(e)})}function J(o,a,e){let r=d(o),t=E(e.mapOptions??{}),p=e.budget??2e3,s=e.context!==void 0&&e.context!==null?d(e.context):R(null),y=v(t.entries.cache);t.entries.subscribe(i=>{for(let u of i)u[0]===b&&(y=v(u[1]))});let c=d(a(r,t.entries));if(g(c,i=>{S(t,i)}),e.evict){let i=new Map,u=V([t.entries],([l])=>{let m=[],N=v(l);for(let n of i.keys())N.has(n)||(i.get(n)(),i.delete(n));for(let[n,T]of N){let k=e.evict(n,T);if(C(k)){if(!i.has(n)){let D=g(k,z=>{z===!0&&t.has(n)&&t.delete(n)});i.set(n,D)}continue}if(typeof k=="boolean"){k&&m.push(n);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return m});g(u,l=>{for(let m of l)t.delete(m)})}let f=e.consolidateTrigger!==void 0&&e.consolidateTrigger!==null;if(e.consolidate&&f){let i=d(e.consolidateTrigger),u=w(i,()=>e.consolidate(y));g(u,l=>{S(t,l)})}let M=V([t.entries,s],([i,u])=>{let l=[...v(i).entries()].map(([n,T])=>({key:n,value:T,score:e.score(T,u),cost:e.cost(T)}));l.sort((n,T)=>T.score-n.score);let m=[],N=p;for(let n of l)n.cost<=N&&(m.push({key:n.key,value:n.value,score:n.score}),N-=n.cost);return m},{meta:{...O("distill",{budget:p})}}),A=V([t.entries],([i])=>v(i).size);return B(M),B(A),{store:t,compact:M,size:A}}export{H as a,J as b};
@@ -1,4 +1,4 @@
1
- import{e as ce}from"./chunk-7Q4ZD3YW.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{i as L}from"./chunk-2BX4NB34.js";import{f as ae,h as ie}from"./chunk-CKFQS2CJ.js";import{i as ne,j as U}from"./chunk-LYCLF26R.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
1
+ import{e as ce}from"./chunk-H5SCWHWP.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{i as L}from"./chunk-POXANAJ6.js";import{f as ae,h as ie}from"./chunk-L77I47VU.js";import{i as ne,j as U}from"./chunk-LYCLF26R.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
2
2
 
3
3
  `),counted:!1}),u?.(),u=void 0):i.enqueue(c.encode(`: keepalive
4
4
 
@@ -1 +1 @@
1
- import{b as G,c as F}from"./chunk-LYM4PBMV.js";import{a as A}from"./chunk-2QXRYP7Q.js";import{a as q}from"./chunk-L6NSJVJZ.js";import{i as I}from"./chunk-2BX4NB34.js";import{b as E}from"./chunk-YXDRGKXP.js";import{C as M}from"./chunk-CKFQS2CJ.js";import{E as d,G as o,H as O,m as S}from"./chunk-LYCLF26R.js";import{b as V}from"./chunk-QYADASLV.js";var $={};V($,{contentModerationGraph:()=>Q,dataQualityGraph:()=>T,issueTrackerGraph:()=>B,observabilityGraph:()=>D});function r(u,a){return q("domain_template",u,a)}function D(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=[{name:"errors",classify:e=>C(e,"error")},{name:"traces",classify:e=>C(e,"trace")},{name:"metrics",classify:e=>C(e,"metric")}],m=a.branches??h,y=m.map(e=>({name:e.name,classify:e.classify})),c=A("stratify",a.source,y);n.mount("stratify",c);let k=m.map(e=>{try{let i=n.resolve(`stratify::branch/${e.name}`);return o([i],([x])=>x,{initial:null})}catch{return d(null)}}),l=a.correlate??(e=>e),_=o(k,e=>l(e),{meta:r("observability",{stage:"correlate"})});n.add(_,{name:"correlate"});let N=a.sloCheck??(()=>({pass:!0})),w=o([_],e=>e[0],{meta:r("observability",{stage:"slo_value"})}),f=o([w],e=>N(e[0]),{meta:r("observability",{stage:"slo_verified"})});n.add(w,{name:"slo_value"}),n.add(f,{name:"slo_verified"});let v=a.weights??m.map(()=>1),b=k.map(e=>o([e],i=>i[0]!=null?1:0)),p=v.map(e=>d(e));for(let e=0;e<b.length;e++)n.add(b[e],{name:`__signal_${e}`}),n.add(p[e],{name:`__weight_${e}`});let t=F(b,p);n.add(t,{name:"alerts"});let g=o([t,f],e=>({scored:e[0],slo:e[1]}),{meta:r("observability",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:r("observability",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let s=o([f],e=>{let i=e[0];return i&&i.pass===!1?i:null},{meta:r("observability",{stage:"feedback_condition"})});return n.add(s,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??5}),n}function B(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=0,m=e=>({id:`issue-${++h}`,title:String(e),severity:1,source:"unknown",raw:e}),y=a.extract??m,c=o([a.source],e=>y(e[0]),{meta:r("issue_tracker",{stage:"extract"})});n.add(c,{name:"extract"});let k=a.verify??(()=>({valid:!0})),l=o([c],e=>{let i=e[0];return{issue:i,verification:k(i)}},{meta:r("issue_tracker",{stage:"verify"})});n.add(l,{name:"verify"});let _=d([],{meta:r("issue_tracker",{stage:"known_patterns"})});n.add(_,{name:"known_patterns"});let N=a.detectRegression??(()=>({regression:!1})),w=o([c,_],e=>{let i=e[0],x=e[1];return{issue:i,regression:N(i,x)}},{meta:r("issue_tracker",{stage:"regression"})});n.add(w,{name:"regression"});let f=o([c],e=>e[0]?.severity??0),v=o([w],e=>e[0]?.regression?2:0);n.add(f,{name:"__severity_signal"}),n.add(v,{name:"__regression_signal"});let b=d(1),p=d(1.5);n.add(b,{name:"__severity_weight"}),n.add(p,{name:"__regression_weight"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([l,w,t],e=>({verified:e[0],regression:e[1],priority:e[2]}),{meta:r("issue_tracker",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:r("issue_tracker",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let s=o([l],e=>{let i=e[0];if(i){let x=i.verification;if(x&&x.valid===!1)return i}return null},{meta:r("issue_tracker",{stage:"feedback_condition"})});return n.add(s,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??3}),n}function Q(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=s=>({label:"review",confidence:.5,original:s}),m=a.classify??h,y=o([a.source],s=>m(s[0]),{meta:r("content_moderation",{stage:"classify"})});n.add(y,{name:"classify"});let c=A("stratify",y,[{name:"safe",classify:s=>s.label==="safe"},{name:"review",classify:s=>s.label==="review"},{name:"block",classify:s=>s.label==="block"}]);n.mount("stratify",c);let k=E([],{name:"review_queue",maxSize:a.maxQueueSize});n.add(k.entries,{name:"review_queue"});let l;try{l=n.resolve("stratify::branch/review")}catch{l=d(null),n.add(l,{name:"__review_fallback"})}let _=O([l],s=>{let e=s[0];e&&k.append(e)});n.add(_,{name:"__review_accumulator"}),n.addDisposer(M(_));let N=d({},{meta:r("content_moderation",{stage:"policy",access:"both",description:"Moderation policy rules \u2014 updated via feedback"})});n.add(N,{name:"policy"});let w=a.weights??[.1,1,2],f=o([y],s=>s[0]?.confidence??0),v=o([y],s=>{let e=s[0];return e?e.label==="block"?w[2]:e.label==="review"?w[1]:w[0]:0});n.add(f,{name:"__confidence_signal"}),n.add(v,{name:"__severity_signal"});let b=d(1),p=d(1);n.add(b,{name:"__w_confidence"}),n.add(p,{name:"__w_severity"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([y,t],s=>({classification:s[0],priority:s[1]}),{meta:r("content_moderation",{stage:"output"})});n.add(g,{name:"output"});let R=o([k.entries,N],s=>{let e=s[0];if(e&&e.length>0){let i=e[e.length-1];if(i&&i.falsePositive)return i}return null},{meta:r("content_moderation",{stage:"feedback_condition"})});return n.add(R,{name:"feedback_condition"}),G(n,"feedback_condition","policy",{maxIterations:a.maxFeedbackIterations??5}),n}function T(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=a.validate??(t=>({valid:!0,errors:[],record:t})),m=o([a.source],t=>t[0]!=null?h(t[0]):void 0,{meta:r("data_quality",{stage:"validate"})});n.add(m,{name:"validate"});let y=a.detectAnomaly??(t=>({anomaly:!1,score:0,record:t})),c=o([a.source],t=>t[0]!=null?y(t[0]):void 0,{meta:r("data_quality",{stage:"anomaly"})});n.add(c,{name:"anomaly"});let k=d(null,{meta:r("data_quality",{stage:"baseline",description:"Rolling baseline for drift detection"})});n.add(k,{name:"baseline"});let l=O([m],t=>{let g=t[0];g?.valid&&S(()=>{k.emit(g.record)})});n.add(l,{name:"__baseline_updater"}),M(l);let _=a.detectDrift??(()=>({drift:!1})),N=o([a.source,k],t=>_(t[0],t[1]),{meta:r("data_quality",{stage:"drift"})});n.add(N,{name:"drift"});let w=a.suggest??(()=>null),f=o([m,c],t=>w({validation:t[0],anomaly:t[1]}),{meta:r("data_quality",{stage:"remediate"})});n.add(f,{name:"remediate"});let v=o([m,c,N,f],t=>({validation:t[0],anomaly:t[1],drift:t[2],remediation:t[3]}),{meta:r("data_quality",{stage:"output"})});n.add(v,{name:"output"});let b=d([],{meta:r("data_quality",{stage:"validation_rules"})});n.add(b,{name:"validation_rules"});let p=o([c],t=>{let g=t[0];return g?.anomaly?g:null},{meta:r("data_quality",{stage:"feedback_condition"})});return n.add(p,{name:"feedback_condition"}),G(n,"feedback_condition","validation_rules",{maxIterations:a.maxFeedbackIterations??3}),n}function C(u,a){if(u==null||typeof u!="object")return!1;let n=u;return n.type===a||n.kind===a}export{D as a,B as b,Q as c,T as d,$ as e};
1
+ import{b as G,c as F}from"./chunk-G3M3IMEV.js";import{a as A}from"./chunk-AI7QC7J6.js";import{a as q}from"./chunk-L6NSJVJZ.js";import{b as E}from"./chunk-TT4C7DXW.js";import{i as I}from"./chunk-POXANAJ6.js";import{C as M}from"./chunk-L77I47VU.js";import{E as d,G as o,H as O,m as S}from"./chunk-LYCLF26R.js";import{b as V}from"./chunk-QYADASLV.js";var $={};V($,{contentModerationGraph:()=>Q,dataQualityGraph:()=>T,issueTrackerGraph:()=>B,observabilityGraph:()=>D});function r(u,a){return q("domain_template",u,a)}function D(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=[{name:"errors",classify:e=>C(e,"error")},{name:"traces",classify:e=>C(e,"trace")},{name:"metrics",classify:e=>C(e,"metric")}],m=a.branches??h,y=m.map(e=>({name:e.name,classify:e.classify})),c=A("stratify",a.source,y);n.mount("stratify",c);let k=m.map(e=>{try{let i=n.resolve(`stratify::branch/${e.name}`);return o([i],([x])=>x,{initial:null})}catch{return d(null)}}),l=a.correlate??(e=>e),_=o(k,e=>l(e),{meta:r("observability",{stage:"correlate"})});n.add(_,{name:"correlate"});let N=a.sloCheck??(()=>({pass:!0})),w=o([_],e=>e[0],{meta:r("observability",{stage:"slo_value"})}),f=o([w],e=>N(e[0]),{meta:r("observability",{stage:"slo_verified"})});n.add(w,{name:"slo_value"}),n.add(f,{name:"slo_verified"});let v=a.weights??m.map(()=>1),b=k.map(e=>o([e],i=>i[0]!=null?1:0)),p=v.map(e=>d(e));for(let e=0;e<b.length;e++)n.add(b[e],{name:`__signal_${e}`}),n.add(p[e],{name:`__weight_${e}`});let t=F(b,p);n.add(t,{name:"alerts"});let g=o([t,f],e=>({scored:e[0],slo:e[1]}),{meta:r("observability",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:r("observability",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let s=o([f],e=>{let i=e[0];return i&&i.pass===!1?i:null},{meta:r("observability",{stage:"feedback_condition"})});return n.add(s,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??5}),n}function B(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=0,m=e=>({id:`issue-${++h}`,title:String(e),severity:1,source:"unknown",raw:e}),y=a.extract??m,c=o([a.source],e=>y(e[0]),{meta:r("issue_tracker",{stage:"extract"})});n.add(c,{name:"extract"});let k=a.verify??(()=>({valid:!0})),l=o([c],e=>{let i=e[0];return{issue:i,verification:k(i)}},{meta:r("issue_tracker",{stage:"verify"})});n.add(l,{name:"verify"});let _=d([],{meta:r("issue_tracker",{stage:"known_patterns"})});n.add(_,{name:"known_patterns"});let N=a.detectRegression??(()=>({regression:!1})),w=o([c,_],e=>{let i=e[0],x=e[1];return{issue:i,regression:N(i,x)}},{meta:r("issue_tracker",{stage:"regression"})});n.add(w,{name:"regression"});let f=o([c],e=>e[0]?.severity??0),v=o([w],e=>e[0]?.regression?2:0);n.add(f,{name:"__severity_signal"}),n.add(v,{name:"__regression_signal"});let b=d(1),p=d(1.5);n.add(b,{name:"__severity_weight"}),n.add(p,{name:"__regression_weight"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([l,w,t],e=>({verified:e[0],regression:e[1],priority:e[2]}),{meta:r("issue_tracker",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:r("issue_tracker",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let s=o([l],e=>{let i=e[0];if(i){let x=i.verification;if(x&&x.valid===!1)return i}return null},{meta:r("issue_tracker",{stage:"feedback_condition"})});return n.add(s,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??3}),n}function Q(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=s=>({label:"review",confidence:.5,original:s}),m=a.classify??h,y=o([a.source],s=>m(s[0]),{meta:r("content_moderation",{stage:"classify"})});n.add(y,{name:"classify"});let c=A("stratify",y,[{name:"safe",classify:s=>s.label==="safe"},{name:"review",classify:s=>s.label==="review"},{name:"block",classify:s=>s.label==="block"}]);n.mount("stratify",c);let k=E([],{name:"review_queue",maxSize:a.maxQueueSize});n.add(k.entries,{name:"review_queue"});let l;try{l=n.resolve("stratify::branch/review")}catch{l=d(null),n.add(l,{name:"__review_fallback"})}let _=O([l],s=>{let e=s[0];e&&k.append(e)});n.add(_,{name:"__review_accumulator"}),n.addDisposer(M(_));let N=d({},{meta:r("content_moderation",{stage:"policy",access:"both",description:"Moderation policy rules \u2014 updated via feedback"})});n.add(N,{name:"policy"});let w=a.weights??[.1,1,2],f=o([y],s=>s[0]?.confidence??0),v=o([y],s=>{let e=s[0];return e?e.label==="block"?w[2]:e.label==="review"?w[1]:w[0]:0});n.add(f,{name:"__confidence_signal"}),n.add(v,{name:"__severity_signal"});let b=d(1),p=d(1);n.add(b,{name:"__w_confidence"}),n.add(p,{name:"__w_severity"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([y,t],s=>({classification:s[0],priority:s[1]}),{meta:r("content_moderation",{stage:"output"})});n.add(g,{name:"output"});let R=o([k.entries,N],s=>{let e=s[0];if(e&&e.length>0){let i=e[e.length-1];if(i&&i.falsePositive)return i}return null},{meta:r("content_moderation",{stage:"feedback_condition"})});return n.add(R,{name:"feedback_condition"}),G(n,"feedback_condition","policy",{maxIterations:a.maxFeedbackIterations??5}),n}function T(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=a.validate??(t=>({valid:!0,errors:[],record:t})),m=o([a.source],t=>t[0]!=null?h(t[0]):void 0,{meta:r("data_quality",{stage:"validate"})});n.add(m,{name:"validate"});let y=a.detectAnomaly??(t=>({anomaly:!1,score:0,record:t})),c=o([a.source],t=>t[0]!=null?y(t[0]):void 0,{meta:r("data_quality",{stage:"anomaly"})});n.add(c,{name:"anomaly"});let k=d(null,{meta:r("data_quality",{stage:"baseline",description:"Rolling baseline for drift detection"})});n.add(k,{name:"baseline"});let l=O([m],t=>{let g=t[0];g?.valid&&S(()=>{k.emit(g.record)})});n.add(l,{name:"__baseline_updater"}),M(l);let _=a.detectDrift??(()=>({drift:!1})),N=o([a.source,k],t=>_(t[0],t[1]),{meta:r("data_quality",{stage:"drift"})});n.add(N,{name:"drift"});let w=a.suggest??(()=>null),f=o([m,c],t=>w({validation:t[0],anomaly:t[1]}),{meta:r("data_quality",{stage:"remediate"})});n.add(f,{name:"remediate"});let v=o([m,c,N,f],t=>({validation:t[0],anomaly:t[1],drift:t[2],remediation:t[3]}),{meta:r("data_quality",{stage:"output"})});n.add(v,{name:"output"});let b=d([],{meta:r("data_quality",{stage:"validation_rules"})});n.add(b,{name:"validation_rules"});let p=o([c],t=>{let g=t[0];return g?.anomaly?g:null},{meta:r("data_quality",{stage:"feedback_condition"})});return n.add(p,{name:"feedback_condition"}),G(n,"feedback_condition","validation_rules",{maxIterations:a.maxFeedbackIterations??3}),n}function C(u,a){if(u==null||typeof u!="object")return!1;let n=u;return n.type===a||n.kind===a}export{D as a,B as b,Q as c,T as d,$ as e};
@@ -0,0 +1,61 @@
1
+ import{h as Lt}from"./chunk-F7VUYPP6.js";import{a as kt,b as Rt,c as xt,d as wt}from"./chunk-GI4Q7PNY.js";import{c as vt}from"./chunk-7PQLZMOG.js";import{a as Ht,b as Xt,c as Zt,d as er,e as tr,f as Be,g as rr}from"./chunk-VV62MIG4.js";import{a as Fe,b as V,c as Le,d as de,e as ee,f as U,g as zt,h as Ge,i as Yt,j as Jt,k as Qt}from"./chunk-UISPDFJ3.js";import{f as $e}from"./chunk-URJ2VFNC.js";import{b as Tt}from"./chunk-WZYB3JQS.js";import{a as we,b as Mt}from"./chunk-TSOYJ743.js";import{b as ut,c as Re,d as mt,f as je}from"./chunk-4MKL6Q3K.js";import{b as xe}from"./chunk-TZQPPQEQ.js";import{a as dt}from"./chunk-L6NSJVJZ.js";import{b as pe}from"./chunk-TT4C7DXW.js";import{i as se}from"./chunk-POXANAJ6.js";import{a as Z}from"./chunk-ESMPEKEV.js";import{R as bt,b as yt,s as ht,x as $}from"./chunk-AK5RHMC5.js";import{A as gt,C as j,f as ct,k as _e,l as pt,m as x,x as ae,z as ft}from"./chunk-L77I47VU.js";import{b as ke,c as X}from"./chunk-35JTVPOX.js";import{D as le,E as L,F as Q,G as v,H as re,m as J,o as H,p as be}from"./chunk-LYCLF26R.js";import{b as G,d as ce,i as q,j as W}from"./chunk-CK2E7BTU.js";import{b as qt}from"./chunk-QYADASLV.js";var Zr={};qt(Zr,{AgentLoopGraph:()=>Pe,AllTiersExhaustedError:()=>tr,BudgetExhaustedError:()=>Ce,ChatStreamGraph:()=>Ie,CircuitOpenError:()=>Re,DEFAULT_DECAY_RATE:()=>we,FallbackMissError:()=>Jt,LLMTimeoutError:()=>ge,ReplayCacheMissError:()=>zt,ToolRegistryGraph:()=>De,admissionFilter3D:()=>Kr,admissionScored:()=>Gt,agentLoop:()=>Br,agentMemory:()=>Ur,anthropicAdapter:()=>Ht,canonicalJson:()=>Yt,cascadingLlmAdapter:()=>Be,chatStream:()=>rt,composePricing:()=>lr,computePrice:()=>We,contentGate:()=>jr,costMeterExtractor:()=>Sr,createAdapter:()=>er,createCapabilitiesRegistry:()=>nr,createPricingRegistry:()=>sr,dryRunAdapter:()=>Fe,fallbackAdapter:()=>Qt,frozenContext:()=>xr,gatedStream:()=>Nr,gaugesAsContext:()=>qr,googleAdapter:()=>Xt,graphFromSpec:()=>$t,graphFromSpecReactive:()=>Hr,handoff:()=>$r,keywordFlagExtractor:()=>Or,knobsAsTools:()=>Yr,llmConsolidator:()=>tt,llmExtractor:()=>et,memoryRetrieval:()=>lt,memoryWithKG:()=>st,memoryWithTiers:()=>it,memoryWithVectors:()=>at,observableAdapter:()=>or,openAICompatAdapter:()=>Zt,parseRateLimitFromError:()=>qe,pricingFor:()=>dr,promptCall:()=>Ze,promptNode:()=>Xe,redactor:()=>_r,registryPricing:()=>ir,resilientAdapter:()=>Mr,streamExtractor:()=>Ir,streamingPromptNode:()=>Lr,suggestStrategy:()=>Wt,suggestStrategyReactive:()=>Qr,systemPromptBuilder:()=>Ar,tier:()=>rr,toolCallExtractor:()=>Pr,toolExecution:()=>nt,toolRegistry:()=>ot,toolSelector:()=>Wr,validateGraphDef:()=>Xr,withBreaker:()=>Ke,withBudgetGate:()=>Ue,withDryRun:()=>mr,withRateLimiter:()=>ze,withReplayCache:()=>Ge,withRetry:()=>Ye,withTimeout:()=>Je,zeroPrice:()=>Ae});function Te(t,e){return`${t}::${e}`}function nr(t){let e=xe({name:"capabilitiesRegistry"}),r=i=>{e.set(Te(i.provider,i.id),i)};if(t)for(let i of t)r(i);let n=(i,d)=>{let m=e.get(Te(i,d));if(m)return m;let c=e.entries.cache;if(!c)return;let p;for(let[,g]of c){if(g.provider!==i)continue;let y=g.id;d.startsWith(y)&&(!p||y.length>p.id.length)&&(p=g)}return p},o=128,a=new Map,s=new Map,l=(i,d,m,c)=>{for(i.has(d)&&i.delete(d),i.set(d,m);i.size>c;){let p=i.keys().next().value;if(p===void 0)break;i.delete(p)}},u=v([e.entries],([i])=>Array.from(i.values()),{name:"capabilitiesRegistry/entries",initial:[]});return{register:r,lookup:n,remove(i,d){let m=e.has(Te(i,d));return m&&e.delete(Te(i,d)),m},entries(){let i=e.entries.cache;return(function*(){if(i)for(let d of i.values())yield d})()},lookupNode(i,d){let m=Te(i,d),c=a.get(m);if(c)return a.delete(m),a.set(m,c),c;let p=v([e.entries],()=>n(i,d),{name:`capabilitiesRegistry/lookup/${i}::${d}`,initial:void 0});return l(a,m,p,o),p},entriesNode:u,byProvider(i){let d=s.get(i);if(d)return s.delete(i),s.set(i,d),d;let m=v([u],([c])=>c.filter(p=>p.provider===i),{name:`capabilitiesRegistry/byProvider/${i}`,initial:[]});return l(s,i,m,o),m}}}function z(t){let e=t.input,r=e.regular+(e.cacheRead??0)+(e.cacheWrite5m??0)+(e.cacheWrite1h??0)+(e.cacheWriteOther??0)+(e.audio??0)+(e.image??0)+(e.video??0)+(e.toolUse??0);if(!e.extensions)return r;let n=0;for(let o of Object.values(e.extensions))n+=o;return r+n}function ne(t){let e=t.output,r=e.regular+(e.reasoning??0)+(e.audio??0)+(e.predictionAccepted??0)+(e.predictionRejected??0);if(!e.extensions)return r;let n=0;for(let o of Object.values(e.extensions))n+=o;return r+n}function Nt(){return{input:{regular:0},output:{regular:0}}}function or(t,e){let r=e?.logMax??1e3,n=pe(void 0,{name:e?.name?`${e.name}/stats`:"adapterStats",maxSize:r}),o=L(null,{name:"adapterStats/lastCall"}),a=v([n.entries],([y])=>y.length,{name:"adapterStats/totalCalls",initial:0}),s=v([n.entries],([y])=>y.reduce((f,h)=>f+z(h.usage),0),{name:"adapterStats/totalInputTokens",initial:0}),l=v([n.entries],([y])=>y.reduce((f,h)=>f+ne(h.usage),0),{name:"adapterStats/totalOutputTokens",initial:0}),u=[j(a),j(s),j(l)],i=y=>{n.append(y),o.emit(y)},d=()=>{n.clear(),o.emit(null)},m=V(t,{invoke(y,f){let h=H(),b=be(),k=t.model??f?.model??"",R=A=>(i(de({provider:t.provider,model:t.model??f?.model??A.model??"",tier:f?.tier??A.tier,usage:A.usage??ee(),startNs:h,startWallClockNs:b,method:"invoke"})),A),C=A=>{let D=A;i(de({provider:t.provider,model:k,tier:f?.tier,usage:ee(),startNs:h,startWallClockNs:b,method:"invoke",error:{type:D?.name??"Error",message:D?.message??String(A)}}))};return Le(t.invoke(y,f),{onResp:R,onError:C,name:"adapterStats/invokeTap"})},async*stream(y,f){let h=H(),b=be(),k=t.model??f?.model??"",R;try{for await(let C of t.stream(y,f))C.type==="usage"&&(R=C.usage),yield C;i(de({provider:t.provider,model:k,tier:f?.tier,usage:R??ee(),startNs:h,startWallClockNs:b,method:"stream"}))}catch(C){let A=C;throw i(de({provider:t.provider,model:k,tier:f?.tier,usage:R??ee(),startNs:h,startWallClockNs:b,method:"stream",error:{type:A?.name??"Error",message:A?.message??String(C)}})),C}}});U(m,"observableAdapter",t);let c=!1;return{adapter:m,stats:{lastCall:o,allCalls:n,totalCalls:a,totalInputTokens:s,totalOutputTokens:l,reset:d,dispose:()=>{if(!c){c=!0;for(let y of u)y();u.length=0}}}}}function ar(t,e){return t==null?0:typeof t=="number"?t:t.thresholdTokens!=null&&t.pricePerMillionAbove!=null&&e>t.thresholdTokens?t.pricePerMillionAbove:t.pricePerMillion}function Ae(t="USD"){return{total:0,currency:t}}function We(t,e,r){let n=z(t),o=e.currency??"USD",a=r?.withBreakdown===!0,s=a?{}:null,l=0,u=(f,h,b)=>{if(!h||b==null)return;let k=ar(b,n),R=h*k/1e6;l+=R,a&&(s[f]=(s[f]??0)+R)},i=t.input,d=e.input;if(d&&(u("input.regular",i.regular,d.regular),u("input.cacheRead",i.cacheRead??0,d.cacheRead),u("input.cacheWrite5m",i.cacheWrite5m??0,d.cacheWrite5m),u("input.cacheWrite1h",i.cacheWrite1h??0,d.cacheWrite1h),u("input.cacheWriteOther",i.cacheWriteOther??0,d.cacheWriteOther),u("input.audio",i.audio??0,d.audio),u("input.image",i.image??0,d.image),u("input.video",i.video??0,d.video),u("input.toolUse",i.toolUse??0,d.toolUse),i.extensions&&d.extensions))for(let[f,h]of Object.entries(i.extensions))u(`input.ext.${f}`,h,d.extensions[f]);let m=t.output,c=e.output;if(c&&(u("output.regular",m.regular,c.regular),u("output.reasoning",m.reasoning??0,c.reasoning),u("output.audio",m.audio??0,c.audio),u("output.predictionAccepted",m.predictionAccepted??0,c.predictionAccepted),u("output.predictionRejected",m.predictionRejected??0,c.predictionRejected),m.extensions&&c.extensions))for(let[f,h]of Object.entries(m.extensions))u(`output.ext.${f}`,h,c.extensions[f]);let p=r?.tier;if(p&&e.tierMultipliers){let f=e.tierMultipliers[p];if(f!=null&&(l*=f,a))for(let h of Object.keys(s))s[h]*=f}let g=t.auxiliary,y=e.auxiliary;if(g&&y)for(let[f,h]of Object.entries(g)){let b=y[f];if(b==null||!h)continue;let k=h*b;l+=k,a&&(s[`auxiliary.${f}`]=k)}return a?{total:l,currency:o,breakdown:s}:{total:l,currency:o}}function Ne(t,e){return`${t}::${e}`}function sr(t){let e=new Map,r=new Map,n=(o,a,s)=>{e.set(Ne(o,a),{provider:o,model:a,pricing:s});let l=r.get(o);l||(l=new Set,r.set(o,l)),l.add(a)};if(t)for(let[o,a,s]of t)n(o,a,s);return{register:n,lookup(o,a){let s=e.get(Ne(o,a));if(s)return s.pricing;let l=r.get(o);if(!l)return;let u;for(let i of l)if(a.startsWith(i)&&(!u||i.length>u.key.length)){let d=e.get(Ne(o,i));d&&(u={key:i,pricing:d.pricing})}return u?.pricing},remove(o,a){let s=e.delete(Ne(o,a));if(s){let l=r.get(o);l?.delete(a),l&&l.size===0&&r.delete(o)}return s},entries(){let o=e.values();return(function*(){for(let{provider:a,model:s,pricing:l}of o)yield[a,s,l]})()}}}function ir(t,e="USD"){return(r,n)=>{let o=t.lookup(n.provider,n.model);return o?We(r,o,{tier:n.tier,withBreakdown:n.withBreakdown}):Ae(e)}}function lr(...t){return(e,r)=>{for(let n of t){let o=n(e,r);if(o.total!==0)return o}return t.length>0?t[0](e,r):Ae()}}function dr(t,e,r){return t?.pricing?We(e,t.pricing,r):Ae()}function Ke(t,e={}){let r=e.breaker??mt(e),n=V(t,{async invoke(o,a){if(!r.canExecute())throw new Re;try{let s=await ae(x(t.invoke(o,a)));return r.recordSuccess(),s}catch(s){throw r.recordFailure(s),s}},async*stream(o,a){if(!r.canExecute())throw new Re;try{for await(let s of t.stream(o,a))yield s;r.recordSuccess()}catch(s){throw r.recordFailure(s),s}}});return U(n,"withBreaker",t),{adapter:n,breaker:r}}var Ce=class extends Error{constructor(r,n,o){super(`Budget exhausted: ${r} (limit=${n}, observed=${o})`);this.which=r;this.limit=n;this.observed=o}name="BudgetExhaustedError"},Ve=Object.freeze({calls:0,inputTokens:0,outputTokens:0,usd:0}),At=()=>({calls:0,inputTokens:0,outputTokens:0,usd:0});function Ue(t,e){let r=pe(void 0,{name:e.name?`${e.name}/log`:"budgetGate/log",maxSize:e.logMax??1e3}),n=L(At(),{name:e.name?`${e.name}/totals`:"budgetGate/totals"}),o=v([n],([i])=>{let d=i;return!(e.caps.calls!=null&&d.calls>=e.caps.calls||e.caps.inputTokens!=null&&d.inputTokens>=e.caps.inputTokens||e.caps.outputTokens!=null&&d.outputTokens>=e.caps.outputTokens||e.caps.usd!=null&&d.usd>=e.caps.usd)},{name:e.name?`${e.name}/isOpen`:"budgetGate/isOpen",initial:!0});if(j(o),e.onExhausted!=null){let i=e.onExhausted,d=!1,m=!0;o.subscribe(c=>{for(let p of c)if(p[0]===G){let g=p[1];if(d&&m&&g===!1){let y=Ct(n.cache??Ve,e.caps);y&&i(y)}m=g,d=!0}})}let a=()=>{if(o.cache===!1){let i=n.cache??Ve,d=Ct(i,e.caps);return new Ce(d??"budget",e.caps[d??"calls"]??0,ur(i,d??"calls"))}},s=(i,d)=>{let m=t.provider,c=de({provider:m,model:d.model,tier:d.tier,usage:i,startNs:d.startNs,method:d.method,...d.error?{error:d.error}:{}});r.append(c);let p=n.cache??Ve,g=e.pricingFn?p.usd+e.pricingFn(i,{model:d.model,provider:m,tier:d.tier}).total:p.usd;n.emit({calls:p.calls+1,inputTokens:p.inputTokens+z(i),outputTokens:p.outputTokens+ne(i),usd:g})},l=()=>{r.clear(),n.emit(At())},u=V(t,{invoke(i,d){let m=a();if(m)return Promise.reject(m);let c=H(),p=t.model??d?.model??"",g=f=>(s(f.usage??ee(),{model:t.model??d?.model??f.model??"",tier:d?.tier??f.tier,startNs:c,method:"invoke"}),f),y=f=>{let h=f;s(ee(),{model:p,tier:d?.tier,startNs:c,method:"invoke",error:{type:h?.name??"Error",message:h?.message??String(f)}})};return Le(t.invoke(i,d),{onResp:g,onError:y,name:"budgetGate/invokeTap"})},async*stream(i,d){let m=a();if(m)throw m;let c=H(),p;try{for await(let g of t.stream(i,d))g.type==="usage"&&(p=g.usage),yield g;s(p??ee(),{model:t.model??d?.model??"",tier:d?.tier,startNs:c,method:"stream"})}catch(g){let y=g;throw s(p??ee(),{model:t.model??d?.model??"",tier:d?.tier,startNs:c,method:"stream",error:{type:y?.name??"Error",message:y?.message??String(g)}}),g}}});return U(u,"withBudgetGate",t),{adapter:u,budget:{totals:n,isOpen:o,log:r,reset:l}}}function Ct(t,e){if(e.calls!=null&&t.calls>=e.calls)return"calls";if(e.inputTokens!=null&&t.inputTokens>=e.inputTokens)return"inputTokens";if(e.outputTokens!=null&&t.outputTokens>=e.outputTokens)return"outputTokens";if(e.usd!=null&&t.usd>=e.usd)return"usd"}function ur(t,e){switch(e){case"calls":return t.calls;case"inputTokens":return t.inputTokens;case"outputTokens":return t.outputTokens;case"usd":return t.usd}}function mr(t,e){let r=e.mock??Fe({provider:t.provider,model:t.model}),n=typeof e.enabled=="boolean"?e.enabled:void 0,o=n===void 0?x(e.enabled):void 0,a;o&&(a=j(o));let s=()=>n!==void 0?n:!!o?.cache,l=V(t,{invoke(i,d){return s()?r.invoke(i,d):t.invoke(i,d)},stream(i,d){return s()?r.stream(i,d):t.stream(i,d)}});return U(l,"withDryRun",t),{adapter:l,dispose:()=>{a&&(a(),a=void 0)}}}function qe(t){if(t==null||typeof t!="object")return;let e=t,r=e.status,n=cr(e.headers);if(r!==429&&r!==503&&!br(e.message))return;let o={},a=n("retry-after"),s=fr(a);s!=null&&(o.retryAfterMs=s);let l=n("anthropic-ratelimit-requests-reset");if(l){let p=St(l);p!=null&&(o.retryAfterMs=Math.max(o.retryAfterMs??0,p))}let u=n("anthropic-ratelimit-tokens-reset");if(u){let p=St(u);p!=null&&(o.retryAfterMs=Math.max(o.retryAfterMs??0,p))}let i=Se(n,"x-ratelimit-limit-requests");i!=null&&(o.rpmCap=i);let d=Se(n,"x-ratelimit-limit-tokens");d!=null&&(o.tpmCap=d);let m=Se(n,"x-ratelimit-remaining-requests"),c=Se(n,"x-ratelimit-remaining-tokens");if(m!=null&&i!=null&&i>0&&(o.usageHint??={},o.usageHint.rpm=1-m/i),c!=null&&d!=null&&d>0&&(o.usageHint??={},o.usageHint.tpm=1-c/d),o.retryAfterMs==null&&e.message){let p=yr(e.message);p!=null&&(o.retryAfterMs=p)}return e.headers&&(o.metadata={headers:pr(e.headers)}),o.retryAfterMs==null&&o.rpmCap==null&&o.tpmCap==null&&o.usageHint==null?o.metadata?o:void 0:o}function cr(t){if(!t)return()=>{};if(typeof t.get=="function"){let n=t;return o=>n.get(o)??n.get(o.toLowerCase())??void 0}let e=t,r={};for(let[n,o]of Object.entries(e)){let a=Array.isArray(o)?o.join(", "):o;a!=null&&(r[n.toLowerCase()]=a)}return n=>r[n.toLowerCase()]}function pr(t){let e={};if(typeof t.forEach=="function")return t.forEach((r,n)=>{e[n]=r}),e;for(let[r,n]of Object.entries(t))n!=null&&(e[r]=Array.isArray(n)?n.join(", "):n);return e}function Se(t,e){let r=t(e);if(r==null)return;let n=Number(r);return Number.isFinite(n)?n:void 0}function fr(t){if(!t)return;let e=t.trim(),r=Number(e);if(Number.isFinite(r)&&r>=0)return r*1e3;let n=Date.parse(e);if(Number.isFinite(n)){let o=n-Date.now();if(o>0)return o}}function St(t){if(!t)return;let e=Date.parse(t);if(Number.isFinite(e))return Math.max(0,e-Date.now())}var gr=/retry\s+(?:in|after)\s+(\d+(?:\.\d+)?)\s*(ms|s|sec|seconds?|m|min|minutes?)/i;function yr(t){let e=gr.exec(t);if(!e)return;let r=Number(e[1]);if(!Number.isFinite(r))return;let n=(e[2]??"s").toLowerCase();if(n==="ms")return r;if(n.startsWith("s"))return r*1e3;if(n.startsWith("m"))return r*6e4}var hr=/rate\s*limit|too\s*many\s*requests|quota|429/i;function br(t){return!!t&&hr.test(t)}function He(t){let e=new Error(t);return e.name="AbortError",e}function Ot(t={}){let e=Math.max(1,t.burstMultiplier??1),r=t.clampCooldownMs??6e4,n=t.rpm!=null?x(t.rpm):L(Number.POSITIVE_INFINITY),o=t.tpm!=null?x(t.tpm):L(Number.POSITIVE_INFINITY),a=L(Number.POSITIVE_INFINITY,{name:"adaptiveRateLimiter/signalRpmCap"}),s=L(Number.POSITIVE_INFINITY,{name:"adaptiveRateLimiter/signalTpmCap"}),l=L({},{name:"adaptiveRateLimiter/lastSignal"}),u=v([n,a],([T,I])=>Math.min(Number(T??1/0),Number(I??1/0)),{name:"adaptiveRateLimiter/effectiveRpm"}),i=v([o,s],([T,I])=>Math.min(Number(T??1/0),Number(I??1/0)),{name:"adaptiveRateLimiter/effectiveTpm"}),d=fe(Number(n.cache??Number.POSITIVE_INFINITY),e),m=fe(Number(o.cache??Number.POSITIVE_INFINITY),e),c=!1,p=!1,g=u.subscribe(T=>{for(let I of T)if(I[0]===G){let P=Number(I[1]);Number.isFinite(P)&&P>0?(d=fe(P,e),c=!1):P===1/0?(d=fe(1/0,e),c=!1):P<=0&&(c=!0)}}),y=i.subscribe(T=>{for(let I of T)if(I[0]===G){let P=Number(I[1]);Number.isFinite(P)&&P>0?(m=fe(P,e),p=!1):P===1/0?(m=fe(1/0,e),p=!1):P<=0&&(p=!0)}}),f=0,h=new Z,b=new Z,k;t.adaptation!=null&&(k=x(t.adaptation).subscribe(I=>{for(let P of I)P[0]===G&&R(P[1])}));function R(T){if(l.emit(T),T.rpmCap!=null&&Number.isFinite(T.rpmCap)&&T.rpmCap>=0&&(a.emit(T.rpmCap),Number.isFinite(r)&&r>0&&h.start(r,()=>a.emit(Number.POSITIVE_INFINITY))),T.tpmCap!=null&&Number.isFinite(T.tpmCap)&&T.tpmCap>=0&&(s.emit(T.tpmCap),Number.isFinite(r)&&r>0&&b.start(r,()=>s.emit(Number.POSITIVE_INFINITY))),T.retryAfterMs!=null&&T.retryAfterMs>0){let I=H()+T.retryAfterMs*1e6;I>f&&(f=I)}}let C=L(0,{name:"adaptiveRateLimiter/pending"}),A=L(Number.POSITIVE_INFINITY,{name:"adaptiveRateLimiter/rpmAvailable"}),D=L(Number.POSITIVE_INFINITY,{name:"adaptiveRateLimiter/tpmAvailable"}),_=T=>{C.emit((C.cache??0)+T)},E=()=>{A.emit(d.available()),D.emit(m.available())};async function O(T={}){let I=T.requestCost??1,P=T.tokenCost??0,K=T.signal;_(1);try{for(;;){if(K?.aborted)throw He("AdaptiveRateLimiter.acquire aborted");let te=H();if(f>te){let M=Math.ceil((f-te)/1e6);await Ee(M,K);continue}if(I>0&&c||P>0&&p){await Ee(250,K);continue}let ie=d,ue=m;if(!ie.tryConsume(I)){await Ee(Et(ie,I),K);continue}if(!(P>0?ue.tryConsume(P):!0)){ie.putBack(I),await Ee(Et(ue,P),K);continue}E();return}}finally{_(-1)}}function S(T){T>0?m.tryConsume(T):T<0&&m.putBack(-T),E()}function F(){g(),y(),k?.(),h.cancel(),b.cancel()}return{effectiveRpm:u,effectiveTpm:i,lastSignal:l,pending:C,rpmAvailable:A,tpmAvailable:D,acquire:O,recordUsage:S,recordSignal:R,dispose:F}}function fe(t,e){if(!Number.isFinite(t)||t===1/0)return je(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);let r=Math.max(1,t*e),n=t/60;return je(r,n)}function Et(t,e){let r=t.available(),n=Math.max(0,e-r);return n<=0?25:Math.min(5e3,Math.max(50,n*100))}function Ee(t,e){return t<=0?Promise.resolve():e?.aborted?Promise.reject(He("AdaptiveRateLimiter.acquire aborted")):new Promise((r,n)=>{let o=new Z,a,s=()=>{o.cancel(),e&&a&&e.removeEventListener("abort",a)};o.start(t,()=>{s(),r()}),e&&(a=()=>{s(),n(He("AdaptiveRateLimiter.acquire aborted"))},e.addEventListener("abort",a,{once:!0}))})}function ze(t,e={}){let r=e.limiter??Ot({name:e.name??"rateLimiter",rpm:e.rpm,tpm:e.tpm,adaptation:e.adaptation,burstMultiplier:e.burstMultiplier}),n=(s,l)=>e.costFn?e.costFn(s,l):0,o=s=>{let l=qe(s);l&&r.recordSignal(l)},a=V(t,{async invoke(s,l){let u=n(s,l);await r.acquire({requestCost:1,tokenCost:u,signal:l?.signal});try{let i=await ae(x(t.invoke(s,l))),d=i.usage??Nt(),c=z(d)+ne(d)-u;return c>0&&r.recordUsage(c),i}catch(i){throw o(i),i}},async*stream(s,l){let u=n(s,l);await r.acquire({requestCost:1,tokenCost:u,signal:l?.signal});try{let i=0;for await(let m of t.stream(s,l))m.type==="usage"&&(i=z(m.usage)+ne(m.usage)),yield m;let d=i-u;d>0&&r.recordUsage(d)}catch(i){throw o(i),i}}});return U(a,"withRateLimiter",t),{adapter:a,limiter:r}}function Oe(t="aborted"){let e=new Error(t);return e.name="AbortError",e}function It(t,e){return t<=0?Promise.resolve():e?.aborted?Promise.reject(Oe()):new Promise((r,n)=>{let o=new Z,a,s=()=>{o.cancel(),e&&a&&e.removeEventListener("abort",a)};o.start(t,()=>{s(),r()}),e&&(a=()=>{s(),n(Oe())},e.addEventListener("abort",a,{once:!0}))})}function Ye(t,e={}){let r=e.attempts??3,n=e.baseDelayMs??500,o=e.maxDelayMs??1e4,a=e.strategy??"decorrelated",s=e.jitter??!0,l=e.shouldRetry??Tr,u=e.retryStreaming??!0,i=(m,c)=>{if(a==="decorrelated"){let f=Math.min(o,Math.max(n,c*3));return n+Math.random()*(f-n)}let p=a==="exp"?n*2**(m-1):n*m,g=Math.min(o,p);if(!s)return g;let y=g*(.5+Math.random());return Math.min(o,y)},d=V(t,{async invoke(m,c){if(c?.signal?.aborted)throw Oe();let p,g=n;for(let y=1;y<=r;y++)try{return await ae(x(t.invoke(m,c)))}catch(f){if(p=f,y>=r||!l(f,y))throw f;let h=i(y,g);g=h,await It(h,c?.signal)}throw p},async*stream(m,c){if(c?.signal?.aborted)throw Oe();if(!u){for await(let y of t.stream(m,c))yield y;return}let p,g=n;for(let y=1;y<=r;y++){let f=!1;try{for await(let h of t.stream(m,c))f=!0,yield h;return}catch(h){if(p=h,f||y>=r||!l(h,y))throw h;let b=i(y,g);g=b,await It(b,c?.signal)}}throw p}});return U(d,"withRetry",t),d}function Tr(t,e){if(t==null)return!1;let r=t;return r.name==="LLMTimeoutError"?!0:r.name==="AbortError"||r.message==="aborted"||r.name==="DOMException"&&r.code!=null&&Number(r.code)===20||r.name==="BudgetExhaustedError"||r.name==="CircuitOpenError"?!1:r.status!=null?r.status===429||r.status>=500&&r.status<600:r.code&&typeof r.code=="string"&&/^E[A-Z]+$/.test(r.code)?!0:r.message?/network|timeout|socket|fetch|econn|eai_/i.test(r.message):!1}var ge=class extends Error{constructor(r){super(`LLM call timed out after ${r}ms`);this.ms=r}name="LLMTimeoutError"};function Je(t,e){if(e<=0)throw new RangeError("withTimeout: ms must be > 0");let r=a=>{let s=new AbortController,l=!1,u,i=new Z;return a&&(a.aborted?s.abort(a.reason):(u=()=>{i.cancel(),s.abort(a.reason)},a.addEventListener("abort",u,{once:!0}))),i.start(e,()=>{l=!0,s.abort(new ge(e))}),{signal:s.signal,cancel:()=>{i.cancel(),a&&u&&a.removeEventListener("abort",u)},timedOut:()=>l}},n=(a,s)=>{if(!s||a instanceof ge)throw a;let l=a;if(l?.name==="AbortError"||l?.name==="DOMException"&&Number(l.code)===20||a?.message==="aborted"){let i=new ge(e);throw i.cause=a,i}throw a},o=V(t,{async invoke(a,s){let{signal:l,cancel:u,timedOut:i}=r(s?.signal);try{return await ae(x(t.invoke(a,{...s,signal:l})))}catch(d){return n(d,i())}finally{u()}},async*stream(a,s){let{signal:l,cancel:u,timedOut:i}=r(s?.signal);try{for await(let d of t.stream(a,{...s,signal:l}))yield d}catch(d){n(d,i())}finally{u()}}});return U(o,"withTimeout",t),o}function Mr(t,e={}){let r={adapter:t},n=t;if(e.rateLimit){let o=ze(n,e.rateLimit);n=o.adapter,r.rateLimiter=o.limiter}if(e.budget){let o=Ue(n,e.budget);n=o.adapter,r.budget=o.budget}if(e.breaker){let o=Ke(n,e.breaker);n=o.adapter,r.breaker=o.breaker}if(e.timeoutMs!=null&&(n=Je(n,e.timeoutMs)),e.retry&&(n=Ye(n,e.retry)),e.fallback){if(e.name==="fallback")throw new RangeError('resilientAdapter: `name` cannot be "fallback" \u2014 collides with the secondary tier label.');let o={};e.onFallback&&(o.onFallback=e.onFallback),e.onExhausted&&(o.onExhausted=e.onExhausted),n=Be([{name:e.name??"primary",adapter:n},{name:"fallback",adapter:e.fallback}],o)}return e.cache&&(n=Ge(n,e.cache)),r.adapter=n,r}function N(t,e){return dt("ai",t,e)}function vr(t){return t!=null&&typeof t.then=="function"}function Qe(t){return typeof t=="object"&&t!==null&&"subscribe"in t&&typeof t.subscribe=="function"&&"cache"in t}function kr(t){return t!=null&&typeof t=="object"&&Symbol.asyncIterator in t&&typeof t[Symbol.asyncIterator]=="function"}var Rr=3e4;function Dt(t,e){if(t.status==="settled"){let n=t.cache;if(n!==void 0)return Promise.resolve(n)}let r=e?.timeoutMs??Rr;return new Promise((n,o)=>{let a=new Z,s=t.subscribe(l=>{for(let u of l){if(u[0]===G){a.cancel(),s(),n(u[1]);return}if(u[0]===W){a.cancel(),s(),o(u[1]);return}if(u[0]===q){a.cancel(),s(),o(new Error("firstDataFromNode: completed without producing a value"));return}}});a.start(r,()=>{s(),o(new Error(`firstDataFromNode: timed out after ${r}ms`))})})}async function Me(t){return vr(t)?Me(await t):Qe(t)?Dt(t):kr(t)?Dt(x(t)):t}function ye(t){let e=t.match(/^```(?:json)?\s*([\s\S]*?)\s*```[\s\S]*$/);return e?e[1]:t}function co(t,e,r){return Q(n=>{let o=new AbortController,a=!1,s=null,l=d=>{a||(a=!0,n.down([[G,d],[q]]),s?.(),s=null)},u;try{u=t.invoke(e,{...r.invokeOpts,signal:o.signal})}catch(d){return l(r.onFailure("throw",d)),()=>o.abort()}return s=x(u,{signal:o.signal}).subscribe(d=>{for(let m of d){if(a)return;if(m[0]===G){try{l(r.onSuccess(m[1]))}catch(c){l(r.onFailure("onSuccess-threw",c))}return}if(m[0]===W){l(r.onFailure("error",m[1]));return}if(m[0]===q){l(r.onFailure("complete",void 0));return}}}),a&&s&&(s(),s=null),()=>{o.abort(),s?.(),s=null}})}function xr(t,e){let r=x(t),n=e?.refreshTrigger!=null?x(e.refreshTrigger):null,o=e?.name!==void 0?{name:e.name}:void 0,a=X("frozenContext",o);return n==null?le([r],(s,l,u)=>{if(u.store.emitted===!0)return;let d=s[0],m=d!=null&&d.length>0?d.at(-1):u.prevData[0];if(m!==void 0)return u.store.emitted=!0,l.emit(m),{invalidate:()=>{u.store.emitted=!1}}},{name:e?.name??"frozenContext",describeKind:"derived",initial:null,meta:N("frozen_context",{...a})}):le([r,n],(s,l,u)=>{let i=s[1];if(!(i!=null&&i.length>0))return;let m=s[0],c=m!=null&&m.length>0?m.at(-1):u.prevData[0];l.emit(c)},{name:e?.name??"frozenContext",describeKind:"derived",initial:null,meta:N("frozen_context",{...a})})}function Pt(t){return t!=null&&typeof t=="object"&&"content"in t?String(t.content):typeof t=="string"?t:String(t)}function wr(t,e=200){return t.length<=e?t:`${t.slice(0,e)}\u2026`}function Xe(t,e,r,n){let o=n?.format??"text",a=n?.name??"prompt_node";n?.tools!==void 0&&o!=="raw"&&console.warn("promptNode: `tools` is set but `format !== 'raw'`. Tool calls in the response will be silently dropped \u2014 set `format: 'raw'` to receive the full LLMResponse with `toolCalls`.");let s=v(e,u=>{if(u.some(d=>d==null))return[];let i=typeof r=="string"?r:r(...u);return i?[{role:"user",content:i}]:[]},{name:`${a}::messages`,meta:N("prompt_node")});return $(s,u=>!u||u.length===0?L(null):Q(i=>{let d=!1,m=!1,c,p={model:n?.model,temperature:n?.temperature,maxTokens:n?.maxTokens,systemPrompt:n?.systemPrompt,...n?.tools!==void 0?{tools:n.tools}:{}};if(n?.abort){let h=gt(n.abort);p.signal=h.signal,c=h.dispose}let g;try{g=t.invoke(u,p)}catch(h){return d=!0,i.down([[W,h]]),()=>{c?.()}}let f=x(g).subscribe(h=>{if(!(m||d))for(let b of h){if(d)return;if(b[0]===G){let k=b[1];if(o==="raw")i.emit(k);else try{let R=Pt(k),C=o==="json"?JSON.parse(ye(R)):R;i.emit(C)}catch(R){let C=Pt(k),A=new Error(`promptNode: failed to parse LLM response as JSON: ${R.message}
2
+ Raw content (first 200 chars): ${wr(C)}`);d=!0,i.down([[W,A]]);return}}else if(b[0]===W){d=!0,i.down([[W,b[1]]]);return}else if(b[0]===q){d=!0,i.down([[q]]);return}else i.down([b])}});return()=>{m=!0,f(),c?.()}},{name:`${a}::call`,meta:N("prompt_node::call")}),{name:`${a}::output`,meta:n?.meta?{...N("prompt_node::output"),...n.meta}:N("prompt_node::output")})}function Ze(t,e,r,n){let o=r.name??n;return a=>{let s=L(a);return Xe(r.adapter,[s],l=>e(l),{name:o,format:"json",systemPrompt:t,model:r.model,temperature:r.temperature??0,maxTokens:r.maxTokens})}}function et(t,e){let r=e.maxExistingKeys??100,n=Ze(t,o=>JSON.stringify({input:o.raw,existingKeys:o.existingKeys}),e,"llmExtractor");return(o,a)=>{let s=r===Number.POSITIVE_INFINITY?[...a.keys()]:[...a.keys()].slice(0,r);return n({raw:o,existingKeys:s})}}function tt(t,e){let r=Ze(t,n=>JSON.stringify({memories:n}),e,"llmConsolidator");return n=>{let o=[...n.entries()].map(([a,s])=>({key:a,value:s}));return r(o)}}async function jt(t,e,r,n){let o="",a=0;for await(let s of t.stream(e,r))n.publish({...s,seq:a++,ts:be()}),s.type==="token"&&(o+=s.delta);return o}function _t(t,e){if(e==="json")try{return JSON.parse(ye(t))}catch(r){let n=t.slice(0,160);throw new Error(`streamingPromptNode: format:"json" \u2014 failed to parse accumulated text as JSON: ${r.message}; content preview: ${n}`)}return t}function Ft(t,e){return v([t.latest],([r],n)=>{let o=n.store;if(r==null)return o.acc??"";let a=r;return a.seq===0&&(o.acc=""),a.type==="token"&&(o.acc=(o.acc??"")+a.delta),o.acc??""},{name:e,meta:N("accumulated_text"),initial:""})}function Lr(t,e,r,n){let o=n?.name??"llm",a=n?.format??"text",s=$e(`${o}/stream`,{...n?.retainedLimit!=null?{retainedLimit:n.retainedLimit}:{}}),l=v(e,m=>{if(m.some(p=>p==null))return[];let c=typeof r=="string"?r:r(...m);return c?[{role:"user",content:c}]:[]},{name:`${o}::messages`,meta:N("prompt_node::messages"),initial:[]}),u=$(l,m=>{let c=m;if(!c||c.length===0)return L(null);let p=new AbortController;async function*g(){try{let y=await jt(t,c,{model:n?.model,temperature:n?.temperature,maxTokens:n?.maxTokens,systemPrompt:n?.systemPrompt,signal:p.signal},s);yield _t(y,a)}finally{p.abort()}}return x(g())},{meta:X("streamingPromptNode")}),i=Ft(s,`${o}::accumulatedText`),d=j(u);return{output:u,deltaTopic:s,accumulatedText:i,dispose:()=>{d(),s.destroy()}}}function Nr(t,e,r,n,o,a){let s=L(0,{name:`${e}/cancel`}),l=0,u=[...n,s],i=a?.name??e,d=a?.format??"text",m=$e(`${i}/stream`,{...a?.retainedLimit!=null?{retainedLimit:a.retainedLimit}:{}}),c=v(u,D=>{let _=D.slice(0,-1);if(_.some(O=>O==null))return[];let E=typeof o=="string"?o:o(..._);return E?[{role:"user",content:E}]:[]},{name:`${i}::messages`,meta:N("prompt_node::messages"),initial:[]}),p=$(c,D=>{let _=D;if(!_||_.length===0)return L(null);let E=new AbortController;async function*O(){try{let S=await jt(r,_,{model:a?.model,temperature:a?.temperature,maxTokens:a?.maxTokens,systemPrompt:a?.systemPrompt,signal:E.signal},m);yield _t(S,d)}finally{E.abort()}}return x(O())},{meta:X("gatedStream")}),g=Ft(m,`${i}::accumulatedText`),y=yt(p,D=>D!=null);t.add(y,{name:`${e}/raw`});let f=vt(`${e}/gate-graph`);t.mount(`${e}/gate-graph`,f),f.add(y,{name:`${e}/raw`});let h=f.approvalGate(`${e}/gate`,`${e}/raw`,a?.gate),b=j(p),k=j(h.node),R=j(g);t.addDisposer(b),t.addDisposer(k),t.addDisposer(R);let C=h.reject.bind(h),A={...h,reject(D=1){J(()=>{C(D),s.emit(++l)})}};return{output:h.node,deltaTopic:m,accumulatedText:g,gate:A,dispose:()=>{b(),k(),R(),m.destroy()}}}function Ar(t,e){let r=e?.separator??`
3
+
4
+ `,n=t.map(s=>typeof s=="string"?L(s):x(s)),o=v(n,s=>s.filter(l=>l!=null&&l!=="").join(r),{name:e?.name??"systemPrompt",describeKind:"derived",meta:N("system_prompt"),initial:""}),a=j(o);return Object.assign(o,{dispose:a})}var Cr=(t,e)=>t===e?!0:t.chunkCount===e.chunkCount&&t.charCount===e.charCount&&t.estimatedTokens===e.estimatedTokens&&t.estimated===e.estimated;function Sr(t,e){let r=e?.charsPerToken??4,n={chunkCount:0,charCount:0,estimatedTokens:0,estimated:!0};return v([t.latest],([o],a)=>{if(o==null)return n;let s=o;"chunkCount"in a.store||(a.store.chunkCount=0,a.store.charCount=0,a.store.usageTokens=0,a.store.sawUsage=!1);let l=a.store;s.type==="token"?(l.chunkCount+=1,l.charCount+=s.delta.length):s.type==="usage"&&(l.sawUsage=!0,l.usageTokens=z(s.usage)+ne(s.usage));let u=l.sawUsage?l.usageTokens:Math.ceil(l.charCount/r);return{chunkCount:l.chunkCount,charCount:l.charCount,estimatedTokens:u,estimated:!l.sawUsage}},{name:e?.name??"cost-meter",describeKind:"derived",initial:n,meta:N("cost_meter_extractor"),equals:Cr})}var Er=(t,e)=>{if(t===e)return!0;if(t==null||e==null)return t===e;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++){let n=t[r],o=e[r];if(n.label!==o.label||n.pattern!==o.pattern||n.match!==o.match||n.position!==o.position)return!1}return!0};function Or(t,e){let r=e.maxPatternLength??128;for(let o of e.patterns)if(o.pattern.source.length>r)throw new Error(`keywordFlagExtractor: pattern "${o.label}" literal exceeds maxPatternLength (${o.pattern.source.length} > ${r}); raise the option or shorten the pattern.`);let n=e.patterns.map(o=>({label:o.label,pattern:o.pattern,compiled:new RegExp(o.pattern.source,`${o.pattern.flags.replace("g","")}g`)}));return v([t],([o],a)=>{if(o==null)return[];let s=o;"flags"in a.store||(a.store.flags=[],a.store.scannedTo=0);let l=a.store.flags,u=a.store.scannedTo,i=Math.max(0,u-r),d=s.slice(i),m=!1;for(let{pattern:c,label:p,compiled:g}of n){g.lastIndex=0;for(let y of d.matchAll(g)){let f=i+(y.index??0);f+y[0].length<=u||(l.push({label:p,pattern:c,match:y[0],position:f}),m=!0)}}return a.store.scannedTo=s.length,m?[...l]:l.slice()},{name:e.name??"keyword-flag-extractor",describeKind:"derived",initial:[],meta:N("keyword_flag_extractor"),equals:Er})}function Ir(t,e,r){return v([t],([n])=>n==null?null:e(n),{name:r?.name??"extractor",describeKind:"derived",initial:null,meta:N("stream_extractor"),...r?.equals?{equals:r.equals}:{}})}var Dr=(t,e)=>{if(t===e)return!0;if(t==null||e==null)return t===e;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++){let n=t[r],o=e[r];if(n.startIndex!==o.startIndex||n.name!==o.name||n.raw!==o.raw)return!1}return!0};function Pr(t,e){return v([t],([r],n)=>{if(r==null)return[];let o=r;"calls"in n.store||(n.store.calls=[],n.store.scanFrom=0);let a=n.store.calls,s=n.store.scanFrom,l=!1;for(;s<o.length;){let u=o.indexOf("{",s);if(u===-1){n.store.scanFrom=o.length;break}let i=0,d=-1,m=!1;for(let p=u;p<o.length;p++){let g=o[p];if(m)g==="\\"&&p+1<o.length?p++:g==='"'&&(m=!1);else if(g==='"')m=!0;else if(g==="{")i++;else if(g==="}"&&(i--,i===0)){d=p;break}}if(d===-1){n.store.scanFrom=u;break}let c=o.slice(u,d+1);try{let p=JSON.parse(c);typeof p.name=="string"&&p.arguments!=null&&typeof p.arguments=="object"&&(a.push({name:p.name,arguments:p.arguments,raw:c,startIndex:u}),l=!0)}catch{}s=d+1,n.store.scanFrom=s}return l?[...a]:a.slice()},{name:e?.name??"tool-call-extractor",describeKind:"derived",initial:[],meta:N("tool_call_extractor"),equals:Dr})}function jr(t,e,r,n){let o=r*(n?.hardMultiplier??1.5),a=typeof e!="function",s=[t];return a&&s.push(e),v(s,l=>{let u=l[0]??"";if(u.length===0)return"allow";let i=a?l[1]??0:e(u);return i>=o?"block":i>=r?"review":"allow"},{name:n?.name??"content-gate",initial:"allow"})}function _r(t,e,r,n){let o=r??(()=>"[REDACTED]");function a(s){let l=s;for(let u of e){let i=u.global?u:new RegExp(u.source,`${u.flags}g`);l=l.replace(i,d=>o(d,u))}return l}return v([t],([s])=>a(s??""),{name:n?.name??"redactor",initial:""})}var Ie=class extends se{_log;messages;latest;messageCount;constructor(e,r={}){super(e,r.graph),this._log=pe([],{name:"messages",maxSize:r.maxMessages}),this.messages=this._log.entries,this.add(this.messages,{name:"messages"}),this.latest=v([this.messages],([n])=>{let o=n;return o.length===0?null:o[o.length-1]},{name:"latest",describeKind:"derived",meta:N("chat_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(j(this.latest)),this.messageCount=v([this.messages],([n])=>n.length,{name:"messageCount",describeKind:"derived",meta:N("chat_message_count"),initial:0}),this.add(this.messageCount,{name:"messageCount"}),this.addDisposer(j(this.messageCount))}append(e,r,n){this._log.append({role:e,content:r,...n})}appendToolResult(e,r){this._log.append({role:"tool",content:r,toolCallId:e})}clear(){this._log.clear()}allMessages(){return this.messages.cache}};function rt(t,e){return new Ie(t,e)}function nt(t){let{toolCalls:e,tools:r}=t,n=t.retryCount??1,o=t.onError??"rescue",a=(s,l)=>{if(s===l)return!0;if(s.length!==l.length)return!1;for(let u=0;u<s.length;u++){let i=s[u],d=l[u];if(i?.id!==d?.id||i?.content!==d?.content)return!1}return!0};return $(e,s=>{if(s==null||s.length===0)throw new Error("toolExecution: received an empty tool-call batch as DATA \u2014 callers must upstream-filter empty batches (emit RESOLVED) so switchMap is only dispatched for non-empty batches.");let l=s.map(u=>Fr(u,r,n,o));return v(l,u=>u,{name:"toolExecution::batch",equals:a})})}function Fr(t,e,r,n){let o=ut(()=>e.executeReactive(t.name,t.arguments),{count:r}),a=v([o],([s])=>({id:t.id,content:typeof s=="string"?s:JSON.stringify(s)}));return n==="propagate"?a:bt(a,s=>({id:t.id,content:JSON.stringify({error:String(s)})}))}var De=class extends se{definitions;schemas;_bundle;constructor(e,r={}){super(e,r.graph),this._bundle=xe({name:"definitions"}),this.definitions=this._bundle.entries,this.add(this.definitions,{name:"definitions"}),this.schemas=v([this.definitions],([n])=>[...(n??new Map).values()],{name:"schemas",describeKind:"derived",meta:N("tool_schemas"),initial:[]}),this.add(this.schemas,{name:"schemas"}),this.addDisposer(j(this.schemas))}register(e){this._bundle.set(e.name,e)}unregister(e){this._bundle.delete(e)}executeReactive(e,r){let n=this._bundle.get(e);if(!n)throw new Error(`toolRegistry: unknown tool "${e}"`);return Q(o=>{let a=new AbortController,s;try{let u=n.handler(r,{signal:a.signal});s=Gr(u,a.signal)}catch(u){return o.down([[W,u]]),()=>{a.abort()}}let l=s.subscribe(u=>{o.down(u)});return()=>{a.abort(),l()}},{name:`executeReactive::${e}`,meta:N("tool_execute_reactive")})}getDefinition(e){return this._bundle.entries.cache?.get(e)}};function ot(t,e){return new De(t,e)}function Gr(t,e){return Qe(t)?t:t!=null&&typeof t.then=="function"?_e(t,{signal:e}):t!=null&&typeof t=="object"&&Symbol.asyncIterator in t?pt(t,{signal:e}):_e(Promise.resolve(t),{signal:e})}var Pe=class extends se{chat;tools;status;turn;aborted;lastResponse;toolCalls;toolResults;_terminalResult;_disposeRunWiring;_running=!1;_currentAbortController=null;constructor(e,r){if(super(e,r.graph),this.chat=rt(`${e}-chat`,{maxMessages:r.maxMessages}),this.mount("chat",this.chat),this.tools=ot(`${e}-tools`),this.mount("tools",this.tools),r.tools)for(let w of r.tools)this.tools.register(w);this.status=L("idle",{name:"status",describeKind:"state",meta:N("agent_status")}),this.add(this.status,{name:"status"}),this.turn=L(0,{name:"turn",describeKind:"state",meta:N("agent_turn_count")}),this.add(this.turn,{name:"turn"}),this.aborted=L(!1,{name:"aborted",describeKind:"state",meta:N("agent_aborted")}),this.add(this.aborted,{name:"aborted"});let n=0,o=this.turn.subscribe(w=>{for(let M of w)M[0]===G&&(n=M[1])}),a=!1,s=this.aborted.subscribe(w=>{for(let M of w)M[0]===G&&(a=M[1])}),l=this.chat.messages.cache??[],u=this.chat.messages.subscribe(w=>{for(let M of w)M[0]===G&&(l=M[1])}),i=this.tools.schemas.cache??[],d=this.tools.schemas.subscribe(w=>{for(let M of w)M[0]===G&&(i=M[1])}),m=r.adapter,c=r.systemPrompt,p=r.model,g=r.temperature,y=r.maxTokens,f=r.maxTurns??10,h=r.stopWhen,b=this.chat,k=this.tools,R=this.status,C=this.turn,A=this.aborted,D=le([R],(w,M,B)=>{if(ve(w,B.prevData,0,"idle")!=="thinking"||a||n>=f){M.down([[ce]]);return}if(l.length===0){M.down([[ce]]);return}M.emit({messages:l,tools:i})},{name:"promptInput",describeKind:"derived",meta:N("agent_prompt_input",{closureReads:["aborted","turn","chat.messages","tools.schemas"]})}),_=$(D,w=>{let M=new AbortController;return this._currentAbortController=M,a&&M.abort(new Error("agentLoop: aborted")),x(m.invoke(w.messages,{tools:w.tools.length>0?w.tools:void 0,systemPrompt:c,model:p,temperature:g,maxTokens:y,signal:M.signal}),{signal:M.signal})},{equals:()=>!1}),E=L(null,{name:"lastResponse",describeKind:"state",meta:N("agent_last_response")});this.lastResponse=E;let O=le([E,R],(w,M,B)=>{let Y=ve(w,B.prevData,0,null);if(ve(w,B.prevData,1,"idle")!=="acting"){M.down([[ce]]);return}let oe=Y?.toolCalls;if(oe==null||oe.length===0){M.down([[ce]]);return}M.emit(oe)},{name:"toolCallsRaw",describeKind:"derived",meta:N("agent_tool_calls_raw")}),S=r.interceptToolCalls?r.interceptToolCalls(O):O;this.toolCalls=S;let F=nt({toolCalls:S,tools:k,retryCount:1});this.toolResults=F;let T=re([_],([w])=>{if(a)return;let M=w,B=n+1,Y=M.toolCalls!=null&&M.toolCalls.length>0,he=M.finishReason==="end_turn"&&(!M.toolCalls||M.toolCalls.length===0),oe=h?.(M)===!0,Vt=B>=f,Ut=oe||he||!Y||Vt?"done":"acting";J(()=>{E.emit(M),R.emit(Ut),C.emit(B),b.append("assistant",M.content,{toolCalls:M.toolCalls})})}),I=re([F],([w])=>{if(a)return;let M=w;if(M.length===0)return;let B=n>=f?"done":"thinking";J(()=>{R.emit(B);for(let Y of M)b.appendToolResult(Y.id,Y.content)})}),P=R.cache??"idle",K=R.subscribe(w=>{for(let M of w)M[0]===G&&(P=M[1])}),te=re([A],([w])=>{w===!0&&(this._currentAbortController?.abort(new Error("agentLoop: aborted")),P!=="done"&&R.emit("done"))}),ie=j(T),ue=j(I),me=j(te);this._terminalResult=le([R,E],(w,M,B)=>{let Y=ve(w,B.prevData,0,"idle"),he=ve(w,B.prevData,1,null);if(Y==="done"){if(he!=null){M.emit(he);return}let oe=new Error("agentLoop: aborted");oe.name="AbortError",M.down([[W,oe]]);return}if(Y==="error"){M.down([[W,new Error("agentLoop: errored")]]);return}M.down([[ce]])},{name:"terminalResult",describeKind:"derived",meta:N("agent_terminal_result")}),this.add(D,{name:"promptInput"}),this.add(_,{name:"llmResponse"}),this.add(this.lastResponse,{name:"lastResponse"}),this.toolCalls===O?this.add(this.toolCalls,{name:"toolCalls"}):(this.add(O,{name:"toolCallsRaw"}),this.add(this.toolCalls,{name:"toolCalls"})),this.add(F,{name:"toolResults"}),this.add(this._terminalResult,{name:"terminalResult"}),this.addDisposer(o),this.addDisposer(s),this.addDisposer(K),this.addDisposer(u),this.addDisposer(d),this.addDisposer(ie),this.addDisposer(ue),this.addDisposer(me),this._disposeRunWiring=()=>{}}async run(e,r){if(this._running)throw new RangeError(`agentLoop "${this.name}": run() called while a previous run() is still pending \u2014 await the previous run before starting another, or call abort() first`);this._running=!0;let n;try{J(()=>{this.turn.emit(0),this.aborted.emit(!1),this.status.emit("idle"),this.lastResponse.emit(null)}),e!=null&&this.chat.append("user",e);let o=ft(this._terminalResult,{skipCurrent:!0});if(r!=null)if(r.aborted)this.aborted.emit(!0);else{let a=()=>this.aborted.emit(!0);r.addEventListener("abort",a,{once:!0}),n=()=>r.removeEventListener("abort",a)}return r?.aborted!==!0&&this.status.emit("thinking"),await o}finally{n?.(),this._running=!1,this._currentAbortController=null}}abort(){this.aborted.emit(!0)}destroy(){try{this._disposeRunWiring()}catch{}super.destroy()}};function ve(t,e,r,n){let o=t[r];if(o!=null&&o.length>0)return o[o.length-1];let a=e[r];return a!==void 0?a:n}function Br(t,e){let r=new Pe(t,e);return r.tagFactory("agentLoop",ke(e)),r}function $r(t,e,r){let n=x(t),o=r?.condition!=null?x(r.condition):null,a=L(null,{name:r?.name?`${r.name}::null`:"handoff::null"});if(o==null)return $(n,l=>{if(l==null)return a;let u=L(l);return e(u)},{meta:X("handoff")});let s=v([n,o],([l,u])=>({v:l,open:u===!0}),{name:r?.name?`${r.name}::router`:"handoff::router",describeKind:"derived"});return $(s,({v:l,open:u})=>{if(l==null)return a;if(!u)return L(l);let i=L(l);return e(i)},{meta:X("handoff")})}function Wr(t,e,r){let n=x(t),o=e.map(s=>x(s)),a=[n,...o];return v(a,s=>{let l=s[0]??[],u=s.slice(1);return l.filter(i=>{for(let d of u)if(d!=null&&!d(i))return!1;return!0})},{name:r?.name??"tool-selector",describeKind:"derived",meta:{...N("tool_selector"),...X("toolSelector")},equals:(s,l)=>{let u=s,i=l;if(u.length!==i.length)return!1;for(let d=0;d<u.length;d++)if(u[d]!==i[d])return!1;return!0}})}function Gt(t){let e=t.thresholds??{};return r=>{let n=t.scoreFn(r);for(let o of Object.keys(e)){let a=e[o];if(a===void 0)continue;let s=n[o];if((Number.isFinite(s)?s:Number.NEGATIVE_INFINITY)<a)return!1}return!0}}function Kr(t){let e={persistence:t.persistenceThreshold??.3,personalValue:t.personalValueThreshold??.3},r=Gt({scoreFn:t.scoreFn,thresholds:e});return t.requireStructured?n=>{if(!r(n))return!1;let o=t.scoreFn(n).structure;return Number.isFinite(o)&&o>0}:r}function at(t,e,r){let n=xt({dimension:r.dimension});t.add(n.entries,{name:"vectorIndex"});let a=re([e.store.entries],([s])=>{let l=s??new Map;for(let[u,i]of l){let d=r.embedFn(i);d&&n.upsert(u,d,i)}}).subscribe(()=>{});return t.addDisposer(a),{vectors:n,dispose:()=>a()}}function st(t,e,r,n){let o=n.mountPath??r,a=wt(`${r}-kg`);if(t.mount(o,a),!n.entityFn)return{kg:a,dispose:()=>{}};let s=n.entityFn,u=re([e.store.entries],([i])=>{let d=i??new Map;for(let[m,c]of d){let p=s(m,c);if(p){for(let g of p.entities??[])a.upsertEntity(g.id,g.value);for(let g of p.relations??[])a.link(g.from,g.to,g.relation,g.weight)}}}).subscribe(()=>{});return t.addDisposer(u),{kg:a,dispose:()=>u()}}function it(t,e,r){let n=r.decayRate??we,o=r.maxActive??1e3,a=r.archiveThreshold??.1,s=r.permanentFilter??(()=>!1),l=Rt("permanent",{ranked:!1});t.mount("permanent",l);let u=new Set,i=b=>u.has(b)?"permanent":(e.store.entries.cache??new Map).has(b)?"active":"archived",d=(b,k)=>{u.add(b),l.upsert(b,k)},m=new Map,c=e.store.entries,p=r.context?x(r.context):L(null),y=re([c,p],([b,k])=>{let R=b??new Map,C=H(),A=[],D=[];for(let[E,O]of R){if(m.has(E)||m.set(E,C),s(E,O)){D.push({key:E,value:O});continue}let S=r.score(O,k),F=m.get(E)??C,T=Number(C-F)/1e9;Mt(S,T,n)<a&&A.push(E)}for(let E of m.keys())R.has(E)||m.delete(E);for(let{key:E,value:O}of D)u.has(E)||d(E,O);let _=R.size-u.size;if(_>o){let E=[...R.entries()].filter(([S])=>!u.has(S)).map(([S,F])=>({key:S,score:r.score(F,k)})).sort((S,F)=>S.score-F.score),O=_-o;for(let S=0;S<O&&S<E.length;S++){let F=E[S].key;A.includes(F)||A.push(F)}}A.length>0&&J(()=>{for(let E of A)e.store.delete(E)})}).subscribe(()=>{}),f=null;r.archiveTier&&(f=t.attachSnapshotStorage([r.archiveTier],r.archiveStorageOptions??{}));let h=()=>{y(),f?.dispose()};return t.addDisposer(h),{tiers:{permanent:l,activeEntries:c,archiveHandle:f,tierOf:i,markPermanent:d},dispose:h}}function Vr(t,e){if(!t||!e)return 0;let r=Math.min(t.length,e.length),n=0;for(;n<r&&t[n]===e[n];)n++;return n}function lt(t,e,r,n,o){let a=o.topK??20,s=o.graphDepth??1,l=o.budget??2e3,u=o.contextWeight??0,i=o.context?x(o.context):L(null),d=(f,h,b)=>{let k=new Map,R=[];if(r&&b.vector){let O=b.vector,S=r.entries.cache;if(S&&S.size>0&&a>0){R=[...S.values()].map(T=>({id:T.id,score:kt(O,T.vector),...T.meta!==void 0?{meta:T.meta}:{}})).sort((T,I)=>I.score-T.score).slice(0,a);for(let T of R){let I=f.get(T.id);I&&k.set(T.id,{value:I,sources:new Set(["vector"])})}}}let C=[];if(n){let O=n.adjacencyOut.cache,S=n.adjacencyIn.cache,F=[...b.entityIds??[],...k.keys()],T=new Set,I=F;for(let P=0;P<s;P++){let K=[];for(let te of I){if(T.has(te))continue;T.add(te);let ie=O?.get(te)??[],ue=S?.get(te)??[];for(let me of ie){let w=me.to;if(!T.has(w)){K.push(w);let M=f.get(w);if(M){let B=k.get(w);B?B.sources.add("graph"):k.set(w,{value:M,sources:new Set(["graph"])}),C.push(w)}}}for(let me of ue){let w=me.from;if(!T.has(w)){K.push(w);let M=f.get(w);if(M){let B=k.get(w);B?B.sources.add("graph"):k.set(w,{value:M,sources:new Set(["graph"])}),C.push(w)}}}}I=K}}for(let[O,S]of f)k.has(O)||k.set(O,{value:S,sources:new Set(["store"])});let A=b.context?.length??0,D=[];for(let[O,{value:S,sources:F}]of k){let T=o.contextOf?o.contextOf(S):void 0,I=o.score(S,h);if(u>0&&A>0){let K=Vr(b.context,T);K>0&&(I=I*(1+u*K/A))}let P=T?{key:O,value:S,score:I,sources:[...F],context:T}:{key:O,value:S,score:I,sources:[...F]};D.push(P)}D.sort((O,S)=>S.score-O.score);let _=[],E=0;for(let O of D){let S=o.cost(O.value);if(E+S>l&&_.length>0)break;_.push(O),E+=S}return{packed:_,trace:{vectorCandidates:R,graphExpanded:C,ranked:D,packed:_}}},m=(f,h)=>{if(f===h)return!0;if(f.length!==h.length)return!1;for(let b=0;b<f.length;b++)if(f[b]!==h[b])return!1;return!0},c=L([],{name:"retrieval",describeKind:"state",meta:N("retrieval_pipeline"),equals:m});t.add(c,{name:"retrieval"});let p=L(null,{name:"retrievalTrace",describeKind:"state",meta:N("retrieval_trace")});return t.add(p,{name:"retrievalTrace"}),{retrieval:c,retrievalTrace:p,retrieve:f=>{let h=e.store.entries.cache??new Map,{packed:b,trace:k}=d(h,i.cache,f);return J(()=>{c.emit(b),p.emit(k)}),b},retrieveReactive:f=>{let h=x(f),b=v([e.store.entries,i,h],([C,A,D])=>{if(D==null)return{packed:[],trace:null};let _=C??new Map,{packed:E,trace:O}=d(_,A,D);return{packed:E,trace:O}},{name:"retrievalReactive::result",describeKind:"derived",meta:N("retrieval_reactive_result"),initial:{packed:[],trace:null}}),R=re([b],([C])=>{let A=C;J(()=>{c.emit(A.packed),A.trace&&p.emit(A.trace)})}).subscribe(()=>{});return t.addDisposer(R),v([b],([C])=>C.packed,{name:"retrievalReactive",describeKind:"derived",meta:N("retrieval_reactive"),initial:[],equals:m})}}}function Ur(t,e,r){let n=new se(t,r.graph);n.tagFactory("agentMemory",ke(r));let o;if(r.extractFn)o=r.extractFn;else if(r.adapter&&r.extractPrompt)o=et(r.extractPrompt,{adapter:r.adapter});else throw new Error("agentMemory: provide either extractFn or adapter + extractPrompt");let a=(b,k)=>{let R=k.cache??new Map,C=k.subscribe(A=>{for(let D of A)D[0]===G&&(R=D[1])});return n.addDisposer(C),$(b,A=>A==null?{upsert:[]}:o(A,R))},s=e;if(r.admissionFilter){let b=x(e),k=r.admissionFilter;s=v([b],([R])=>{if(k(R))return R},{name:"admissionFilter",describeKind:"derived"})}let l;r.consolidateFn?l=r.consolidateFn:r.adapter&&r.consolidatePrompt&&(l=tt(r.consolidatePrompt,{adapter:r.adapter}));let u=r.consolidateTrigger;if(!u&&l&&r.reflection?.enabled!==!1){let b=r.reflection?.interval??3e5;u=ct(b,{period:b})}let i={score:r.score,cost:r.cost,budget:r.budget??2e3,context:r.context,consolidate:l,consolidateTrigger:u},d=Tt(s,a,i);n.add(d.store.entries,{name:"store"}),n.add(d.compact,{name:"compact"}),n.add(d.size,{name:"size"});let m=null;r.vectorDimensions&&r.vectorDimensions>0&&r.embedFn&&(m=at(n,d,{dimension:r.vectorDimensions,embedFn:r.embedFn}).vectors);let c=null;r.enableKnowledgeGraph&&(c=st(n,d,t,{mountPath:"kg",entityFn:r.entityFn}).kg);let p=null;r.tiers&&(p=it(n,d,{...r.tiers,score:r.score,context:r.context}).tiers);let g=null,y=null,f=null,h=null;if(m||c){let b=lt(n,d,m,c,{score:r.score,cost:r.cost,budget:r.budget,topK:r.retrieval?.topK,graphDepth:r.retrieval?.graphDepth,contextOf:r.contextOf,contextWeight:r.contextWeight,context:r.context});g=b.retrieval,y=b.retrievalTrace,f=b.retrieve,h=b.retrieveReactive}return Object.assign(n,{distillBundle:d,compact:d.compact,size:d.size,vectors:m,kg:c,memoryTiers:p,retrieval:g,retrievalTrace:y,retrieve:f,retrieveReactive:h})}function qr(t,e,r){let n=t.describe({actor:e,detail:"full"}),o=r?.groupByTags??!0,a=r?.separator??`
5
+ `,s=[],l=r?.sinceVersion;for(let[u,i]of Object.entries(n.nodes)){let d=i.meta??{},m=d.description,c=d.format;if(!m&&!c)continue;if(l!=null&&i.v!=null){let h=l.get(u);if(h!=null&&h.id===i.v.id&&i.v.version<=h.version)continue}let p=m??u,g=i.value,y=d.unit,f;c==="currency"&&typeof g=="number"?f=`$${g.toFixed(2)}`:c==="percentage"&&typeof g=="number"?f=`${(g*100).toFixed(1)}%`:g==null?f="(no value)":f=String(g),y&&c!=="currency"&&c!=="percentage"&&(f=`${f} ${y}`),s.push({path:u,description:p,formatted:f})}if(s.length===0)return"";if(o){let u=new Map,i=[];for(let m of s){let p=n.nodes[m.path].meta?.tags;if(p&&p.length>0){let g=p[0],y=u.get(g);y||(y=[],u.set(g,y)),y.push(m)}else i.push(m)}if(u.size===0)return s.map(m=>`- ${m.description}: ${m.formatted}`).join(a);let d=[];for(let[m,c]of[...u.entries()].sort((p,g)=>p[0].localeCompare(g[0])))d.push(`[${m}]${a}${c.map(p=>`- ${p.description}: ${p.formatted}`).join(a)}`);return i.length>0&&d.push(i.map(m=>`- ${m.description}: ${m.formatted}`).join(a)),d.join(a+a)}return s.map(u=>`- ${u.description}: ${u.formatted}`).join(a)}var Bt=`You are a graph architect for GraphReFly, a reactive graph protocol.
6
+
7
+ Given a natural-language description, produce a JSON graph specification with this structure:
8
+
9
+ {
10
+ "name": "<graph_name>",
11
+ "nodes": {
12
+ "<node_name>": {
13
+ "type": "state" | "derived" | "producer" | "effect" | "operator",
14
+ "initial": <initial_value_for_state_nodes>,
15
+ "deps": ["<dep_node_name>", ...],
16
+ "meta": {
17
+ "description": "<human-readable purpose>",
18
+ "type": "string" | "number" | "boolean" | "integer" | "enum",
19
+ "range": [min, max],
20
+ "values": ["a", "b"],
21
+ "format": "currency" | "percentage" | "status",
22
+ "access": "human" | "llm" | "both" | "system",
23
+ "unit": "<unit>",
24
+ "tags": ["<tag>"]
25
+ }
26
+ }
27
+ }
28
+ }
29
+
30
+ Rules:
31
+ - "state" nodes have no deps and hold user/LLM-writable values (knobs). Use "initial" for the starting value.
32
+ - "derived" nodes have deps and compute from them (pure, no side effects).
33
+ - "effect" nodes have deps but produce side effects (no return value).
34
+ - "producer" nodes have no deps but generate values asynchronously.
35
+ - "operator" nodes are parameterized transformations with deps.
36
+ - Use "deps" inside each node to declare dependencies \u2014 no separate "edges" array.
37
+ - meta.description is required for every node.
38
+ - Return ONLY valid JSON, no markdown fences or commentary.`;async function $t(t,e,r){let o=[{role:"system",content:r?.systemPromptExtra?`${Bt}
39
+
40
+ ${r.systemPromptExtra}`:Bt},{role:"user",content:t}],a=e.invoke(o,{model:r?.model,temperature:r?.temperature??0,maxTokens:r?.maxTokens,signal:r?.signal}),l=(await Me(a)).content.trim();l.startsWith("```")&&(l=ye(l));let u;try{u=JSON.parse(l)}catch{throw new Error(`graphFromSpec: LLM response is not valid JSON: ${l.slice(0,200)}`)}return Lt(u,{catalog:r?.catalog})}function Hr(t,e,r){let n=x(t);return $(n,o=>!o||typeof o!="string"||o.trim().length===0?L(null):Q(a=>{let s=new AbortController,l=!1;return $t(o,e,{...r,signal:s.signal}).then(u=>{if(l){u.destroy();return}a.emit(u),a.down([[q]])}).catch(u=>{l||a.down([[W,u]])}),()=>{l=!0,s.abort()}},{name:"graphFromSpec::call"}))}function zr(t){let e={},r=t.type;return r==="enum"&&Array.isArray(t.values)?(e.type="string",e.enum=t.values):r==="integer"?e.type="integer":r==="number"?e.type="number":r==="boolean"?e.type="boolean":r==="string"?e.type="string":e.type=["string","number","boolean"],Array.isArray(t.range)&&t.range.length===2&&(e.minimum=t.range[0],e.maximum=t.range[1]),typeof t.format=="string"&&(e.description=`Format: ${t.format}`),typeof t.unit=="string"&&(e.description?e.description+=` (${t.unit})`:e.description=`Unit: ${t.unit}`),e}function Yr(t,e){let r=t.describe({actor:e,detail:"full"}),n=[],o=[],a=[];for(let[s,l]of Object.entries(r.nodes)){if(l.type!=="state"||s.includes("::__meta__::")||l.status==="completed"||l.status==="errored")continue;let u=l.meta??{},i=u.access;if(i==="human"||i==="system")continue;let d=u.description??`Set the value of ${s}`,m=zr(u),c={type:"object",required:["value"],properties:{value:m},additionalProperties:!1},p=s.replace(/::/g,"__");n.push({type:"function",function:{name:p,description:d,parameters:c}}),o.push({name:s,description:d,inputSchema:c});let g=t,y=e,f=l.v;a.push({name:s,description:d,parameters:c,handler(h){return g.set(s,h.value,y?{actor:y}:void 0),h.value},...f!=null?{version:{id:f.id,version:f.version}}:{}})}return{openai:n,mcp:o,definitions:a}}var Jr=`You are a reactive graph optimizer for GraphReFly.
41
+
42
+ Given a graph's current structure (from describe()) and a problem statement, suggest topology and parameter changes to solve the problem.
43
+
44
+ Return ONLY valid JSON with this structure:
45
+ {
46
+ "summary": "<one-line summary of the strategy>",
47
+ "reasoning": "<explanation of why these changes help>",
48
+ "operations": [
49
+ { "type": "add_node", "name": "<name>", "nodeType": "state|derived|effect|producer|operator", "meta": {...}, "initial": <value> },
50
+ { "type": "remove_node", "name": "<name>" },
51
+ { "type": "connect", "from": "<source>", "to": "<target>" },
52
+ { "type": "disconnect", "from": "<source>", "to": "<target>" },
53
+ { "type": "set_value", "name": "<name>", "value": <new_value> },
54
+ { "type": "update_meta", "name": "<name>", "key": "<meta_key>", "value": <new_value> }
55
+ ]
56
+ }
57
+
58
+ Rules:
59
+ - Only suggest operations that reference existing nodes (for remove/disconnect/set_value/update_meta) or new nodes you define (for add_node).
60
+ - Keep changes minimal \u2014 prefer the smallest set of operations that solves the problem.
61
+ - Return ONLY valid JSON, no markdown fences or commentary.`;async function Wt(t,e,r,n){let{expand:o,...a}=t.describe({actor:n?.actor,detail:"standard"}),s=[{role:"system",content:Jr},{role:"user",content:JSON.stringify({graph:a,problem:e})}],l=r.invoke(s,{model:n?.model,temperature:n?.temperature??0,maxTokens:n?.maxTokens,signal:n?.signal}),i=(await Me(l)).content.trim();i.startsWith("```")&&(i=i.replace(/^```(?:json)?\s*/,"").replace(/\s*```$/,""));let d;try{d=JSON.parse(i)}catch{throw new Error(`suggestStrategy: LLM response is not valid JSON: ${i.slice(0,200)}`)}let m=d;if(typeof m.summary!="string")throw new Error("suggestStrategy: missing 'summary' in response");if(typeof m.reasoning!="string")throw new Error("suggestStrategy: missing 'reasoning' in response");if(!Array.isArray(m.operations))throw new Error("suggestStrategy: missing 'operations' array in response");return{summary:m.summary,reasoning:m.reasoning,operations:m.operations}}function Qr(t,e,r,n){let o=x(e),a=ht(o,t);return $(a,s=>{if(s==null)return L(null);let[l,u]=s;return!u||!l||typeof l!="string"||l.trim().length===0?L(null):u.destroyed?L(null):Q(i=>{let d=new AbortController,m=!1;return Wt(u,l,r,{...n,signal:d.signal}).then(c=>{m||(i.emit(c),i.down([[q]]))}).catch(c=>{m||i.down([[W,c]])}),()=>{m=!0,d.abort()}},{name:"suggestStrategy::call"})})}var Kt=new Set(["state","derived","producer","operator","effect"]);function Xr(t){let e=[];if(t==null||typeof t!="object")return{valid:!1,errors:["Definition must be a non-null object"]};let r=t;if((typeof r.name!="string"||r.name.length===0)&&e.push("Missing or empty 'name' field"),r.nodes==null||typeof r.nodes!="object"||Array.isArray(r.nodes))return e.push("Missing or invalid 'nodes' field (must be an object)"),{valid:!1,errors:e};let n=new Set(Object.keys(r.nodes));for(let[o,a]of Object.entries(r.nodes)){if(a==null||typeof a!="object"){e.push(`Node "${o}": must be an object`);continue}let s=a;if((typeof s.type!="string"||!Kt.has(s.type))&&e.push(`Node "${o}": invalid type "${String(s.type)}" (expected: ${[...Kt].join(", ")})`),Array.isArray(s.deps))for(let l of s.deps)typeof l=="string"&&!n.has(l)&&e.push(`Node "${o}": dep "${l}" does not reference an existing node`)}if(!Array.isArray(r.edges))r.edges!==void 0&&e.push("'edges' must be an array");else{let o=new Set;for(let a=0;a<r.edges.length;a++){let s=r.edges[a];if(s==null||typeof s!="object"){e.push(`Edge [${a}]: must be an object`);continue}let l=s;(typeof l.from!="string"||!n.has(l.from))&&e.push(`Edge [${a}]: 'from' "${String(l.from)}" does not reference an existing node`),(typeof l.to!="string"||!n.has(l.to))&&e.push(`Edge [${a}]: 'to' "${String(l.to)}" does not reference an existing node`);let u=`${l.from}->${l.to}`;o.has(u)&&e.push(`Edge [${a}]: duplicate edge ${u}`),o.add(u)}}return{valid:e.length===0,errors:e}}export{nr as a,or as b,Ae as c,We as d,sr as e,ir as f,lr as g,dr as h,Ke as i,Ce as j,Ue as k,mr as l,qe as m,ze as n,Ye as o,ge as p,Je as q,Mr as r,ye as s,co as t,xr as u,Xe as v,Ze as w,et as x,tt as y,Lr as z,Nr as A,Ar as B,Sr as C,Or as D,Ir as E,Pr as F,jr as G,_r as H,Ie as I,rt as J,nt as K,De as L,ot as M,Pe as N,Br as O,$r as P,Wr as Q,Gt as R,Kr as S,at as T,st as U,it as V,lt as W,Ur as X,qr as Y,$t as Z,Hr as _,Yr as $,Wt as aa,Qr as ba,Xr as ca,Zr as da};
@@ -1 +1 @@
1
- import{a as dr,b as fr}from"./chunk-PPUYQ66A.js";import{b as pe}from"./chunk-TSOYJ743.js";import{$ as sr,A as It,B as Lt,C as Ct,D as jt,E as Vt,F as Pt,G as At,H as zt,I as Kt,J as Dt,K as Ut,L as _t,M as $t,N as Ft,O as Ht,P as Gt,Q as qt,R as Jt,S as Qt,T as Xt,U as Yt,V as Zt,W as er,X as nr,Y as tr,Z as rr,_ as or,a as bn,aa as ir,b as yn,ba as mr,c as ct,d as dt,e as ft,f as ut,g as pt,h as lt,i as mt,j as gt,k as bt,l as yt,m as kt,n as ht,o as vt,p as xt,q as Tt,r as wt,s as Et,t as Nt,u as Mt,v as St,w as Rt,x as Bt,y as Ot,z as Wt}from"./chunk-LCGAVGGV.js";import{a as Y,b as ee,c as ne,d as te,e as re,f as oe,g as se,h as ie,i as ae,j as ce,k as de,l as fe}from"./chunk-RZJDIV2G.js";import{b as ur,c as pr,d as lr,e as hr,f as vr}from"./chunk-6I726LZU.js";import{a as Cr}from"./chunk-2QXRYP7Q.js";import{a as ke,b as tn}from"./chunk-5QDBSZBV.js";import{a as an,b as cn,c as dn,d as fn,e as un,f as pn,g as ln,h as mn,i as gn}from"./chunk-756D5TFD.js";import{a as xe}from"./chunk-L6NSJVJZ.js";import{a as ue}from"./chunk-2BX4NB34.js";import{a as Z}from"./chunk-ESMPEKEV.js";import{a as wr,b as Er,c as Nr,d as Mr,e as Sr,f as Rr,g as Br,h as Or,i as Wr,j as Ir,k as Lr}from"./chunk-D5RFJOZ2.js";import{a as xr,b as Tr}from"./chunk-CE72X3WO.js";import{A as Kn,B as Dn,C as Un,D as _n,E as $n,F as Fn,G as Hn,I as Gn,J as qn,K as Jn,L as Qn,M as Xn,N as Yn,O as Zn,P as et,Q as nt,R as tt,S as rt,T as ot,U as st,V as it,W as at,a as U,b as J,c as kn,d as hn,e as vn,f as xn,g as Tn,h as wn,i as Q,j as En,k as Nn,l as Mn,m as Sn,n as Rn,o as Bn,p as On,q as Wn,r as In,s as Ln,t as X,u as Cn,v as jn,w as Vn,x as Pn,y as An,z as zn}from"./chunk-FHRBBHJN.js";import{c as Te,d as we,e as Ee,f as Ne,g as Me,h as Se,i as Re}from"./chunk-4VVTGLXJ.js";import{a as gr,b as br}from"./chunk-NNKJUORL.js";import{a as yr,b as kr}from"./chunk-KGKJCHEK.js";import{a as ar,b as cr}from"./chunk-TZQPPQEQ.js";import{a as rn,b as on,c as sn}from"./chunk-YXDRGKXP.js";import{A as Ye,B as Ze,C as en,D as nn,a as he,b as ve,c as Be,d as Oe,e as We,f as q,g as Ie,h as Le,i as Ce,j as je,k as Ve,l as Pe,m as Ae,n as ze,o as Ke,p as De,q as Ue,r as _e,s as $e,t as Fe,u as He,v as Ge,w as qe,x as Je,y as Qe,z as Xe}from"./chunk-CKFQS2CJ.js";import{A as K,D as C,E as O,H as D,m as W}from"./chunk-LYCLF26R.js";import{b as h,e as $,f as F,g as H,h as S,i as G,j as B}from"./chunk-CK2E7BTU.js";import{b as ye}from"./chunk-QYADASLV.js";var Dr={};ye(Dr,{CircuitOpenError:()=>ne,ContentAddressedMissError:()=>ur,DEFAULT_AUDIT_GUARD:()=>cn,NS_PER_MS:()=>NS_PER_MS,NS_PER_SEC:()=>NS_PER_SEC,NativeIndexBackend:()=>gr,NativeListBackend:()=>yr,NativeLogBackend:()=>rn,NativeMapBackend:()=>ar,NativePubSubBackend:()=>_,RateLimiterOverflowError:()=>se,ResettableTimer:()=>Z,TimeoutError:()=>ce,appendAudit:()=>un,appendLogStorage:()=>Sr,audit:()=>Hn,awaitSettled:()=>Xe,budgetGate:()=>Y,buffer:()=>Gn,bufferCount:()=>qn,bufferTime:()=>Qn,bumpCursor:()=>fn,cached:()=>qe,canonicalJson:()=>pr,cascadingCache:()=>jr,catchError:()=>at,checkpointToRedis:()=>er,checkpointToS3:()=>Zt,circuitBreaker:()=>te,combine:()=>In,combineLatest:()=>ot,concat:()=>jn,concatMap:()=>zn,constant:()=>Te,contentAddressedStorage:()=>lr,createAuditLog:()=>dn,createTransport:()=>L,createWatermarkController:()=>tn,csvRows:()=>jt,debounce:()=>_n,debounceTime:()=>st,decay:()=>pe,decorrelatedJitter:()=>Me,defer:()=>_e,delay:()=>Un,deserializeError:()=>A,dictKv:()=>Ir,dictSnapshot:()=>Lr,distill:()=>fr,distinctUntilChanged:()=>On,domainMeta:()=>xe,elementAt:()=>Mn,empty:()=>Ke,escapeRegexChar:()=>Be,exhaustMap:()=>An,exponential:()=>Ee,externalBundle:()=>yn,externalProducer:()=>bn,fallback:()=>de,fibonacci:()=>Ne,filter:()=>J,find:()=>Nn,first:()=>Q,firstValueFrom:()=>Je,firstWhere:()=>Qe,flatMap:()=>Dn,forEach:()=>$e,fromAny:()=>Ae,fromAsyncIter:()=>Pe,fromCSV:()=>Ct,fromClickHouseWatch:()=>At,fromCron:()=>Le,fromDrizzle:()=>sr,fromEvent:()=>Ce,fromHTTP:()=>ut,fromHTTPPoll:()=>ht,fromHTTPStream:()=>kt,fromIter:()=>je,fromKafka:()=>Ot,fromKysely:()=>ir,fromMCP:()=>Tt,fromNATS:()=>Dt,fromNDJSON:()=>Pt,fromOTel:()=>wt,fromPrisma:()=>or,fromPrometheus:()=>Rt,fromPromise:()=>Ve,fromPulsar:()=>zt,fromRabbitMQ:()=>_t,fromRaf:()=>Ie,fromRedisStream:()=>It,fromSSE:()=>yt,fromSqlite:()=>nr,fromSqliteCursor:()=>tr,fromStatsD:()=>Mt,fromSyslog:()=>Et,fromTimer:()=>q,fromWebSocket:()=>dt,fromWebSocketReconnect:()=>xt,fromWebhook:()=>ft,globToRegExp:()=>Oe,interval:()=>Zn,jsonCodec:()=>wr,jsonCodecFor:()=>Er,keepalive:()=>en,kvStorage:()=>Rr,last:()=>En,lightMutation:()=>pn,linear:()=>we,lru:()=>le,makeHttpError:()=>mr,map:()=>U,matchesAnyPattern:()=>We,matchesCron:()=>ve,memoryAppendLog:()=>Or,memoryBackend:()=>Nr,memoryKv:()=>Wr,memorySnapshot:()=>Br,merge:()=>X,mergeMap:()=>Kn,mergeReactiveLogs:()=>sn,nameToSignal:()=>V,ndjsonRows:()=>Vt,never:()=>De,nodeSignal:()=>Ye,of:()=>ze,onFirstData:()=>Rn,pairwise:()=>Wn,parseCron:()=>he,parsePrometheusText:()=>Bt,parseSSEStream:()=>bt,parseStatsD:()=>St,parseSyslog:()=>Nt,pausable:()=>nt,pubsub:()=>Vr,race:()=>Vn,rateLimiter:()=>ie,reactiveCounter:()=>nn,reactiveIndex:()=>br,reactiveList:()=>kr,reactiveLog:()=>on,reactiveMap:()=>cr,reactiveSink:()=>ct,reduce:()=>hn,registerCursor:()=>mn,registerCursorMap:()=>gn,repeat:()=>et,replay:()=>Ge,rescue:()=>tt,resolveBackoffPreset:()=>Re,retry:()=>ee,sample:()=>Fn,scan:()=>kn,serializeError:()=>P,share:()=>He,shareReplay:()=>Ze,signalToName:()=>I,singleFromAny:()=>hr,singleNodeFromAny:()=>vr,skip:()=>xn,snapshotStorage:()=>Mr,sortJsonValue:()=>xr,stableJsonString:()=>Tr,stratify:()=>Cr,switchMap:()=>Pn,take:()=>vn,takeUntil:()=>wn,takeWhile:()=>Tn,tap:()=>Sn,tapFirst:()=>Bn,throttle:()=>$n,throttleTime:()=>it,throwError:()=>Ue,timeout:()=>fe,toArray:()=>Fe,toCSV:()=>Ht,toClickHouse:()=>Gt,toFile:()=>Ft,toHTTP:()=>pt,toKafka:()=>Wt,toLoki:()=>Xt,toMongo:()=>Qt,toNATS:()=>Ut,toObservable:()=>ke,toPostgres:()=>Jt,toPulsar:()=>Kt,toRabbitMQ:()=>$t,toReadableStream:()=>gt,toRedisStream:()=>Lt,toS3:()=>qt,toSSE:()=>lt,toSSEBytes:()=>mt,toSqlite:()=>rr,toTempo:()=>Yt,toWebSocket:()=>vt,tokenBucket:()=>oe,topologyDiff:()=>ue,tryIncrementBounded:()=>an,valve:()=>rt,verifiable:()=>dr,window:()=>Yn,windowCount:()=>Jn,windowTime:()=>Xn,withBreaker:()=>re,withLatestFrom:()=>Ln,withMaxAttempts:()=>Se,withStatus:()=>ae,workerBridge:()=>ge,workerSelf:()=>be,wrapMutation:()=>ln,zip:()=>Cn});function le(){let e=new Map,r=null,n=null;function p(t){t.prev?t.prev.next=t.next:r=t.next,t.next?t.next.prev=t.prev:n=t.prev,t.prev=null,t.next=null}function l(t){t.next=r,t.prev=null,r&&(r.prev=t),r=t,n===null&&(n=t)}return{insert(t){if(e.has(t)){this.touch(t);return}let f={key:t,prev:null,next:null};e.set(t,f),l(f)},touch(t){let f=e.get(t);f&&(p(f),l(f))},delete(t){let f=e.get(t);f&&(p(f),e.delete(t))},evict(t){let f=[];for(let v=0;v<t&&n!==null;v++){let N=n;f.push(N.key),p(N),e.delete(N.key)}return f},size(){return e.size}}}function me(e){return e!=null&&typeof e.then=="function"}function j(e){me(e)&&e.catch(()=>{})}function jr(e,r){let n=new Map,p=r?.maxSize??0,l=p>0?r?.eviction??le():null,t=r?.writeThrough??!1;function f(o,u,m){for(let g=0;g<m;g++)try{j(e[g].save(o,u))}catch{}}function v(o,u,m=0){for(let g=m;g<e.length;g++){let w;try{w=e[g].load(o)}catch{continue}if(me(w)){let T=g;w.then(M=>{M!==void 0?(u.down([[h,M]]),f(o,M,T)):v(o,u,T+1)},()=>{v(o,u,T+1)});return}if(w!==void 0){u.down([[h,w]]),f(o,w,g);return}}}function N(){if(!(!l||p<=0))for(;l.size()>=p;){let o=l.evict(1);if(o.length===0)break;for(let u of o){let m=n.get(u);if(m){let g=m.cache;if(m.status!=="sentinel"&&e.length>0){let w=e.length-1;try{j(e[w].save(u,g))}catch{}for(let T=0;T<w;T++)try{let M=e[T].delete;M&&j(M.call(e[T],u))}catch{}}m.down([[S]])}n.delete(u)}}}return{load(o){let u=n.get(o);if(u)return l?.touch(o),u;l&&p>0&&l.size()>=p&&N();let m=O(void 0);return n.set(o,m),l?.insert(o),v(o,m),m},save(o,u){if(t)for(let g of e)try{j(g.save(o,u))}catch{}else if(e[0])try{j(e[0].save(o,u))}catch{}let m=n.get(o);if(m)m.down([[h,u]]),l?.touch(o);else{l&&p>0&&l.size()>=p&&N();let g=O(u);n.set(o,g),l?.insert(o)}},invalidate(o){let u=n.get(o);u&&v(o,u)},delete(o){l?.delete(o);let u=n.get(o);u&&u.down([[S]]),n.delete(o);for(let m of e)try{let g=m.delete;g&&j(g.call(m,o))}catch{}},has(o){return n.has(o)},get size(){return n.size}}}var _=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(r){return this._topics.has(r)}topicNames(){return this._topics.values()}createTopic(r){return this._topics.has(r)?!1:(this._topics.add(r),this._version+=1,!0)}removeTopic(r){let n=this._topics.delete(r);return n&&(this._version+=1),n}};function Vr(e={}){let{backend:r}=e,n=r??new _,p=new Map;function l(t){let f=p.get(t);return f===void 0&&(f=C({describeKind:"state"}),p.set(t,f),n.createTopic(t)),f}return{topic(t){return l(t)},publish(t,f){l(t).emit(f)},publishMany(t){W(()=>{for(let[f,v]of t)l(f).emit(v)})},removeTopic(t){let f=p.get(t);return f===void 0?!1:(p.delete(t),n.removeTopic(t),f.down([[S]]),!0)},has(t){return n.hasTopic(t)},get size(){return n.topicCount},topicNames(){return n.topicNames()}}}var Pr=new Map([[$,"INVALIDATE"],[F,"PAUSE"],[H,"RESUME"],[S,"TEARDOWN"],[G,"COMPLETE"],[B,"ERROR"]]),Ar=new Map([["INVALIDATE",$],["PAUSE",F],["RESUME",H],["TEARDOWN",S],["COMPLETE",G],["ERROR",B]]);function I(e){let r=Pr.get(e);return r||(Symbol.keyFor(e)??"UNKNOWN")}function V(e){let r=Ar.get(e);if(r)return r;if(e&&e!=="UNKNOWN")return Symbol.for(e)}function P(e){return e instanceof Error?{message:e.message,name:e.name,stack:e.stack}:{message:String(e),name:"Error"}}function A(e){let r=new Error(e.message);return r.name=e.name,e.stack&&(r.stack=e.stack),r}function L(e){if(typeof MessagePort<"u"&&e instanceof MessagePort)return{post(r,n){e.postMessage(r,n??[])},listen(r){let n=p=>r(p.data);return e.addEventListener("message",n),e.start(),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof SharedWorker<"u"&&e instanceof SharedWorker)return L(e.port);if(typeof Worker<"u"&&e instanceof Worker)return{post(r,n){e.postMessage(r,n??[])},listen(r){let n=p=>r(p.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.terminate()}};if(typeof BroadcastChannel<"u"&&e instanceof BroadcastChannel)return{post(r,n){n&&n.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),e.postMessage(r)},listen(r){let n=p=>r(p.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof ServiceWorker<"u"&&e instanceof ServiceWorker)return{post(r,n){e.postMessage(r,n??[])},listen(r){let n=p=>{p.source===e&&r(p.data)};return navigator.serviceWorker.addEventListener("message",n),()=>navigator.serviceWorker.removeEventListener("message",n)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function zr(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function ge(e,r){let n=zr(e)?e:L(e),p=r.name??"workerBridge",l=Object.entries(r.expose??{}),t=r.import??[],f=r.transfer??{},v=O("connecting",{name:`${p}::meta::status`}),N=O(null,{name:`${p}::meta::error`}),o=new Map,u=new Map;for(let c of t){let a=O(void 0,{name:`${p}::${c}`});o.set(c,a)}let m;if(l.length>0){let c=l.map(([,d])=>d),a=C(c,(d,i)=>{let k={};for(let y=0;y<l.length;y++){let[R]=l[y],E=d[y];E!=null&&E.length>0&&(k[R]=E.at(-1))}Object.keys(k).length!==0&&i.emit(k)},{name:`${p}::aggregated`,partial:!0});m=D([a],d=>{let i=d[0];if(i==null||Object.keys(i).length===0)return;let k=[];for(let E of Object.keys(i)){let z=f[E];z&&k.push(...z(i[E]))}let y;for(let[E,z]of l)E in i&&z.v!=null&&(y==null&&(y={}),y[E]=z.v.version);let R={t:"b",u:i,...y?{v:y}:{}};try{n.post(R,k.length>0?k:void 0)}catch(E){N.down([[h,E instanceof Error?E:new Error(String(E))]])}}).subscribe(()=>{})}let g=!1,w=n.listen(c=>{if(g)return;let a=c;switch(a.t){case"r":{W(()=>{for(let[d,i]of Object.entries(a.stores)){let k=o.get(d);k&&k.down([[h,i]])}}),v.down([[h,"connected"]]);let s={};for(let[d,i]of l)s[d]=i.cache;n.post({t:"i",stores:s});break}case"v":{let s=o.get(a.s);s&&s.down([[h,a.d]]);break}case"b":{W(()=>{for(let[s,d]of Object.entries(a.u)){let i=a.v?.[s];if(i!=null){let y=u.get(s);if(y!=null&&i<=y)continue;u.set(s,i)}let k=o.get(s);k&&k.down([[h,d]])}});break}case"e":{let s=o.get(a.s);s&&s.down([[B,A(a.err)]]);break}case"s":{let s=V(a.sig);if(!s)break;let d=a.s==="*"?[...o.values()]:o.has(a.s)?[o.get(a.s)]:[];for(let i of d)i.down(a.d===void 0?[[s]]:[[s,a.d]]);break}}}),T=[];for(let[c,a]of l){let s=a.subscribe((d=>{if(!g)for(let i of d){let k=i[0];k!==h&&(K.isLocalOnly(k)||(k===B?n.post({t:"e",s:c,err:P(i[1])}):n.post({t:"s",s:c,sig:I(k),d:i.length>1?i[1]:void 0})))}}));T.push(s)}let M;if(r.timeoutMs!=null&&r.timeoutMs>0){let c=q(r.timeoutMs),a=J(v,d=>d==="connected");M=Q(X(U(c,()=>"timeout"),U(a,()=>"ready"))).subscribe(d=>{for(let i of d)i[0]===h&&i[1]==="timeout"&&(N.down([[h,new Error("Worker bridge handshake timeout")]]),x())})}function x(){if(!g){g=!0,M?.(),n.post({t:"s",s:"*",sig:I(S)}),m&&m();for(let c of T)c();T.length=0,w(),v.down([[h,"closed"]]),u.clear(),o.clear()}}let b={meta:{status:v,error:N},destroy:x};for(let[c,a]of o)b[c]=a;return b}function Kr(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function be(e,r){let n=Kr(e)?e:L(e),p=r.import??[],l=r.transfer??{},t=new Map,f=new Map,v={};for(let x of p){let b=O(void 0,{name:`worker::${x}`});t.set(x,b),v[x]=b}let N=r.expose(v),o=Object.entries(N),u,m=!1;if(o.length>0){let x=o.map(([,a])=>a),b=C(x,(a,s)=>{let d={};for(let i=0;i<o.length;i++){let[k]=o[i],y=a[i];y!=null&&y.length>0&&(d[k]=y.at(-1))}Object.keys(d).length!==0&&s.emit(d)},{name:"workerSelf::aggregated",partial:!0});u=D([b],a=>{if(m)return;let s=a[0];if(s==null||Object.keys(s).length===0)return;let d=[];for(let y of Object.keys(s)){let R=l[y];R&&d.push(...R(s[y]))}let i;for(let[y,R]of o)y in s&&R.v!=null&&(i==null&&(i={}),i[y]=R.v.version);let k={t:"b",u:s,...i?{v:i}:{}};try{n.post(k,d.length>0?d:void 0)}catch{}}).subscribe(()=>{})}let g=[];for(let[x,b]of o){let c=b.subscribe((a=>{if(!m)for(let s of a){let d=s[0];d!==h&&(K.isLocalOnly(d)||(d===B?n.post({t:"e",s:x,err:P(s[1])}):n.post({t:"s",s:x,sig:I(d),d:s.length>1?s[1]:void 0})))}}));g.push(c)}let w=n.listen(x=>{if(m)return;let b=x;switch(b.t){case"i":{W(()=>{for(let[c,a]of Object.entries(b.stores)){let s=t.get(c);s&&s.down([[h,a]])}});break}case"v":{let c=t.get(b.s);c&&c.down([[h,b.d]]);break}case"b":{W(()=>{for(let[c,a]of Object.entries(b.u)){let s=b.v?.[c];if(s!=null){let i=f.get(c);if(i!=null&&s<=i)continue;f.set(c,s)}let d=t.get(c);d&&d.down([[h,a]])}});break}case"e":{let c=t.get(b.s);c&&c.down([[B,A(b.err)]]);break}case"s":{let c=V(b.sig);if(!c)break;if(c===S&&b.s==="*"){M();return}let a=b.s==="*"?[...t.values()]:t.has(b.s)?[t.get(b.s)]:[];for(let s of a)s.down(b.d===void 0?[[c]]:[[c,b.d]]);break}}}),T={};for(let[x,b]of o)T[x]=b.cache;n.post({t:"r",stores:T});function M(){if(!m){m=!0,u&&u();for(let x of g)x();g.length=0,w(),n.terminate?.(),f.clear(),t.clear()}}return{destroy:M}}export{le as a,jr as b,_ as c,Vr as d,I as e,V as f,P as g,A as h,L as i,ge as j,be as k,Dr as l};
1
+ import{a as dr,b as fr}from"./chunk-WZYB3JQS.js";import{b as pe}from"./chunk-TSOYJ743.js";import{$ as sr,A as It,B as Lt,C as Ct,D as jt,E as Vt,F as Pt,G as At,H as zt,I as Kt,J as Dt,K as Ut,L as _t,M as $t,N as Ft,O as Ht,P as Gt,Q as qt,R as Jt,S as Qt,T as Xt,U as Yt,V as Zt,W as er,X as nr,Y as tr,Z as rr,_ as or,a as bn,aa as ir,b as yn,ba as mr,c as ct,d as dt,e as ft,f as ut,g as pt,h as lt,i as mt,j as gt,k as bt,l as yt,m as kt,n as ht,o as vt,p as xt,q as Tt,r as wt,s as Et,t as Nt,u as Mt,v as St,w as Rt,x as Bt,y as Ot,z as Wt}from"./chunk-CYOSWFT2.js";import{a as Y,b as ee,c as ne,d as te,e as re,f as oe,g as se,h as ie,i as ae,j as ce,k as de,l as fe}from"./chunk-4MKL6Q3K.js";import{b as ur,c as pr,d as lr,e as hr,f as vr}from"./chunk-KNVCCBIU.js";import{a as Cr}from"./chunk-AI7QC7J6.js";import{a as gr,b as br}from"./chunk-NNKJUORL.js";import{a as yr,b as kr}from"./chunk-KGKJCHEK.js";import{a as ar,b as cr}from"./chunk-TZQPPQEQ.js";import{a as ke,b as tn}from"./chunk-5QDBSZBV.js";import{a as an,b as cn,c as dn,d as fn,e as un,f as pn,g as ln,h as mn,i as gn}from"./chunk-VXPLLA4P.js";import{a as xe}from"./chunk-L6NSJVJZ.js";import{a as rn,b as on,c as sn}from"./chunk-TT4C7DXW.js";import{a as ue}from"./chunk-POXANAJ6.js";import{a as Z}from"./chunk-ESMPEKEV.js";import{a as wr,b as Er,c as Nr,d as Mr,e as Sr,f as Rr,g as Br,h as Or,i as Wr,j as Ir,k as Lr}from"./chunk-D5RFJOZ2.js";import{a as xr,b as Tr}from"./chunk-CE72X3WO.js";import{A as Kn,B as Dn,C as Un,D as _n,E as $n,F as Fn,G as Hn,I as Gn,J as qn,K as Jn,L as Qn,M as Xn,N as Yn,O as Zn,P as et,Q as nt,R as tt,S as rt,T as ot,U as st,V as it,W as at,a as U,b as J,c as kn,d as hn,e as vn,f as xn,g as Tn,h as wn,i as Q,j as En,k as Nn,l as Mn,m as Sn,n as Rn,o as Bn,p as On,q as Wn,r as In,s as Ln,t as X,u as Cn,v as jn,w as Vn,x as Pn,y as An,z as zn}from"./chunk-AK5RHMC5.js";import{c as Te,d as we,e as Ee,f as Ne,g as Me,h as Se,i as Re}from"./chunk-4VVTGLXJ.js";import{A as Ye,B as Ze,C as en,D as nn,a as he,b as ve,c as Be,d as Oe,e as We,f as q,g as Ie,h as Le,i as Ce,j as je,k as Ve,l as Pe,m as Ae,n as ze,o as Ke,p as De,q as Ue,r as _e,s as $e,t as Fe,u as He,v as Ge,w as qe,x as Je,y as Qe,z as Xe}from"./chunk-L77I47VU.js";import{A as K,D as C,E as O,H as D,m as W}from"./chunk-LYCLF26R.js";import{b as h,e as $,f as F,g as H,h as S,i as G,j as B}from"./chunk-CK2E7BTU.js";import{b as ye}from"./chunk-QYADASLV.js";var Dr={};ye(Dr,{CircuitOpenError:()=>ne,ContentAddressedMissError:()=>ur,DEFAULT_AUDIT_GUARD:()=>cn,NS_PER_MS:()=>NS_PER_MS,NS_PER_SEC:()=>NS_PER_SEC,NativeIndexBackend:()=>gr,NativeListBackend:()=>yr,NativeLogBackend:()=>rn,NativeMapBackend:()=>ar,NativePubSubBackend:()=>_,RateLimiterOverflowError:()=>se,ResettableTimer:()=>Z,TimeoutError:()=>ce,appendAudit:()=>un,appendLogStorage:()=>Sr,audit:()=>Hn,awaitSettled:()=>Xe,budgetGate:()=>Y,buffer:()=>Gn,bufferCount:()=>qn,bufferTime:()=>Qn,bumpCursor:()=>fn,cached:()=>qe,canonicalJson:()=>pr,cascadingCache:()=>jr,catchError:()=>at,checkpointToRedis:()=>er,checkpointToS3:()=>Zt,circuitBreaker:()=>te,combine:()=>In,combineLatest:()=>ot,concat:()=>jn,concatMap:()=>zn,constant:()=>Te,contentAddressedStorage:()=>lr,createAuditLog:()=>dn,createTransport:()=>L,createWatermarkController:()=>tn,csvRows:()=>jt,debounce:()=>_n,debounceTime:()=>st,decay:()=>pe,decorrelatedJitter:()=>Me,defer:()=>_e,delay:()=>Un,deserializeError:()=>A,dictKv:()=>Ir,dictSnapshot:()=>Lr,distill:()=>fr,distinctUntilChanged:()=>On,domainMeta:()=>xe,elementAt:()=>Mn,empty:()=>Ke,escapeRegexChar:()=>Be,exhaustMap:()=>An,exponential:()=>Ee,externalBundle:()=>yn,externalProducer:()=>bn,fallback:()=>de,fibonacci:()=>Ne,filter:()=>J,find:()=>Nn,first:()=>Q,firstValueFrom:()=>Je,firstWhere:()=>Qe,flatMap:()=>Dn,forEach:()=>$e,fromAny:()=>Ae,fromAsyncIter:()=>Pe,fromCSV:()=>Ct,fromClickHouseWatch:()=>At,fromCron:()=>Le,fromDrizzle:()=>sr,fromEvent:()=>Ce,fromHTTP:()=>ut,fromHTTPPoll:()=>ht,fromHTTPStream:()=>kt,fromIter:()=>je,fromKafka:()=>Ot,fromKysely:()=>ir,fromMCP:()=>Tt,fromNATS:()=>Dt,fromNDJSON:()=>Pt,fromOTel:()=>wt,fromPrisma:()=>or,fromPrometheus:()=>Rt,fromPromise:()=>Ve,fromPulsar:()=>zt,fromRabbitMQ:()=>_t,fromRaf:()=>Ie,fromRedisStream:()=>It,fromSSE:()=>yt,fromSqlite:()=>nr,fromSqliteCursor:()=>tr,fromStatsD:()=>Mt,fromSyslog:()=>Et,fromTimer:()=>q,fromWebSocket:()=>dt,fromWebSocketReconnect:()=>xt,fromWebhook:()=>ft,globToRegExp:()=>Oe,interval:()=>Zn,jsonCodec:()=>wr,jsonCodecFor:()=>Er,keepalive:()=>en,kvStorage:()=>Rr,last:()=>En,lightMutation:()=>pn,linear:()=>we,lru:()=>le,makeHttpError:()=>mr,map:()=>U,matchesAnyPattern:()=>We,matchesCron:()=>ve,memoryAppendLog:()=>Or,memoryBackend:()=>Nr,memoryKv:()=>Wr,memorySnapshot:()=>Br,merge:()=>X,mergeMap:()=>Kn,mergeReactiveLogs:()=>sn,nameToSignal:()=>V,ndjsonRows:()=>Vt,never:()=>De,nodeSignal:()=>Ye,of:()=>ze,onFirstData:()=>Rn,pairwise:()=>Wn,parseCron:()=>he,parsePrometheusText:()=>Bt,parseSSEStream:()=>bt,parseStatsD:()=>St,parseSyslog:()=>Nt,pausable:()=>nt,pubsub:()=>Vr,race:()=>Vn,rateLimiter:()=>ie,reactiveCounter:()=>nn,reactiveIndex:()=>br,reactiveList:()=>kr,reactiveLog:()=>on,reactiveMap:()=>cr,reactiveSink:()=>ct,reduce:()=>hn,registerCursor:()=>mn,registerCursorMap:()=>gn,repeat:()=>et,replay:()=>Ge,rescue:()=>tt,resolveBackoffPreset:()=>Re,retry:()=>ee,sample:()=>Fn,scan:()=>kn,serializeError:()=>P,share:()=>He,shareReplay:()=>Ze,signalToName:()=>I,singleFromAny:()=>hr,singleNodeFromAny:()=>vr,skip:()=>xn,snapshotStorage:()=>Mr,sortJsonValue:()=>xr,stableJsonString:()=>Tr,stratify:()=>Cr,switchMap:()=>Pn,take:()=>vn,takeUntil:()=>wn,takeWhile:()=>Tn,tap:()=>Sn,tapFirst:()=>Bn,throttle:()=>$n,throttleTime:()=>it,throwError:()=>Ue,timeout:()=>fe,toArray:()=>Fe,toCSV:()=>Ht,toClickHouse:()=>Gt,toFile:()=>Ft,toHTTP:()=>pt,toKafka:()=>Wt,toLoki:()=>Xt,toMongo:()=>Qt,toNATS:()=>Ut,toObservable:()=>ke,toPostgres:()=>Jt,toPulsar:()=>Kt,toRabbitMQ:()=>$t,toReadableStream:()=>gt,toRedisStream:()=>Lt,toS3:()=>qt,toSSE:()=>lt,toSSEBytes:()=>mt,toSqlite:()=>rr,toTempo:()=>Yt,toWebSocket:()=>vt,tokenBucket:()=>oe,topologyDiff:()=>ue,tryIncrementBounded:()=>an,valve:()=>rt,verifiable:()=>dr,window:()=>Yn,windowCount:()=>Jn,windowTime:()=>Xn,withBreaker:()=>re,withLatestFrom:()=>Ln,withMaxAttempts:()=>Se,withStatus:()=>ae,workerBridge:()=>ge,workerSelf:()=>be,wrapMutation:()=>ln,zip:()=>Cn});function le(){let e=new Map,r=null,n=null;function p(t){t.prev?t.prev.next=t.next:r=t.next,t.next?t.next.prev=t.prev:n=t.prev,t.prev=null,t.next=null}function l(t){t.next=r,t.prev=null,r&&(r.prev=t),r=t,n===null&&(n=t)}return{insert(t){if(e.has(t)){this.touch(t);return}let f={key:t,prev:null,next:null};e.set(t,f),l(f)},touch(t){let f=e.get(t);f&&(p(f),l(f))},delete(t){let f=e.get(t);f&&(p(f),e.delete(t))},evict(t){let f=[];for(let v=0;v<t&&n!==null;v++){let N=n;f.push(N.key),p(N),e.delete(N.key)}return f},size(){return e.size}}}function me(e){return e!=null&&typeof e.then=="function"}function j(e){me(e)&&e.catch(()=>{})}function jr(e,r){let n=new Map,p=r?.maxSize??0,l=p>0?r?.eviction??le():null,t=r?.writeThrough??!1;function f(o,u,m){for(let g=0;g<m;g++)try{j(e[g].save(o,u))}catch{}}function v(o,u,m=0){for(let g=m;g<e.length;g++){let w;try{w=e[g].load(o)}catch{continue}if(me(w)){let T=g;w.then(M=>{M!==void 0?(u.down([[h,M]]),f(o,M,T)):v(o,u,T+1)},()=>{v(o,u,T+1)});return}if(w!==void 0){u.down([[h,w]]),f(o,w,g);return}}}function N(){if(!(!l||p<=0))for(;l.size()>=p;){let o=l.evict(1);if(o.length===0)break;for(let u of o){let m=n.get(u);if(m){let g=m.cache;if(m.status!=="sentinel"&&e.length>0){let w=e.length-1;try{j(e[w].save(u,g))}catch{}for(let T=0;T<w;T++)try{let M=e[T].delete;M&&j(M.call(e[T],u))}catch{}}m.down([[S]])}n.delete(u)}}}return{load(o){let u=n.get(o);if(u)return l?.touch(o),u;l&&p>0&&l.size()>=p&&N();let m=O(void 0);return n.set(o,m),l?.insert(o),v(o,m),m},save(o,u){if(t)for(let g of e)try{j(g.save(o,u))}catch{}else if(e[0])try{j(e[0].save(o,u))}catch{}let m=n.get(o);if(m)m.down([[h,u]]),l?.touch(o);else{l&&p>0&&l.size()>=p&&N();let g=O(u);n.set(o,g),l?.insert(o)}},invalidate(o){let u=n.get(o);u&&v(o,u)},delete(o){l?.delete(o);let u=n.get(o);u&&u.down([[S]]),n.delete(o);for(let m of e)try{let g=m.delete;g&&j(g.call(m,o))}catch{}},has(o){return n.has(o)},get size(){return n.size}}}var _=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(r){return this._topics.has(r)}topicNames(){return this._topics.values()}createTopic(r){return this._topics.has(r)?!1:(this._topics.add(r),this._version+=1,!0)}removeTopic(r){let n=this._topics.delete(r);return n&&(this._version+=1),n}};function Vr(e={}){let{backend:r}=e,n=r??new _,p=new Map;function l(t){let f=p.get(t);return f===void 0&&(f=C({describeKind:"state"}),p.set(t,f),n.createTopic(t)),f}return{topic(t){return l(t)},publish(t,f){l(t).emit(f)},publishMany(t){W(()=>{for(let[f,v]of t)l(f).emit(v)})},removeTopic(t){let f=p.get(t);return f===void 0?!1:(p.delete(t),n.removeTopic(t),f.down([[S]]),!0)},has(t){return n.hasTopic(t)},get size(){return n.topicCount},topicNames(){return n.topicNames()}}}var Pr=new Map([[$,"INVALIDATE"],[F,"PAUSE"],[H,"RESUME"],[S,"TEARDOWN"],[G,"COMPLETE"],[B,"ERROR"]]),Ar=new Map([["INVALIDATE",$],["PAUSE",F],["RESUME",H],["TEARDOWN",S],["COMPLETE",G],["ERROR",B]]);function I(e){let r=Pr.get(e);return r||(Symbol.keyFor(e)??"UNKNOWN")}function V(e){let r=Ar.get(e);if(r)return r;if(e&&e!=="UNKNOWN")return Symbol.for(e)}function P(e){return e instanceof Error?{message:e.message,name:e.name,stack:e.stack}:{message:String(e),name:"Error"}}function A(e){let r=new Error(e.message);return r.name=e.name,e.stack&&(r.stack=e.stack),r}function L(e){if(typeof MessagePort<"u"&&e instanceof MessagePort)return{post(r,n){e.postMessage(r,n??[])},listen(r){let n=p=>r(p.data);return e.addEventListener("message",n),e.start(),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof SharedWorker<"u"&&e instanceof SharedWorker)return L(e.port);if(typeof Worker<"u"&&e instanceof Worker)return{post(r,n){e.postMessage(r,n??[])},listen(r){let n=p=>r(p.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.terminate()}};if(typeof BroadcastChannel<"u"&&e instanceof BroadcastChannel)return{post(r,n){n&&n.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),e.postMessage(r)},listen(r){let n=p=>r(p.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof ServiceWorker<"u"&&e instanceof ServiceWorker)return{post(r,n){e.postMessage(r,n??[])},listen(r){let n=p=>{p.source===e&&r(p.data)};return navigator.serviceWorker.addEventListener("message",n),()=>navigator.serviceWorker.removeEventListener("message",n)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function zr(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function ge(e,r){let n=zr(e)?e:L(e),p=r.name??"workerBridge",l=Object.entries(r.expose??{}),t=r.import??[],f=r.transfer??{},v=O("connecting",{name:`${p}::meta::status`}),N=O(null,{name:`${p}::meta::error`}),o=new Map,u=new Map;for(let c of t){let a=O(void 0,{name:`${p}::${c}`});o.set(c,a)}let m;if(l.length>0){let c=l.map(([,d])=>d),a=C(c,(d,i)=>{let k={};for(let y=0;y<l.length;y++){let[R]=l[y],E=d[y];E!=null&&E.length>0&&(k[R]=E.at(-1))}Object.keys(k).length!==0&&i.emit(k)},{name:`${p}::aggregated`,partial:!0});m=D([a],d=>{let i=d[0];if(i==null||Object.keys(i).length===0)return;let k=[];for(let E of Object.keys(i)){let z=f[E];z&&k.push(...z(i[E]))}let y;for(let[E,z]of l)E in i&&z.v!=null&&(y==null&&(y={}),y[E]=z.v.version);let R={t:"b",u:i,...y?{v:y}:{}};try{n.post(R,k.length>0?k:void 0)}catch(E){N.down([[h,E instanceof Error?E:new Error(String(E))]])}}).subscribe(()=>{})}let g=!1,w=n.listen(c=>{if(g)return;let a=c;switch(a.t){case"r":{W(()=>{for(let[d,i]of Object.entries(a.stores)){let k=o.get(d);k&&k.down([[h,i]])}}),v.down([[h,"connected"]]);let s={};for(let[d,i]of l)s[d]=i.cache;n.post({t:"i",stores:s});break}case"v":{let s=o.get(a.s);s&&s.down([[h,a.d]]);break}case"b":{W(()=>{for(let[s,d]of Object.entries(a.u)){let i=a.v?.[s];if(i!=null){let y=u.get(s);if(y!=null&&i<=y)continue;u.set(s,i)}let k=o.get(s);k&&k.down([[h,d]])}});break}case"e":{let s=o.get(a.s);s&&s.down([[B,A(a.err)]]);break}case"s":{let s=V(a.sig);if(!s)break;let d=a.s==="*"?[...o.values()]:o.has(a.s)?[o.get(a.s)]:[];for(let i of d)i.down(a.d===void 0?[[s]]:[[s,a.d]]);break}}}),T=[];for(let[c,a]of l){let s=a.subscribe((d=>{if(!g)for(let i of d){let k=i[0];k!==h&&(K.isLocalOnly(k)||(k===B?n.post({t:"e",s:c,err:P(i[1])}):n.post({t:"s",s:c,sig:I(k),d:i.length>1?i[1]:void 0})))}}));T.push(s)}let M;if(r.timeoutMs!=null&&r.timeoutMs>0){let c=q(r.timeoutMs),a=J(v,d=>d==="connected");M=Q(X(U(c,()=>"timeout"),U(a,()=>"ready"))).subscribe(d=>{for(let i of d)i[0]===h&&i[1]==="timeout"&&(N.down([[h,new Error("Worker bridge handshake timeout")]]),x())})}function x(){if(!g){g=!0,M?.(),n.post({t:"s",s:"*",sig:I(S)}),m&&m();for(let c of T)c();T.length=0,w(),v.down([[h,"closed"]]),u.clear(),o.clear()}}let b={meta:{status:v,error:N},destroy:x};for(let[c,a]of o)b[c]=a;return b}function Kr(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function be(e,r){let n=Kr(e)?e:L(e),p=r.import??[],l=r.transfer??{},t=new Map,f=new Map,v={};for(let x of p){let b=O(void 0,{name:`worker::${x}`});t.set(x,b),v[x]=b}let N=r.expose(v),o=Object.entries(N),u,m=!1;if(o.length>0){let x=o.map(([,a])=>a),b=C(x,(a,s)=>{let d={};for(let i=0;i<o.length;i++){let[k]=o[i],y=a[i];y!=null&&y.length>0&&(d[k]=y.at(-1))}Object.keys(d).length!==0&&s.emit(d)},{name:"workerSelf::aggregated",partial:!0});u=D([b],a=>{if(m)return;let s=a[0];if(s==null||Object.keys(s).length===0)return;let d=[];for(let y of Object.keys(s)){let R=l[y];R&&d.push(...R(s[y]))}let i;for(let[y,R]of o)y in s&&R.v!=null&&(i==null&&(i={}),i[y]=R.v.version);let k={t:"b",u:s,...i?{v:i}:{}};try{n.post(k,d.length>0?d:void 0)}catch{}}).subscribe(()=>{})}let g=[];for(let[x,b]of o){let c=b.subscribe((a=>{if(!m)for(let s of a){let d=s[0];d!==h&&(K.isLocalOnly(d)||(d===B?n.post({t:"e",s:x,err:P(s[1])}):n.post({t:"s",s:x,sig:I(d),d:s.length>1?s[1]:void 0})))}}));g.push(c)}let w=n.listen(x=>{if(m)return;let b=x;switch(b.t){case"i":{W(()=>{for(let[c,a]of Object.entries(b.stores)){let s=t.get(c);s&&s.down([[h,a]])}});break}case"v":{let c=t.get(b.s);c&&c.down([[h,b.d]]);break}case"b":{W(()=>{for(let[c,a]of Object.entries(b.u)){let s=b.v?.[c];if(s!=null){let i=f.get(c);if(i!=null&&s<=i)continue;f.set(c,s)}let d=t.get(c);d&&d.down([[h,a]])}});break}case"e":{let c=t.get(b.s);c&&c.down([[B,A(b.err)]]);break}case"s":{let c=V(b.sig);if(!c)break;if(c===S&&b.s==="*"){M();return}let a=b.s==="*"?[...t.values()]:t.has(b.s)?[t.get(b.s)]:[];for(let s of a)s.down(b.d===void 0?[[c]]:[[c,b.d]]);break}}}),T={};for(let[x,b]of o)T[x]=b.cache;n.post({t:"r",stores:T});function M(){if(!m){m=!0,u&&u();for(let x of g)x();g.length=0,w(),n.terminate?.(),f.clear(),t.clear()}}return{destroy:M}}export{le as a,jr as b,_ as c,Vr as d,I as e,V as f,P as g,A as h,L as i,ge as j,be as k,Dr as l};
@@ -1 +1 @@
1
- import{a as e}from"../chunk-I2DEVPMU.js";import{b as a}from"../chunk-KRH66M4O.js";import{i as b}from"../chunk-CLD3F4R5.js";import{G as c}from"../chunk-6VWBPSSY.js";import"../chunk-7Q4ZD3YW.js";import{d}from"../chunk-VJLMUKOI.js";import{d as f}from"../chunk-VIMF6LGM.js";import{d as g}from"../chunk-6QZNQS5B.js";import{d as h}from"../chunk-GPW2V3RE.js";import{b as i}from"../chunk-B7LCDQEV.js";import"../chunk-ECQRP2UT.js";import"../chunk-3G5U5QNE.js";import"../chunk-C72GO4IZ.js";import"../chunk-4I45FVQS.js";import"../chunk-5QDBSZBV.js";import"../chunk-756D5TFD.js";import"../chunk-L6NSJVJZ.js";import"../chunk-2BX4NB34.js";import"../chunk-SGS4OJGS.js";import"../chunk-ESMPEKEV.js";import"../chunk-35JTVPOX.js";import"../chunk-YXDRGKXP.js";import"../chunk-CKFQS2CJ.js";import"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{a as jotai,b as nanostores,c as nestjs,d as react,e as signals,f as solid,g as svelte,h as vue,i as zustand};
1
+ import{a as e}from"../chunk-M3FQSXEW.js";import{b as a}from"../chunk-KRH66M4O.js";import{i as b}from"../chunk-CLD3F4R5.js";import{G as c}from"../chunk-X7QKTXXC.js";import"../chunk-H5SCWHWP.js";import{d}from"../chunk-VJLMUKOI.js";import{d as f}from"../chunk-VIMF6LGM.js";import{d as g}from"../chunk-6QZNQS5B.js";import{d as h}from"../chunk-GPW2V3RE.js";import{b as i}from"../chunk-CGNOWGV6.js";import"../chunk-4I45FVQS.js";import"../chunk-5TEFC2ZX.js";import"../chunk-3G5U5QNE.js";import"../chunk-C72GO4IZ.js";import"../chunk-5QDBSZBV.js";import"../chunk-VXPLLA4P.js";import"../chunk-L6NSJVJZ.js";import"../chunk-TT4C7DXW.js";import"../chunk-POXANAJ6.js";import"../chunk-SGS4OJGS.js";import"../chunk-ESMPEKEV.js";import"../chunk-L77I47VU.js";import"../chunk-35JTVPOX.js";import"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{a as jotai,b as nanostores,c as nestjs,d as react,e as signals,f as solid,g as svelte,h as vue,i as zustand};
@@ -1 +1 @@
1
- import{A as B,B as C,C as D,D as E,E as F,F as G,a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r,r as s,s as t,t as u,u as v,v as w,w as x,x as y,y as z,z as A}from"../../chunk-6VWBPSSY.js";import"../../chunk-7Q4ZD3YW.js";import"../../chunk-ECQRP2UT.js";import"../../chunk-3G5U5QNE.js";import"../../chunk-C72GO4IZ.js";import"../../chunk-4I45FVQS.js";import{a}from"../../chunk-5QDBSZBV.js";import"../../chunk-756D5TFD.js";import"../../chunk-L6NSJVJZ.js";import"../../chunk-2BX4NB34.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-35JTVPOX.js";import"../../chunk-YXDRGKXP.js";import"../../chunk-CKFQS2CJ.js";import"../../chunk-LYCLF26R.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{A as ACTOR_KEY,i as COMMAND_HANDLERS,j as CQRS_EVENT_HANDLERS,h as CRON_HANDLERS,s as CommandHandler,f as EVENT_HANDLERS,t as EventHandler,c as GRAPHREFLY_REQUEST_GRAPH,b as GRAPHREFLY_ROOT_GRAPH,r as GraphCron,q as GraphInterval,w as GraphReflyEventExplorer,F as GraphReflyGuard,E as GraphReflyGuardImpl,G as GraphReflyModule,g as INTERVAL_HANDLERS,n as InjectCqrsGraph,m as InjectGraph,o as InjectNode,z as ObserveGateway,p as OnGraphEvent,k as QUERY_HANDLERS,u as QueryHandler,l as SAGA_HANDLERS,v as SagaHandler,C as fromHeader,B as fromJwtPayload,D as getActor,d as getGraphToken,e as getNodeToken,x as observeSSE,y as observeSubscription,a as toObservable};
1
+ import{A as B,B as C,C as D,D as E,E as F,F as G,a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r,r as s,s as t,t as u,u as v,v as w,w as x,x as y,y as z,z as A}from"../../chunk-X7QKTXXC.js";import"../../chunk-H5SCWHWP.js";import"../../chunk-4I45FVQS.js";import"../../chunk-5TEFC2ZX.js";import"../../chunk-3G5U5QNE.js";import"../../chunk-C72GO4IZ.js";import{a}from"../../chunk-5QDBSZBV.js";import"../../chunk-VXPLLA4P.js";import"../../chunk-L6NSJVJZ.js";import"../../chunk-TT4C7DXW.js";import"../../chunk-POXANAJ6.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-L77I47VU.js";import"../../chunk-35JTVPOX.js";import"../../chunk-LYCLF26R.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{A as ACTOR_KEY,i as COMMAND_HANDLERS,j as CQRS_EVENT_HANDLERS,h as CRON_HANDLERS,s as CommandHandler,f as EVENT_HANDLERS,t as EventHandler,c as GRAPHREFLY_REQUEST_GRAPH,b as GRAPHREFLY_ROOT_GRAPH,r as GraphCron,q as GraphInterval,w as GraphReflyEventExplorer,F as GraphReflyGuard,E as GraphReflyGuardImpl,G as GraphReflyModule,g as INTERVAL_HANDLERS,n as InjectCqrsGraph,m as InjectGraph,o as InjectNode,z as ObserveGateway,p as OnGraphEvent,k as QUERY_HANDLERS,u as QueryHandler,l as SAGA_HANDLERS,v as SagaHandler,C as fromHeader,B as fromJwtPayload,D as getActor,d as getGraphToken,e as getNodeToken,x as observeSSE,y as observeSubscription,a as toObservable};
@@ -1 +1 @@
1
- import{a}from"../../chunk-B7LCDQEV.js";import"../../chunk-2BX4NB34.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-35JTVPOX.js";import"../../chunk-CKFQS2CJ.js";import"../../chunk-LYCLF26R.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{a as create};
1
+ import{a}from"../../chunk-CGNOWGV6.js";import"../../chunk-POXANAJ6.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-L77I47VU.js";import"../../chunk-35JTVPOX.js";import"../../chunk-LYCLF26R.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{a as create};
@@ -1 +1 @@
1
- import{a as jc,b as kc,c as tc,d as uc,e as Qc,f as Rc,g as Sc,h as Tc,i as Uc,j as Vc,k as Wc}from"../chunk-N43XM7BM.js";import{a as nc,b as oc}from"../chunk-PPUYQ66A.js";import{b as Pc}from"../chunk-TSOYJ743.js";import{$ as hc,A as Ib,B as Jb,C as Kb,D as Lb,E as Mb,F as Nb,G as Ob,H as Pb,I as Qb,J as Rb,K as Sb,L as Tb,M as Ub,N as Vb,O as Wb,P as Xb,Q as Yb,R as Zb,S as _b,T as $b,U as ac,V as bc,W as cc,X as dc,Y as ec,Z as fc,_ as gc,a as oa,aa as ic,b as pa,ba as sc,c as kb,d as lb,e as mb,f as nb,g as ob,h as pb,i as qb,j as rb,k as sb,l as tb,m as ub,n as vb,o as wb,p as xb,q as yb,r as zb,s as Ab,t as Bb,u as Cb,v as Db,w as Eb,x as Fb,y as Gb,z as Hb}from"../chunk-LCGAVGGV.js";import{a as e,b as p,c as q,d as r,e as s,f as t,g as u,h as v,i as w,j as x,k as y,l as z}from"../chunk-RZJDIV2G.js";import{b as pc,c as qc,d as rc,e as zc,f as Ac}from"../chunk-6I726LZU.js";import{a as Oc}from"../chunk-2QXRYP7Q.js";import{a,b as aa}from"../chunk-5QDBSZBV.js";import{a as fa,b as ga,c as ha,d as ia,e as ja,f as ka,g as la,h as ma,i as na}from"../chunk-756D5TFD.js";import{a as d}from"../chunk-L6NSJVJZ.js";import{a as ba}from"../chunk-2BX4NB34.js";import"../chunk-SGS4OJGS.js";import{a as o}from"../chunk-ESMPEKEV.js";import{a as Dc,b as Ec,c as Fc,d as Gc,e as Hc,f as Ic,g as Jc,h as Kc,i as Lc,j as Mc,k as Nc}from"../chunk-D5RFJOZ2.js";import{a as Bc,b as Cc}from"../chunk-CE72X3WO.js";import{A as Qa,B as Ra,C as Sa,D as Ta,E as Ua,F as Va,G as Wa,I as Xa,J as Ya,K as Za,L as _a,M as $a,N as ab,O as bb,P as cb,Q as db,R as eb,S as fb,T as gb,U as hb,V as ib,W as jb,a as qa,b as ra,c as sa,d as ta,e as ua,f as va,g as wa,h as xa,i as ya,j as za,k as Aa,l as Ba,m as Ca,n as Da,o as Ea,p as Fa,q as Ga,r as Ha,s as Ia,t as Ja,u as Ka,v as La,w as Ma,x as Na,y as Oa,z as Pa}from"../chunk-FHRBBHJN.js";import{a as f,b as g,c as h,d as i,e as j,f as k,g as l,h as m,i as n}from"../chunk-4VVTGLXJ.js";import"../chunk-35JTVPOX.js";import{a as vc,b as wc}from"../chunk-NNKJUORL.js";import{a as xc,b as yc}from"../chunk-KGKJCHEK.js";import{a as lc,b as mc}from"../chunk-TZQPPQEQ.js";import{a as ca,b as da,c as ea}from"../chunk-YXDRGKXP.js";import{A as Y,B as Z,C as _,D as $,a as b,b as c,c as A,d as B,e as C,f as D,g as E,h as F,i as G,j as H,k as I,l as J,m as K,n as L,o as M,p as N,q as O,r as P,s as Q,t as R,u as S,v as T,w as U,x as V,y as W,z as X}from"../chunk-CKFQS2CJ.js";import"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{q as CircuitOpenError,pc as ContentAddressedMissError,ga as DEFAULT_AUDIT_GUARD,f as NS_PER_MS,g as NS_PER_SEC,vc as NativeIndexBackend,xc as NativeListBackend,ca as NativeLogBackend,lc as NativeMapBackend,tc as NativePubSubBackend,u as RateLimiterOverflowError,o as ResettableTimer,x as TimeoutError,ja as appendAudit,Hc as appendLogStorage,Wa as audit,X as awaitSettled,e as budgetGate,Xa as buffer,Ya as bufferCount,_a as bufferTime,ia as bumpCursor,U as cached,qc as canonicalJson,kc as cascadingCache,jb as catchError,cc as checkpointToRedis,bc as checkpointToS3,r as circuitBreaker,Ha as combine,gb as combineLatest,La as concat,Pa as concatMap,h as constant,rc as contentAddressedStorage,ha as createAuditLog,Uc as createTransport,aa as createWatermarkController,Lb as csvRows,Ta as debounce,hb as debounceTime,Pc as decay,l as decorrelatedJitter,P as defer,Sa as delay,Tc as deserializeError,Mc as dictKv,Nc as dictSnapshot,oc as distill,Fa as distinctUntilChanged,d as domainMeta,Ba as elementAt,M as empty,A as escapeRegexChar,Oa as exhaustMap,j as exponential,pa as externalBundle,oa as externalProducer,y as fallback,k as fibonacci,ra as filter,Aa as find,ya as first,V as firstValueFrom,W as firstWhere,Ra as flatMap,Q as forEach,K as fromAny,J as fromAsyncIter,Kb as fromCSV,Ob as fromClickHouseWatch,F as fromCron,hc as fromDrizzle,G as fromEvent,nb as fromHTTP,vb as fromHTTPPoll,ub as fromHTTPStream,H as fromIter,Gb as fromKafka,ic as fromKysely,yb as fromMCP,Rb as fromNATS,Nb as fromNDJSON,zb as fromOTel,gc as fromPrisma,Eb as fromPrometheus,I as fromPromise,Pb as fromPulsar,Tb as fromRabbitMQ,E as fromRaf,Ib as fromRedisStream,tb as fromSSE,dc as fromSqlite,ec as fromSqliteCursor,Cb as fromStatsD,Ab as fromSyslog,D as fromTimer,lb as fromWebSocket,xb as fromWebSocketReconnect,mb as fromWebhook,B as globToRegExp,bb as interval,Dc as jsonCodec,Ec as jsonCodecFor,_ as keepalive,Ic as kvStorage,za as last,ka as lightMutation,i as linear,jc as lru,sc as makeHttpError,qa as map,C as matchesAnyPattern,c as matchesCron,Kc as memoryAppendLog,Fc as memoryBackend,Lc as memoryKv,Jc as memorySnapshot,Ja as merge,Qa as mergeMap,ea as mergeReactiveLogs,Rc as nameToSignal,Mb as ndjsonRows,N as never,Y as nodeSignal,L as of,Da as onFirstData,Ga as pairwise,b as parseCron,Fb as parsePrometheusText,sb as parseSSEStream,Db as parseStatsD,Bb as parseSyslog,db as pausable,uc as pubsub,Ma as race,v as rateLimiter,$ as reactiveCounter,wc as reactiveIndex,yc as reactiveList,da as reactiveLog,mc as reactiveMap,kb as reactiveSink,ta as reduce,ma as registerCursor,na as registerCursorMap,cb as repeat,T as replay,eb as rescue,n as resolveBackoffPreset,p as retry,Va as sample,sa as scan,Sc as serializeError,S as share,Z as shareReplay,Qc as signalToName,zc as singleFromAny,Ac as singleNodeFromAny,va as skip,Gc as snapshotStorage,Bc as sortJsonValue,Cc as stableJsonString,Oc as stratify,Na as switchMap,ua as take,xa as takeUntil,wa as takeWhile,Ca as tap,Ea as tapFirst,Ua as throttle,ib as throttleTime,O as throwError,z as timeout,R as toArray,Wb as toCSV,Xb as toClickHouse,Vb as toFile,ob as toHTTP,Hb as toKafka,$b as toLoki,_b as toMongo,Sb as toNATS,a as toObservable,Zb as toPostgres,Qb as toPulsar,Ub as toRabbitMQ,rb as toReadableStream,Jb as toRedisStream,Yb as toS3,pb as toSSE,qb as toSSEBytes,fc as toSqlite,ac as toTempo,wb as toWebSocket,t as tokenBucket,ba as topologyDiff,fa as tryIncrementBounded,fb as valve,nc as verifiable,ab as window,Za as windowCount,$a as windowTime,s as withBreaker,Ia as withLatestFrom,m as withMaxAttempts,w as withStatus,Vc as workerBridge,Wc as workerSelf,la as wrapMutation,Ka as zip};
1
+ import{a as jc,b as kc,c as tc,d as uc,e as Qc,f as Rc,g as Sc,h as Tc,i as Uc,j as Vc,k as Wc}from"../chunk-ZAJ7J7TO.js";import{a as nc,b as oc}from"../chunk-WZYB3JQS.js";import{b as Pc}from"../chunk-TSOYJ743.js";import{$ as hc,A as Ib,B as Jb,C as Kb,D as Lb,E as Mb,F as Nb,G as Ob,H as Pb,I as Qb,J as Rb,K as Sb,L as Tb,M as Ub,N as Vb,O as Wb,P as Xb,Q as Yb,R as Zb,S as _b,T as $b,U as ac,V as bc,W as cc,X as dc,Y as ec,Z as fc,_ as gc,a as oa,aa as ic,b as pa,ba as sc,c as kb,d as lb,e as mb,f as nb,g as ob,h as pb,i as qb,j as rb,k as sb,l as tb,m as ub,n as vb,o as wb,p as xb,q as yb,r as zb,s as Ab,t as Bb,u as Cb,v as Db,w as Eb,x as Fb,y as Gb,z as Hb}from"../chunk-CYOSWFT2.js";import{a as e,b as p,c as q,d as r,e as s,f as t,g as u,h as v,i as w,j as x,k as y,l as z}from"../chunk-4MKL6Q3K.js";import{b as pc,c as qc,d as rc,e as zc,f as Ac}from"../chunk-KNVCCBIU.js";import{a as Oc}from"../chunk-AI7QC7J6.js";import{a as vc,b as wc}from"../chunk-NNKJUORL.js";import{a as xc,b as yc}from"../chunk-KGKJCHEK.js";import{a as lc,b as mc}from"../chunk-TZQPPQEQ.js";import{a,b as aa}from"../chunk-5QDBSZBV.js";import{a as fa,b as ga,c as ha,d as ia,e as ja,f as ka,g as la,h as ma,i as na}from"../chunk-VXPLLA4P.js";import{a as d}from"../chunk-L6NSJVJZ.js";import{a as ca,b as da,c as ea}from"../chunk-TT4C7DXW.js";import{a as ba}from"../chunk-POXANAJ6.js";import"../chunk-SGS4OJGS.js";import{a as o}from"../chunk-ESMPEKEV.js";import{a as Dc,b as Ec,c as Fc,d as Gc,e as Hc,f as Ic,g as Jc,h as Kc,i as Lc,j as Mc,k as Nc}from"../chunk-D5RFJOZ2.js";import{a as Bc,b as Cc}from"../chunk-CE72X3WO.js";import{A as Qa,B as Ra,C as Sa,D as Ta,E as Ua,F as Va,G as Wa,I as Xa,J as Ya,K as Za,L as _a,M as $a,N as ab,O as bb,P as cb,Q as db,R as eb,S as fb,T as gb,U as hb,V as ib,W as jb,a as qa,b as ra,c as sa,d as ta,e as ua,f as va,g as wa,h as xa,i as ya,j as za,k as Aa,l as Ba,m as Ca,n as Da,o as Ea,p as Fa,q as Ga,r as Ha,s as Ia,t as Ja,u as Ka,v as La,w as Ma,x as Na,y as Oa,z as Pa}from"../chunk-AK5RHMC5.js";import{a as f,b as g,c as h,d as i,e as j,f as k,g as l,h as m,i as n}from"../chunk-4VVTGLXJ.js";import{A as Y,B as Z,C as _,D as $,a as b,b as c,c as A,d as B,e as C,f as D,g as E,h as F,i as G,j as H,k as I,l as J,m as K,n as L,o as M,p as N,q as O,r as P,s as Q,t as R,u as S,v as T,w as U,x as V,y as W,z as X}from"../chunk-L77I47VU.js";import"../chunk-35JTVPOX.js";import"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{q as CircuitOpenError,pc as ContentAddressedMissError,ga as DEFAULT_AUDIT_GUARD,f as NS_PER_MS,g as NS_PER_SEC,vc as NativeIndexBackend,xc as NativeListBackend,ca as NativeLogBackend,lc as NativeMapBackend,tc as NativePubSubBackend,u as RateLimiterOverflowError,o as ResettableTimer,x as TimeoutError,ja as appendAudit,Hc as appendLogStorage,Wa as audit,X as awaitSettled,e as budgetGate,Xa as buffer,Ya as bufferCount,_a as bufferTime,ia as bumpCursor,U as cached,qc as canonicalJson,kc as cascadingCache,jb as catchError,cc as checkpointToRedis,bc as checkpointToS3,r as circuitBreaker,Ha as combine,gb as combineLatest,La as concat,Pa as concatMap,h as constant,rc as contentAddressedStorage,ha as createAuditLog,Uc as createTransport,aa as createWatermarkController,Lb as csvRows,Ta as debounce,hb as debounceTime,Pc as decay,l as decorrelatedJitter,P as defer,Sa as delay,Tc as deserializeError,Mc as dictKv,Nc as dictSnapshot,oc as distill,Fa as distinctUntilChanged,d as domainMeta,Ba as elementAt,M as empty,A as escapeRegexChar,Oa as exhaustMap,j as exponential,pa as externalBundle,oa as externalProducer,y as fallback,k as fibonacci,ra as filter,Aa as find,ya as first,V as firstValueFrom,W as firstWhere,Ra as flatMap,Q as forEach,K as fromAny,J as fromAsyncIter,Kb as fromCSV,Ob as fromClickHouseWatch,F as fromCron,hc as fromDrizzle,G as fromEvent,nb as fromHTTP,vb as fromHTTPPoll,ub as fromHTTPStream,H as fromIter,Gb as fromKafka,ic as fromKysely,yb as fromMCP,Rb as fromNATS,Nb as fromNDJSON,zb as fromOTel,gc as fromPrisma,Eb as fromPrometheus,I as fromPromise,Pb as fromPulsar,Tb as fromRabbitMQ,E as fromRaf,Ib as fromRedisStream,tb as fromSSE,dc as fromSqlite,ec as fromSqliteCursor,Cb as fromStatsD,Ab as fromSyslog,D as fromTimer,lb as fromWebSocket,xb as fromWebSocketReconnect,mb as fromWebhook,B as globToRegExp,bb as interval,Dc as jsonCodec,Ec as jsonCodecFor,_ as keepalive,Ic as kvStorage,za as last,ka as lightMutation,i as linear,jc as lru,sc as makeHttpError,qa as map,C as matchesAnyPattern,c as matchesCron,Kc as memoryAppendLog,Fc as memoryBackend,Lc as memoryKv,Jc as memorySnapshot,Ja as merge,Qa as mergeMap,ea as mergeReactiveLogs,Rc as nameToSignal,Mb as ndjsonRows,N as never,Y as nodeSignal,L as of,Da as onFirstData,Ga as pairwise,b as parseCron,Fb as parsePrometheusText,sb as parseSSEStream,Db as parseStatsD,Bb as parseSyslog,db as pausable,uc as pubsub,Ma as race,v as rateLimiter,$ as reactiveCounter,wc as reactiveIndex,yc as reactiveList,da as reactiveLog,mc as reactiveMap,kb as reactiveSink,ta as reduce,ma as registerCursor,na as registerCursorMap,cb as repeat,T as replay,eb as rescue,n as resolveBackoffPreset,p as retry,Va as sample,sa as scan,Sc as serializeError,S as share,Z as shareReplay,Qc as signalToName,zc as singleFromAny,Ac as singleNodeFromAny,va as skip,Gc as snapshotStorage,Bc as sortJsonValue,Cc as stableJsonString,Oc as stratify,Na as switchMap,ua as take,xa as takeUntil,wa as takeWhile,Ca as tap,Ea as tapFirst,Ua as throttle,ib as throttleTime,O as throwError,z as timeout,R as toArray,Wb as toCSV,Xb as toClickHouse,Vb as toFile,ob as toHTTP,Hb as toKafka,$b as toLoki,_b as toMongo,Sb as toNATS,a as toObservable,Zb as toPostgres,Qb as toPulsar,Ub as toRabbitMQ,rb as toReadableStream,Jb as toRedisStream,Yb as toS3,pb as toSSE,qb as toSSEBytes,fc as toSqlite,ac as toTempo,wb as toWebSocket,t as tokenBucket,ba as topologyDiff,fa as tryIncrementBounded,fb as valve,nc as verifiable,ab as window,Za as windowCount,$a as windowTime,s as withBreaker,Ia as withLatestFrom,m as withMaxAttempts,w as withStatus,Vc as workerBridge,Wc as workerSelf,la as wrapMutation,Ka as zip};
@@ -1,2 +1,2 @@
1
- import{a as K,b as j,c as I,d as D,e as z,f as $,g as Q,h as U}from"../chunk-VN6RDSK2.js";import"../chunk-D5RFJOZ2.js";import"../chunk-CE72X3WO.js";import{x as P}from"../chunk-FHRBBHJN.js";import"../chunk-4VVTGLXJ.js";import"../chunk-35JTVPOX.js";import{d as E,e as g,f as L}from"../chunk-CKFQS2CJ.js";import{F as v,p as F}from"../chunk-LYCLF26R.js";import{b as y,i as B,j as x}from"../chunk-CK2E7BTU.js";import{a as q}from"../chunk-QYADASLV.js";function V(a,h){let{pollMs:o=5e3,include:c,exclude:e,maxConsecutiveErrors:t=1}=h??{},u=c?.map(E)??[],n=e?.map(E)??[],{execFileSync:d}=q("child_process"),r=S=>d("git",S,{cwd:a,encoding:"utf-8"}).trim(),l,i=0;return P(L(0,{period:o}),()=>v(S=>{try{let s=r(["rev-parse","HEAD"]);if(!s)return i=0,()=>{};if(l===void 0)return l=s,i=0,()=>{};if(s===l)return i=0,()=>{};let p=r(["diff","--name-only",`${l}..${s}`]).split(`
1
+ import{a as K,b as j,c as I,d as D,e as z,f as $,g as Q,h as U}from"../chunk-VN6RDSK2.js";import"../chunk-D5RFJOZ2.js";import"../chunk-CE72X3WO.js";import{x as P}from"../chunk-AK5RHMC5.js";import"../chunk-4VVTGLXJ.js";import{d as E,e as g,f as L}from"../chunk-L77I47VU.js";import"../chunk-35JTVPOX.js";import{F as v,p as F}from"../chunk-LYCLF26R.js";import{b as y,i as B,j as x}from"../chunk-CK2E7BTU.js";import{a as q}from"../chunk-QYADASLV.js";function V(a,h){let{pollMs:o=5e3,include:c,exclude:e,maxConsecutiveErrors:t=1}=h??{},u=c?.map(E)??[],n=e?.map(E)??[],{execFileSync:d}=q("child_process"),r=S=>d("git",S,{cwd:a,encoding:"utf-8"}).trim(),l,i=0;return P(L(0,{period:o}),()=>v(S=>{try{let s=r(["rev-parse","HEAD"]);if(!s)return i=0,()=>{};if(l===void 0)return l=s,i=0,()=>{};if(s===l)return i=0,()=>{};let p=r(["diff","--name-only",`${l}..${s}`]).split(`
2
2
  `).filter(Boolean);u.length>0&&(p=p.filter(w=>g(w,u))),n.length>0&&(p=p.filter(w=>!g(w,n)));let k=r(["log","-1","--format=%s",s]),T=r(["log","-1","--format=%an",s]);S.emit({hook:"post-commit",commit:s,files:p,message:k,author:T,timestamp_ns:F()}),l=s,i=0}catch(s){i+=1,i>=t&&S.down([[x,s]])}return()=>{}}))}import{existsSync as X,watch as Y}from"fs";import{resolve as _}from"path";function Z(a){return{describeKind:"producer",...a}}function Se(a,h){let o=Array.isArray(a)?a:[a];if(o.length===0)throw new RangeError("fromFSWatch expects at least one path");let{recursive:c=!0,debounce:e=100,include:t,exclude:u,...n}=h??{},d=t?.map(E)??[],r=(u??["**/node_modules/**","**/.git/**","**/dist/**"]).map(E);return v(l=>{let i=new Map,S=[],s=!1,p=!1,k=0,T=()=>{for(let f of S.splice(0))f.close()},w=f=>{p||(p=!0,s=!0,m!==void 0&&clearTimeout(m),m=void 0,i.clear(),T(),l.down([[x,f]]))},m,H=f=>{if(m=void 0,s||p||i.size===0)return;let O=[];for(let b of i.values())O.push([y,b]);i.clear(),!(s||p||f!==k)&&l.down(O)};try{for(let f of o){let O=Y(f,{recursive:c},(b,N)=>{if(s||p||N==null)return;let M=String(N).replaceAll("\\","/"),A=_(f,String(N)).replaceAll("\\","/"),J=_(f).replaceAll("\\","/"),R=M.startsWith("./")?M.slice(2):M;if(!(d.length===0||g(A,d)||g(R,d))||g(A,r)||g(R,r))return;let G="change";if(b==="rename")try{G=X(A)?"create":"delete"}catch{G="rename"}i.set(A,{type:G,path:A,root:J,relative_path:R,timestamp_ns:F()}),m!==void 0&&clearTimeout(m);let W=k;m=setTimeout(()=>H(W),e)});O.on("error",b=>w(b)),S.push(O)}}catch(f){w(f)}return()=>{s=!0,k+=1,m!==void 0&&clearTimeout(m),m=void 0,T(),i.clear()}},Z(n))}import{spawn as C}from"child_process";function ee(a,h,o){return v(c=>{let e=C(a,h,{cwd:o?.cwd,env:o?.env,shell:o?.shell,signal:o?.signal,stdio:o?.stdio??"pipe"}),t=!0,u=null;return e.stdout?.on("data",n=>{t&&c.down([[y,{kind:"stdout",chunk:n}]])}),e.stderr?.on("data",n=>{t&&c.down([[y,{kind:"stderr",chunk:n}]])}),e.on("error",n=>{t&&(t=!1,c.down([[x,n]]))}),e.on("exit",(n,d)=>{u==null&&(u={code:n,signal:d})}),e.on("close",()=>{if(!t)return;t=!1;let n=u??{code:null,signal:null};c.down([[y,{kind:"exit",code:n.code,signal:n.signal}],[B]])}),()=>{if(t){t=!1,e.stdout?.removeAllListeners(),e.stderr?.removeAllListeners(),e.removeAllListeners("error"),e.removeAllListeners("exit"),e.removeAllListeners("close");try{e.kill("SIGTERM")}catch{}}}},{name:"from_spawn"})}function te(a,h,o){return v(c=>{let e=C(a,h,{cwd:o?.cwd,env:o?.env,shell:o?.shell,signal:o?.signal,stdio:o?.stdio??"pipe"}),t=!0,u=[],n=[],d=null;return e.stdout?.on("data",r=>{t&&u.push(r)}),e.stderr?.on("data",r=>{t&&n.push(r)}),e.on("error",r=>{t&&(t=!1,c.down([[x,r]]))}),e.on("exit",(r,l)=>{d==null&&(d={code:r,signal:l})}),e.on("close",()=>{if(!t)return;t=!1;let r=d??{code:null,signal:null},l=Buffer.concat(u).toString("utf8"),i=Buffer.concat(n).toString("utf8");c.down([[y,{stdout:l,stderr:i,exitCode:r.code,signal:r.signal}],[B]])}),()=>{if(t){t=!1,e.stdout?.removeAllListeners(),e.stderr?.removeAllListeners(),e.removeAllListeners("error"),e.removeAllListeners("exit"),e.removeAllListeners("close");try{e.kill("SIGTERM")}catch{}}}},{name:"run_process"})}export{D as fileAppendLog,K as fileBackend,Q as fileKv,I as fileSnapshot,Se as fromFSWatch,V as fromGitHook,ee as fromSpawn,te as runProcess,$ as sqliteAppendLog,j as sqliteBackend,U as sqliteKv,z as sqliteSnapshot};
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-FHRBBHJN.js";import"../chunk-4VVTGLXJ.js";import"../chunk-35JTVPOX.js";import"../chunk-CKFQS2CJ.js";import"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{G as audit,I as buffer,J as bufferCount,L as bufferTime,W as catchError,r as combine,T as combineLatest,v as concat,z as concatMap,D as debounce,U as debounceTime,C as delay,p as distinctUntilChanged,l as elementAt,y as exhaustMap,b as filter,k as find,i as first,B as flatMap,O as interval,j as last,a as map,t as merge,A as mergeMap,n as onFirstData,q as pairwise,Q as pausable,w as race,d as reduce,P as repeat,R as rescue,F as sample,c as scan,f as skip,x as switchMap,e as take,h as takeUntil,g as takeWhile,m as tap,o as tapFirst,E as throttle,V as throttleTime,H as timeout,S as valve,N as window,K as windowCount,M as windowTime,s as withLatestFrom,u as zip};
1
+ import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-AK5RHMC5.js";import"../chunk-4VVTGLXJ.js";import"../chunk-L77I47VU.js";import"../chunk-35JTVPOX.js";import"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{G as audit,I as buffer,J as bufferCount,L as bufferTime,W as catchError,r as combine,T as combineLatest,v as concat,z as concatMap,D as debounce,U as debounceTime,C as delay,p as distinctUntilChanged,l as elementAt,y as exhaustMap,b as filter,k as find,i as first,B as flatMap,O as interval,j as last,a as map,t as merge,A as mergeMap,n as onFirstData,q as pairwise,Q as pausable,w as race,d as reduce,P as repeat,R as rescue,F as sample,c as scan,f as skip,x as switchMap,e as take,h as takeUntil,g as takeWhile,m as tap,o as tapFirst,E as throttle,V as throttleTime,H as timeout,S as valve,N as window,K as windowCount,M as windowTime,s as withLatestFrom,u as zip};
@@ -1 +1 @@
1
- import{a as p,b as t}from"../chunk-NNKJUORL.js";import{a as x,b as a}from"../chunk-KGKJCHEK.js";import{a as f,b as m}from"../chunk-TZQPPQEQ.js";import{a as o,b as r,c as e}from"../chunk-YXDRGKXP.js";import"../chunk-CKFQS2CJ.js";import"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{p as NativeIndexBackend,x as NativeListBackend,o as NativeLogBackend,f as NativeMapBackend,e as mergeReactiveLogs,t as reactiveIndex,a as reactiveList,r as reactiveLog,m as reactiveMap};
1
+ import{a as p,b as t}from"../chunk-NNKJUORL.js";import{a as x,b as a}from"../chunk-KGKJCHEK.js";import{a as f,b as m}from"../chunk-TZQPPQEQ.js";import{a as o,b as r,c as e}from"../chunk-TT4C7DXW.js";import"../chunk-L77I47VU.js";import"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{p as NativeIndexBackend,x as NativeListBackend,o as NativeLogBackend,f as NativeMapBackend,e as mergeReactiveLogs,t as reactiveIndex,a as reactiveList,r as reactiveLog,m as reactiveMap};
@@ -1 +1 @@
1
- import{A as y,B as z,C as A,D as B,c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"../chunk-CKFQS2CJ.js";import"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{x as awaitSettled,u as cached,p as defer,m as empty,a as escapeRegexChar,v as firstValueFrom,w as firstWhere,q as forEach,k as fromAny,j as fromAsyncIter,f as fromCron,g as fromEvent,h as fromIter,i as fromPromise,e as fromRaf,d as fromTimer,b as globToRegExp,A as keepalive,c as matchesAnyPattern,n as never,y as nodeSignal,l as of,B as reactiveCounter,t as replay,s as share,z as shareReplay,o as throwError,r as toArray};
1
+ import{A as y,B as z,C as A,D as B,c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"../chunk-L77I47VU.js";import"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{x as awaitSettled,u as cached,p as defer,m as empty,a as escapeRegexChar,v as firstValueFrom,w as firstWhere,q as forEach,k as fromAny,j as fromAsyncIter,f as fromCron,g as fromEvent,h as fromIter,i as fromPromise,e as fromRaf,d as fromTimer,b as globToRegExp,A as keepalive,c as matchesAnyPattern,n as never,y as nodeSignal,l as of,B as reactiveCounter,t as replay,s as share,z as shareReplay,o as throwError,r as toArray};
@@ -1 +1 @@
1
- import{a as s,b as t}from"../chunk-ECQRP2UT.js";import"../chunk-3G5U5QNE.js";import"../chunk-C72GO4IZ.js";import{b as i,c as j,d as k,e as l,f as m,g as n,h as o,i as p,j as q,k as r}from"../chunk-2BX4NB34.js";import"../chunk-SGS4OJGS.js";import"../chunk-ESMPEKEV.js";import"../chunk-35JTVPOX.js";import"../chunk-CKFQS2CJ.js";import{a,b,c,d,e,f,g,h}from"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{d as ENVELOPE_VERSION,n as GRAPH_META_SEGMENT,p as Graph,a as JsonCodec,j as SIZEOF_OVERHEAD,k as SIZEOF_SYMBOL,o as SNAPSHOT_VERSION,b as createDagCborCodec,c as createDagCborZstdCodec,f as decodeEnvelope,q as diffForWAL,e as encodeEnvelope,i as explainPath,m as graphProfile,r as reachable,g as registerBuiltinCodecs,h as replayWAL,l as sizeof,t as validateGraphObservability,s as watchTopologyTree};
1
+ import{a as s,b as t}from"../chunk-5TEFC2ZX.js";import"../chunk-3G5U5QNE.js";import"../chunk-C72GO4IZ.js";import{b as i,c as j,d as k,e as l,f as m,g as n,h as o,i as p,j as q,k as r}from"../chunk-POXANAJ6.js";import"../chunk-SGS4OJGS.js";import"../chunk-ESMPEKEV.js";import"../chunk-L77I47VU.js";import"../chunk-35JTVPOX.js";import{a,b,c,d,e,f,g,h}from"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{d as ENVELOPE_VERSION,n as GRAPH_META_SEGMENT,p as Graph,a as JsonCodec,j as SIZEOF_OVERHEAD,k as SIZEOF_SYMBOL,o as SNAPSHOT_VERSION,b as createDagCborCodec,c as createDagCborZstdCodec,f as decodeEnvelope,q as diffForWAL,e as encodeEnvelope,i as explainPath,m as graphProfile,r as reachable,g as registerBuiltinCodecs,h as replayWAL,l as sizeof,t as validateGraphObservability,s as watchTopologyTree};