zen-code 4.9.0 → 4.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +187 -144
- package/dist/{chunk-4nsg4vcd.js → chunk-0pss3s5r.js} +1 -1
- package/dist/chunk-0sxrk9sx.js +1 -0
- package/dist/{chunk-gcm4jp0d.js → chunk-0zk0m93z.js} +1 -1
- package/dist/chunk-178yjjsx.js +1 -0
- package/dist/chunk-1p9xzvpt.js +3 -0
- package/dist/{chunk-hfve7nf5.js → chunk-2eh0sv3s.js} +2 -2
- package/dist/chunk-43xrz4wp.js +2 -0
- package/dist/chunk-48ce2wt0.js +1 -0
- package/dist/chunk-48vkm1yn.js +5 -0
- package/dist/{chunk-va71tsw3.js → chunk-55nx49pj.js} +2 -2
- package/dist/chunk-578m1dhj.js +2 -0
- package/dist/{chunk-trjpzw1n.js → chunk-5dsevrtz.js} +3 -3
- package/dist/{chunk-1y82m5kn.js → chunk-62zh99t6.js} +4 -4
- package/dist/chunk-66890qd3.js +2 -0
- package/dist/{chunk-9k5d9vf1.js → chunk-6nfpdtn6.js} +1 -1
- package/dist/chunk-738m8242.js +53 -0
- package/dist/{chunk-98f6hg43.js → chunk-8f2zh5h6.js} +2 -2
- package/dist/{chunk-jbf8ve63.js → chunk-8ty2zfve.js} +1 -1
- package/dist/{chunk-9dahn9h7.js → chunk-94jawhw7.js} +1 -1
- package/dist/chunk-98wjxsna.js +79 -0
- package/dist/chunk-9b7nj74j.js +1 -0
- package/dist/{chunk-wn43r152.js → chunk-9k64296h.js} +1 -1
- package/dist/chunk-9x562s6p.js +1 -0
- package/dist/chunk-a90fm6gz.js +278 -0
- package/dist/chunk-ac5t2ywn.js +100 -0
- package/dist/chunk-ad2hbq42.js +1 -0
- package/dist/chunk-afhxxkmv.js +16 -0
- package/dist/chunk-b4vvgbav.js +1 -0
- package/dist/{chunk-g7pm00z7.js → chunk-b9pcntkv.js} +9 -9
- package/dist/chunk-c7y5efa0.js +1 -0
- package/dist/chunk-cbjnwrt7.js +2 -0
- package/dist/{chunk-g377vrpj.js → chunk-ce53j63y.js} +1 -1
- package/dist/{chunk-kba8akjs.js → chunk-dcs1r9as.js} +1 -1
- package/dist/chunk-dcwnpdtk.js +9 -0
- package/dist/{chunk-b52b0t16.js → chunk-dxec2q4t.js} +1 -1
- package/dist/{chunk-13nyfrmm.js → chunk-e3tyc24s.js} +1 -1
- package/dist/{chunk-ep2es95e.js → chunk-e8hp8d68.js} +3 -3
- package/dist/chunk-fkrydbn4.js +18 -0
- package/dist/chunk-frhhpxxy.js +2 -0
- package/dist/{chunk-ns6tjjkq.js → chunk-fw3nrwpf.js} +1 -1
- package/dist/chunk-gyhxdxb4.js +1 -0
- package/dist/chunk-h1enhch1.js +2 -0
- package/dist/chunk-hcnx1j2z.js +1 -0
- package/dist/chunk-hfegb4pr.js +2 -0
- package/dist/{chunk-mmq834zt.js → chunk-hfypkhky.js} +1 -1
- package/dist/chunk-hmemx3cw.js +2 -0
- package/dist/chunk-hra0748z.js +2 -0
- package/dist/chunk-hsev32dg.js +4 -0
- package/dist/chunk-hyf24r36.js +2 -0
- package/dist/chunk-jb4yt88g.js +6 -0
- package/dist/chunk-jjcmm167.js +1 -0
- package/dist/chunk-jrepjpft.js +2 -0
- package/dist/chunk-k38fjqj7.js +140 -0
- package/dist/{chunk-cs73xbzz.js → chunk-kym9tb01.js} +1 -1
- package/dist/chunk-mt1g6g89.js +1 -0
- package/dist/chunk-p0vzbr7s.js +585 -0
- package/dist/{chunk-heasksrr.js → chunk-pndhbee8.js} +2 -2
- package/dist/{chunk-cggjws6a.js → chunk-pwrscdkf.js} +1 -1
- package/dist/{chunk-j7a40ww9.js → chunk-r019959h.js} +2 -2
- package/dist/chunk-r10bn684.js +1 -0
- package/dist/{chunk-30sq2w0d.js → chunk-r3pe49q4.js} +3 -3
- package/dist/chunk-r4tq44hr.js +1 -0
- package/dist/chunk-rjrnaka2.js +1 -0
- package/dist/{chunk-8g2zdcy0.js → chunk-rt5mpgbg.js} +2 -2
- package/dist/chunk-rztre6k0.js +1 -0
- package/dist/chunk-s77qbhtz.js +3 -0
- package/dist/chunk-t7rwtc17.js +1 -0
- package/dist/chunk-v8g52kan.js +1 -0
- package/dist/chunk-vd6c87cm.js +2 -0
- package/dist/{chunk-rncpxz1b.js → chunk-vfwbx331.js} +2 -2
- package/dist/chunk-vh9zd1v3.js +5 -0
- package/dist/chunk-w2hbsa9j.js +86 -0
- package/dist/chunk-wabmqprd.js +184 -0
- package/dist/chunk-wpy5r9ma.js +40 -0
- package/dist/chunk-x552nspp.js +6 -0
- package/dist/chunk-x90r4sje.js +1 -0
- package/dist/chunk-yndex7hs.js +1 -0
- package/dist/{chunk-7kdvr78m.js → chunk-yqwxbcc7.js} +4 -4
- package/dist/chunk-z8n7y37k.js +1 -0
- package/dist/chunk-zr7sx9hd.js +1 -0
- package/dist/chunk-zxqmghzf.js +1 -0
- package/dist/cli.js +1 -1
- package/dist/nonInteractive.js +2 -2
- package/dist/zen-keyboard.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-02vv5584.js +0 -1
- package/dist/chunk-1edvf7b5.js +0 -1
- package/dist/chunk-1rmnbdef.js +0 -1
- package/dist/chunk-1ttywx0y.js +0 -6
- package/dist/chunk-32ase1cw.js +0 -2
- package/dist/chunk-3490ntd8.js +0 -1
- package/dist/chunk-3pcybja5.js +0 -7
- package/dist/chunk-5rr85f28.js +0 -1
- package/dist/chunk-5x8nxw0t.js +0 -137
- package/dist/chunk-6rfc36jg.js +0 -1
- package/dist/chunk-76h8pe7x.js +0 -2
- package/dist/chunk-8z38ybz7.js +0 -1
- package/dist/chunk-b8dxq9rq.js +0 -1
- package/dist/chunk-cjqarwdn.js +0 -1
- package/dist/chunk-cyexd09c.js +0 -2
- package/dist/chunk-f8ewggk1.js +0 -1
- package/dist/chunk-j9aysaeb.js +0 -1
- package/dist/chunk-jfhc5c0d.js +0 -1
- package/dist/chunk-jxsfzfac.js +0 -2
- package/dist/chunk-m76ya904.js +0 -1
- package/dist/chunk-mjzeawnq.js +0 -6
- package/dist/chunk-nwy6n6b6.js +0 -274
- package/dist/chunk-qd305hg1.js +0 -1
- package/dist/chunk-qez6ejd4.js +0 -1
- package/dist/chunk-r2h3x9zv.js +0 -2
- package/dist/chunk-rz3b356n.js +0 -1
- package/dist/chunk-xhnvpygg.js +0 -2
- package/dist/chunk-xkz5z0zn.js +0 -1
- package/dist/chunk-zwxjkwqd.js +0 -26
- package/dist/chunk-zz32kgt2.js +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{$g as I$,bh as F$,ch as rQ,eh as F8,rh as U0,sh as fQ,uh as X1,vh as m$,wh as s$,yh as X8,zh as t$}from"./chunk-ac5t2ywn.js";import{ri as sQ}from"./chunk-cbjnwrt7.js";import{$i as kQ,$j as $1,Bj as W8,Bk as H1,Hj as L8,Kk as U8,Lk as Z$,Rj as Q1,Tk as XQ,Uk as q$,Vj as J$,Vk as V1,Wk as V8,Yj as i8,Zk as U1,aj as d8,ij as e$,jk as QQ,lk as Y1,mk as UQ,nl as r8,ok as cQ,pl as YQ,ql as S$,tk as g8,tl as Z0,yl as SQ}from"./chunk-w2hbsa9j.js";import{El as Y$}from"./chunk-rztre6k0.js";var xQ=class extends Error{lc_error_code;constructor(Q,$){let J=Q??"";if($?.lc_error_code)J=`${J}
|
|
2
|
+
|
|
3
|
+
Troubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${$.lc_error_code}/
|
|
4
|
+
`;super(J);this.lc_error_code=$?.lc_error_code}},f0=class extends xQ{get is_bubble_up(){return!0}},k0=class extends xQ{constructor(Q,$){super(Q,$);this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}},uQ=class extends xQ{constructor(Q,$){super(Q,$);this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}},AQ=class extends f0{interrupts;constructor(Q,$){super(JSON.stringify(Q,null,2),$);this.name="GraphInterrupt",this.interrupts=Q??[]}static get unminifiable_name(){return"GraphInterrupt"}},D0=class extends AQ{constructor(Q,$){super([{value:Q}],$);this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}},K0=class extends f0{command;constructor(Q){super();this.name="ParentCommand",this.command=Q}static get unminifiable_name(){return"ParentCommand"}};function g0(Q){return Q!==void 0&&Q.name===K0.unminifiable_name}function dQ(Q){return Q!==void 0&&Q.is_bubble_up===!0}function OQ(Q){return Q!==void 0&&[AQ.unminifiable_name,D0.unminifiable_name].includes(Q.name)}var M0=class extends xQ{constructor(Q,$){super(Q,$);this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}},E=class extends xQ{constructor(Q,$){super(Q,$);this.name="EmptyChannelError"}static get unminifiable_name(){return"EmptyChannelError"}},b=class extends xQ{constructor(Q,$){super(Q,$);this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}};var m0=class extends xQ{constructor(Q,$){super(Q,$);this.name="UnreachableNodeError"}static get unminifiable_name(){return"UnreachableNodeError"}};var Y0=class extends xQ{constructor(Q,$){super(Q,$);this.name="StateGraphInputError",this.message="Invalid StateGraph input. Make sure to pass a valid StateDefinition, Annotation.Root, or Zod schema."}static get unminifiable_name(){return"StateGraphInputError"}};function A8(Q){return Q!=null&&Q.lg_is_channel===!0}var p=class{ValueType;UpdateType;lg_is_channel=!0;consume(){return!1}finish(){return!1}isAvailable(){try{return this.get(),!0}catch(Q){if(Q.name===E.unminifiable_name)return!1;throw Q}}equals(Q){return this===Q}},x8=Symbol.for("LG_IS_ONLY_BASE_CHANNEL");function x0(Q){if(Q[x8]===!0)return Q;let $={};for(let J in Q){if(!Object.prototype.hasOwnProperty.call(Q,J))continue;let Z=Q[J];if(A8(Z))$[J]=Z}return Object.assign($,{[x8]:!0}),$}function pQ(Q,$){let J=x0(Q),Z={};for(let q in J){if(!Object.prototype.hasOwnProperty.call(J,q))continue;let z=$.channel_values[q];Z[q]=J[q].fromCheckpoint(z)}return Object.assign(Z,{[x8]:!0}),Z}function LQ(Q,$,J,Z){let q;if($===void 0)q=Q.channel_values;else{q={};for(let z in $){if(!Object.prototype.hasOwnProperty.call($,z))continue;try{q[z]=$[z].checkpoint()}catch(Y){if(Y.name===E.unminifiable_name);else throw Y}}}return{v:4,id:Z?.id??F$(J),ts:new Date().toISOString(),channel_values:q,channel_versions:Q.channel_versions,versions_seen:Q.versions_seen}}var P1=(Q)=>{return Q!=null&&Q.lc_graph_name==="BinaryOperatorAggregate"},wQ=class Q extends p{lc_graph_name="BinaryOperatorAggregate";value;operator;initialValueFactory;constructor($,J){super();this.operator=$,this.initialValueFactory=J,this.value=J?.()}fromCheckpoint($){let J=new Q(this.operator,this.initialValueFactory);if(typeof $<"u")J.value=$;return J}update($){let J=$;if(!J.length)return!1;if(this.value===void 0)[this.value]=J,J=J.slice(1);for(let Z of J)if(this.value!==void 0)this.value=this.operator(this.value,Z);return!0}get(){if(this.value===void 0)throw new E;return this.value}checkpoint(){if(this.value===void 0)throw new E;return this.value}isAvailable(){return this.value!==void 0}equals($){if(this===$)return!0;if(!P1($))return!1;return this.operator===$.operator}};var jQ=class Q extends p{lc_graph_name="LastValue";value=[];constructor($){super();if(this.initialValueFactory=$,$)this.value=[$()]}fromCheckpoint($){let J=new Q(this.initialValueFactory);if(typeof $<"u")J.value=[$];return J}update($){if($.length===0)return!1;if($.length!==1)throw new b("LastValue can only receive one value per step.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this.value=[$[$.length-1]],!0}get(){if(this.value.length===0)throw new E;return this.value[0]}checkpoint(){if(this.value.length===0)throw new E;return this.value[0]}isAvailable(){return this.value.length!==0}},O8=class Q extends p{lc_graph_name="LastValueAfterFinish";value=[];finished=!1;fromCheckpoint($){let J=new Q;if(typeof $<"u"){let[Z,q]=$;J.value=[Z],J.finished=q}return J}update($){if($.length===0)return!1;return this.finished=!1,this.value=[$[$.length-1]],!0}get(){if(this.value.length===0||!this.finished)throw new E;return this.value[0]}checkpoint(){if(this.value.length===0)return;return[this.value[0],this.finished]}consume(){if(this.finished)return this.finished=!1,this.value=[],!0;return!1}finish(){if(!this.finished&&this.value.length>0)return this.finished=!0,!0;return!1}isAvailable(){return this.value.length!==0&&this.finished}};var A0=class{lc_graph_name="AnnotationRoot";spec;constructor(Q){this.spec=Q}static isInstance(Q){return typeof Q==="object"&&Q!==null&&"lc_graph_name"in Q&&Q.lc_graph_name==="AnnotationRoot"}},aQ=function(Q){if(Q)return h0(Q);else return new jQ};aQ.Root=(Q)=>new A0(Q);function h0(Q){if(typeof Q==="object"&&Q&&"reducer"in Q&&Q.reducer)return new wQ(Q.reducer,Q.default);if(typeof Q==="object"&&Q&&"value"in Q&&Q.value)return new wQ(Q.value,Q.default);return new jQ}var R="__start__",A="__end__",PQ="__input__",W$="__copy__",l="__error__",u0="__pregel_ns_writes",HQ="__pregel_send",d0="__pregel_call",RQ="__pregel_read",g="__pregel_checkpointer",yQ="__pregel_resuming",X0="__pregel_task_id",w0="__pregel_stream";var F0="__pregel_resume_map",JQ="__pregel_scratchpad",P0="__pregel_previous",L$="__pregel_durability",w8="checkpoint_id",FQ="checkpoint_ns",j$="__pregel_node_finished",ZQ="checkpoint_map",P8="__pregel_abort_signals",S="__interrupt__",o="__resume__",p0="__no_writes__",VQ="__return__",eQ="__previous__",y="langsmith:hidden",H$="langsmith:nostream",R8="__self__",c="__pregel_tasks",r="__pregel_push",R0="__pregel_pull",n="00000000-0000-0000-0000-000000000000",V$=["langsmith:hidden","__input__","__interrupt__","__resume__","__error__","__no_writes__","__pregel_send","__pregel_read","__pregel_checkpointer","__pregel_durability","__pregel_stream","__pregel_resuming","__pregel_task_id","__pregel_call","__pregel_resume_value","__pregel_scratchpad","__pregel_previous","checkpoint_map","checkpoint_ns","checkpoint_id"],k="|",e=":",B$=Symbol.for("langgraph.command"),U$=class{[B$];constructor(Q){this[B$]=Q}};function l0(Q){let $=Q;return $!==null&&$!==void 0&&typeof $.node==="string"&&$.args!==void 0}var lQ=class{lg_name="Send";node;args;constructor(Q,$){this.node=Q,this.args=O0($)}toJSON(){return{lg_name:this.lg_name,node:this.node,args:this.args}}};function d(Q){return Q instanceof lQ}function B0(Q){if(!Q||typeof Q!=="object")return!1;if(!("__interrupt__"in Q))return!1;return Array.isArray(Q.__interrupt__)}var a=class extends U${lg_name="Command";lc_direct_tool_output=!0;graph;update;resume;goto=[];static PARENT="__parent__";constructor(Q){super(Q);if(this.resume=Q.resume,this.graph=Q.graph,this.update=Q.update,Q.goto)this.goto=Array.isArray(Q.goto)?O0(Q.goto):[O0(Q.goto)]}_updateAsTuples(){if(this.update&&typeof this.update==="object"&&!Array.isArray(this.update))return Object.entries(this.update);else if(Array.isArray(this.update)&&this.update.every((Q)=>Array.isArray(Q)&&Q.length===2&&typeof Q[0]==="string"))return this.update;else return[["__root__",this.update]]}toJSON(){let Q;if(typeof this.goto==="string")Q=this.goto;else if(d(this.goto))Q=this.goto.toJSON();else Q=this.goto?.map(($)=>{if(typeof $==="string")return $;else return $.toJSON()});return{lg_name:this.lg_name,update:this.update,resume:this.resume,goto:Q}}};function u(Q){if(typeof Q!=="object")return!1;if(Q===null||Q===void 0)return!1;if("lg_name"in Q&&Q.lg_name==="Command")return!0;return!1}function O0(Q,$=new Map){if(Q!==void 0&&Q!==null&&typeof Q==="object"){if($.has(Q))return $.get(Q);let J;if(Array.isArray(Q))J=[],$.set(Q,J),Q.forEach((Z,q)=>{J[q]=O0(Z,$)});else if(u(Q)&&!(Q instanceof a))J=new a(Q),$.set(Q,J);else if(l0(Q)&&!(Q instanceof lQ))J=new lQ(Q.node,Q.args),$.set(Q,J);else if(u(Q)||d(Q))J=Q,$.set(Q,J);else if("lc_serializable"in Q&&Q.lc_serializable)J=Q,$.set(Q,J);else{J={},$.set(Q,J);for(let[Z,q]of Object.entries(Q))J[Z]=O0(q,$)}return J}return Q}var U=(Q)=>BigInt(Q),v=(Q,$=0)=>new DataView(Q.buffer,Q.byteOffset+$,Q.byteLength-$),M$=U("0x9E3779B1"),x$=U("0x85EBCA77"),R1=U("0xC2B2AE3D"),oQ=U("0x9E3779B185EBCA87"),Q0=U("0xC2B2AE3D27D4EB4F"),A$=U("0x165667B19E3779F9"),S8=U("0x85EBCA77C2B2AE63"),T1=U("0x27D4EB2F165667C5"),b1=U("0x165667919E3779F9"),S1=U("0x9FB21C651E98DF25"),I1=(Q)=>{let $=Q.length;if($%2!==0)throw Error("String should have an even number of characters");let J=$/2,Z=new Uint8Array(J),q=0,z=0;while(z<J){let Y=Q.slice(q,q+=2);Z[z]=Number.parseInt(Y,16),z+=1}return v(Z)},TQ=I1("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),W0=(U(1)<<U(128))-U(1),P=(U(1)<<U(64))-U(1),i0=(U(1)<<U(32))-U(1);function L0(Q){if(!Q)throw Error("Assert failed")}function _1(Q){let $=new DataView(new ArrayBuffer(8));return $.setBigUint64(0,Q,!0),$.getBigUint64(0,!1)}function N1(Q){let $=Q;return $=($&U(65535))<<U(16)|($&U(4294901760))>>U(16),$=($&U(16711935))<<U(8)|($&U(4278255360))>>U(8),$}function E1(Q,$){return(Q&i0)*($&i0)&P}function y1(Q,$){return(Q<<$|Q>>U(32)-$)&i0}function O$(Q,$,J){for(let Z=0;Z<8;Z+=1){let q=$.getBigUint64(Z*8,!0),z=q^J.getBigUint64(Z*8,!0);Q[Z^1]+=q,Q[Z]+=E1(z,z>>U(32))}return Q}function G$(Q,$,J,Z){for(let q=0;q<Z;q+=1)O$(Q,v($,q*64),v(J,q*8));return Q}function v1(Q,$){for(let J=0;J<8;J+=1){let Z=$.getBigUint64(J*8,!0),q=Q[J];q=T8(q,U(47)),q^=Z,q*=M$,Q[J]=q&P}return Q}function o0(Q,$){return w$(Q[0]^$.getBigUint64(0,!0),Q[1]^$.getBigUint64(8,!0))}function D$(Q,$,J){let Z=J;return Z+=o0(Q.slice(0),v($,0)),Z+=o0(Q.slice(2),v($,16)),Z+=o0(Q.slice(4),v($,32)),Z+=o0(Q.slice(6),v($,48)),bQ(Z&P)}function C1(Q,$,J,Z,q){let z=Q,Y=Math.floor((J.byteLength-64)/8),X=64*Y,B=Math.floor(($.byteLength-1)/X);for(let F=0;F<B;F+=1)z=G$(z,v($,F*X),J,Y),z=q(z,v(J,J.byteLength-64));{let F=Math.floor(($.byteLength-1-X*B)/64);z=G$(z,v($,B*X),J,F),z=Z(z,v($,$.byteLength-64),v(J,J.byteLength-64-7))}return z}function f1(Q,$){let J=new BigUint64Array([R1,oQ,Q0,A$,S8,x$,T1,M$]);L0(Q.byteLength>128),J=C1(J,Q,$,O$,v1),L0(J.length*8===64);{let Z=D$(J,v($,11),U(Q.byteLength)*oQ&P);return D$(J,v($,$.byteLength-64-11),~(U(Q.byteLength)*Q0)&P)<<U(64)|Z}}function w$(Q,$){let J=Q*$&W0;return J&P^J>>U(64)}function K$(Q,$,J){return w$((Q.getBigUint64(0,!0)^$.getBigUint64(0,!0)+J)&P,(Q.getBigUint64(8,!0)^$.getBigUint64(8,!0)-J)&P)}function c0(Q,$,J,Z,q){let z=Q&P,Y=Q>>U(64)&P;return z+=K$($,Z,q),z^=J.getBigUint64(0,!0)+J.getBigUint64(8,!0),z&=P,Y+=K$(J,v(Z,16),q),Y^=$.getBigUint64(0,!0)+$.getBigUint64(8,!0),Y&=P,Y<<U(64)|z}function bQ(Q){let $=Q;return $^=$>>U(37),$*=b1,$&=P,$^=$>>U(32),$}function r0(Q){let $=Q;return $^=$>>U(33),$*=Q0,$&=P,$^=$>>U(29),$*=A$,$&=P,$^=$>>U(32),$}function k1(Q,$,J){let Z=Q.byteLength;L0(Z>0&&Z<=3);let q=U(Q.getUint8(Z-1))|U(Z<<8)|U(Q.getUint8(0)<<16)|U(Q.getUint8(Z>>1)<<24),z=(q^(U($.getUint32(0,!0))^U($.getUint32(4,!0)))+J)&P,Y=(U($.getUint32(8,!0))^U($.getUint32(12,!0)))-J;return(r0((y1(N1(q),U(13))^Y)&P)&P)<<U(64)|r0(z)}function T8(Q,$){return Q^Q>>$}function g1(Q,$,J){let Z=Q.byteLength;L0(Z>=4&&Z<=8);{let q=Q.getUint32(0,!0),z=Q.getUint32(Z-4,!0),Y=((U(q)|U(z)<<U(32))^($.getBigUint64(16,!0)^$.getBigUint64(24,!0))+J&P)*(oQ+(U(Z)<<U(2)))&W0;return Y+=(Y&P)<<U(65),Y&=W0,Y^=Y>>U(67),T8(T8(Y&P,U(35))*S1&P,U(28))|bQ(Y>>U(64))<<U(64)}}function m1(Q,$,J){let Z=Q.byteLength;L0(Z>=9&&Z<=16);{let q=($.getBigUint64(32,!0)^$.getBigUint64(40,!0))+J&P,z=($.getBigUint64(48,!0)^$.getBigUint64(56,!0))-J&P,Y=Q.getBigUint64(0,!0),X=Q.getBigUint64(Z-8,!0),B=(Y^X^q)*oQ,F=(B&P)+(U(Z-1)<<U(54));B=B&(W0^P)|F,X^=z,B+=X+(X&i0)*(x$-U(1))<<U(64),B&=W0,B^=_1(B>>U(64));let W=(B&P)*Q0;return W+=(B>>U(64))*Q0<<U(64),W&=W0,bQ(W&P)|bQ(W>>U(64))<<U(64)}}function h1(Q,$){let J=Q.byteLength;if(L0(J<=16),J>8)return m1(Q,TQ,$);if(J>=4)return g1(Q,TQ,$);if(J>0)return k1(Q,TQ,$);return r0($^TQ.getBigUint64(64,!0)^TQ.getBigUint64(72,!0))|r0($^TQ.getBigUint64(80,!0)^TQ.getBigUint64(88,!0))<<U(64)}function b8(Q){return~Q+U(1)&P}function u1(Q,$,J){let Z=U(Q.byteLength)*oQ&P,q=U(Q.byteLength-1)/U(32);while(q>=0){let X=Number(q);Z=c0(Z,v(Q,16*X),v(Q,Q.byteLength-16*(X+1)),v($,32*X),J),q-=U(1)}let z=Z+(Z>>U(64))&P;z=bQ(z);let Y=(Z&P)*oQ+(Z>>U(64))*S8+(U(Q.byteLength)-J&P)*Q0;return Y&=P,Y=b8(bQ(Y)),z|Y<<U(64)}function d1(Q,$,J){let Z=U(Q.byteLength)*oQ&P;for(let Y=32;Y<160;Y+=32)Z=c0(Z,v(Q,Y-32),v(Q,Y-16),v($,Y-32),J);Z=bQ(Z&P)|bQ(Z>>U(64))<<U(64);for(let Y=160;Y<=Q.byteLength;Y+=32)Z=c0(Z,v(Q,Y-32),v(Q,Y-16),v($,3+Y-160),J);Z=c0(Z,v(Q,Q.byteLength-16),v(Q,Q.byteLength-32),v($,103),b8(J));let q=Z+(Z>>U(64))&P;q=bQ(q);let z=(Z&P)*oQ+(Z>>U(64))*S8+(U(Q.byteLength)-J&P)*Q0;return z&=P,z=b8(bQ(z)),q|z<<U(64)}function vQ(Q,$=U(0)){let Z=v(typeof Q==="string"?new TextEncoder().encode(Q):Q),q=Z.byteLength,z=(Y)=>Y.toString(16).padStart(32,"0");if(q<=16)return z(h1(Z,$));if(q<=128)return z(u1(Z,TQ,$));if(q<=240)return z(d1(Z,TQ,$));return z(f1(Z,TQ))}function n0(Q){return/^[0-9a-f]{32}$/.test(Q)}function I8(Q){let $=QQ.getRunnableConfig();if(!$)throw Error("Called interrupt() outside the context of a graph.");let J=$.configurable;if(!J)throw Error("No configurable found in config");if(!J[g])throw new uQ("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let Z=J[JQ];Z.interruptCounter+=1;let q=Z.interruptCounter;if(Z.resume.length>0&&q<Z.resume.length)return J[HQ]?.([[o,Z.resume]]),Z.resume[q];if(Z.nullResume!==void 0){if(Z.resume.length!==q)throw Error(`Resume length mismatch: ${Z.resume.length} !== ${q}`);let Y=Z.consumeNullResume();return Z.resume.push(Y),J[HQ]?.([[o,Z.resume]]),Y}let z=J[FQ]?.split(k);throw new AQ([{id:z?vQ(z.join(k)):void 0,value:Q}])}import{AsyncLocalStorage as p1}from"node:async_hooks";function P$(){QQ.initializeGlobalInstance(new p1)}var l1=["tags","metadata","callbacks","configurable"],o1=["tags","metadata","callbacks","runName","maxConcurrency","recursionLimit","configurable","runId","outputKeys","streamMode","store","writer","interrupt","context","interruptBefore","interruptAfter","checkpointDuring","durability","signal"],c1=25;function T0(...Q){let $={tags:[],metadata:{},callbacks:void 0,recursionLimit:c1,configurable:{}},J=QQ.getRunnableConfig();if(J!==void 0){for(let[Z,q]of Object.entries(J))if(q!==void 0)if(l1.includes(Z)){let z;if(Array.isArray(q))z=[...q];else if(typeof q==="object")if(Z==="callbacks"&&"copy"in q&&typeof q.copy==="function")z=q.copy();else z={...q};else z=q;$[Z]=z}else $[Z]=q}for(let Z of Q){if(Z===void 0)continue;for(let[q,z]of Object.entries(Z))if(z!==void 0&&o1.includes(q))$[q]=z}for(let[Z,q]of Object.entries($.configurable))if($.metadata=$.metadata??{},!Z.startsWith("__")&&(typeof q==="string"||typeof q==="number"||typeof q==="boolean")&&!(Z in $.metadata))$.metadata[Z]=q;return $}function _8(){return QQ.getRunnableConfig()}function i1(Q){let $=Q??QQ.getRunnableConfig();if($===void 0)throw Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getCurrentTaskInput` in such environment, pass the `config` from the node function directly."].join(`
|
|
5
|
+
`));if($.configurable?.[JQ]?.currentTaskInput===void 0)throw Error("BUG: internal scratchpad not initialized.");return $.configurable[JQ].currentTaskInput}function s0(Q){return Q.split(k).filter(($)=>!$.match(/^\d+$/)).map(($)=>$.split(e)[0]).join(k)}function R$(Q){let $=Q.split(k);while($.length>1&&$[$.length-1].match(/^\d+$/))$.pop();return $.slice(0,-1).join(k)}var s=class extends YQ{lc_namespace=["langgraph"];func;tags;config;trace=!0;recurse=!0;constructor(Q){super();this.name=Q.name??Q.func.name,this.func=Q.func,this.config=Q.tags?{tags:Q.tags}:void 0,this.trace=Q.trace??this.trace,this.recurse=Q.recurse??this.recurse}async _tracedInvoke(Q,$,J){return new Promise((Z,q)=>{let z=cQ($,{callbacks:J?.getChild()});QQ.runWithConfig(z,async()=>{try{Z(await this.func(Q,z))}catch(Y){q(Y)}})})}async invoke(Q,$){let J,Z=T0($),q=UQ(this.config,Z);if(this.trace)J=await this._callWithConfig(this._tracedInvoke,Q,q);else J=await QQ.runWithConfig(q,async()=>this.func(Q,q));if(YQ.isRunnable(J)&&this.recurse)return await QQ.runWithConfig(q,async()=>J.invoke(Q,q));return J}};function*CQ(Q,$){if($===void 0)yield*Q;else for(let J of Q)yield[$,J]}async function GQ(Q){let $=[];for await(let J of await Q)$.push(J);return $}function $0(Q){let $=[];for(let J of Q)$.push(J);return $}function J0(Q,$){if(!Q)return{configurable:$};else if(!("configurable"in Q))return{...Q,configurable:$};else return{...Q,configurable:{...Q.configurable,...$}}}function T$(Q){return Q!=null&&typeof Q==="function"&&Q instanceof Object.getPrototypeOf(async function*(){}).constructor}function b$(Q){return Q!=null&&typeof Q==="function"&&Q instanceof Object.getPrototypeOf(function*(){}).constructor}var _J={[Symbol.for("LG_SKIP_WRITE")]:!0};function r1(Q){return typeof Q==="object"&&Q?.[Symbol.for("LG_SKIP_WRITE")]!==void 0}var qQ={[Symbol.for("LG_PASSTHROUGH")]:!0};function t0(Q){return typeof Q==="object"&&Q?.[Symbol.for("LG_PASSTHROUGH")]!==void 0}var N8=Symbol("IS_WRITER"),m=class Q extends s{writes;constructor($,J){let Z=`ChannelWrite<${$.map((q)=>{if(d(q))return q.node;else if("channel"in q)return q.channel;return"..."}).join(",")}>`;super({writes:$,name:Z,tags:J,func:async(q,z)=>{return this._write(q,z??{})}});this.writes=$}async _write($,J){let Z=this.writes.map((q)=>{if(E8(q)&&t0(q.value))return{mapper:q.mapper,value:$};else if(a0(q)&&t0(q.value))return{channel:q.channel,value:$,skipNone:q.skipNone,mapper:q.mapper};else return q});return await Q.doWrite(J,Z),$}static async doWrite($,J){for(let z of J){if(a0(z)){if(z.channel===c)throw new b("Cannot write to the reserved channel TASKS");if(t0(z.value))throw new b("PASSTHROUGH value must be replaced")}if(E8(z)){if(t0(z.value))throw new b("PASSTHROUGH value must be replaced")}}let Z=[];for(let z of J)if(d(z))Z.push([c,z]);else if(E8(z)){let Y=await z.mapper.invoke(z.value,$);if(Y!=null&&Y.length>0)Z.push(...Y)}else if(a0(z)){let Y=z.mapper!==void 0?await z.mapper.invoke(z.value,$):z.value;if(r1(Y))continue;if(z.skipNone&&Y===void 0)continue;Z.push([z.channel,Y])}else throw Error(`Invalid write entry: ${JSON.stringify(z)}`);let q=$.configurable?.[HQ];q(Z)}static isWriter($){return $ instanceof Q||N8 in $&&!!$[N8]}static registerWriter($){return Object.defineProperty($,N8,{value:!0})}};function a0(Q){return Q!==void 0&&typeof Q.channel==="string"}function E8(Q){return Q!==void 0&&!a0(Q)&&YQ.isRunnable(Q.mapper)}var _$=class Q extends s{lc_graph_name="ChannelRead";channel;fresh=!1;mapper;constructor($,J,Z=!1){super({func:(q,z)=>Q.doRead(z,this.channel,this.fresh,this.mapper)});this.fresh=Z,this.mapper=J,this.channel=$,this.name=Array.isArray($)?`ChannelRead<${$.join(",")}>`:`ChannelRead<${$}>`}static doRead($,J,Z,q){let z=$.configurable?.[RQ];if(!z)throw Error("Runnable is not configured with a read function. Make sure to call in the context of a Pregel process");if(q)return q(z(J,Z));else return z(J,Z)}},j0=new I$,DQ=class Q extends S${lc_graph_name="PregelNode";channels;triggers=[];mapper;writers=[];bound=j0;kwargs={};metadata={};tags=[];retryPolicy;cachePolicy;subgraphs;ends;constructor($){let{channels:J,triggers:Z,mapper:q,writers:z,bound:Y,kwargs:X,metadata:B,retryPolicy:F,cachePolicy:W,tags:L,subgraphs:H,ends:j}=$,V=[...$.config?.tags?$.config.tags:[],...L??[]];super({...$,bound:$.bound??j0,config:{...$.config?$.config:{},tags:V}});this.channels=J,this.triggers=Z,this.mapper=q,this.writers=z??this.writers,this.bound=Y??this.bound,this.kwargs=X??this.kwargs,this.metadata=B??this.metadata,this.tags=V,this.retryPolicy=F,this.cachePolicy=W,this.subgraphs=H,this.ends=j}getWriters(){let $=[...this.writers];while($.length>1&&$[$.length-1]instanceof m&&$[$.length-2]instanceof m){let J=$.slice(-2),Z=J[0].writes.concat(J[1].writes);$[$.length-2]=new m(Z,J[0].config?.tags),$.pop()}return $}getNode(){let $=this.getWriters();if(this.bound===j0&&$.length===0)return;else if(this.bound===j0&&$.length===1)return $[0];else if(this.bound===j0)return new Z0({first:$[0],middle:$.slice(1,$.length-1),last:$[$.length-1],omitSequenceTags:!0});else if($.length>0)return new Z0({first:this.bound,middle:$.slice(0,$.length-1),last:$[$.length-1],omitSequenceTags:!0});else return this.bound}join($){if(!Array.isArray($))throw Error("channels must be a list");if(typeof this.channels!=="object")throw Error("all channels must be named when using .join()");return new Q({channels:{...this.channels,...Object.fromEntries($.map((J)=>[J,J]))},triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound,kwargs:this.kwargs,config:this.config,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy})}pipe($){if(m.isWriter($))return new Q({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:[...this.writers,$],bound:this.bound,config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy});else if(this.bound===j0)return new Q({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:SQ($),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy});else return new Q({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound.pipe($),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy})}};function n1(Q){return"steps"in Q&&Array.isArray(Q.steps)}function b0(Q){return"lg_is_pregel"in Q&&Q.lg_is_pregel===!0}function e0(Q){let $=[Q];for(let J of $)if(b0(J))return J;else if(n1(J))$.push(...J.steps)}function q0(Q,$,J=!0,Z=!1){try{return Q[$].get()}catch(q){if(q.name===E.unminifiable_name){if(Z)return q;else if(J)return null}throw q}}function KQ(Q,$,J=!0){if(Array.isArray($)){let Z={};for(let q of $)try{Z[q]=q0(Q,q,!J)}catch(z){if(z.name===E.unminifiable_name)continue}return Z}else return q0(Q,$)}function*N$(Q,$){if(Q.graph===a.PARENT)throw new b("There is no parent graph.");if(Q.goto){let J;if(Array.isArray(Q.goto))J=Q.goto;else J=[Q.goto];for(let Z of J)if(d(Z))yield[n,c,Z];else if(typeof Z==="string")yield[n,`branch:to:${Z}`,"__start__"];else throw Error(`In Command.send, expected Send or string, got ${typeof Z}`)}if(Q.resume)if(typeof Q.resume==="object"&&Object.keys(Q.resume).length&&Object.keys(Q.resume).every(n0))for(let[J,Z]of Object.entries(Q.resume)){let q=$.filter((z)=>z[0]===J&&z[1]===o).map((z)=>z[2]).slice(0,1)??[];q.push(Z),yield[J,o,q]}else yield[n,o,Q.resume];if(Q.update){if(typeof Q.update!=="object"||!Q.update)throw Error("Expected cmd.update to be a dict mapping channel names to update values");if(Array.isArray(Q.update))for(let[J,Z]of Q.update)yield[n,J,Z];else for(let[J,Z]of Object.entries(Q.update))yield[n,J,Z]}}function*Q8(Q,$){if($!==void 0&&$!==null)if(Array.isArray(Q)&&typeof $==="object"&&!Array.isArray($)){for(let J in $)if(Q.includes(J))yield[J,$[J]]}else if(Array.isArray(Q))throw Error('Input chunk must be an object when "inputChannels" is an array');else yield[Q,$]}function*$8(Q,$,J){if(Array.isArray(Q)){if($===!0||$.find(([Z,q])=>Q.includes(Z)))yield KQ(J,Q)}else if($===!0||$.some(([Z,q])=>Z===Q))yield q0(J,Q)}function*E$(Q,$,J){let Z=$.filter(([X,B])=>{return(X.config===void 0||!X.config.tags?.includes(y))&&B[0][0]!==l&&B[0][0]!==S});if(!Z.length)return;let q;if(Z.some(([X])=>X.writes.some(([B,F])=>B===VQ)))q=Z.flatMap(([X])=>X.writes.filter(([B,F])=>B===VQ).map(([B,F])=>[X.name,F]));else if(!Array.isArray(Q))q=Z.flatMap(([X])=>X.writes.filter(([B,F])=>B===Q).map(([B,F])=>[X.name,F]));else q=Z.flatMap(([X])=>{let{writes:B}=X,F={};for(let[W]of B)if(Q.includes(W))F[W]=(F[W]||0)+1;if(Object.values(F).some((W)=>W>1))return B.filter(([W])=>Q.includes(W)).map(([W,L])=>[X.name,{[W]:L}]);else return[[X.name,Object.fromEntries(B.filter(([W])=>Q.includes(W)))]]});let z={};for(let[X,B]of q){if(!(X in z))z[X]=[];z[X].push(B)}let Y={};for(let X in z)if(z[X].length===1){let[B]=z[X];Y[X]=B}else Y[X]=z[X];if(J)Y.__metadata__={cached:J};yield Y}function J8(Q){let $=typeof Q[R];if($==="number")return 0;if($==="string")return"";for(let J in Q){if(!Object.prototype.hasOwnProperty.call(Q,J))continue;let Z=typeof Q[J];if(Z==="number")return 0;if(Z==="string")return"";break}}function H0(Q,$){if(Object.keys(Q).length>0){let J=J8($);return Object.fromEntries(Object.entries($).filter(([Z,q])=>q>(Q[Z]??J)))}else return $}function y$(Q,$){return Q&&!Array.isArray(Q)&&!(Q instanceof Date)&&typeof Q==="object"?Q:{[$]:Q}}function zQ(Q,$){if(Q===null)return{configurable:$};else if(Q?.configurable===void 0)return{...Q,configurable:$};else return{...Q,configurable:{...Q.configurable,...$}}}function iQ(Q,$){let J=$?.parents??{};if(Object.keys(J).length>0)return zQ(Q,{[ZQ]:{...J,[Q.configurable?.checkpoint_ns??""]:Q.configurable?.checkpoint_id}});else return Q}function V0(...Q){let $=[...new Set(Q.filter(Boolean))];if($.length===0)return{signal:void 0,dispose:void 0};if($.length===1)return{signal:$[0],dispose:void 0};let J=new AbortController,Z=()=>{let z=$.find((Y)=>Y.aborted)?.reason;J.abort(z),$.forEach((Y)=>Y.removeEventListener("abort",Z))};$.forEach((z)=>z.addEventListener("abort",Z,{once:!0}));let q=$.find((z)=>z.aborted);if(q)J.abort(q.reason);return{signal:J.signal,dispose:()=>{$.forEach((z)=>z.removeEventListener("abort",Z))}}}var v$=(Q,$)=>{if(!Q&&!$)return;if(!Q)return $;if(!$)return Q;if(Array.isArray(Q)&&Array.isArray($))return[...Q,...$];if(Array.isArray(Q))return[...Q,$];if(Array.isArray($))return[Q,...$];return[Q,$]};var C$=class{func;name;input;retry;cache;callbacks;__lg_type="call";constructor({func:Q,name:$,input:J,retry:Z,cache:q,callbacks:z}){this.func=Q,this.name=$,this.input=J,this.retry=Z,this.cache=q,this.callbacks=z}};function f$(Q){return typeof Q==="object"&&Q!==null&&"__lg_type"in Q&&Q.__lg_type==="call"}function k$(Q,$){return new Z0({name:Q,first:new s({func:(J)=>$(...J),name:Q,trace:!1,recurse:!1}),last:new m([{channel:VQ,value:qQ}],[y])})}function g$(Q,$){return new s({func:(J,Z)=>{return $(J,Z)},name:Q,trace:!1,recurse:!1})}var h$=(Q)=>{return Q!==void 0?Q+1:1};function s1(Q,$){if($==null)return!1;for(let J of Q)if($[J])return!0;return!1}function t1(Q){let $;for(let J in Q){if(!Object.prototype.hasOwnProperty.call(Q,J))continue;if($==null)$=Q[J];else $=m$($,Q[J])}return $}function I0(Q,$,J){let Z=J8(Q.channel_versions),q=Q.versions_seen[S]??{},z=!1;if((Q.channel_versions[R]??Z)>(q[R]??Z))z=!0;else for(let X in Q.channel_versions){if(!Object.prototype.hasOwnProperty.call(Q.channel_versions,X))continue;if(Q.channel_versions[X]>(q[X]??Z)){z=!0;break}}let Y=J.some((X)=>$==="*"?!X.config?.tags?.includes(y):$.includes(X.name));return z&&Y}function S0(Q,$,J,Z,q=!1){let z=new Set;if(!Array.isArray(Z)){for(let[X]of J.writes)if(X===Z){z=new Set([X]);break}z=z||new Set}else z=new Set(Z.filter((X)=>J.writes.some(([B,F])=>B===X)));let Y;if(q&&z.size>0){let X=Object.fromEntries(Object.entries($).filter(([W,L])=>z.has(W))),B=LQ(Q,X,-1),F=pQ(X,B);$Q(fQ(B),F,[J],void 0,void 0),Y=KQ({...$,...F},Z)}else Y=KQ($,Z);return Y}function y8(Q,$,J){for(let[Z,q]of J)if([r,c].includes(Z)&&q!=null){if(!d(q))throw new b(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(q)}`);if(!(q.node in $))throw new b(`Invalid node name "${q.node}" in Send packet`)}Q(J)}var a1=new Set([p0,r,o,S,VQ,l]);function $Q(Q,$,J,Z,q){J.sort((H,j)=>{let V=H.path?.slice(0,3)||[],G=j.path?.slice(0,3)||[];for(let M=0;M<Math.min(V.length,G.length);M+=1){if(V[M]<G[M])return-1;if(V[M]>G[M])return 1}return V.length-G.length});let z=J.some((H)=>H.triggers.length>0),Y=x0($);for(let H of J){Q.versions_seen[H.name]??={};for(let j of H.triggers)if(j in Q.channel_versions)Q.versions_seen[H.name][j]=Q.channel_versions[j]}let X=t1(Q.channel_versions),B=new Set(J.flatMap((H)=>H.triggers).filter((H)=>!V$.includes(H))),F=!1;for(let H of B)if(H in Y&&Y[H].consume()){if(Z!==void 0)Q.channel_versions[H]=Z(X),F=!0}let W={};for(let H of J)for(let[j,V]of H.writes)if(a1.has(j));else if(j in Y)W[j]??=[],W[j].push(V);if(X!=null&&Z!=null)X=F?Z(X):X;let L=new Set;for(let[H,j]of Object.entries(W))if(H in Y){let V=Y[H],G;try{G=V.update(j)}catch(M){if(M.name===b.unminifiable_name){let O=new b(`Invalid update for channel "${H}" with values ${JSON.stringify(j)}: ${M.message}`);throw O.lc_error_code=M.lc_error_code,O}else throw M}if(G&&Z!==void 0){if(Q.channel_versions[H]=Z(X),V.isAvailable())L.add(H)}}if(z)for(let H in Y){if(!Object.prototype.hasOwnProperty.call(Y,H))continue;let j=Y[H];if(j.isAvailable()&&!L.has(H)){if(j.update([])&&Z!==void 0){if(Q.channel_versions[H]=Z(X),j.isAvailable())L.add(H)}}}if(z&&!s1(L,q))for(let H in Y){if(!Object.prototype.hasOwnProperty.call(Y,H))continue;let j=Y[H];if(j.finish()&&Z!==void 0){if(Q.channel_versions[H]=Z(X),j.isAvailable())L.add(H)}}return L}function*e1(Q,$,J){if(J.updatedChannels!=null&&J.triggerToNodes!=null){let Z=new Set;for(let q of J.updatedChannels){let z=J.triggerToNodes[q];for(let Y of z??[])Z.add(Y)}yield*[...Z].sort();return}if((()=>{for(let Z in Q.channel_versions)if(Q.channel_versions[Z]!==null)return!1;return!0})())return;for(let Z in $){if(!Object.prototype.hasOwnProperty.call($,Z))continue;yield Z}}function nQ(Q,$,J,Z,q,z,Y){let X={},B=Z[c];if(B?.isAvailable()){let F=B.get().length;for(let W=0;W<F;W+=1){let L=Z8([r,W],Q,$,J,Z,q,z,Y);if(L!==void 0)X[L.id]=L}}for(let F of e1(Q,J,Y)){let W=Z8([R0,F],Q,$,J,Z,q,z,Y);if(W!==void 0)X[W.id]=W}return X}function Z8(Q,$,J,Z,q,z,Y,X){let{step:B,checkpointer:F,manager:W}=X,L=z.configurable??{},H=L.checkpoint_ns??"";if(Q[0]===r&&f$(Q[Q.length-1])){let j=Q[Q.length-1],V=k$(j.name,j.func),G=[r],M=H===""?j.name:`${H}${k}${j.name}`,O=rQ(JSON.stringify([M,B.toString(),j.name,r,Q[1],Q[2]]),$.id),I=`${M}${e}${O}`,w=[...Q.slice(0,3),!0],N={langgraph_step:B,langgraph_node:j.name,langgraph_triggers:G,langgraph_path:w,langgraph_checkpoint_ns:I};if(Y){let _=[];return{name:j.name,input:j.input,proc:V,writes:_,config:cQ(UQ(z,{metadata:N,store:X.store??z.store}),{runName:j.name,callbacks:W?.getChild(`graph:step:${B}`),configurable:{[X0]:O,[HQ]:(f)=>y8((D)=>_.push(...D),Z,f),[RQ]:(f,D=!1)=>S0($,q,{name:j.name,writes:_,triggers:G,path:w},f,D),[g]:F??L[g],[ZQ]:{...L[ZQ],[H]:$.id},[JQ]:v8({pendingWrites:J??[],taskId:O,currentTaskInput:j.input,resumeMap:z.configurable?.[F0],namespaceHash:vQ(I)}),[P0]:$.channel_values[eQ],checkpoint_id:void 0,checkpoint_ns:I}}),triggers:G,retry_policy:j.retry,cache_key:j.cache?{key:vQ((j.cache.keyFunc??JSON.stringify)([j.input])),ns:[u0,j.name??"__dynamic__"],ttl:j.cache.ttl}:void 0,id:O,path:w,writers:[]}}else return{id:O,name:j.name,interrupts:[],path:w}}else if(Q[0]===r){let j=typeof Q[1]==="number"?Q[1]:parseInt(Q[1],10);if(!q[c]?.isAvailable())return;let V=q[c].get();if(j<0||j>=V.length)return;let G=l0(V[j])&&!d(V[j])?new lQ(V[j].node,V[j].args):V[j];if(!l0(G)){console.warn(`Ignoring invalid packet ${JSON.stringify(G)} in pending sends.`);return}if(!(G.node in Z)){console.warn(`Ignoring unknown node name ${G.node} in pending sends.`);return}let M=[r],O=H===""?G.node:`${H}${k}${G.node}`,I=rQ(JSON.stringify([O,B.toString(),G.node,r,j.toString()]),$.id),w=`${O}${e}${I}`,N={langgraph_step:B,langgraph_node:G.node,langgraph_triggers:M,langgraph_path:Q.slice(0,3),langgraph_checkpoint_ns:w};if(Y){let _=Z[G.node],f=_.getNode();if(f!==void 0){if(_.metadata!==void 0)N={...N,..._.metadata};let D=[];return{name:G.node,input:G.args,proc:f,subgraphs:_.subgraphs,writes:D,config:cQ(UQ(z,{metadata:N,tags:_.tags,store:X.store??z.store}),{runName:G.node,callbacks:W?.getChild(`graph:step:${B}`),configurable:{[X0]:I,[HQ]:(x)=>y8((T)=>D.push(...T),Z,x),[RQ]:(x,T=!1)=>S0($,q,{name:G.node,writes:D,triggers:M,path:Q},x,T),[g]:F??L[g],[ZQ]:{...L[ZQ],[H]:$.id},[JQ]:v8({pendingWrites:J??[],taskId:I,currentTaskInput:G.args,resumeMap:z.configurable?.[F0],namespaceHash:vQ(w)}),[P0]:$.channel_values[eQ],checkpoint_id:void 0,checkpoint_ns:w}}),triggers:M,retry_policy:_.retryPolicy,cache_key:_.cachePolicy?{key:vQ((_.cachePolicy.keyFunc??JSON.stringify)([G.args])),ns:[u0,_.name??"__dynamic__",G.node],ttl:_.cachePolicy.ttl}:void 0,id:I,path:Q,writers:_.getWriters()}}}else return{id:I,name:G.node,interrupts:[],path:Q}}else if(Q[0]===R0){let j=Q[1].toString(),V=Z[j];if(V===void 0)return;if(J?.length){let I=H===""?j:`${H}${k}${j}`,w=rQ(JSON.stringify([I,B.toString(),j,R0,j]),$.id);if(J.some((N)=>N[0]===w&&N[1]!==l))return}let G=J8($.channel_versions);if(G===void 0)return;let M=$.versions_seen[j]??{},O=V.triggers.find((I)=>{if(!q[I].isAvailable())return!1;return($.channel_versions[I]??G)>(M[I]??G)});if(O!==void 0){let I=Q6(V,q,Y);if(I===void 0)return;let w=H===""?j:`${H}${k}${j}`,N=rQ(JSON.stringify([w,B.toString(),j,R0,[O]]),$.id),_=`${w}${e}${N}`,f={langgraph_step:B,langgraph_node:j,langgraph_triggers:[O],langgraph_path:Q,langgraph_checkpoint_ns:_};if(Y){let D=V.getNode();if(D!==void 0){if(V.metadata!==void 0)f={...f,...V.metadata};let x=[];return{name:j,input:I,proc:D,subgraphs:V.subgraphs,writes:x,config:cQ(UQ(z,{metadata:f,tags:V.tags,store:X.store??z.store}),{runName:j,callbacks:W?.getChild(`graph:step:${B}`),configurable:{[X0]:N,[HQ]:(T)=>y8((K)=>{x.push(...K)},Z,T),[RQ]:(T,K=!1)=>S0($,q,{name:j,writes:x,triggers:[O],path:Q},T,K),[g]:F??L[g],[ZQ]:{...L[ZQ],[H]:$.id},[JQ]:v8({pendingWrites:J??[],taskId:N,currentTaskInput:I,resumeMap:z.configurable?.[F0],namespaceHash:vQ(_)}),[P0]:$.channel_values[eQ],checkpoint_id:void 0,checkpoint_ns:_}}),triggers:[O],retry_policy:V.retryPolicy,cache_key:V.cachePolicy?{key:vQ((V.cachePolicy.keyFunc??JSON.stringify)([I])),ns:[u0,V.name??"__dynamic__",j],ttl:V.cachePolicy.ttl}:void 0,id:N,path:Q,writers:V.getWriters()}}}else return{id:N,name:j,interrupts:[],path:Q}}}}function Q6(Q,$,J){let Z;if(typeof Q.channels==="object"&&!Array.isArray(Q.channels)){Z={};for(let[q,z]of Object.entries(Q.channels))if(Q.triggers.includes(z))try{Z[q]=q0($,z,!1)}catch(Y){if(Y.name===E.unminifiable_name)return;else throw Y}else if(z in $)try{Z[q]=q0($,z,!1)}catch(Y){if(Y.name===E.unminifiable_name)continue;else throw Y}}else if(Array.isArray(Q.channels)){let q=!1;for(let z of Q.channels)try{Z=q0($,z,!1),q=!0;break}catch(Y){if(Y.name===E.unminifiable_name)continue;else throw Y}if(!q)return}else throw Error(`Invalid channels type, expected list or dict, got ${Q.channels}`);if(J&&Q.mapper!==void 0)Z=Q.mapper(Z);return Z}function u$(Q,$){if(typeof Q.args!=="object"||Q.args===null)return Q;let J={};for(let[Z,q]of Object.entries(Q.args)){let z=$[Z];if(!z||z.lc_graph_name!=="UntrackedValue")J[Z]=q}return new lQ(Q.node,J)}function v8({pendingWrites:Q,taskId:$,currentTaskInput:J,resumeMap:Z,namespaceHash:q}){let z=Q.find(([X,B])=>X===n&&B===o)?.[2],Y={callCounter:0,interruptCounter:-1,resume:(()=>{let X=Q.filter(([B,F])=>B===$&&F===o).flatMap(([B,F,W])=>W);if(Z!=null&&q in Z){let B=Z[q];X.push(B)}return X})(),nullResume:z,subgraphCounter:0,currentTaskInput:J,consumeNullResume:()=>{if(Y.nullResume)return delete Y.nullResume,Q.splice(Q.findIndex(([X,B])=>X===n&&B===o),1),z}};return Y}var _0={blue:{start:"\x1B[34m",end:"\x1B[0m"},green:{start:"\x1B[32m",end:"\x1B[0m"},yellow:{start:"\x1B[33;1m",end:"\x1B[0m"}},N0=(Q,$)=>`${Q.start}${$}${Q.end}`;function*C8(Q){for(let{id:$,name:J,input:Z,config:q,triggers:z,writes:Y}of Q){if(q?.tags?.includes(y))continue;yield{id:$,name:J,input:Z,triggers:z,interrupts:Y.filter(([X,B])=>{return X===$&&B===S}).map(([,X])=>{return X})}}}function $6(Q){if(typeof Q!=="object"||Q===null)return!1;return"$writes"in Q&&Array.isArray(Q.$writes)}function d$(Q){let $={};for(let[J,Z]of Q){let q=String(J);if(q in $){let z=$6($[q])?$[q].$writes:[$[q]];z.push(Z),$[q]={$writes:z}}else $[q]=Z}return $}function*p$(Q,$){for(let[{id:J,name:Z,config:q},z]of Q){if(q?.tags?.includes(y))continue;yield{id:J,name:Z,result:d$(z.filter(([Y])=>{return Array.isArray($)?$.includes(Y):Y===$})),interrupts:z.filter((Y)=>Y[0]===S).map((Y)=>Y[1])}}}function*l$(Q,$,J,Z,q,z,Y,X){function B(L){let H={};if(L.callbacks!=null)H.callbacks=L.callbacks;if(L.configurable!=null)H.configurable=L.configurable;if(L.maxConcurrency!=null)H.max_concurrency=L.maxConcurrency;if(L.metadata!=null)H.metadata=L.metadata;if(L.recursionLimit!=null)H.recursion_limit=L.recursionLimit;if(L.runId!=null)H.run_id=L.runId;if(L.runName!=null)H.run_name=L.runName;if(L.tags!=null)H.tags=L.tags;return H}let F=Q.configurable?.checkpoint_ns,W={};for(let L of q){if(!((L.subgraphs?.length)?L.subgraphs:[L.proc]).find(e0))continue;let H=`${L.name}:${L.id}`;if(F)H=`${F}|${H}`;W[L.id]={configurable:{thread_id:Q.configurable?.thread_id,checkpoint_ns:H}}}yield{config:B(Q),values:KQ($,J),metadata:Z,next:q.map((L)=>L.name),tasks:f8(q,z,W,X),parentConfig:Y?B(Y):void 0}}function f8(Q,$,J,Z){return Q.map((q)=>{let z=$.find(([F,W])=>F===q.id&&W===l)?.[2],Y=$.filter(([F,W])=>F===q.id&&W===S).map(([,,F])=>F),X=(()=>{if(z||Y.length||!$.length)return;let F=$.findIndex(([W,L])=>W===q.id&&L===VQ);if(F>=0)return $[F][2];if(typeof Z==="string")return $.find(([W,L])=>W===q.id&&L===Z)?.[2];if(Array.isArray(Z)){let W=$.filter(([L,H])=>L===q.id&&Z.includes(H)).map(([,L,H])=>[L,H]);if(!W.length)return;return d$(W)}})();if(z)return{id:q.id,name:q.name,path:q.path,error:z,interrupts:Y,result:X};let B=J?.[q.id];return{id:q.id,name:q.name,path:q.path,interrupts:Y,...B!==void 0?{state:B}:{},result:X}})}function o$(Q,$,J){console.log([`${N0(_0.blue,`[${Q}:checkpoint]`)}`,`\x1B[1m State at the end of step ${Q}:\x1B[0m
|
|
6
|
+
`,JSON.stringify(KQ($,J),null,2)].join(""))}function q8(Q,$){let J=$.length;console.log([`${N0(_0.blue,`[${Q}:tasks]`)}`,`\x1B[1m Starting step ${Q} with ${J} task${J===1?"":"s"}:\x1B[0m
|
|
7
|
+
`,$.map((Z)=>`- ${N0(_0.green,String(Z.name))} -> ${JSON.stringify(Z.input,null,2)}`).join(`
|
|
8
|
+
`)].join(""))}function c$(Q,$,J){let Z={};for(let[q,z]of $)if(J.includes(q)){if(!Z[q])Z[q]=[];Z[q].push(z)}console.log([`${N0(_0.blue,`[${Q}:writes]`)}`,`\x1B[1m Finished step ${Q} with writes to ${Object.keys(Z).length} channel${Object.keys(Z).length!==1?"s":""}:\x1B[0m
|
|
9
|
+
`,Object.entries(Z).map(([q,z])=>`- ${N0(_0.yellow,q)} -> ${z.map((Y)=>JSON.stringify(Y)).join(", ")}`).join(`
|
|
10
|
+
`)].join(""))}var m8=class extends g8{_abortController;_innerReader;constructor(Q,$){let J=Q.getReader(),Z=$??new AbortController;super({start(q){return z();function z(){return J.read().then(({done:Y,value:X})=>{if(Y){q.close();return}return q.enqueue(X),z()})}}});this._abortController=Z,this._innerReader=J}async cancel(Q){this._abortController.abort(Q),this._innerReader.releaseLock()}get signal(){return this._abortController.signal}},z8=class extends g8{modes;controller;passthroughFn;_closed=!1;get closed(){return this._closed}constructor(Q){let $,J=new Promise((Z)=>{$=Z});super({start:(Z)=>{$(Z)}});J.then((Z)=>{this.controller=Z}),this.passthroughFn=Q.passthroughFn,this.modes=Q.modes}push(Q){this.passthroughFn?.(Q),this.controller.enqueue(Q)}close(){try{this.controller.close()}catch(Q){}finally{this._closed=!0}}error(Q){this.controller.error(Q)}};function J6(Q){return JSON.stringify(Q,function($,J){let Z=this[$];if(Z!=null&&typeof Z==="object"&&"toDict"in Z&&typeof Z.toDict==="function"){let{type:q,data:z}=Z.toDict();return{...z,type:q}}return J})}function Z6(Q){if(Q instanceof Error)return{error:Q.name,message:Q.message};return{error:"Error",message:JSON.stringify(Q)}}function h8(Q){if(typeof Q!=="object"||Q==null)return!1;return"configurable"in Q&&typeof Q.configurable==="object"&&Q.configurable!=null}function k8(Q){if(!h8(Q)||!Q.configurable.thread_id)return null;return{thread_id:Q.configurable.thread_id,checkpoint_ns:Q.configurable.checkpoint_ns||"",checkpoint_id:Q.configurable.checkpoint_id||null,checkpoint_map:Q.configurable.checkpoint_map||null}}function i$(Q){if(h8(Q)){let $=Object.fromEntries(Object.entries(Q.configurable).filter(([Z])=>!Z.startsWith("__"))),J={...Q,configurable:$};return delete J.callbacks,J}return Q}function r$(Q){let $={...Q,checkpoint:k8(Q.config),parent_checkpoint:k8(Q.parentConfig),config:i$(Q.config),parent_config:i$(Q.parentConfig),tasks:Q.tasks.map((J)=>{if(h8(J.state)){let Z=k8(J.state);if(Z!=null){let q={...J,checkpoint:Z};return delete q.state,q}}return J})};return delete $.parentConfig,$}function n$(Q){let $=new TextEncoder;return new ReadableStream({async start(J){let Z=(q)=>{J.enqueue($.encode(`event: ${q.event}
|
|
11
|
+
data: ${J6(q.data)}
|
|
12
|
+
|
|
13
|
+
`))};try{for await(let q of Q){let[z,Y,X]=q,B=X;if(Y==="debug"){let F=X;if(F.type==="checkpoint")B={...F,payload:r$(F.payload)}}if(Y==="checkpoints")B=r$(X);Z({event:z?.length?`${Y}|${z.join("|")}`:Y,data:B})}}catch(q){Z({event:"error",data:Z6(q)})}J.close()}})}var Y8=Symbol.for("INPUT_DONE"),u8=Symbol.for("INPUT_RESUMING"),q6=25;function z6(...Q){return new z8({passthroughFn:($)=>{for(let J of Q)if(J.modes.has($[1]))J.push($)},modes:new Set(Q.flatMap(($)=>Array.from($.modes)))})}var Y6=class extends t${cache;queue=Promise.resolve();constructor(Q){super();this.cache=Q}async get(Q){return this.enqueueOperation("get",Q)}async set(Q){return this.enqueueOperation("set",Q)}async clear(Q){return this.enqueueOperation("clear",Q)}async stop(){await this.queue}enqueueOperation(Q,...$){let J=this.queue.then(()=>{return this.cache[Q](...$)});return this.queue=J.then(()=>{return},()=>{return}),J}},a$=class Q{input;output;config;checkpointer;checkpointerGetNextVersion;channels;checkpoint;checkpointIdSaved;checkpointConfig;checkpointMetadata;checkpointNamespace;checkpointPendingWrites=[];checkpointPreviousVersions;step;stop;durability;outputKeys;streamKeys;nodes;skipDoneTasks;prevCheckpointConfig;updatedChannels;status="pending";tasks={};stream;checkpointerPromises=[];isNested;_checkpointerChainedPromise=Promise.resolve();store;cache;manager;interruptAfter;interruptBefore;toInterrupt=[];debug=!1;triggerToNodes;get isResuming(){let $=!1;if(R in this.checkpoint.channel_versions)$=!0;else for(let X in this.checkpoint.channel_versions)if(Object.prototype.hasOwnProperty.call(this.checkpoint.channel_versions,X)){$=!0;break}let J=this.config.configurable?.[yQ]!==void 0&&this.config.configurable?.[yQ],Z=this.input===null||this.input===void 0,q=u(this.input)&&this.input.resume!=null,z=this.input===u8,Y=!this.isNested&&this.config.metadata?.run_id!==void 0&&this.checkpointMetadata?.run_id!==void 0&&this.config.metadata.run_id===this.checkpointMetadata?.run_id;return $&&(J||Z||q||z||Y)}constructor($){if(this.input=$.input,this.checkpointer=$.checkpointer,this.checkpointer!==void 0)this.checkpointerGetNextVersion=this.checkpointer.getNextVersion.bind(this.checkpointer);else this.checkpointerGetNextVersion=h$;this.checkpoint=$.checkpoint,this.checkpointMetadata=$.checkpointMetadata,this.checkpointPreviousVersions=$.checkpointPreviousVersions,this.channels=$.channels,this.checkpointPendingWrites=$.checkpointPendingWrites,this.step=$.step,this.stop=$.stop,this.config=$.config,this.checkpointConfig=$.checkpointConfig,this.isNested=$.isNested,this.manager=$.manager,this.outputKeys=$.outputKeys,this.streamKeys=$.streamKeys,this.nodes=$.nodes,this.skipDoneTasks=$.skipDoneTasks,this.store=$.store,this.cache=$.cache?new Y6($.cache):void 0,this.stream=$.stream,this.checkpointNamespace=$.checkpointNamespace,this.prevCheckpointConfig=$.prevCheckpointConfig,this.interruptAfter=$.interruptAfter,this.interruptBefore=$.interruptBefore,this.durability=$.durability,this.debug=$.debug,this.triggerToNodes=$.triggerToNodes}static async initialize($){let{config:J,stream:Z}=$;if(Z!==void 0&&J.configurable?.[w0]!==void 0)Z=z6(Z,J.configurable[w0]);let q=J.configurable?!("checkpoint_id"in J.configurable):!0,z=J.configurable?.[JQ];if(J.configurable&&z){if(z.subgraphCounter>0)J=zQ(J,{[FQ]:[J.configurable[FQ],z.subgraphCounter.toString()].join(k)});z.subgraphCounter+=1}let Y=RQ in(J.configurable??{});if(!Y&&J.configurable?.checkpoint_ns!==void 0&&J.configurable?.checkpoint_ns!=="")J=zQ(J,{checkpoint_ns:"",checkpoint_id:void 0});let X=J;if(J.configurable?.[ZQ]!==void 0&&J.configurable?.[ZQ]?.[J.configurable?.checkpoint_ns])X=zQ(J,{checkpoint_id:J.configurable[ZQ][J.configurable?.checkpoint_ns]});let B=J.configurable?.checkpoint_ns?.split(k)??[],F=await $.checkpointer?.getTuple(X)??{config:J,checkpoint:U0(),metadata:{source:"input",step:-2,parents:{}},pendingWrites:[]};X={...J,...F.config,configurable:{checkpoint_ns:"",...J.configurable,...F.config.configurable}};let W=F.parentConfig,L=fQ(F.checkpoint),H={...F.metadata},j=F.pendingWrites??[],V=pQ($.channelSpecs,L),G=(H.step??0)+1,M=G+(J.recursionLimit??q6)+1,O={...L.channel_versions},I=$.store?new X8($.store):void 0;if(I)await I.start();return new Q({input:$.input,config:J,checkpointer:$.checkpointer,checkpoint:L,checkpointMetadata:H,checkpointConfig:X,prevCheckpointConfig:W,checkpointNamespace:B,channels:V,isNested:Y,manager:$.manager,skipDoneTasks:q,step:G,stop:M,checkpointPreviousVersions:O,checkpointPendingWrites:j,outputKeys:$.outputKeys??[],streamKeys:$.streamKeys??[],nodes:$.nodes,stream:Z,store:I,cache:$.cache,interruptAfter:$.interruptAfter,interruptBefore:$.interruptBefore,durability:$.durability,debug:$.debug,triggerToNodes:$.triggerToNodes})}_checkpointerPutAfterPrevious($){this._checkpointerChainedPromise=this._checkpointerChainedPromise.then(()=>{return this.checkpointer?.put($.config,$.checkpoint,$.metadata,$.newVersions)}),this.checkpointerPromises.push(this._checkpointerChainedPromise)}putWrites($,J){let Z=J;if(Z.length===0)return;if(Z.every(([B])=>(B in s$)))Z=Array.from(new Map(Z.map((B)=>[B[0],B])).values());let q=!1;for(let B in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,B)){if(this.channels[B].lc_graph_name==="UntrackedValue"){q=!0;break}}let z=Z;if(q)z=Z.filter(([B])=>{let F=this.channels[B];return!F||F.lc_graph_name!=="UntrackedValue"}).map(([B,F])=>{if(B===c&&d(F))return[B,u$(F,this.channels)];return[B,F]});this.checkpointPendingWrites=this.checkpointPendingWrites.filter((B)=>B[0]!==$);for(let[B,F]of z)this.checkpointPendingWrites.push([$,B,F]);let Y=zQ(this.checkpointConfig,{[FQ]:this.config.configurable?.checkpoint_ns??"",[w8]:this.checkpoint.id});if(this.durability!=="exit"&&this.checkpointer!=null)this.checkpointerPromises.push(this.checkpointer.putWrites(Y,z,$));if(this.tasks)this._outputWrites($,Z);if(!J.length||!this.cache||!this.tasks)return;let X=this.tasks[$];if(X==null||X.cache_key==null)return;if(J[0][0]===l||J[0][0]===S)return;this.cache.set([{key:[X.cache_key.ns,X.cache_key.key],value:X.writes,ttl:X.cache_key.ttl}])}_outputWrites($,J,Z=!1){let q=this.tasks[$];if(q!==void 0){if(q.config!==void 0&&(q.config.tags??[]).includes(y))return;if(J.length>0){if(J[0][0]===S){if(q.path?.[0]===r&&q.path?.[q.path.length-1]===!0)return;let z=J.filter((Y)=>Y[0]===S).flatMap((Y)=>Y[1]);this._emit([["updates",{[S]:z}],["values",{[S]:z}]])}else if(J[0][0]!==l)this._emit($0(CQ(E$(this.outputKeys,[[q,J]],Z),"updates")))}if(!Z)this._emit($0(CQ(p$([[q,J]],this.streamKeys),"tasks")))}}async _matchCachedWrites(){if(!this.cache)return[];let $=[],J=([Y,X])=>{return`ns:${Y.join(",")}|key:${X}`},Z=[],q={};for(let Y of Object.values(this.tasks))if(Y.cache_key!=null&&!Y.writes.length)Z.push([Y.cache_key.ns,Y.cache_key.key]),q[J([Y.cache_key.ns,Y.cache_key.key])]=Y;if(Z.length===0)return[];let z=await this.cache.get(Z);for(let{key:Y,value:X}of z){let B=q[J(Y)];if(B!=null)B.writes.push(...X),$.push({task:B,result:X})}return $}async tick($){if(this.store&&!this.store.isRunning)await this.store?.start();let{inputKeys:J=[]}=$;if(this.status!=="pending")throw Error(`Cannot tick when status is no longer "pending". Current status: "${this.status}"`);if(![Y8,u8].includes(this.input))await this._first(J);else if(this.toInterrupt.length>0)throw this.status="interrupt_before",new AQ;else if(Object.values(this.tasks).every((q)=>q.writes.length>0)){let q=Object.values(this.tasks).flatMap((Y)=>Y.writes);this.updatedChannels=$Q(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes);let z=await GQ(CQ($8(this.outputKeys,q,this.channels),"values"));if(this._emit(z),this.checkpointPendingWrites=[],await this._putCheckpoint({source:"loop"}),I0(this.checkpoint,this.interruptAfter,Object.values(this.tasks)))throw this.status="interrupt_after",new AQ;if(this.config.configurable?.[yQ]!==void 0)delete this.config.configurable?.[yQ]}else return!1;if(this.step>this.stop)return this.status="out_of_steps",!1;if(this.tasks=nQ(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step,checkpointer:this.checkpointer,isResuming:this.isResuming,manager:this.manager,store:this.store,stream:this.stream,triggerToNodes:this.triggerToNodes,updatedChannels:this.updatedChannels}),this.checkpointer)this._emit(await GQ(CQ(l$(this.checkpointConfig,this.channels,this.streamKeys,this.checkpointMetadata,Object.values(this.tasks),this.checkpointPendingWrites,this.prevCheckpointConfig,this.outputKeys),"checkpoints")));if(Object.values(this.tasks).length===0)return this.status="done",!1;if(this.skipDoneTasks&&this.checkpointPendingWrites.length>0){for(let[q,z,Y]of this.checkpointPendingWrites){if(z===l||z===S||z===o)continue;let X=Object.values(this.tasks).find((B)=>B.id===q);if(X)X.writes.push([z,Y])}for(let q of Object.values(this.tasks))if(q.writes.length>0)this._outputWrites(q.id,q.writes,!0)}if(Object.values(this.tasks).every((q)=>q.writes.length>0))return this.tick({inputKeys:J});if(I0(this.checkpoint,this.interruptBefore,Object.values(this.tasks)))throw this.status="interrupt_before",new AQ;let Z=await GQ(CQ(C8(Object.values(this.tasks)),"tasks"));return this._emit(Z),!0}async finishAndHandleError($){if(this.durability==="exit"&&(!this.isNested||typeof $<"u"||this.checkpointNamespace.every((Z)=>!Z.includes(e))))this._putCheckpoint(this.checkpointMetadata),this._flushPendingWrites();let J=this._suppressInterrupt($);if(J||$===void 0)this.output=KQ(this.channels,this.outputKeys);if(J){if(this.tasks!==void 0&&this.checkpointPendingWrites.length>0&&Object.values(this.tasks).some((Z)=>Z.writes.length>0))this.updatedChannels=$Q(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes),this._emit($0(CQ($8(this.outputKeys,Object.values(this.tasks).flatMap((Z)=>Z.writes),this.channels),"values")));if(OQ($)&&!$.interrupts.length)this._emit([["updates",{[S]:[]}],["values",{[S]:[]}]])}return J}async acceptPush($,J,Z){if(this.interruptAfter?.length>0&&I0(this.checkpoint,this.interruptAfter,[$])){this.toInterrupt.push($);return}let q=Z8([r,$.path??[],J,$.id,Z],this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,$.config??{},!0,{step:this.step,checkpointer:this.checkpointer,manager:this.manager,store:this.store,stream:this.stream});if(!q)return;if(this.interruptBefore?.length>0&&I0(this.checkpoint,this.interruptBefore,[q])){this.toInterrupt.push(q);return}if(this._emit($0(CQ(C8([q]),"tasks"))),this.debug)q8(this.step,[q]);if(this.tasks[q.id]=q,this.skipDoneTasks)this._matchWrites({[q.id]:q});let z=await this._matchCachedWrites();for(let{task:Y}of z)this._outputWrites(Y.id,Y.writes,!0);return q}_suppressInterrupt($){return OQ($)&&!this.isNested}async _first($){let{configurable:J}=this.config,Z=J?.[JQ];if(Z&&Z.nullResume!==void 0)this.putWrites(n,[[o,Z.nullResume]]);if(u(this.input)){let Y=this.input.resume!=null;if(this.input.resume!=null&&typeof this.input.resume==="object"&&Object.keys(this.input.resume).every(n0))this.config.configurable??={},this.config.configurable[F0]=this.input.resume;if(Y&&this.checkpointer==null)throw Error("Cannot use Command(resume=...) without checkpointer");let X={};for(let[B,F,W]of N$(this.input,this.checkpointPendingWrites))X[B]??=[],X[B].push([F,W]);if(Object.keys(X).length===0)throw new M0("Received empty Command input");for(let[B,F]of Object.entries(X))this.putWrites(B,F)}let q=(this.checkpointPendingWrites??[]).filter((Y)=>Y[0]===n).map((Y)=>Y.slice(1));if(q.length>0)$Q(this.checkpoint,this.channels,[{name:PQ,writes:q,triggers:[]}],this.checkpointerGetNextVersion,this.triggerToNodes);let z=u(this.input)&&q.length>0;if(this.isResuming||z){for(let X in this.channels){if(!Object.prototype.hasOwnProperty.call(this.channels,X))continue;if(this.checkpoint.channel_versions[X]!==void 0){let B=this.checkpoint.channel_versions[X];this.checkpoint.versions_seen[S]={...this.checkpoint.versions_seen[S],[X]:B}}}let Y=await GQ(CQ($8(this.outputKeys,!0,this.channels),"values"));this._emit(Y)}if(this.isResuming)this.input=u8;else if(z)await this._putCheckpoint({source:"input"}),this.input=Y8;else{let Y=await GQ(Q8($,this.input));if(Y.length>0){let X=nQ(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step});this.updatedChannels=$Q(this.checkpoint,this.channels,Object.values(X).concat([{name:PQ,writes:Y,triggers:[]}]),this.checkpointerGetNextVersion,this.triggerToNodes),await this._putCheckpoint({source:"input"}),this.input=Y8}else if(!(yQ in(this.config.configurable??{})))throw new M0(`Received no input writes for ${JSON.stringify($,null,2)}`);else this.input=Y8}if(!this.isNested)this.config=zQ(this.config,{[yQ]:this.isResuming})}_emit($){for(let[J,Z]of $){if(this.stream.modes.has(J))this.stream.push([this.checkpointNamespace,J,Z]);if((J==="checkpoints"||J==="tasks")&&this.stream.modes.has("debug")){let q=J==="checkpoints"?this.step-1:this.step,z=new Date().toISOString(),Y=(()=>{if(J==="checkpoints")return"checkpoint";else if(typeof Z==="object"&&Z!=null&&"result"in Z)return"task_result";else return"task"})();this.stream.push([this.checkpointNamespace,"debug",{step:q,type:Y,timestamp:z,payload:Z}])}}}_putCheckpoint($){let J=this.checkpointMetadata===$,Z=this.checkpointer!=null&&(this.durability!=="exit"||J),q=(z)=>{this.prevCheckpointConfig=this.checkpointConfig?.configurable?.checkpoint_id?this.checkpointConfig:void 0,this.checkpointConfig=zQ(this.checkpointConfig,{[FQ]:this.config.configurable?.checkpoint_ns??""});let Y={...this.checkpoint.channel_versions},X=H0(this.checkpointPreviousVersions,Y);this.checkpointPreviousVersions=Y,this._checkpointerPutAfterPrevious({config:{...this.checkpointConfig},checkpoint:fQ(z),metadata:{...this.checkpointMetadata},newVersions:X}),this.checkpointConfig={...this.checkpointConfig,configurable:{...this.checkpointConfig.configurable,checkpoint_id:this.checkpoint.id}}};if(!J)this.checkpointMetadata={...$,step:this.step,parents:this.config.configurable?.[ZQ]??{}};if(this.checkpoint=LQ(this.checkpoint,Z?this.channels:void 0,this.step,J?{id:this.checkpoint.id}:void 0),Z)q(this.checkpoint);if(!J)this.step+=1}_flushPendingWrites(){if(this.checkpointer==null)return;if(this.checkpointPendingWrites.length===0)return;let $=zQ(this.checkpointConfig,{[FQ]:this.config.configurable?.checkpoint_ns??"",[w8]:this.checkpoint.id}),J={};for(let[Z,q,z]of this.checkpointPendingWrites)J[Z]??=[],J[Z].push([q,z]);for(let[Z,q]of Object.entries(J))this.checkpointerPromises.push(this.checkpointer.putWrites($,q,Z))}_matchWrites($){for(let[J,Z,q]of this.checkpointPendingWrites){if(Z===l||Z===S||Z===o)continue;let z=Object.values($).find((Y)=>Y.id===J);if(z)z.writes.push([Z,q])}for(let J of Object.values($))if(J.writes.length>0)this._outputWrites(J.id,J.writes,!0)}};function X6(Q){return kQ(Q?.message)}var J1=class extends $1{name="StreamMessagesHandler";streamFn;metadatas={};seen={};emittedChatModelRunIds={};stableMessageIdMap={};lc_prefer_streaming=!0;constructor(Q){super();this.streamFn=Q}_emit(Q,$,J,Z=!1){if(Z&&$.id!==void 0&&this.seen[$.id]!==void 0)return;let q=$.id;if(J!=null)if(e$($))q??=`run-${J}-tool-${$.tool_call_id}`;else{if(q==null||q===`run-${J}`)q=this.stableMessageIdMap[J]??q??`run-${J}`;this.stableMessageIdMap[J]??=q}if(q!==$.id)$.id=q,$.lc_kwargs.id=q;if($.id!=null)this.seen[$.id]=$;this.streamFn([Q[0],"messages",[$,Q[1]]])}handleChatModelStart(Q,$,J,Z,q,z,Y,X){if(Y&&(!z||!z.includes(H$)&&!z.includes("nostream")))this.metadatas[J]=[Y.langgraph_checkpoint_ns.split("|"),{tags:z,name:X,...Y}]}handleLLMNewToken(Q,$,J,Z,q,z){let Y=z?.chunk;if(this.emittedChatModelRunIds[J]=!0,this.metadatas[J]!==void 0)if(X6(Y))this._emit(this.metadatas[J],Y.message,J);else this._emit(this.metadatas[J],new Q1({content:Q}),J)}handleLLMEnd(Q,$){if(this.metadatas[$]===void 0)return;if(!this.emittedChatModelRunIds[$]){let J=Q.generations?.[0]?.[0];if(kQ(J?.message))this._emit(this.metadatas[$],J?.message,$,!0);delete this.emittedChatModelRunIds[$]}delete this.metadatas[$],delete this.stableMessageIdMap[$]}handleLLMError(Q,$){delete this.metadatas[$]}handleChainStart(Q,$,J,Z,q,z,Y,X){if(z!==void 0&&X===z.langgraph_node&&(q===void 0||!q.includes(y))){if(this.metadatas[J]=[z.langgraph_checkpoint_ns.split("|"),{tags:q,name:X,...z}],typeof $==="object"){for(let B of Object.values($))if((kQ(B)||d8(B))&&B.id!==void 0)this.seen[B.id]=B;else if(Array.isArray(B)){for(let F of B)if((kQ(F)||d8(F))&&F.id!==void 0)this.seen[F.id]=F}}}}handleChainEnd(Q,$){let J=this.metadatas[$];if(delete this.metadatas[$],J!==void 0){if(kQ(Q))this._emit(J,Q,$,!0);else if(Array.isArray(Q)){for(let Z of Q)if(kQ(Z))this._emit(J,Z,$,!0)}else if(Q!=null&&typeof Q==="object"){for(let Z of Object.values(Q))if(kQ(Z))this._emit(J,Z,$,!0);else if(Array.isArray(Z)){for(let q of Z)if(kQ(q))this._emit(J,q,$,!0)}}}}handleChainError(Q,$){delete this.metadatas[$]}};var F6=500,B6=2,W6=128000,L6=3,j6=[400,401,402,403,404,405,406,407,409],H6=(Q)=>{if(Q.message.startsWith("Cancel")||Q.message.startsWith("AbortError")||Q.name==="AbortError")return!1;if(Q.name==="GraphValueError")return!1;if(Q?.code==="ECONNABORTED")return!1;let $=Q?.response?.status??Q?.status;if($&&j6.includes(+$))return!1;if(Q?.error?.code==="insufficient_quota")return!1;return!0};async function p8(Q,$,J,Z){let q=Q.retry_policy??$,z=q!==void 0?q.initialInterval??F6:0,Y=0,X,B,{config:F}=Q;if(J)F=zQ(F,J);F={...F,signal:Z};while(!0){if(Z?.aborted)break;Q.writes.splice(0,Q.writes.length),X=void 0;try{B=await Q.proc.invoke(Q.input,F);break}catch(W){if(X=W,X.pregelTaskId=Q.id,g0(X)){let j=F?.configurable?.checkpoint_ns,V=X.command;if(V.graph===j){for(let G of Q.writers)await G.invoke(V,F);X=void 0;break}else if(V.graph===a.PARENT){let G=R$(j);X.command=new a({...X.command,graph:G})}}if(dQ(X))break;if(q===void 0)break;if(Y+=1,Y>=(q.maxAttempts??L6))break;if(!(q.retryOn??H6)(X))break;z=Math.min(q.maxInterval??W6,z*(q.backoffFactor??B6));let L=q.jitter?Math.floor(z+Math.random()*1000):z;await new Promise((j)=>setTimeout(j,L));let H=X.name??X.constructor.unminifiable_name??X.constructor.name;if(q?.logWarning??!0)console.log(`Retrying task "${String(Q.name)}" after ${z.toFixed(2)}ms (attempt ${Y}) after ${H}: ${X}`);F=zQ(F,{[yQ]:!0})}}return{task:Q,result:B,error:X,signalAborted:Z?.aborted}}var l8=Symbol.for("promiseAdded");function V6(){let Q={next:()=>{return},wait:Promise.resolve(l8)};function $(J){Q.next=()=>{Q.wait=new Promise($),J(l8)}}return Q.wait=new Promise($),Q}var Z1=class{nodeFinished;loop;constructor({loop:Q,nodeFinished:$}){this.loop=Q,this.nodeFinished=$}async tick(Q={}){let{timeout:$,retryPolicy:J,onStepWrite:Z,maxConcurrency:q}=Q,z=new Set,Y,X=new AbortController,B=X.signal,F=$?AbortSignal.timeout($):void 0,W=Object.values(this.loop.tasks).filter((V)=>V.writes.length===0),{signals:L,disposeCombinedSignal:H}=this._initializeAbortSignals({exceptionSignal:B,stepTimeoutSignal:F,signal:Q.signal}),j=this._executeTasksWithRetry(W,{signals:L,retryPolicy:J,maxConcurrency:q});for await(let{task:V,error:G,signalAborted:M}of j)if(this._commit(V,G),OQ(G))Y=G;else if(dQ(G)&&!OQ(Y))Y=G;else if(G&&(z.size===0||!M))X.abort(),z.add(G);if(H?.(),Z?.(this.loop.step,Object.values(this.loop.tasks).map((V)=>V.writes).flat()),z.size===1)throw Array.from(z)[0];else if(z.size>1)throw AggregateError(Array.from(z),`Multiple errors occurred during superstep ${this.loop.step}. See the "errors" field of this exception for more details.`);if(OQ(Y))throw Y;if(dQ(Y)&&this.loop.isNested)throw Y}_initializeAbortSignals({exceptionSignal:Q,stepTimeoutSignal:$,signal:J}){let Z=this.loop.config.configurable?.[P8]??{},q=Z.externalAbortSignal??J,z=$??Z.timeoutAbortSignal,{signal:Y,dispose:X}=V0(q,z,Q),B={externalAbortSignal:q,timeoutAbortSignal:z,composedAbortSignal:Y};return this.loop.config=zQ(this.loop.config,{[P8]:B}),{signals:B,disposeCombinedSignal:X}}async*_executeTasksWithRetry(Q,$){let{retryPolicy:J,maxConcurrency:Z,signals:q}=$??{},z=V6(),Y={},X={executingTasksMap:Y,barrier:z,retryPolicy:J,scheduleTask:async(H,j,V)=>this.loop.acceptPush(H,j,V)};if(q?.composedAbortSignal?.aborted)throw Error("Abort");let B=0,F,W=V0(q?.externalAbortSignal,q?.timeoutAbortSignal),L=W.signal?new Promise((H,j)=>{F=()=>j(Error("Abort")),W.signal?.addEventListener("abort",F,{once:!0})}):void 0;while((B===0||Object.keys(Y).length>0)&&Q.length){for(;Object.values(Y).length<(Z??Q.length)&&B<Q.length;B+=1){let j=Q[B];Y[j.id]=p8(j,J,{[d0]:q1?.bind(X,this,j)},q?.composedAbortSignal).catch((V)=>{return{task:j,error:V,signalAborted:q?.composedAbortSignal?.aborted}})}let H=await Promise.race([...Object.values(Y),...L?[L]:[],z.wait]);if(H===l8)continue;if(yield H,F!=null)W.signal?.removeEventListener("abort",F),W.dispose?.();delete Y[H.task.id]}}_commit(Q,$){if($!==void 0)if(OQ($)){if($.interrupts.length){let J=$.interrupts.map((q)=>[S,q]),Z=Q.writes.filter((q)=>q[0]===o);if(Z.length)J.push(...Z);this.loop.putWrites(Q.id,J)}}else if(dQ($)&&Q.writes.length)this.loop.putWrites(Q.id,Q.writes);else this.loop.putWrites(Q.id,[[l,{message:$.message,name:$.name}]]);else{if(this.nodeFinished&&(Q.config?.tags==null||!Q.config.tags.includes(y)))this.nodeFinished(String(Q.name));if(Q.writes.length===0)Q.writes.push([p0,null]);this.loop.putWrites(Q.id,Q.writes)}}};async function q1(Q,$,J,Z,q,z={}){let Y=$.config?.configurable?.[JQ];if(!Y)throw Error(`BUG: No scratchpad found on task ${$.name}__${$.id}`);let X=Y.callCounter;Y.callCounter+=1;let B=new C$({func:J,name:Z,input:q,cache:z.cache,retry:z.retry,callbacks:z.callbacks}),F=await this.scheduleTask($,X,B);if(!F)return;let W=this.executingTasksMap[F.id];if(W!==void 0)return W;if(F.writes.length>0){let L=F.writes.filter(([j])=>j===VQ),H=F.writes.filter(([j])=>j===l);if(L.length>0){if(L.length===1)return Promise.resolve(L[0][1]);throw Error(`BUG: multiple returns found for task ${F.name}__${F.id}`)}if(H.length>0){if(H.length===1){let j=H[0][1],V=j instanceof Error?j:Error(String(j));return Promise.reject(V)}throw Error(`BUG: multiple errors found for task ${F.name}__${F.id}`)}return}else{let L=p8(F,z.retry,{[d0]:q1.bind(this,Q,F)});return this.executingTasksMap[F.id]=L,this.barrier.next(),L.then(({result:H,error:j})=>{if(j)return Promise.reject(j);return H})}}var gQ=class extends Error{constructor(Q){super(Q);this.name="GraphValidationError"}};function z1({nodes:Q,channels:$,inputChannels:J,outputChannels:Z,streamChannels:q,interruptAfterNodes:z,interruptBeforeNodes:Y}){if(!$)throw new gQ("Channels not provided");let X=new Set,B=new Set;for(let[F,W]of Object.entries(Q)){if(F===S)throw new gQ(`"Node name ${S} is reserved"`);if(W.constructor===DQ)W.triggers.forEach((L)=>X.add(L));else throw new gQ(`Invalid node type ${typeof W}, expected PregelNode`)}for(let F of X)if(!(F in $))throw new gQ(`Subscribed channel '${String(F)}' not in channels`);if(!Array.isArray(J)){if(!X.has(J))throw new gQ(`Input channel ${String(J)} is not subscribed to by any node`)}else if(J.every((F)=>!X.has(F)))throw new gQ(`None of the input channels ${J} are subscribed to by any node`);if(!Array.isArray(Z))B.add(Z);else Z.forEach((F)=>B.add(F));if(q&&!Array.isArray(q))B.add(q);else if(Array.isArray(q))q.forEach((F)=>B.add(F));for(let F of B)if(!(F in $))throw new gQ(`Output channel '${String(F)}' not in channels`);if(z&&z!=="*"){for(let F of z)if(!(F in Q))throw new gQ(`Node ${String(F)} not in nodes`)}if(Y&&Y!=="*"){for(let F of Y)if(!(F in Q))throw new gQ(`Node ${String(F)} not in nodes`)}}function o8(Q,$){if(Array.isArray(Q)){for(let J of Q)if(!(J in $))throw Error(`Key ${String(J)} not found in channels`)}else if(!(Q in $))throw Error(`Key ${String(Q)} not found in channels`)}var c8=class Q extends p{lc_graph_name="Topic";unique=!1;accumulate=!1;seen;values;constructor($){super();this.unique=$?.unique??this.unique,this.accumulate=$?.accumulate??this.accumulate,this.seen=new Set,this.values=[]}fromCheckpoint($){let J=new Q({unique:this.unique,accumulate:this.accumulate});if(typeof $<"u")J.seen=new Set($[0]),J.values=$[1];return J}update($){let J=!1;if(!this.accumulate)J=this.values.length>0,this.values=[];let Z=$.flat();if(Z.length>0)if(this.unique){for(let q of Z)if(!this.seen.has(q))J=!0,this.seen.add(q),this.values.push(q)}else J=!0,this.values.push(...Z);return J}get(){if(this.values.length===0)throw new E;return this.values}checkpoint(){return[[...this.seen],this.values]}isAvailable(){return this.values.length!==0}};var F1=class{static subscribeTo(Q,$){let{key:J,tags:Z}={key:void 0,tags:void 0,...$??{}};if(Array.isArray(Q)&&J!==void 0)throw Error("Can't specify a key when subscribing to multiple channels");let q;if(typeof Q==="string")if(J)q={[J]:Q};else q=[Q];else q=Object.fromEntries(Q.map((z)=>[z,z]));return new DQ({channels:q,triggers:Array.isArray(Q)?Q:[Q],tags:Z})}static writeTo(Q,$){let J=[];for(let Z of Q)J.push({channel:Z,value:qQ,skipNone:!1});for(let[Z,q]of Object.entries($??{}))if(YQ.isRunnable(q)||typeof q==="function")J.push({channel:Z,value:qQ,skipNone:!0,mapper:SQ(q)});else J.push({channel:Z,value:q,skipNone:!1});return new m(J)}},U6=class extends YQ{lc_namespace=["langgraph","pregel"];invoke(Q,$){throw Error("Not implemented")}withConfig(Q){return super.withConfig(Q)}stream(Q,$){return super.stream(Q,$)}},B8=class extends U6{static lc_name(){return"LangGraph"}lc_namespace=["langgraph","pregel"];lg_is_pregel=!0;nodes;channels;inputChannels;outputChannels;autoValidate=!0;streamMode=["values"];streamChannels;interruptAfter;interruptBefore;stepTimeout;debug=!1;checkpointer;retryPolicy;config;store;cache;userInterrupt;triggerToNodes={};constructor(Q){super(Q);let{streamMode:$}=Q;if($!=null&&!Array.isArray($))$=[$];if(this.nodes=Q.nodes,this.channels=Q.channels,c in this.channels&&"lc_graph_name"in this.channels[c]&&this.channels[c].lc_graph_name!=="Topic")throw Error(`Channel '${c}' is reserved and cannot be used in the graph.`);else this.channels[c]=new c8({accumulate:!1});if(this.autoValidate=Q.autoValidate??this.autoValidate,this.streamMode=$??this.streamMode,this.inputChannels=Q.inputChannels,this.outputChannels=Q.outputChannels,this.streamChannels=Q.streamChannels??this.streamChannels,this.interruptAfter=Q.interruptAfter,this.interruptBefore=Q.interruptBefore,this.stepTimeout=Q.stepTimeout??this.stepTimeout,this.debug=Q.debug??this.debug,this.checkpointer=Q.checkpointer,this.retryPolicy=Q.retryPolicy,this.config=Q.config,this.store=Q.store,this.cache=Q.cache,this.name=Q.name,this.triggerToNodes=Q.triggerToNodes??this.triggerToNodes,this.userInterrupt=Q.userInterrupt,this.autoValidate)this.validate()}withConfig(Q){let $=UQ(this.config,Q);return new this.constructor({...this,config:$})}validate(){z1({nodes:this.nodes,channels:this.channels,outputChannels:this.outputChannels,inputChannels:this.inputChannels,streamChannels:this.streamChannels,interruptAfterNodes:this.interruptAfter,interruptBeforeNodes:this.interruptBefore});for(let[Q,$]of Object.entries(this.nodes))for(let J of $.triggers)this.triggerToNodes[J]??=[],this.triggerToNodes[J].push(Q);return this}get streamChannelsList(){if(Array.isArray(this.streamChannels))return this.streamChannels;else if(this.streamChannels)return[this.streamChannels];else return Object.keys(this.channels)}get streamChannelsAsIs(){if(this.streamChannels)return this.streamChannels;else return Object.keys(this.channels)}async getGraphAsync(Q){return this.getGraph(Q)}*getSubgraphs(Q,$){for(let[J,Z]of Object.entries(this.nodes)){if(Q!==void 0){if(!Q.startsWith(J))continue}let q=Z.subgraphs?.length?Z.subgraphs:[Z.bound];for(let z of q){let Y=e0(z);if(Y!==void 0){if(J===Q){yield[J,Y];return}if(Q===void 0)yield[J,Y];if($){let X=Q;if(Q!==void 0)X=Q.slice(J.length+1);for(let[B,F]of Y.getSubgraphs(X,$))yield[`${J}${k}${B}`,F]}}}}}async*getSubgraphsAsync(Q,$){yield*this.getSubgraphs(Q,$)}async _prepareStateSnapshot({config:Q,saved:$,subgraphCheckpointer:J,applyPendingWrites:Z=!1}){if($===void 0)return{values:{},next:[],config:Q,tasks:[]};let q=pQ(this.channels,$.checkpoint);if($.pendingWrites?.length){let L=$.pendingWrites.filter(([H,j])=>H===n).map(([H,j,V])=>[String(j),V]);if(L.length>0)$Q($.checkpoint,q,[{name:PQ,writes:L,triggers:[]}],void 0,this.triggerToNodes)}let z=Object.values(nQ($.checkpoint,$.pendingWrites,this.nodes,q,$.config,!0,{step:($.metadata?.step??-1)+1,store:this.store})),Y=await GQ(this.getSubgraphsAsync()),X=$.config.configurable?.checkpoint_ns??"",B={};for(let L of z){let H=Y.find(([V])=>V===L.name);if(!H)continue;let j=`${String(L.name)}${e}${L.id}`;if(X)j=`${X}${k}${j}`;if(J===void 0){let V={configurable:{thread_id:$.config.configurable?.thread_id,checkpoint_ns:j}};B[L.id]=V}else{let V={configurable:{[g]:J,thread_id:$.config.configurable?.thread_id,checkpoint_ns:j}},G=H[1];B[L.id]=await G.getState(V,{subgraphs:!0})}}if(Z&&$.pendingWrites?.length){let L=Object.fromEntries(z.map((j)=>[j.id,j]));for(let[j,V,G]of $.pendingWrites){if([l,S,F8].includes(V))continue;if(!(j in L))continue;L[j].writes.push([String(V),G])}let H=z.filter((j)=>j.writes.length>0);if(H.length>0)$Q($.checkpoint,q,H,void 0,this.triggerToNodes)}let F=$?.metadata;if(F&&$?.config?.configurable?.thread_id)F={...F,thread_id:$.config.configurable.thread_id};let W=z.filter((L)=>L.writes.length===0).map((L)=>L.name);return{values:KQ(q,this.streamChannelsAsIs),next:W,tasks:f8(z,$?.pendingWrites??[],B,this.streamChannelsAsIs),metadata:F,config:iQ($.config,$.metadata),createdAt:$.checkpoint.ts,parentConfig:$.parentConfig}}async getState(Q,$){let J=Q.configurable?.[g]??this.checkpointer;if(!J)throw new uQ("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let Z=Q.configurable?.checkpoint_ns??"";if(Z!==""&&Q.configurable?.[g]===void 0){let Y=s0(Z);for await(let[X,B]of this.getSubgraphsAsync(Y,!0))if(X===Y)return await B.getState(J0(Q,{[g]:J}),{subgraphs:$?.subgraphs});throw Error(`Subgraph with namespace "${Y}" not found.`)}let q=UQ(this.config,Q),z=await J.getTuple(Q);return await this._prepareStateSnapshot({config:q,saved:z,subgraphCheckpointer:$?.subgraphs?J:void 0,applyPendingWrites:!Q.configurable?.checkpoint_id})}async*getStateHistory(Q,$){let J=Q.configurable?.[g]??this.checkpointer;if(!J)throw new uQ("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let Z=Q.configurable?.checkpoint_ns??"";if(Z!==""&&Q.configurable?.[g]===void 0){let z=s0(Z);for await(let[Y,X]of this.getSubgraphsAsync(z,!0))if(Y===z){yield*X.getStateHistory(J0(Q,{[g]:J}),$);return}throw Error(`Subgraph with namespace "${z}" not found.`)}let q=UQ(this.config,Q,{configurable:{checkpoint_ns:Z}});for await(let z of J.list(q,$))yield this._prepareStateSnapshot({config:z.config,saved:z})}async bulkUpdateState(Q,$){let J=Q.configurable?.[g]??this.checkpointer;if(!J)throw new uQ("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});if($.length===0)throw Error("No supersteps provided");if($.some((Y)=>Y.updates.length===0))throw Error("No updates provided");let Z=Q.configurable?.checkpoint_ns??"";if(Z!==""&&Q.configurable?.[g]===void 0){let Y=s0(Z);for await(let[,X]of this.getSubgraphsAsync(Y,!0))return await X.bulkUpdateState(J0(Q,{[g]:J}),$);throw Error(`Subgraph "${Y}" not found`)}let q=async(Y,X)=>{let B=this.config?UQ(this.config,Y):Y,F=await J.getTuple(B),W=F!==void 0?fQ(F.checkpoint):U0(),L={...F?.checkpoint.channel_versions},H=F?.metadata?.step??-1,j=J0(B,{checkpoint_ns:B.configurable?.checkpoint_ns??""}),V=B.metadata??{};if(F?.config.configurable)j=J0(B,F.config.configurable),V={...F.metadata,...V};let{values:G,asNode:M}=X[0];if(G==null&&M===void 0){if(X.length>1)throw new b("Cannot create empty checkpoint with multiple updates");return iQ(await J.put(j,LQ(W,void 0,H),{source:"update",step:H+1,parents:F?.metadata?.parents??{}},{}),F?F.metadata:void 0)}let O=pQ(this.channels,W);if(G===null&&M===A){if(X.length>1)throw new b("Cannot apply multiple updates when clearing state");if(F){let D=nQ(W,F.pendingWrites||[],this.nodes,O,F.config,!0,{step:(F.metadata?.step??-1)+1,checkpointer:J,store:this.store}),x=(F.pendingWrites||[]).filter((T)=>T[0]===n).map((T)=>T.slice(1));if(x.length>0)$Q(W,O,[{name:PQ,writes:x,triggers:[]}],J.getNextVersion.bind(J),this.triggerToNodes);for(let[T,K,C]of F.pendingWrites||[]){if([l,S,F8].includes(K))continue;if(!(T in D))continue;D[T].writes.push([K,C])}$Q(W,O,Object.values(D),J.getNextVersion.bind(J),this.triggerToNodes)}return iQ(await J.put(j,LQ(W,O,H),{...V,source:"update",step:H+1,parents:F?.metadata?.parents??{}},H0(L,W.channel_versions)),F?F.metadata:void 0)}if(M===W$){if(X.length>1)throw new b("Cannot copy checkpoint with multiple updates");if(F==null)throw new b("Cannot copy a non-existent checkpoint");let D=(K)=>{if(!Array.isArray(K))return!1;if(K.length===0)return!1;return K.every((C)=>Array.isArray(C)&&C.length===2)},x=LQ(W,void 0,H),T=await J.put(F.parentConfig??J0(F.config,{checkpoint_id:void 0}),x,{source:"fork",step:H+1,parents:F.metadata?.parents??{}},{});if(D(G)){let K=nQ(x,F.pendingWrites,this.nodes,O,T,!1,{step:H+2}),C=Object.values(K).reduce((i,{name:C0,id:M8})=>{return i[C0]??=[],i[C0].push({id:M8}),i},{}),h=G.reduce((i,C0)=>{let[M8,G0]=C0;i[G0]??=[];let O1=i[G0].length,w1=C[G0]?.[O1]?.id;return i[G0].push({values:M8,asNode:G0,taskId:w1}),i},{});return q(iQ(T,F.metadata),Object.values(h).flat())}return iQ(T,F.metadata)}if(M===PQ){if(X.length>1)throw new b("Cannot apply multiple updates when updating as input");let D=await GQ(Q8(this.inputChannels,G));if(D.length===0)throw new b(`Received no input writes for ${JSON.stringify(this.inputChannels,null,2)}`);$Q(W,O,[{name:PQ,writes:D,triggers:[]}],J.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let x=F?.metadata?.step!=null?F.metadata.step+1:-1,T=await J.put(j,LQ(W,O,x),{source:"input",step:x,parents:F?.metadata?.parents??{}},H0(L,W.channel_versions));return await J.putWrites(T,D,rQ(PQ,W.id)),iQ(T,F?F.metadata:void 0)}if(B.configurable?.checkpoint_id===void 0&&F?.pendingWrites!==void 0&&F.pendingWrites.length>0){let D=nQ(W,F.pendingWrites,this.nodes,O,F.config,!0,{store:this.store,checkpointer:this.checkpointer,step:(F.metadata?.step??-1)+1}),x=(F.pendingWrites??[]).filter((K)=>K[0]===n).map((K)=>K.slice(1));if(x.length>0)$Q(F.checkpoint,O,[{name:PQ,writes:x,triggers:[]}],void 0,this.triggerToNodes);for(let[K,C,h]of F.pendingWrites){if([l,S,F8].includes(C)||D[K]===void 0)continue;D[K].writes.push([C,h])}let T=Object.values(D).filter((K)=>{return K.writes.length>0});if(T.length>0)$Q(W,O,T,void 0,this.triggerToNodes)}let I=Object.values(W.versions_seen).map((D)=>{return Object.values(D)}).flat().find((D)=>!!D),w=[];if(X.length===1){let{values:D,asNode:x,taskId:T}=X[0];if(x===void 0&&Object.keys(this.nodes).length===1)[x]=Object.keys(this.nodes);else if(x===void 0&&I===void 0){if(typeof this.inputChannels==="string"&&this.nodes[this.inputChannels]!==void 0)x=this.inputChannels}else if(x===void 0){let K=Object.entries(W.versions_seen).map(([C,h])=>{return Object.values(h).map((i)=>{return[i,C]})}).flat().filter(([C,h])=>h!==S).sort(([C],[h])=>X1(C,h));if(K){if(K.length===1)x=K[0][1];else if(K[K.length-1][0]!==K[K.length-2][0])x=K[K.length-1][1]}}if(x===void 0)throw new b('Ambiguous update, specify "asNode"');w.push({values:D,asNode:x,taskId:T})}else for(let{asNode:D,values:x,taskId:T}of X){if(D==null)throw new b('"asNode" is required when applying multiple updates');w.push({values:x,asNode:D,taskId:T})}let N=[];for(let{asNode:D,values:x,taskId:T}of w){if(this.nodes[D]===void 0)throw new b(`Node "${D.toString()}" does not exist`);let K=this.nodes[D].getWriters();if(!K.length)throw new b(`No writers found for node "${D.toString()}"`);N.push({name:D,input:x,proc:K.length>1?Z0.from(K,{omitSequenceTags:!0}):K[0],writes:[],triggers:[S],id:T??rQ(S,W.id),writers:[]})}for(let D of N)await D.proc.invoke(D.input,cQ({...B,store:B?.store??this.store},{runName:B.runName??`${this.getName()}UpdateState`,configurable:{[HQ]:(x)=>D.writes.push(...x),[RQ]:(x,T=!1)=>S0(W,O,D,x,T)}}));for(let D of N){let x=D.writes.filter((T)=>T[0]!==r);if(F!==void 0&&x.length>0)await J.putWrites(j,x,D.id)}$Q(W,O,N,J.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let _=H0(L,W.channel_versions),f=await J.put(j,LQ(W,O,H+1),{source:"update",step:H+1,parents:F?.metadata?.parents??{}},_);for(let D of N){let x=D.writes.filter((T)=>T[0]===r);if(x.length>0)await J.putWrites(f,x,D.id)}return iQ(f,F?F.metadata:void 0)},z=Q;for(let{updates:Y}of $)z=await q(z,Y);return z}async updateState(Q,$,J){return this.bulkUpdateState(Q,[{updates:[{values:$,asNode:J}]}])}_defaults(Q){let{debug:$,streamMode:J,inputKeys:Z,outputKeys:q,interruptAfter:z,interruptBefore:Y,...X}=Q,B=!0,F=$!==void 0?$:this.debug,W=q;if(W===void 0)W=this.streamChannelsAsIs;else o8(W,this.channels);let L=Z;if(L===void 0)L=this.inputChannels;else o8(L,this.channels);let H=Y??this.interruptBefore??[],j=z??this.interruptAfter??[],V;if(J!==void 0)V=Array.isArray(J)?J:[J],B=typeof J==="string";else{if(Q.configurable?.[X0]!==void 0)V=["values"];else V=this.streamMode;B=!0}let G;if(this.checkpointer===!1)G=void 0;else if(Q!==void 0&&Q.configurable?.[g]!==void 0)G=Q.configurable[g];else if(this.checkpointer===!0)throw Error("checkpointer: true cannot be used for root graphs.");else G=this.checkpointer;let M=Q.store??this.store,O=Q.cache??this.cache;if(Q.durability!=null&&Q.checkpointDuring!=null)throw Error("Cannot use both `durability` and `checkpointDuring` at the same time.");let I=(()=>{if(Q.checkpointDuring==null)return;if(Q.checkpointDuring===!1)return"exit";return"async"})(),w=Q.durability??I??Q?.configurable?.[L$]??"async";return[F,V,L,W,X,H,j,G,M,B,O,w]}async stream(Q,$){let J=new AbortController,Z={recursionLimit:this.config?.recursionLimit,...$,signal:V0($?.signal,J.signal).signal},q=await super.stream(Q,Z);return new m8($?.encoding==="text/event-stream"?n$(q):q,J)}streamEvents(Q,$,J){let Z=new AbortController,q={recursionLimit:this.config?.recursionLimit,...$,callbacks:v$(this.config?.callbacks,$?.callbacks),signal:V0($?.signal,Z.signal).signal};return new m8(super.streamEvents(Q,q,J),Z)}async _validateInput(Q){return Q}async _validateContext(Q){return Q}async*_streamIterator(Q,$){let J="version"in($??{})?void 0:$?.encoding??void 0,Z=$?.subgraphs,q=T0(this.config,$);if(q.recursionLimit===void 0||q.recursionLimit<1)throw Error('Passed "recursionLimit" must be at least 1.');if(this.checkpointer!==void 0&&this.checkpointer!==!1&&q.configurable===void 0)throw Error('Checkpointer requires one or more of the following "configurable" keys: "thread_id", "checkpoint_ns", "checkpoint_id"');let z=await this._validateInput(Q),{runId:Y,...X}=q,[B,F,,W,L,H,j,V,G,M,O,I]=this._defaults(X);if(typeof L.context<"u")L.context=await this._validateContext(L.context);else L.configurable=await this._validateContext(L.configurable);let w=new z8({modes:new Set(F)});if(this.checkpointer===!0){L.configurable??={};let K=L.configurable[FQ]??"";L.configurable[FQ]=K.split(k).map((C)=>C.split(e)[0]).join(k)}if(F.includes("messages")){let K=new J1((h)=>w.push(h)),{callbacks:C}=L;if(C===void 0)L.callbacks=[K];else if(Array.isArray(C))L.callbacks=C.concat(K);else{let h=C.copy();h.addHandler(K,!0),L.callbacks=h}}L.writer??=(K)=>{if(!F.includes("custom"))return;let C=_8()?.configurable?.[FQ]?.split(k).slice(0,-1);w.push([C??[],"custom",K])},L.interrupt??=this.userInterrupt??I8;let N=await(await Y1(L))?.handleChainStart(this.toJSON(),y$(Q,"input"),Y,void 0,void 0,void 0,L?.runName??this.getName()),_=x0(this.channels),f,D,T=(async()=>{try{f=await a$.initialize({input:z,config:L,checkpointer:V,nodes:this.nodes,channelSpecs:_,outputKeys:W,streamKeys:this.streamChannelsAsIs,store:G,cache:O,stream:w,interruptAfter:j,interruptBefore:H,manager:N,debug:this.debug,triggerToNodes:this.triggerToNodes,durability:I});let K=new Z1({loop:f,nodeFinished:L.configurable?.[j$]});if($?.subgraphs)f.config.configurable={...f.config.configurable,[w0]:f.stream};if(await this._runLoop({loop:f,runner:K,debug:B,config:L}),I==="sync")await Promise.all(f?.checkpointerPromises??[])}catch(K){D=K}finally{try{if(f)await f.store?.stop(),await f.cache?.stop();await Promise.all(f?.checkpointerPromises??[])}catch(K){D=D??K}if(D)w.error(D);else w.close()}})();try{for await(let K of w){if(K===void 0)throw Error("Data structure error.");let[C,h,i]=K;if(F.includes(h)){if(J==="text/event-stream"){if(Z)yield[C,h,i];else yield[null,h,i];continue}if(Z&&!M)yield[C,h,i];else if(!M)yield[h,i];else if(Z)yield[C,i];else yield i}}}catch(K){throw await N?.handleChainError(D),K}finally{await T}await N?.handleChainEnd(f?.output??{},Y,void 0,void 0,void 0)}async invoke(Q,$){let J=$?.streamMode??"values",Z={...$,outputKeys:$?.outputKeys??this.outputChannels,streamMode:J,encoding:void 0},q=[],z=await this.stream(Q,Z),Y=[],X;for await(let B of z)if(J==="values")if(B0(B))Y.push(B[S]);else X=B;else q.push(B);if(J==="values"){if(Y.length>0){let B=Y.flat(1);if(X==null)return{[S]:B};if(typeof X==="object")return{...X,[S]:B}}return X}return q}async _runLoop(Q){let{loop:$,runner:J,debug:Z,config:q}=Q,z;try{while(await $.tick({inputKeys:this.inputChannels})){for(let{task:Y}of await $._matchCachedWrites())$._outputWrites(Y.id,Y.writes,!0);if(Z)o$($.checkpointMetadata.step,$.channels,this.streamChannelsList);if(Z)q8($.step,Object.values($.tasks));await J.tick({timeout:this.stepTimeout,retryPolicy:this.retryPolicy,onStepWrite:(Y,X)=>{if(Z)c$(Y,X,this.streamChannelsList)},maxConcurrency:q.maxConcurrency,signal:q.signal})}if($.status==="out_of_steps")throw new k0([`Recursion limit of ${q.recursionLimit} reached`,"without hitting a stop condition. You can increase the",'limit by setting the "recursionLimit" config key.'].join(" "),{lc_error_code:"GRAPH_RECURSION_LIMIT"})}catch(Y){if(z=Y,!await $.finishAndHandleError(z))throw Y}finally{if(z===void 0)await $.finishAndHandleError()}}async clearCache(){await this.cache?.clear([])}};var MQ=class Q extends p{lc_graph_name="EphemeralValue";guard;value=[];constructor($=!0){super();this.guard=$}fromCheckpoint($){let J=new Q(this.guard);if(typeof $<"u")J.value=[$];return J}update($){if($.length===0){let J=this.value.length>0;return this.value=[],J}if($.length!==1&&this.guard)throw new b("EphemeralValue can only receive one value per step.");return this.value=[$[$.length-1]],!0}get(){if(this.value.length===0)throw new E;return this.value[0]}checkpoint(){if(this.value.length===0)throw new E;return this.value[0]}isAvailable(){return this.value.length!==0}};var n8=class{path;ends;constructor(Q){if(YQ.isRunnable(Q.path))this.path=Q.path;else this.path=SQ(Q.path).withConfig({runName:"Branch"});this.ends=Array.isArray(Q.pathMap)?Q.pathMap.reduce(($,J)=>{return $[J]=J,$},{}):Q.pathMap}run(Q,$){return m.registerWriter(new s({name:"<branch_run>",trace:!1,func:async(J,Z)=>{try{return await this._route(J,Z,Q,$)}catch(q){if(q.name===D0.unminifiable_name)console.warn(`[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.
|
|
14
|
+
NodeInterrupt should only be thrown inside a node, not in edge conditions.`);throw q}}}))}async _route(Q,$,J,Z){let q=await this.path.invoke(Z?Z($):Q,$);if(!Array.isArray(q))q=[q];let z;if(this.ends)z=q.map((Y)=>d(Y)?Y:this.ends[Y]);else z=q;if(z.some((Y)=>!Y))throw Error("Branch condition returned unknown or null destination");if(z.filter(d).some((Y)=>Y.node===A))throw new b("Cannot send a packet to the END node");return await J(z,$)??Q}},E0=class{nodes;edges;branches;entryPoint;compiled=!1;constructor(){this.nodes={},this.edges=new Set,this.branches={}}warnIfCompiled(Q){if(this.compiled)console.warn(Q)}get allEdges(){return this.edges}addNode(...Q){function $(Z){return Z.length>=1&&typeof Z[0]!=="string"}let J=$(Q)?Array.isArray(Q[0])?Q[0]:Object.entries(Q[0]):[[Q[0],Q[1],Q[2]]];if(J.length===0)throw Error("No nodes provided in `addNode`");for(let[Z,q,z]of J){for(let X of[k,e])if(Z.includes(X))throw Error(`"${X}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),Z in this.nodes)throw Error(`Node \`${Z}\` already present.`);if(Z===A)throw Error(`Node \`${Z}\` is reserved.`);let Y=SQ(q);this.nodes[Z]={runnable:Y,metadata:z?.metadata,subgraphs:b0(Y)?[Y]:z?.subgraphs,ends:z?.ends}}return this}addEdge(Q,$){if(this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),Q===A)throw Error("END cannot be a start node");if($===R)throw Error("START cannot be an end node");if(Array.from(this.edges).some(([J])=>J===Q)&&!("channels"in this))throw Error(`Already found path for ${Q}. For multiple edges, use StateGraph.`);return this.edges.add([Q,$]),this}addConditionalEdges(Q,$,J){let Z=typeof Q==="object"?Q:{source:Q,path:$,pathMap:J};if(this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),!YQ.isRunnable(Z.path)){let z=Array.isArray(Z.pathMap)?Z.pathMap.join(","):Object.keys(Z.pathMap??{}).join(",");Z.path=SQ(Z.path).withConfig({runName:`Branch<${Z.source}${z!==""?`,${z}`:""}>`.slice(0,63)})}let q=Z.path.getName()==="RunnableLambda"?"condition":Z.path.getName();if(this.branches[Z.source]&&this.branches[Z.source][q])throw Error(`Condition \`${q}\` already present for node \`${Q}\``);return this.branches[Z.source]??={},this.branches[Z.source][q]=new n8(Z),this}setEntryPoint(Q){return this.warnIfCompiled("Setting the entry point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(R,Q)}setFinishPoint(Q){return this.warnIfCompiled("Setting a finish point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(Q,A)}compile({checkpointer:Q,interruptBefore:$,interruptAfter:J,name:Z}={}){this.validate([...Array.isArray($)?$:[],...Array.isArray(J)?J:[]]);let q=new s8({builder:this,checkpointer:Q,interruptAfter:J,interruptBefore:$,autoValidate:!1,nodes:{},channels:{[R]:new MQ,[A]:new MQ},inputChannels:R,outputChannels:A,streamChannels:[],streamMode:"values",name:Z});for(let[z,Y]of Object.entries(this.nodes))q.attachNode(z,Y);for(let[z,Y]of this.edges)q.attachEdge(z,Y);for(let[z,Y]of Object.entries(this.branches))for(let[X,B]of Object.entries(Y))q.attachBranch(z,X,B);return q.validate()}validate(Q){let $=new Set([...this.allEdges].map(([Z,q])=>Z));for(let[Z]of Object.entries(this.branches))$.add(Z);for(let Z of $)if(Z!==R&&!(Z in this.nodes))throw Error(`Found edge starting at unknown node \`${Z}\``);let J=new Set([...this.allEdges].map(([Z,q])=>q));for(let[Z,q]of Object.entries(this.branches))for(let z of Object.values(q))if(z.ends!=null)for(let Y of Object.values(z.ends))J.add(Y);else{J.add(A);for(let Y of Object.keys(this.nodes))if(Y!==Z)J.add(Y)}for(let Z of Object.values(this.nodes))for(let q of Z.ends??[])J.add(q);for(let Z of Object.keys(this.nodes))if(!J.has(Z))throw new m0([`Node \`${Z}\` is not reachable.`,"","If you are returning Command objects from your node,",'make sure you are passing names of potential destination nodes as an "ends" array','into ".addNode(..., { ends: ["node1", "node2"] })".'].join(`
|
|
15
|
+
`),{lc_error_code:"UNREACHABLE_NODE"});for(let Z of J)if(Z!==A&&!(Z in this.nodes))throw Error(`Found edge ending at unknown node \`${Z}\``);if(Q){for(let Z of Q)if(!(Z in this.nodes))throw Error(`Interrupt node \`${Z}\` is not present`)}this.compiled=!0}},s8=class extends B8{builder;constructor({builder:Q,...$}){super($);this.builder=Q}attachNode(Q,$){this.channels[Q]=new MQ,this.nodes[Q]=new DQ({channels:[],triggers:[],metadata:$.metadata,subgraphs:$.subgraphs,ends:$.ends}).pipe($.runnable).pipe(new m([{channel:Q,value:qQ}],[y])),this.streamChannels.push(Q)}attachEdge(Q,$){if($===A){if(Q===R)throw Error("Cannot have an edge from START to END");this.nodes[Q].writers.push(new m([{channel:A,value:qQ}],[y]))}else this.nodes[$].triggers.push(Q),this.nodes[$].channels.push(Q)}attachBranch(Q,$,J){if(Q===R&&!this.nodes[R])this.nodes[R]=F1.subscribeTo(R,{tags:[y]});this.nodes[Q].pipe(J.run((q)=>{return new m(q.map((z)=>{if(d(z))return z;return{channel:z===A?A:`branch:${Q}:${$}:${z}`,value:qQ}}),[y])}));let Z=J.ends?Object.values(J.ends):Object.keys(this.nodes);for(let q of Z)if(q!==A){let z=`branch:${Q}:${$}:${q}`;this.channels[z]=new MQ,this.nodes[q].triggers.push(z),this.nodes[q].channels.push(z)}}async getGraphAsync(Q){let $=Q?.xray,J=new r8,Z={[R]:J.addNode({schema:sQ.any()},R)},q={},z={};if($)z=Object.fromEntries((await GQ(this.getSubgraphsAsync())).filter((B)=>B1(B[1])));function Y(B,F,W,L=!1){if(F===A&&q[A]===void 0)q[A]=J.addNode({schema:sQ.any()},A);if(Z[B]===void 0)return;if(q[F]===void 0)throw Error(`End node ${F} not found!`);return J.addEdge(Z[B],q[F],W!==F?W:void 0,L)}for(let[B,F]of Object.entries(this.builder.nodes)){let W=t(B),L=F.runnable,H=F.metadata??{};if(this.interruptBefore?.includes(B)&&this.interruptAfter?.includes(B))H.__interrupt="before,after";else if(this.interruptBefore?.includes(B))H.__interrupt="before";else if(this.interruptAfter?.includes(B))H.__interrupt="after";if($){let j=typeof $==="number"?$-1:$,V=z[B]!==void 0?await z[B].getGraphAsync({...Q,xray:j}):L.getGraph(Q);if(V.trimFirstNode(),V.trimLastNode(),Object.keys(V.nodes).length>1){let O=function(w){return w?w.lc_runnable:!1},I=function(w,N){if(w!==void 0&&!i8(w))return w;else if(O(N))try{let _=N.getName();return _=_.startsWith("Runnable")?_.slice(8):_,_}catch(_){return N.getName()}else return N.name??"UnknownSchema"},[G,M]=J.extend(V,W);if(G===void 0)throw Error(`Could not extend subgraph "${B}" due to missing entrypoint.`);if(M!==void 0)Z[W]={name:I(M.id,M.data),...M};q[W]={name:I(G.id,G.data),...G}}else{let G=J.addNode(L,W,H);Z[W]=G,q[W]=G}}else{let j=J.addNode(L,W,H);Z[W]=j,q[W]=j}}let X=[...this.builder.allEdges].sort(([B],[F])=>{if(B<F)return-1;else if(F>B)return 1;else return 0});for(let[B,F]of X)Y(t(B),t(F));for(let[B,F]of Object.entries(this.builder.branches)){let W={...Object.fromEntries(Object.keys(this.builder.nodes).filter((L)=>L!==B).map((L)=>[t(L),t(L)])),[A]:A};for(let L of Object.values(F)){let H;if(L.ends!==void 0)H=L.ends;else H=W;for(let[j,V]of Object.entries(H))Y(t(B),t(V),j,!0)}}for(let[B,F]of Object.entries(this.builder.nodes))if(F.ends!==void 0)for(let W of F.ends)Y(t(B),t(W),void 0,!0);return J}getGraph(Q){let $=Q?.xray,J=new r8,Z={[R]:J.addNode({schema:sQ.any()},R)},q={},z={};if($)z=Object.fromEntries($0(this.getSubgraphs()).filter((B)=>B1(B[1])));function Y(B,F,W,L=!1){if(F===A&&q[A]===void 0)q[A]=J.addNode({schema:sQ.any()},A);return J.addEdge(Z[B],q[F],W!==F?W:void 0,L)}for(let[B,F]of Object.entries(this.builder.nodes)){let W=t(B),L=F.runnable,H=F.metadata??{};if(this.interruptBefore?.includes(B)&&this.interruptAfter?.includes(B))H.__interrupt="before,after";else if(this.interruptBefore?.includes(B))H.__interrupt="before";else if(this.interruptAfter?.includes(B))H.__interrupt="after";if($){let j=typeof $==="number"?$-1:$,V=z[B]!==void 0?z[B].getGraph({...Q,xray:j}):L.getGraph(Q);if(V.trimFirstNode(),V.trimLastNode(),Object.keys(V.nodes).length>1){let O=function(w){return w?w.lc_runnable:!1},I=function(w,N){if(w!==void 0&&!i8(w))return w;else if(O(N))try{let _=N.getName();return _=_.startsWith("Runnable")?_.slice(8):_,_}catch(_){return N.getName()}else return N.name??"UnknownSchema"},[G,M]=J.extend(V,W);if(G===void 0)throw Error(`Could not extend subgraph "${B}" due to missing entrypoint.`);if(M!==void 0)Z[W]={name:I(M.id,M.data),...M};q[W]={name:I(G.id,G.data),...G}}else{let G=J.addNode(L,W,H);Z[W]=G,q[W]=G}}else{let j=J.addNode(L,W,H);Z[W]=j,q[W]=j}}let X=[...this.builder.allEdges].sort(([B],[F])=>{if(B<F)return-1;else if(F>B)return 1;else return 0});for(let[B,F]of X)Y(t(B),t(F));for(let[B,F]of Object.entries(this.builder.branches)){let W={...Object.fromEntries(Object.keys(this.builder.nodes).filter((L)=>L!==B).map((L)=>[t(L),t(L)])),[A]:A};for(let L of Object.values(F)){let H;if(L.ends!==void 0)H=L.ends;else H=W;for(let[j,V]of Object.entries(H))Y(t(B),t(V),j,!0)}}return J}};function B1(Q){return typeof Q.attachNode==="function"&&typeof Q.attachEdge==="function"}function t(Q){if(Q==="subgraph")return`"${Q}"`;return Q}function IQ(Q){return typeof Q==="object"&&Q!==null&&"~standard"in Q&&typeof Q["~standard"]==="object"&&Q["~standard"]!==null&&"validate"in Q["~standard"]}function W1(Q){return typeof Q==="object"&&Q!==null&&"~standard"in Q&&typeof Q["~standard"]==="object"&&Q["~standard"]!==null&&"jsonSchema"in Q["~standard"]}function _Q(Q){if(W1(Q))try{return Q["~standard"].jsonSchema.input({target:"draft-07"})}catch{return}}function NQ(Q){if(Q==null)return;if(!IQ(Q))return;try{let $=Q["~standard"].validate(void 0);if($&&typeof $==="object"&&!(("then"in $)&&typeof $.then==="function")){let J=$;if(!J.issues){let Z=J.value;return()=>Z}}}catch{}}var t8=Symbol.for("langgraph.channel.missing"),y0=class Q extends p{lc_graph_name="UntrackedValue";guard;_value=t8;initialValueFactory;constructor($){super();if(this.guard=$?.guard??!0,this.initialValueFactory=$?.initialValueFactory,this.initialValueFactory)this._value=this.initialValueFactory()}fromCheckpoint($){return new Q({guard:this.guard,initialValueFactory:this.initialValueFactory})}update($){if($.length===0)return!1;if($.length!==1&&this.guard)throw new b("UntrackedValue(guard=true) can receive only one value per step. Use guard=false if you want to store any one of multiple values.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this._value=$[$.length-1],!0}get(){if(this._value===t8)throw new E;return this._value}checkpoint(){}isAvailable(){return this._value!==t8}};var a8=Symbol.for("langgraph.state.reduced_value"),BQ=class{[a8]=!0;valueSchema;inputSchema;reducer;jsonSchemaExtra;constructor(Q,$){this.reducer=$.reducer,this.jsonSchemaExtra=$.jsonSchemaExtra,this.valueSchema=Q,this.inputSchema="inputSchema"in $?$.inputSchema:Q,this.jsonSchemaExtra=$.jsonSchemaExtra}static isInstance(Q){return typeof Q==="object"&&Q!==null&&a8 in Q&&Q[a8]===!0}};var L1=Symbol.for("langgraph.state.untracked_value"),EQ=class{[L1]=!0;schema;guard;constructor(Q,$){this.schema=Q,this.guard=$?.guard??!0}static isInstance(Q){return typeof Q==="object"&&Q!==null&&L1 in Q}};var tQ=(Q,$)=>Q.size===$.size&&[...Q].every((J)=>$.has(J)),e8=class Q extends p{lc_graph_name="NamedBarrierValue";names;seen;constructor($){super();this.names=$,this.seen=new Set}fromCheckpoint($){let J=new Q(this.names);if(typeof $<"u")J.seen=new Set($);return J}update($){let J=!1;for(let Z of $)if(this.names.has(Z)){if(!this.seen.has(Z))this.seen.add(Z),J=!0}else throw new b(`Value ${JSON.stringify(Z)} not in names ${JSON.stringify(this.names)}`);return J}get(){if(!tQ(this.names,this.seen))throw new E}checkpoint(){return[...this.seen]}consume(){if(this.seen&&this.names&&tQ(this.seen,this.names))return this.seen=new Set,!0;return!1}isAvailable(){return!!this.names&&tQ(this.names,this.seen)}},Q$=class Q extends p{lc_graph_name="NamedBarrierValueAfterFinish";names;seen;finished;constructor($){super();this.names=$,this.seen=new Set,this.finished=!1}fromCheckpoint($){let J=new Q(this.names);if(typeof $<"u"){let[Z,q]=$;J.seen=new Set(Z),J.finished=q}return J}update($){let J=!1;for(let Z of $)if(this.names.has(Z)&&!this.seen.has(Z))this.seen.add(Z),J=!0;else if(!this.names.has(Z))throw new b(`Value ${JSON.stringify(Z)} not in names ${JSON.stringify(this.names)}`);return J}get(){if(!this.finished||!tQ(this.names,this.seen))throw new E}checkpoint(){return[[...this.seen],this.finished]}consume(){if(this.finished&&this.seen&&this.names&&tQ(this.seen,this.names))return this.seen=new Set,this.finished=!1,!0;return!1}finish(){if(!this.finished&&!!this.names&&tQ(this.names,this.seen))return this.finished=!0,!0;return!1}isAvailable(){return this.finished&&!!this.names&&tQ(this.names,this.seen)}};var $$=Symbol.for("langgraph.state.state_schema"),WQ=class{[$$]=!0;constructor(Q){this.fields=Q}getChannels(){let Q={};for(let[$,J]of Object.entries(this.fields))if(BQ.isInstance(J)){let Z=NQ(J.valueSchema);Q[$]=new wQ(J.reducer,Z)}else if(EQ.isInstance(J)){let Z=J.schema?NQ(J.schema):void 0;Q[$]=new y0({guard:J.guard,initialValueFactory:Z})}else if(IQ(J))Q[$]=new jQ(NQ(J));else throw Error(`Invalid state field "${$}": must be a schema, ReducedValue, UntrackedValue, or ManagedValue`);return Q}getJsonSchema(){let Q={},$=[];for(let[J,Z]of Object.entries(this.fields)){let q;if(BQ.isInstance(Z)){if(q=_Q(Z.valueSchema),Z.jsonSchemaExtra)q={...q??{},...Z.jsonSchemaExtra}}else if(EQ.isInstance(Z))q=Z.schema?_Q(Z.schema):void 0;else if(IQ(Z))q=_Q(Z);if(q){Q[J]=q;let z=!1;if(BQ.isInstance(Z))z=NQ(Z.valueSchema)!==void 0;else if(EQ.isInstance(Z))z=Z.schema?NQ(Z.schema)!==void 0:!1;else z=NQ(Z)!==void 0;if(!z)$.push(J)}}return{type:"object",properties:Q,required:$.length>0?$:void 0}}getInputJsonSchema(){let Q={};for(let[$,J]of Object.entries(this.fields)){let Z;if(BQ.isInstance(J))Z=_Q(J.inputSchema);else if(EQ.isInstance(J))Z=J.schema?_Q(J.schema):void 0;else if(IQ(J))Z=_Q(J);if(Z)Q[$]=Z}return{type:"object",properties:Q}}getChannelKeys(){return Object.entries(this.fields).map(([Q])=>Q)}getAllKeys(){return Object.keys(this.fields)}async validateInput(Q){if(Q==null||typeof Q!=="object")return Q;let $={};for(let[J,Z]of Object.entries(Q)){let q=this.fields[J];if(q===void 0){$[J]=Z;continue}let z;if(BQ.isInstance(q))z=q.inputSchema;else if(EQ.isInstance(q))z=q.schema;else if(IQ(q))z=q;if(z){let Y=await z["~standard"].validate(Z);if(Y.issues)throw Error(`Validation failed for field "${J}": ${JSON.stringify(Y.issues)}`);$[J]=Y.value}else $[J]=Z}return $}static isInstance(Q){return typeof Q==="object"&&Q!==null&&$$ in Q&&Q[$$]===!0}};var j8="__remove_all__";function mQ(Q,$){let J=Array.isArray(Q)?Q:[Q],Z=Array.isArray($)?$:[$],q=J.map(L8),z=Z.map(L8);for(let W of q)if(W.id===null||W.id===void 0)W.id=J$(),W.lc_kwargs.id=W.id;let Y;for(let W=0;W<z.length;W+=1){let L=z[W];if(L.id===null||L.id===void 0)L.id=J$(),L.lc_kwargs.id=L.id;if(W8.isInstance(L)&&L.id===j8)Y=W}if(Y!=null)return z.slice(Y+1);let X=[...q],B=new Map(X.map((W,L)=>[W.id,L])),F=new Set;for(let W of z){let L=B.get(W.id);if(L!==void 0)if(W8.isInstance(W))F.add(W.id);else F.delete(W.id),X[L]=W;else{if(W8.isInstance(W))throw Error(`Attempting to delete a message with an ID that doesn't exist ('${W.id}')`);B.set(W.id,X.length),X.push(W)}}return X.filter((W)=>!F.has(W.id))}var G6=sQ.custom().default(()=>[]),D6=sQ.custom(),H8=new BQ(G6,{inputSchema:D6,reducer:mQ,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}});var K6="lg:",M6=class{_map=new Map;_extensionCache=new Map;get(Q){return this._map.get(Q)}extend(Q,$){let J=this.get(Q);this._map.set(Q,$(J))}remove(Q){return this._map.delete(Q),this}has(Q){return this._map.has(Q)}getChannelsForSchema(Q){let $={},J=q$(Q);for(let[Z,q]of Object.entries(J)){let z=this.get(q);if(z?.reducer)$[Z]=new wQ(z.reducer.fn,z.default);else $[Z]=new jQ(z?.default)}return $}getExtendedChannelSchemas(Q,$){if(Object.keys($).length===0)return Q;let J=Object.entries($).filter(([,z])=>z===!0).sort(([z],[Y])=>z.localeCompare(Y)).map(([z,Y])=>`${z}:${Y}`).join("|"),Z=this._extensionCache.get(J)??new Map;if(Z.has(Q))return Z.get(Q);let q=Q;if($.withReducerSchema||$.withJsonSchemaExtrasAsDescription){let z=Object.entries(q$(Q)).map(([Y,X])=>{let B=this.get(X),F=$.withReducerSchema?B?.reducer?.schema??X:X;if($.withJsonSchemaExtrasAsDescription&&B?.jsonSchemaExtra){let W=Z$(F)??Z$(X),L=JSON.stringify({...B.jsonSchemaExtra,description:W});F=F.describe(`${K6}${L}`)}return[Y,F]});if(q=V1(Q,Object.fromEntries(z)),H1(q))q._def.unknownKeys="strip"}if($.asPartial)q=V8(q);return Z.set(Q,q),this._extensionCache.set(J,Z),q}},v0=new M6;function G1(Q,$){if($.reducer&&!$.default){let J=U1(Q);if(J!=null)$.default=J}if($.reducer){let J=Object.assign(Q,{lg_reducer_schema:$.reducer?.schema??Q});return v0.extend(J,()=>$),J}else return v0.extend(Q,()=>$),Q}function z0(Q){if(Q==null)return!1;if(WQ.isInstance(Q))return!0;if(XQ(Q))return!0;if(typeof Q==="object"&&"lc_graph_name"in Q&&Q.lc_graph_name==="AnnotationRoot")return!0;if(typeof Q==="object"&&!Array.isArray(Q)&&Object.keys(Q).length>0&&Object.values(Q).every(($)=>typeof $==="function"||A8($)))return!0;return!1}function D1(Q){if(typeof Q!=="object"||Q==null)return!1;let $=Q,J="state"in $&&z0($.state),Z="stateSchema"in $&&z0($.stateSchema),q="input"in $&&z0($.input);if(!J&&!Z&&!q)return!1;if("input"in $&&$.input!=null&&!z0($.input))return!1;if("output"in $&&$.output!=null&&!z0($.output))return!1;return!0}var hQ="__root__",G8=Symbol.for("langgraph.state.partial"),D8=class extends E0{channels={};waitingEdges=new Set;_schemaDefinition;_schemaRuntimeDefinition;_inputDefinition;_inputRuntimeDefinition;_outputDefinition;_outputRuntimeDefinition;_schemaDefinitions=new Map;_metaRegistry=v0;_configSchema;_configRuntimeSchema;_interrupt;_writer;constructor(Q,$){super();let J=this._normalizeToStateGraphInit(Q,$),Z=J.state??J.stateSchema??J.input;if(!Z)throw new Y0;let q=this._getChannelsFromSchema(Z);if(this._schemaDefinition=q,WQ.isInstance(Z))this._schemaRuntimeDefinition=Z;else if(XQ(Z))this._schemaRuntimeDefinition=Z;if(J.input)if(WQ.isInstance(J.input))this._inputRuntimeDefinition=J.input;else if(XQ(J.input))this._inputRuntimeDefinition=J.input;else this._inputRuntimeDefinition=G8;else this._inputRuntimeDefinition=G8;if(J.output)if(WQ.isInstance(J.output))this._outputRuntimeDefinition=J.output;else if(XQ(J.output))this._outputRuntimeDefinition=J.output;else this._outputRuntimeDefinition=this._schemaRuntimeDefinition;else this._outputRuntimeDefinition=this._schemaRuntimeDefinition;let z=J.input?this._getChannelsFromSchema(J.input):q,Y=J.output?this._getChannelsFromSchema(J.output):q;if(this._inputDefinition=z,this._outputDefinition=Y,this._addSchema(this._schemaDefinition),this._addSchema(this._inputDefinition),this._addSchema(this._outputDefinition),J.context){if(XQ(J.context))this._configRuntimeSchema=J.context}this._interrupt=J.interrupt,this._writer=J.writer}_normalizeToStateGraphInit(Q,$){if(D1(Q)){if(XQ($)||A0.isInstance($))return{...Q,context:$};let J=$;return{...Q,input:Q.input??J?.input,output:Q.output??J?.output,context:Q.context??J?.context,interrupt:Q.interrupt??J?.interrupt,writer:Q.writer??J?.writer,nodes:Q.nodes??J?.nodes}}if(z0(Q)){if(XQ($)||A0.isInstance($))return{state:Q,context:$};let J=$;return{state:Q,input:J?.input,output:J?.output,context:J?.context,interrupt:J?.interrupt,writer:J?.writer,nodes:J?.nodes}}if(A6(Q))return{state:x6(Q.channels)};throw new Y0}_getChannelsFromSchema(Q){if(WQ.isInstance(Q))return Q.getChannels();if(XQ(Q))return this._metaRegistry.getChannelsForSchema(Q);if(typeof Q==="object"&&"lc_graph_name"in Q&&Q.lc_graph_name==="AnnotationRoot")return Q.spec;if(typeof Q==="object"&&!Array.isArray(Q)&&Object.keys(Q).length>0)return Q;throw new Y0("Invalid schema type. Expected StateSchema, Zod object, AnnotationRoot, or StateDefinition.")}get allEdges(){return new Set([...this.edges,...Array.from(this.waitingEdges).flatMap(([Q,$])=>Q.map((J)=>[J,$]))])}_addSchema(Q){if(this._schemaDefinitions.has(Q))return;this._schemaDefinitions.set(Q,Q);for(let[$,J]of Object.entries(Q)){let Z;if(typeof J==="function")Z=J();else Z=J;if(this.channels[$]!==void 0){if(!this.channels[$].equals(Z)){if(Z.lc_graph_name!=="LastValue")throw Error(`Channel "${$}" already exists with a different type.`)}}else this.channels[$]=Z}}addNode(...Q){function $(Z){return Z.length>=1&&typeof Z[0]!=="string"}let J=$(Q)?Array.isArray(Q[0])?Q[0]:Object.entries(Q[0]).map(([Z,q])=>[Z,q]):[[Q[0],Q[1],Q[2]]];if(J.length===0)throw Error("No nodes provided in `addNode`");for(let[Z,q,z]of J){if(Z in this.channels)throw Error(`${Z} is already being used as a state attribute (a.k.a. a channel), cannot also be used as a node name.`);for(let W of[k,e])if(Z.includes(W))throw Error(`"${W}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),Z in this.nodes)throw Error(`Node \`${Z}\` already present.`);if(Z===A||Z===R)throw Error(`Node \`${Z}\` is reserved.`);let Y=this._schemaDefinition;if(z?.input!==void 0)Y=this._getChannelsFromSchema(z.input);this._addSchema(Y);let X;if(YQ.isRunnable(q))X=q;else if(typeof q==="function")X=new s({func:q,name:Z,trace:!1});else X=SQ(q);let B=z?.cachePolicy;if(typeof B==="boolean")B=B?{}:void 0;let F={runnable:X,retryPolicy:z?.retryPolicy,cachePolicy:B,metadata:z?.metadata,input:Y??this._schemaDefinition,subgraphs:b0(X)?[X]:z?.subgraphs,ends:z?.ends,defer:z?.defer};this.nodes[Z]=F}return this}addEdge(Q,$){if(typeof Q==="string")return super.addEdge(Q,$);if(this.compiled)console.warn("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.");for(let J of Q){if(J===A)throw Error("END cannot be a start node");if(!Object.keys(this.nodes).some((Z)=>Z===J))throw Error(`Need to add a node named "${J}" first`)}if($===A)throw Error("END cannot be an end node");if(!Object.keys(this.nodes).some((J)=>J===$))throw Error(`Need to add a node named "${$}" first`);return this.waitingEdges.add([Q,$]),this}addSequence(Q){let $=Array.isArray(Q)?Q:Object.entries(Q);if($.length===0)throw Error("Sequence requires at least one node.");let J;for(let[Z,q,z]of $){if(Z in this.nodes)throw Error(`Node names must be unique: node with the name "${Z}" already exists.`);let Y=Z;if(this.addNode(Y,q,z),J!=null)this.addEdge(J,Y);J=Y}return this}compile({checkpointer:Q,store:$,cache:J,interruptBefore:Z,interruptAfter:q,name:z,description:Y}={}){this.validate([...Array.isArray(Z)?Z:[],...Array.isArray(q)?q:[]]);let X=Object.keys(this._schemaDefinitions.get(this._outputDefinition)),B=X.length===1&&X[0]===hQ?hQ:X,F=Object.keys(this.channels),W=F.length===1&&F[0]===hQ?hQ:F,L=this._interrupt,H=new K8({builder:this,checkpointer:Q,interruptAfter:q,interruptBefore:Z,autoValidate:!1,nodes:{},channels:{...this.channels,[R]:new MQ},inputChannels:R,outputChannels:B,streamChannels:W,streamMode:"updates",store:$,cache:J,name:z,description:Y,userInterrupt:L});H.attachNode(R);for(let[j,V]of Object.entries(this.nodes))H.attachNode(j,V);H.attachBranch(R,R8,K1(),{withReader:!1});for(let[j]of Object.entries(this.nodes))H.attachBranch(j,R8,K1(),{withReader:!1});for(let[j,V]of this.edges)H.attachEdge(j,V);for(let[j,V]of this.waitingEdges)H.attachEdge(j,V);for(let[j,V]of Object.entries(this.branches))for(let[G,M]of Object.entries(V))H.attachBranch(j,G,M);return H.validate()}};function x6(Q){let $={};for(let[J,Z]of Object.entries(Q))if(J===hQ)$[J]=h0(Z);else $[J]=h0(Z);return $}var K8=class extends s8{description;_metaRegistry=v0;constructor({description:Q,...$}){super($);this.description=Q}attachNode(Q,$){let J;if(Q===R)J=Object.entries(this.builder._schemaDefinitions.get(this.builder._inputDefinition)).map(([X])=>X);else J=Object.keys(this.builder.channels);function Z(X){if(u(X)){if(X.graph===a.PARENT)return null;return X._updateAsTuples()}else if(Array.isArray(X)&&X.length>0&&X.some((B)=>u(B))){let B=[];for(let F of X)if(u(F)){if(F.graph===a.PARENT)continue;B.push(...F._updateAsTuples())}else B.push([hQ,F]);return B}else if(X!=null)return[[hQ,X]];return null}let q=Q;function z(X){if(!X)return null;else if(u(X)){if(X.graph===a.PARENT)return null;return X._updateAsTuples().filter(([B])=>J.includes(B))}else if(Array.isArray(X)&&X.length>0&&X.some(u)){let B=[];for(let F of X)if(u(F)){if(F.graph===a.PARENT)continue;B.push(...F._updateAsTuples().filter(([W])=>J.includes(W)))}else{let W=z(F);if(W)B.push(...W??[])}return B}else if(typeof X==="object"&&!Array.isArray(X))return Object.entries(X).filter(([B])=>J.includes(B));else{let B=Array.isArray(X)?"array":typeof X;throw new b(`Expected node "${q.toString()}" to return an object or an array containing at least one Command object, received ${B}`,{lc_error_code:"INVALID_GRAPH_NODE_RETURN_VALUE"})}}let Y=[{value:qQ,mapper:new s({func:J.length&&J[0]===hQ?Z:z,trace:!1,recurse:!1})}];if(Q===R)this.nodes[Q]=new DQ({tags:[y],triggers:[R],channels:[R],writers:[new m(Y,[y])]});else{let X=$?.input??this.builder._schemaDefinition,B=Object.fromEntries(Object.keys(this.builder._schemaDefinitions.get(X)).map((L)=>[L,L])),F=Object.keys(B).length===1&&hQ in B,W=`branch:to:${Q}`;this.channels[W]=$?.defer?new O8:new MQ(!1),this.nodes[Q]=new DQ({triggers:[W],channels:F?Object.keys(B):B,writers:[new m(Y,[y])],mapper:F?void 0:(L)=>{return Object.fromEntries(Object.entries(L).filter(([H])=>(H in B)))},bound:$?.runnable,metadata:$?.metadata,retryPolicy:$?.retryPolicy,cachePolicy:$?.cachePolicy,subgraphs:$?.subgraphs,ends:$?.ends})}}attachEdge(Q,$){if($===A)return;if(typeof Q==="string")this.nodes[Q].writers.push(new m([{channel:`branch:to:${$}`,value:null}],[y]));else if(Array.isArray(Q)){let J=`join:${Q.join("+")}:${$}`;this.channels[J]=this.builder.nodes[$].defer?new Q$(new Set(Q)):new e8(new Set(Q)),this.nodes[$].triggers.push(J);for(let Z of Q)this.nodes[Z].writers.push(new m([{channel:J,value:Z}],[y]))}}attachBranch(Q,$,J,Z={withReader:!0}){let q=async(z,Y)=>{let X=z.filter((F)=>F!==A);if(!X.length)return;let B=X.map((F)=>{if(d(F))return F;return{channel:F===A?F:`branch:to:${F}`,value:Q}});await m.doWrite({...Y,tags:(Y.tags??[]).concat([y])},B)};this.nodes[Q].writers.push(J.run(q,Z.withReader?(z)=>_$.doRead(z,this.streamChannels??this.outputChannels,!0):void 0))}async _validateInput(Q){if(Q==null)return Q;let $=this.builder._inputRuntimeDefinition,J=this.builder._schemaRuntimeDefinition;if(WQ.isInstance($)){if(u(Q)){let q=Q;if(Q.update)q.update=await $.validateInput(Array.isArray(Q.update)?Object.fromEntries(Q.update):Q.update);return q}return await $.validateInput(Q)}if($===G8&&WQ.isInstance(J)){if(u(Q)){let q=Q;if(Q.update)q.update=await J.validateInput(Array.isArray(Q.update)?Object.fromEntries(Q.update):Q.update);return q}return await J.validateInput(Q)}let Z=(()=>{let q=(z)=>{if(z==null)return;return this._metaRegistry.getExtendedChannelSchemas(z,{withReducerSchema:!0})};if(XQ($))return q($);if($===G8){if(XQ(J))return V8(q(J));return}})();if(u(Q)){let q=Q;if(Q.update&&Z!=null)q.update=U8(Z,Q.update);return q}if(Z!=null)return U8(Z,Q);return Q}isInterrupted(Q){return B0(Q)}async _validateContext(Q){let $=this.builder._configRuntimeSchema;if(XQ($))U8($,Q);return Q}};function A6(Q){return typeof Q==="object"&&Q!==null&&Q.channels!==void 0}function O6(Q){if(d(Q))return[Q];let $=[];if(u(Q))$.push(Q);else if(Array.isArray(Q))$.push(...Q.filter(u));let J=[];for(let Z of $){if(Z.graph===a.PARENT)throw new K0(Z);if(d(Z.goto))J.push(Z.goto);else if(typeof Z.goto==="string")J.push(Z.goto);else if(Array.isArray(Z.goto))J.push(...Z.goto)}return J}function K1(){return new n8({path:new s({func:O6,tags:[y],trace:!1,recurse:!1,name:"<control_branch>"})})}var z$=function($,J){let{name:Z,checkpointer:q,store:z,cache:Y}=typeof $==="string"?{name:$,checkpointer:void 0,store:void 0}:$;if(T$(J)||b$(J))throw Error("Generators are disallowed as entrypoints. For streaming responses, use config.write.");let X="updates",B=g$(Z,J);function F(j){return typeof j==="object"&&j!==null&&"__lg_type"in j&&j.__lg_type==="__pregel_final"}let W=new s({name:"pluckReturnValue",func:(j)=>{return F(j)?j.value:j}}),L=new s({name:"pluckSaveValue",func:(j)=>{return F(j)?j.save:j}}),H=new DQ({bound:B,triggers:[R],channels:[R],writers:[new m([{channel:A,value:qQ,mapper:W},{channel:eQ,value:qQ,mapper:L}],[y])]});return new B8({name:Z,checkpointer:q,nodes:{[Z]:H},channels:{[R]:new MQ,[A]:new jQ,[eQ]:new jQ},inputChannels:R,outputChannels:A,streamChannels:A,streamMode:X,store:z,cache:Y})};z$.final=function({value:$,save:J}){return{value:$,save:J,__lg_type:"__pregel_final"}};var M1=aQ.Root({messages:aQ({reducer:mQ,default:()=>[]})}),X$={reducer:{fn:mQ},jsonSchemaExtra:{langgraph_type:"messages"},default:()=>[]},x1=Y$.object({messages:G1(Y$.custom(),X$)});P$();
|
|
16
|
+
export{OQ as Lg,aQ as Mg,R as Ng,A as Og,lQ as Pg,a as Qg,u as Rg,i1 as Sg,I8 as Tg,j8 as Ug,v0 as Vg,G1 as Wg,D8 as Xg,M1 as Yg,X$ as Zg};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{q as f}from"./chunk-kym9tb01.js";import"./chunk-vfwbx331.js";import{O as C,Q as _}from"./chunk-55nx49pj.js";import{Ae as X,Be as Y,Ke as K,Oe as M,ye as g}from"./chunk-a90fm6gz.js";import{Ue as A}from"./chunk-jrepjpft.js";import{ug as R}from"./chunk-p0vzbr7s.js";import"./chunk-x552nspp.js";import"./chunk-48vkm1yn.js";import"./chunk-afhxxkmv.js";import"./chunk-43xrz4wp.js";import"./chunk-ac5t2ywn.js";import"./chunk-dcwnpdtk.js";import"./chunk-cbjnwrt7.js";import"./chunk-vh9zd1v3.js";import"./chunk-w2hbsa9j.js";import"./chunk-rztre6k0.js";import"./chunk-wpy5r9ma.js";import"./chunk-frhhpxxy.js";import"./chunk-h1enhch1.js";import"./chunk-hyf24r36.js";import"./chunk-hra0748z.js";import"./chunk-k38fjqj7.js";import{pq as Q}from"./chunk-dcs1r9as.js";var F=Q(g(),1);import{join as w}from"path";function $({type:G,enabled:J=!0}){return C({queryKey:G==="memories"?_.knowledge.memories():_.knowledge.skills(),queryFn:async()=>{let L=w(process.cwd(),".claude",G),N=w(process.env.HOME||"",".deepagents/code",G);try{if(G==="memories")return A(N,L).map((W)=>({...W,type:"memory"}));else return R(N,L).map((W)=>({...W,type:"skill"}))}catch(O){return console.warn(`Failed to load ${G}:`,O),[]}},enabled:J,staleTime:120000})}var H=Q(K(),1),S=(G)=>{return G.length>80?G.slice(0,80)+"...":G},k=({onClose:G})=>{let[J,L]=F.useState("memories"),N=F.useRef(L);F.default.useEffect(()=>{N.current=L},[L]);let{data:O=[]}=$({type:"memories",enabled:J==="memories"}),{data:W=[]}=$({type:"skills",enabled:J==="skills"}),U=F.useCallback(async()=>{return J==="memories"?O:W},[J,O,W]),q=F.useCallback((z,E,Z)=>{let V=S(z.description);return H.jsxDEV(X,{flexDirection:"column",paddingY:1,children:[H.jsxDEV(X,{children:H.jsxDEV(Y,{bold:!0,color:Z?"cyan":"gray",children:[E+1,". ",z.name]},void 0,!0,void 0,this)},void 0,!1,void 0,this),H.jsxDEV(X,{paddingY:1,children:H.jsxDEV(Y,{color:Z?"white":"gray",children:V},void 0,!1,void 0,this)},void 0,!1,void 0,this),H.jsxDEV(X,{children:H.jsxDEV(Y,{color:"cyan",dimColor:!Z,children:[f(z.path),z.category&&H.jsxDEV(Y,{color:"yellow",children:[" ",z.category]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},z.path,!0,void 0,this)},[]),I=F.useCallback((z)=>{console.log("Selected knowledge item:",z.name)},[]),P=F.useMemo(()=>[{id:"memory",label:"记忆",predicate:(z)=>z.type==="memory"},{id:"skill",label:"技能",predicate:(z)=>z.type==="skill"}],[]),B=F.useMemo(()=>({h:(z)=>{N.current("memories"),z.setActiveFilter("memory")},s:(z)=>{N.current("skills"),z.setActiveFilter("skill")}}),[]),h=F.useMemo(()=>({id:"knowledge",title:"知识库",icon:"\uD83D\uDCDA",dataSource:U,searchable:!0,searchFields:["name","description"],searchPlaceholder:"搜索知识库 (名称/描述/分类)...",filterable:!0,filters:P,defaultFilter:J==="memories"?"memory":"skill",itemHeight:8,visibleCount:3,renderItem:q,showCount:!0,onSelect:I,keyMap:B}),[U,P,q,I,B,J]);return H.jsxDEV(M,{config:h,onClose:G},void 0,!1,void 0,this)},l=k;export{l as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}
|
|
1
|
+
import{Xe as D}from"./chunk-62zh99t6.js";import{kf as p,nf as E,of as k,pf as C}from"./chunk-738m8242.js";import{Rf as F,Sf as G,Vf as P}from"./chunk-p0vzbr7s.js";import{Ng as _,Ug as L,Xg as N}from"./chunk-afhxxkmv.js";import{ri as K}from"./chunk-cbjnwrt7.js";import{Bj as x,Oj as R,xj as Y}from"./chunk-w2hbsa9j.js";import{oq as S}from"./chunk-k38fjqj7.js";import{pq as I}from"./chunk-dcs1r9as.js";function H($,f="Human",J="AI"){let q=[];for(let B of $){let U;if(B.type==="human")U=f;else if(B.type==="ai")U=J;else if(B.type==="system")U="System";else if(B.type==="tool")U="Tool";else if(B.type==="generic")U=B.role;else throw Error(`Got unsupported message type: ${B.type}`);let O=B.name?`${B.name}, `:"",Q=typeof B.content==="string"?B.content:JSON.stringify(B.content,null,2);q.push(`${U}: ${O}${Q}`)}return q.join(`
|
|
2
|
+
`)}var T=I(S(),1);import{promises as W}from"fs";import X from"path";var b=($)=>{return $?.replace(process.cwd(),".")||$||""};var v=K.object({summary_of_chat:K.string().describe("对话总结(300-500字):1) 完整复现对话的核心过程(任务背景→关键决策→解决方案→最终结果);2) 明确说明接下来要做什么(后续行动、待完成任务、需要用户确认的事项);3) 突出关键成果和交付物"),name:K.string().describe("记忆名称(kebab-case 格式)"),description:K.string().describe("对于这个记忆的中等长度描述(索引综述,200-500字符,包含背景、关键点、适用场景)"),tags:K.array(K.string()).describe("记忆标签"),category:K.enum(["architecture","bug-fix","workflow","configuration","optimization"]).describe("记忆分类"),created:K.string().describe("创建日期(ISO 格式:YYYY-MM-DD)"),last_updated:K.string().describe("最后更新日期(ISO 格式:YYYY-MM-DD)"),priority:K.enum(["high","medium","low"]).describe("优先级"),context_scope:K.enum(["user","project"]).describe("上下文范围"),content:K.string().describe("记忆内容(详细说明,包含代码示例)")}),u=`你是一个负责分析对话并提取关键信息的智能助手。
|
|
3
3
|
|
|
4
4
|
## 任务
|
|
5
5
|
|
|
@@ -227,27 +227,27 @@ middleware.forEach(m => m.wrapModelCall(req, handler))
|
|
|
227
227
|
3. **用户优先**:明确记录用户的指示和偏好
|
|
228
228
|
4. **精确具体**:使用具体的文件名、代码片段、配置项
|
|
229
229
|
5. **独立完整**:记忆应能独立理解,不依赖外部上下文
|
|
230
|
-
`;async function
|
|
230
|
+
`;async function V($,f){let J=[new Y(f),new Y("请分析这段对话,提取值得保存的信息。")],B=await G({model:$,tools:[],systemPrompt:u,responseFormat:F(v)}).invoke({messages:J});return await A(B.structuredResponse)}function w($,f){let J=$.toLowerCase().replace(/[^\u4e00-\u9fa5a-z0-9\s]/gi," ").split(/\s+/).filter((U)=>U.length>1).slice(0,4);if(J.length===0)return`memory-${Date.now()}-${f}`;let B=`${J.join("-")}-${Date.now()}-${f}`;return B.length>64?B.substring(0,61)+"...":B}function c($){return $.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function A($){if($.name.startsWith("no-memory-"))return`${$.summary_of_chat}
|
|
231
231
|
|
|
232
232
|
---
|
|
233
233
|
|
|
234
234
|
name: "${$.name}"
|
|
235
235
|
description: "${$.description}"
|
|
236
236
|
|
|
237
|
-
⚠️ 无重要信息,未保存记忆`;let f=X.join(process.cwd(),".claude/memories");await W.mkdir(f,{recursive:!0});let q=
|
|
238
|
-
`),O=U>0?$.content.substring(0,Math.min(U,100)):$.content.substring(0,Math.min(100,$.content.length)),Q={name:q,description:$.description.replace(/\n/g," "),tags:$.tags,category:$.category,created:$.created,last_updated:$.last_updated,priority:$.priority,context_scope:$.context_scope},
|
|
239
|
-
${
|
|
237
|
+
⚠️ 无重要信息,未保存记忆`;let f=X.join(process.cwd(),".claude/memories");await W.mkdir(f,{recursive:!0});let q=c($.name||w($.content,0))||w($.content,0),B=X.join(f,q);await W.mkdir(B,{recursive:!0});let U=$.content.indexOf(`
|
|
238
|
+
`),O=U>0?$.content.substring(0,Math.min(U,100)):$.content.substring(0,Math.min(100,$.content.length)),Q={name:q,description:$.description.replace(/\n/g," "),tags:$.tags,category:$.category,created:$.created,last_updated:$.last_updated,priority:$.priority,context_scope:$.context_scope},j=`---
|
|
239
|
+
${T.default.stringify(Q,{indent:2,lineWidth:0})}
|
|
240
240
|
---
|
|
241
241
|
|
|
242
242
|
# ${O}
|
|
243
243
|
|
|
244
244
|
${$.content}
|
|
245
|
-
`,
|
|
245
|
+
`,Z=X.join(B,"MEMORY.md");return await W.writeFile(Z,j,"utf-8"),`${$.summary_of_chat}
|
|
246
246
|
|
|
247
247
|
---
|
|
248
248
|
|
|
249
249
|
name: "${$.name}"
|
|
250
250
|
description: "${$.description}"
|
|
251
251
|
|
|
252
|
-
✓ 保存记忆: ${
|
|
253
|
-
export{
|
|
252
|
+
✓ 保存记忆: ${b(Z)}`}var z={smart_memory:async($)=>{let f=await E($.model_id,{modelProvider:$.provider_type,streamUsage:!0,enableThinking:$.enable_thinking??!0}),J=await V(f,H($.messages));return{switch_command:"",messages:[new x({id:L}),new R(J)]}}};async function M($,f,J,q){let B=await k($,f,J,q);J.thread_id=P(q);let U=await B.invoke(J,{recursionLimit:500,configurable:q.configurable,context:q.context});return{switch_command:"",task_store:U.task_store,messages:U.messages}}function h(){return new N(p).addNode("graph",async($,f)=>{let{switch_command:J}=$;if(J==="smart_memory")return z.smart_memory($);let q=D,B=await C(q),U=(J==="default"?"agents/default":J)||"agents/default";if(!B.includes(U))throw Error(`Unknown agent: ${J||"default"}. Available: ${B.join(", ")}`);return await M(U,q,$,f)}).addEdge(_,"graph").compile()}var Q$=h();
|
|
253
|
+
export{Q$ as Ve};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Te as a}from"./chunk-yqwxbcc7.js";import"./chunk-jrepjpft.js";import"./chunk-vh9zd1v3.js";import"./chunk-w2hbsa9j.js";import"./chunk-rztre6k0.js";import"./chunk-wpy5r9ma.js";import"./chunk-h1enhch1.js";import"./chunk-hyf24r36.js";import"./chunk-k38fjqj7.js";import"./chunk-dcs1r9as.js";export{a as MemoriesMiddleware};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{$l as HQ,$m as sQ,$n as p$,$o as s,$p as y1,Am as IQ,An as G6,Ao as h0,Ap as G1,Bm as kQ,Bn as J6,Bo as c0,Bp as J1,Cm as bQ,Cn as B6,Co as p0,Cp as B1,Dm as TQ,Do as q6,Dp as L1,Em as vQ,En as L6,Eo as d0,Ep as K1,Fl as H6,Fm as zQ,Fn as R,Fo as V,Fp as O1,Gl as H,Gm as jQ,Gn as U0,Go as C,Gp as D1,Hl as Y6,Hm as gQ,Hn as A6,Ho as F,Hp as M1,Il as JQ,Im as xQ,In as b$,Io as M,Ip as P1,Jl as g,Jm as ZQ,Jn as kA,Jo as Q$,Jp as C1,Kl as B$,Km as yQ,Kn as T$,Ko as q$,Kp as N1,Ll as JA,Lm as SQ,Ln as v$,Lo as H$,Lp as E1,Ml as G,Mm as uQ,Mn as z$,Mo as Y$,Mp as R1,Nl as aW,Nm as lQ,Nn as j$,No as b,Np as V1,Ol as UA,Om as fQ,On as vA,Oo as T,Op as F1,Pl as IA,Pm as oQ,Pn as g$,Po as E,Pp as U1,Ql as _6,Qm as hQ,Qn as x$,Qo as Z,Qp as e$,Rl as X6,Rm as cQ,Rn as Z$,Ro as y,Rp as I1,Sl as sW,Sm as pQ,Sn as y$,So as U,Sp as k1,Tm as dQ,Tn as S$,To as S,Tp as b1,Ul as AQ,Um as rQ,Un as u$,Uo as m,Up as T1,Vm as mQ,Vn as l$,Vo as e,Vp as v1,Wl as $Q,Wm as eQ,Wn as f$,Wo as i,Wp as z1,Xm as iQ,Xn as o$,Xo as n,Xp as j1,Yl as WQ,Ym as nQ,Yn as I0,Yo as a,Yp as g1,Zl as QQ,Zm as aQ,Zn as h$,Zo as t,Zp as x1,_l as qQ,_m as tQ,_n as c$,_o as _$,_p as Z1,am as YQ,an as A0,ao as d$,ap as AA,aq as i$,bm as _Q,bn as $0,bo as r$,bp as $A,bq as S1,cm as XQ,cn as W0,co as m$,cp as WA,cq as O6,dm as wQ,dn as Q0,do as K6,dp as QA,dq as I,em as GQ,en as q0,eo as mW,ep as qA,fm as z,fn as H0,fo as eW,fp as HA,gm as BQ,gn as Y0,go as iW,gp as r0,hm as I$,hn as _0,ho as nW,hp as m0,im as k$,in as X0,io as k0,ip as e0,jm as LQ,jn as w0,jo as $6,jp as i0,km as KQ,kn as G0,ko as b0,kp as n0,lm as OQ,ln as J0,lo as T0,lp as a0,mm as DQ,mn as B0,mo as v0,mp as t0,nm as MQ,nn as L0,no as z0,np as s0,om as PQ,on as K0,oo as j0,op as BA,pm as CQ,pn as O0,po as g0,pp as A1,qm as NQ,qn as D0,qo as W6,qp as U$,rm as EQ,rn as M0,ro as x0,rp as $1,sm as RQ,sn as P0,so as Q6,sp as W1,tm as VQ,tn as C0,to as Z0,tp as Q1,um as FQ,un as N0,uo as y0,up as q1,vm as cW,vn as E0,vo as S0,vp as H1,wm as pW,wn as R0,wo as u0,wp as Y1,xm as dW,xn as V0,xo as l0,xp as _1,ym as rW,yn as F0,yo as f0,yp as X1,zm as UQ,zn as w6,zo as o0,zp as w1}from"./chunk-wpy5r9ma.js";import{rq as r}from"./chunk-dcs1r9as.js";var v6={};r(v6,{xor:()=>b4,xid:()=>a1,void:()=>R4,uuidv7:()=>c1,uuidv6:()=>h1,uuidv4:()=>o1,uuid:()=>f1,util:()=>G,url:()=>p1,uppercase:()=>i,unknown:()=>v,union:()=>nA,undefined:()=>N4,ulid:()=>n1,uint64:()=>P4,uint32:()=>O4,tuple:()=>LW,trim:()=>WA,treeifyError:()=>_6,transform:()=>tA,toUpperCase:()=>qA,toLowerCase:()=>QA,toJSONSchema:()=>O6,templateLiteral:()=>o4,symbol:()=>C4,superRefine:()=>fW,success:()=>u4,stringbool:()=>i4,stringFormat:()=>X4,string:()=>bA,strictObject:()=>I4,startsWith:()=>a,slugify:()=>HA,size:()=>Z,setErrorMap:()=>N6,set:()=>g4,safeParseAsync:()=>D$,safeParse:()=>O$,safeEncodeAsync:()=>V$,safeEncode:()=>E$,safeDecodeAsync:()=>F$,safeDecode:()=>R$,registry:()=>L6,regexes:()=>z,regex:()=>m,refine:()=>lW,record:()=>KW,readonly:()=>gW,property:()=>_$,promise:()=>h4,prettifyError:()=>X6,preprocess:()=>a4,prefault:()=>IW,positive:()=>Q$,pipe:()=>GA,partialRecord:()=>v4,parseAsync:()=>K$,parse:()=>L$,overwrite:()=>AA,optional:()=>XA,object:()=>U4,number:()=>a$,nullish:()=>S4,nullable:()=>wA,null:()=>WW,normalize:()=>$A,nonpositive:()=>H$,nonoptional:()=>kW,nonnegative:()=>Y$,never:()=>iA,negative:()=>q$,nativeEnum:()=>x4,nanoid:()=>m1,nan:()=>l4,multipleOf:()=>b,minSize:()=>E,minLength:()=>U,mime:()=>s,meta:()=>m4,maxSize:()=>T,maxLength:()=>y,map:()=>j4,mac:()=>A4,lte:()=>C,lt:()=>V,lowercase:()=>e,looseRecord:()=>z4,looseObject:()=>k4,locales:()=>G6,literal:()=>Z4,length:()=>S,lazy:()=>yW,ksuid:()=>t1,keyof:()=>F4,jwt:()=>_4,json:()=>n4,iso:()=>u,ipv6:()=>$4,ipv4:()=>s1,intersection:()=>JW,int64:()=>M4,int32:()=>K4,int:()=>TA,instanceof:()=>e4,includes:()=>n,httpUrl:()=>d1,hostname:()=>w4,hex:()=>G4,hash:()=>J4,guid:()=>l1,gte:()=>M,gt:()=>F,globalRegistry:()=>R,getErrorMap:()=>E6,function:()=>c4,fromJSONSchema:()=>s4,formatError:()=>IA,float64:()=>L4,float32:()=>B4,flattenError:()=>UA,file:()=>y4,exactOptional:()=>EW,enum:()=>aA,endsWith:()=>t,encodeAsync:()=>C$,encode:()=>M$,emoji:()=>r1,email:()=>u1,e164:()=>Y4,discriminatedUnion:()=>T4,describe:()=>r4,decodeAsync:()=>N$,decode:()=>P$,date:()=>V4,custom:()=>d4,cuid2:()=>i1,cuid:()=>e1,core:()=>I,config:()=>g,coerce:()=>hW,codec:()=>f4,clone:()=>JA,cidrv6:()=>Q4,cidrv4:()=>W4,check:()=>p4,catch:()=>vW,boolean:()=>t$,bigint:()=>D4,base64url:()=>H4,base64:()=>q4,array:()=>OA,any:()=>E4,_function:()=>c4,_default:()=>FW,_ZodString:()=>zA,ZodXor:()=>XW,ZodXID:()=>uA,ZodVoid:()=>YW,ZodUnknown:()=>qW,ZodUnion:()=>MA,ZodUndefined:()=>AW,ZodUUID:()=>N,ZodURL:()=>LA,ZodULID:()=>SA,ZodType:()=>X,ZodTuple:()=>BW,ZodTransform:()=>CW,ZodTemplateLiteral:()=>xW,ZodSymbol:()=>s$,ZodSuccess:()=>bW,ZodStringFormat:()=>B,ZodString:()=>f,ZodSet:()=>DW,ZodRecord:()=>PA,ZodRealError:()=>D,ZodReadonly:()=>jW,ZodPromise:()=>SW,ZodPrefault:()=>UW,ZodPipe:()=>$$,ZodOptional:()=>sA,ZodObject:()=>DA,ZodNumberFormat:()=>j,ZodNumber:()=>h,ZodNullable:()=>RW,ZodNull:()=>$W,ZodNonOptional:()=>A$,ZodNever:()=>HW,ZodNanoID:()=>xA,ZodNaN:()=>zW,ZodMap:()=>OW,ZodMAC:()=>n$,ZodLiteral:()=>MW,ZodLazy:()=>ZW,ZodKSUID:()=>lA,ZodJWT:()=>mA,ZodIssueCode:()=>C6,ZodIntersection:()=>GW,ZodISOTime:()=>VA,ZodISODuration:()=>FA,ZodISODateTime:()=>EA,ZodISODate:()=>RA,ZodIPv6:()=>oA,ZodIPv4:()=>fA,ZodGUID:()=>_A,ZodFunction:()=>uW,ZodFirstPartyTypeKind:()=>oW,ZodFile:()=>PW,ZodExactOptional:()=>NW,ZodError:()=>M6,ZodEnum:()=>l,ZodEmoji:()=>gA,ZodEmail:()=>jA,ZodE164:()=>rA,ZodDiscriminatedUnion:()=>wW,ZodDefault:()=>VW,ZodDate:()=>KA,ZodCustomStringFormat:()=>o,ZodCustom:()=>CA,ZodCodec:()=>W$,ZodCatch:()=>TW,ZodCUID2:()=>yA,ZodCUID:()=>ZA,ZodCIDRv6:()=>cA,ZodCIDRv4:()=>hA,ZodBoolean:()=>c,ZodBigIntFormat:()=>eA,ZodBigInt:()=>p,ZodBase64URL:()=>dA,ZodBase64:()=>pA,ZodArray:()=>_W,ZodAny:()=>QW,TimePrecision:()=>K6,NEVER:()=>H6,$output:()=>J6,$input:()=>B6,$brand:()=>Y6});var YA={};r(YA,{xor:()=>b4,xid:()=>a1,void:()=>R4,uuidv7:()=>c1,uuidv6:()=>h1,uuidv4:()=>o1,uuid:()=>f1,url:()=>p1,unknown:()=>v,union:()=>nA,undefined:()=>N4,ulid:()=>n1,uint64:()=>P4,uint32:()=>O4,tuple:()=>LW,transform:()=>tA,templateLiteral:()=>o4,symbol:()=>C4,superRefine:()=>fW,success:()=>u4,stringbool:()=>i4,stringFormat:()=>X4,string:()=>bA,strictObject:()=>I4,set:()=>g4,refine:()=>lW,record:()=>KW,readonly:()=>gW,promise:()=>h4,preprocess:()=>a4,prefault:()=>IW,pipe:()=>GA,partialRecord:()=>v4,optional:()=>XA,object:()=>U4,number:()=>a$,nullish:()=>S4,nullable:()=>wA,null:()=>WW,nonoptional:()=>kW,never:()=>iA,nativeEnum:()=>x4,nanoid:()=>m1,nan:()=>l4,meta:()=>m4,map:()=>j4,mac:()=>A4,looseRecord:()=>z4,looseObject:()=>k4,literal:()=>Z4,lazy:()=>yW,ksuid:()=>t1,keyof:()=>F4,jwt:()=>_4,json:()=>n4,ipv6:()=>$4,ipv4:()=>s1,intersection:()=>JW,int64:()=>M4,int32:()=>K4,int:()=>TA,instanceof:()=>e4,httpUrl:()=>d1,hostname:()=>w4,hex:()=>G4,hash:()=>J4,guid:()=>l1,function:()=>c4,float64:()=>L4,float32:()=>B4,file:()=>y4,exactOptional:()=>EW,enum:()=>aA,emoji:()=>r1,email:()=>u1,e164:()=>Y4,discriminatedUnion:()=>T4,describe:()=>r4,date:()=>V4,custom:()=>d4,cuid2:()=>i1,cuid:()=>e1,codec:()=>f4,cidrv6:()=>Q4,cidrv4:()=>W4,check:()=>p4,catch:()=>vW,boolean:()=>t$,bigint:()=>D4,base64url:()=>H4,base64:()=>q4,array:()=>OA,any:()=>E4,_function:()=>c4,_default:()=>FW,_ZodString:()=>zA,ZodXor:()=>XW,ZodXID:()=>uA,ZodVoid:()=>YW,ZodUnknown:()=>qW,ZodUnion:()=>MA,ZodUndefined:()=>AW,ZodUUID:()=>N,ZodURL:()=>LA,ZodULID:()=>SA,ZodType:()=>X,ZodTuple:()=>BW,ZodTransform:()=>CW,ZodTemplateLiteral:()=>xW,ZodSymbol:()=>s$,ZodSuccess:()=>bW,ZodStringFormat:()=>B,ZodString:()=>f,ZodSet:()=>DW,ZodRecord:()=>PA,ZodReadonly:()=>jW,ZodPromise:()=>SW,ZodPrefault:()=>UW,ZodPipe:()=>$$,ZodOptional:()=>sA,ZodObject:()=>DA,ZodNumberFormat:()=>j,ZodNumber:()=>h,ZodNullable:()=>RW,ZodNull:()=>$W,ZodNonOptional:()=>A$,ZodNever:()=>HW,ZodNanoID:()=>xA,ZodNaN:()=>zW,ZodMap:()=>OW,ZodMAC:()=>n$,ZodLiteral:()=>MW,ZodLazy:()=>ZW,ZodKSUID:()=>lA,ZodJWT:()=>mA,ZodIntersection:()=>GW,ZodIPv6:()=>oA,ZodIPv4:()=>fA,ZodGUID:()=>_A,ZodFunction:()=>uW,ZodFile:()=>PW,ZodExactOptional:()=>NW,ZodEnum:()=>l,ZodEmoji:()=>gA,ZodEmail:()=>jA,ZodE164:()=>rA,ZodDiscriminatedUnion:()=>wW,ZodDefault:()=>VW,ZodDate:()=>KA,ZodCustomStringFormat:()=>o,ZodCustom:()=>CA,ZodCodec:()=>W$,ZodCatch:()=>TW,ZodCUID2:()=>yA,ZodCUID:()=>ZA,ZodCIDRv6:()=>cA,ZodCIDRv4:()=>hA,ZodBoolean:()=>c,ZodBigIntFormat:()=>eA,ZodBigInt:()=>p,ZodBase64URL:()=>dA,ZodBase64:()=>pA,ZodArray:()=>_W,ZodAny:()=>QW});var NA={};r(NA,{uppercase:()=>i,trim:()=>WA,toUpperCase:()=>qA,toLowerCase:()=>QA,startsWith:()=>a,slugify:()=>HA,size:()=>Z,regex:()=>m,property:()=>_$,positive:()=>Q$,overwrite:()=>AA,normalize:()=>$A,nonpositive:()=>H$,nonnegative:()=>Y$,negative:()=>q$,multipleOf:()=>b,minSize:()=>E,minLength:()=>U,mime:()=>s,maxSize:()=>T,maxLength:()=>y,lte:()=>C,lt:()=>V,lowercase:()=>e,length:()=>S,includes:()=>n,gte:()=>M,gt:()=>F,endsWith:()=>t});var u={};r(u,{time:()=>G$,duration:()=>J$,datetime:()=>X$,date:()=>w$,ZodISOTime:()=>VA,ZodISODuration:()=>FA,ZodISODateTime:()=>EA,ZodISODate:()=>RA});var EA=H("ZodISODateTime",(A,$)=>{cW.init(A,$),B.init(A,$)});function X$(A){return mW(EA,A)}var RA=H("ZodISODate",(A,$)=>{pW.init(A,$),B.init(A,$)});function w$(A){return eW(RA,A)}var VA=H("ZodISOTime",(A,$)=>{dW.init(A,$),B.init(A,$)});function G$(A){return iW(VA,A)}var FA=H("ZodISODuration",(A,$)=>{rW.init(A,$),B.init(A,$)});function J$(A){return nW(FA,A)}var tW=(A,$)=>{aW.init(A,$),A.name="ZodError",Object.defineProperties(A,{format:{value:(W)=>IA(A,W)},flatten:{value:(W)=>UA(A,W)},addIssue:{value:(W)=>{A.issues.push(W),A.message=JSON.stringify(A.issues,B$,2)}},addIssues:{value:(W)=>{A.issues.push(...W),A.message=JSON.stringify(A.issues,B$,2)}},isEmpty:{get(){return A.issues.length===0}}})},M6=H("ZodError",tW),D=H("ZodError",tW,{Parent:Error});var L$=sW(D),K$=AQ(D),O$=$Q(D),D$=WQ(D),M$=QQ(D),P$=qQ(D),C$=HQ(D),N$=YQ(D),E$=_Q(D),R$=XQ(D),V$=wQ(D),F$=GQ(D);var X=H("ZodType",(A,$)=>{return I$.init(A,$),Object.assign(A["~standard"],{jsonSchema:{input:U$(A,"input"),output:U$(A,"output")}}),A.toJSONSchema=A1(A,{}),A.def=$,A.type=$.type,Object.defineProperty(A,"_def",{value:$}),A.check=(...W)=>{return A.clone(G.mergeDefs($,{checks:[...$.checks??[],...W.map((Q)=>typeof Q==="function"?{_zod:{check:Q,def:{check:"custom"},onattach:[]}}:Q)]}),{parent:!0})},A.with=A.check,A.clone=(W,Q)=>JA(A,W,Q),A.brand=()=>A,A.register=(W,Q)=>{return W.add(A,Q),A},A.parse=(W,Q)=>L$(A,W,Q,{callee:A.parse}),A.safeParse=(W,Q)=>O$(A,W,Q),A.parseAsync=async(W,Q)=>K$(A,W,Q,{callee:A.parseAsync}),A.safeParseAsync=async(W,Q)=>D$(A,W,Q),A.spa=A.safeParseAsync,A.encode=(W,Q)=>M$(A,W,Q),A.decode=(W,Q)=>P$(A,W,Q),A.encodeAsync=async(W,Q)=>C$(A,W,Q),A.decodeAsync=async(W,Q)=>N$(A,W,Q),A.safeEncode=(W,Q)=>E$(A,W,Q),A.safeDecode=(W,Q)=>R$(A,W,Q),A.safeEncodeAsync=async(W,Q)=>V$(A,W,Q),A.safeDecodeAsync=async(W,Q)=>F$(A,W,Q),A.refine=(W,Q)=>A.check(lW(W,Q)),A.superRefine=(W)=>A.check(fW(W)),A.overwrite=(W)=>A.check(AA(W)),A.optional=()=>XA(A),A.exactOptional=()=>EW(A),A.nullable=()=>wA(A),A.nullish=()=>XA(wA(A)),A.nonoptional=(W)=>kW(A,W),A.array=()=>OA(A),A.or=(W)=>nA([A,W]),A.and=(W)=>JW(A,W),A.transform=(W)=>GA(A,tA(W)),A.default=(W)=>FW(A,W),A.prefault=(W)=>IW(A,W),A.catch=(W)=>vW(A,W),A.pipe=(W)=>GA(A,W),A.readonly=()=>gW(A),A.describe=(W)=>{let Q=A.clone();return R.add(Q,{description:W}),Q},Object.defineProperty(A,"description",{get(){return R.get(A)?.description},configurable:!0}),A.meta=(...W)=>{if(W.length===0)return R.get(A);let Q=A.clone();return R.add(Q,W[0]),Q},A.isOptional=()=>A.safeParse(void 0).success,A.isNullable=()=>A.safeParse(null).success,A.apply=(W)=>W(A),A}),zA=H("_ZodString",(A,$)=>{k$.init(A,$),X.init(A,$),A._zod.processJSONSchema=(Q,q,_)=>$1(A,Q,q,_);let W=A._zod.bag;A.format=W.format??null,A.minLength=W.minimum??null,A.maxLength=W.maximum??null,A.regex=(...Q)=>A.check(m(...Q)),A.includes=(...Q)=>A.check(n(...Q)),A.startsWith=(...Q)=>A.check(a(...Q)),A.endsWith=(...Q)=>A.check(t(...Q)),A.min=(...Q)=>A.check(U(...Q)),A.max=(...Q)=>A.check(y(...Q)),A.length=(...Q)=>A.check(S(...Q)),A.nonempty=(...Q)=>A.check(U(1,...Q)),A.lowercase=(Q)=>A.check(e(Q)),A.uppercase=(Q)=>A.check(i(Q)),A.trim=()=>A.check(WA()),A.normalize=(...Q)=>A.check($A(...Q)),A.toLowerCase=()=>A.check(QA()),A.toUpperCase=()=>A.check(qA()),A.slugify=()=>A.check(HA())}),f=H("ZodString",(A,$)=>{k$.init(A,$),zA.init(A,$),A.email=(W)=>A.check(b$(jA,W)),A.url=(W)=>A.check(vA(LA,W)),A.jwt=(W)=>A.check(m$(mA,W)),A.emoji=(W)=>A.check(g$(gA,W)),A.guid=(W)=>A.check(kA(_A,W)),A.uuid=(W)=>A.check(T$(N,W)),A.uuidv4=(W)=>A.check(v$(N,W)),A.uuidv6=(W)=>A.check(z$(N,W)),A.uuidv7=(W)=>A.check(j$(N,W)),A.nanoid=(W)=>A.check(x$(xA,W)),A.guid=(W)=>A.check(kA(_A,W)),A.cuid=(W)=>A.check(Z$(ZA,W)),A.cuid2=(W)=>A.check(y$(yA,W)),A.ulid=(W)=>A.check(S$(SA,W)),A.base64=(W)=>A.check(p$(pA,W)),A.base64url=(W)=>A.check(d$(dA,W)),A.xid=(W)=>A.check(u$(uA,W)),A.ksuid=(W)=>A.check(l$(lA,W)),A.ipv4=(W)=>A.check(f$(fA,W)),A.ipv6=(W)=>A.check(o$(oA,W)),A.cidrv4=(W)=>A.check(h$(hA,W)),A.cidrv6=(W)=>A.check(c$(cA,W)),A.e164=(W)=>A.check(r$(rA,W)),A.datetime=(W)=>A.check(X$(W)),A.date=(W)=>A.check(w$(W)),A.time=(W)=>A.check(G$(W)),A.duration=(W)=>A.check(J$(W))});function bA(A){return U0(f,A)}var B=H("ZodStringFormat",(A,$)=>{LQ.init(A,$),zA.init(A,$)}),jA=H("ZodEmail",(A,$)=>{DQ.init(A,$),B.init(A,$)});function u1(A){return b$(jA,A)}var _A=H("ZodGUID",(A,$)=>{KQ.init(A,$),B.init(A,$)});function l1(A){return kA(_A,A)}var N=H("ZodUUID",(A,$)=>{OQ.init(A,$),B.init(A,$)});function f1(A){return T$(N,A)}function o1(A){return v$(N,A)}function h1(A){return z$(N,A)}function c1(A){return j$(N,A)}var LA=H("ZodURL",(A,$)=>{MQ.init(A,$),B.init(A,$)});function p1(A){return vA(LA,A)}function d1(A){return vA(LA,{protocol:/^https?$/,hostname:z.domain,...G.normalizeParams(A)})}var gA=H("ZodEmoji",(A,$)=>{PQ.init(A,$),B.init(A,$)});function r1(A){return g$(gA,A)}var xA=H("ZodNanoID",(A,$)=>{CQ.init(A,$),B.init(A,$)});function m1(A){return x$(xA,A)}var ZA=H("ZodCUID",(A,$)=>{NQ.init(A,$),B.init(A,$)});function e1(A){return Z$(ZA,A)}var yA=H("ZodCUID2",(A,$)=>{EQ.init(A,$),B.init(A,$)});function i1(A){return y$(yA,A)}var SA=H("ZodULID",(A,$)=>{RQ.init(A,$),B.init(A,$)});function n1(A){return S$(SA,A)}var uA=H("ZodXID",(A,$)=>{VQ.init(A,$),B.init(A,$)});function a1(A){return u$(uA,A)}var lA=H("ZodKSUID",(A,$)=>{FQ.init(A,$),B.init(A,$)});function t1(A){return l$(lA,A)}var fA=H("ZodIPv4",(A,$)=>{UQ.init(A,$),B.init(A,$)});function s1(A){return f$(fA,A)}var n$=H("ZodMAC",(A,$)=>{kQ.init(A,$),B.init(A,$)});function A4(A){return I0(n$,A)}var oA=H("ZodIPv6",(A,$)=>{IQ.init(A,$),B.init(A,$)});function $4(A){return o$(oA,A)}var hA=H("ZodCIDRv4",(A,$)=>{bQ.init(A,$),B.init(A,$)});function W4(A){return h$(hA,A)}var cA=H("ZodCIDRv6",(A,$)=>{TQ.init(A,$),B.init(A,$)});function Q4(A){return c$(cA,A)}var pA=H("ZodBase64",(A,$)=>{vQ.init(A,$),B.init(A,$)});function q4(A){return p$(pA,A)}var dA=H("ZodBase64URL",(A,$)=>{zQ.init(A,$),B.init(A,$)});function H4(A){return d$(dA,A)}var rA=H("ZodE164",(A,$)=>{jQ.init(A,$),B.init(A,$)});function Y4(A){return r$(rA,A)}var mA=H("ZodJWT",(A,$)=>{gQ.init(A,$),B.init(A,$)});function _4(A){return m$(mA,A)}var o=H("ZodCustomStringFormat",(A,$)=>{xQ.init(A,$),B.init(A,$)});function X4(A,$,W={}){return BA(o,A,$,W)}function w4(A){return BA(o,"hostname",z.hostname,A)}function G4(A){return BA(o,"hex",z.hex,A)}function J4(A,$){let W=$?.enc??"hex",Q=`${A}_${W}`,q=z[Q];if(!q)throw Error(`Unrecognized hash format: ${Q}`);return BA(o,Q,q,$)}var h=H("ZodNumber",(A,$)=>{ZQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(Q,q,_)=>W1(A,Q,q,_),A.gt=(Q,q)=>A.check(F(Q,q)),A.gte=(Q,q)=>A.check(M(Q,q)),A.min=(Q,q)=>A.check(M(Q,q)),A.lt=(Q,q)=>A.check(V(Q,q)),A.lte=(Q,q)=>A.check(C(Q,q)),A.max=(Q,q)=>A.check(C(Q,q)),A.int=(Q)=>A.check(TA(Q)),A.safe=(Q)=>A.check(TA(Q)),A.positive=(Q)=>A.check(F(0,Q)),A.nonnegative=(Q)=>A.check(M(0,Q)),A.negative=(Q)=>A.check(V(0,Q)),A.nonpositive=(Q)=>A.check(C(0,Q)),A.multipleOf=(Q,q)=>A.check(b(Q,q)),A.step=(Q,q)=>A.check(b(Q,q)),A.finite=()=>A;let W=A._zod.bag;A.minValue=Math.max(W.minimum??Number.NEGATIVE_INFINITY,W.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,A.maxValue=Math.min(W.maximum??Number.POSITIVE_INFINITY,W.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,A.isInt=(W.format??"").includes("int")||Number.isSafeInteger(W.multipleOf??0.5),A.isFinite=!0,A.format=W.format??null});function a$(A){return k0(h,A)}var j=H("ZodNumberFormat",(A,$)=>{yQ.init(A,$),h.init(A,$)});function TA(A){return b0(j,A)}function B4(A){return T0(j,A)}function L4(A){return v0(j,A)}function K4(A){return z0(j,A)}function O4(A){return j0(j,A)}var c=H("ZodBoolean",(A,$)=>{SQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>Q1(A,W,Q,q)});function t$(A){return g0(c,A)}var p=H("ZodBigInt",(A,$)=>{uQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(Q,q,_)=>q1(A,Q,q,_),A.gte=(Q,q)=>A.check(M(Q,q)),A.min=(Q,q)=>A.check(M(Q,q)),A.gt=(Q,q)=>A.check(F(Q,q)),A.gte=(Q,q)=>A.check(M(Q,q)),A.min=(Q,q)=>A.check(M(Q,q)),A.lt=(Q,q)=>A.check(V(Q,q)),A.lte=(Q,q)=>A.check(C(Q,q)),A.max=(Q,q)=>A.check(C(Q,q)),A.positive=(Q)=>A.check(F(BigInt(0),Q)),A.negative=(Q)=>A.check(V(BigInt(0),Q)),A.nonpositive=(Q)=>A.check(C(BigInt(0),Q)),A.nonnegative=(Q)=>A.check(M(BigInt(0),Q)),A.multipleOf=(Q,q)=>A.check(b(Q,q));let W=A._zod.bag;A.minValue=W.minimum??null,A.maxValue=W.maximum??null,A.format=W.format??null});function D4(A){return x0(p,A)}var eA=H("ZodBigIntFormat",(A,$)=>{lQ.init(A,$),p.init(A,$)});function M4(A){return Z0(eA,A)}function P4(A){return y0(eA,A)}var s$=H("ZodSymbol",(A,$)=>{fQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>H1(A,W,Q,q)});function C4(A){return S0(s$,A)}var AW=H("ZodUndefined",(A,$)=>{oQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>_1(A,W,Q,q)});function N4(A){return u0(AW,A)}var $W=H("ZodNull",(A,$)=>{hQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>Y1(A,W,Q,q)});function WW(A){return l0($W,A)}var QW=H("ZodAny",(A,$)=>{cQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>G1(A,W,Q,q)});function E4(){return f0(QW)}var qW=H("ZodUnknown",(A,$)=>{pQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>J1(A,W,Q,q)});function v(){return o0(qW)}var HW=H("ZodNever",(A,$)=>{dQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>w1(A,W,Q,q)});function iA(A){return h0(HW,A)}var YW=H("ZodVoid",(A,$)=>{rQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>X1(A,W,Q,q)});function R4(A){return c0(YW,A)}var KA=H("ZodDate",(A,$)=>{mQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(Q,q,_)=>B1(A,Q,q,_),A.min=(Q,q)=>A.check(M(Q,q)),A.max=(Q,q)=>A.check(C(Q,q));let W=A._zod.bag;A.minDate=W.minimum?new Date(W.minimum):null,A.maxDate=W.maximum?new Date(W.maximum):null});function V4(A){return p0(KA,A)}var _W=H("ZodArray",(A,$)=>{eQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>F1(A,W,Q,q),A.element=$.element,A.min=(W,Q)=>A.check(U(W,Q)),A.nonempty=(W)=>A.check(U(1,W)),A.max=(W,Q)=>A.check(y(W,Q)),A.length=(W,Q)=>A.check(S(W,Q)),A.unwrap=()=>A.element});function OA(A,$){return r0(_W,A,$)}function F4(A){let $=A._zod.def.shape;return aA(Object.keys($))}var DA=H("ZodObject",(A,$)=>{iQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>U1(A,W,Q,q),G.defineLazy(A,"shape",()=>{return $.shape}),A.keyof=()=>aA(Object.keys(A._zod.def.shape)),A.catchall=(W)=>A.clone({...A._zod.def,catchall:W}),A.passthrough=()=>A.clone({...A._zod.def,catchall:v()}),A.loose=()=>A.clone({...A._zod.def,catchall:v()}),A.strict=()=>A.clone({...A._zod.def,catchall:iA()}),A.strip=()=>A.clone({...A._zod.def,catchall:void 0}),A.extend=(W)=>{return G.extend(A,W)},A.safeExtend=(W)=>{return G.safeExtend(A,W)},A.merge=(W)=>G.merge(A,W),A.pick=(W)=>G.pick(A,W),A.omit=(W)=>G.omit(A,W),A.partial=(...W)=>G.partial(sA,A,W[0]),A.required=(...W)=>G.required(A$,A,W[0])});function U4(A,$){let W={type:"object",shape:A??{},...G.normalizeParams($)};return new DA(W)}function I4(A,$){return new DA({type:"object",shape:A,catchall:iA(),...G.normalizeParams($)})}function k4(A,$){return new DA({type:"object",shape:A,catchall:v(),...G.normalizeParams($)})}var MA=H("ZodUnion",(A,$)=>{nQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>e$(A,W,Q,q),A.options=$.options});function nA(A,$){return new MA({type:"union",options:A,...G.normalizeParams($)})}var XW=H("ZodXor",(A,$)=>{MA.init(A,$),aQ.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>e$(A,W,Q,q),A.options=$.options});function b4(A,$){return new XW({type:"union",options:A,inclusive:!1,...G.normalizeParams($)})}var wW=H("ZodDiscriminatedUnion",(A,$)=>{MA.init(A,$),tQ.init(A,$)});function T4(A,$,W){return new wW({type:"union",options:$,discriminator:A,...G.normalizeParams(W)})}var GW=H("ZodIntersection",(A,$)=>{sQ.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>I1(A,W,Q,q)});function JW(A,$){return new GW({type:"intersection",left:A,right:$})}var BW=H("ZodTuple",(A,$)=>{A0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>k1(A,W,Q,q),A.rest=(W)=>A.clone({...A._zod.def,rest:W})});function LW(A,$,W){let Q=$ instanceof I$,q=Q?W:$;return new BW({type:"tuple",items:A,rest:Q?$:null,...G.normalizeParams(q)})}var PA=H("ZodRecord",(A,$)=>{$0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>b1(A,W,Q,q),A.keyType=$.keyType,A.valueType=$.valueType});function KW(A,$,W){return new PA({type:"record",keyType:A,valueType:$,...G.normalizeParams(W)})}function v4(A,$,W){let Q=JA(A);return Q._zod.values=void 0,new PA({type:"record",keyType:Q,valueType:$,...G.normalizeParams(W)})}function z4(A,$,W){return new PA({type:"record",keyType:A,valueType:$,mode:"loose",...G.normalizeParams(W)})}var OW=H("ZodMap",(A,$)=>{W0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>R1(A,W,Q,q),A.keyType=$.keyType,A.valueType=$.valueType,A.min=(...W)=>A.check(E(...W)),A.nonempty=(W)=>A.check(E(1,W)),A.max=(...W)=>A.check(T(...W)),A.size=(...W)=>A.check(Z(...W))});function j4(A,$,W){return new OW({type:"map",keyType:A,valueType:$,...G.normalizeParams(W)})}var DW=H("ZodSet",(A,$)=>{Q0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>V1(A,W,Q,q),A.min=(...W)=>A.check(E(...W)),A.nonempty=(W)=>A.check(E(1,W)),A.max=(...W)=>A.check(T(...W)),A.size=(...W)=>A.check(Z(...W))});function g4(A,$){return new DW({type:"set",valueType:A,...G.normalizeParams($)})}var l=H("ZodEnum",(A,$)=>{q0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(Q,q,_)=>L1(A,Q,q,_),A.enum=$.entries,A.options=Object.values($.entries);let W=new Set(Object.keys($.entries));A.extract=(Q,q)=>{let _={};for(let w of Q)if(W.has(w))_[w]=$.entries[w];else throw Error(`Key ${w} not found in enum`);return new l({...$,checks:[],...G.normalizeParams(q),entries:_})},A.exclude=(Q,q)=>{let _={...$.entries};for(let w of Q)if(W.has(w))delete _[w];else throw Error(`Key ${w} not found in enum`);return new l({...$,checks:[],...G.normalizeParams(q),entries:_})}});function aA(A,$){let W=Array.isArray(A)?Object.fromEntries(A.map((Q)=>[Q,Q])):A;return new l({type:"enum",entries:W,...G.normalizeParams($)})}function x4(A,$){return new l({type:"enum",entries:A,...G.normalizeParams($)})}var MW=H("ZodLiteral",(A,$)=>{H0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>K1(A,W,Q,q),A.values=new Set($.values),Object.defineProperty(A,"value",{get(){if($.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return $.values[0]}})});function Z4(A,$){return new MW({type:"literal",values:Array.isArray(A)?A:[A],...G.normalizeParams($)})}var PW=H("ZodFile",(A,$)=>{Y0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>M1(A,W,Q,q),A.min=(W,Q)=>A.check(E(W,Q)),A.max=(W,Q)=>A.check(T(W,Q)),A.mime=(W,Q)=>A.check(s(Array.isArray(W)?W:[W],Q))});function y4(A){return m0(PW,A)}var CW=H("ZodTransform",(A,$)=>{_0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>E1(A,W,Q,q),A._zod.parse=(W,Q)=>{if(Q.direction==="backward")throw new JQ(A.constructor.name);W.addIssue=(_)=>{if(typeof _==="string")W.issues.push(G.issue(_,W.value,$));else{let w=_;if(w.fatal)w.continue=!1;w.code??(w.code="custom"),w.input??(w.input=W.value),w.inst??(w.inst=A),W.issues.push(G.issue(w))}};let q=$.transform(W.value,W);if(q instanceof Promise)return q.then((_)=>{return W.value=_,W});return W.value=q,W}});function tA(A){return new CW({type:"transform",transform:A})}var sA=H("ZodOptional",(A,$)=>{X0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>i$(A,W,Q,q),A.unwrap=()=>A._zod.def.innerType});function XA(A){return new sA({type:"optional",innerType:A})}var NW=H("ZodExactOptional",(A,$)=>{w0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>i$(A,W,Q,q),A.unwrap=()=>A._zod.def.innerType});function EW(A){return new NW({type:"optional",innerType:A})}var RW=H("ZodNullable",(A,$)=>{G0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>T1(A,W,Q,q),A.unwrap=()=>A._zod.def.innerType});function wA(A){return new RW({type:"nullable",innerType:A})}function S4(A){return XA(wA(A))}var VW=H("ZodDefault",(A,$)=>{J0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>z1(A,W,Q,q),A.unwrap=()=>A._zod.def.innerType,A.removeDefault=A.unwrap});function FW(A,$){return new VW({type:"default",innerType:A,get defaultValue(){return typeof $==="function"?$():G.shallowClone($)}})}var UW=H("ZodPrefault",(A,$)=>{B0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>j1(A,W,Q,q),A.unwrap=()=>A._zod.def.innerType});function IW(A,$){return new UW({type:"prefault",innerType:A,get defaultValue(){return typeof $==="function"?$():G.shallowClone($)}})}var A$=H("ZodNonOptional",(A,$)=>{L0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>v1(A,W,Q,q),A.unwrap=()=>A._zod.def.innerType});function kW(A,$){return new A$({type:"nonoptional",innerType:A,...G.normalizeParams($)})}var bW=H("ZodSuccess",(A,$)=>{K0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>P1(A,W,Q,q),A.unwrap=()=>A._zod.def.innerType});function u4(A){return new bW({type:"success",innerType:A})}var TW=H("ZodCatch",(A,$)=>{O0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>g1(A,W,Q,q),A.unwrap=()=>A._zod.def.innerType,A.removeCatch=A.unwrap});function vW(A,$){return new TW({type:"catch",innerType:A,catchValue:typeof $==="function"?$:()=>$})}var zW=H("ZodNaN",(A,$)=>{D0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>O1(A,W,Q,q)});function l4(A){return d0(zW,A)}var $$=H("ZodPipe",(A,$)=>{M0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>x1(A,W,Q,q),A.in=$.in,A.out=$.out});function GA(A,$){return new $$({type:"pipe",in:A,out:$})}var W$=H("ZodCodec",(A,$)=>{$$.init(A,$),P0.init(A,$)});function f4(A,$,W){return new W$({type:"pipe",in:A,out:$,transform:W.decode,reverseTransform:W.encode})}var jW=H("ZodReadonly",(A,$)=>{C0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>Z1(A,W,Q,q),A.unwrap=()=>A._zod.def.innerType});function gW(A){return new jW({type:"readonly",innerType:A})}var xW=H("ZodTemplateLiteral",(A,$)=>{N0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>D1(A,W,Q,q)});function o4(A,$){return new xW({type:"template_literal",parts:A,...G.normalizeParams($)})}var ZW=H("ZodLazy",(A,$)=>{V0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>S1(A,W,Q,q),A.unwrap=()=>A._zod.def.getter()});function yW(A){return new ZW({type:"lazy",getter:A})}var SW=H("ZodPromise",(A,$)=>{R0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>y1(A,W,Q,q),A.unwrap=()=>A._zod.def.innerType});function h4(A){return new SW({type:"promise",innerType:A})}var uW=H("ZodFunction",(A,$)=>{E0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>N1(A,W,Q,q)});function c4(A){return new uW({type:"function",input:Array.isArray(A?.input)?LW(A?.input):A?.input??OA(v()),output:A?.output??v()})}var CA=H("ZodCustom",(A,$)=>{F0.init(A,$),X.init(A,$),A._zod.processJSONSchema=(W,Q,q)=>C1(A,W,Q,q)});function p4(A){let $=new BQ({check:"custom"});return $._zod.check=A,$}function d4(A,$){return e0(CA,A??(()=>!0),$)}function lW(A,$={}){return i0(CA,A,$)}function fW(A){return n0(A)}var r4=a0,m4=t0;function e4(A,$={}){let W=new CA({type:"custom",check:"custom",fn:(Q)=>Q instanceof A,abort:!0,...G.normalizeParams($)});return W._zod.bag.Class=A,W._zod.check=(Q)=>{if(!(Q.value instanceof A))Q.issues.push({code:"invalid_type",expected:A.name,input:Q.value,inst:W,path:[...W._zod.def.path??[]]})},W}var i4=(...A)=>s0({Codec:W$,Boolean:c,String:f},...A);function n4(A){let $=yW(()=>{return nA([bA(A),a$(),t$(),WW(),OA($),KW(bA(),$)])});return $}function a4(A,$){return GA(tA(A),$)}var C6={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function N6(A){g({customError:A})}function E6(){return g().customError}var oW;(function(A){})(oW||(oW={}));var Y={...YA,...NA,iso:u},R6=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function V6(A,$){let W=A.$schema;if(W==="https://json-schema.org/draft/2020-12/schema")return"draft-2020-12";if(W==="http://json-schema.org/draft-07/schema#")return"draft-7";if(W==="http://json-schema.org/draft-04/schema#")return"draft-4";return $??"draft-2020-12"}function F6(A,$){if(!A.startsWith("#"))throw Error("External $ref is not supported, only local refs (#/...) are allowed");let W=A.slice(1).split("/").filter(Boolean);if(W.length===0)return $.rootSchema;let Q=$.version==="draft-2020-12"?"$defs":"definitions";if(W[0]===Q){let q=W[1];if(!q||!$.defs[q])throw Error(`Reference not found: ${A}`);return $.defs[q]}throw Error(`Reference not found: ${A}`)}function t4(A,$){if(A.not!==void 0){if(typeof A.not==="object"&&Object.keys(A.not).length===0)return Y.never();throw Error("not is not supported in Zod (except { not: {} } for never)")}if(A.unevaluatedItems!==void 0)throw Error("unevaluatedItems is not supported");if(A.unevaluatedProperties!==void 0)throw Error("unevaluatedProperties is not supported");if(A.if!==void 0||A.then!==void 0||A.else!==void 0)throw Error("Conditional schemas (if/then/else) are not supported");if(A.dependentSchemas!==void 0||A.dependentRequired!==void 0)throw Error("dependentSchemas and dependentRequired are not supported");if(A.$ref){let q=A.$ref;if($.refs.has(q))return $.refs.get(q);if($.processing.has(q))return Y.lazy(()=>{if(!$.refs.has(q))throw Error(`Circular reference not resolved: ${q}`);return $.refs.get(q)});$.processing.add(q);let _=F6(q,$),w=K(_,$);return $.refs.set(q,w),$.processing.delete(q),w}if(A.enum!==void 0){let q=A.enum;if($.version==="openapi-3.0"&&A.nullable===!0&&q.length===1&&q[0]===null)return Y.null();if(q.length===0)return Y.never();if(q.length===1)return Y.literal(q[0]);if(q.every((w)=>typeof w==="string"))return Y.enum(q);let _=q.map((w)=>Y.literal(w));if(_.length<2)return _[0];return Y.union([_[0],_[1],..._.slice(2)])}if(A.const!==void 0)return Y.literal(A.const);let W=A.type;if(Array.isArray(W)){let q=W.map((_)=>{let w={...A,type:_};return t4(w,$)});if(q.length===0)return Y.never();if(q.length===1)return q[0];return Y.union(q)}if(!W)return Y.any();let Q;switch(W){case"string":{let q=Y.string();if(A.format){let _=A.format;if(_==="email")q=q.check(Y.email());else if(_==="uri"||_==="uri-reference")q=q.check(Y.url());else if(_==="uuid"||_==="guid")q=q.check(Y.uuid());else if(_==="date-time")q=q.check(Y.iso.datetime());else if(_==="date")q=q.check(Y.iso.date());else if(_==="time")q=q.check(Y.iso.time());else if(_==="duration")q=q.check(Y.iso.duration());else if(_==="ipv4")q=q.check(Y.ipv4());else if(_==="ipv6")q=q.check(Y.ipv6());else if(_==="mac")q=q.check(Y.mac());else if(_==="cidr")q=q.check(Y.cidrv4());else if(_==="cidr-v6")q=q.check(Y.cidrv6());else if(_==="base64")q=q.check(Y.base64());else if(_==="base64url")q=q.check(Y.base64url());else if(_==="e164")q=q.check(Y.e164());else if(_==="jwt")q=q.check(Y.jwt());else if(_==="emoji")q=q.check(Y.emoji());else if(_==="nanoid")q=q.check(Y.nanoid());else if(_==="cuid")q=q.check(Y.cuid());else if(_==="cuid2")q=q.check(Y.cuid2());else if(_==="ulid")q=q.check(Y.ulid());else if(_==="xid")q=q.check(Y.xid());else if(_==="ksuid")q=q.check(Y.ksuid())}if(typeof A.minLength==="number")q=q.min(A.minLength);if(typeof A.maxLength==="number")q=q.max(A.maxLength);if(A.pattern)q=q.regex(new RegExp(A.pattern));Q=q;break}case"number":case"integer":{let q=W==="integer"?Y.number().int():Y.number();if(typeof A.minimum==="number")q=q.min(A.minimum);if(typeof A.maximum==="number")q=q.max(A.maximum);if(typeof A.exclusiveMinimum==="number")q=q.gt(A.exclusiveMinimum);else if(A.exclusiveMinimum===!0&&typeof A.minimum==="number")q=q.gt(A.minimum);if(typeof A.exclusiveMaximum==="number")q=q.lt(A.exclusiveMaximum);else if(A.exclusiveMaximum===!0&&typeof A.maximum==="number")q=q.lt(A.maximum);if(typeof A.multipleOf==="number")q=q.multipleOf(A.multipleOf);Q=q;break}case"boolean":{Q=Y.boolean();break}case"null":{Q=Y.null();break}case"object":{let q={},_=A.properties||{},w=new Set(A.required||[]);for(let[L,O]of Object.entries(_)){let k=K(O,$);q[L]=w.has(L)?k:k.optional()}if(A.propertyNames){let L=K(A.propertyNames,$),O=A.additionalProperties&&typeof A.additionalProperties==="object"?K(A.additionalProperties,$):Y.any();if(Object.keys(q).length===0){Q=Y.record(L,O);break}let k=Y.object(q).passthrough(),P=Y.looseRecord(L,O);Q=Y.intersection(k,P);break}if(A.patternProperties){let L=A.patternProperties,O=Object.keys(L),k=[];for(let x of O){let d=K(L[x],$),D6=Y.string().regex(new RegExp(x));k.push(Y.looseRecord(D6,d))}let P=[];if(Object.keys(q).length>0)P.push(Y.object(q).passthrough());if(P.push(...k),P.length===0)Q=Y.object({}).passthrough();else if(P.length===1)Q=P[0];else{let x=Y.intersection(P[0],P[1]);for(let d=2;d<P.length;d++)x=Y.intersection(x,P[d]);Q=x}break}let J=Y.object(q);if(A.additionalProperties===!1)Q=J.strict();else if(typeof A.additionalProperties==="object")Q=J.catchall(K(A.additionalProperties,$));else Q=J.passthrough();break}case"array":{let{prefixItems:q,items:_}=A;if(q&&Array.isArray(q)){let w=q.map((L)=>K(L,$)),J=_&&typeof _==="object"&&!Array.isArray(_)?K(_,$):void 0;if(J)Q=Y.tuple(w).rest(J);else Q=Y.tuple(w);if(typeof A.minItems==="number")Q=Q.check(Y.minLength(A.minItems));if(typeof A.maxItems==="number")Q=Q.check(Y.maxLength(A.maxItems))}else if(Array.isArray(_)){let w=_.map((L)=>K(L,$)),J=A.additionalItems&&typeof A.additionalItems==="object"?K(A.additionalItems,$):void 0;if(J)Q=Y.tuple(w).rest(J);else Q=Y.tuple(w);if(typeof A.minItems==="number")Q=Q.check(Y.minLength(A.minItems));if(typeof A.maxItems==="number")Q=Q.check(Y.maxLength(A.maxItems))}else if(_!==void 0){let w=K(_,$),J=Y.array(w);if(typeof A.minItems==="number")J=J.min(A.minItems);if(typeof A.maxItems==="number")J=J.max(A.maxItems);Q=J}else Q=Y.array(Y.any());break}default:throw Error(`Unsupported type: ${W}`)}if(A.description)Q=Q.describe(A.description);if(A.default!==void 0)Q=Q.default(A.default);return Q}function K(A,$){if(typeof A==="boolean")return A?Y.any():Y.never();let W=t4(A,$),Q=A.type||A.enum!==void 0||A.const!==void 0;if(A.anyOf&&Array.isArray(A.anyOf)){let J=A.anyOf.map((O)=>K(O,$)),L=Y.union(J);W=Q?Y.intersection(W,L):L}if(A.oneOf&&Array.isArray(A.oneOf)){let J=A.oneOf.map((O)=>K(O,$)),L=Y.xor(J);W=Q?Y.intersection(W,L):L}if(A.allOf&&Array.isArray(A.allOf))if(A.allOf.length===0)W=Q?W:Y.any();else{let J=Q?W:K(A.allOf[0],$),L=Q?0:1;for(let O=L;O<A.allOf.length;O++)J=Y.intersection(J,K(A.allOf[O],$));W=J}if(A.nullable===!0&&$.version==="openapi-3.0")W=Y.nullable(W);if(A.readOnly===!0)W=Y.readonly(W);let q={},_=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let J of _)if(J in A)q[J]=A[J];let w=["contentEncoding","contentMediaType","contentSchema"];for(let J of w)if(J in A)q[J]=A[J];for(let J of Object.keys(A))if(!R6.has(J))q[J]=A[J];if(Object.keys(q).length>0)$.registry.add(W,q);return W}function s4(A,$){if(typeof A==="boolean")return A?Y.any():Y.never();let W=V6(A,$?.defaultTarget),Q=A.$defs||A.definitions||{},q={version:W,defs:Q,refs:new Map,processing:new Set,rootSchema:A,registry:$?.registry??R};return K(A,q)}var hW={};r(hW,{string:()=>U6,number:()=>I6,date:()=>T6,boolean:()=>k6,bigint:()=>b6});function U6(A){return A6(f,A)}function I6(A){return $6(h,A)}function k6(A){return W6(c,A)}function b6(A){return Q6(p,A)}function T6(A){return q6(KA,A)}g(w6());
|
|
2
|
+
export{u as Wh,M6 as Xh,bA as Yh,p1 as Zh,a$ as _h,t$ as $h,WW as ai,E4 as bi,v as ci,OA as di,U4 as ei,k4 as fi,nA as gi,T4 as hi,JW as ii,KW as ji,aA as ki,Z4 as li,XA as mi,d4 as ni,a4 as oi,C6 as pi,hW as qi,v6 as ri};
|