zen-code 4.9.2 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +94 -128
- package/dist/chunk-075hks9v.js +1 -0
- package/dist/chunk-0fj768k4.js +112 -0
- package/dist/chunk-19mf2aa7.js +1 -0
- package/dist/chunk-1mq2jmfy.js +2 -0
- package/dist/chunk-1v863afn.js +278 -0
- package/dist/chunk-1vn8d8b8.js +1 -0
- package/dist/{chunk-hfypkhky.js → chunk-1w19w1bm.js} +1 -1
- package/dist/chunk-3dnayvgx.js +224 -0
- package/dist/chunk-4hg13vwj.js +1 -0
- package/dist/chunk-4scrkcqv.js +1 -0
- package/dist/chunk-54cdhhqm.js +1 -0
- package/dist/chunk-5m4yb9av.js +91 -0
- package/dist/chunk-5yd4ntp6.js +8 -0
- package/dist/{chunk-dxec2q4t.js → chunk-6scjjkn3.js} +1 -1
- package/dist/{chunk-hmemx3cw.js → chunk-7jatn15w.js} +2 -2
- package/dist/{chunk-0pss3s5r.js → chunk-7w9y11hj.js} +1 -1
- package/dist/chunk-7yzv6385.js +1 -0
- package/dist/{chunk-ce53j63y.js → chunk-875hayaj.js} +3 -3
- package/dist/chunk-8bs8r50r.js +1 -0
- package/dist/{chunk-x552nspp.js → chunk-8waww0j9.js} +2 -2
- package/dist/chunk-8ysg0rga.js +1 -0
- package/dist/chunk-9czhw5k6.js +4 -0
- package/dist/chunk-9tgp14v7.js +16 -0
- package/dist/{chunk-yndex7hs.js → chunk-a239dn0b.js} +1 -1
- package/dist/chunk-arv4h3h1.js +2 -0
- package/dist/chunk-b2551zfb.js +2 -0
- package/dist/chunk-b9emn03n.js +1 -0
- package/dist/chunk-bm7578sn.js +1 -0
- package/dist/{chunk-62zh99t6.js → chunk-bytq4kd1.js} +3 -125
- package/dist/chunk-c2wfgbj6.js +1 -0
- package/dist/{chunk-0zk0m93z.js → chunk-cef4vbtb.js} +1 -1
- package/dist/{chunk-hsev32dg.js → chunk-cnzhxgn5.js} +2 -2
- package/dist/chunk-d2770b2z.js +1 -0
- package/dist/chunk-d72063sm.js +2 -0
- package/dist/{chunk-6nfpdtn6.js → chunk-d988tv30.js} +1 -1
- package/dist/{chunk-55nx49pj.js → chunk-dx9k6sdd.js} +3 -3
- package/dist/chunk-e6ggkg36.js +2 -0
- package/dist/{chunk-x90r4sje.js → chunk-fjqtrakn.js} +1 -1
- package/dist/chunk-gbfpab0j.js +1 -0
- package/dist/chunk-gkvx829z.js +1 -0
- package/dist/{chunk-94jawhw7.js → chunk-gwf8b14k.js} +1 -1
- package/dist/chunk-gz7fz9fg.js +1 -0
- package/dist/{chunk-48vkm1yn.js → chunk-h0q3dvnv.js} +2 -2
- package/dist/chunk-h0qb9jk1.js +1 -0
- package/dist/chunk-h9y136h8.js +1 -0
- package/dist/chunk-hrcxdj3c.js +54 -0
- package/dist/chunk-hz9yw7cs.js +166 -0
- package/dist/{chunk-98wjxsna.js → chunk-j4y5rjne.js} +1 -1
- package/dist/chunk-k12y05c3.js +3 -0
- package/dist/{chunk-fkrydbn4.js → chunk-k6fxqssr.js} +3 -3
- package/dist/{chunk-vfwbx331.js → chunk-kmxdq21k.js} +2 -2
- package/dist/chunk-mcb8rewr.js +213 -0
- package/dist/{chunk-9k64296h.js → chunk-mm9w91rj.js} +1 -1
- package/dist/chunk-mv0xzmq8.js +2 -0
- package/dist/{chunk-rztre6k0.js → chunk-n849zsd3.js} +1 -1
- package/dist/chunk-nm253hhf.js +81 -0
- package/dist/{chunk-gyhxdxb4.js → chunk-prg6489q.js} +1 -1
- package/dist/{chunk-pwrscdkf.js → chunk-pxdgy0vr.js} +1 -1
- package/dist/{chunk-frhhpxxy.js → chunk-qhzm2qw9.js} +2 -2
- package/dist/{chunk-8f2zh5h6.js → chunk-qmxtys9q.js} +2 -2
- package/dist/chunk-r0cfe5c1.js +294 -0
- package/dist/chunk-rtjytfhh.js +1 -0
- package/dist/chunk-s7ttf0pm.js +2 -0
- package/dist/{chunk-k38fjqj7.js → chunk-t01t72t2.js} +2 -2
- package/dist/{chunk-fw3nrwpf.js → chunk-t0f66x64.js} +1 -1
- package/dist/chunk-tn356gwf.js +93 -0
- package/dist/chunk-vd8kwzra.js +41 -0
- package/dist/chunk-vhn13anh.js +233 -0
- package/dist/chunk-vnewbtjy.js +1 -0
- package/dist/{chunk-hfegb4pr.js → chunk-wbm7rn9w.js} +2 -2
- package/dist/chunk-wd3gkd45.js +3 -0
- package/dist/chunk-whdf0vbb.js +1 -0
- package/dist/{chunk-r019959h.js → chunk-ws232ksq.js} +2 -2
- package/dist/{chunk-rt5mpgbg.js → chunk-yerf10k7.js} +2 -2
- package/dist/{chunk-pndhbee8.js → chunk-yzv3n8mw.js} +2 -2
- package/dist/chunk-z3e4c424.js +2 -0
- package/dist/{chunk-jb4yt88g.js → chunk-znw7fpep.js} +2 -2
- package/dist/chunk-zq2g4rfd.js +1 -0
- package/dist/cli.js +1 -1
- package/dist/nonInteractive.js +314 -4
- package/dist/zen-keyboard.js +1 -1
- package/package.json +37 -37
- package/dist/chunk-0sxrk9sx.js +0 -1
- package/dist/chunk-178yjjsx.js +0 -1
- package/dist/chunk-1p9xzvpt.js +0 -3
- package/dist/chunk-2eh0sv3s.js +0 -2
- package/dist/chunk-43xrz4wp.js +0 -2
- package/dist/chunk-48ce2wt0.js +0 -1
- package/dist/chunk-578m1dhj.js +0 -2
- package/dist/chunk-5dsevrtz.js +0 -91
- package/dist/chunk-66890qd3.js +0 -2
- package/dist/chunk-738m8242.js +0 -53
- package/dist/chunk-8ty2zfve.js +0 -3
- package/dist/chunk-9b7nj74j.js +0 -1
- package/dist/chunk-9x562s6p.js +0 -1
- package/dist/chunk-a90fm6gz.js +0 -278
- package/dist/chunk-ac5t2ywn.js +0 -100
- package/dist/chunk-ad2hbq42.js +0 -1
- package/dist/chunk-afhxxkmv.js +0 -16
- package/dist/chunk-b4vvgbav.js +0 -1
- package/dist/chunk-b9pcntkv.js +0 -253
- package/dist/chunk-c7y5efa0.js +0 -1
- package/dist/chunk-cbjnwrt7.js +0 -2
- package/dist/chunk-dcs1r9as.js +0 -2
- package/dist/chunk-dcwnpdtk.js +0 -9
- package/dist/chunk-e3tyc24s.js +0 -310
- package/dist/chunk-e8hp8d68.js +0 -81
- package/dist/chunk-h1enhch1.js +0 -2
- package/dist/chunk-hcnx1j2z.js +0 -1
- package/dist/chunk-hra0748z.js +0 -2
- package/dist/chunk-hyf24r36.js +0 -2
- package/dist/chunk-jjcmm167.js +0 -1
- package/dist/chunk-jrepjpft.js +0 -2
- package/dist/chunk-kym9tb01.js +0 -1
- package/dist/chunk-mt1g6g89.js +0 -1
- package/dist/chunk-p0vzbr7s.js +0 -585
- package/dist/chunk-r10bn684.js +0 -1
- package/dist/chunk-r3pe49q4.js +0 -8
- package/dist/chunk-r4tq44hr.js +0 -1
- package/dist/chunk-rjrnaka2.js +0 -1
- package/dist/chunk-s77qbhtz.js +0 -3
- package/dist/chunk-t7rwtc17.js +0 -1
- package/dist/chunk-v8g52kan.js +0 -1
- package/dist/chunk-vd6c87cm.js +0 -2
- package/dist/chunk-vh9zd1v3.js +0 -5
- package/dist/chunk-w2hbsa9j.js +0 -86
- package/dist/chunk-wabmqprd.js +0 -184
- package/dist/chunk-wpy5r9ma.js +0 -40
- package/dist/chunk-yqwxbcc7.js +0 -31
- package/dist/chunk-z8n7y37k.js +0 -1
- package/dist/chunk-zr7sx9hd.js +0 -1
- package/dist/chunk-zxqmghzf.js +0 -1
package/dist/chunk-r10bn684.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as e,z as d}from"./chunk-r019959h.js";import{H as o}from"./chunk-vfwbx331.js";import{I as u}from"./chunk-2eh0sv3s.js";import"./chunk-55nx49pj.js";import{Ae as N,Be as J,Ee as c,Je as x,Ke as f,Le as s,Me as i,Oe as t,ye as l}from"./chunk-a90fm6gz.js";import"./chunk-ad2hbq42.js";import"./chunk-pwrscdkf.js";import"./chunk-fkrydbn4.js";import"./chunk-43xrz4wp.js";import"./chunk-cbjnwrt7.js";import"./chunk-wpy5r9ma.js";import"./chunk-hyf24r36.js";import"./chunk-578m1dhj.js";import"./chunk-1p9xzvpt.js";import"./chunk-hra0748z.js";import"./chunk-jb4yt88g.js";import"./chunk-k38fjqj7.js";import{pq as S}from"./chunk-dcs1r9as.js";var zq=S(l(),1);var U=S(l(),1);var H=S(f(),1),a={openai:"\uD83E\uDD16",anthropic:"\uD83E\uDDE0",gemini:"✨",default:"\uD83D\uDD2E"};var Jq=({defaultValue:O,onSubmit:F,onSwitchProvider:X})=>{let[_,W]=U.useState(O),B=U.useCallback((G)=>{if(!G.trim())return;F(G.trim())},[F]),R=U.useCallback((G,K)=>{if(K.tab)return X?.(K.shift?"left":"right"),!1;if(K.leftArrow)return X?.("left"),!1;if(K.rightArrow)return X?.("right"),!1;return!0},[X]);return H.jsxDEV(N,{paddingX:2,paddingY:1,flexDirection:"column",gap:1,children:[H.jsxDEV(J,{color:"gray",children:"请输入模型名称(Enter 确认):"},void 0,!1,void 0,this),H.jsxDEV(s,{value:_,onChange:W,onSubmit:B,onHotKey:R,maxVisibleLines:1,placeholder:"例如:gpt-4o"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},Qq=({onClose:O})=>{let{extraParams:F,config:X,updateConfig:_}=u(),[W,B]=U.useState(""),R=U.useRef([]),G=U.useMemo(()=>{if(!X?.providers||X.providers.length===0)return[];return X.providers.map((q)=>{let $=q.type||"default";return{id:q.id,label:q.id,icon:a[$]||a.default,config:q}})},[X?.providers]);U.useMemo(()=>{if(G.length>0&&!W){let q=G.find(($)=>$.id===F.provider_id);B(q?.id||G[0].id)}},[G,F.provider_id,W]);let K=G.find((q)=>q.id===W),{data:V,isLoading:y,error:v}=d({provider:K?.config||null,enabled:!!W}),b=U.useMemo(()=>{let q=(V||[]).map(($)=>({id:$.id,name:$.name}));return R.current=q,q},[V]),D=U.useCallback(async()=>{return R.current},[]),j=U.useCallback((q,$,C)=>{let M=q.id===F.provider_id+"-"+q.id;return H.jsxDEV(i,{isSelected:C,isCurrent:M,children:[H.jsxDEV(J,{bold:!0,children:[$+1,". ",q.id]},void 0,!0,void 0,this),H.jsxDEV(J,{dimColor:!0,children:[" ",q.name!==q.id?`(${q.name})`:""]},void 0,!0,void 0,this)]},`model-${$}-${q.id}`,!0,void 0,this)},[F.provider_id]),P=U.useCallback((q)=>{return q.id===F.provider_id+"-"+q.id},[F.provider_id]),g=U.useCallback(async(q)=>{await _({model_id:q}),O()},[_,O]),E=U.useCallback(async(q)=>{let C=G.find((M)=>M.id===W)?.config.type||"openai";await _({provider_id:W,provider_type:C,model_id:q.id}),O()},[_,W,O,G]),k=U.useCallback(async(q)=>{if(G.length<=1)return;let $=G.findIndex((p)=>p.id===W),C=q==="left"?($-1+G.length)%G.length:($+1)%G.length,M=G[C];B(M.id),await _({provider_id:M.id,provider_type:M.config.type})},[W,G,_]),m=U.useMemo(()=>{let q=K?.label||"加载中...";return{id:`model-${W}`,title:`模型选择 - ${q}`,icon:K?.icon||"\uD83D\uDD2E",dataSource:D,searchable:!0,searchFields:["id","name"],searchPlaceholder:"搜索模型...",itemHeight:1,visibleCount:10,renderItem:j,isSelected:P,onSelect:E,showCount:!0,keyMap:{leftArrow:($)=>{k("left")},rightArrow:($)=>{k("right")}}}},[W,K,D,j,P,E,k]);if(G.length===0)return H.jsxDEV(N,{flexDirection:"column",paddingX:2,paddingY:1,children:[H.jsxDEV(J,{color:"yellow",children:"⚠️ 未配置任何 Provider"},void 0,!1,void 0,this),H.jsxDEV(J,{color:"gray",dimColor:!0,children:"请先配置 Provider 后再查看模型列表"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let T=K?.config.apiKey;return H.jsxDEV(N,{flexDirection:"column",children:[H.jsxDEV(N,{gap:1,paddingX:1,paddingY:1,children:G.map((q,$)=>H.jsxDEV(J,{bold:q.id===W,color:q.id===W?"cyan":"gray",children:[q.icon," ",q.label,q.id===W&&" [当前]",q.id===W&&!T&&" (未配置 API Key)"]},`provider-tab-${$}-${q.id}`,!0,void 0,this))},void 0,!1,void 0,this),y?H.jsxDEV(N,{paddingX:2,paddingY:1,children:H.jsxDEV(J,{color:"gray",children:"加载模型列表中..."},void 0,!1,void 0,this)},void 0,!1,void 0,this):v||b.length===0?H.jsxDEV(Jq,{defaultValue:X?.model_id||"",onSubmit:g,onSwitchProvider:k},void 0,!1,void 0,this):!T?H.jsxDEV(N,{paddingX:2,paddingY:1,children:H.jsxDEV(J,{color:"yellow",children:"请先配置 API Key"},void 0,!1,void 0,this)},void 0,!1,void 0,this):H.jsxDEV(t,{config:m,onClose:O},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},r=Qq;var z=S(l(),1);var Z=S(f(),1),Wq=({onClose:O})=>{let{config:F,updateConfig:X}=u(),[_,W]=z.useState("list"),[B,R]=z.useState(null),[G,K]=z.useState(0),[V,y]=z.useState(null),v=z.useCallback(()=>y(null),[]);o(v,V?3000:null);let b=z.useRef(_),D=z.useRef(G),j=z.useRef([]),P=z.useRef(!0);z.useEffect(()=>{b.current=_},[_]),z.useEffect(()=>{D.current=G},[G]);let g=F?.providers||[];z.useEffect(()=>{j.current=g},[g]);let E=z.useCallback(()=>{P.current=!0,R(null),W("form"),y(null)},[]),k=z.useCallback(()=>{let Q=j.current,Y=D.current,L=Q[Y];if(!L)return;P.current=!1,R(L),W("form"),y(null)},[]),m=z.useCallback(()=>{W("list"),R(null),y(null)},[]),T=z.useCallback(async(Q)=>{let Y=j.current,L=P.current,A=L?[...Y,Q]:Y.map((w)=>w.id===Q.id?Q:w);if(await X({providers:A}),y(L?`已添加 Provider: ${Q.id}`:`已更新 Provider: ${Q.id}`),L){let w=A.findIndex((I)=>I.id===Q.id);K(w>=0?w:0)}W("list"),R(null),y(null)},[X]),q=z.useCallback(async()=>{let Q=j.current,Y=D.current,L=Q[Y];if(!L)return;if(Q.length<=1){y("无法删除最后一个 Provider");return}let A=Q.filter((I)=>I.id!==L.id);await X({providers:A});let w=Math.min(Y,A.length-1);K(w>=0?w:0),y(`已删除 Provider: ${L.id}`)},[X]),$=z.useRef(E),C=z.useRef(k),M=z.useRef(q),p=z.useRef(m),n=z.useRef(O);z.useEffect(()=>{$.current=E},[E]),z.useEffect(()=>{C.current=k},[k]),z.useEffect(()=>{M.current=q},[q]),z.useEffect(()=>{p.current=m},[m]),z.useEffect(()=>{n.current=O},[O]),x((Q,Y)=>{let L=b.current,A=j.current,w=D.current;if(L==="form"){if(Y.escape)p.current();return}if(Y.upArrow)K((I)=>I>0?I-1:A.length-1);else if(Y.downArrow)K((I)=>I<A.length-1?I+1:0);else if(Q==="n"||Q==="N")$.current();else if((Q==="e"||Q==="E"||Y.return)&&A[w])C.current();else if((Q==="d"||Q==="D")&&A[w])M.current();else if(Y.escape)n.current()},{isActive:!0});let Gq=z.useMemo(()=>{if(g.length===0)return Z.jsxDEV(N,{paddingX:2,paddingY:1,children:Z.jsxDEV(J,{color:"yellow",children:"未配置任何 Provider"},void 0,!1,void 0,this)},void 0,!1,void 0,this);return Z.jsxDEV(N,{flexDirection:"column",paddingX:2,gap:1,children:[g.map((Q,Y)=>{let L=!!Q.apiKey,A=L?"green":"yellow";return Z.jsxDEV(N,{marginBottom:0,gap:1,children:[Z.jsxDEV(J,{color:Y===G?"cyan":"gray",bold:Y===G,children:Y===G?">":" "},void 0,!1,void 0,this),Z.jsxDEV(J,{bold:Y===G,color:Y===G?"cyan":void 0,children:Q.id},void 0,!1,void 0,this),Z.jsxDEV(c,{},void 0,!1,void 0,this),Z.jsxDEV(J,{color:"gray",dimColor:Y!==G,children:[" ",Q.type]},void 0,!0,void 0,this),Z.jsxDEV(J,{color:A,dimColor:Y!==G,children:[" ","[",L?"已配置":"未配置","]"]},void 0,!0,void 0,this)]},`provider-${Y}-${Q.id}`,!0,void 0,this)}),Z.jsxDEV(N,{marginTop:1,children:Z.jsxDEV(J,{color:"gray",dimColor:!0,children:[Z.jsxDEV(J,{color:"cyan",children:"↑↓"},void 0,!1,void 0,this)," 导航 ",Z.jsxDEV(J,{color:"cyan",children:"n"},void 0,!1,void 0,this)," 新增 ",Z.jsxDEV(J,{color:"cyan",children:"d"},void 0,!1,void 0,this)," ","删除 ",Z.jsxDEV(J,{color:"cyan",children:"Esc"},void 0,!1,void 0,this)," 关闭"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},[g,G]);return Z.jsxDEV(N,{flexDirection:"column",children:[Z.jsxDEV(N,{paddingX:2,paddingY:1,children:Z.jsxDEV(J,{bold:!0,color:"cyan",children:"Providers"},void 0,!1,void 0,this)},void 0,!1,void 0,this),_==="list"?Gq:Z.jsxDEV(e,{provider:B||void 0,onCancel:m,onSave:T},void 0,!1,void 0,this),V&&Z.jsxDEV(N,{paddingX:2,paddingY:0,children:Z.jsxDEV(J,{color:"green",children:V},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},qq=Wq;var h=S(f(),1),Xq=({onClose:O,initialTab:F="model"})=>{let[X,_]=zq.useState(F);return x((W,B)=>{if(B.leftArrow&&B.alt)_("model");else if(B.rightArrow&&B.alt)_("provider");else if(B.escape)O()},{isActive:!0}),h.jsxDEV(N,{flexDirection:"column",width:"100%",borderStyle:"single",borderDimColor:!0,children:[h.jsxDEV(N,{flexDirection:"column",paddingX:0,paddingY:0,children:[X==="model"&&h.jsxDEV(r,{onClose:O},void 0,!1,void 0,this),X==="provider"&&h.jsxDEV(qq,{onClose:O},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h.jsxDEV(N,{flexDirection:"row",gap:2,paddingX:2,paddingY:1,borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:"single",borderColor:"gray",children:[h.jsxDEV(J,{bold:X==="model",color:X==="model"?"cyan":"gray",children:"\uD83E\uDD16 Model"},void 0,!1,void 0,this),h.jsxDEV(J,{bold:X==="provider",color:X==="provider"?"cyan":"gray",children:"\uD83D\uDD0C Provider"},void 0,!1,void 0,this),h.jsxDEV(c,{},void 0,!1,void 0,this),h.jsxDEV(J,{dimColor:!0,children:"Alt+ < >"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},jq=Xq;export{jq as default};
|
package/dist/chunk-r3pe49q4.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{Ae as j,Be as E,Ke as t,ye as c0}from"./chunk-a90fm6gz.js";import{hf as g}from"./chunk-wabmqprd.js";import{pq as h,qq as P,tq as M}from"./chunk-dcs1r9as.js";var b=P((IA,X0)=>{var n0=M("child_process").spawn;function p0(A,G,X,L){if(typeof X==="function")L=X,X=void 0;let J=!1,H=n0(A,G,X),K="",Y="";H.stdout.on("data",function($){K+=$.toString()}),H.stderr.on("data",function($){Y+=$.toString()}),H.on("error",function($){if(J)return;J=!0,L(Error($))}),H.on("close",function($,Q){if(J)return;if(J=!0,Y)return L(Error(Y));L(null,K,$)})}X0.exports=p0});var y=P((OA,L0)=>{var B={},w={},x={},n=0,R=null;function a0(A,G){if(G<=0)return;if(w[A]!==void 0)B[A]=Date.now()+(G||60000);return w[A]}function i0(A,G,X,L){if(G===void 0||X<=0)return;if(B[A]=Date.now()+(X||60000),w[A]===void 0)n++,G0(X);if(w[A]=G,L)x[A]=L}function G0(A){if(n>0){if(R===null){if(R=setInterval(d0,(A||60000)/2),typeof R.unref==="function")R.unref()}return}if(R!==null)clearInterval(R),R=null}function d0(){let A=Date.now(),G=Object.keys(B);for(let X=0;X<G.length;X++){let L=G[X];if(B[L]<A){if(n--,x[L])x[L](w[L]);delete w[L],delete B[L],delete x[L]}}G0()}function c(A){for(let G in A)delete A[G]}function o0(){if(R!==null)clearInterval(R),R=null;c(w),c(B),c(x)}L0.exports={get:a0,set:i0,clear:o0}});var W0=P((EA,Q0)=>{var K0=M("os"),r0=b(),H0=y(),f=K0.platform();function J0(A,G){let X=0,L=A.split(/-|:|\./),J=L.length-1;if(J>=0&&G&&f==="darwin")X+=parseInt(L[J--],10)*10;if(J>=0)X+=parseInt(L[J--],10)*1000;if(J>=0)X+=parseInt(L[J--],10)*60000;if(J>=0)X+=parseInt(L[J--],10)*3600000;if(J>=0)X+=parseInt(L[J--],10)*86400000;return X}function s0(A,G,X){let L=A.join(","),J=["-o","etime,pid,ppid,pcpu,rss,time","-p",L];if(f==="aix"||f==="os400")J=["-o","etime,pid,ppid,pcpu,rssize,time","-p",L];r0("ps",J,function(H,K,Y){if(H){if(f==="os390"&&/no matching processes found/.test(H))H=Error("No matching pid found"),H.code="ENOENT";return X(H)}if(Y===1){let N=Error("No matching pid found");return N.code="ENOENT",X(N)}if(Y!==0)return X(Error("pidusage ps command exited with code "+Y));let $=Date.now();K=K.split(K0.EOL);let Q={};for(let N=1;N<K.length;N++){let U=K[N].trim().split(/\s+/);if(!U||U.length!==6)continue;let W=parseInt(U[1],10),q=H0.get(W,G.maxage);if(q===void 0)q={};let Z=parseInt(U[2],10),F=parseInt(U[4],10)*1024,v=J0(U[0]),C=J0(U[5],!0),T=C-(q.ctime||0),I=Math.abs(q.elapsed!==void 0?v-q.elapsed:v),D=I>0?T/I*100:0;Q[W]={cpu:D,memory:F,ppid:Z,pid:W,ctime:C,elapsed:v,timestamp:$},H0.set(W,Q[W],G.maxage)}X(null,Q)})}Q0.exports=s0});var p=P((SA,Y0)=>{function t0(A,G,X){if(typeof G==="function")X=G,G={};let L;if(!Array.isArray(A))L=Object.keys(A);let J=L?L.length:A.length,H=J,K=L?{}:[];function Y($,Q,N){if(K[$]=N,--H===0||Q&&!G.graceful){if(G.graceful&&Q&&J>1)Q=null;X&&X(Q,K),X=null}}if(L)L.forEach(function($){A[$](function(Q,N){Y($,Q,N)})});else A.forEach(function($,Q){$(function(N,U){Y(Q,N,U)})})}Y0.exports=t0});var Z0=P((jA,q0)=>{var e0=M("os"),AA=M("fs"),XA=M("child_process").exec,U0=p();function GA(A,G){if(A!==null){$0(function(X,L){if(X)return G(X);A.uptime=L,G(null,A)});return}U0([LA,$0],function(X,L){if(X)return G(X);A={clockTick:L[0].clockTick,pageSize:L[0].pageSize,uptime:L[1]},G(null,A)})}q0.exports=GA;function $0(A){AA.readFile("/proc/uptime","utf8",function(G,X){if(G||X===void 0){if(!process.env.PIDUSAGE_SILENT)console.warn("[pidusage] We couldn't find uptime from /proc/uptime, using os.uptime() value");return A(null,e0.uptime()||new Date/1000)}return A(null,parseFloat(X.split(" ")[0]))})}function LA(A){U0([function(X){N0("CLK_TCK",{default:100},X)},function(X){N0("PAGESIZE",{default:4096},X)}],function(G,X){if(G)return A(G);A(null,{clockTick:X[0],pageSize:X[1]})})}function N0(A,G,X){if(typeof G==="function")X=G,G={default:""};XA("getconf "+A,function(L,J,H){if(L!==null){if(!process.env.PIDUSAGE_SILENT)console.error('Error while calling "getconf '+A+'"',L);return X(null,G.default)}if(J=parseInt(J),!isNaN(J))return X(null,J);return X(null,G.default)})}});var M0=P((a,F0)=>{/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var l=M("buffer"),V=l.Buffer;function _0(A,G){for(var X in A)G[X]=A[X]}if(V.from&&V.alloc&&V.allocUnsafe&&V.allocUnsafeSlow)F0.exports=l;else _0(l,a),a.Buffer=z;function z(A,G,X){return V(A,G,X)}z.prototype=Object.create(V.prototype);_0(V,z);z.from=function(A,G,X){if(typeof A==="number")throw TypeError("Argument must not be a number");return V(A,G,X)};z.alloc=function(A,G,X){if(typeof A!=="number")throw TypeError("Argument must be a number");var L=V(A);if(G!==void 0)if(typeof X==="string")L.fill(G,X);else L.fill(G);else L.fill(0);return L};z.allocUnsafe=function(A){if(typeof A!=="number")throw TypeError("Argument must be a number");return V(A)};z.allocUnsafeSlow=function(A){if(typeof A!=="number")throw TypeError("Argument must be a number");return l.SlowBuffer(A)}});var R0=P((wA,P0)=>{var d=M("fs"),HA=M("path"),JA=Z0(),KA=p(),v0=y(),O=null,C0=M0().Buffer,i=1024;function QA(){}function WA(A,G,X){if(G.fd)return X(null,G.fd);d.open(A,"r",X)}function YA(A){if(A.fd)d.close(A.fd,QA)}function T0(A,G,X){let L=!1;if(typeof G==="function")X=G,G=C0.alloc(i),L=!0;d.read(A,G,0,i,0,function(J,H,K){if(J){X(J);return}let Y=C0.concat([G,K],L?H:G.length+H);if(H===i){T0(A,Y,X);return}X(null,G)})}function D0(A,G,X){let L=v0.get(A,G.maxage),J=!1;if(L===void 0)J=!0,L={};WA(HA.join("/proc",""+A,"stat"),L,function(H,K){if(H){if(H.code==="ENOENT")H.message="No matching pid found";return X(H,null)}if(H)return X(H);T0(K,function(Y,$){if(Y)return X(Y);let Q=$.toString("utf8"),N=Date.now(),U=Q.lastIndexOf(")");Q=Q.substr(U+2).split(" ");let W={ppid:parseInt(Q[1]),utime:parseFloat(Q[11])*1000/O.clockTick,stime:parseFloat(Q[12])*1000/O.clockTick,cutime:parseFloat(Q[13])*1000/O.clockTick,cstime:parseFloat(Q[14])*1000/O.clockTick,start:parseFloat(Q[19])*1000/O.clockTick,rss:parseFloat(Q[21]),uptime:O.uptime*1000,fd:K},q=W.rss*O.pageSize,Z=G.childrens?W.cutime+W.cstime:0,F=W.stime-(L.stime||0)+W.utime-(L.utime||0)+Z,v=Math.abs(L.uptime!==void 0?W.uptime-L.uptime:W.start-W.uptime),C=v>0?F/v*100:0;if(v0.set(A,W,G.maxage,YA),J)return D0(A,G,X);return X(null,{cpu:C,memory:q,ctime:W.utime+W.stime,elapsed:W.uptime-W.start,timestamp:N,pid:A,ppid:W.ppid})})})}function $A(A,G,X){JA(O,function(L,J){if(L)return X(L);O=J;let H={};A.forEach(function(K,Y){H[K]=function($){D0(K,G,$)}}),KA(H,{graceful:!0},X)})}P0.exports=$A});var S0=P((zA,E0)=>{var V0=M("os"),NA=b(),I0=y();function UA(A){let G=A.substring(0,4),X=A.substring(4,6),L=A.substring(6,8),J=A.substring(8,10),H=A.substring(10,12),K=A.substring(12,14),Y=A.substring(15,21),$=A.substring(21,22),Q=parseInt(A.substring(22,25),10),N=Math.floor(Q/60),U=Q%60;return new Date(G+"-"+X+"-"+L+"T"+J+":"+H+":"+K+"."+Y+$+(N>9?N:"0"+N)+(U>9?U:"0"+U))}function O0(A,G,X){let L="ProcessId="+A[0];for(let H=1;H<A.length;H++)L+=" or ProcessId="+A[H];let J=["PROCESS","where",'"'+L+'"',"get","CreationDate,KernelModeTime,ParentProcessId,ProcessId,UserModeTime,WorkingSetSize"];NA("wmic",J,{windowsHide:!0,windowsVerbatimArguments:!0},function(H,K,Y){if(H){if(H.message.indexOf("No Instance(s) Available.")!==-1){let W=Error("No matching pid found");return W.code="ENOENT",X(W)}return X(H)}if(Y!==0)return X(Error("pidusage wmic command exited with code "+Y));let $=Date.now(),Q=Math.floor(V0.uptime()||$/1000);K=K.split(V0.EOL);let N=!1,U={};for(let W=1;W<K.length;W++){let q=K[W].trim().split(/\s+/);if(!q||q.length!==6)continue;let Z=UA(q[0]),F=parseInt(q[2],10),v=parseInt(q[3],10),C=Math.round(parseInt(q[1],10)/1e4),T=Math.round(parseInt(q[4],10)/1e4),I=parseInt(q[5],10),D=I0.get(v,G.maxage);if(D===void 0)N=!0,D={ctime:C+T,uptime:Q};let u=(C+T-D.ctime)/1000,S=Q-D.uptime,m=S>0?u/S*100:0;I0.set(v,{ctime:T+C,uptime:Q},G.maxage),U[v]={cpu:m,memory:I,ppid:F,pid:v,ctime:T+C,elapsed:$-Z.getTime(),timestamp:$}}if(N)return O0(A,G,function(W,q){if(W)return X(W);X(null,Object.assign(U,q))});X(null,U)})}E0.exports=O0});var y0=P((BA,B0)=>{var j0=M("os"),qA=b(),w0=y();function ZA(A){let G=A.substring(0,4),X=A.substring(4,6),L=A.substring(6,8),J=A.substring(8,10),H=A.substring(10,12),K=A.substring(12,14),Y=A.substring(15,21),$=A.substring(21,22),Q=parseInt(A.substring(22,25),10),N=Math.floor(Q/60),U=Q%60;return new Date(G+"-"+X+"-"+L+"T"+J+":"+H+":"+K+"."+Y+$+(N>9?N:"0"+N)+(U>9?U:"0"+U))}function z0(A,G,X){let L="ProcessId="+A[0];for(let K=1;K<A.length;K++)L+=" or ProcessId="+A[K];let J="CreationDate,KernelModeTime,ParentProcessId,ProcessId,UserModeTime,WorkingSetSize",H=["win32_process","-Filter","'"+L+"'","| select "+J,"| format-table"];qA("gwmi",H,{windowsHide:!0,windowsVerbatimArguments:!0,shell:"powershell.exe"},function(K,Y,$){if(K){if(K.message.indexOf("No Instance(s) Available.")!==-1){let Z=Error("No matching pid found");return Z.code="ENOENT",X(Z)}return X(K)}if($!==0)return X(Error("pidusage gwmi command exited with code "+$));let Q=Date.now(),N=Math.floor(j0.uptime()||Q/1000);Y=Y.split(j0.EOL).slice(1);let U=Y.findIndex((Z)=>!!Z);if(Y=Y.slice(U+2),!Y.length){let Z=Error("No matching pid found");return Z.code="ENOENT",X(Z)}let W=!1,q={};for(let Z=0;Z<Y.length;Z++){let F=Y[Z].trim().split(/\s+/);if(!F||F.length===1)continue;let v=ZA(F[0]),C=parseInt(F[2],10),T=parseInt(F[3],10),I=Math.round(parseInt(F[1],10)/1e4),D=Math.round(parseInt(F[4],10)/1e4),u=parseInt(F[5],10),S=w0.get(T,G.maxage);if(S===void 0)W=!0,S={ctime:I+D,uptime:N};let m=(I+D-S.ctime)/1000,s=N-S.uptime,m0=s>0?m/s*100:0;w0.set(T,{ctime:D+I,uptime:N},G.maxage),q[T]={cpu:m0,memory:u,ppid:C,pid:T,ctime:D+I,elapsed:Q-v.getTime(),timestamp:Q}}if(W)return z0(A,G,function(Z,F){if(Z)return X(Z);X(null,Object.assign(q,F))});X(null,q)})}B0.exports=z0});var h0=P((yA,g0)=>{var _A=M("fs"),k0=M("os"),FA=M("child_process").spawn,o={ps:()=>W0(),procfile:()=>R0(),wmic:()=>S0(),gwmi:()=>y0()},MA={aix:"ps",os400:"ps",android:"procfile",alpine:"procfile",darwin:"ps",freebsd:"ps",os390:"ps",linux:"procfile",netbsd:"procfile",openbsd:"ps",sunos:"ps",win:"wmic"},k=k0.platform();if(_A.existsSync("/etc/alpine-release"))k="alpine";if(k.match(/^win/))k="win";var x0;try{x0=o[MA[k]]()}catch(A){}function vA(A,G,X){let L=x0;if(k!=="win"&&G.usePs===!0)L=o.ps();if(k==="win"){let H;try{H=FA("wmic",function(K){if(K)throw Error(K)})}catch(K){L=o.gwmi()}finally{if(H)H.kill()}}if(L===void 0)return X(Error(k0.platform()+" is not supported yet, please open an issue (https://github.com/soyuka/pidusage)"));let J=!1;if(!Array.isArray(A))J=!0,A=[A];if(A.length===0)return X(TypeError("You must provide at least one pid"));for(let H=0;H<A.length;H++)if(A[H]=parseInt(A[H],10),isNaN(A[H])||A[H]<0)return X(TypeError("One of the pids provided is invalid"));L(A,G,function(H,K){if(H)return X(H);if(J)X(null,K[A[0]]);else X(null,K)})}g0.exports=vA});var f0=P((kA,r)=>{var b0=h0();function CA(A,G,X){if(typeof G==="function")X=G,G={};if(G===void 0)G={};if(G=Object.assign({usePs:/^true$/i.test(process.env.PIDUSAGE_USE_PS),maxage:process.env.PIDUSAGE_MAXAGE},G),typeof X==="function"){b0(A,G,X);return}return new Promise(function(L,J){b0(A,G,function(H,K){if(H)return J(H);L(K)})})}r.exports=CA;r.exports.clear=y().clear});var e=h(c0(),1);var _=h(t(),1);class A0 extends e.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(A){return{hasError:!0,error:A}}componentDidCatch(A,G){let{name:X="ErrorBoundary"}=this.props;console.error(`
|
|
2
|
-
========================================`),console.error(`[${X}] React Error Caught`),console.error("========================================"),console.error("Error:",A.message),console.error("Stack:",A.stack),console.error("Component Stack:",G.componentStack),console.error(`========================================
|
|
3
|
-
`),import("./chunk-fw3nrwpf.js").then(({logAgentError:L})=>{L(X,A)}).catch((L)=>{console.warn("Failed to log React error:",L)}),this.setState({errorInfo:G})}render(){let{hasError:A,error:G,errorInfo:X}=this.state,{name:L="ErrorBoundary",fallback:J,children:H}=this.props;if(A){if(J)return _.jsxDEV(_.Fragment,{children:J},void 0,!1,void 0,this);return _.jsxDEV(j,{flexDirection:"column",padding:1,borderStyle:"double",borderColor:"red",children:[_.jsxDEV(j,{marginBottom:1,children:_.jsxDEV(E,{color:"red",bold:!0,children:["✗ [",L,"] Render Error"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),_.jsxDEV(j,{marginBottom:1,children:_.jsxDEV(E,{color:"red",children:["Message: ",G?.message||"Unknown error"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),G?.stack&&_.jsxDEV(j,{flexDirection:"column",marginBottom:1,children:[_.jsxDEV(E,{color:"yellow",bold:!0,children:"Stack Trace:"},void 0,!1,void 0,this),_.jsxDEV(E,{color:"gray",children:G.stack.split(`
|
|
4
|
-
`).slice(0,5).join(`
|
|
5
|
-
`)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X?.componentStack&&_.jsxDEV(j,{flexDirection:"column",children:[_.jsxDEV(E,{color:"yellow",bold:!0,children:"Component Stack:"},void 0,!1,void 0,this),_.jsxDEV(E,{color:"gray",dimColor:!0,children:X.componentStack.split(`
|
|
6
|
-
`).slice(0,5).join(`
|
|
7
|
-
`)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_.jsxDEV(j,{marginTop:1,children:_.jsxDEV(E,{color:"blue",dimColor:!0,children:"Press Ctrl+C to exit"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}return _.jsxDEV(_.Fragment,{children:H},void 0,!1,void 0,this)}}var VA=A0;var l0=h(f0(),1);class u0{async getProcessList(){let A=[];for(let[G,X]of g)try{let L=await l0.default(G);A.push({pid:G,command:X.command,startTime:X.startTime,duration:Date.now()-X.startTime,cpu:L.cpu,memory:L.memory,status:this.checkStatus(X)})}catch{A.push({pid:G,command:X.command,startTime:X.startTime,duration:Date.now()-X.startTime,cpu:0,memory:0,status:"stopped"})}return A}killProcess(A){let G=g.get(A);if(!G)return!1;return G.process.kill("SIGTERM"),g.delete(A),!0}getProcessOutput(A){let G=g.get(A);if(!G)return null;return{stdout:G.stdout.join(""),stderr:G.stderr.join("")}}checkStatus(A){try{return process.kill(A.process.pid,0),"running"}catch{return"stopped"}}}var gA=new u0;
|
|
8
|
-
export{VA as h,gA as i};
|
package/dist/chunk-r4tq44hr.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{nq as a}from"./chunk-jb4yt88g.js";import"./chunk-k38fjqj7.js";import"./chunk-dcs1r9as.js";export{a as FileSystemSkillStore};
|
package/dist/chunk-rjrnaka2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as b,$a as ba,$b as bb,$c as bc,$d as bd,Aa as C,Ab as Ca,Ac as Cb,Ad as Cc,Ba as D,Bb as Da,Bc as Db,Bd as Dc,Ca as E,Cb as Ea,Cc as Eb,Cd as Ec,Da as F,Db as Fa,Dc as Fb,Dd as Fc,Ea as G,Eb as Ga,Ec as Gb,Ed as Gc,Fa as H,Fb as Ha,Fc as Hb,Fd as Hc,Ga as I,Gb as Ia,Gc as Ib,Gd as Ic,Ha as J,Hb as Ja,Hc as Jb,Hd as Jc,Ia as K,Ib as Ka,Ic as Kb,Id as Kc,Ja as L,Jb as La,Jc as Lb,Jd as Lc,Ka as M,Kb as Ma,Kc as Mb,Kd as Mc,La as N,Lb as Na,Lc as Nb,Ld as Nc,Ma as O,Mb as Oa,Mc as Ob,Md as Oc,Na as P,Nb as Pa,Nc as Pb,Nd as Pc,Oa as Q,Ob as Qa,Oc as Qb,Od as Qc,Pa as R,Pb as Ra,Pc as Rb,Pd as Rc,Qa as S,Qb as Sa,Qc as Sb,Qd as Sc,Ra as T,Rb as Ta,Rc as Tb,Rd as Tc,Sa as U,Sb as Ua,Sc as Ub,Sd as Uc,Ta as V,Tb as Va,Tc as Vb,Td as Vc,Ua as W,Ub as Wa,Uc as Wb,Ud as Wc,Va as X,Vb as Xa,Vc as Xb,Vd as Xc,Wa as Y,Wb as Ya,Wc as Yb,Wd as Yc,Xa as Z,Xb as Za,Xc as Zb,Xd as Zc,Ya as _,Yb as _a,Yc as _b,Yd as _c,Za as $,Zb as $a,Zc as $b,Zd as $c,_ as a,_a as aa,_b as ab,_c as ac,_d as ad,aa as c,ab as ca,ac as cb,ad as cc,ae as cd,ba as d,bb as da,bc as db,bd as dc,be as dd,ca as e,cb as ea,cc as eb,cd as ec,ce as ed,da as f,db as fa,dc as fb,dd as fc,de as fd,ea as g,eb as ga,ec as gb,ed as gc,ee as gd,fa as h,fb as ha,fc as hb,fd as hc,fe as hd,ga as i,gb as ia,gc as ib,gd as ic,ge as id,ha as j,hb as ja,hc as jb,hd as jc,he as jd,ia as k,ib as ka,ic as kb,id as kc,ie as kd,ja as l,jb as la,jc as lb,jd as lc,je as ld,ka as m,kb as ma,kc as mb,kd as mc,ke as md,la as n,lb as na,lc as nb,ld as nc,le as nd,ma as o,mb as oa,mc as ob,md as oc,me as od,na as p,nb as pa,nc as pb,nd as pc,ne as pd,oa as q,ob as qa,oc as qb,od as qc,oe as qd,pa as r,pb as ra,pc as rb,pd as rc,pe as rd,qa as s,qb as sa,qc as sb,qd as sc,qe as sd,ra as t,rb as ta,rc as tb,rd as tc,re as td,sa as u,sb as ua,sc as ub,sd as uc,se as ud,ta as v,tb as va,tc as vb,td as vc,te as vd,ua as w,ub as wa,uc as wb,ud as wc,ue as wd,va as x,vb as xa,vc as xb,vd as xc,wa as y,wb as ya,wc as yb,wd as yc,xa as z,xb as za,xc as zb,xd as zc,ya as A,yb as Aa,yc as Ab,yd as Ac,za as B,zb as Ba,zc as Bb,zd as Bc}from"./chunk-hsev32dg.js";import"./chunk-dcs1r9as.js";export{zc as validateTransactionSettings,Mc as sql,vd as replaceWithNoncontingentExpression,wd as pushValueIntoList,R as logOnce,D as isOperator,m as isOperationNodeSource,za as isNoResultErrorConstructor,Fc as isKyselyProps,H as isJSONOperator,n as isExpression,M as isDynamicReferenceBuilder,Cc as isCompilable,F as isComparisonOperator,zb as isColumnDataType,E as isBinaryOperator,G as isArithmeticOperator,o as isAliasedExpression,Eb as isAliasedDynamicTableBuilder,Bb as expressionBuilder,hb as createSelectQueryBuilder,Lc as createRawBuilder,Pa as createQueryId,mb as createFunctionModule,Ra as WithSchemaPlugin,Oa as WithNode,ia as WhereNode,Xa as WheneableMergeQueryBuilder,la as WhenNode,ta as ValuesNode,X as ValueNode,W as ValueListNode,ga as UsingNode,Ka as UpdateResult,fa as UpdateQueryNode,La as UpdateQueryBuilder,Tb as UniqueConstraintNode,nb as UnaryOperationNode,A as UNARY_OPERATORS,z as UNARY_FILTER_OPERATORS,xb as TupleNode,vb as TraversedJSONPathBuilder,Hc as TransactionBuilder,Ec as Transaction,Ea as TopNode,l as TableNode,yc as TRANSACTION_ISOLATION_LEVELS,xc as TRANSACTION_ACCESS_MODES,Tc as SqliteQueryCompiler,_c as SqliteIntrospector,Sc as SqliteDriver,ad as SqliteDialect,$c as SqliteAdapter,wc as SingleConnectionProvider,bb as SetOperationNode,sa as SelectionNode,pa as SelectQueryNode,p as SelectModifierNode,J as SelectAllNode,g as SchemableIdentifierNode,sc as SchemaModule,ja as ReturningNode,$b as RenameConstraintNode,Ib as RenameColumnNode,qc as RefreshMaterializedViewNode,rc as RefreshMaterializedViewBuilder,Lb as ReferencesNode,K as ReferenceNode,O as RawNode,oa as QueryNode,_a as QueryCreator,V as PrimitiveValueListNode,Yb as PrimaryKeyConstraintNode,Zb as PrimaryConstraintNode,bd as PostgresQueryCompiler,cd as PostgresIntrospector,jd as PostgresDriver,kd as PostgresDialect,dd as PostgresAdapter,_ as PartitionByNode,ra as PartitionByItemNode,td as ParseJSONResultsPlugin,Y as ParensNode,$ as OverNode,na as OutputNode,Z as OrderByNode,N as OrderByItemNode,Q as OrderByItemBuilder,eb as OrWrapper,r as OrNode,Fa as OrActionNode,C as OperatorNode,Nc as OperationNodeVisitor,Qa as OperationNodeTransformer,s as OnNode,wa as OnDuplicateKeyNode,Da as OnConflictUpdateBuilder,Aa as OnConflictNode,Ca as OnConflictDoNothingBuilder,Ba as OnConflictBuilder,$a as OffsetNode,B as OPERATORS,Kb as ON_MODIFY_FOREIGN_ACTIONS,e as ON_COMMIT_ACTIONS,Za as NotMatchedThenableMergeQueryBuilder,Ta as NoopQueryExecutor,ya as NoResultError,Yc as NO_MIGRATIONS,Ua as NOOP_QUERY_EXECUTOR,fd as MysqlQueryCompiler,gd as MysqlIntrospector,ed as MysqlDriver,id as MysqlDialect,hd as MysqlAdapter,od as MssqlQueryCompiler,nd as MssqlIntrospector,md as MssqlDriver,pd as MssqlDialect,ld as MssqlAdapter,Pb as ModifyColumnNode,Zc as Migrator,Va as MergeResult,ma as MergeQueryNode,Wa as MergeQueryBuilder,Ya as MatchedThenableMergeQueryBuilder,Sa as MatchedNode,Xc as MIGRATION_LOCK_ID,Bc as Log,ea as ListNode,Ia as LimitNode,Ac as LOG_LEVELS,Dc as Kysely,t as JoinNode,qa as JoinBuilder,x as JSON_OPERATORS,S as JSONReferenceNode,U as JSONPathNode,tb as JSONPathLegNode,ub as JSONPathBuilder,T as JSONOperatorChainNode,xa as InsertResult,da as InsertQueryNode,Ga as InsertQueryBuilder,b as IdentifierNode,ca as HavingNode,ud as HandleEmptyInListsPlugin,ba as GroupByNode,ab as GroupByItemNode,Mb as GeneratedNode,jb as FunctionNode,aa as FromNode,Qb as ForeignKeyConstraintNode,Rb as ForeignKeyConstraintBuilder,qd as FileMigrationProvider,gb as FetchNode,cb as ExpressionWrapper,ka as ExplainNode,Cb as DynamicTableBuilder,L as DynamicReferenceBuilder,tc as DynamicModule,Qc as DummyDriver,kc as DropViewNode,lc as DropViewBuilder,oc as DropTypeNode,pc as DropTypeBuilder,j as DropTableNode,hc as DropTableBuilder,i as DropSchemaNode,gc as DropSchemaBuilder,h as DropIndexNode,fc as DropIndexBuilder,Ub as DropConstraintNode,Hb as DropColumnNode,Rc as DialectAdapterBase,Ha as DeleteResult,ha as DeleteQueryNode,Ja as DeleteQueryBuilder,Nb as DefaultValueNode,vc as DefaultQueryExecutor,Oc as DefaultQueryCompiler,ua as DefaultInsertValueNode,uc as DefaultConnectionProvider,sd as DeduplicateJoinsPlugin,yb as DataTypeNode,Uc as DEFAULT_MIGRATION_TABLE,Vc as DEFAULT_MIGRATION_LOCK_TABLE,Wc as DEFAULT_ALLOW_UNORDERED_MIGRATIONS,ic as CreateViewNode,jc as CreateViewBuilder,mc as CreateTypeNode,nc as CreateTypeBuilder,f as CreateTableNode,ec as CreateTableBuilder,d as CreateSchemaNode,dc as CreateSchemaBuilder,c as CreateIndexNode,cc as CreateIndexBuilder,Ic as ControlledTransactionBuilder,Jc as ControlledTransaction,Gc as ConnectionBuilder,Pc as CompiledQuery,Na as CommonTableExpressionNode,Ma as CommonTableExpressionNameNode,Kc as Command,va as ColumnUpdateNode,I as ColumnNode,Gb as ColumnDefinitionNode,Ob as ColumnDefinitionBuilder,P as CollateNode,Jb as CheckConstraintNode,Ab as CastNode,rb as CaseWhenBuilder,qb as CaseThenBuilder,ob as CaseNode,sb as CaseEndBuilder,pb as CaseBuilder,rd as CamelCasePlugin,v as COMPARISON_OPERATORS,u as BinaryOperationNode,y as BINARY_OPERATORS,fb as AndWrapper,q as AndNode,Xb as AlteredColumnBuilder,a as AlterTableNode,bc as AlterTableColumnAlteringBuilder,ac as AlterTableBuilder,Vb as AlterColumnNode,Wb as AlterColumnBuilder,wb as AliasedJSONPathBuilder,db as AliasedExpressionWrapper,Db as AliasedDynamicTableBuilder,lb as AliasedAggregateFunctionBuilder,k as AliasNode,ib as AggregateFunctionNode,kb as AggregateFunctionBuilder,_b as AddIndexNode,Sb as AddConstraintNode,Fb as AddColumnNode,w as ARITHMETIC_OPERATORS};
|
package/dist/chunk-s77qbhtz.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{eq as yr}from"./chunk-frhhpxxy.js";import{fq as hr}from"./chunk-h1enhch1.js";import{pq as gh,qq as M,tq as O}from"./chunk-dcs1r9as.js";var Ku=M((Xu)=>{(function(){var u=function(e,r,f){var h,_;_="";while(e.length>0)if(h=e.match(r),h)_+=e.slice(0,h.index),_+=f(h),e=e.slice(h.index+h[0].length);else _+=e,e="";return _};Xu.split=function(e){var r,f;if(e==null)e="";if(f=[],r="",u(e,/\s*(?:([^\s\\\'\"]+)|'((?:[^\'\\]|\\.)*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|$)?/,function(h){var _,q,E,w,C,X,K;if(w=h[0],K=h[1],X=h[2],_=h[3],q=h[4],E=h[5],C=h[6],E!=null)throw Error("Unmatched quote");if(r+=K||(X||_||q).replace(/\\(?=.)/,""),C!=null)return f.push(r),r=""}),r)f.push(r);return f},Xu.escape=function(e){if(e==null)e="";if(e==null)return"''";return e.replace(/([^A-Za-z0-9_\-.,:\/@\n])/g,"\\$1").replace(/\n/g,`'
|
|
2
|
-
'`)}}).call(Xu)});var Qu=M((mh,Vu)=>{var Zu=O("fs"),p;function oe(){try{return Zu.statSync("/.dockerenv"),!0}catch(u){return!1}}function ur(){try{return Zu.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch(u){return!1}}Vu.exports=()=>{if(p===void 0)p=oe()||ur();return p}});var Gu=M((xh,s)=>{var er=O("os"),rr=O("fs"),Fu=Qu(),Uu=()=>{if(process.platform!=="linux")return!1;if(er.release().toLowerCase().includes("microsoft")){if(Fu())return!1;return!0}try{return rr.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!Fu():!1}catch(u){return!1}};if(process.env.__IS_WSL_TEST__)s.exports=Uu;else s.exports=Uu()});var G=M((Yr,J)=>{var fr=Ku(),j=O("child_process"),uu=hr(),_r=Gu(),qr=O("path"),wr=O("url"),U=O("os"),o=O("fs"),Or=O("net");function zu(u){return JSON.parse(JSON.stringify(u))}Yr.clone=zu;var Er=function(u){if(typeof u==="string")return u.replace(/(["$`\\])/g,"\\$1");else return u},Mr=function(u,e){return u.indexOf(e)!==-1},Nu={u:"urgency",urgency:"urgency",t:"expire-time",time:"expire-time",timeout:"expire-time",e:"expire-time",expire:"expire-time","expire-time":"expire-time",i:"icon",icon:"icon",c:"category",category:"category",subtitle:"category",h:"hint",hint:"hint",a:"app-name","app-name":"app-name"};Yr.command=function(u,e,r){if(u=fr.escape(u),process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1)console.info("node-notifier debug info (command):"),console.info("[notifier path]",u),console.info("[notifier options]",e.join(" "));return j.exec(u+" "+e.join(" "),function(f,h,_){if(f)return r(f);r(_,h)})};Yr.fileCommand=function(u,e,r){if(process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1)console.info("node-notifier debug info (fileCommand):"),console.info("[notifier path]",u),console.info("[notifier options]",e.join(" "));return j.execFile(u,e,function(f,h,_){if(f)return r(f,h);r(_,h)})};Yr.fileCommandJson=function(u,e,r){if(process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1)console.info("node-notifier debug info (fileCommandJson):"),console.info("[notifier path]",u),console.info("[notifier options]",e.join(" "));return j.execFile(u,e,function(f,h,_){if(f)return r(f,h);if(!h)return r(f,{});try{let q=JSON.parse(h);r(!_?null:_,q)}catch(q){r(q,h)}})};Yr.immediateFileCommand=function(u,e,r){if(process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1)console.info("node-notifier debug info (notifier):"),console.info("[notifier path]",u);Cr(u,function(f,h){if(!h)return r(Error("Notifier ("+u+") not found on system."));j.execFile(u,e),r()})};function Cr(u,e){return o.stat(u,function(r,f){if(!r)return e(r,f.isFile());if(qr.extname(u))return e(r,!1);return o.stat(u+".exe",function(h,_){if(h)return e(h,!1);e(h,_.isFile())})})}var k=function(u){if(u.appIcon)u.icon=u.appIcon,delete u.appIcon;return u},z=function(u){if(u.text)u.message=u.text,delete u.text;return u},Iu=function(u){if(u.i)u.icon=u.i,delete u.i;return u};Yr.mapToNotifySend=function(u){if(u=k(u),u=z(u),u.timeout===!1)delete u.timeout;if(u.wait===!0)u["expire-time"]=5;for(let e in u){if(e==="message"||e==="title")continue;if(u.hasOwnProperty(e)&&Nu[e]!==e)u[Nu[e]]=u[e],delete u[e]}if(typeof u["expire-time"]>"u")u["expire-time"]=1e4;else if(typeof u["expire-time"]==="number")u["expire-time"]=u["expire-time"]*1000;return u};Yr.mapToGrowl=function(u){if(u=k(u),u=Iu(u),u=z(u),u.icon&&!Buffer.isBuffer(u.icon))try{u.icon=o.readFileSync(u.icon)}catch(e){}return u};Yr.mapToMac=function(u){if(u=Iu(u),u=z(u),u.icon)u.appIcon=u.icon,delete u.icon;if(u.sound===!0)u.sound="Bottle";if(u.sound===!1)delete u.sound;if(u.sound&&u.sound.indexOf("Notification.")===0)u.sound="Bottle";if(u.wait===!0){if(!u.timeout)u.timeout=5;delete u.wait}if(!u.wait&&!u.timeout)if(u.timeout===!1)delete u.timeout;else u.timeout=10;return u.json=!0,u};function eu(u){return Object.prototype.toString.call(u)==="[object Array]"}Yr.isArray=eu;function Lr(){}Yr.actionJackerDecorator=function(u,e,r,f){if(e=zu(e),r=r||Lr,typeof r!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof r);return function(h,_){let q=_,E={};if(q&&typeof q==="object")E=q,q=q.activationType;if(q){if(q=q.toLowerCase().trim(),q.match(/^activate|clicked$/))q="activate";if(q.match(/^timedout$/))q="timeout"}if(r.apply(u,[h,q,E]),!f||!q)return;let w=f(q);if(!w)return;u.emit(w,u,e,E)}};Yr.constructArgumentList=function(u,e){let r=[];e=e||{};let f=e.initial||[],h=e.keyExtra||"",_=e.allowedArguments||[],q=e.noEscape!==void 0,E=e.allowedArguments!==void 0,w=!!e.explicitTrue,C=!!e.keepNewlines,X=e.wrapper===void 0?'"':e.wrapper,K=function L(F){if(eu(F))return Ru(F.map(L).join(","));if(!q)F=Er(F);if(typeof F==="string"&&!C)F=Ru(F);return X+F+X};f.forEach(function(L){r.push(K(L))});for(let L in u)if(u.hasOwnProperty(L)&&(!E||Mr(_,L)))if(w&&u[L]===!0)r.push("-"+h+L);else if(w&&u[L]===!1)continue;else r.push("-"+h+L,K(u[L]));return r};function Ru(u){let e=process.platform==="win32"?"\\r\\n":"\\n";return u.replace(/\r?\n/g,e)}var Jr=["t","m","b","tb","p","id","s","silent","appID","pid","pipeName","close","install"],$r="Notification.",Wu="Notification.Default";Yr.mapToWin8=function(u){if(u=k(u),u=z(u),u.icon){if(/^file:\/+/.test(u.icon))u.p=new wr.URL(u.icon).pathname.replace(/^\/(\w:\/)/,"$1").replace(/\//g,"\\");else u.p=u.icon;delete u.icon}if(u.message)u.m=u.message.replace(/\x1b/g,""),delete u.message;if(u.title)u.t=u.title,delete u.title;if(u.appName)u.appID=u.appName,delete u.appName;if(typeof u.remove<"u")u.close=u.remove,delete u.remove;if(u.quiet||u.silent)u.silent=u.quiet||u.silent,delete u.quiet;if(typeof u.sound<"u")u.s=u.sound,delete u.sound;if(u.s===!1)u.silent=!0,delete u.s;if(u.s&&u.silent)delete u.s;if(u.s===!0)u.s=Wu;if(u.s&&u.s.indexOf($r)!==0)u.s=Wu;if(u.actions&&eu(u.actions))u.b=u.actions.join(";"),delete u.actions;for(let e in u)if(u.hasOwnProperty(e)&&Jr.indexOf(e)===-1)delete u[e];return u};Yr.mapToNotifu=function(u){if(u=k(u),u=z(u),u.icon)u.i=u.icon,delete u.icon;if(u.message)u.m=u.message,delete u.message;if(u.title)u.p=u.title,delete u.title;if(u.time)u.d=u.time,delete u.time;if(u.q!==!1)u.q=!0;else delete u.q;if(u.quiet===!1)delete u.q,delete u.quiet;if(u.sound)delete u.q,delete u.sound;if(u.t)u.d=u.t,delete u.t;if(u.type)u.t=vr(u.type),delete u.type;return u};Yr.isMac=function(){return U.type()==="Darwin"};Yr.isMountainLion=function(){return U.type()==="Darwin"&&uu.satisfies(ru(U.release()),">=12.0.0")};Yr.isWin8=function(){return U.type()==="Windows_NT"&&uu.satisfies(ru(U.release()),">=6.2.9200")};Yr.isWSL=function(){return _r};Yr.isLessThanWin8=function(){return U.type()==="Windows_NT"&&uu.satisfies(ru(U.release()),"<6.2.9200")};function ru(u){if(u.split(".").length===2)u+=".0";return u}function vr(u){if(typeof u==="string"||u instanceof String){if(u.toLowerCase()==="info")return"info";if(u.toLowerCase()==="warn")return"warn";if(u.toLowerCase()==="error")return"error"}return"info"}Yr.createNamedPipe=(u)=>{let e=Buffer.alloc(1024);return new Promise((r)=>{u.instance=Or.createServer((f)=>{f.on("data",(h)=>{e.write(h.toString())}),f.on("end",()=>{u.instance.close()})}),u.instance.listen(u.namedPipe,()=>{r(e)})})}});var Hu=M((jh,Su)=>{var du=O("os"),Dr=yr(),I=G(),Bu=O("events").EventEmitter,cr=O("util"),l;Su.exports=d;function d(u){if(u=I.clone(u||{}),!(this instanceof d))return new d(u);this.options=u,Bu.call(this)}cr.inherits(d,Bu);function Pr(){}function Tr(u,e){if(u=I.clone(u||{}),e=e||Pr,typeof e!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof e);if(typeof u==="string")u={title:"node-notifier",message:u};if(!u.message)return e(Error("Message is required.")),this;if(du.type()!=="Linux"&&!du.type().match(/BSD$/))return e(Error("Only supported on Linux and *BSD systems")),this;if(l===!1)return e(Error("notify-send must be installed on the system.")),this;if(l||!!this.options.suppressOsdCheck)return gu(u,e),this;try{l=!!Dr.sync("notify-send"),gu(u,e)}catch(r){return l=!1,e(r)}return this}Object.defineProperty(d.prototype,"notify",{get:function(){if(!this._notify)this._notify=Tr.bind(this);return this._notify}});var mr=["urgency","expire-time","icon","category","hint","app-name"];function gu(u,e){u=I.mapToNotifySend(u),u.title=u.title||"Node Notification:";let r=[u.title,u.message];delete u.title,delete u.message;let f=I.constructArgumentList(u,{initial:r,keyExtra:"-",allowedArguments:mr});I.command("notify-send",f,e)}});var hu=M((kh,yu)=>{var xr=O("net");yu.exports=function(u,e){if(typeof e>"u")e=u,u={};let r=u.port||23053,f=u.host||"localhost",h=xr.connect(r,f);h.setTimeout(100),h.once("connect",function(){h.end(),e(null,!0)}),h.once("error",function(){h.end(),e(null,!1)})}});var Pu=M((lh,cu)=>{var jr=O("net"),kr=O("crypto"),Du=O("util").format,lr=O("fs"),Y=`\r
|
|
3
|
-
`;function N(u,e){e=e||{},this.type=u,this.host=e.host||"localhost",this.port=e.port||23053,this.request="GNTP/1.0 "+u+" NONE"+Y,this.resources=[],this.attempts=0,this.maxAttempts=5}N.prototype.parseResp=function(u){var e={},r,f;return u=u.slice(0,u.indexOf(Y+Y)).split(Y),r=u[0],f=u.slice(1),e.state=r.match(/-(OK|ERROR|CALLBACK)/)[0].slice(1),f.forEach(function(h){h=h.split(": "),e[h[0]]=h[1]}),e};N.prototype.retry=function(){var u=this,e=arguments;setTimeout(function(){u.send.apply(u,e)},750)};N.prototype.addResource=function(u){var e=kr.createHash("md5").update(u).digest("hex"),r="Identifier: "+e+Y+"Length: "+u.length+Y+Y;return this.resources.push({header:r,file:u}),"x-growl-resource://"+e};N.prototype.add=function(u,e){if(e===void 0)return;if(/-Icon/.test(u)&&!/^https?:\/\//.test(e)){if(/\.(png|gif|jpe?g)$/.test(e))e=this.addResource(lr.readFileSync(e));else if(e instanceof Buffer)e=this.addResource(e)}this.request+=u+": "+e+Y};N.prototype.newline=function(){this.request+=Y};N.prototype.send=function(u){var e=this,r=jr.connect(this.port,this.host),f="";u=u||function(){},this.attempts+=1,r.on("connect",function(){r.write(e.request),e.resources.forEach(function(h){r.write(h.header),r.write(h.file),r.write(Y+Y)})}),r.on("data",function(h){if(f+=h.toString(),f.slice(f.length-4)!==Y+Y)return;if(f=e.parseResp(f),f.state==="ERROR"||f.state==="CALLBACK")r.end();else f=""}),r.on("end",function(){if(["200","401","402"].indexOf(f["Error-Code"])>=0)if(e.attempts<=e.maxAttempts)e.retry(u);else{var h='GNTP request to "%s:%d" failed with error code %s (%s)';u(Error(Du(h,e.host,e.port,f["Error-Code"],f["Error-Description"])))}else u(void 0,f)}),r.on("error",function(){u(Error(Du('Error while sending GNTP request to "%s:%d"',e.host,e.port))),r.destroy()})};cu.exports=N});var xu=M((bh,mu)=>{var Tu=Pu();function g(){this.appname="Growly",this.notifications=void 0,this.labels=void 0,this.count=0,this.registered=!1,this.host=void 0,this.port=void 0}g.prototype.getLabels=function(){return this.notifications.map(function(u){return u.label})};g.prototype.setHost=function(u,e){this.host=u,this.port=e};g.prototype.register=function(u,e,r,f){var h;if(typeof e==="object")r=e,e=void 0;if(r===void 0||!r.length)r=[{label:"default",dispname:"Default Notification",enabled:!0}];if(typeof arguments[arguments.length-1]==="function")f=arguments[arguments.length-1];else f=function(){};this.appname=u,this.notifications=r,this.labels=this.getLabels(),this.registered=!0,h=new Tu("REGISTER",{host:this.host,port:this.port}),h.add("Application-Name",u),h.add("Application-Icon",e),h.add("Notifications-Count",r.length),h.newline(),r.forEach(function(_){if(_.enabled===void 0)_.enabled=!0;h.add("Notification-Name",_.label),h.add("Notification-Display-Name",_.dispname),h.add("Notification-Enabled",_.enabled?"True":"False"),h.add("Notification-Icon",_.icon),h.newline()}),h.send(f)};g.prototype.notify=function(u,e,r){var f=this,h;if(!this.registered){this.register(this.appname,function(_){if(_)console.log(_);f.notify.call(f,u,e,r)});return}if(e=e||{},typeof e==="function")r=e,e={};h=new Tu("NOTIFY",{host:this.host,port:this.port}),h.add("Application-Name",this.appname),h.add("Notification-Name",e.label||this.labels[0]),h.add("Notification-ID",++this.count),h.add("Notification-Title",e.title),h.add("Notification-Text",u),h.add("Notification-Sticky",e.sticky?"True":"False"),h.add("Notification-Priority",e.priority),h.add("Notification-Icon",e.icon),h.add("Notification-Coalescing-ID",e.coalescingId||void 0),h.add("Notification-Callback-Context",r?"context":void 0),h.add("Notification-Callback-Context-Type",r?"string":void 0),h.add("Notification-Callback-Target",void 0),h.newline(),h.send(function(_,q){if(r&&_)r(_);else if(r&&q.state==="CALLBACK")r(void 0,q["Notification-Callback-Result"].toLowerCase())})};mu.exports=new g});var a=M((ah,lu)=>{var br=hu(),b=G(),B=xu(),ku=O("events").EventEmitter,ar=O("util");lu.exports=S;var ju;function S(u){if(u=b.clone(u||{}),!(this instanceof S))return new S(u);B.appname=u.name||"Node",this.options=u,ku.call(this)}ar.inherits(S,ku);function nr(u,e){if(B.setHost(this.options.host,this.options.port),u=b.clone(u||{}),typeof u==="string")u={title:"node-notifier",message:u};if(e=b.actionJackerDecorator(this,u,e,function(r){if(r==="click")return"click";if(r==="timedout")return"timeout";return!1}),u=b.mapToGrowl(u),!u.message)return e(Error("Message is required.")),this;if(u.title=u.title||"Node Notification:",ju||!!u.wait){let r=u.wait?e:ir;if(B.notify(u.message,u,r),!u.wait)e();return this}return br(B,function(r,f){if(ju=f,!f)return e(Error("Couldn't connect to growl (might be used as a fallback). Make sure it is running"));B.notify(u.message,u),e()}),this}Object.defineProperty(S.prototype,"notify",{get:function(){if(!this._notify)this._notify=nr.bind(this);return this._notify}});function ir(){}});var iu=M((nh,nu)=>{var __dirname="/Users/konghayao/code/ai/code-graph/node_modules/.bun/node-notifier@10.0.1/node_modules/node-notifier/notifiers",R=G(),tr=a(),pr=O("path"),sr=pr.join(__dirname,"../vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier"),au=O("events").EventEmitter,or=O("util"),u0="You need Mac OS X 10.8 or above to use NotificationCenter, or use Growl fallback with constructor option {withFallback: true}.";nu.exports=H;function H(u){if(u=R.clone(u||{}),!(this instanceof H))return new H(u);this.options=u,au.call(this)}or.inherits(H,au);var bu=null;function e0(){}function r0(u,e){let r,f=h0();if(u=R.clone(u||{}),bu=f,typeof u==="string")u={title:"node-notifier",message:u};if(e=e||e0,typeof e!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof fn);let h=R.actionJackerDecorator(this,u,e,function(q){if(bu!==f)return!1;if(q==="activate")return"click";if(q==="timeout")return"timeout";if(q==="replied")return"replied";return!1});if(u=R.mapToMac(u),!u.message&&!u.group&&!u.list&&!u.remove)return e(Error("Message, group, remove or list property is required.")),this;let _=R.constructArgumentList(u);if(R.isMountainLion())return R.fileCommandJson(this.options.customPath||sr,_,h),this;if(r||!!this.options.withFallback)return r=r||new tr(this.options),r.notify(u,e);return e(Error(u0)),this}Object.defineProperty(H.prototype,"notify",{get:function(){if(!this._notify)this._notify=r0.bind(this);return this._notify}});function h0(){return{_ref:"val"}}});var fu=M((ih,ou)=>{var __dirname="/Users/konghayao/code/ai/code-graph/node_modules/.bun/node-notifier@10.0.1/node_modules/node-notifier/notifiers",f0=O("path"),_0=f0.resolve(__dirname,"../vendor/notifu/notifu"),q0=hu(),V=G(),w0=_u(),tu=a(),O0=O("os"),su=O("events").EventEmitter,E0=O("util"),n;ou.exports=y;function y(u){if(u=V.clone(u||{}),!(this instanceof y))return new y(u);this.options=u,su.call(this)}E0.inherits(y,su);function M0(){}function C0(u,e){let r,f=this.options;if(u=V.clone(u||{}),e=e||M0,typeof u==="string")u={title:"node-notifier",message:u};let h=V.actionJackerDecorator(this,u,e,function(_){if(_==="activate")return"click";if(_==="timeout")return"timeout";return!1});if(!!this.options.withFallback&&V.isWin8())return r=r||new w0(f),r.notify(u,e);if(!!this.options.withFallback&&(!V.isLessThanWin8()||n===!0))return r=r||new tu(f),r.notify(u,e);if(!this.options.withFallback||n===!1)return pu(u,f,h),this;return q0(f,function(_,q){if(n=q,n)return r=r||new tu(f),r.notify(u,e);pu(u,f,h)}),this}Object.defineProperty(y.prototype,"notify",{get:function(){if(!this._notify)this._notify=C0.bind(this);return this._notify}});var L0=["t","d","p","m","i","e","q","w","xp"];function pu(u,e,r){let f=O0.arch()==="x64";u=u||{},u=V.mapToNotifu(u),u.p=u.p||"Node Notification:";let h=_0+(f?"64":"")+".exe",_=e.customPath||h;if(!u.m)return r(Error("Message is required.")),this;let q=V.constructArgumentList(u,{wrapper:"",noEscape:!0,explicitTrue:!0,allowedArguments:L0});if(u.wait)return V.fileCommand(_,q,function(E,w){let C=J0(E.code);if(C==="error")return r(E,w);return r(null,C)});V.immediateFileCommand(_,q,r)}function J0(u){switch(u){case 2:return"timeout";case 3:case 6:case 7:return"activate";case 4:return"close";default:return"error"}}});var qu=M((ue)=>{Object.defineProperty(ue,"__esModule",{value:!0});ue.default=Y0;var $0=v0(O("crypto"));function v0(u){return u&&u.__esModule?u:{default:u}}var t=new Uint8Array(256),i=t.length;function Y0(){if(i>t.length-16)$0.default.randomFillSync(t),i=0;return t.slice(i,i+=16)}});var he=M((ee)=>{Object.defineProperty(ee,"__esModule",{value:!0});ee.default=void 0;var X0=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;ee.default=X0});var D=M((fe)=>{Object.defineProperty(fe,"__esModule",{value:!0});fe.default=void 0;var K0=Z0(he());function Z0(u){return u&&u.__esModule?u:{default:u}}function V0(u){return typeof u==="string"&&K0.default.test(u)}var Q0=V0;fe.default=Q0});var c=M((qe)=>{Object.defineProperty(qe,"__esModule",{value:!0});qe.default=void 0;var F0=U0(D());function U0(u){return u&&u.__esModule?u:{default:u}}var v=[];for(let u=0;u<256;++u)v.push((u+256).toString(16).substr(1));function G0(u,e=0){let r=(v[u[e+0]]+v[u[e+1]]+v[u[e+2]]+v[u[e+3]]+"-"+v[u[e+4]]+v[u[e+5]]+"-"+v[u[e+6]]+v[u[e+7]]+"-"+v[u[e+8]]+v[u[e+9]]+"-"+v[u[e+10]]+v[u[e+11]]+v[u[e+12]]+v[u[e+13]]+v[u[e+14]]+v[u[e+15]]).toLowerCase();if(!(0,F0.default)(r))throw TypeError("Stringified UUID is invalid");return r}var N0=G0;qe.default=N0});var Le=M((Me)=>{Object.defineProperty(Me,"__esModule",{value:!0});Me.default=void 0;var R0=Ee(qu()),W0=Ee(c());function Ee(u){return u&&u.__esModule?u:{default:u}}var Oe,wu,Ou=0,Eu=0;function z0(u,e,r){let f=e&&r||0,h=e||Array(16);u=u||{};let _=u.node||Oe,q=u.clockseq!==void 0?u.clockseq:wu;if(_==null||q==null){let L=u.random||(u.rng||R0.default)();if(_==null)_=Oe=[L[0]|1,L[1],L[2],L[3],L[4],L[5]];if(q==null)q=wu=(L[6]<<8|L[7])&16383}let E=u.msecs!==void 0?u.msecs:Date.now(),w=u.nsecs!==void 0?u.nsecs:Eu+1,C=E-Ou+(w-Eu)/1e4;if(C<0&&u.clockseq===void 0)q=q+1&16383;if((C<0||E>Ou)&&u.nsecs===void 0)w=0;if(w>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");Ou=E,Eu=w,wu=q,E+=12219292800000;let X=((E&268435455)*1e4+w)%4294967296;h[f++]=X>>>24&255,h[f++]=X>>>16&255,h[f++]=X>>>8&255,h[f++]=X&255;let K=E/4294967296*1e4&268435455;h[f++]=K>>>8&255,h[f++]=K&255,h[f++]=K>>>24&15|16,h[f++]=K>>>16&255,h[f++]=q>>>8|128,h[f++]=q&255;for(let L=0;L<6;++L)h[f+L]=_[L];return e||(0,W0.default)(h)}var I0=z0;Me.default=I0});var Mu=M((Je)=>{Object.defineProperty(Je,"__esModule",{value:!0});Je.default=void 0;var d0=g0(D());function g0(u){return u&&u.__esModule?u:{default:u}}function B0(u){if(!(0,d0.default)(u))throw TypeError("Invalid UUID");let e,r=new Uint8Array(16);return r[0]=(e=parseInt(u.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=e&255,r[4]=(e=parseInt(u.slice(9,13),16))>>>8,r[5]=e&255,r[6]=(e=parseInt(u.slice(14,18),16))>>>8,r[7]=e&255,r[8]=(e=parseInt(u.slice(19,23),16))>>>8,r[9]=e&255,r[10]=(e=parseInt(u.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=e&255,r}var S0=B0;Je.default=S0});var Cu=M((Xe)=>{Object.defineProperty(Xe,"__esModule",{value:!0});Xe.default=c0;Xe.URL=Xe.DNS=void 0;var H0=ve(c()),y0=ve(Mu());function ve(u){return u&&u.__esModule?u:{default:u}}function D0(u){u=unescape(encodeURIComponent(u));let e=[];for(let r=0;r<u.length;++r)e.push(u.charCodeAt(r));return e}var Ye="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Xe.DNS=Ye;var Ae="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Xe.URL=Ae;function c0(u,e,r){function f(h,_,q,E){if(typeof h==="string")h=D0(h);if(typeof _==="string")_=(0,y0.default)(_);if(_.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let w=new Uint8Array(16+h.length);if(w.set(_),w.set(h,_.length),w=r(w),w[6]=w[6]&15|e,w[8]=w[8]&63|128,q){E=E||0;for(let C=0;C<16;++C)q[E+C]=w[C];return q}return(0,H0.default)(w)}try{f.name=u}catch(h){}return f.DNS=Ye,f.URL=Ae,f}});var Qe=M((Ze)=>{Object.defineProperty(Ze,"__esModule",{value:!0});Ze.default=void 0;var m0=x0(O("crypto"));function x0(u){return u&&u.__esModule?u:{default:u}}function j0(u){if(Array.isArray(u))u=Buffer.from(u);else if(typeof u==="string")u=Buffer.from(u,"utf8");return m0.default.createHash("md5").update(u).digest()}var k0=j0;Ze.default=k0});var Ne=M((Ue)=>{Object.defineProperty(Ue,"__esModule",{value:!0});Ue.default=void 0;var l0=Fe(Cu()),b0=Fe(Qe());function Fe(u){return u&&u.__esModule?u:{default:u}}var a0=(0,l0.default)("v3",48,b0.default),n0=a0;Ue.default=n0});var Ie=M((We)=>{Object.defineProperty(We,"__esModule",{value:!0});We.default=void 0;var i0=Re(qu()),t0=Re(c());function Re(u){return u&&u.__esModule?u:{default:u}}function p0(u,e,r){u=u||{};let f=u.random||(u.rng||i0.default)();if(f[6]=f[6]&15|64,f[8]=f[8]&63|128,e){r=r||0;for(let h=0;h<16;++h)e[r+h]=f[h];return e}return(0,t0.default)(f)}var s0=p0;We.default=s0});var Be=M((de)=>{Object.defineProperty(de,"__esModule",{value:!0});de.default=void 0;var o0=uh(O("crypto"));function uh(u){return u&&u.__esModule?u:{default:u}}function eh(u){if(Array.isArray(u))u=Buffer.from(u);else if(typeof u==="string")u=Buffer.from(u,"utf8");return o0.default.createHash("sha1").update(u).digest()}var rh=eh;de.default=rh});var De=M((He)=>{Object.defineProperty(He,"__esModule",{value:!0});He.default=void 0;var hh=Se(Cu()),fh=Se(Be());function Se(u){return u&&u.__esModule?u:{default:u}}var _h=(0,hh.default)("v5",80,fh.default),qh=_h;He.default=qh});var Te=M((ce)=>{Object.defineProperty(ce,"__esModule",{value:!0});ce.default=void 0;var wh="00000000-0000-0000-0000-000000000000";ce.default=wh});var je=M((me)=>{Object.defineProperty(me,"__esModule",{value:!0});me.default=void 0;var Oh=Eh(D());function Eh(u){return u&&u.__esModule?u:{default:u}}function Mh(u){if(!(0,Oh.default)(u))throw TypeError("Invalid UUID");return parseInt(u.substr(14,1),16)}var Ch=Mh;me.default=Ch});var ke=M((A)=>{Object.defineProperty(A,"__esModule",{value:!0});Object.defineProperty(A,"v1",{enumerable:!0,get:function(){return Lh.default}});Object.defineProperty(A,"v3",{enumerable:!0,get:function(){return Jh.default}});Object.defineProperty(A,"v4",{enumerable:!0,get:function(){return $h.default}});Object.defineProperty(A,"v5",{enumerable:!0,get:function(){return vh.default}});Object.defineProperty(A,"NIL",{enumerable:!0,get:function(){return Yh.default}});Object.defineProperty(A,"version",{enumerable:!0,get:function(){return Ah.default}});Object.defineProperty(A,"validate",{enumerable:!0,get:function(){return Xh.default}});Object.defineProperty(A,"stringify",{enumerable:!0,get:function(){return Kh.default}});Object.defineProperty(A,"parse",{enumerable:!0,get:function(){return Zh.default}});var Lh=Q(Le()),Jh=Q(Ne()),$h=Q(Ie()),vh=Q(De()),Yh=Q(Te()),Ah=Q(je()),Xh=Q(D()),Kh=Q(c()),Zh=Q(Mu());function Q(u){return u&&u.__esModule?u:{default:u}}});var _u=M((Cf,be)=>{var __dirname="/Users/konghayao/code/ai/code-graph/node_modules/.bun/node-notifier@10.0.1/node_modules/node-notifier/notifiers",Vh=O("path"),Qh=Vh.resolve(__dirname,"../vendor/snoreToast/snoretoast"),Z=G(),Fh=fu(),Uh=O("os"),{v4:Gh}=ke(),le=O("events").EventEmitter,Nh=O("util"),Lu;be.exports=P;function P(u){if(u=Z.clone(u||{}),!(this instanceof P))return new P(u);this.options=u,le.call(this)}Nh.inherits(P,le);function Rh(){}function Wh(u){if(!u)return{};return u.split(";").reduce((e,r)=>{let f=r.split("=");if(f&&f.length===2)e[f[0]]=f[1];return e},{})}function zh(){return`${Z.isWSL()?"/tmp/":"\\\\.\\pipe\\"}notifierPipe-${Gh()}`}function Ih(u,e){u=Z.clone(u||{}),e=e||Rh;let r=Uh.arch()==="x64",f,h={namedPipe:zh()};if(typeof u==="string")u={title:"node-notifier",message:u};if(typeof e!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof fn);let _=(E,w)=>{let C=Wh(f&&f.toString("utf16le"));if(C.action==="buttonClicked"&&C.button)C.activationType=C.button;else if(C.action)C.activationType=C.action;if(E&&E.code===-1)w(E,C);w(null,C),h.instance&&h.instance.close()},q=(E)=>_(E,Z.actionJackerDecorator(this,u,e,(w)=>w==="activate"?"click":w||!1));if(u.title=u.title||"Node Notification:",typeof u.message>"u"&&typeof u.close>"u")return e(Error("Message or ID to close is required.")),this;if(!Z.isWin8()&&!Z.isWSL()&&!!this.options.withFallback)return Lu=Lu||new Fh(this.options),Lu.notify(u,e);return Z.createNamedPipe(h).then((E)=>{f=E,u.pipeName=h.namedPipe;let w=u.customPath||this.options.customPath||Qh+"-x"+(r?"64":"86")+".exe";u=Z.mapToWin8(u);let C=Z.constructArgumentList(u,{explicitTrue:!0,wrapper:"",keepNewlines:!0,noEscape:!0});Z.fileCommand(w,C,q)}),this}Object.defineProperty(P.prototype,"notify",{get:function(){if(!this._notify)this._notify=Ih.bind(this);return this._notify}})});var ie=M((Lf,$)=>{var ae=O("os"),ne=G(),T=Hu(),Ju=iu(),m=_u(),$u=a(),vu=fu(),W={withFallback:!0},dh=ne.isWSL()?"WSL":ae.type();switch(dh){case"Linux":$.exports=new T(W),$.exports.Notification=T;break;case"Darwin":$.exports=new Ju(W),$.exports.Notification=Ju;break;case"Windows_NT":if(ne.isLessThanWin8())$.exports=new vu(W),$.exports.Notification=vu;else $.exports=new m(W),$.exports.Notification=m;break;case"WSL":$.exports=new m(W),$.exports.Notification=m;break;default:if(ae.type().match(/BSD$/))$.exports=new T(W),$.exports.Notification=T;else $.exports=new $u(W),$.exports.Notification=$u}$.exports.NotifySend=T;$.exports.NotificationCenter=Ju;$.exports.WindowsToaster=m;$.exports.WindowsBalloon=vu;$.exports.Growl=$u});import Au from"node:path";import te from"node:os";import x from"node:fs";function pe(u){let e=u.replace(/^~/,te.homedir()),r=Au.resolve(e),f=Au.dirname(r);if(!x.existsSync(f))x.mkdirSync(f,{recursive:!0});return r}function se(u,e){if(!x.existsSync(u)){process.env.DATABASE_INIT="true";return}let r=process.env.SQLITE_MAX_SIZE_MB?parseInt(process.env.SQLITE_MAX_SIZE_MB,10)*1024*1024:void 0,f=e??r??104857600,_=x.statSync(u).size,q=_/1048576;if(_>f){let E=f/1048576;console.warn(`⚠️ Database file is large: ${q.toFixed(2)}MB (limit: ${E.toFixed(2)}MB)`),console.warn(` Path: ${u}`),console.warn(" Set SQLITE_MAX_SIZE_MB to adjust limit")}}function yh(u){let e=pe(u);return process.env.SQLITE_DATABASE_URI=e,se(e),e}var Yu=gh(ie(),1);function Jf(u){if(typeof u==="string")Yu.default.notify({title:"Notification",message:u});else Yu.default.notify({title:u.title||"Notification",message:u.message,icon:u.icon,sound:u.sound??!0})}var vf={path:process.cwd()};export{yh as ve,Jf as we,vf as xe};
|
package/dist/chunk-t7rwtc17.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{kq as a}from"./chunk-578m1dhj.js";import"./chunk-1p9xzvpt.js";import"./chunk-hra0748z.js";import"./chunk-dcs1r9as.js";export{a as FileSystemConfigStore};
|
package/dist/chunk-v8g52kan.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as A,f as W}from"./chunk-rt5mpgbg.js";import"./chunk-8f2zh5h6.js";import{bh as q,th as R}from"./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-h1enhch1.js";import"./chunk-hyf24r36.js";import{pq as V}from"./chunk-dcs1r9as.js";var x=V(W(),1);function B(M){if(M===null||typeof M!=="object")return JSON.stringify(M);if(Array.isArray(M))return JSON.stringify(M.map((J)=>B(J)));let F={},G=Object.keys(M).sort();for(let J of G)F[J]=M[J];return JSON.stringify(F,(J,Q)=>{if(Q!==null&&typeof Q==="object"&&!Array.isArray(Q)){let X={},Y=Object.keys(Q).sort();for(let Z of Y)X[Z]=Q[Z];return X}return Q})}var P=[{index:"checkpoints",prefix:"checkpoint:",schema:{"$.thread_id":{type:"TAG",AS:"thread_id"},"$.checkpoint_ns":{type:"TAG",AS:"checkpoint_ns"},"$.checkpoint_id":{type:"TAG",AS:"checkpoint_id"},"$.parent_checkpoint_id":{type:"TAG",AS:"parent_checkpoint_id"},"$.checkpoint_ts":{type:"NUMERIC",AS:"checkpoint_ts"},"$.has_writes":{type:"TAG",AS:"has_writes"},"$.source":{type:"TAG",AS:"source"},"$.step":{type:"NUMERIC",AS:"step"}}},{index:"checkpoint_writes",prefix:"checkpoint_write:",schema:{"$.thread_id":{type:"TAG",AS:"thread_id"},"$.checkpoint_ns":{type:"TAG",AS:"checkpoint_ns"},"$.checkpoint_id":{type:"TAG",AS:"checkpoint_id"},"$.task_id":{type:"TAG",AS:"task_id"},"$.idx":{type:"NUMERIC",AS:"idx"},"$.channel":{type:"TAG",AS:"channel"},"$.type":{type:"TAG",AS:"type"}}}],N=class M extends R{client;ttlConfig;constructor(F,G){super();this.client=F,this.ttlConfig=G}static async fromUrl(F,G){let J=x.createClient({url:F});await J.connect();let Q=new M(J,G);return await Q.ensureIndexes(),Q}async get(F){return(await this.getTuple(F))?.checkpoint}async put(F,G,J,Q){await this.ensureIndexes();let X=F.configurable?.thread_id,Y=F.configurable?.checkpoint_ns??"",Z=F.configurable?.checkpoint_id;if(!X)throw Error("thread_id is required");let _=G.id||q(0),E=`checkpoint:${X}:${Y}:shallow`,H=null,$=null;try{if(H=await this.client.json.get(E),H&&typeof H==="object")$=H.checkpoint_id}catch(O){}if($&&$!==_)await this.cleanupOldCheckpoint(X,Y,$);let L={...G,channel_values:G.channel_values||{},channel_blobs:void 0},U={thread_id:X,checkpoint_ns:Y,checkpoint_id:_,parent_checkpoint_id:Z||null,checkpoint:L,metadata:this.sanitizeMetadata(J),checkpoint_ts:Date.now(),has_writes:"false"};if(this.addSearchableMetadataFields(U,J),await this.client.json.set(E,"$",U),this.ttlConfig?.defaultTTL)await this.applyTTL(E);return{configurable:{thread_id:X,checkpoint_ns:Y,checkpoint_id:_}}}async getTuple(F){let G=F.configurable?.thread_id,J=F.configurable?.checkpoint_ns??"",Q=F.configurable?.checkpoint_id;if(!G)return;let X=`checkpoint:${G}:${J}:shallow`,Y=await this.client.json.get(X);if(!Y)return;if(Q&&Y.checkpoint_id!==Q)return;if(this.ttlConfig?.refreshOnRead&&this.ttlConfig?.defaultTTL)await this.applyTTL(X);let Z=await this.serde.loadsTyped("json",JSON.stringify(Y.checkpoint)),_;if(Y.has_writes==="true")_=await this.loadPendingWrites(Y.thread_id,Y.checkpoint_ns,Y.checkpoint_id);return await this.createCheckpointTuple(Y,Z,_)}async*list(F,G){if(await this.ensureIndexes(),F?.configurable?.thread_id){let J=await this.getTuple(F);if(J)if(G?.filter){if(this.checkMetadataFilterMatch(J.metadata,G.filter))yield J}else yield J}else{let J=[];if(G?.filter){for(let[Y,Z]of Object.entries(G.filter))if(Z===void 0);else if(Z===null);else if(typeof Z==="string"){let _=A(Y),E=A(Z);J.push(`(@${_}:{${E}})`)}else if(typeof Z==="number"){let _=A(Y);J.push(`(@${_}:[${Z} ${Z}])`)}}if(J.length===0)J.push("*");let Q=J.join(" "),X=G?.limit??10;try{let Y=await this.client.ft.search("checkpoints",Q,{LIMIT:{from:0,size:X*2},SORTBY:{BY:"checkpoint_ts",DIRECTION:"DESC"}}),Z=new Set,_=0;for(let E of Y.documents){if(_>=X)break;let H=E.value,$=`${H.thread_id}:${H.checkpoint_ns}`;if(Z.has($))continue;if(Z.add($),G?.filter){if(!this.checkMetadataFilterMatch(H.metadata,G.filter))continue}let L=await this.serde.loadsTyped("json",JSON.stringify(H.checkpoint));yield await this.createCheckpointTuple(H,L),_++}}catch(Y){if(Y.message?.includes("no such index")){let Z=await this.client.keys("checkpoint:*:*:shallow");if(Z.length===0)return;Z.sort().reverse();let _=new Set,E=0,H=G?.limit??10;for(let $ of Z){if(E>=H)break;let L=await this.client.json.get($);if(!L)continue;let U=`${L.thread_id}:${L.checkpoint_ns}`;if(_.has(U))continue;if(_.add(U),G?.filter){if(!this.checkMetadataFilterMatch(L.metadata,G.filter))continue}let O=await this.serde.loadsTyped("json",JSON.stringify(L.checkpoint));yield await this.createCheckpointTuple(L,O),E++}return}throw Y}}}async putWrites(F,G,J){await this.ensureIndexes();let Q=F.configurable?.thread_id,X=F.configurable?.checkpoint_ns??"",Y=F.configurable?.checkpoint_id;if(!Q||!Y)throw Error("thread_id and checkpoint_id are required");let Z=`checkpoint_write:${Q}:${X}:${Y}:${J}:*`,_=await this.client.keys(Z);if(_.length>0)await this.client.del(_);let E=[];for(let $=0;$<G.length;$++){let[L,U]=G[$],O=`checkpoint_write:${Q}:${X}:${Y}:${J}:${$}`;E.push(O);let T={thread_id:Q,checkpoint_ns:X,checkpoint_id:Y,task_id:J,idx:$,channel:L,type:typeof U==="object"?"json":"string",value:U};await this.client.json.set(O,"$",T)}if(E.length>0){let $=`write_keys_zset:${Q}:${X}:${Y}`,L={};if(E.forEach((U,O)=>{L[U]=O}),await this.client.zAdd($,Object.entries(L).map(([U,O])=>({score:O,value:U}))),this.ttlConfig?.defaultTTL)await this.applyTTL(...E,$)}let H=`checkpoint:${Q}:${X}:shallow`;if(await this.client.exists(H)){let $=await this.client.json.get(H);if($)$.has_writes="true",await this.client.json.set(H,"$",$)}}async deleteThread(F){let G=`checkpoint:${F}:*:shallow`,J=await this.client.keys(G);if(J.length>0)await this.client.del(J);let Q=`checkpoint_write:${F}:*`,X=await this.client.keys(Q);if(X.length>0)await this.client.del(X);let Y=`write_keys_zset:${F}:*`,Z=await this.client.keys(Y);if(Z.length>0)await this.client.del(Z)}async end(){await this.client.quit()}addSearchableMetadataFields(F,G){if(!G)return;if("source"in G)F.source=G.source;if("step"in G)F.step=G.step;if("writes"in G)F.writes=typeof G.writes==="object"?JSON.stringify(G.writes):G.writes;if("score"in G)F.score=G.score}async createCheckpointTuple(F,G,J){let Q=await this.serde.loadsTyped("json",JSON.stringify(F.metadata));return{config:{configurable:{thread_id:F.thread_id,checkpoint_ns:F.checkpoint_ns,checkpoint_id:F.checkpoint_id}},checkpoint:G,metadata:Q,parentConfig:F.parent_checkpoint_id?{configurable:{thread_id:F.thread_id,checkpoint_ns:F.checkpoint_ns,checkpoint_id:F.parent_checkpoint_id}}:void 0,pendingWrites:J}}async applyTTL(...F){if(!this.ttlConfig?.defaultTTL)return;let G=Math.floor(this.ttlConfig.defaultTTL*60),J=await Promise.allSettled(F.map((Q)=>this.client.expire(Q,G)));for(let Q=0;Q<J.length;Q++)if(J[Q].status==="rejected")console.warn(`Failed to set TTL for key ${F[Q]}:`,J[Q].reason)}async loadPendingWrites(F,G,J){let Q=`write_keys_zset:${F}:${G}:${J}`,X=await this.client.zRange(Q,0,-1);if(X.length===0)return;let Y=[];for(let Z of X){let _=await this.client.json.get(Z);if(_){let E=await this.serde.loadsTyped("json",JSON.stringify(_.value));Y.push([_.task_id,_.channel,E])}}return Y}checkMetadataFilterMatch(F,G){for(let[J,Q]of Object.entries(G)){let X=F?.[J];if(Q===null){if(!(J in(F||{}))||X!==null)return!1}else if(typeof Q==="object"&&!Array.isArray(Q)){if(typeof X!=="object"||X===null)return!1;if(B(Q)!==B(X))return!1}else if(X!==Q)return!1}return!0}async cleanupOldCheckpoint(F,G,J){let Q=`checkpoint_write:${F}:${G}:${J}:*`,X=await this.client.keys(Q);if(X.length>0)await this.client.del(X);let Y=`write_keys_zset:${F}:${G}:${J}`;await this.client.del(Y);let Z=`checkpoint_blob:${F}:${G}:${J}:*`,_=await this.client.keys(Z);if(_.length>0)await this.client.del(_)}sanitizeMetadata(F){if(!F)return{};let G={};for(let[J,Q]of Object.entries(F)){let X=J.replace(/\x00/g,"");G[X]=typeof Q==="string"?Q.replace(/\x00/g,""):Q}return G}async ensureIndexes(){for(let F of P)try{await this.client.ft.create(F.index,F.schema,{ON:"JSON",PREFIX:F.prefix})}catch(G){if(!G.message?.includes("Index already exists"))console.error(`Failed to create index ${F.index}:`,G.message)}}};export{N as ShallowRedisSaver};
|
package/dist/chunk-vd6c87cm.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Z as Y0}from"./chunk-pndhbee8.js";import{Pg as Z0,Qg as X0}from"./chunk-afhxxkmv.js";import{bh as o,dh as j,qh as d,sh as r,th as t,vh as a,wh as e,xh as $0}from"./chunk-ac5t2ywn.js";import{Rj as n,uk as s}from"./chunk-w2hbsa9j.js";import{tq as L}from"./chunk-dcs1r9as.js";var K=[];for(let $=0;$<256;++$)K.push(($+256).toString(16).slice(1));function p($,Z=0){return(K[$[Z+0]]+K[$[Z+1]]+K[$[Z+2]]+K[$[Z+3]]+"-"+K[$[Z+4]]+K[$[Z+5]]+"-"+K[$[Z+6]]+K[$[Z+7]]+"-"+K[$[Z+8]]+K[$[Z+9]]+"-"+K[$[Z+10]]+K[$[Z+11]]+K[$[Z+12]]+K[$[Z+13]]+K[$[Z+14]]+K[$[Z+15]]).toLowerCase()}import{randomFillSync as V0}from"node:crypto";var w=new Uint8Array(256),S=w.length;function G(){if(S>w.length-16)V0(w),S=0;return w.slice(S,S+=16)}var m={};function K0($,Z,X){let Y;if($)Y=l($.random??$.rng?.()??G(),$.msecs,$.seq,Z,X);else{let J=Date.now(),U=G();F0(m,J,U),Y=l(U,m.msecs,m.seq,Z,X)}return Z??p(Y)}function F0($,Z,X){if($.msecs??=-1/0,$.seq??=0,Z>$.msecs)$.seq=X[6]<<23|X[7]<<16|X[8]<<8|X[9],$.msecs=Z;else if($.seq=$.seq+1|0,$.seq===0)$.msecs++;return $}function l($,Z,X,Y,J=0){if($.length<16)throw Error("Random bytes length must be >= 16");if(!Y)Y=new Uint8Array(16),J=0;else if(J<0||J+16>Y.length)throw RangeError(`UUID byte range ${J}:${J+15} is out of buffer bounds`);return Z??=Date.now(),X??=$[6]*127<<24|$[7]<<16|$[8]<<8|$[9],Y[J++]=Z/1099511627776&255,Y[J++]=Z/4294967296&255,Y[J++]=Z/16777216&255,Y[J++]=Z/65536&255,Y[J++]=Z/256&255,Y[J++]=Z&255,Y[J++]=112|X>>>28&15,Y[J++]=X>>>20&255,Y[J++]=128|X>>>14&63,Y[J++]=X>>>6&255,Y[J++]=X<<2&255|$[10]&3,Y[J++]=$[11],Y[J++]=$[12],Y[J++]=$[13],Y[J++]=$[14],Y[J++]=$[15],Y}var B=K0;var A0=($)=>{let Z=$.goto!=null&&!Array.isArray($.goto)?[$.goto]:$.goto;return new X0({goto:Z?.map((X)=>{if(typeof X!=="string")return new Z0(X.node,X.input);return X}),update:$.update??void 0,resume:$.resume})},i="[...]",B0="[Circular]",M=[],E=[];function N0(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function R0($,Z,X,Y){if(typeof Y>"u")Y=N0();k($,"",0,[],void 0,0,Y);var J;try{if(E.length===0)J=JSON.stringify($,Z,X);else J=JSON.stringify($,L0(Z),X)}catch(H){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{while(M.length!==0){var U=M.pop();if(U.length===4)Object.defineProperty(U[0],U[1],U[3]);else U[0][U[1]]=U[2]}}return J}function b($,Z,X,Y){var J=Object.getOwnPropertyDescriptor(Y,X);if(J.get!==void 0)if(J.configurable)Object.defineProperty(Y,X,{value:$}),M.push([Y,X,Z,J]);else E.push([Z,X,$]);else Y[X]=$,M.push([Y,X,Z])}function k($,Z,X,Y,J,U,H){U+=1;var x;if(typeof $==="object"&&$!==null){for(x=0;x<Y.length;x++)if(Y[x]===$){b(B0,$,Z,J);return}if(typeof H.depthLimit<"u"&&U>H.depthLimit){b(i,$,Z,J);return}if(typeof H.edgesLimit<"u"&&X+1>H.edgesLimit){b(i,$,Z,J);return}if(Y.push($),Array.isArray($))for(x=0;x<$.length;x++)k($[x],x,x,Y,$,U,H);else{var W=Object.keys($);for(x=0;x<W.length;x++){var Q=W[x];k($[Q],Q,x,Y,$,U,H)}}Y.pop()}}function L0($){return $=typeof $<"u"?$:function(Z,X){return X},function(Z,X){if(E.length>0)for(var Y=0;Y<E.length;Y++){var J=E[Y];if(J[1]===Z&&J[0]===X){X=J[2],E.splice(Y,1);break}}return $.call(this,Z,X)}}function _0($){return $!==null&&$.lc===1&&$.type==="constructor"&&Array.isArray($.id)}async function y($){if($&&typeof $==="object")if(Array.isArray($))return await Promise.all($.map((X)=>y(X)));else{let Z={};for(let[X,Y]of Object.entries($))Z[X]=await y(Y);if(Z.lc===2&&Z.type==="undefined")return;else if(Z.lc===2&&Z.type==="constructor"&&Array.isArray(Z.id))try{let X=Z.id[Z.id.length-1],Y;switch(X){case"Set":Y=Set;break;case"Map":Y=Map;break;case"RegExp":Y=RegExp;break;case"Error":Y=Error;break;default:return Z}if(Z.method)return Y[Z.method](...Z.args||[]);else return new Y(...Z.args||[])}catch(X){return Z}else if(_0(Z))return d(JSON.stringify(Z));return Z}return $}function v($,Z,X,Y){return{lc:2,type:"constructor",id:[$.name],method:Z??null,args:X??[],kwargs:Y??{}}}function E0($){if($===void 0)return{lc:2,type:"undefined"};else if($ instanceof Set||$ instanceof Map)return v($.constructor,void 0,[Array.from($)]);else if($ instanceof RegExp)return v(RegExp,void 0,[$.source,$.flags]);else if($ instanceof Error)return v($.constructor,void 0,[$.message]);else if($?.lg_name==="Send")return{node:$.node,args:$.args};else return $}class J0{_dumps($){return new TextEncoder().encode(R0($,(X,Y)=>{return E0(Y)}))}async dumpsTyped($){if($ instanceof Uint8Array)return["bytes",$];else return["json",this._dumps($)]}async _loads($){let Z=JSON.parse($);return y(Z)}async loadsTyped($,Z){if($==="bytes")return typeof Z==="string"?new TextEncoder().encode(Z):Z;else if($==="json")return this._loads(typeof Z==="string"?Z:new TextDecoder().decode(Z));else throw Error(`Unknown serialization type: ${$}`)}}class U0 extends Y0.default{constructor($,Z=!0,X=300){super();this.id=$,this.compressMessages=Z,this.ttl=X}serializer=new J0;async encodeData($){let[Z,X]=await this.serializer.dumpsTyped($);return X}async decodeData($){return await this.serializer.loadsTyped("json",$)}}class H0{queues=new Map;defaultCompressMessages;queueConstructor;constructor($,Z={}){this.defaultCompressMessages=Z.defaultCompressMessages??!0,this.queueConstructor=$}createQueue($,Z=300){return this.queues.set($,new this.queueConstructor($,this.defaultCompressMessages,Z)),this.queues.get($)}async getQueue($){let Z=this.queues.get($);if(!Z)if(await this.queueConstructor?.isQueueExist?.($))return this.createQueue($);else throw Error(`Queue with id '${$}' does not exist`);return Z}async cancelQueue($){await this.removeQueue($)}async pushToQueue($,Z){await(await this.getQueue($)).push(Z)}async getQueueData($){let Z=this.queues.get($);if(!Z)throw Error(`Queue with id '${$}' does not exist`);return await Z.getAll()}async clearQueue($){let Z=this.queues.get($);if(Z){let X=Z.clear();if(X instanceof Promise)await X}}async removeQueue($){let Z=this.queues.get($);if(!Z)return!1;try{await Z.cancel()}catch(X){console.error("Error cancelling queue:",X)}try{let X=Z.clear();if(X instanceof Promise)await X}catch(X){console.error("Error clearing queue:",X)}if(typeof Z.destroy==="function")try{await Z.destroy()}catch(X){console.error("Error destroying queue:",X)}return this.queues.delete($)}getAllQueueIds(){return Array.from(this.queues.keys())}async getAllQueuesData(){let $={};for(let[Z,X]of this.queues)$[Z]=await X.getAll();return $}clearAllQueues(){for(let $ of this.queues.values())$.clear()}async copyQueue($,Z,X){let J=await(await this.getQueue($)).copyToQueue(Z,X);return this.queues.set(Z,J),J}}var T={};async function n0($,Z){T[$]=Z}async function x0($,Z,X){if(!T[$])throw Error(`Graph "${$}" not found`);let Y=typeof T[$]==="function"?await T[$](Z??{configurable:{}}):T[$];if(typeof X?.checkpointer<"u")Y.checkpointer=X?.checkpointer??F.globalCheckPointer;else Y.checkpointer=F.globalCheckPointer;return Y.store=X?.store??void 0,Y}class I{db;adapter;constructor($){this.db=$.db,this.adapter=$}async setup(){await this.adapter.createTables(this.db),await this.adapter.createIndexes(this.db)}async create($){let Z=$?.threadId||B(),X=new Date,Y=$?.metadata||{},J={};if($?.ifExists==="raise"){if(await this.db.selectFrom("threads").select("thread_id").where("thread_id","=",Z).executeTakeFirst())throw Error(`Thread with ID ${Z} already exists.`)}if($?.ifExists==="do_nothing"&&$?.threadId){let U=await this.db.selectFrom("threads").selectAll().where("thread_id","=",Z).executeTakeFirst();if(U)return{thread_id:U.thread_id,created_at:this.adapter.dbToDate(U.created_at).toISOString(),updated_at:this.adapter.dbToDate(U.updated_at).toISOString(),state_updated_at:this.adapter.dbToDate(U.updated_at).toISOString(),metadata:this.adapter.dbToJson(U.metadata),status:U.status,values:U.values?this.adapter.dbToJson(U.values):null,interrupts:this.adapter.dbToJson(U.interrupts),title:U.title}}return await this.db.insertInto("threads").values({thread_id:Z,created_at:this.adapter.dateToDb(X),updated_at:this.adapter.dateToDb(X),metadata:this.adapter.jsonToDb(Y),status:"idle",values:null,interrupts:this.adapter.jsonToDb(J)}).execute(),{thread_id:Z,created_at:X.toISOString(),updated_at:X.toISOString(),state_updated_at:X.toISOString(),metadata:Y,status:"idle",values:null,interrupts:J,title:null}}async search($){let Z=this.db.selectFrom("threads"),X;if($?.select)X=new Set($.select);else if($?.withoutDetails)X=new Set(["thread_id","created_at","updated_at","metadata","status","title"]);else X=new Set(["thread_id","created_at","updated_at","metadata","status","values","interrupts","title"]);let Y=[];if(X.has("thread_id"))Y.push("thread_id");if(X.has("created_at"))Y.push("created_at");if(X.has("updated_at"))Y.push("updated_at");if(X.has("metadata"))Y.push("metadata");if(X.has("status"))Y.push("status");if(X.has("values"))Y.push("values");if(X.has("interrupts"))Y.push("interrupts");if(X.has("title"))Y.push("title");if(Y.length>0)Z=Z.select(Y);else Z=Z.selectAll();if($?.ids&&$.ids.length>0)Z=Z.where("thread_id","in",$.ids);if($?.status)Z=Z.where("status","=",$.status);if($?.metadata)for(let[U,H]of Object.entries($.metadata))Z=Z.where(this.adapter.buildJsonQuery(this.db,"metadata",U,H));if($?.values)Z=Z.where((U)=>{return U("values","=",this.adapter.jsonToDb($.values))});if($?.sortBy){let U=$.sortOrder==="desc"?"desc":"asc";Z=Z.orderBy($.sortBy,U)}if($?.limit!==void 0){if(Z=Z.limit($.limit),$?.offset!==void 0)Z=Z.offset($.offset)}return(await Z.execute()).map((U)=>{let H={thread_id:U.thread_id};if(X.has("created_at"))H.created_at=this.adapter.dbToDate(U.created_at).toISOString();if(X.has("updated_at"))H.updated_at=this.adapter.dbToDate(U.updated_at).toISOString();if(X.has("metadata"))H.metadata=this.adapter.dbToJson(U.metadata);if(X.has("status"))H.status=U.status;if(X.has("values"))H.values=U.values?this.adapter.dbToJson(U.values):null;if(X.has("interrupts"))H.interrupts=this.adapter.dbToJson(U.interrupts);if(X.has("title"))H.title=U.title;return H})}async get($){let Z=await this.db.selectFrom("threads").selectAll().where("thread_id","=",$).executeTakeFirst();if(!Z)throw Error(`Thread with ID ${$} not found.`);return{thread_id:Z.thread_id,created_at:this.adapter.dbToDate(Z.created_at).toISOString(),updated_at:this.adapter.dbToDate(Z.updated_at).toISOString(),state_updated_at:this.adapter.dbToDate(Z.updated_at).toISOString(),metadata:this.adapter.dbToJson(Z.metadata),status:Z.status,values:Z.values?this.adapter.dbToJson(Z.values):null,interrupts:this.adapter.dbToJson(Z.interrupts),title:Z.title}}async set($,Z){if(!await this.db.selectFrom("threads").select("thread_id").where("thread_id","=",$).executeTakeFirst())throw Error(`Thread with ID ${$} not found.`);let Y={updated_at:this.adapter.dateToDb(new Date)};if(Z.metadata!==void 0)Y.metadata=this.adapter.jsonToDb(Z.metadata);if(Z.status!==void 0)Y.status=Z.status;if(Z.values!==void 0)Y.values=Z.values?this.adapter.jsonToDb(Z.values):null;if(Z.interrupts!==void 0)Y.interrupts=this.adapter.jsonToDb(Z.interrupts);if(Z.title!==void 0)Y.title=Z.title;await this.db.updateTable("threads").set(Y).where("thread_id","=",$).execute()}async delete($){if((await this.db.deleteFrom("threads").where("thread_id","=",$).executeTakeFirst()).numDeletedRows===0n)throw Error(`Thread with ID ${$} not found.`)}async updateState($,Z){let X=await this.get($);if(X.status==="busy")throw Error(`Thread with ID ${$} is busy, can't update state.`);let Y=X.metadata?.graph_id;if(!Y)return await this.set($,{values:Z.values??null}),{configurable:{thread_id:$}};let J={configurable:{thread_id:$,graph_id:Y}},U=await x0(Y,J),H=await U.updateState(J,Z.values),x=await U.getState(J);return await this.set($,{values:JSON.parse(f(x.values))}),H}async createRun($,Z,X){let Y=B(),J=new Date,U=X?.metadata??{};return await this.db.insertInto("runs").values({run_id:Y,thread_id:$,assistant_id:Z,created_at:this.adapter.dateToDb(J),updated_at:this.adapter.dateToDb(J),status:"pending",metadata:this.adapter.jsonToDb(U),multitask_strategy:"reject"}).execute(),{run_id:Y,thread_id:$,assistant_id:Z,created_at:J.toISOString(),updated_at:J.toISOString(),status:"pending",metadata:U,multitask_strategy:"reject"}}async listRuns($,Z){let X=this.db.selectFrom("runs").selectAll().where("thread_id","=",$).orderBy("created_at","desc");if(Z?.status)X=X.where("status","=",Z.status);if(Z?.limit!==void 0){if(X=X.limit(Z.limit),Z?.offset!==void 0)X=X.offset(Z.offset)}return(await X.execute()).map((J)=>({run_id:J.run_id,thread_id:J.thread_id,assistant_id:J.assistant_id,created_at:this.adapter.dbToDate(J.created_at).toISOString(),updated_at:this.adapter.dbToDate(J.updated_at).toISOString(),status:J.status,metadata:this.adapter.dbToJson(J.metadata),multitask_strategy:J.multitask_strategy}))}async updateRun($,Z){if(!await this.db.selectFrom("runs").select("run_id").where("run_id","=",$).executeTakeFirst())throw Error(`Run with ID ${$} not found.`);let Y={updated_at:this.adapter.dateToDb(new Date)};if(Z.status!==void 0)Y.status=Z.status;if(Z.metadata!==void 0)Y.metadata=this.adapter.jsonToDb(Z.metadata);if(Z.multitask_strategy!==void 0)Y.multitask_strategy=Z.multitask_strategy;await this.db.updateTable("runs").set(Y).where("run_id","=",$).execute()}async count($){return(await this.search($)).length}async patch($,Z){let X=await this.db.selectFrom("threads").selectAll().where("thread_id","=",$).executeTakeFirst();if(!X)throw Error(`Thread with ID ${$} not found.`);let Y={updated_at:this.adapter.dateToDb(new Date)};if(Z.metadata!==void 0){let J=this.adapter.dbToJson(X.metadata)||{};Y.metadata=this.adapter.jsonToDb({...J,...Z.metadata})}if(Z.status!==void 0)Y.status=Z.status;if(Z.values!==void 0)Y.values=Z.values?this.adapter.jsonToDb(Z.values):null;if(Z.interrupts!==void 0)Y.interrupts=this.adapter.jsonToDb(Z.interrupts);if(Z.title!==void 0)Y.title=Z.title;return await this.db.updateTable("threads").set(Y).where("thread_id","=",$).execute(),await this.get($)}async getState($,Z){let X=await this.get($);if(Z?.checkpointId){let J=await this.db.selectFrom("checkpoints").selectAll().where("checkpoint_id","=",Z.checkpointId).where("thread_id","=",$).executeTakeFirst();if(!J)throw Error(`Checkpoint with ID ${Z.checkpointId} not found for thread ${$}`);return{values:this.adapter.dbToJson(J.values),next:this.adapter.dbToJson(J.next),metadata:this.adapter.dbToJson(J.metadata),checkpoint:{id:J.checkpoint_id,thread_id:$,parent_checkpoint_id:null,checkpoint_ns:"",metadata:this.adapter.dbToJson(J.metadata),created_at:this.adapter.dbToDate(J.created_at).toISOString()},created_at:this.adapter.dbToDate(J.created_at).toISOString(),parent_checkpoint:null,tasks:[]}}return{values:X.values||{},next:[],metadata:X.metadata,checkpoint:null,created_at:X.created_at,parent_checkpoint:null,tasks:[]}}async getStateHistory($,Z){let Y=await this.db.selectFrom("checkpoints").selectAll().where("thread_id","=",$).orderBy("created_at","asc").execute(),J=Y.map((U)=>({values:this.adapter.dbToJson(U.values),next:this.adapter.dbToJson(U.next),metadata:this.adapter.dbToJson(U.metadata),checkpoint:{thread_id:$,checkpoint_ns:"",checkpoint_id:U.checkpoint_id,checkpoint_map:null},created_at:this.adapter.dbToDate(U.created_at).toISOString(),parent_checkpoint:null,tasks:[]}));if(Z?.before){let U=Y.findIndex((H)=>H.checkpoint_id===Z.before);if(U!==-1)J=J.slice(U+1)}if(Z?.limit)J=J.slice(0,Z.limit);return J}async copy($){let Z=await this.get($),X=B(),Y=new Date;await this.db.insertInto("threads").values({thread_id:X,created_at:this.adapter.dateToDb(Y),updated_at:this.adapter.dateToDb(Y),metadata:this.adapter.jsonToDb(Z.metadata),status:Z.status,values:Z.values?this.adapter.jsonToDb(Z.values):null,interrupts:this.adapter.jsonToDb(Z.interrupts),title:Z.title}).execute();let J=await this.db.selectFrom("checkpoints").selectAll().where("thread_id","=",$).orderBy("created_at","asc").execute();for(let U of J)await this.db.insertInto("checkpoints").values({checkpoint_id:B(),thread_id:X,values:U.values,next:U.next,config:U.config,created_at:U.created_at,metadata:U.metadata}).execute();return{...Z,thread_id:X,created_at:Y.toISOString(),updated_at:Y.toISOString()}}async saveCheckpoint($,Z,X,Y,J){await this.db.insertInto("checkpoints").values({checkpoint_id:B(),thread_id:$,values:this.adapter.jsonToDb(Z),next:this.adapter.jsonToDb(X),config:this.adapter.jsonToDb(Y),created_at:this.adapter.dateToDb(new Date),metadata:this.adapter.jsonToDb(J||{})}).execute()}async setTitleIfNull($,Z){return(await this.db.updateTable("threads").set({title:Z,updated_at:this.adapter.dateToDb(new Date)}).where("thread_id","=",$).where("title","is",null).executeTakeFirst()).numUpdatedRows>0n}}function T0($){let[Z,X]=$.split("::");return{threadId:Z,checkpointNs:X??""}}function C($,Z,X){return`${$}::${Z}::${X}`}function g($){if($===null||typeof $!=="object")return JSON.stringify($);if(Array.isArray($))return JSON.stringify($.map((Y)=>g(Y)));let Z={},X=Object.keys($).sort();for(let Y of X)Z[Y]=$[Y];return JSON.stringify(Z,(Y,J)=>{if(J!==null&&typeof J==="object"&&!Array.isArray(J)){let U={},H=Object.keys(J).sort();for(let x of H)U[x]=J[x];return U}return J})}class W0 extends t{storage={};writes={};constructor($){super($)}async get($){return(await this.getTuple($))?.checkpoint}async _migratePendingSends($,Z,X,Y){let J=$,U=C(Z,X,Y),H=await Promise.all(Object.values(this.writes[U]??{}).filter(([x,W])=>W===j).map(async([x,W,Q])=>await this.serde.loadsTyped("json",Q)));J.channel_values??={},J.channel_values[j]=H,J.channel_versions??={},J.channel_versions[j]=Object.keys(J.channel_versions).length>0?a(...Object.values(J.channel_versions)):this.getNextVersion(void 0)}async _loadPendingWrites($,Z,X){let Y=C($,Z,X),J=this.writes[Y]??{};if(Object.keys(J).length===0)return[];return await Promise.all(Object.values(J).map(async([U,H,x])=>{return[U,H,await this.serde.loadsTyped("json",x)]}))}_cleanupOldWrites($,Z,X){let Y=C($,Z,X);delete this.writes[Y]}_checkMetadataFilterMatch($,Z){for(let[X,Y]of Object.entries(Z)){let J=$?.[X];if(Y===null){if(!(X in($||{}))||J!==null)return!1}else if(typeof Y==="object"&&!Array.isArray(Y)){if(typeof J!=="object"||J===null)return!1;if(g(Y)!==g(J))return!1}else if(J!==Y)return!1}return!0}async getTuple($){let Z=$.configurable?.thread_id,X=$.configurable?.checkpoint_ns??"",Y=$0($);if(Z===void 0)return;let J=this.storage[Z]?.[X];if(J===void 0)return;let{checkpoint:U,metadata:H,checkpoint_id:x,parent_checkpoint_id:W}=J;if(Y&&x!==Y)return;let Q=await this.serde.loadsTyped("json",U);if(Q.v<4&&W!==void 0)await this._migratePendingSends(Q,Z,X,W);let P=await this._loadPendingWrites(Z,X,x),z=await this.serde.loadsTyped("json",H),V={config:{configurable:{thread_id:Z,checkpoint_ns:X,checkpoint_id:x}},checkpoint:Q,metadata:z,pendingWrites:P};if(W!==void 0)V.parentConfig={configurable:{thread_id:Z,checkpoint_ns:X,checkpoint_id:W}};return V}async*list($,Z){let{before:X,limit:Y,filter:J}=Z??{},U=$.configurable?.thread_id?[$.configurable.thread_id]:Object.keys(this.storage),H=$.configurable?.checkpoint_ns,x=$.configurable?.checkpoint_id,W=[];for(let P of U){let z=this.storage[P];if(z===void 0)continue;for(let V of Object.keys(z)){if(H!==void 0&&V!==H)continue;let A=z[V];if(A===void 0)continue;let{checkpoint_id:D}=A;if(x&&D!==x)continue;if(X?.configurable?.checkpoint_id&&D>=X.configurable.checkpoint_id)continue;let N=await this.serde.loadsTyped("json",A.metadata);if(J&&!this._checkMetadataFilterMatch(N,J))continue;W.push({threadId:P,checkpointNs:V,namespaceData:A})}}W.sort((P,z)=>z.namespaceData.checkpoint_ts-P.namespaceData.checkpoint_ts);let Q=0;for(let{threadId:P,checkpointNs:z,namespaceData:V}of W){if(Y!==void 0&&Q>=Y)return;let{checkpoint:A,metadata:D,checkpoint_id:N,parent_checkpoint_id:_}=V,O=await this.serde.loadsTyped("json",A);if(O.v<4&&_!==void 0)await this._migratePendingSends(O,P,z,_);let q=await this._loadPendingWrites(P,z,N),D0=await this.serde.loadsTyped("json",D),u={config:{configurable:{thread_id:P,checkpoint_ns:z,checkpoint_id:N}},checkpoint:O,metadata:D0,pendingWrites:q};if(_!==void 0)u.parentConfig={configurable:{thread_id:P,checkpoint_ns:z,checkpoint_id:_}};Q++,yield u}}async put($,Z,X,Y){let J=r(Z),U=$.configurable?.thread_id,H=$.configurable?.checkpoint_ns??"",x=$.configurable?.checkpoint_id;if(U===void 0)throw Error("thread_id is required");let W=Z.id||o(0);if(!this.storage[U])this.storage[U]={};let Q=this.storage[U][H];if(Q!==void 0&&Q.checkpoint_id!==W)this._cleanupOldWrites(U,H,Q.checkpoint_id);let[[,P],[,z]]=await Promise.all([this.serde.dumpsTyped(J),this.serde.dumpsTyped(X)]);return this.storage[U][H]={checkpoint:P,metadata:z,checkpoint_id:W,parent_checkpoint_id:x,checkpoint_ts:Date.now()},{configurable:{thread_id:U,checkpoint_ns:H,checkpoint_id:W}}}async putWrites($,Z,X){let Y=$.configurable?.thread_id,J=$.configurable?.checkpoint_ns??"",U=$.configurable?.checkpoint_id;if(!Y||!U)throw Error("thread_id and checkpoint_id are required");let H=C(Y,J,U),x=this.writes[H];if(this.writes[H]===void 0)this.writes[H]={};await Promise.all(Z.map(async([W,Q],P)=>{let[,z]=await this.serde.dumpsTyped(Q),V=[X,e[W]||P],A=`${V[0]},${V[1]}`;if(V[1]>=0&&x&&A in x)return;this.writes[H][A]=[X,W,z]}))}async deleteThread($){delete this.storage[$];for(let Z of Object.keys(this.writes)){let{threadId:X}=T0(Z.split("::").slice(0,2).join("::"));if(X===$)delete this.writes[Z]}}}class R{event;data;id;constructor($,Z){this.event=$,this.data=Z}}class P0 extends R{constructor(){super("__system_cancel__","user cancel this run")}}class Q0 extends R{constructor(){super("__stream_end__","stream end")}}class c extends R{constructor($){super("__stream_error__",{error:$.name,message:$.message})}}class h extends U0{data=[];activeGenerators=new Set;isDestroyed=!1;async push($){if(this.isDestroyed)return;let Z=this.compressMessages?await this.encodeData($):$;process.env.LG_TEMP_MESSAGE!=="true"&&this.data.push(Z),this.emit("dataChange",Z)}onDataChange($){if(this.isDestroyed)return()=>{};return this.on("dataChange",async(Z)=>{if(this.isDestroyed)return;$(this.compressMessages?await this.decodeData(Z):Z)}),()=>this.off("dataChange",$)}async*onDataReceive(){if(this.isDestroyed)return;let $=new AbortController;this.activeGenerators.add($);let Z=[],X=null,Y=!1,J=!1,U=null,H=async(Q)=>{if(J||$.signal.aborted)return;try{let P=this.compressMessages?await this.decodeData(Q):Q;if(Z.push(P),P.event==="__stream_end__"||P.event==="__stream_error__"||P.event==="__stream_cancel__"){if(U)clearTimeout(U),U=null;if(U=setTimeout(()=>{if(Y=!0,X)X(),X=null},300),P.event==="__stream_cancel__")$.abort("stream cancelled")}if(X)X(),X=null}catch(P){if(console.error("Error in handleData:",P),X)X(),X=null}};this.on("dataChange",H);let x=()=>{if(Y=!0,X)X(),X=null};$.signal.addEventListener("abort",x);let W=()=>{if(J)return;if(J=!0,U)clearTimeout(U),U=null;try{this.off("dataChange",H)}catch(Q){}try{$.signal.removeEventListener("abort",x)}catch(Q){}if(X)X(),X=null;Z.length=0,this.activeGenerators.delete($)};try{if($.signal.aborted||this.isDestroyed)return;while(!Y&&!$.signal.aborted&&!this.isDestroyed)if(Z.length>0){for(let Q of Z)yield Q;Z.length=0}else await new Promise((Q)=>{X=Q})}finally{W()}}async getAll(){if(this.isDestroyed)return[];return this.compressMessages?await Promise.all(this.data.map(($)=>this.decodeData($))):[...this.data]}clear(){this.data.length=0}cancelSignal=new AbortController;async cancel(){for(let $ of this.activeGenerators)try{$.abort("user cancel this run")}catch(Z){}if(this.activeGenerators.clear(),!this.cancelSignal.signal.aborted)this.cancelSignal.abort("user cancel this run");if(!this.isDestroyed)await this.push(new P0)}async copyToQueue($,Z){let X=this.data.slice(),Y=new h($,this.compressMessages,Z??this.ttl);return Y.data=X,Y}async destroy(){if(this.isDestroyed)return;this.isDestroyed=!0,await this.cancel(),this.clear(),this.removeAllListeners(),this.activeGenerators.clear()}}class O0{threads=[];checkpoints=new Map;async setup(){return}async create($){let Z=$?.threadId||B();if($?.ifExists==="raise"&&this.threads.some((Y)=>Y.thread_id===Z))throw Error(`Thread with ID ${Z} already exists.`);let X={thread_id:Z,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),state_updated_at:new Date().toISOString(),metadata:$?.metadata||{},status:"idle",values:null,interrupts:{},title:null};return this.checkpoints.set(Z,[]),this.threads.push(X),X}async search($){let Z=[...this.threads];if($?.ids&&$.ids.length>0)Z=Z.filter((U)=>$.ids.includes(U.thread_id));if($?.status)Z=Z.filter((U)=>U.status===$.status);if($?.metadata){for(let U in $.metadata)if(Object.prototype.hasOwnProperty.call($.metadata,U))Z=Z.filter((H)=>H.metadata&&H.metadata[U]===$.metadata?.[U])}if($?.values)Z=Z.filter((U)=>{if(!U.values)return!1;return this.deepEqual(U.values,$.values)});if($?.sortBy)Z.sort((U,H)=>{let x,W;switch($.sortBy){case"thread_id":x=U.thread_id,W=H.thread_id;break;case"created_at":x=new Date(U.created_at).getTime(),W=new Date(H.created_at).getTime();break;case"updated_at":x=new Date(U.updated_at).getTime(),W=new Date(H.updated_at).getTime();break;case"status":x=U.status,W=H.status;break;default:return 0}if($.sortOrder==="desc")return W>x?1:W<x?-1:0;else return x>W?1:x<W?-1:0});let X=$?.offset||0,Y=$?.limit||Z.length;return Z.slice(X,X+Y).map((U)=>{let H={thread_id:U.thread_id},x;if($?.select)x=new Set($.select);else if($?.withoutDetails)x=new Set(["thread_id","created_at","updated_at","metadata","status"]);else x=new Set(["thread_id","created_at","updated_at","metadata","status","values","interrupts","title"]);if(x.has("thread_id"))H.thread_id=U.thread_id;if(x.has("created_at"))H.created_at=U.created_at;if(x.has("updated_at"))H.updated_at=U.updated_at;if(x.has("metadata"))H.metadata=U.metadata;if(x.has("status"))H.status=U.status;if(x.has("values"))H.values=U.values;if(x.has("interrupts"))H.interrupts=U.interrupts;if(x.has("title"))H.title=U.title;return H})}deepEqual($,Z){if($===Z)return!0;if(typeof $!==typeof Z)return!1;if(typeof $!=="object"||$===null||Z===null)return!1;let X=Object.keys($),Y=Object.keys(Z);if(X.length!==Y.length)return!1;for(let J of X){if(!Y.includes(J))return!1;if(!this.deepEqual($[J],Z[J]))return!1}return!0}async get($){let Z=this.threads.find((X)=>X.thread_id===$);if(!Z)throw Error(`Thread with ID ${$} not found.`);return Z}async set($,Z){let X=this.threads.findIndex((Y)=>Y.thread_id===$);if(X===-1)throw Error(`Thread with ID ${$} not found.`);this.threads[X]={...this.threads[X],...Z}}async delete($){let Z=this.threads.length;if(this.threads=this.threads.filter((X)=>X.thread_id!==$),this.checkpoints.delete($),this.threads.length===Z)throw Error(`Thread with ID ${$} not found.`)}async updateState($,Z){let X=this.threads.findIndex((J)=>J.thread_id===$);if(X===-1)throw Error(`Thread with ID ${$} not found.`);let Y=this.threads[X];if(Y.status==="busy")throw Error(`Thread with ID ${$} is busy, can't update state.`);if(this.threads[X]={...Y,values:Z.values,updated_at:new Date().toISOString()},Y.metadata?.graph_id){let J=Y.metadata?.graph_id,U={configurable:{thread_id:$,graph_id:J}};try{let H=await x0(J,U),x=await H.updateState(U,Z.values),W=await H.getState(U);return await this.set($,{values:JSON.parse(f(W.values))}),x}catch(H){console.warn("Failed to update graph state:",H)}}return{configurable:{thread_id:$}}}runs=[];async createRun($,Z,X){let J={run_id:B(),thread_id:$,assistant_id:Z,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),status:"pending",metadata:X?.metadata??{},multitask_strategy:"reject"};return this.runs.push(J),J}async listRuns($,Z){let X=[...this.runs];if(Z?.status)X=X.filter((Y)=>Y.status===Z.status);if(Z?.limit)X=X.slice(Z.offset||0,(Z.offset||0)+Z.limit);return X}async updateRun($,Z){let X=this.runs.findIndex((Y)=>Y.run_id===$);if(X===-1)throw Error(`Run with ID ${$} not found.`);this.runs[X]={...this.runs[X],...Z}}async count($){return(await this.search($)).length}async patch($,Z){let X=this.threads.findIndex((J)=>J.thread_id===$);if(X===-1)throw Error(`Thread with ID ${$} not found.`);let Y={...this.threads[X],...Z,updated_at:new Date().toISOString(),metadata:Z.metadata?{...this.threads[X].metadata,...Z.metadata}:this.threads[X].metadata};return this.threads[X]=Y,Y}async getState($,Z){let X=await this.get($);if(Z?.checkpointId){let U=(this.checkpoints.get($)||[]).find((H)=>H.checkpoint_id===Z.checkpointId);if(!U)throw Error(`Checkpoint with ID ${Z.checkpointId} not found for thread ${$}`);return{values:U.values,next:U.next,metadata:U.metadata,checkpoint:{id:U.checkpoint_id,thread_id:$,parent_checkpoint_id:null,checkpoint_ns:"",metadata:U.metadata,created_at:U.created_at},created_at:U.created_at,parent_checkpoint:null,tasks:[]}}return{values:X.values||{},next:[],metadata:X.metadata,checkpoint:null,created_at:X.created_at,parent_checkpoint:null,tasks:[]}}async getStateHistory($,Z){let X=this.checkpoints.get($)||[],Y=X.map((J)=>({values:J.values,next:J.next,metadata:J.metadata,checkpoint:{checkpoint_id:J.checkpoint_id,thread_id:$,checkpoint_ns:"",checkpoint_map:void 0},created_at:J.created_at,parent_checkpoint:null,tasks:[]}));if(Z?.before){let J=X.findIndex((U)=>U.checkpoint_id===Z.before);if(J!==-1)Y=Y.slice(J+1)}if(Z?.limit)Y=Y.slice(0,Z.limit);return Y}async copy($){let Z=await this.get($),X=B(),Y={...Z,thread_id:X,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};this.threads.push(Y);let U=(this.checkpoints.get($)||[]).map((H)=>({...H,checkpoint_id:B(),thread_id:X}));return this.checkpoints.set(X,U),Y}async saveCheckpoint($,Z,X,Y,J){let U=this.checkpoints.get($)||[],H={checkpoint_id:B(),thread_id:$,values:Z,next:X,config:Y,created_at:new Date().toISOString(),metadata:J};U.push(H),this.checkpoints.set($,U)}async setTitleIfNull($,Z){let X=this.threads.findIndex((Y)=>Y.thread_id===$);if(X===-1)throw Error(`Thread with ID ${$} not found.`);if(this.threads[X].title===null)return this.threads[X]={...this.threads[X],title:Z,updated_at:new Date().toISOString()},!0;return!1}}var S0=async()=>{if(process.env.REDIS_URL&&(process.env.CHECKPOINT_TYPE==="redis"||process.env.CHECKPOINT_TYPE==="shallow/redis")){if(process.env.CHECKPOINT_TYPE==="redis"){console.debug("LG | Using redis as checkpoint");let{RedisSaver:$}=await import("./chunk-9b7nj74j.js");return await $.fromUrl(process.env.REDIS_URL,{defaultTTL:60,refreshOnRead:!0})}if(process.env.CHECKPOINT_TYPE==="shallow/redis"){console.debug("LG | Using shallow redis as checkpoint");let{ShallowRedisSaver:$}=await import("./chunk-v8g52kan.js");return await $.fromUrl(process.env.REDIS_URL)}}if(process.env.DATABASE_URL&&z0(process.env.DATABASE_URL)==="postgres"){console.debug("LG | Using postgres as checkpoint");let{createPGCheckpoint:$}=await import("./chunk-0pss3s5r.js");return $()}if(process.env.SQLITE_DATABASE_URI){if(process.env.CHECKPOINT_TYPE==="sqlite"){console.debug("LG | Using sqlite (full) as checkpoint");let{SqliteSaver:X}=await import("./chunk-5dsevrtz.js");return await X.fromConnStringAsync(process.env.SQLITE_DATABASE_URI)}console.debug("LG | Using shallow sqlite as checkpoint (default)");let{SqliteShallowSaver:$}=await import("./chunk-e8hp8d68.js");return await $.fromConnStringAsync(process.env.SQLITE_DATABASE_URI)}return console.log("LG | You are using memory as checkpoint!"),console.log("\x1B[33m%s\x1B[0m","LG | set SQLITE_DATABASE_URI=./.langgraph_api/langgraph.db to your .env file to use \x1B[1mSQLite\x1B[0m for dev!"),console.log("\x1B[33m%s\x1B[0m","LG | set DATABASE_URL=postgresql://user:pass@localhost:5432/db to your .env file to use \x1B[1mPostgreSQL\x1B[0m for prod!"),new W0},w0=async()=>{let $;if(process.env.REDIS_URL){console.debug("LG | Using redis as stream queue");let{RedisStreamQueue:Z}=await import("./chunk-ce53j63y.js");$=Z}else $=h;return new H0($)};function z0($){let Z=$.toLowerCase();if(Z.startsWith("http://")||Z.startsWith("https://"))return"remote";return"postgres"}var G0=async($)=>{if(process.env.DATABASE_URL){if(z0(process.env.DATABASE_URL)==="remote"){console.debug("LG | Using Remote PostgreSQL ThreadsManager");let{RemoteKyselyThreadsManager:X}=await import("./chunk-6nfpdtn6.js"),Y=new X(process.env.DATABASE_URL);if(process.env.DATABASE_INIT==="true")await Y.setup();return Y}else if($.checkpointer){console.debug("LG | Using PostgreSQL ThreadsManager");let{PostgresAdapter:X}=await import("./chunk-dxec2q4t.js"),Y=$.checkpointer.pool,J=new I(new X(Y));if(process.env.DATABASE_INIT==="true")await J.setup();return J}}if(process.env.SQLITE_DATABASE_URI&&$.checkpointer){console.debug("LG | Using SQLite ThreadsManager");let{SQLiteAdapter:Z}=await import("./chunk-0zk0m93z.js"),X=$.checkpointer.db,Y=new I(new Z(X));return await Y.setup(),Y}return new O0};function C0($){if(typeof $==="string")return $;if(Array.isArray($))return $.find((X)=>X.type==="text")?.text||"";if($?.text)return $.text;return""}var j0=($,Z)=>{let X=$?.messages;if(!X||!Array.isArray(X)||X.length===0)return null;let Y=X[0];if(!Y)return null;let J=C0(Y.content);if(!J)return null;let U=J.trim().replace(/\n/g," ");if(!U)return null;let H=15,x=U.slice(0,H);return x.length<U.length?`${x}...`:x};class F{static globalMessageQueue=null;static globalCheckPointer=null;static globalThreadsManager=null;static isInitialized=null;static _titleGenerator=j0;static setTitleGenerator($){F._titleGenerator=$}static getTitleGenerator(){return F._titleGenerator}static async initGlobal(){if(F.isInitialized)return F.isInitialized;return F.isInitialized=(async()=>{let[$,Z]=await Promise.all([w0(),S0()]);console.debug("LG | checkpointer created");let X=await G0({checkpointer:Z});console.debug("LG | threads manager created"),console.debug("LG | global init done"),F.globalMessageQueue=$,F.globalCheckPointer=Z,F.globalThreadsManager=X})(),F.isInitialized}}async function M0($,Z,X,Y,J){let H=Y.config?.configurable?.graph_id;if(!H||typeof H!=="string")throw Error("Invalid or missing graph_id");let x=await J.getGraph(H,Y.config,{checkpointer:Y.temporary?null:void 0}),W=Array.isArray(Y.streamMode)?Y.streamMode:Y.streamMode?[Y.streamMode]:[],Q=new Set(["values",...W.filter((D)=>D!=="events"&&D!=="messages-tuple")]);if(W.includes("messages-tuple"))Q.add("messages");if(W.includes("messages"))Q.add("values");await X.push(new R("metadata",{run_id:Z.run_id,attempt:J.attempt,graph_id:H}));let P={...Y.config?.metadata,run_attempt:J.attempt},z=null,V=null,A=null;try{z=new Set,V=new Map,A=await x.stream(Y.command!=null?A0(Y.command):Y.input??null,{interruptAfter:Y.interruptAfter,interruptBefore:Y.interruptBefore,tags:Y.config?.tags,configurable:Y.config?.configurable,recursionLimit:Y.config?.recursionLimit,subgraphs:Y.streamSubgraphs,metadata:P,runId:Z.run_id,streamMode:[...Q],signal:X.cancelSignal.signal});for await(let D of A){let N=[];if(D.length===3)N=D.splice(0,1);let _=(O)=>{if(N.length===0)return O;if(N.length===1&&N[0]?.length===0)return O;return`${O}|${N.join("|")}`};if(D[0]==="values"){let O=D[1];if(_("values")==="values")if(await X.push(new R(_("values"),O)),O?.__interrupt__)await $.set(Z.thread_id,{status:"interrupted",interrupts:O?JSON.parse(f(O)):""});else await $.set(Z.thread_id,{values:O?JSON.parse(f(O)):""})}else if(D[0]==="messages"){let O=D[1][0],q=D[1][1];if(O.id&&!z.has(O.id))await X.push(new R("messages/metadata",{[O.id]:q})),z.add(O.id);if(n.isInstance(O)&&O.id){if(V.set(O.id,[...V.get(O.id)??[],O]),await X.push(new R("messages/partial",[V.get(O.id).reduce(s)])),O.content===""&&!O.tool_calls?.length)V.delete(O.id)}else await X.push(new R("messages/partial",[O]))}else if(D[0]==="updates"){let O=D[1];await X.push(new R(_("updates"),O))}}}catch(D){if(!(D instanceof Error&&D.message?.includes("cancel"))){console.error("streamStateWithQueue error:",D);try{await X.push(new c(D))}catch(N){}}throw D}finally{try{await X.push(new Q0)}catch(D){}if(z)z.clear(),z=null;if(V)V.clear(),V=null;A=null}}var f=($,Z=0)=>{return JSON.stringify($,function(X,Y){let J=this[X];if(J!=null&&typeof J==="object"&&"toDict"in J&&typeof J.toDict==="function"){let{type:U,data:H}=J.toDict();return{...H,type:U}}return Y},Z)};async function*s0($,Z,X,Y){Z=await Z;let{run_id:J,thread_id:U}=Z,H=null,x=null,W=null,Q=!1;try{await $.set(U,{status:"busy"}),await $.updateRun(Z.run_id,{status:"running"}),x=F.globalMessageQueue.createQueue(J),H=x.onDataReceive(),W=M0($,Z,x,X,Y).catch((P)=>{if(Q)return;if(P.message!=="user cancel this run")console.error("Queue task error:",P);F.globalMessageQueue.pushToQueue(J,new c(P))});for await(let P of H)yield P;await $.updateRun(Z.run_id,{status:"success"})}catch(P){console.error("Stream error:",P),await $.updateRun(Z.run_id,{status:"error"}),await $.set(U,{status:"error"})}finally{if(Q=!0,H){try{await H.return(void 0)}catch(z){}H=null}if(x&&!x.cancelSignal.signal.aborted)try{x.cancelSignal.abort("Stream consumer disconnected")}catch(z){}if(W){try{await Promise.race([W,new Promise((z)=>setTimeout(z,1000))])}catch(z){}W=null}if((await $.get(U)).status==="interrupted")await F.globalMessageQueue.copyQueue(J,U,30000);else await $.set(U,{status:"idle",interrupts:{}});await F.globalMessageQueue.removeQueue(J),x=null}}
|
|
2
|
-
export{U0 as R,T as S,n0 as T,x0 as U,P0 as V,F as W,f as X,s0 as Y};
|
package/dist/chunk-vh9zd1v3.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{$i as Hq,Ai as i,Aj as jq,Bi as n,Bj as b,Ci as t,Cj as H,Di as a,Dj as E,Ei as s,Ej as Bq,Fi as e,Fj as Sq,Gi as qq,Gj as Oq,Hi as zq,Hj as _q,Ii as Jq,Ij as fq,Jj as xq,Kj as yq,Lj as Tq,Mj as P,Nj as hq,Oj as B,Pj as cq,Qi as Qq,Qj as kq,Ri as Vq,Rj as S,Si as Xq,Ti as Zq,Ui as $q,Vi as Gq,Wi as wq,Xi as Wq,Yi as Yq,Zi as Dq,_i as Uq,aj as _,bj as Eq,cj as Kq,ej as bq,fj as L,gj as v,hj as Pq,ij as Lq,jj as vq,pj as F,qj as N,rj as Fq,sj as Nq,tj as A,uj as R,vi as g,vj as Aq,vl as f,wj as Rq,xj as I,yj as j,zj as Iq}from"./chunk-w2hbsa9j.js";var O=(Z,q)=>{let J=[...new Set(q?.map((z)=>{if(typeof z==="string")return z;let G=new z({});if(!("getType"in G)||typeof G.getType!=="function")throw Error("Invalid type provided.");return G.getType()}))],V=Z.getType();return J.some((z)=>z===V)};function C(Z,q){if(Array.isArray(Z))return c(Z,q);return f.from((J)=>{return c(J,Z)})}function c(Z,q={}){let{includeNames:J,excludeNames:V,includeTypes:z,excludeTypes:G,includeIds:Y,excludeIds:X}=q,w=[];for(let Q of Z){if(V&&Q.name&&V.includes(Q.name))continue;else if(G&&O(Q,G))continue;else if(X&&Q.id&&X.includes(Q.id))continue;if(!(z||Y||J))w.push(Q);else if(J&&Q.name&&J.some(($)=>$===Q.name))w.push(Q);else if(z&&O(Q,z))w.push(Q);else if(Y&&Q.id&&Y.some(($)=>$===Q.id))w.push(Q)}return w}function d(Z){if(Array.isArray(Z))return k(Z);return f.from(k)}function k(Z){if(!Z.length)return[];let q=[];for(let J of Z){let V=J,z=q.pop();if(!z)q.push(V);else if(V.getType()==="tool"||V.getType()!==z.getType())q.push(z,V);else{let G=P(z),Y=P(V),X=G.concat(Y);if(typeof G.content==="string"&&typeof Y.content==="string")X.content=`${G.content}
|
|
2
|
-
${Y.content}`;q.push(dq(X))}}return q}function m(Z,q){if(Array.isArray(Z)){let J=Z;if(!q)throw Error("Options parameter is required when providing messages.");return p(J,q)}else{let J=Z;return f.from((V)=>p(V,J)).withConfig({runName:"trim_messages"})}}async function p(Z,q){let{maxTokens:J,tokenCounter:V,strategy:z="last",allowPartial:G=!1,endOn:Y,startOn:X,includeSystem:w=!1,textSplitter:Q}=q;if(X&&z==="first")throw Error("`startOn` should only be specified if `strategy` is 'last'.");if(w&&z==="first")throw Error("`includeSystem` should only be specified if `strategy` is 'last'.");let $;if("getNumTokens"in V)$=async(W)=>{return(await Promise.all(W.map((U)=>V.getNumTokens(U.content)))).reduce((U,K)=>U+K,0)};else $=async(W)=>V(W);let D=y;if(Q)if("splitText"in Q)D=Q.splitText;else D=async(W)=>Q(W);if(z==="first")return r(Z,{maxTokens:J,tokenCounter:$,textSplitter:D,partialStrategy:G?"first":void 0,endOn:Y});else if(z==="last")return Cq(Z,{maxTokens:J,tokenCounter:$,textSplitter:D,allowPartial:G,includeSystem:w,startOn:X,endOn:Y});else throw Error(`Unrecognized strategy: '${z}'. Must be one of 'first' or 'last'.`)}async function r(Z,q){let{maxTokens:J,tokenCounter:V,textSplitter:z,partialStrategy:G,endOn:Y}=q,X=[...Z],w=0;for(let Q=0;Q<X.length;Q+=1)if(await V(Q>0?X.slice(0,-Q):X)<=J){w=X.length-Q;break}if(w<X.length&&G){let Q=!1;if(Array.isArray(X[w].content)){let $=X[w];if(typeof $.content==="string")throw Error("Expected content to be an array.");let D=$.content.length,W=G==="last"?[...$.content].reverse():$.content;for(let U=1;U<=D;U+=1){let K=G==="first"?W.slice(0,U):W.slice(-U),pq=Object.fromEntries(Object.entries($).filter(([h])=>h!=="type"&&!h.startsWith("lc_"))),Mq=x($.getType(),{...pq,content:K}),T=[...X.slice(0,w),Mq];if(await V(T)<=J)X=T,w+=1,Q=!0;else break}if(Q&&G==="last")$.content=[...W].reverse()}if(!Q){let $=X[w],D;if(Array.isArray($.content)&&$.content.some((W)=>typeof W==="string"||W.type==="text"))D=$.content.find((W)=>W.type==="text"&&W.text)?.text;else if(typeof $.content==="string")D=$.content;if(D){let W=await z(D),U=W.length;if(G==="last")W.reverse();for(let K=0;K<U-1;K+=1)if(W.pop(),$.content=W.join(""),await V([...X.slice(0,w),$])<=J){if(G==="last")$.content=[...W].reverse().join("");X=[...X.slice(0,w),$],w+=1;break}}}}if(Y){let Q=Array.isArray(Y)?Y:[Y];while(w>0&&!O(X[w-1],Q))w-=1}return X.slice(0,w)}async function Cq(Z,q){let{allowPartial:J=!1,includeSystem:V=!1,endOn:z,startOn:G,...Y}=q,X=Z.map(($)=>{let D=Object.fromEntries(Object.entries($).filter(([W])=>W!=="type"&&!W.startsWith("lc_")));return x($.getType(),D,_($))});if(z){let $=Array.isArray(z)?z:[z];while(X.length>0&&!O(X[X.length-1],$))X=X.slice(0,-1)}let w=V&&X[0]?.getType()==="system",Q=w?X.slice(0,1).concat(X.slice(1).reverse()):X.reverse();if(Q=await r(Q,{...Y,partialStrategy:J?"last":void 0,endOn:G}),w)return[Q[0],...Q.slice(1).reverse()];else return Q.reverse()}var M={human:{message:I,messageChunk:j},ai:{message:B,messageChunk:S},system:{message:H,messageChunk:E},developer:{message:H,messageChunk:E},tool:{message:L,messageChunk:v},function:{message:A,messageChunk:R},generic:{message:F,messageChunk:N},remove:{message:b,messageChunk:b}};function x(Z,q,J){let V,z;switch(Z){case"human":if(J)V=new j(q);else z=new I(q);break;case"ai":if(J){let G={...q};if("tool_calls"in G)G={...G,tool_call_chunks:G.tool_calls?.map((Y)=>({...Y,type:"tool_call_chunk",index:void 0,args:JSON.stringify(Y.args)}))};V=new S(G)}else z=new B(q);break;case"system":if(J)V=new E(q);else z=new H(q);break;case"developer":if(J)V=new E({...q,additional_kwargs:{...q.additional_kwargs,__openai_role__:"developer"}});else z=new H({...q,additional_kwargs:{...q.additional_kwargs,__openai_role__:"developer"}});break;case"tool":if("tool_call_id"in q)if(J)V=new v(q);else z=new L(q);else throw Error("Can not convert ToolMessage to ToolMessageChunk if 'tool_call_id' field is not defined.");break;case"function":if(J)V=new R(q);else{if(!q.name)throw Error("FunctionMessage must have a 'name' field");z=new A(q)}break;case"generic":if("role"in q)if(J)V=new N(q);else z=new F(q);else throw Error("Can not convert ChatMessage to ChatMessageChunk if 'role' field is not defined.");break;default:throw Error(`Unrecognized message type ${Z}`)}if(J&&V)return V;if(z)return z;throw Error(`Unrecognized message type ${Z}`)}function dq(Z){let q=Z.getType(),J,V=Object.fromEntries(Object.entries(Z).filter(([z])=>!["type","tool_call_chunks"].includes(z)&&!z.startsWith("lc_")));if(q in M)J=x(q,V);if(!J)throw Error(`Unrecognized message chunk class ${q}. Supported classes are ${Object.keys(M)}`);return J}function y(Z){let q=Z.split(`
|
|
3
|
-
`);return Promise.resolve([...q.slice(0,-1).map((J)=>`${J}
|
|
4
|
-
`),q[q.length-1]])}var u=["tool_call","tool_call_chunk","invalid_tool_call","server_tool_call","server_tool_call_chunk","server_tool_call_result"];var l=["image","video","audio","text-plain","file"];var o=["text","reasoning",...u,...l];var Lz=g({AIMessage:()=>B,AIMessageChunk:()=>S,BaseMessage:()=>Zq,BaseMessageChunk:()=>Dq,ChatMessage:()=>F,ChatMessageChunk:()=>N,DEFAULT_MERGE_IGNORE_KEYS:()=>Gq,FunctionMessage:()=>A,FunctionMessageChunk:()=>R,HumanMessage:()=>I,HumanMessageChunk:()=>j,KNOWN_BLOCK_TYPES:()=>o,RemoveMessage:()=>b,SystemMessage:()=>H,SystemMessageChunk:()=>E,ToolMessage:()=>L,ToolMessageChunk:()=>v,_isMessageFieldWithRole:()=>Uq,_mergeDicts:()=>wq,_mergeLists:()=>Wq,_mergeObj:()=>Yq,_mergeStatus:()=>Xq,coerceMessageLikeToMessage:()=>_q,collapseToolCallChunks:()=>hq,convertToChunk:()=>P,convertToOpenAIImageBlock:()=>e,convertToProviderContentBlock:()=>Jq,defaultTextSplitter:()=>y,defaultToolCallParser:()=>Pq,filterMessages:()=>C,getBufferString:()=>fq,iife:()=>Oq,isAIMessage:()=>cq,isAIMessageChunk:()=>kq,isBase64ContentBlock:()=>t,isBaseMessage:()=>Hq,isBaseMessageChunk:()=>_,isChatMessage:()=>Fq,isChatMessageChunk:()=>Nq,isDataContentBlock:()=>i,isDirectToolOutput:()=>bq,isFunctionMessage:()=>Aq,isFunctionMessageChunk:()=>Rq,isHumanMessage:()=>Iq,isHumanMessageChunk:()=>jq,isIDContentBlock:()=>s,isMessage:()=>Qq,isOpenAIToolCallArray:()=>$q,isPlainTextContentBlock:()=>a,isSystemMessage:()=>Bq,isSystemMessageChunk:()=>Sq,isToolMessage:()=>Lq,isToolMessageChunk:()=>vq,isURLContentBlock:()=>n,mapChatMessagesToStoredMessages:()=>Tq,mapStoredMessageToChatMessage:()=>xq,mapStoredMessagesToChatMessages:()=>yq,mergeContent:()=>Vq,mergeMessageRuns:()=>d,mergeResponseMetadata:()=>Eq,mergeUsageMetadata:()=>Kq,parseBase64DataUrl:()=>zq,parseMimeType:()=>qq,trimMessages:()=>m});
|
|
5
|
-
export{C as si,m as ti,Lz as ui};
|