zen-code 4.9.2 → 4.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/app.js +2606 -182
  2. package/dist/cli.js +3116 -1
  3. package/dist/nonInteractive.js +2084 -4
  4. package/dist/zen-keyboard.js +358 -3
  5. package/package.json +37 -37
  6. package/dist/chunk-0pss3s5r.js +0 -88
  7. package/dist/chunk-0sxrk9sx.js +0 -1
  8. package/dist/chunk-0zk0m93z.js +0 -26
  9. package/dist/chunk-178yjjsx.js +0 -1
  10. package/dist/chunk-1p9xzvpt.js +0 -3
  11. package/dist/chunk-2eh0sv3s.js +0 -2
  12. package/dist/chunk-43xrz4wp.js +0 -2
  13. package/dist/chunk-48ce2wt0.js +0 -1
  14. package/dist/chunk-48vkm1yn.js +0 -5
  15. package/dist/chunk-55nx49pj.js +0 -7
  16. package/dist/chunk-578m1dhj.js +0 -2
  17. package/dist/chunk-5dsevrtz.js +0 -91
  18. package/dist/chunk-62zh99t6.js +0 -298
  19. package/dist/chunk-66890qd3.js +0 -2
  20. package/dist/chunk-6nfpdtn6.js +0 -1
  21. package/dist/chunk-738m8242.js +0 -53
  22. package/dist/chunk-8f2zh5h6.js +0 -2
  23. package/dist/chunk-8ty2zfve.js +0 -3
  24. package/dist/chunk-94jawhw7.js +0 -3
  25. package/dist/chunk-98wjxsna.js +0 -79
  26. package/dist/chunk-9b7nj74j.js +0 -1
  27. package/dist/chunk-9k64296h.js +0 -4
  28. package/dist/chunk-9x562s6p.js +0 -1
  29. package/dist/chunk-a90fm6gz.js +0 -278
  30. package/dist/chunk-ac5t2ywn.js +0 -100
  31. package/dist/chunk-ad2hbq42.js +0 -1
  32. package/dist/chunk-afhxxkmv.js +0 -16
  33. package/dist/chunk-b4vvgbav.js +0 -1
  34. package/dist/chunk-b9pcntkv.js +0 -253
  35. package/dist/chunk-c7y5efa0.js +0 -1
  36. package/dist/chunk-cbjnwrt7.js +0 -2
  37. package/dist/chunk-ce53j63y.js +0 -3
  38. package/dist/chunk-dcs1r9as.js +0 -2
  39. package/dist/chunk-dcwnpdtk.js +0 -9
  40. package/dist/chunk-dxec2q4t.js +0 -23
  41. package/dist/chunk-e3tyc24s.js +0 -310
  42. package/dist/chunk-e8hp8d68.js +0 -81
  43. package/dist/chunk-fkrydbn4.js +0 -18
  44. package/dist/chunk-frhhpxxy.js +0 -2
  45. package/dist/chunk-fw3nrwpf.js +0 -1
  46. package/dist/chunk-gyhxdxb4.js +0 -1
  47. package/dist/chunk-h1enhch1.js +0 -2
  48. package/dist/chunk-hcnx1j2z.js +0 -1
  49. package/dist/chunk-hfegb4pr.js +0 -2
  50. package/dist/chunk-hfypkhky.js +0 -2
  51. package/dist/chunk-hmemx3cw.js +0 -2
  52. package/dist/chunk-hra0748z.js +0 -2
  53. package/dist/chunk-hsev32dg.js +0 -4
  54. package/dist/chunk-hyf24r36.js +0 -2
  55. package/dist/chunk-jb4yt88g.js +0 -6
  56. package/dist/chunk-jjcmm167.js +0 -1
  57. package/dist/chunk-jrepjpft.js +0 -2
  58. package/dist/chunk-k38fjqj7.js +0 -140
  59. package/dist/chunk-kym9tb01.js +0 -1
  60. package/dist/chunk-mt1g6g89.js +0 -1
  61. package/dist/chunk-p0vzbr7s.js +0 -585
  62. package/dist/chunk-pndhbee8.js +0 -2
  63. package/dist/chunk-pwrscdkf.js +0 -2
  64. package/dist/chunk-r019959h.js +0 -2
  65. package/dist/chunk-r10bn684.js +0 -1
  66. package/dist/chunk-r3pe49q4.js +0 -8
  67. package/dist/chunk-r4tq44hr.js +0 -1
  68. package/dist/chunk-rjrnaka2.js +0 -1
  69. package/dist/chunk-rt5mpgbg.js +0 -6
  70. package/dist/chunk-rztre6k0.js +0 -1
  71. package/dist/chunk-s77qbhtz.js +0 -3
  72. package/dist/chunk-t7rwtc17.js +0 -1
  73. package/dist/chunk-v8g52kan.js +0 -1
  74. package/dist/chunk-vd6c87cm.js +0 -2
  75. package/dist/chunk-vfwbx331.js +0 -2
  76. package/dist/chunk-vh9zd1v3.js +0 -5
  77. package/dist/chunk-w2hbsa9j.js +0 -86
  78. package/dist/chunk-wabmqprd.js +0 -184
  79. package/dist/chunk-wpy5r9ma.js +0 -40
  80. package/dist/chunk-x552nspp.js +0 -6
  81. package/dist/chunk-x90r4sje.js +0 -1
  82. package/dist/chunk-yndex7hs.js +0 -1
  83. package/dist/chunk-yqwxbcc7.js +0 -31
  84. package/dist/chunk-z8n7y37k.js +0 -1
  85. package/dist/chunk-zr7sx9hd.js +0 -1
  86. package/dist/chunk-zxqmghzf.js +0 -1
@@ -1,7 +0,0 @@
1
- import{ye as c}from"./chunk-a90fm6gz.js";import{pq as h,qq as wY}from"./chunk-dcs1r9as.js";var IX=wY((DY)=>{var p=h(c());(function(){function X($){if($==null)return null;if(typeof $==="function")return $.$$typeof===i?null:$.displayName||$.name||null;if(typeof $==="string")return $;switch($){case L:return"Fragment";case k:return"Profiler";case P:return"StrictMode";case b:return"Suspense";case YX:return"SuspenseList";case d:return"Activity"}if(typeof $==="object")switch(typeof $.tag==="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),$.$$typeof){case w:return"Portal";case R:return $.displayName||"Context";case S:return($._context.displayName||"Context")+".Consumer";case g:var V=$.render;return $=$.displayName,$||($=V.displayName||V.name||"",$=$!==""?"ForwardRef("+$+")":"ForwardRef"),$;case O:return V=$.displayName||null,V!==null?V:X($.type)||"Memo";case Q:V=$._payload,$=$._init;try{return X($(V))}catch(D){}}return null}function Y($){return""+$}function G($){try{Y($);var V=!1}catch(_X){V=!0}if(V){V=console;var D=V.error,T=typeof Symbol==="function"&&Symbol.toStringTag&&$[Symbol.toStringTag]||$.constructor.name||"Object";return D.call(V,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",T),Y($)}}function J($){if($===L)return"<>";if(typeof $==="object"&&$!==null&&$.$$typeof===Q)return"<...>";try{var V=X($);return V?"<"+V+">":"<...>"}catch(D){return"<...>"}}function Z(){var $=s.A;return $===null?null:$.getOwner()}function H(){return Error("react-stack-top-frame")}function _($){if(y.call($,"key")){var V=Object.getOwnPropertyDescriptor($,"key").get;if(V&&V.isReactWarning)return!1}return $.key!==void 0}function W($,V){function D(){vX||(vX=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",V))}D.isReactWarning=!0,Object.defineProperty($,"key",{get:D,configurable:!0})}function A(){var $=X(this.type);return gX[$]||(gX[$]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),$=this.props.ref,$!==void 0?$:null}function U($,V,D,T,_X,KX){var I=D.ref;return $={$$typeof:K,type:$,key:V,props:D,_owner:T},(I!==void 0?I:null)!==null?Object.defineProperty($,"ref",{enumerable:!1,get:A}):Object.defineProperty($,"ref",{enumerable:!1,value:null}),$._store={},Object.defineProperty($._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty($,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty($,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:_X}),Object.defineProperty($,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:KX}),Object.freeze&&(Object.freeze($.props),Object.freeze($)),$}function z($,V,D,T,_X,KX){var I=V.children;if(I!==void 0)if(T)if(n(I)){for(T=0;T<I.length;T++)E(I[T]);Object.freeze&&Object.freeze(I)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else E(I);if(y.call(V,"key")){I=X($);var a=Object.keys(V).filter(function(BY){return BY!=="key"});T=0<a.length?"{key: someKey, "+a.join(": ..., ")+": ...}":"{key: someKey}",mX[I+T]||(a=0<a.length?"{"+a.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
- let props = %s;
3
- <%s {...props} />
4
- React keys must be passed directly to JSX without using spread:
5
- let props = %s;
6
- <%s key={someKey} {...props} />`,T,I,a,I),mX[I+T]=!0)}if(I=null,D!==void 0&&(G(D),I=""+D),_(V)&&(G(V.key),I=""+V.key),"key"in V){D={};for(var TX in V)TX!=="key"&&(D[TX]=V[TX])}else D=V;return I&&W(D,typeof $==="function"?$.displayName||$.name||"Unknown":$),U($,I,D,Z(),_X,KX)}function E($){N($)?$._store&&($._store.validated=1):typeof $==="object"&&$!==null&&$.$$typeof===Q&&($._payload.status==="fulfilled"?N($._payload.value)&&$._payload.value._store&&($._payload.value._store.validated=1):$._store&&($._store.validated=1))}function N($){return typeof $==="object"&&$!==null&&$.$$typeof===K}var K=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),L=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),R=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),YX=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),d=Symbol.for("react.activity"),i=Symbol.for("react.client.reference"),s=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,y=Object.prototype.hasOwnProperty,n=Array.isArray,EX=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function($){return $()}};var vX,gX={},bX=p.react_stack_bottom_frame.bind(p,H)(),hX=EX(J(H)),mX={};DY.Fragment=L,DY.jsx=function($,V,D){var T=1e4>s.recentlyCreatedOwnerStacks++;return z($,V,D,!1,T?Error("react-stack-top-frame"):bX,T?EX(J($)):hX)},DY.jsxs=function($,V,D){var T=1e4>s.recentlyCreatedOwnerStacks++;return z($,V,D,!0,T?Error("react-stack-top-frame"):bX,T?EX(J($)):hX)}})()});var o=h(c(),1),fX=h(IX(),1),PX=o.createContext(void 0),GX=(X)=>{let Y=o.useContext(PX);if(X)return X;if(!Y)throw Error("No QueryClient set, use QueryClientProvider to set one");return Y},FY=({client:X,children:Y})=>{return o.useEffect(()=>{return X.mount(),()=>{X.unmount()}},[X]),fX.jsx(PX.Provider,{value:X,children:Y})};var M=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(X){return this.listeners.add(X),this.onSubscribe(),()=>{this.listeners.delete(X),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var EY={setTimeout:(X,Y)=>setTimeout(X,Y),clearTimeout:(X)=>clearTimeout(X),setInterval:(X,Y)=>setInterval(X,Y),clearInterval:(X)=>clearInterval(X)},KY=class{#X=EY;#Y=!1;setTimeoutProvider(X){if(this.#Y&&X!==this.#X)console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#X,provider:X});this.#X=X,this.#Y=!1}setTimeout(X,Y){return this.#Y=!0,this.#X.setTimeout(X,Y)}clearTimeout(X){this.#X.clearTimeout(X)}setInterval(X,Y){return this.#Y=!0,this.#X.setInterval(X,Y)}clearInterval(X){this.#X.clearInterval(X)}},q=new KY;function dX(X){setTimeout(X,0)}var x=typeof window>"u"||"Deno"in globalThis;function F(){}function cX(X,Y){return typeof X==="function"?X(Y):X}function JX(X){return typeof X==="number"&&X>=0&&X!==1/0}function VX(X,Y){return Math.max(X+(Y||0)-Date.now(),0)}function C(X,Y){return typeof X==="function"?X(Y):X}function j(X,Y){return typeof X==="function"?X(Y):X}function AX(X,Y){let{type:G="all",exact:J,fetchStatus:Z,predicate:H,queryKey:_,stale:W}=X;if(_){if(J){if(Y.queryHash!==ZX(_,Y.options))return!1}else if(!u(Y.queryKey,_))return!1}if(G!=="all"){let A=Y.isActive();if(G==="active"&&!A)return!1;if(G==="inactive"&&A)return!1}if(typeof W==="boolean"&&Y.isStale()!==W)return!1;if(Z&&Z!==Y.state.fetchStatus)return!1;if(H&&!H(Y))return!1;return!0}function NX(X,Y){let{exact:G,status:J,predicate:Z,mutationKey:H}=X;if(H){if(!Y.options.mutationKey)return!1;if(G){if(v(Y.options.mutationKey)!==v(H))return!1}else if(!u(Y.options.mutationKey,H))return!1}if(J&&Y.state.status!==J)return!1;if(Z&&!Z(Y))return!1;return!0}function ZX(X,Y){return(Y?.queryKeyHashFn||v)(X)}function v(X){return JSON.stringify(X,(Y,G)=>kX(G)?Object.keys(G).sort().reduce((J,Z)=>{return J[Z]=G[Z],J},{}):G)}function u(X,Y){if(X===Y)return!0;if(typeof X!==typeof Y)return!1;if(X&&Y&&typeof X==="object"&&typeof Y==="object")return Object.keys(Y).every((G)=>u(X[G],Y[G]));return!1}var TY=Object.prototype.hasOwnProperty;function zX(X,Y,G=0){if(X===Y)return X;if(G>500)return Y;let J=yX(X)&&yX(Y);if(!J&&!(kX(X)&&kX(Y)))return Y;let H=(J?X:Object.keys(X)).length,_=J?Y:Object.keys(Y),W=_.length,A=J?Array(W):{},U=0;for(let z=0;z<W;z++){let E=J?z:_[z],N=X[E],K=Y[E];if(N===K){if(A[E]=N,J?z<H:TY.call(X,E))U++;continue}if(N===null||K===null||typeof N!=="object"||typeof K!=="object"){A[E]=K;continue}let w=zX(N,K,G+1);if(A[E]=w,w===N)U++}return H===W&&U===H?X:A}function r(X,Y){if(!Y||Object.keys(X).length!==Object.keys(Y).length)return!1;for(let G in X)if(X[G]!==Y[G])return!1;return!0}function yX(X){return Array.isArray(X)&&X.length===Object.keys(X).length}function kX(X){if(!pX(X))return!1;let Y=X.constructor;if(Y===void 0)return!0;let G=Y.prototype;if(!pX(G))return!1;if(!G.hasOwnProperty("isPrototypeOf"))return!1;if(Object.getPrototypeOf(X)!==Object.prototype)return!1;return!0}function pX(X){return Object.prototype.toString.call(X)==="[object Object]"}function lX(X){return new Promise((Y)=>{q.setTimeout(Y,X)})}function $X(X,Y,G){if(typeof G.structuralSharing==="function")return G.structuralSharing(X,Y);else if(G.structuralSharing!==!1){try{return zX(X,Y)}catch(J){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${G.queryHash}]: ${J}`),J}return zX(X,Y)}return Y}function uX(X,Y,G=0){let J=[...X,Y];return G&&J.length>G?J.slice(1):J}function iX(X,Y,G=0){let J=[Y,...X];return G&&J.length>G?J.slice(0,-1):J}var l=Symbol();function LX(X,Y){if(X.queryFn===l)console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${X.queryHash}'`);if(!X.queryFn&&Y?.initialPromise)return()=>Y.initialPromise;if(!X.queryFn||X.queryFn===l)return()=>Promise.reject(Error(`Missing queryFn: '${X.queryHash}'`));return X.queryFn}function t(X,Y){if(typeof X==="function")return X(...Y);return!!X}function sX(X,Y,G){let J=!1,Z;return Object.defineProperty(X,"signal",{enumerable:!0,get:()=>{if(Z??=Y(),J)return Z;if(J=!0,Z.aborted)G();else Z.addEventListener("abort",G,{once:!0});return Z}}),X}var IY=class extends M{#X;#Y;#G;constructor(){super();this.#G=(X)=>{if(!x&&window.addEventListener){let Y=()=>X();return window.addEventListener("visibilitychange",Y,!1),()=>{window.removeEventListener("visibilitychange",Y)}}return}}onSubscribe(){if(!this.#Y)this.setEventListener(this.#G)}onUnsubscribe(){if(!this.hasListeners())this.#Y?.(),this.#Y=void 0}setEventListener(X){this.#G=X,this.#Y?.(),this.#Y=X((Y)=>{if(typeof Y==="boolean")this.setFocused(Y);else this.onFocus()})}setFocused(X){if(this.#X!==X)this.#X=X,this.onFocus()}onFocus(){let X=this.isFocused();this.listeners.forEach((Y)=>{Y(X)})}isFocused(){if(typeof this.#X==="boolean")return this.#X;return globalThis.document?.visibilityState!=="hidden"}},e=new IY;function WX(){let X,Y,G=new Promise((Z,H)=>{X=Z,Y=H});G.status="pending",G.catch(()=>{});function J(Z){Object.assign(G,Z),delete G.resolve,delete G.reject}return G.resolve=(Z)=>{J({status:"fulfilled",value:Z}),X(Z)},G.reject=(Z)=>{J({status:"rejected",reason:Z}),Y(Z)},G}var nX=dX;function PY(){let X=[],Y=0,G=(W)=>{W()},J=(W)=>{W()},Z=nX,H=(W)=>{if(Y)X.push(W);else Z(()=>{G(W)})},_=()=>{let W=X;if(X=[],W.length)Z(()=>{J(()=>{W.forEach((A)=>{G(A)})})})};return{batch:(W)=>{let A;Y++;try{A=W()}finally{if(Y--,!Y)_()}return A},batchCalls:(W)=>{return(...A)=>{H(()=>{W(...A)})}},schedule:H,setNotifyFunction:(W)=>{G=W},setBatchNotifyFunction:(W)=>{J=W},setScheduler:(W)=>{Z=W}}}var B=PY();var kY=class extends M{#X=!0;#Y;#G;constructor(){super();this.#G=(X)=>{if(!x&&window.addEventListener){let Y=()=>X(!0),G=()=>X(!1);return window.addEventListener("online",Y,!1),window.addEventListener("offline",G,!1),()=>{window.removeEventListener("online",Y),window.removeEventListener("offline",G)}}return}}onSubscribe(){if(!this.#Y)this.setEventListener(this.#G)}onUnsubscribe(){if(!this.hasListeners())this.#Y?.(),this.#Y=void 0}setEventListener(X){this.#G=X,this.#Y?.(),this.#Y=X(this.setOnline.bind(this))}setOnline(X){if(this.#X!==X)this.#X=X,this.listeners.forEach((G)=>{G(X)})}isOnline(){return this.#X}},XX=new kY;function QY(X){return Math.min(1000*2**X,30000)}function QX(X){return(X??"online")==="online"?XX.isOnline():!0}var UX=class extends Error{constructor(X){super("CancelledError");this.revert=X?.revert,this.silent=X?.silent}};function BX(X){let Y=!1,G=0,J,Z=WX(),H=()=>Z.status!=="pending",_=(L)=>{if(!H()){let P=new UX(L);N(P),X.onCancel?.(P)}},W=()=>{Y=!0},A=()=>{Y=!1},U=()=>e.isFocused()&&(X.networkMode==="always"||XX.isOnline())&&X.canRun(),z=()=>QX(X.networkMode)&&X.canRun(),E=(L)=>{if(!H())J?.(),Z.resolve(L)},N=(L)=>{if(!H())J?.(),Z.reject(L)},K=()=>{return new Promise((L)=>{J=(P)=>{if(H()||U())L(P)},X.onPause?.()}).then(()=>{if(J=void 0,!H())X.onContinue?.()})},w=()=>{if(H())return;let L,P=G===0?X.initialPromise:void 0;try{L=P??X.fn()}catch(k){L=Promise.reject(k)}Promise.resolve(L).then(E).catch((k)=>{if(H())return;let S=X.retry??(x?0:3),R=X.retryDelay??QY,g=typeof R==="function"?R(G,k):R,b=S===!0||typeof S==="number"&&G<S||typeof S==="function"&&S(G,k);if(Y||!b){N(k);return}G++,X.onFail?.(G,k),lX(g).then(()=>{return U()?void 0:K()}).then(()=>{if(Y)N(k);else w()})})};return{promise:Z,status:()=>Z.status,cancel:_,continue:()=>{return J?.(),Z},cancelRetry:W,continueRetry:A,canStart:z,start:()=>{if(z())w();else K().then(w);return Z}}}var wX=class{#X;destroy(){this.clearGcTimeout()}scheduleGc(){if(this.clearGcTimeout(),JX(this.gcTime))this.#X=q.setTimeout(()=>{this.optionalRemove()},this.gcTime)}updateGcTime(X){this.gcTime=Math.max(this.gcTime||0,X??(x?1/0:300000))}clearGcTimeout(){if(this.#X)q.clearTimeout(this.#X),this.#X=void 0}};var rX=class extends wX{#X;#Y;#G;#Z;#J;#W;#H;constructor(X){super();this.#H=!1,this.#W=X.defaultOptions,this.setOptions(X.options),this.observers=[],this.#Z=X.client,this.#G=this.#Z.getQueryCache(),this.queryKey=X.queryKey,this.queryHash=X.queryHash,this.#X=oX(this.options),this.state=X.state??this.#X,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#J?.promise}setOptions(X){if(this.options={...this.#W,...X},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let Y=oX(this.options);if(Y.data!==void 0)this.setState(aX(Y.data,Y.dataUpdatedAt)),this.#X=Y}}optionalRemove(){if(!this.observers.length&&this.state.fetchStatus==="idle")this.#G.remove(this)}setData(X,Y){let G=$X(this.state.data,X,this.options);return this.#$({data:G,type:"success",dataUpdatedAt:Y?.updatedAt,manual:Y?.manual}),G}setState(X,Y){this.#$({type:"setState",state:X,setStateOptions:Y})}cancel(X){let Y=this.#J?.promise;return this.#J?.cancel(X),Y?Y.then(F).catch(F):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#X)}isActive(){return this.observers.some((X)=>j(X.options.enabled,this)!==!1)}isDisabled(){if(this.getObserversCount()>0)return!this.isActive();return this.options.queryFn===l||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){if(this.getObserversCount()>0)return this.observers.some((X)=>C(X.options.staleTime,this)==="static");return!1}isStale(){if(this.getObserversCount()>0)return this.observers.some((X)=>X.getCurrentResult().isStale);return this.state.data===void 0||this.state.isInvalidated}isStaleByTime(X=0){if(this.state.data===void 0)return!0;if(X==="static")return!1;if(this.state.isInvalidated)return!0;return!VX(this.state.dataUpdatedAt,X)}onFocus(){this.observers.find((Y)=>Y.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#J?.continue()}onOnline(){this.observers.find((Y)=>Y.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#J?.continue()}addObserver(X){if(!this.observers.includes(X))this.observers.push(X),this.clearGcTimeout(),this.#G.notify({type:"observerAdded",query:this,observer:X})}removeObserver(X){if(this.observers.includes(X)){if(this.observers=this.observers.filter((Y)=>Y!==X),!this.observers.length){if(this.#J)if(this.#H)this.#J.cancel({revert:!0});else this.#J.cancelRetry();this.scheduleGc()}this.#G.notify({type:"observerRemoved",query:this,observer:X})}}getObserversCount(){return this.observers.length}invalidate(){if(!this.state.isInvalidated)this.#$({type:"invalidate"})}async fetch(X,Y){if(this.state.fetchStatus!=="idle"&&this.#J?.status()!=="rejected"){if(this.state.data!==void 0&&Y?.cancelRefetch)this.cancel({silent:!0});else if(this.#J)return this.#J.continueRetry(),this.#J.promise}if(X)this.setOptions(X);if(!this.options.queryFn){let W=this.observers.find((A)=>A.options.queryFn);if(W)this.setOptions(W.options)}if(!Array.isArray(this.options.queryKey))console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']");let G=new AbortController,J=(W)=>{Object.defineProperty(W,"signal",{enumerable:!0,get:()=>{return this.#H=!0,G.signal}})},Z=()=>{let W=LX(this.options,Y),U=(()=>{let z={client:this.#Z,queryKey:this.queryKey,meta:this.meta};return J(z),z})();if(this.#H=!1,this.options.persister)return this.options.persister(W,U,this);return W(U)},_=(()=>{let W={fetchOptions:Y,options:this.options,queryKey:this.queryKey,client:this.#Z,state:this.state,fetchFn:Z};return J(W),W})();if(this.options.behavior?.onFetch(_,this),this.#Y=this.state,this.state.fetchStatus==="idle"||this.state.fetchMeta!==_.fetchOptions?.meta)this.#$({type:"fetch",meta:_.fetchOptions?.meta});this.#J=BX({initialPromise:Y?.initialPromise,fn:_.fetchFn,onCancel:(W)=>{if(W instanceof UX&&W.revert)this.setState({...this.#Y,fetchStatus:"idle"});G.abort()},onFail:(W,A)=>{this.#$({type:"failed",failureCount:W,error:A})},onPause:()=>{this.#$({type:"pause"})},onContinue:()=>{this.#$({type:"continue"})},retry:_.options.retry,retryDelay:_.options.retryDelay,networkMode:_.options.networkMode,canRun:()=>!0});try{let W=await this.#J.start();if(W===void 0)throw console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),Error(`${this.queryHash} data is undefined`);return this.setData(W),this.#G.config.onSuccess?.(W,this),this.#G.config.onSettled?.(W,this.state.error,this),W}catch(W){if(W instanceof UX){if(W.silent)return this.#J.promise;else if(W.revert){if(this.state.data===void 0)throw W;return this.state.data}}throw this.#$({type:"error",error:W}),this.#G.config.onError?.(W,this),this.#G.config.onSettled?.(this.state.data,W,this),W}finally{this.scheduleGc()}}#$(X){let Y=(G)=>{switch(X.type){case"failed":return{...G,fetchFailureCount:X.failureCount,fetchFailureReason:X.error};case"pause":return{...G,fetchStatus:"paused"};case"continue":return{...G,fetchStatus:"fetching"};case"fetch":return{...G,...xX(G.data,this.options),fetchMeta:X.meta??null};case"success":let J={...G,...aX(X.data,X.dataUpdatedAt),dataUpdateCount:G.dataUpdateCount+1,...!X.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#Y=X.manual?J:void 0,J;case"error":let Z=X.error;return{...G,error:Z,errorUpdateCount:G.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:G.fetchFailureCount+1,fetchFailureReason:Z,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...G,isInvalidated:!0};case"setState":return{...G,...X.state}}};this.state=Y(this.state),B.batch(()=>{this.observers.forEach((G)=>{G.onQueryUpdate()}),this.#G.notify({query:this,type:"updated",action:X})})}};function xX(X,Y){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:QX(Y.networkMode)?"fetching":"paused",...X===void 0&&{error:null,status:"pending"}}}function aX(X,Y){return{data:X,dataUpdatedAt:Y??Date.now(),error:null,isInvalidated:!1,status:"success"}}function oX(X){let Y=typeof X.initialData==="function"?X.initialData():X.initialData,G=Y!==void 0,J=G?typeof X.initialDataUpdatedAt==="function"?X.initialDataUpdatedAt():X.initialDataUpdatedAt:0;return{data:Y,dataUpdateCount:0,dataUpdatedAt:G?J??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:G?"success":"pending",fetchStatus:"idle"}}var SX=class extends M{constructor(X,Y){super();this.options=Y,this.#X=X,this.#$=null,this.#H=WX(),this.bindMethods(),this.setOptions(Y)}#X;#Y=void 0;#G=void 0;#Z=void 0;#J;#W;#H;#$;#B;#N;#L;#z;#V;#_;#U=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){if(this.listeners.size===1){if(this.#Y.addObserver(this),tX(this.#Y,this.options))this.#A();else this.updateResult();this.#E()}}onUnsubscribe(){if(!this.hasListeners())this.destroy()}shouldFetchOnReconnect(){return jX(this.#Y,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return jX(this.#Y,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#K(),this.#T(),this.#Y.removeObserver(this)}setOptions(X){let Y=this.options,G=this.#Y;if(this.options=this.#X.defaultQueryOptions(X),this.options.enabled!==void 0&&typeof this.options.enabled!=="boolean"&&typeof this.options.enabled!=="function"&&typeof j(this.options.enabled,this.#Y)!=="boolean")throw Error("Expected enabled to be a boolean or a callback that returns a boolean");if(this.#I(),this.#Y.setOptions(this.options),Y._defaulted&&!r(this.options,Y))this.#X.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#Y,observer:this});let J=this.hasListeners();if(J&&eX(this.#Y,G,this.options,Y))this.#A();if(this.updateResult(),J&&(this.#Y!==G||j(this.options.enabled,this.#Y)!==j(Y.enabled,this.#Y)||C(this.options.staleTime,this.#Y)!==C(Y.staleTime,this.#Y)))this.#w();let Z=this.#D();if(J&&(this.#Y!==G||j(this.options.enabled,this.#Y)!==j(Y.enabled,this.#Y)||Z!==this.#_))this.#F(Z)}getOptimisticResult(X){let Y=this.#X.getQueryCache().build(this.#X,X),G=this.createResult(Y,X);if(jY(this,G))this.#Z=G,this.#W=this.options,this.#J=this.#Y.state;return G}getCurrentResult(){return this.#Z}trackResult(X,Y){return new Proxy(X,{get:(G,J)=>{if(this.trackProp(J),Y?.(J),J==="promise"){if(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#H.status==="pending")this.#H.reject(Error("experimental_prefetchInRender feature flag is not enabled"))}return Reflect.get(G,J)}})}trackProp(X){this.#U.add(X)}getCurrentQuery(){return this.#Y}refetch({...X}={}){return this.fetch({...X})}fetchOptimistic(X){let Y=this.#X.defaultQueryOptions(X),G=this.#X.getQueryCache().build(this.#X,Y);return G.fetch().then(()=>this.createResult(G,Y))}fetch(X){return this.#A({...X,cancelRefetch:X.cancelRefetch??!0}).then(()=>{return this.updateResult(),this.#Z})}#A(X){this.#I();let Y=this.#Y.fetch(this.options,X);if(!X?.throwOnError)Y=Y.catch(F);return Y}#w(){this.#K();let X=C(this.options.staleTime,this.#Y);if(x||this.#Z.isStale||!JX(X))return;let G=VX(this.#Z.dataUpdatedAt,X)+1;this.#z=q.setTimeout(()=>{if(!this.#Z.isStale)this.updateResult()},G)}#D(){return(typeof this.options.refetchInterval==="function"?this.options.refetchInterval(this.#Y):this.options.refetchInterval)??!1}#F(X){if(this.#T(),this.#_=X,x||j(this.options.enabled,this.#Y)===!1||!JX(this.#_)||this.#_===0)return;this.#V=q.setInterval(()=>{if(this.options.refetchIntervalInBackground||e.isFocused())this.#A()},this.#_)}#E(){this.#w(),this.#F(this.#D())}#K(){if(this.#z)q.clearTimeout(this.#z),this.#z=void 0}#T(){if(this.#V)q.clearInterval(this.#V),this.#V=void 0}createResult(X,Y){let G=this.#Y,J=this.options,Z=this.#Z,H=this.#J,_=this.#W,A=X!==G?X.state:this.#G,{state:U}=X,z={...U},E=!1,N;if(Y._optimisticResults){let Q=this.hasListeners(),d=!Q&&tX(X,Y),i=Q&&eX(X,G,Y,J);if(d||i)z={...z,...xX(U.data,X.options)};if(Y._optimisticResults==="isRestoring")z.fetchStatus="idle"}let{error:K,errorUpdatedAt:w,status:L}=z;N=z.data;let P=!1;if(Y.placeholderData!==void 0&&N===void 0&&L==="pending"){let Q;if(Z?.isPlaceholderData&&Y.placeholderData===_?.placeholderData)Q=Z.data,P=!0;else Q=typeof Y.placeholderData==="function"?Y.placeholderData(this.#L?.state.data,this.#L):Y.placeholderData;if(Q!==void 0)L="success",N=$X(Z?.data,Q,Y),E=!0}if(Y.select&&N!==void 0&&!P)if(Z&&N===H?.data&&Y.select===this.#B)N=this.#N;else try{this.#B=Y.select,N=Y.select(N),N=$X(Z?.data,N,Y),this.#N=N,this.#$=null}catch(Q){this.#$=Q}if(this.#$)K=this.#$,N=this.#N,w=Date.now(),L="error";let k=z.fetchStatus==="fetching",S=L==="pending",R=L==="error",g=S&&k,b=N!==void 0,O={status:L,fetchStatus:z.fetchStatus,isPending:S,isSuccess:L==="success",isError:R,isInitialLoading:g,isLoading:g,data:N,dataUpdatedAt:z.dataUpdatedAt,error:K,errorUpdatedAt:w,failureCount:z.fetchFailureCount,failureReason:z.fetchFailureReason,errorUpdateCount:z.errorUpdateCount,isFetched:z.dataUpdateCount>0||z.errorUpdateCount>0,isFetchedAfterMount:z.dataUpdateCount>A.dataUpdateCount||z.errorUpdateCount>A.errorUpdateCount,isFetching:k,isRefetching:k&&!S,isLoadingError:R&&!b,isPaused:z.fetchStatus==="paused",isPlaceholderData:E,isRefetchError:R&&b,isStale:MX(X,Y),refetch:this.refetch,promise:this.#H,isEnabled:j(Y.enabled,X)!==!1};if(this.options.experimental_prefetchInRender){let Q=O.data!==void 0,d=O.status==="error"&&!Q,i=(n)=>{if(d)n.reject(O.error);else if(Q)n.resolve(O.data)},s=()=>{let n=this.#H=O.promise=WX();i(n)},y=this.#H;switch(y.status){case"pending":if(X.queryHash===G.queryHash)i(y);break;case"fulfilled":if(d||O.data!==y.value)s();break;case"rejected":if(!d||O.error!==y.reason)s();break}}return O}updateResult(){let X=this.#Z,Y=this.createResult(this.#Y,this.options);if(this.#J=this.#Y.state,this.#W=this.options,this.#J.data!==void 0)this.#L=this.#Y;if(r(Y,X))return;this.#Z=Y;let G=()=>{if(!X)return!0;let{notifyOnChangeProps:J}=this.options,Z=typeof J==="function"?J():J;if(Z==="all"||!Z&&!this.#U.size)return!0;let H=new Set(Z??this.#U);if(this.options.throwOnError)H.add("error");return Object.keys(this.#Z).some((_)=>{let W=_;return this.#Z[W]!==X[W]&&H.has(W)})};this.#P({listeners:G()})}#I(){let X=this.#X.getQueryCache().build(this.#X,this.options);if(X===this.#Y)return;let Y=this.#Y;if(this.#Y=X,this.#G=X.state,this.hasListeners())Y?.removeObserver(this),X.addObserver(this)}onQueryUpdate(){if(this.updateResult(),this.hasListeners())this.#E()}#P(X){B.batch(()=>{if(X.listeners)this.listeners.forEach((Y)=>{Y(this.#Z)});this.#X.getQueryCache().notify({query:this.#Y,type:"observerResultsUpdated"})})}};function xY(X,Y){return j(Y.enabled,X)!==!1&&X.state.data===void 0&&!(X.state.status==="error"&&Y.retryOnMount===!1)}function tX(X,Y){return xY(X,Y)||X.state.data!==void 0&&jX(X,Y,Y.refetchOnMount)}function jX(X,Y,G){if(j(Y.enabled,X)!==!1&&C(Y.staleTime,X)!=="static"){let J=typeof G==="function"?G(X):G;return J==="always"||J!==!1&&MX(X,Y)}return!1}function eX(X,Y,G,J){return(X!==Y||j(J.enabled,X)===!1)&&(!G.suspense||X.state.status!=="error")&&MX(X,G)}function MX(X,Y){return j(Y.enabled,X)!==!1&&X.isStaleByTime(C(Y.staleTime,X))}function jY(X,Y){if(!r(X.getCurrentResult(),Y))return!0;return!1}function RX(X){return{onFetch:(Y,G)=>{let J=Y.options,Z=Y.fetchOptions?.meta?.fetchMore?.direction,H=Y.state.data?.pages||[],_=Y.state.data?.pageParams||[],W={pages:[],pageParams:[]},A=0,U=async()=>{let z=!1,E=(w)=>{sX(w,()=>Y.signal,()=>z=!0)},N=LX(Y.options,Y.fetchOptions),K=async(w,L,P)=>{if(z)return Promise.reject();if(L==null&&w.pages.length)return Promise.resolve(w);let S=(()=>{let YX={client:Y.client,queryKey:Y.queryKey,pageParam:L,direction:P?"backward":"forward",meta:Y.options.meta};return E(YX),YX})(),R=await N(S),{maxPages:g}=Y.options,b=P?iX:uX;return{pages:b(w.pages,R,g),pageParams:b(w.pageParams,L,g)}};if(Z&&H.length){let w=Z==="backward",L=w?SY:XY,P={pages:H,pageParams:_},k=L(J,P);W=await K(P,k,w)}else{let w=X??H.length;do{let L=A===0?_[0]??J.initialPageParam:XY(J,W);if(A>0&&L==null)break;W=await K(W,L),A++}while(A<w)}return W};if(Y.options.persister)Y.fetchFn=()=>{return Y.options.persister?.(U,{client:Y.client,queryKey:Y.queryKey,meta:Y.options.meta,signal:Y.signal},G)};else Y.fetchFn=U}}}function XY(X,{pages:Y,pageParams:G}){let J=Y.length-1;return Y.length>0?X.getNextPageParam(Y[J],Y,G[J],G):void 0}function SY(X,{pages:Y,pageParams:G}){return Y.length>0?X.getPreviousPageParam?.(Y[0],Y,G[0],G):void 0}var YY=class extends wX{#X;#Y;#G;#Z;constructor(X){super();this.#X=X.client,this.mutationId=X.mutationId,this.#G=X.mutationCache,this.#Y=[],this.state=X.state||CX(),this.setOptions(X.options),this.scheduleGc()}setOptions(X){this.options=X,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(X){if(!this.#Y.includes(X))this.#Y.push(X),this.clearGcTimeout(),this.#G.notify({type:"observerAdded",mutation:this,observer:X})}removeObserver(X){this.#Y=this.#Y.filter((Y)=>Y!==X),this.scheduleGc(),this.#G.notify({type:"observerRemoved",mutation:this,observer:X})}optionalRemove(){if(!this.#Y.length)if(this.state.status==="pending")this.scheduleGc();else this.#G.remove(this)}continue(){return this.#Z?.continue()??this.execute(this.state.variables)}async execute(X){let Y=()=>{this.#J({type:"continue"})},G={client:this.#X,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#Z=BX({fn:()=>{if(!this.options.mutationFn)return Promise.reject(Error("No mutationFn found"));return this.options.mutationFn(X,G)},onFail:(H,_)=>{this.#J({type:"failed",failureCount:H,error:_})},onPause:()=>{this.#J({type:"pause"})},onContinue:Y,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#G.canRun(this)});let J=this.state.status==="pending",Z=!this.#Z.canStart();try{if(J)Y();else{if(this.#J({type:"pending",variables:X,isPaused:Z}),this.#G.config.onMutate)await this.#G.config.onMutate(X,this,G);let _=await this.options.onMutate?.(X,G);if(_!==this.state.context)this.#J({type:"pending",context:_,variables:X,isPaused:Z})}let H=await this.#Z.start();return await this.#G.config.onSuccess?.(H,X,this.state.context,this,G),await this.options.onSuccess?.(H,X,this.state.context,G),await this.#G.config.onSettled?.(H,null,this.state.variables,this.state.context,this,G),await this.options.onSettled?.(H,null,X,this.state.context,G),this.#J({type:"success",data:H}),H}catch(H){try{await this.#G.config.onError?.(H,X,this.state.context,this,G)}catch(_){Promise.reject(_)}try{await this.options.onError?.(H,X,this.state.context,G)}catch(_){Promise.reject(_)}try{await this.#G.config.onSettled?.(void 0,H,this.state.variables,this.state.context,this,G)}catch(_){Promise.reject(_)}try{await this.options.onSettled?.(void 0,H,X,this.state.context,G)}catch(_){Promise.reject(_)}throw this.#J({type:"error",error:H}),H}finally{this.#G.runNext(this)}}#J(X){let Y=(G)=>{switch(X.type){case"failed":return{...G,failureCount:X.failureCount,failureReason:X.error};case"pause":return{...G,isPaused:!0};case"continue":return{...G,isPaused:!1};case"pending":return{...G,context:X.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:X.isPaused,status:"pending",variables:X.variables,submittedAt:Date.now()};case"success":return{...G,data:X.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...G,data:void 0,error:X.error,failureCount:G.failureCount+1,failureReason:X.error,isPaused:!1,status:"error"}}};this.state=Y(this.state),B.batch(()=>{this.#Y.forEach((G)=>{G.onMutationUpdate(X)}),this.#G.notify({mutation:this,type:"updated",action:X})})}};function CX(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var GY=class extends M{constructor(X={}){super();this.config=X,this.#X=new Set,this.#Y=new Map,this.#G=0}#X;#Y;#G;build(X,Y,G){let J=new YY({client:X,mutationCache:this,mutationId:++this.#G,options:X.defaultMutationOptions(Y),state:G});return this.add(J),J}add(X){this.#X.add(X);let Y=DX(X);if(typeof Y==="string"){let G=this.#Y.get(Y);if(G)G.push(X);else this.#Y.set(Y,[X])}this.notify({type:"added",mutation:X})}remove(X){if(this.#X.delete(X)){let Y=DX(X);if(typeof Y==="string"){let G=this.#Y.get(Y);if(G){if(G.length>1){let J=G.indexOf(X);if(J!==-1)G.splice(J,1)}else if(G[0]===X)this.#Y.delete(Y)}}}this.notify({type:"removed",mutation:X})}canRun(X){let Y=DX(X);if(typeof Y==="string"){let J=this.#Y.get(Y)?.find((Z)=>Z.state.status==="pending");return!J||J===X}else return!0}runNext(X){let Y=DX(X);if(typeof Y==="string")return this.#Y.get(Y)?.find((J)=>J!==X&&J.state.isPaused)?.continue()??Promise.resolve();else return Promise.resolve()}clear(){B.batch(()=>{this.#X.forEach((X)=>{this.notify({type:"removed",mutation:X})}),this.#X.clear(),this.#Y.clear()})}getAll(){return Array.from(this.#X)}find(X){let Y={exact:!0,...X};return this.getAll().find((G)=>NX(Y,G))}findAll(X={}){return this.getAll().filter((Y)=>NX(X,Y))}notify(X){B.batch(()=>{this.listeners.forEach((Y)=>{Y(X)})})}resumePausedMutations(){let X=this.getAll().filter((Y)=>Y.state.isPaused);return B.batch(()=>Promise.all(X.map((Y)=>Y.continue().catch(F))))}};function DX(X){return X.options.scope?.id}var OX=class extends M{#X;#Y=void 0;#G;#Z;constructor(X,Y){super();this.#X=X,this.setOptions(Y),this.bindMethods(),this.#J()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(X){let Y=this.options;if(this.options=this.#X.defaultMutationOptions(X),!r(this.options,Y))this.#X.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#G,observer:this});if(Y?.mutationKey&&this.options.mutationKey&&v(Y.mutationKey)!==v(this.options.mutationKey))this.reset();else if(this.#G?.state.status==="pending")this.#G.setOptions(this.options)}onUnsubscribe(){if(!this.hasListeners())this.#G?.removeObserver(this)}onMutationUpdate(X){this.#J(),this.#W(X)}getCurrentResult(){return this.#Y}reset(){this.#G?.removeObserver(this),this.#G=void 0,this.#J(),this.#W()}mutate(X,Y){return this.#Z=Y,this.#G?.removeObserver(this),this.#G=this.#X.getMutationCache().build(this.#X,this.options),this.#G.addObserver(this),this.#G.execute(X)}#J(){let X=this.#G?.state??CX();this.#Y={...X,isPending:X.status==="pending",isSuccess:X.status==="success",isError:X.status==="error",isIdle:X.status==="idle",mutate:this.mutate,reset:this.reset}}#W(X){B.batch(()=>{if(this.#Z&&this.hasListeners()){let Y=this.#Y.variables,G=this.#Y.context,J={client:this.#X,meta:this.options.meta,mutationKey:this.options.mutationKey};if(X?.type==="success"){try{this.#Z.onSuccess?.(X.data,Y,G,J)}catch(Z){Promise.reject(Z)}try{this.#Z.onSettled?.(X.data,null,Y,G,J)}catch(Z){Promise.reject(Z)}}else if(X?.type==="error"){try{this.#Z.onError?.(X.error,Y,G,J)}catch(Z){Promise.reject(Z)}try{this.#Z.onSettled?.(void 0,X.error,Y,G,J)}catch(Z){Promise.reject(Z)}}}this.listeners.forEach((Y)=>{Y(this.#Y)})})}};var JY=class extends M{constructor(X={}){super();this.config=X,this.#X=new Map}#X;build(X,Y,G){let J=Y.queryKey,Z=Y.queryHash??ZX(J,Y),H=this.get(Z);if(!H)H=new rX({client:X,queryKey:J,queryHash:Z,options:X.defaultQueryOptions(Y),state:G,defaultOptions:X.getQueryDefaults(J)}),this.add(H);return H}add(X){if(!this.#X.has(X.queryHash))this.#X.set(X.queryHash,X),this.notify({type:"added",query:X})}remove(X){let Y=this.#X.get(X.queryHash);if(Y){if(X.destroy(),Y===X)this.#X.delete(X.queryHash);this.notify({type:"removed",query:X})}}clear(){B.batch(()=>{this.getAll().forEach((X)=>{this.remove(X)})})}get(X){return this.#X.get(X)}getAll(){return[...this.#X.values()]}find(X){let Y={exact:!0,...X};return this.getAll().find((G)=>AX(Y,G))}findAll(X={}){let Y=this.getAll();return Object.keys(X).length>0?Y.filter((G)=>AX(X,G)):Y}notify(X){B.batch(()=>{this.listeners.forEach((Y)=>{Y(X)})})}onFocus(){B.batch(()=>{this.getAll().forEach((X)=>{X.onFocus()})})}onOnline(){B.batch(()=>{this.getAll().forEach((X)=>{X.onOnline()})})}};var MY=class{#X;#Y;#G;#Z;#J;#W;#H;#$;constructor(X={}){this.#X=X.queryCache||new JY,this.#Y=X.mutationCache||new GY,this.#G=X.defaultOptions||{},this.#Z=new Map,this.#J=new Map,this.#W=0}mount(){if(this.#W++,this.#W!==1)return;this.#H=e.subscribe(async(X)=>{if(X)await this.resumePausedMutations(),this.#X.onFocus()}),this.#$=XX.subscribe(async(X)=>{if(X)await this.resumePausedMutations(),this.#X.onOnline()})}unmount(){if(this.#W--,this.#W!==0)return;this.#H?.(),this.#H=void 0,this.#$?.(),this.#$=void 0}isFetching(X){return this.#X.findAll({...X,fetchStatus:"fetching"}).length}isMutating(X){return this.#Y.findAll({...X,status:"pending"}).length}getQueryData(X){let Y=this.defaultQueryOptions({queryKey:X});return this.#X.get(Y.queryHash)?.state.data}ensureQueryData(X){let Y=this.defaultQueryOptions(X),G=this.#X.build(this,Y),J=G.state.data;if(J===void 0)return this.fetchQuery(X);if(X.revalidateIfStale&&G.isStaleByTime(C(Y.staleTime,G)))this.prefetchQuery(Y);return Promise.resolve(J)}getQueriesData(X){return this.#X.findAll(X).map(({queryKey:Y,state:G})=>{let J=G.data;return[Y,J]})}setQueryData(X,Y,G){let J=this.defaultQueryOptions({queryKey:X}),H=this.#X.get(J.queryHash)?.state.data,_=cX(Y,H);if(_===void 0)return;return this.#X.build(this,J).setData(_,{...G,manual:!0})}setQueriesData(X,Y,G){return B.batch(()=>this.#X.findAll(X).map(({queryKey:J})=>[J,this.setQueryData(J,Y,G)]))}getQueryState(X){let Y=this.defaultQueryOptions({queryKey:X});return this.#X.get(Y.queryHash)?.state}removeQueries(X){let Y=this.#X;B.batch(()=>{Y.findAll(X).forEach((G)=>{Y.remove(G)})})}resetQueries(X,Y){let G=this.#X;return B.batch(()=>{return G.findAll(X).forEach((J)=>{J.reset()}),this.refetchQueries({type:"active",...X},Y)})}cancelQueries(X,Y={}){let G={revert:!0,...Y},J=B.batch(()=>this.#X.findAll(X).map((Z)=>Z.cancel(G)));return Promise.all(J).then(F).catch(F)}invalidateQueries(X,Y={}){return B.batch(()=>{if(this.#X.findAll(X).forEach((G)=>{G.invalidate()}),X?.refetchType==="none")return Promise.resolve();return this.refetchQueries({...X,type:X?.refetchType??X?.type??"active"},Y)})}refetchQueries(X,Y={}){let G={...Y,cancelRefetch:Y.cancelRefetch??!0},J=B.batch(()=>this.#X.findAll(X).filter((Z)=>!Z.isDisabled()&&!Z.isStatic()).map((Z)=>{let H=Z.fetch(void 0,G);if(!G.throwOnError)H=H.catch(F);return Z.state.fetchStatus==="paused"?Promise.resolve():H}));return Promise.all(J).then(F)}fetchQuery(X){let Y=this.defaultQueryOptions(X);if(Y.retry===void 0)Y.retry=!1;let G=this.#X.build(this,Y);return G.isStaleByTime(C(Y.staleTime,G))?G.fetch(Y):Promise.resolve(G.state.data)}prefetchQuery(X){return this.fetchQuery(X).then(F).catch(F)}fetchInfiniteQuery(X){return X.behavior=RX(X.pages),this.fetchQuery(X)}prefetchInfiniteQuery(X){return this.fetchInfiniteQuery(X).then(F).catch(F)}ensureInfiniteQueryData(X){return X.behavior=RX(X.pages),this.ensureQueryData(X)}resumePausedMutations(){if(XX.isOnline())return this.#Y.resumePausedMutations();return Promise.resolve()}getQueryCache(){return this.#X}getMutationCache(){return this.#Y}getDefaultOptions(){return this.#G}setDefaultOptions(X){this.#G=X}setQueryDefaults(X,Y){this.#Z.set(v(X),{queryKey:X,defaultOptions:Y})}getQueryDefaults(X){let Y=[...this.#Z.values()],G={};return Y.forEach((J)=>{if(u(X,J.queryKey))Object.assign(G,J.defaultOptions)}),G}setMutationDefaults(X,Y){this.#J.set(v(X),{mutationKey:X,defaultOptions:Y})}getMutationDefaults(X){let Y=[...this.#J.values()],G={};return Y.forEach((J)=>{if(u(X,J.mutationKey))Object.assign(G,J.defaultOptions)}),G}defaultQueryOptions(X){if(X._defaulted)return X;let Y={...this.#G.queries,...this.getQueryDefaults(X.queryKey),...X,_defaulted:!0};if(!Y.queryHash)Y.queryHash=ZX(Y.queryKey,Y);if(Y.refetchOnReconnect===void 0)Y.refetchOnReconnect=Y.networkMode!=="always";if(Y.throwOnError===void 0)Y.throwOnError=!!Y.suspense;if(!Y.networkMode&&Y.persister)Y.networkMode="offlineFirst";if(Y.queryFn===l)Y.enabled=!1;return Y}defaultMutationOptions(X){if(X?._defaulted)return X;return{...this.#G.mutations,...X?.mutationKey&&this.getMutationDefaults(X.mutationKey),...X,_defaulted:!0}}clear(){this.#X.clear(),this.#Y.clear()}};var f=h(c(),1);var HX=h(c(),1),RY=h(IX(),1);function CY(){let X=!1;return{clearReset:()=>{X=!1},reset:()=>{X=!0},isReset:()=>{return X}}}var OY=HX.createContext(CY()),ZY=()=>HX.useContext(OY);var $Y=h(c(),1);var WY=(X,Y,G)=>{let J=G?.state.error&&typeof X.throwOnError==="function"?t(X.throwOnError,[G.state.error,G]):X.throwOnError;if(X.suspense||X.experimental_prefetchInRender||J){if(!Y.isReset())X.retryOnMount=!1}},HY=(X)=>{$Y.useEffect(()=>{X.clearReset()},[X])},_Y=({result:X,errorResetBoundary:Y,throwOnError:G,query:J,suspense:Z})=>{return X.isError&&!Y.isReset()&&!X.isFetching&&J&&(Z&&X.data===void 0||t(G,[X.error,J]))};var FX=h(c(),1),zY=FX.createContext(!1),VY=()=>FX.useContext(zY),K2=zY.Provider;var AY=(X)=>{if(X.suspense){let G=(Z)=>Z==="static"?Z:Math.max(Z??1000,1000),J=X.staleTime;if(X.staleTime=typeof J==="function"?(...Z)=>G(J(...Z)):G(J),typeof X.gcTime==="number")X.gcTime=Math.max(X.gcTime,1000)}},NY=(X,Y)=>X.isLoading&&X.isFetching&&!Y,LY=(X,Y)=>X?.suspense&&Y.isPending,qX=(X,Y,G)=>Y.fetchOptimistic(X).catch(()=>{G.clearReset()});function UY(X,Y,G){if(typeof X!=="object"||Array.isArray(X))throw Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');let J=VY(),Z=ZY(),H=GX(G),_=H.defaultQueryOptions(X);H.getDefaultOptions().queries?._experimental_beforeQuery?.(_);let W=H.getQueryCache().get(_.queryHash);if(!_.queryFn)console.error(`[${_.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`);_._optimisticResults=J?"isRestoring":"optimistic",AY(_),WY(_,Z,W),HY(Z);let A=!H.getQueryCache().get(_.queryHash),[U]=f.useState(()=>new Y(H,_)),z=U.getOptimisticResult(_),E=!J&&X.subscribed!==!1;if(f.useSyncExternalStore(f.useCallback((N)=>{let K=E?U.subscribe(B.batchCalls(N)):F;return U.updateResult(),K},[U,E]),()=>U.getCurrentResult(),()=>U.getCurrentResult()),f.useEffect(()=>{U.setOptions(_)},[_,U]),LY(_,z))throw qX(_,U,Z);if(_Y({result:z,errorResetBoundary:Z,throwOnError:_.throwOnError,query:W,suspense:_.suspense}))throw z.error;if(H.getDefaultOptions().queries?._experimental_afterQuery?.(_,z),_.experimental_prefetchInRender&&!x&&NY(z,J))(A?qX(_,U,Z):W?.promise)?.catch(F).finally(()=>{U.updateResult()});return!_.notifyOnChangeProps?U.trackResult(z):z}function qY(X,Y){return UY(X,SX,Y)}var m=h(c(),1);function vY(X,Y){let G=GX(Y),[J]=m.useState(()=>new OX(G,X));m.useEffect(()=>{J.setOptions(X)},[J,X]);let Z=m.useSyncExternalStore(m.useCallback((_)=>J.subscribe(B.batchCalls(_)),[J]),()=>J.getCurrentResult(),()=>J.getCurrentResult()),H=m.useCallback((_,W)=>{J.mutate(_,W).catch(F)},[J]);if(Z.error&&t(J.options.throwOnError,[Z.error]))throw Z.error;return{...Z,mutate:H,mutateAsync:Z.mutate}}var p2={config:{all:["config"],detail:()=>["config","detail"]},providers:{all:["providers"],list:()=>["providers","list"],detail:(X)=>["providers","detail",X]},models:{all:["models"],list:(X)=>["models","list",X],available:()=>["models","available"]},skills:{all:["skills"],list:()=>["skills","list"],detail:(X)=>["skills","detail",X]},tasks:{all:["tasks"],list:(X)=>["tasks","list",X],detail:(X)=>["tasks","detail",X]},history:{all:["history"],list:()=>["history","list"],detail:(X)=>["history","detail",X]},knowledge:{all:["knowledge"],memories:()=>["knowledge","memories"],skills:()=>["knowledge","skills"]},agents:{all:["agents"],list:()=>["agents","list"],detail:(X)=>["agents","detail",X]},mcp:{all:["mcp"],config:()=>["mcp","config"]},errors:{all:["errors"],list:()=>["errors","list"],stats:()=>["errors","stats"]}};
7
- export{MY as K,IX as L,GX as M,FY as N,qY as O,vY as P,p2 as Q};
@@ -1,2 +0,0 @@
1
- import{lq as r}from"./chunk-1p9xzvpt.js";import{mq as Ow}from"./chunk-hra0748z.js";import{pq as iw,qq as B,tq as uw}from"./chunk-dcs1r9as.js";var f=B((PS,m)=>{function M(S,w){if(typeof w==="boolean")w={forever:w};if(this._originalTimeouts=JSON.parse(JSON.stringify(S)),this._timeouts=S,this._options=w||{},this._maxRetryTime=w&&w.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}m.exports=M;M.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};M.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);this._timeouts=[],this._cachedTimeouts=null};M.prototype.retry=function(S){if(this._timeout)clearTimeout(this._timeout);if(!S)return!1;var w=new Date().getTime();if(S&&w-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(S);var N=this._timeouts.shift();if(N===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),N=this._timeouts.shift();else return!1;var J=this,x=setTimeout(function(){if(J._attempts++,J._operationTimeoutCb){if(J._timeout=setTimeout(function(){J._operationTimeoutCb(J._attempts)},J._operationTimeout),J._options.unref)J._timeout.unref()}J._fn(J._attempts)},N);if(this._options.unref)x.unref();return!0};M.prototype.attempt=function(S,w){if(this._fn=S,w){if(w.timeout)this._operationTimeout=w.timeout;if(w.cb)this._operationTimeoutCb=w.cb}var N=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){N._operationTimeoutCb()},N._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};M.prototype.try=function(S){console.log("Using RetryOperation.try() is deprecated"),this.attempt(S)};M.prototype.start=function(S){console.log("Using RetryOperation.start() is deprecated"),this.attempt(S)};M.prototype.start=M.prototype.try;M.prototype.errors=function(){return this._errors};M.prototype.attempts=function(){return this._attempts};M.prototype.mainError=function(){if(this._errors.length===0)return null;var S={},w=null,N=0;for(var J=0;J<this._errors.length;J++){var x=this._errors[J],h=x.message,E=(S[h]||0)+1;if(S[h]=E,E>=N)w=x,N=E}return w}});var n=B((Yw)=>{var Xw=f();Yw.operation=function(S){var w=Yw.timeouts(S);return new Xw(w,{forever:S&&S.forever,unref:S&&S.unref,maxRetryTime:S&&S.maxRetryTime})};Yw.timeouts=function(S){if(S instanceof Array)return[].concat(S);var w={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var N in S)w[N]=S[N];if(w.minTimeout>w.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var J=[];for(var x=0;x<w.retries;x++)J.push(this.createTimeout(x,w));if(S&&S.forever&&!J.length)J.push(this.createTimeout(x,w));return J.sort(function(h,E){return h-E}),J};Yw.createTimeout=function(S,w){var N=w.randomize?Math.random()+1:1,J=Math.round(N*w.minTimeout*Math.pow(w.factor,S));return J=Math.min(J,w.maxTimeout),J};Yw.wrap=function(S,w,N){if(w instanceof Array)N=w,w=null;if(!N){N=[];for(var J in S)if(typeof S[J]==="function")N.push(J)}for(var x=0;x<N.length;x++){var h=N[x],E=S[h];S[h]=function(V){var $=Yw.operation(w),z=Array.prototype.slice.call(arguments,1),xw=z.pop();z.push(function(v){if($.retry(v))return;if(v)arguments[0]=$.mainError();xw.apply(this,arguments)}),$.attempt(function(){V.apply(S,z)})}.bind(S,E),S[h].options=w}}});var a=B((_w,u)=>{var c=Symbol();function Uw(S,w,N){let J=w[c];if(J)return w.stat(S,(h,E)=>{if(h)return N(h);N(null,E.mtime,J)});let x=new Date(Math.ceil(Date.now()/1000)*1000+5);w.utimes(S,x,x,(h)=>{if(h)return N(h);w.stat(S,(E,F)=>{if(E)return N(E);let V=F.mtime.getTime()%1000===0?"s":"ms";Object.defineProperty(w,c,{value:V}),N(null,F.mtime,V)})})}function qw(S){let w=Date.now();if(S==="s")w=Math.ceil(w/1000)*1000;return new Date(w)}_w.probe=Uw;_w.getMtime=qw});var i=B((vw,Q)=>{var Cw=uw("path"),P=r(),Pw=n(),Rw=Ow(),p=a(),T={};function K(S,w){return w.lockfilePath||`${S}.lock`}function R(S,w,N){if(!w.realpath)return N(null,Cw.resolve(S));w.fs.realpath(S,N)}function C(S,w,N){let J=K(S,w);w.fs.mkdir(J,(x)=>{if(!x)return p.probe(J,w.fs,(h,E,F)=>{if(h)return w.fs.rmdir(J,()=>{}),N(h);N(null,E,F)});if(x.code!=="EEXIST")return N(x);if(w.stale<=0)return N(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:S}));w.fs.stat(J,(h,E)=>{if(h){if(h.code==="ENOENT")return C(S,{...w,stale:0},N);return N(h)}if(!t(E,w))return N(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:S}));s(S,w,(F)=>{if(F)return N(F);C(S,{...w,stale:0},N)})})})}function t(S,w){return S.mtime.getTime()<Date.now()-w.stale}function s(S,w,N){w.fs.rmdir(K(S,w),(J)=>{if(J&&J.code!=="ENOENT")return N(J);N()})}function Z(S,w){let N=T[S];if(N.updateTimeout)return;if(N.updateDelay=N.updateDelay||w.update,N.updateTimeout=setTimeout(()=>{N.updateTimeout=null,w.fs.stat(N.lockfilePath,(J,x)=>{let h=N.lastUpdate+w.stale<Date.now();if(J){if(J.code==="ENOENT"||h)return O(S,N,Object.assign(J,{code:"ECOMPROMISED"}));return N.updateDelay=1000,Z(S,w)}if(N.mtime.getTime()!==x.mtime.getTime())return O(S,N,Object.assign(Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let F=p.getMtime(N.mtimePrecision);w.fs.utimes(N.lockfilePath,F,F,(V)=>{let $=N.lastUpdate+w.stale<Date.now();if(N.released)return;if(V){if(V.code==="ENOENT"||$)return O(S,N,Object.assign(V,{code:"ECOMPROMISED"}));return N.updateDelay=1000,Z(S,w)}N.mtime=F,N.lastUpdate=Date.now(),N.updateDelay=null,Z(S,w)})})},N.updateDelay),N.updateTimeout.unref)N.updateTimeout.unref()}function O(S,w,N){if(w.released=!0,w.updateTimeout)clearTimeout(w.updateTimeout);if(T[S]===w)delete T[S];w.options.onCompromised(N)}function jw(S,w,N){w={stale:1e4,update:null,realpath:!0,retries:0,fs:P,onCompromised:(J)=>{throw J},...w},w.retries=w.retries||0,w.retries=typeof w.retries==="number"?{retries:w.retries}:w.retries,w.stale=Math.max(w.stale||0,2000),w.update=w.update==null?w.stale/2:w.update||0,w.update=Math.max(Math.min(w.update,w.stale/2),1000),R(S,w,(J,x)=>{if(J)return N(J);let h=Pw.operation(w.retries);h.attempt(()=>{C(x,w,(E,F,V)=>{if(h.retry(E))return;if(E)return N(h.mainError());let $=T[x]={lockfilePath:K(x,w),mtime:F,mtimePrecision:V,options:w,lastUpdate:Date.now()};Z(x,w),N(null,(z)=>{if($.released)return z&&z(Object.assign(Error("Lock is already released"),{code:"ERELEASED"}));l(x,{...w,realpath:!1},z)})})})})}function l(S,w,N){w={fs:P,realpath:!0,...w},R(S,w,(J,x)=>{if(J)return N(J);let h=T[x];if(!h)return N(Object.assign(Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));h.updateTimeout&&clearTimeout(h.updateTimeout),h.released=!0,delete T[x],s(x,w,N)})}function Lw(S,w,N){w={stale:1e4,realpath:!0,fs:P,...w},w.stale=Math.max(w.stale||0,2000),R(S,w,(J,x)=>{if(J)return N(J);w.fs.stat(K(x,w),(h,E)=>{if(h)return h.code==="ENOENT"?N(null,!1):N(h);return N(null,!t(E,w))})})}function yw(){return T}Rw(()=>{for(let S in T){let w=T[S].options;try{w.fs.rmdirSync(K(S,w))}catch(N){}}});vw.lock=jw;vw.unlock=l;vw.check=Lw;vw.getLocks=yw});var o=B((jS,e)=>{var fw=r();function kw(S){let w=["mkdir","realpath","stat","rmdir","utimes"],N={...S};return w.forEach((J)=>{N[J]=(...x)=>{let h=x.pop(),E;try{E=S[`${J}Sync`](...x)}catch(F){return h(F)}h(null,E)}}),N}function nw(S){return(...w)=>new Promise((N,J)=>{w.push((x,h)=>{if(x)J(x);else N(h)}),S(...w)})}function cw(S){return(...w)=>{let N,J;if(w.push((x,h)=>{N=x,J=h}),S(...w),N)throw N;return J}}function aw(S){if(S={...S},S.fs=kw(S.fs||fw),typeof S.retries==="number"&&S.retries>0||S.retries&&typeof S.retries.retries==="number"&&S.retries.retries>0)throw Object.assign(Error("Cannot use retries with the sync api"),{code:"ESYNC"});return S}e.exports={toPromise:nw,toSync:cw,toSyncOptions:aw}});var Sw=B((LS,W)=>{var G=i(),{toPromise:H,toSync:I,toSyncOptions:j}=o();async function ww(S,w){let N=await H(G.lock)(S,w);return H(N)}function rw(S,w){let N=I(G.lock)(S,j(w));return I(N)}function pw(S,w){return H(G.unlock)(S,w)}function tw(S,w){return I(G.unlock)(S,j(w))}function sw(S,w){return H(G.check)(S,w)}function lw(S,w){return I(G.check)(S,j(w))}W.exports=ww;W.exports.lock=ww;W.exports.unlock=pw;W.exports.lockSync=rw;W.exports.unlockSync=tw;W.exports.check=sw;W.exports.checkSync=lw});class d{#w=null;read(){return Promise.resolve(this.#w)}write(S){return this.#w=S,Promise.resolve()}}class g{#w=null;read(){return this.#w||null}write(S){this.#w=S}}function hw(S,w){if(S===void 0)throw Error("lowdb: missing adapter");if(w===void 0)throw Error("lowdb: missing default data")}class X{adapter;data;constructor(S,w){hw(S,w),this.adapter=S,this.data=w}async read(){let S=await this.adapter.read();if(S)this.data=S}async write(){if(this.data)await this.adapter.write(this.data)}async update(S){S(this.data),await this.write()}}import{readFileSync as Bw,renameSync as Gw,writeFileSync as Kw}from"node:fs";import{readFile as Qw}from"node:fs/promises";import q from"node:path";import{rename as Ew,writeFile as Fw}from"node:fs/promises";import{basename as Mw,dirname as Vw,join as Tw}from"node:path";import{fileURLToPath as Ww}from"node:url";function $w(S){let w=S instanceof URL?Ww(S):S.toString();return Tw(Vw(w),`.${Mw(w)}.tmp`)}async function zw(S,w,N){for(let J=0;J<w;J++)try{return await S()}catch(x){if(J<w-1)await new Promise((h)=>setTimeout(h,N));else throw x}}class U{#w;#S;#N=!1;#x=null;#h=null;#E=null;#J=null;#F(S){return this.#J=S,this.#E||=new Promise((w,N)=>{this.#h=[w,N]}),new Promise((w,N)=>{this.#E?.then(w).catch(N)})}async#M(S){this.#N=!0;try{await Fw(this.#S,S,"utf-8"),await zw(async()=>{await Ew(this.#S,this.#w)},10,100),this.#x?.[0]()}catch(w){if(w instanceof Error)this.#x?.[1](w);throw w}finally{if(this.#N=!1,this.#x=this.#h,this.#h=this.#E=null,this.#J!==null){let w=this.#J;this.#J=null,await this.write(w)}}}constructor(S){this.#w=S,this.#S=$w(S)}async write(S){return this.#N?this.#F(S):this.#M(S)}}class _{#w;#S;constructor(S){this.#w=S,this.#S=new U(S)}async read(){let S;try{S=await Qw(this.#w,"utf-8")}catch(w){if(w.code==="ENOENT")return null;throw w}return S}write(S){return this.#S.write(S)}}class A{#w;#S;constructor(S){this.#S=S;let w=S.toString();this.#w=q.join(q.dirname(w),`.${q.basename(w)}.tmp`)}read(){let S;try{S=Bw(this.#S,"utf-8")}catch(w){if(w.code==="ENOENT")return null;throw w}return S}write(S){Kw(this.#w,S),Gw(this.#w,this.#S)}}class D{#w;#S;#N;constructor(S,{parse:w,stringify:N}){this.#w=new _(S),this.#S=w,this.#N=N}async read(){let S=await this.#w.read();if(S===null)return null;else return this.#S(S)}write(S){return this.#w.write(this.#N(S))}}class b{#w;#S;#N;constructor(S,{parse:w,stringify:N}){this.#w=new A(S),this.#S=w,this.#N=N}read(){let S=this.#w.read();if(S===null)return null;else return this.#S(S)}write(S){this.#w.write(this.#N(S))}}class Y extends D{constructor(S){super(S,{parse:JSON.parse,stringify:(w)=>JSON.stringify(w,null,2)})}}var Jw=iw(Sw(),1);import ew from"os";import Nw from"path";import L from"fs";var y={config:{provider_id:"default",provider_type:"openai",model_id:"glm-5",providers:[{id:"default",type:"openai",apiKey:"",baseUrl:"https://api.openai.com/v1"}],compact_mode:!0}};function ow(S){return"main_model"in S&&!("providers"in S)}function wS(S){let w=[];if(S.model_provider==="openai"||S.openai_api_key||S.openai_base_url)w.push({id:"openai",type:"openai",apiKey:S.openai_api_key||"",baseUrl:S.openai_base_url||"https://api.openai.com/v1"});if(S.model_provider==="anthropic"||S.anthropic_api_key||S.anthropic_base_url)w.push({id:"anthropic",type:"anthropic",apiKey:S.anthropic_api_key||"",baseUrl:S.anthropic_base_url||"https://api.anthropic.com"});if(w.length===0)w.push({id:"default",type:"openai",apiKey:"",baseUrl:"https://api.openai.com/v1"});let N=S.model_provider==="anthropic"?"anthropic":"openai",J=w.find((x)=>x.id===N)||w[0];return{provider_id:J.id,provider_type:J.type,model_id:S.main_model,providers:w,mcp_config:S.mcp_config,stream_refresh_interval:S.stream_refresh_interval,enable_thinking:S.enable_thinking,switch_command:S.switch_command,compact_mode:S.compact_mode,permissions:S.permissions}}class SS{db;zenConfigDir;dbPath;getLockfilePath(){return`${this.dbPath}.lock`}lockOptions={stale:5000,retries:{retries:5,minTimeout:100,maxTimeout:1000}};constructor(){let S=ew.homedir();this.zenConfigDir=Nw.join(S,".zen-code");let w=Nw.join(this.zenConfigDir,"settings.json"),N=new Y(w);this.dbPath=w,this.db=new X(N,y)}async withLock(S){if(await L.promises.mkdir(this.zenConfigDir,{recursive:!0}),!L.existsSync(this.dbPath))await L.promises.writeFile(this.dbPath,JSON.stringify(y,null,2),"utf-8");let w=await Jw.default.lock(this.dbPath,{...this.lockOptions,lockfilePath:this.getLockfilePath()});try{return await S()}finally{await w()}}async initialize(){await this.withLock(async()=>{if(await this.db.read(),!this.db.data||!this.db.data.config)this.db.data=y,await this.db.write();else if(ow(this.db.data.config))console.log("Migrating legacy config to new format..."),this.db.data.config=wS(this.db.data.config),await this.db.write(),console.log("Config migration completed.");this.syncEnvFromConfig()})}async getConfig(){return this.withLock(async()=>{return await this.db.read(),this.db.data.config})}async updateConfig(S){await this.withLock(async()=>{await this.db.read(),Object.assign(this.db.data.config,S),await this.db.write(),this.syncEnvFromConfig()})}syncEnvFromConfig(){let S=this.db.data.config,w=S.providers.find((N)=>N.id===S.provider_id);if(w){if(w.type==="openai")process.env.MODEL_PROVIDER="openai",process.env.OPENAI_API_KEY=w.apiKey,process.env.OPENAI_BASE_URL=w.baseUrl;else if(w.type==="anthropic")process.env.MODEL_PROVIDER="anthropic",process.env.ANTHROPIC_API_KEY=w.apiKey,process.env.ANTHROPIC_BASE_URL=w.baseUrl;else if(w.type==="gemini"||w.type==="google")process.env.MODEL_PROVIDER="gemini",process.env.GOOGLE_API_KEY=w.apiKey,process.env.GOOGLE_BASE_URL=w.baseUrl}}getZenConfigDir(){return this.zenConfigDir}}
2
- export{X as iq,Y as jq,SS as kq};
@@ -1,91 +0,0 @@
1
- import{Bd as L,Kd as D}from"./chunk-hsev32dg.js";import{dh as z,sh as P,th as K,vh as O}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 R,tq as b}from"./chunk-dcs1r9as.js";var G={maxRetries:3,baseDelayMs:100,nonRetryablePatterns:["database disk image is malformed","database is malformed","cannot rollback","no transaction is active","database or disk is full"],isRetryableError:(H)=>{let J=H?.message?.toLowerCase()||"";for(let V of G.nonRetryablePatterns)if(J.includes(V.toLowerCase()))return!1;return J.includes("sqlite_busy")||J.includes("database is locked")||J==="sqlite_busy"||J==="database is locked"}};async function F(H,J){let V=null;for(let Z=0;Z<G.maxRetries;Z++)try{return await H()}catch($){V=$;let X=$?.message?.toLowerCase()||"";if(!G.isRetryableError($)){if(X.includes("malformed")){let j=Error(`SQLite database is corrupted: ${$.message}
2
-
3
- Context: ${J||"unknown"}
4
-
5
- Possible causes:
6
- 1. Database file was manually deleted or modified
7
- 2. Disk I/O errors during write operations
8
- 3. Concurrent access without proper locking
9
-
10
- Recovery options:
11
- - Delete the database file to start fresh (data will be lost)
12
- - Use SQLite recovery tools: sqlite3 <db> ".recover" > recover.sql
13
- - Switch to PostgreSQL/Redis for production use`);throw j.name="SQLiteCorruptError",j.cause=$,j}throw $}if(Z<G.maxRetries-1){let j=G.baseDelayMs*Math.pow(2,Z);console.warn(`SQLite lock detected${J?` (${J})`:""}, retrying in ${j}ms (attempt ${Z+1}/${G.maxRetries})`),await new Promise((U)=>setTimeout(U,j))}}throw V}var x=["source","step","parents"];function E(H){return H}var T=E(x);class N extends K{db;isSetup;constructor(H,J){super(J);this.db=new L({dialect:H}),this.isSetup=!1}static async fromConnStringAsync(H){let J;if(globalThis.Bun){console.log("LG | Using BunWorkerDialect "+H);let{BunSqliteDialect:V}=await import("./chunk-gyhxdxb4.js");J=new N(new V({url:H}))}else{console.log("LG | Using NodeWasmDialect");let{default:V}=await import("./chunk-x90r4sje.js").then((m)=>R(m.default,1)),{NodeWasmDialect:Z}=await import("./chunk-yndex7hs.js");console.log(H);let $=new Z({database:new V.Database(H)});J=new N($)}return await J.setup(),J}async setup(){if(this.isSetup)return;await D`PRAGMA busy_timeout = 5000`.execute(this.db),await D`PRAGMA journal_mode = WAL`.execute(this.db),await D`PRAGMA synchronous = NORMAL`.execute(this.db),await D`PRAGMA wal_autocheckpoint = 1000`.execute(this.db),await D`
14
- CREATE TABLE IF NOT EXISTS checkpoints (
15
- thread_id TEXT NOT NULL,
16
- checkpoint_ns TEXT NOT NULL DEFAULT '',
17
- checkpoint_id TEXT NOT NULL,
18
- parent_checkpoint_id TEXT,
19
- type TEXT,
20
- checkpoint BLOB,
21
- metadata BLOB,
22
- PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id)
23
- )`.execute(this.db),await D`
24
- CREATE TABLE IF NOT EXISTS writes (
25
- thread_id TEXT NOT NULL,
26
- checkpoint_ns TEXT NOT NULL DEFAULT '',
27
- checkpoint_id TEXT NOT NULL,
28
- task_id TEXT NOT NULL,
29
- idx INTEGER NOT NULL,
30
- channel TEXT NOT NULL,
31
- type TEXT,
32
- value BLOB,
33
- PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id, task_id, idx)
34
- )`.execute(this.db),this.isSetup=!0}async getTuple(H){await this.setup();let{thread_id:J,checkpoint_ns:V="",checkpoint_id:Z}=H.configurable??{},$=this.db.selectFrom("checkpoints").select(["thread_id","checkpoint_ns","checkpoint_id","parent_checkpoint_id","type","checkpoint","metadata",D`(
35
- SELECT json_group_array(
36
- json_object(
37
- 'task_id', pw.task_id,
38
- 'channel', pw.channel,
39
- 'type', pw.type,
40
- 'value', CAST(pw.value AS TEXT)
41
- )
42
- )
43
- FROM writes as pw
44
- WHERE pw.thread_id = checkpoints.thread_id
45
- AND pw.checkpoint_ns = checkpoints.checkpoint_ns
46
- AND pw.checkpoint_id = checkpoints.checkpoint_id
47
- )`.as("pending_writes"),D`(
48
- SELECT json_group_array(
49
- json_object(
50
- 'type', ps.type,
51
- 'value', CAST(ps.value AS TEXT)
52
- )
53
- )
54
- FROM writes as ps
55
- WHERE ps.thread_id = checkpoints.thread_id
56
- AND ps.checkpoint_ns = checkpoints.checkpoint_ns
57
- AND ps.checkpoint_id = checkpoints.parent_checkpoint_id
58
- AND ps.channel = ${z}
59
- ORDER BY ps.idx
60
- )`.as("pending_sends")]).where("thread_id","=",J).where("checkpoint_ns","=",V);if(Z)$=$.where("checkpoint_id","=",Z);else $=$.orderBy("checkpoint_id","desc").limit(1);let X=await $.executeTakeFirst();if(!X)return;let j=H;if(!Z)j={configurable:{thread_id:X.thread_id,checkpoint_ns:V,checkpoint_id:X.checkpoint_id}};if(j.configurable?.thread_id===void 0||j.configurable?.checkpoint_id===void 0)throw Error("Missing thread_id or checkpoint_id");let U=await Promise.all(JSON.parse(X.pending_writes).map(async(A)=>{return[A.task_id,A.channel,await this.serde.loadsTyped(A.type??"json",A.value??"")]})),W=await this.serde.loadsTyped(X.type??"json",new TextDecoder().decode(X.checkpoint));if(W.v<4&&X.parent_checkpoint_id!=null)await this.migratePendingSends(W,X.thread_id,X.parent_checkpoint_id);return{checkpoint:W,config:j,metadata:await this.serde.loadsTyped(X.type??"json",new TextDecoder().decode(X.metadata)),parentConfig:X.parent_checkpoint_id?{configurable:{thread_id:X.thread_id,checkpoint_ns:V,checkpoint_id:X.parent_checkpoint_id}}:void 0,pendingWrites:U}}async*list(H,J){let{limit:V,before:Z,filter:$}=J??{};await this.setup();let X=H.configurable?.thread_id,j=H.configurable?.checkpoint_ns,U=this.db.selectFrom("checkpoints").select(["thread_id","checkpoint_ns","checkpoint_id","parent_checkpoint_id","type","checkpoint","metadata",D`(
61
- SELECT json_group_array(
62
- json_object(
63
- 'task_id', pw.task_id,
64
- 'channel', pw.channel,
65
- 'type', pw.type,
66
- 'value', CAST(pw.value AS TEXT)
67
- )
68
- )
69
- FROM writes as pw
70
- WHERE pw.thread_id = checkpoints.thread_id
71
- AND pw.checkpoint_ns = checkpoints.checkpoint_ns
72
- AND pw.checkpoint_id = checkpoints.checkpoint_id
73
- )`.as("pending_writes"),D`(
74
- SELECT json_group_array(
75
- json_object(
76
- 'type', ps.type,
77
- 'value', CAST(ps.value AS TEXT)
78
- )
79
- )
80
- FROM writes as ps
81
- WHERE ps.thread_id = checkpoints.thread_id
82
- AND ps.checkpoint_ns = checkpoints.checkpoint_ns
83
- AND ps.checkpoint_id = checkpoints.parent_checkpoint_id
84
- AND ps.channel = ${z}
85
- ORDER BY ps.idx
86
- )`.as("pending_sends")]);if(X)U=U.where("thread_id","=",X);if(j!==void 0&&j!==null)U=U.where("checkpoint_ns","=",j);if(Z?.configurable?.checkpoint_id!==void 0)U=U.where("checkpoint_id","<",Z.configurable.checkpoint_id);let W=Object.fromEntries(Object.entries($??{}).filter(([B,M])=>M!==void 0&&T.includes(B)));for(let[B,M]of Object.entries(W))U=U.where(D`json_extract(CAST(metadata AS TEXT), ${D.lit("$."+B)})`,"=",D.lit(JSON.stringify(M)));if(U=U.orderBy("checkpoint_id","desc"),V)U=U.limit(parseInt(V,10));let A=await U.execute();for(let B of A){let M=await Promise.all(JSON.parse(B.pending_writes).map(async(Q)=>{return[Q.task_id,Q.channel,await this.serde.loadsTyped(Q.type??"json",Q.value??"")]})),Y=await this.serde.loadsTyped(B.type??"json",new TextDecoder().decode(B.checkpoint));if(Y.v<4&&B.parent_checkpoint_id!=null)await this.migratePendingSends(Y,B.thread_id,B.parent_checkpoint_id);yield{config:{configurable:{thread_id:B.thread_id,checkpoint_ns:B.checkpoint_ns,checkpoint_id:B.checkpoint_id}},checkpoint:Y,metadata:await this.serde.loadsTyped(B.type??"json",new TextDecoder().decode(B.metadata)),parentConfig:B.parent_checkpoint_id?{configurable:{thread_id:B.thread_id,checkpoint_ns:B.checkpoint_ns,checkpoint_id:B.parent_checkpoint_id}}:void 0,pendingWrites:M}}}async put(H,J,V){if(await this.setup(),!H.configurable)throw Error("Empty configuration supplied.");let Z=H.configurable?.thread_id,$=H.configurable?.checkpoint_ns??"",X=H.configurable?.checkpoint_id;if(!Z)throw Error('Missing "thread_id" field in passed "config.configurable".');let j=P(J),[[U,W],[A,B]]=await Promise.all([this.serde.dumpsTyped(j),this.serde.dumpsTyped(V)]);if(U!==A)throw Error("Failed to serialized checkpoint and metadata to the same type.");return await F(async()=>{await this.db.insertInto("checkpoints").values({thread_id:Z,checkpoint_ns:$,checkpoint_id:J.id,parent_checkpoint_id:X??null,type:U,checkpoint:new Uint8Array(Buffer.from(W)),metadata:new Uint8Array(Buffer.from(B))}).onConflict((M)=>M.columns(["thread_id","checkpoint_ns","checkpoint_id"]).doUpdateSet({parent_checkpoint_id:X??null,type:U,checkpoint:new Uint8Array(Buffer.from(W)),metadata:new Uint8Array(Buffer.from(B))})).execute()},`put(${Z}/${J.id})`),{configurable:{thread_id:Z,checkpoint_ns:$,checkpoint_id:J.id}}}async putWrites(H,J,V){if(await this.setup(),!H.configurable)throw Error("Empty configuration supplied.");if(!H.configurable?.thread_id)throw Error("Missing thread_id field in config.configurable.");if(!H.configurable?.checkpoint_id)throw Error("Missing checkpoint_id field in config.configurable.");let Z=await Promise.all(J.map(async(j,U)=>{let[W,A]=await this.serde.dumpsTyped(j[1]);return{thread_id:H.configurable.thread_id,checkpoint_ns:H.configurable.checkpoint_ns??"",checkpoint_id:H.configurable.checkpoint_id,task_id:V,idx:U,channel:j[0],type:W,value:new Uint8Array(Buffer.from(A))}}));if(Z.length===0)return;let $=H.configurable.thread_id,X=H.configurable.checkpoint_id;await F(async()=>{await this.db.transaction().execute(async(j)=>{await j.deleteFrom("writes").where("thread_id","=",$).where("checkpoint_ns","=",Z[0].checkpoint_ns).where("checkpoint_id","=",X).where("task_id","=",V).execute();for(let U of Z)await j.insertInto("writes").values(U).execute()})},`putWrites(${$}/${X}/${V})`)}async deleteThread(H){await F(async()=>{await this.db.transaction().execute(async(J)=>{await J.deleteFrom("checkpoints").where("thread_id","=",H).execute(),await J.deleteFrom("writes").where("thread_id","=",H).execute()})},`deleteThread(${H})`)}async migratePendingSends(H,J,V){let Z=await this.db.selectFrom("writes as ps").select(["ps.checkpoint_id",D`json_group_array(
87
- json_object(
88
- 'type', ps.type,
89
- 'value', CAST(ps.value AS TEXT)
90
- )
91
- )`.as("pending_sends")]).where("ps.thread_id","=",J).where("ps.checkpoint_id","=",V).where("ps.channel","=",z).orderBy("ps.idx").executeTakeFirst();if(!Z)return;let $=H;$.channel_values??={},$.channel_values[z]=await Promise.all(JSON.parse(Z.pending_sends).map(({type:X,value:j})=>this.serde.loadsTyped(X,j))),$.channel_versions[z]=Object.keys(H.channel_versions).length>0?O(...Object.values(H.channel_versions)):this.getNextVersion(void 0)}}export{N as SqliteSaver};
@@ -1,298 +0,0 @@
1
- import{gf as f,if as g}from"./chunk-wabmqprd.js";import{qf as T}from"./chunk-e3tyc24s.js";import{ng as b,pg as w}from"./chunk-p0vzbr7s.js";import{Vh as d}from"./chunk-dcwnpdtk.js";import{ri as s}from"./chunk-cbjnwrt7.js";import{tq as o}from"./chunk-dcs1r9as.js";var A=s.object({content:s.string().min(1),status:s.enum(["pending","in_progress","completed"]),id:s.string()}),z=s.object({todos:s.array(A).describe("The updated todo list")}),u=d(async()=>{return"todo saved successfully"},{name:"todo_write",description:`Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
2
- It also helps the user understand the progress of the task and overall progress of their requests.
3
- ## When to Use This Tool
4
- Use this tool proactively in these scenarios:
5
-
6
- 1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
7
- 2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
8
- 3. User explicitly requests todo list - When the user directly asks you to use the todo list
9
- 4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
10
- 5. After receiving new instructions - Immediately capture user requirements as todos
11
- 6. When you start working on a task - Mark it as in_progress BEFORE beginning work. Ideally you should only have one todo as in_progress at a time
12
- 7. After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
13
-
14
- ## When NOT to Use This Tool
15
-
16
- Skip using this tool when:
17
- 1. There is only a single, straightforward task
18
- 2. The task is trivial and tracking it provides no organizational benefit
19
- 3. The task can be completed in less than 3 trivial steps
20
- 4. The task is purely conversational or informational
21
-
22
- NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
23
-
24
- ## Examples of When to Use the Todo List
25
-
26
- <example>
27
- User: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done!
28
- Assistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.
29
- *Creates todo list with the following items:*
30
- 1. Create dark mode toggle component in Settings page
31
- 2. Add dark mode state management (context/store)
32
- 3. Implement CSS-in-JS styles for dark theme
33
- 4. Update existing components to support theme switching
34
- 5. Run tests and build process, addressing any failures or errors that occur
35
- *Begins working on the first task*
36
-
37
- <reasoning>
38
- The assistant used the todo list because:
39
- 1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes
40
- 2. The user explicitly requested tests and build be run afterward
41
- 3. The assistant inferred that tests and build need to pass by adding "Ensure tests and build succeed" as the final task
42
- </reasoning>
43
- </example>
44
-
45
- <example>
46
- User: Help me rename the function getCwd to getCurrentWorkingDirectory across my project
47
- Assistant: Let me first search through your codebase to find all occurrences of 'getCwd'.
48
- *Uses grep or search tools to locate all instances of getCwd in the codebase*
49
- Assistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.
50
- *Creates todo list with specific items for each file that needs updating*
51
-
52
- <reasoning>
53
- The assistant used the todo list because:
54
- 1. First, the assistant searched to understand the scope of the task
55
- 2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps
56
- 3. The todo list helps ensure every instance is tracked and updated systematically
57
- 4. This approach prevents missing any occurrences and maintains code consistency
58
- </reasoning>
59
- </example>
60
-
61
-
62
- <example>
63
- User: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow.
64
- Assistant: I'll help implement these features. First, let's add all the features to the todo list.
65
- *Creates a todo list breaking down each feature into specific tasks based on the project architecture*
66
- Assistant: Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system.
67
-
68
- <reasoning>
69
- The assistant used the todo list because:
70
- 1. The user provided multiple complex features to implement in a comma separated list
71
- 2. The todo list helps organize these large features into manageable tasks
72
- 3. This approach allows for tracking progress across the entire implementation
73
- </reasoning>
74
- </example>
75
-
76
- <example>
77
- User: Can you help optimize my React application? It's rendering slowly and has performance issues.</user>
78
- Assistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks.
79
- *Reviews component structure, render patterns, state management, and data fetching*
80
- Assistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts.
81
- *Creates todo list with items like: 1) Implement memoization for expensive calculations in ProductList, 2) Add virtualization for long lists in Dashboard, 3) Optimize image loading in Gallery component, 4) Fix state update loops in ShoppingCart, 5) Review bundle size and implement code splitting*
82
- Let's start by implementing memoization for the expensive calculations in your ProductList component.</assistant>
83
-
84
- <reasoning>
85
- The assistant used the todo list because:
86
- 1. First, the assistant examined the codebase to identify specific performance issues
87
- 2. Based on this analysis, it identified multiple optimization opportunities
88
- 3. Performance optimization is a non-trivial task requiring multiple steps
89
- 4. The todo list helps methodically track improvements across different components
90
- 5. This systematic approach ensures all performance bottlenecks are addressed
91
- </reasoning>
92
- </example>
93
-
94
- ## Examples of When NOT to Use the Todo List
95
-
96
- <example>
97
- User: How do I print 'Hello World' in Python?
98
- Assistant: In Python, you can print "Hello World" with this simple code:
99
-
100
- python
101
- print("Hello World")
102
-
103
- This will output the text "Hello World" to the console when executed.</assistant>
104
-
105
- <reasoning>
106
- The assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request.
107
- </reasoning>
108
- </example>
109
-
110
- <example>
111
- User: What does the git status command do?
112
- Assistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits.
113
-
114
- <reasoning>
115
- The assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks.
116
- </reasoning>
117
- </example>
118
-
119
- <example>
120
- User: Can you add a comment to the calculateTotal function to explain what it does?
121
- Assistant: Sure, let me add a comment to the calculateTotal function to explain what it does.
122
- * Uses the Edit tool to add a comment to the calculateTotal function *
123
-
124
- <reasoning>
125
- The assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization.
126
- </reasoning>
127
- </example>
128
-
129
- <example>
130
- User: Run npm install for me and tell me what happens.
131
- Assistant: I'll run the npm install command for you.
132
-
133
- *Executes: npm install*
134
-
135
- The command completed successfully. Here's the output:
136
- [Output of npm install command]
137
-
138
- All dependencies have been installed according to your package.json file.
139
-
140
- <reasoning>
141
- The assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task.
142
- </reasoning>
143
- </example>
144
-
145
- ## Task States and Management
146
-
147
- 1. **Task States**: Use these states to track progress:
148
- - pending: Task not yet started
149
- - in_progress: Currently working on (limit to ONE task at a time)
150
- - completed: Task finished successfully
151
-
152
- 2. **Task Management**:
153
- - Update task status in real-time as you work
154
- - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
155
- - Only have ONE task in_progress at any time
156
- - Complete current tasks before starting new ones
157
- - Remove tasks that are no longer relevant from the list entirely
158
-
159
- 3. **Task Completion Requirements**:
160
- - ONLY mark a task as completed when you have FULLY accomplished it
161
- - If you encounter errors, blockers, or cannot finish, keep the task as in_progress
162
- - When blocked, create a new task describing what needs to be resolved
163
- - Never mark a task as completed if:
164
- - Tests are failing
165
- - Implementation is partial
166
- - You encountered unresolved errors
167
- - You couldn't find necessary files or dependencies
168
-
169
- 4. **Task Breakdown**:
170
- - Create specific, actionable items
171
- - Break complex tasks into smaller, manageable steps
172
- - Use clear, descriptive task names
173
-
174
- When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
175
- `,schema:z});var C=s.object({label:s.string().min(1).max(50).describe("选项显示文本,简洁明了(1-50 字符)")}),W=s.object({description:s.string().min(1).describe("向用户提出的问题,清晰具体,包含必要的上下文"),type:s.enum(["single_select","multi_select"]).describe("选择类型:single_select(单选)或 multi_select(多选)"),options:s.array(C).min(2).max(6).describe("选项列表,至少 2 个,最多 6 个"),allow_custom_input:s.boolean().default(!0).describe("是否允许用户输入自定义文本,默认 true"),placeholder:s.string().optional().describe("自定义输入框的占位符文本")}),h=d(()=>{},{name:"ask_user_questions",description:"Ask the user a question with selectable options",schema:W});var q=[h,u];async function _(e,t){await e.addTool({id:t.name,name:t.name,description:t.description});let r={id:t.name,name:t.name,description:t.description,paramsSchema:t.schema,execute:async(l)=>{let n=await t.invoke(l);if(n&&typeof n==="object"&&"content"in n)return n.content;return n}};e.tools.registerImplementation(r)}async function p(e){return await Promise.all(q.map((t)=>_(e,t)))}async function y(e){let t={id:"filesystem",name:"filesystem",description:"File and directory operations (read, write, search, glob)",execute:async()=>{return new f}};await e.addMiddleware(t),e.middlewares.registerImplementation(t);let r={id:"terminal",name:"terminal",description:"Terminal command execution (Bash/CMD, background processes)",execute:async()=>{return new g}};await e.addMiddleware(r),e.middlewares.registerImplementation(r);let l={id:"subagents",name:"subagents",description:"Task delegation to specialized agents",execute:async()=>{let{createSubAgentsMiddleware:a}=await import("./chunk-178yjjsx.js");return await a(e)}};await e.addMiddleware(l),e.middlewares.registerImplementation(l);let n={id:"memories",name:"memories",description:"Knowledge persistence",execute:async(a)=>{a.projectMemoriesDir=a.projectMemoriesDir||"./.claude/memories";let{MemoriesMiddleware:i}=await import("./chunk-c7y5efa0.js");return new i(a)}};await e.addMiddleware(n),e.middlewares.registerImplementation(n);let c={id:"skills",name:"skills",description:"Progressive skills disclosure",execute:async(a)=>{if(a.projectSkillsDir=a.projectSkillsDir||"./.claude/skills",!a.skillsDir){let U=await import("os"),I=await import("path");a.skillsDir=I.join(U.homedir(),".claude","skills")}let{SkillsMiddleware:i}=await import("./chunk-0sxrk9sx.js");return new i(a)}};await e.addMiddleware(c),e.middlewares.registerImplementation(c);let m={id:"agents_md",name:"agents_md",description:"Inject agent documentation",execute:async(a)=>{let{AgentsMdMiddleware:i}=await import("./chunk-0sxrk9sx.js");return new i({projectRoot:a?.projectRoot})}};await e.addMiddleware(m),e.middlewares.registerImplementation(m)}var k=`# 架构师 - 任务派发协调者
176
-
177
- 你是一位**任务派发架构师**,核心职责是将用户需求分析并拆解为子任务,然后委派给合适的子 agent 执行。
178
-
179
- ## 核心职责
180
-
181
- **你的唯一任务**:
182
- 1. 理解用户需求
183
- 2. 拆解为可执行的子任务
184
- 3. 委派给合适的子 agent
185
- 4. 跟踪和汇总结果
186
-
187
- **不要做的事**:
188
- - ❌ 不要自己编写代码
189
- - ❌ 不要自己读取文件或搜索代码
190
- - ❌ 不要自己执行终端命令
191
- - ❌ 不要做具体的架构分析或设计文档
192
-
193
- ## 工作流程
194
-
195
- ### 步骤 1:需求分析
196
-
197
- 当收到用户请求时,快速判断:
198
-
199
- 1. **任务类型**:
200
- - 代码实现/修改 → 委派给 \`agents/default\`
201
- - 任务规划/协调 → 委派给 \`agents/manager\`
202
- - 复杂任务 → 先由 \`agents/manager\` 规划,再由 \`agents/default\` 执行
203
-
204
- 2. **任务规模**:
205
- - 单一任务 → 直接委派
206
- - 多任务 → 拆分后分别委派
207
-
208
- ### 步骤 2:任务拆解
209
-
210
- 使用 \`task\` 工具委派任务:
211
-
212
- \`\`\`typescript
213
- // 示例:委派代码实现任务
214
- {
215
- subagent_id: "agents/default",
216
- task_description: "实现用户认证功能,包括登录、注册、登出三个接口",
217
- data_transfer: {
218
- requirements: "使用 JWT 认证,密码需要加密存储",
219
- constraints: "使用现有的数据库连接池"
220
- }
221
- }
222
- \`\`\`
223
-
224
- ### 步骤 3:结果汇总
225
-
226
- 子 agent 完成后:
227
- 1. 检查执行结果
228
- 2. 如果有多个子任务,协调依赖关系
229
- 3. 向用户汇报整体进度和结果
230
-
231
- ## 委派策略
232
-
233
- ### 简单任务
234
-
235
- 用户请求单一功能时,直接委派:
236
-
237
- > 用户:添加一个日志工具函数
238
-
239
- → 委派给 \`agents/default\`,任务描述清晰完整
240
-
241
- ### 复杂任务
242
-
243
- 用户请求多功能时,拆分后委派:
244
-
245
- > 用户:重构用户模块并添加测试
246
-
247
- → 拆分为:
248
- 1. 委派 \`agents/default\`:重构用户模块代码
249
- 2. 等第一步完成后,委派 \`agents/default\`:为用户模块编写测试
250
-
251
- ### 规划任务
252
-
253
- 用户需要方案设计时:
254
-
255
- > 用户:设计一个新的权限系统
256
-
257
- → 委派 \`agents/manager\` 进行任务规划,然后按规划执行
258
-
259
- ## 输出格式
260
-
261
- ### 委派时
262
-
263
- \`\`\`markdown
264
- ## 任务分析
265
-
266
- **用户需求**:{用户原始请求}
267
-
268
- **任务拆解**:
269
- 1. 任务 A → 委派给 agents/default
270
- 2. 任务 B → 委派给 agents/manager
271
-
272
- **开始执行**...
273
- \`\`\`
274
-
275
- ### 汇报时
276
-
277
- \`\`\`markdown
278
- ## 执行结果
279
-
280
- **已完成**:
281
- - ✅ 任务 A:{简要结果}
282
- - ✅ 任务 B:{简要结果}
283
-
284
- **总结**:{整体结果摘要}
285
- \`\`\`
286
-
287
- ## 重要约束
288
-
289
- 1. **立即委派**:收到任务后,不要犹豫,立即分析并委派
290
- 2. **清晰描述**:给子 agent 的任务描述要完整、清晰
291
- 3. **传递上下文**:使用 \`data_transfer\` 传递必要的背景信息
292
- 4. **不要插手**:相信子 agent 的能力,不要自己动手做具体工作
293
- 5. **保持简洁**:你的输出应该简短,重点是协调和汇总
294
-
295
- ---
296
-
297
- **记住**:你是协调者,不是执行者。快速分析需求,立即委派任务,高效汇总结果。`;async function v(){let e=new w,t=new b(e);return await t.addModel({id:"glm-4.7",model_name:"glm-4.7",model_provider:process.env.MODEL_PROVIDER||"openai",stream_usage:!0,enable_thinking:!0,temperature:0.7,max_tokens:4096,top_p:1,frequency_penalty:0,presence_penalty:0}),await t.addPrompt({id:"prompts/default",name:"default",content:T}),await t.addPrompt({id:"prompts/manager",name:"manager",content:k}),await p(t),await y(t),await t.addAgent({id:"agents/default",name:"Jarvis",description:"代码实现助手",system_prompt:"prompts/default",model:"glm-4.7",tools:{ask_user_questions:!0,todo_write:!0},middleware:{filesystem:!0,terminal:!0,agents_md:!0,skills:!0,memories:!0,subagents:!0}}),await t.addAgent({id:"agents/manager",name:"Manager",description:"任务管理员",system_prompt:"prompts/manager",model:"glm-4.7",tools:{ask_user_questions:!0,todo_write:!0},middleware:{filesystem:!0,terminal:!0,agents_md:!0,skills:!0,memories:!0,subagents:!0}}),t}var x;try{x=await v()}catch(e){throw console.error("Failed to load agent package:",e),Error(`Failed to initialize agent package: ${e instanceof Error?e.message:String(e)}`)}var te=x;
298
- export{z as We,te as Xe};
@@ -1,2 +0,0 @@
1
- import{jf as B,of as D}from"./chunk-738m8242.js";import{Fg as q,Gg as x}from"./chunk-p0vzbr7s.js";async function Q(z){let E=await q(z);return new x({agents:E,stateSchema:B,async createAgent(G,H,J){return await D(H.subagent_id,z,J,{},{parent_id:G})}})}
2
- export{Q as Se};
@@ -1 +0,0 @@
1
- import"./chunk-dcs1r9as.js";var V=((f)=>{return f.NETWORK_ERROR="NETWORK_ERROR",f.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",f.INTERNAL_ERROR="INTERNAL_ERROR",f.THREAD_NOT_FOUND="THREAD_NOT_FOUND",f.THREAD_BUSY="THREAD_BUSY",f.RUN_NOT_FOUND="RUN_NOT_FOUND",f.GRAPH_NOT_FOUND="GRAPH_NOT_FOUND",f.INVALID_REQUEST="INVALID_REQUEST",f})(V||{});class N extends Error{constructor(f,w,x){super(w);this.code=f,this.statusCode=x,this.name="RemoteApiError"}}async function O(f,w,x){try{let z=f;if(x?.query){let W=new URLSearchParams;Object.entries(x.query).forEach(([Z,_])=>{W.append(Z,String(_))}),z+=`?${W.toString()}`}let Q=await fetch(z,{method:w,headers:{"Content-Type":"application/json"},body:x?.body?JSON.stringify(x.body):void 0}),H=await Q.json();if(!Q.ok||!H.success)throw new N(H.error?.code||V.INTERNAL_ERROR,H.error?.message||"Unknown error",Q.status);return H}catch(z){if(z instanceof N)throw z;throw new N(V.NETWORK_ERROR,`Network error: ${z instanceof Error?z.message:"Unknown error"}`)}}async function J(f,w){return O(f,"GET",{query:w})}async function F(f,w,x){return O(f,"POST",{body:w,query:x})}async function Y(f,w,x){return O(f,"PUT",{body:w,query:x})}async function $(f,w){return O(f,"DELETE",{query:w})}class j{constructor(f,w){this.serverUrl=f,this.httpClient=w,this.serverUrl=f.replace(/\/$/,""),this.httpClient=w||fetch}async setup(){await F(`${this.serverUrl}/setup`)}async create(f){return(await F(`${this.serverUrl}/threads`,f)).data}async search(f){let w={};if(f?.ids!==void 0&&f.ids.length>0)w.ids=JSON.stringify(f.ids);if(f?.metadata!==void 0)w.metadata=JSON.stringify(f.metadata);if(f?.limit!==void 0)w.limit=f.limit;if(f?.offset!==void 0)w.offset=f.offset;if(f?.status!==void 0)w.status=f.status;if(f?.sortBy!==void 0)w.sortBy=f.sortBy;if(f?.sortOrder!==void 0)w.sortOrder=f.sortOrder;if(f?.values!==void 0)w.values=JSON.stringify(f.values);if(f?.select!==void 0)w.select=JSON.stringify(f.select);if(f?.withoutDetails!==void 0)w.withoutDetails=f.withoutDetails;return(await J(`${this.serverUrl}/threads`,w)).data}async get(f){return(await J(`${this.serverUrl}/threads/${f}`)).data}async set(f,w){await Y(`${this.serverUrl}/threads/${f}`,w)}async delete(f){await $(`${this.serverUrl}/threads/${f}`)}async updateState(f,w){return(await F(`${this.serverUrl}/threads/${f}/state`,w)).data}async createRun(f,w,x){return(await F(`${this.serverUrl}/threads/${f}/runs`,x||{},{assistantId:w})).data}async listRuns(f,w){let x={};if(w?.limit!==void 0)x.limit=w.limit;if(w?.offset!==void 0)x.offset=w.offset;if(w?.status!==void 0)x.status=w.status;return(await J(`${this.serverUrl}/threads/${f}/runs`,x)).data}async updateRun(f,w){await Y(`${this.serverUrl}/runs/${f}`,w)}async count(f){let w={};if(f?.ids!==void 0&&f.ids.length>0)w.ids=JSON.stringify(f.ids);if(f?.metadata!==void 0)w.metadata=JSON.stringify(f.metadata);if(f?.status!==void 0)w.status=f.status;if(f?.values!==void 0)w.values=JSON.stringify(f.values);return(await J(`${this.serverUrl}/threads/count`,w)).data}async patch(f,w){return(await F(`${this.serverUrl}/threads/${f}`,w)).data}async getState(f,w){let x={};if(w?.subgraphs!==void 0)x.subgraphs=w.subgraphs;if(w?.checkpointId!==void 0)x.checkpointId=w.checkpointId;return(await F(`${this.serverUrl}/threads/${f}/state`,x)).data}async getStateHistory(f,w){let x={};if(w?.limit!==void 0)x.limit=w.limit;if(w?.before!==void 0)x.before=w.before;return(await F(`${this.serverUrl}/threads/${f}/history`,x)).data}async copy(f){return(await F(`${this.serverUrl}/threads/${f}/copy`)).data}async setTitleIfNull(f,w){try{return(await F(`${this.serverUrl}/threads/${f}/title`,{title:w})).data.success}catch(x){let z=await this.get(f);if(z?.title===null||z?.title===void 0)return await this.set(f,{title:w}),!0;return!1}}}export{j as RemoteKyselyThreadsManager};