diff --git a/.gitignore b/.gitignore index f3074850..90004bca 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ node_modules/ .env .env.local *.tmp -*.temp \ No newline at end of file +*.temp diff --git a/README.md b/README.md index 8a159d95..dc673407 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Claude Memory System (claude-mem) -**🎯 Context That Stands Out** +## 😵‍💫 Remember that one thing? Neither do we. But claude-mem remembers. Transform your Claude Code from a goldfish into an elephant. Every conversation, every breakthrough, every "aha!" moment - captured, compressed, and ready when you need it. diff --git a/dist/claude-mem.min.js b/dist/claude-mem.min.js index 466ef5eb..7b28fb94 100755 --- a/dist/claude-mem.min.js +++ b/dist/claude-mem.min.js @@ -107,7 +107,7 @@ END-CONTEXT-DATA -->{{/if}}`,JC,HC,IH;var x4=Y6(()=>{n4=o6(L4(),1),JC=n4.default `))}catch(j){let K={type:"control_response",response:{subtype:"error",request_id:q.request_id,error:j.message||String(j)}};await Promise.resolve(this.transport.write(JSON.stringify(K)+` `))}finally{this.cancelControllers.delete(q.request_id)}}handleControlCancelRequest(q){let _=this.cancelControllers.get(q.request_id);if(_)_.abort(),this.cancelControllers.delete(q.request_id)}async processControlRequest(q,_){if(q.request.subtype==="can_use_tool"){if(!this.canUseTool)throw new Error("canUseTool callback is not provided.");return this.canUseTool(q.request.tool_name,q.request.input,{signal:_,suggestions:q.request.permission_suggestions})}else if(q.request.subtype==="hook_callback")return await this.handleHookCallbacks(q.request.callback_id,q.request.input,q.request.tool_use_id,_);else if(q.request.subtype==="mcp_message"){let j=q.request,K=this.sdkMcpTransports.get(j.server_name);if(!K)throw new Error(`SDK MCP server not found: ${j.server_name}`);if("method"in j.message&&"id"in j.message&&j.message.id!==null)return{mcp_response:await this.handleMcpControlRequest(j.server_name,j,K)};else{if(K.onmessage)K.onmessage(j.message);return{mcp_response:{jsonrpc:"2.0",result:{},id:0}}}}throw new Error("Unsupported control request subtype: "+q.request.subtype)}async*readSdkMessages(){for await(let q of this.inputStream)yield q}async initialize(){let q;if(this.hooks){q={};for(let[K,Y]of Object.entries(this.hooks))if(Y.length>0)q[K]=Y.map((f)=>{let P=[];for(let $ of f.hooks){let O=`hook_${this.nextCallbackId++}`;this.hookCallbacks.set(O,$),P.push(O)}return{matcher:f.matcher,hookCallbackIds:P}})}let _={subtype:"initialize",hooks:q};return(await this.request(_)).response}async interrupt(){if(!this.isStreamingMode)throw new Error("Interrupt requires --input-format stream-json");await this.request({subtype:"interrupt"})}async setPermissionMode(q){if(!this.isStreamingMode)throw new Error("setPermissionMode requires --input-format stream-json");await this.request({subtype:"set_permission_mode",mode:q})}request(q){let _=Math.random().toString(36).substring(2,15),j={request_id:_,type:"control_request",request:q};return new Promise((K,Y)=>{this.pendingControlResponses.set(_,(f)=>{if(f.subtype==="success")K(f);else Y(new Error(f.error))}),Promise.resolve(this.transport.write(JSON.stringify(j)+` `))})}async supportedCommands(){if(!this.isStreamingMode)throw new Error("supportedCommands requires --input-format stream-json");if(!this.intialization)throw new Error("supportedCommands requires transport with bidirectional communication");return(await this.intialization).commands}async streamInput(q){try{for await(let _ of q){if(this.abortController?.signal.aborted)break;await Promise.resolve(this.transport.write(JSON.stringify(_)+` -`))}this.transport.endInput()}catch(_){if(!(_ instanceof L_))throw _}}handleHookCallbacks(q,_,j,K){let Y=this.hookCallbacks.get(q);if(!Y)throw new Error(`No hook callback found for ID: ${q}`);return Y(_,j,{signal:K})}sendMcpServerMessageToCli(q,_){if("id"in _&&_.id!==null&&_.id!==void 0){let j=`${q}:${_.id}`,K=this.pendingMcpResponses.get(j);if(K){K.resolve(_),this.pendingMcpResponses.delete(j);return}}throw new Error("No pending request found")}handleMcpControlRequest(q,_,j){let K="id"in _.message?_.message.id:null,Y=`${q}:${K}`;return new Promise((f,P)=>{let $=null,O=()=>{if($)clearTimeout($);this.pendingMcpResponses.delete(Y)},w=(z)=>{O(),f(z)},v=(z)=>{O(),P(z)};if(this.pendingMcpResponses.set(Y,{resolve:w,reject:v}),j.onmessage)j.onmessage(_.message);else{O(),P(new Error("No message handler registered"));return}$=setTimeout(()=>{if(this.pendingMcpResponses.has(Y))O(),P(new Error("Request timeout"))},30000)})}};Z={};cH(Z,{void:()=>TZ,util:()=>u8,unknown:()=>JZ,union:()=>AZ,undefined:()=>vZ,tuple:()=>hZ,transformer:()=>I1,symbol:()=>OZ,string:()=>F1,strictObject:()=>XZ,setErrorMap:()=>gT,set:()=>VZ,record:()=>DZ,quotelessJson:()=>mT,promise:()=>RZ,preprocess:()=>gZ,pipeline:()=>yZ,ostring:()=>dZ,optional:()=>mZ,onumber:()=>pZ,oboolean:()=>LZ,objectUtil:()=>i4,object:()=>kZ,number:()=>U1,nullable:()=>IZ,null:()=>zZ,never:()=>HZ,nativeEnum:()=>EZ,nan:()=>fZ,map:()=>CZ,makeIssue:()=>x3,literal:()=>bZ,lazy:()=>NZ,late:()=>PZ,isValid:()=>j_,isDirty:()=>a4,isAsync:()=>gK,isAborted:()=>o4,intersection:()=>uZ,instanceof:()=>YZ,getParsedType:()=>Rq,getErrorMap:()=>n3,function:()=>MZ,enum:()=>SZ,effect:()=>I1,discriminatedUnion:()=>GZ,defaultErrorMap:()=>x_,datetimeRegex:()=>B1,date:()=>wZ,custom:()=>e1,coerce:()=>lZ,boolean:()=>s1,bigint:()=>$Z,array:()=>ZZ,any:()=>WZ,addIssueToContext:()=>F,ZodVoid:()=>dK,ZodUnknown:()=>lq,ZodUnion:()=>o_,ZodUndefined:()=>r_,ZodType:()=>k8,ZodTuple:()=>kq,ZodTransformer:()=>t6,ZodSymbol:()=>yK,ZodString:()=>Pq,ZodSet:()=>f_,ZodSchema:()=>k8,ZodRecord:()=>pK,ZodReadonly:()=>s_,ZodPromise:()=>$_,ZodPipeline:()=>nK,ZodParsedType:()=>Q,ZodOptional:()=>fq,ZodObject:()=>i8,ZodNumber:()=>nq,ZodNullable:()=>mq,ZodNull:()=>i_,ZodNever:()=>Zq,ZodNativeEnum:()=>e_,ZodNaN:()=>lK,ZodMap:()=>LK,ZodLiteral:()=>t_,ZodLazy:()=>B_,ZodIssueCode:()=>t,ZodIntersection:()=>a_,ZodFunction:()=>n_,ZodFirstPartyTypeKind:()=>z8,ZodError:()=>g6,ZodEnum:()=>cq,ZodEffects:()=>t6,ZodDiscriminatedUnion:()=>c3,ZodDefault:()=>F_,ZodDate:()=>P_,ZodCatch:()=>U_,ZodBranded:()=>r3,ZodBoolean:()=>c_,ZodBigInt:()=>xq,ZodArray:()=>Yq,ZodAny:()=>Y_,Schema:()=>k8,ParseStatus:()=>H6,OK:()=>D6,NEVER:()=>nZ,INVALID:()=>O8,EMPTY_PATH:()=>yT,DIRTY:()=>l_,BRAND:()=>jZ});(function(q){q.assertEqual=(Y)=>{};function _(Y){}q.assertIs=_;function j(Y){throw new Error}q.assertNever=j,q.arrayToEnum=(Y)=>{let f={};for(let P of Y)f[P]=P;return f},q.getValidEnumValues=(Y)=>{let f=q.objectKeys(Y).filter(($)=>typeof Y[Y[$]]!=="number"),P={};for(let $ of f)P[$]=Y[$];return q.objectValues(P)},q.objectValues=(Y)=>{return q.objectKeys(Y).map(function(f){return Y[f]})},q.objectKeys=typeof Object.keys==="function"?(Y)=>Object.keys(Y):(Y)=>{let f=[];for(let P in Y)if(Object.prototype.hasOwnProperty.call(Y,P))f.push(P);return f},q.find=(Y,f)=>{for(let P of Y)if(f(P))return P;return},q.isInteger=typeof Number.isInteger==="function"?(Y)=>Number.isInteger(Y):(Y)=>typeof Y==="number"&&Number.isFinite(Y)&&Math.floor(Y)===Y;function K(Y,f=" | "){return Y.map((P)=>typeof P==="string"?`'${P}'`:P).join(f)}q.joinValues=K,q.jsonStringifyReplacer=(Y,f)=>{if(typeof f==="bigint")return f.toString();return f}})(u8||(u8={}));(function(q){q.mergeShapes=(_,j)=>{return{..._,...j}}})(i4||(i4={}));Q=u8.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),t=u8.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);g6=class g6 extends Error{get errors(){return this.issues}constructor(q){super();this.issues=[],this.addIssue=(j)=>{this.issues=[...this.issues,j]},this.addIssues=(j=[])=>{this.issues=[...this.issues,...j]};let _=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,_);else this.__proto__=_;this.name="ZodError",this.issues=q}format(q){let _=q||function(Y){return Y.message},j={_errors:[]},K=(Y)=>{for(let f of Y.issues)if(f.code==="invalid_union")f.unionErrors.map(K);else if(f.code==="invalid_return_type")K(f.returnTypeError);else if(f.code==="invalid_arguments")K(f.argumentsError);else if(f.path.length===0)j._errors.push(_(f));else{let P=j,$=0;while($_.message){let _={},j=[];for(let K of this.issues)if(K.path.length>0){let Y=K.path[0];_[Y]=_[Y]||[],_[Y].push(q(K))}else j.push(q(K));return{formErrors:j,fieldErrors:_}}get formErrors(){return this.flatten()}};g6.create=(q)=>{return new g6(q)};x_=IT,i1=x_;yT=[];O8=Object.freeze({status:"aborted"});(function(q){q.errToObj=(_)=>typeof _==="string"?{message:_}:_||{},q.toString=(_)=>typeof _==="string"?_:_?.message})(P8||(P8={}));dT=/^c[^\s-]{8,}$/i,pT=/^[0-9a-z]+$/,LT=/^[0-9A-HJKMNP-TV-Z]{26}$/i,lT=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,nT=/^[a-z0-9_-]{21}$/i,xT=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,cT=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,rT=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,oT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,aT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,BT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,tT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,eT=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,FT=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,UT=new RegExp(`^${o1}$`);Pq=class Pq extends k8{_parse(q){if(this._def.coerce)q.data=String(q.data);if(this._getType(q)!==Q.string){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_type,expected:Q.string,received:Y.parsedType}),O8}let j=new H6,K=void 0;for(let Y of this._def.checks)if(Y.kind==="min"){if(q.data.lengthY.value)K=this._getOrReturnCtx(q,K),F(K,{code:t.too_big,maximum:Y.value,type:"string",inclusive:!0,exact:!1,message:Y.message}),j.dirty()}else if(Y.kind==="length"){let f=q.data.length>Y.value,P=q.data.lengthq.test(K),{validation:_,code:t.invalid_string,...P8.errToObj(j)})}_addCheck(q){return new Pq({...this._def,checks:[...this._def.checks,q]})}email(q){return this._addCheck({kind:"email",...P8.errToObj(q)})}url(q){return this._addCheck({kind:"url",...P8.errToObj(q)})}emoji(q){return this._addCheck({kind:"emoji",...P8.errToObj(q)})}uuid(q){return this._addCheck({kind:"uuid",...P8.errToObj(q)})}nanoid(q){return this._addCheck({kind:"nanoid",...P8.errToObj(q)})}cuid(q){return this._addCheck({kind:"cuid",...P8.errToObj(q)})}cuid2(q){return this._addCheck({kind:"cuid2",...P8.errToObj(q)})}ulid(q){return this._addCheck({kind:"ulid",...P8.errToObj(q)})}base64(q){return this._addCheck({kind:"base64",...P8.errToObj(q)})}base64url(q){return this._addCheck({kind:"base64url",...P8.errToObj(q)})}jwt(q){return this._addCheck({kind:"jwt",...P8.errToObj(q)})}ip(q){return this._addCheck({kind:"ip",...P8.errToObj(q)})}cidr(q){return this._addCheck({kind:"cidr",...P8.errToObj(q)})}datetime(q){if(typeof q==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:q});return this._addCheck({kind:"datetime",precision:typeof q?.precision==="undefined"?null:q?.precision,offset:q?.offset??!1,local:q?.local??!1,...P8.errToObj(q?.message)})}date(q){return this._addCheck({kind:"date",message:q})}time(q){if(typeof q==="string")return this._addCheck({kind:"time",precision:null,message:q});return this._addCheck({kind:"time",precision:typeof q?.precision==="undefined"?null:q?.precision,...P8.errToObj(q?.message)})}duration(q){return this._addCheck({kind:"duration",...P8.errToObj(q)})}regex(q,_){return this._addCheck({kind:"regex",regex:q,...P8.errToObj(_)})}includes(q,_){return this._addCheck({kind:"includes",value:q,position:_?.position,...P8.errToObj(_?.message)})}startsWith(q,_){return this._addCheck({kind:"startsWith",value:q,...P8.errToObj(_)})}endsWith(q,_){return this._addCheck({kind:"endsWith",value:q,...P8.errToObj(_)})}min(q,_){return this._addCheck({kind:"min",value:q,...P8.errToObj(_)})}max(q,_){return this._addCheck({kind:"max",value:q,...P8.errToObj(_)})}length(q,_){return this._addCheck({kind:"length",value:q,...P8.errToObj(_)})}nonempty(q){return this.min(1,P8.errToObj(q))}trim(){return new Pq({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Pq({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Pq({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((q)=>q.kind==="datetime")}get isDate(){return!!this._def.checks.find((q)=>q.kind==="date")}get isTime(){return!!this._def.checks.find((q)=>q.kind==="time")}get isDuration(){return!!this._def.checks.find((q)=>q.kind==="duration")}get isEmail(){return!!this._def.checks.find((q)=>q.kind==="email")}get isURL(){return!!this._def.checks.find((q)=>q.kind==="url")}get isEmoji(){return!!this._def.checks.find((q)=>q.kind==="emoji")}get isUUID(){return!!this._def.checks.find((q)=>q.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((q)=>q.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((q)=>q.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((q)=>q.kind==="cuid2")}get isULID(){return!!this._def.checks.find((q)=>q.kind==="ulid")}get isIP(){return!!this._def.checks.find((q)=>q.kind==="ip")}get isCIDR(){return!!this._def.checks.find((q)=>q.kind==="cidr")}get isBase64(){return!!this._def.checks.find((q)=>q.kind==="base64")}get isBase64url(){return!!this._def.checks.find((q)=>q.kind==="base64url")}get minLength(){let q=null;for(let _ of this._def.checks)if(_.kind==="min"){if(q===null||_.value>q)q=_.value}return q}get maxLength(){let q=null;for(let _ of this._def.checks)if(_.kind==="max"){if(q===null||_.value{return new Pq({checks:[],typeName:z8.ZodString,coerce:q?.coerce??!1,...Z8(q)})};nq=class nq extends k8{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(q){if(this._def.coerce)q.data=Number(q.data);if(this._getType(q)!==Q.number){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_type,expected:Q.number,received:Y.parsedType}),O8}let j=void 0,K=new H6;for(let Y of this._def.checks)if(Y.kind==="int"){if(!u8.isInteger(q.data))j=this._getOrReturnCtx(q,j),F(j,{code:t.invalid_type,expected:"integer",received:"float",message:Y.message}),K.dirty()}else if(Y.kind==="min"){if(Y.inclusive?q.dataY.value:q.data>=Y.value)j=this._getOrReturnCtx(q,j),F(j,{code:t.too_big,maximum:Y.value,type:"number",inclusive:Y.inclusive,exact:!1,message:Y.message}),K.dirty()}else if(Y.kind==="multipleOf"){if(KZ(q.data,Y.value)!==0)j=this._getOrReturnCtx(q,j),F(j,{code:t.not_multiple_of,multipleOf:Y.value,message:Y.message}),K.dirty()}else if(Y.kind==="finite"){if(!Number.isFinite(q.data))j=this._getOrReturnCtx(q,j),F(j,{code:t.not_finite,message:Y.message}),K.dirty()}else u8.assertNever(Y);return{status:K.value,value:q.data}}gte(q,_){return this.setLimit("min",q,!0,P8.toString(_))}gt(q,_){return this.setLimit("min",q,!1,P8.toString(_))}lte(q,_){return this.setLimit("max",q,!0,P8.toString(_))}lt(q,_){return this.setLimit("max",q,!1,P8.toString(_))}setLimit(q,_,j,K){return new nq({...this._def,checks:[...this._def.checks,{kind:q,value:_,inclusive:j,message:P8.toString(K)}]})}_addCheck(q){return new nq({...this._def,checks:[...this._def.checks,q]})}int(q){return this._addCheck({kind:"int",message:P8.toString(q)})}positive(q){return this._addCheck({kind:"min",value:0,inclusive:!1,message:P8.toString(q)})}negative(q){return this._addCheck({kind:"max",value:0,inclusive:!1,message:P8.toString(q)})}nonpositive(q){return this._addCheck({kind:"max",value:0,inclusive:!0,message:P8.toString(q)})}nonnegative(q){return this._addCheck({kind:"min",value:0,inclusive:!0,message:P8.toString(q)})}multipleOf(q,_){return this._addCheck({kind:"multipleOf",value:q,message:P8.toString(_)})}finite(q){return this._addCheck({kind:"finite",message:P8.toString(q)})}safe(q){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:P8.toString(q)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:P8.toString(q)})}get minValue(){let q=null;for(let _ of this._def.checks)if(_.kind==="min"){if(q===null||_.value>q)q=_.value}return q}get maxValue(){let q=null;for(let _ of this._def.checks)if(_.kind==="max"){if(q===null||_.valueq.kind==="int"||q.kind==="multipleOf"&&u8.isInteger(q.value))}get isFinite(){let q=null,_=null;for(let j of this._def.checks)if(j.kind==="finite"||j.kind==="int"||j.kind==="multipleOf")return!0;else if(j.kind==="min"){if(_===null||j.value>_)_=j.value}else if(j.kind==="max"){if(q===null||j.value{return new nq({checks:[],typeName:z8.ZodNumber,coerce:q?.coerce||!1,...Z8(q)})};xq=class xq extends k8{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(q){if(this._def.coerce)try{q.data=BigInt(q.data)}catch{return this._getInvalidInput(q)}if(this._getType(q)!==Q.bigint)return this._getInvalidInput(q);let j=void 0,K=new H6;for(let Y of this._def.checks)if(Y.kind==="min"){if(Y.inclusive?q.dataY.value:q.data>=Y.value)j=this._getOrReturnCtx(q,j),F(j,{code:t.too_big,type:"bigint",maximum:Y.value,inclusive:Y.inclusive,message:Y.message}),K.dirty()}else if(Y.kind==="multipleOf"){if(q.data%Y.value!==BigInt(0))j=this._getOrReturnCtx(q,j),F(j,{code:t.not_multiple_of,multipleOf:Y.value,message:Y.message}),K.dirty()}else u8.assertNever(Y);return{status:K.value,value:q.data}}_getInvalidInput(q){let _=this._getOrReturnCtx(q);return F(_,{code:t.invalid_type,expected:Q.bigint,received:_.parsedType}),O8}gte(q,_){return this.setLimit("min",q,!0,P8.toString(_))}gt(q,_){return this.setLimit("min",q,!1,P8.toString(_))}lte(q,_){return this.setLimit("max",q,!0,P8.toString(_))}lt(q,_){return this.setLimit("max",q,!1,P8.toString(_))}setLimit(q,_,j,K){return new xq({...this._def,checks:[...this._def.checks,{kind:q,value:_,inclusive:j,message:P8.toString(K)}]})}_addCheck(q){return new xq({...this._def,checks:[...this._def.checks,q]})}positive(q){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:P8.toString(q)})}negative(q){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:P8.toString(q)})}nonpositive(q){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:P8.toString(q)})}nonnegative(q){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:P8.toString(q)})}multipleOf(q,_){return this._addCheck({kind:"multipleOf",value:q,message:P8.toString(_)})}get minValue(){let q=null;for(let _ of this._def.checks)if(_.kind==="min"){if(q===null||_.value>q)q=_.value}return q}get maxValue(){let q=null;for(let _ of this._def.checks)if(_.kind==="max"){if(q===null||_.value{return new xq({checks:[],typeName:z8.ZodBigInt,coerce:q?.coerce??!1,...Z8(q)})};c_=class c_ extends k8{_parse(q){if(this._def.coerce)q.data=Boolean(q.data);if(this._getType(q)!==Q.boolean){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:Q.boolean,received:j.parsedType}),O8}return D6(q.data)}};c_.create=(q)=>{return new c_({typeName:z8.ZodBoolean,coerce:q?.coerce||!1,...Z8(q)})};P_=class P_ extends k8{_parse(q){if(this._def.coerce)q.data=new Date(q.data);if(this._getType(q)!==Q.date){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_type,expected:Q.date,received:Y.parsedType}),O8}if(Number.isNaN(q.data.getTime())){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_date}),O8}let j=new H6,K=void 0;for(let Y of this._def.checks)if(Y.kind==="min"){if(q.data.getTime()Y.value)K=this._getOrReturnCtx(q,K),F(K,{code:t.too_big,message:Y.message,inclusive:!0,exact:!1,maximum:Y.value,type:"date"}),j.dirty()}else u8.assertNever(Y);return{status:j.value,value:new Date(q.data.getTime())}}_addCheck(q){return new P_({...this._def,checks:[...this._def.checks,q]})}min(q,_){return this._addCheck({kind:"min",value:q.getTime(),message:P8.toString(_)})}max(q,_){return this._addCheck({kind:"max",value:q.getTime(),message:P8.toString(_)})}get minDate(){let q=null;for(let _ of this._def.checks)if(_.kind==="min"){if(q===null||_.value>q)q=_.value}return q!=null?new Date(q):null}get maxDate(){let q=null;for(let _ of this._def.checks)if(_.kind==="max"){if(q===null||_.value{return new P_({checks:[],coerce:q?.coerce||!1,typeName:z8.ZodDate,...Z8(q)})};yK=class yK extends k8{_parse(q){if(this._getType(q)!==Q.symbol){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:Q.symbol,received:j.parsedType}),O8}return D6(q.data)}};yK.create=(q)=>{return new yK({typeName:z8.ZodSymbol,...Z8(q)})};r_=class r_ extends k8{_parse(q){if(this._getType(q)!==Q.undefined){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:Q.undefined,received:j.parsedType}),O8}return D6(q.data)}};r_.create=(q)=>{return new r_({typeName:z8.ZodUndefined,...Z8(q)})};i_=class i_ extends k8{_parse(q){if(this._getType(q)!==Q.null){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:Q.null,received:j.parsedType}),O8}return D6(q.data)}};i_.create=(q)=>{return new i_({typeName:z8.ZodNull,...Z8(q)})};Y_=class Y_ extends k8{constructor(){super(...arguments);this._any=!0}_parse(q){return D6(q.data)}};Y_.create=(q)=>{return new Y_({typeName:z8.ZodAny,...Z8(q)})};lq=class lq extends k8{constructor(){super(...arguments);this._unknown=!0}_parse(q){return D6(q.data)}};lq.create=(q)=>{return new lq({typeName:z8.ZodUnknown,...Z8(q)})};Zq=class Zq extends k8{_parse(q){let _=this._getOrReturnCtx(q);return F(_,{code:t.invalid_type,expected:Q.never,received:_.parsedType}),O8}};Zq.create=(q)=>{return new Zq({typeName:z8.ZodNever,...Z8(q)})};dK=class dK extends k8{_parse(q){if(this._getType(q)!==Q.undefined){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:Q.void,received:j.parsedType}),O8}return D6(q.data)}};dK.create=(q)=>{return new dK({typeName:z8.ZodVoid,...Z8(q)})};Yq=class Yq extends k8{_parse(q){let{ctx:_,status:j}=this._processInputParams(q),K=this._def;if(_.parsedType!==Q.array)return F(_,{code:t.invalid_type,expected:Q.array,received:_.parsedType}),O8;if(K.exactLength!==null){let f=_.data.length>K.exactLength.value,P=_.data.lengthK.maxLength.value)F(_,{code:t.too_big,maximum:K.maxLength.value,type:"array",inclusive:!0,exact:!1,message:K.maxLength.message}),j.dirty()}if(_.common.async)return Promise.all([..._.data].map((f,P)=>{return K.type._parseAsync(new $q(_,f,_.path,P))})).then((f)=>{return H6.mergeArray(j,f)});let Y=[..._.data].map((f,P)=>{return K.type._parseSync(new $q(_,f,_.path,P))});return H6.mergeArray(j,Y)}get element(){return this._def.type}min(q,_){return new Yq({...this._def,minLength:{value:q,message:P8.toString(_)}})}max(q,_){return new Yq({...this._def,maxLength:{value:q,message:P8.toString(_)}})}length(q,_){return new Yq({...this._def,exactLength:{value:q,message:P8.toString(_)}})}nonempty(q){return this.min(1,q)}};Yq.create=(q,_)=>{return new Yq({type:q,minLength:null,maxLength:null,exactLength:null,typeName:z8.ZodArray,...Z8(_)})};i8=class i8 extends k8{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let q=this._def.shape(),_=u8.objectKeys(q);return this._cached={shape:q,keys:_},this._cached}_parse(q){if(this._getType(q)!==Q.object){let O=this._getOrReturnCtx(q);return F(O,{code:t.invalid_type,expected:Q.object,received:O.parsedType}),O8}let{status:j,ctx:K}=this._processInputParams(q),{shape:Y,keys:f}=this._getCached(),P=[];if(!(this._def.catchall instanceof Zq&&this._def.unknownKeys==="strip")){for(let O in K.data)if(!f.includes(O))P.push(O)}let $=[];for(let O of f){let w=Y[O],v=K.data[O];$.push({key:{status:"valid",value:O},value:w._parse(new $q(K,v,K.path,O)),alwaysSet:O in K.data})}if(this._def.catchall instanceof Zq){let O=this._def.unknownKeys;if(O==="passthrough")for(let w of P)$.push({key:{status:"valid",value:w},value:{status:"valid",value:K.data[w]}});else if(O==="strict"){if(P.length>0)F(K,{code:t.unrecognized_keys,keys:P}),j.dirty()}else if(O==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let O=this._def.catchall;for(let w of P){let v=K.data[w];$.push({key:{status:"valid",value:w},value:O._parse(new $q(K,v,K.path,w)),alwaysSet:w in K.data})}}if(K.common.async)return Promise.resolve().then(async()=>{let O=[];for(let w of $){let v=await w.key,z=await w.value;O.push({key:v,value:z,alwaysSet:w.alwaysSet})}return O}).then((O)=>{return H6.mergeObjectSync(j,O)});else return H6.mergeObjectSync(j,$)}get shape(){return this._def.shape()}strict(q){return P8.errToObj,new i8({...this._def,unknownKeys:"strict",...q!==void 0?{errorMap:(_,j)=>{let K=this._def.errorMap?.(_,j).message??j.defaultError;if(_.code==="unrecognized_keys")return{message:P8.errToObj(q).message??K};return{message:K}}}:{}})}strip(){return new i8({...this._def,unknownKeys:"strip"})}passthrough(){return new i8({...this._def,unknownKeys:"passthrough"})}extend(q){return new i8({...this._def,shape:()=>({...this._def.shape(),...q})})}merge(q){return new i8({unknownKeys:q._def.unknownKeys,catchall:q._def.catchall,shape:()=>({...this._def.shape(),...q._def.shape()}),typeName:z8.ZodObject})}setKey(q,_){return this.augment({[q]:_})}catchall(q){return new i8({...this._def,catchall:q})}pick(q){let _={};for(let j of u8.objectKeys(q))if(q[j]&&this.shape[j])_[j]=this.shape[j];return new i8({...this._def,shape:()=>_})}omit(q){let _={};for(let j of u8.objectKeys(this.shape))if(!q[j])_[j]=this.shape[j];return new i8({...this._def,shape:()=>_})}deepPartial(){return p_(this)}partial(q){let _={};for(let j of u8.objectKeys(this.shape)){let K=this.shape[j];if(q&&!q[j])_[j]=K;else _[j]=K.optional()}return new i8({...this._def,shape:()=>_})}required(q){let _={};for(let j of u8.objectKeys(this.shape))if(q&&!q[j])_[j]=this.shape[j];else{let Y=this.shape[j];while(Y instanceof fq)Y=Y._def.innerType;_[j]=Y}return new i8({...this._def,shape:()=>_})}keyof(){return t1(u8.objectKeys(this.shape))}};i8.create=(q,_)=>{return new i8({shape:()=>q,unknownKeys:"strip",catchall:Zq.create(),typeName:z8.ZodObject,...Z8(_)})};i8.strictCreate=(q,_)=>{return new i8({shape:()=>q,unknownKeys:"strict",catchall:Zq.create(),typeName:z8.ZodObject,...Z8(_)})};i8.lazycreate=(q,_)=>{return new i8({shape:q,unknownKeys:"strip",catchall:Zq.create(),typeName:z8.ZodObject,...Z8(_)})};o_=class o_ extends k8{_parse(q){let{ctx:_}=this._processInputParams(q),j=this._def.options;function K(Y){for(let P of Y)if(P.result.status==="valid")return P.result;for(let P of Y)if(P.result.status==="dirty")return _.common.issues.push(...P.ctx.common.issues),P.result;let f=Y.map((P)=>new g6(P.ctx.common.issues));return F(_,{code:t.invalid_union,unionErrors:f}),O8}if(_.common.async)return Promise.all(j.map(async(Y)=>{let f={..._,common:{..._.common,issues:[]},parent:null};return{result:await Y._parseAsync({data:_.data,path:_.path,parent:f}),ctx:f}})).then(K);else{let Y=void 0,f=[];for(let $ of j){let O={..._,common:{..._.common,issues:[]},parent:null},w=$._parseSync({data:_.data,path:_.path,parent:O});if(w.status==="valid")return w;else if(w.status==="dirty"&&!Y)Y={result:w,ctx:O};if(O.common.issues.length)f.push(O.common.issues)}if(Y)return _.common.issues.push(...Y.ctx.common.issues),Y.result;let P=f.map(($)=>new g6($));return F(_,{code:t.invalid_union,unionErrors:P}),O8}}get options(){return this._def.options}};o_.create=(q,_)=>{return new o_({options:q,typeName:z8.ZodUnion,...Z8(_)})};c3=class c3 extends k8{_parse(q){let{ctx:_}=this._processInputParams(q);if(_.parsedType!==Q.object)return F(_,{code:t.invalid_type,expected:Q.object,received:_.parsedType}),O8;let j=this.discriminator,K=_.data[j],Y=this.optionsMap.get(K);if(!Y)return F(_,{code:t.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[j]}),O8;if(_.common.async)return Y._parseAsync({data:_.data,path:_.path,parent:_});else return Y._parseSync({data:_.data,path:_.path,parent:_})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(q,_,j){let K=new Map;for(let Y of _){let f=Eq(Y.shape[q]);if(!f.length)throw new Error(`A discriminator value for key \`${q}\` could not be extracted from all schema options`);for(let P of f){if(K.has(P))throw new Error(`Discriminator property ${String(q)} has duplicate value ${String(P)}`);K.set(P,Y)}}return new c3({typeName:z8.ZodDiscriminatedUnion,discriminator:q,options:_,optionsMap:K,...Z8(j)})}};a_=class a_ extends k8{_parse(q){let{status:_,ctx:j}=this._processInputParams(q),K=(Y,f)=>{if(o4(Y)||o4(f))return O8;let P=B4(Y.value,f.value);if(!P.valid)return F(j,{code:t.invalid_intersection_types}),O8;if(a4(Y)||a4(f))_.dirty();return{status:_.value,value:P.data}};if(j.common.async)return Promise.all([this._def.left._parseAsync({data:j.data,path:j.path,parent:j}),this._def.right._parseAsync({data:j.data,path:j.path,parent:j})]).then(([Y,f])=>K(Y,f));else return K(this._def.left._parseSync({data:j.data,path:j.path,parent:j}),this._def.right._parseSync({data:j.data,path:j.path,parent:j}))}};a_.create=(q,_,j)=>{return new a_({left:q,right:_,typeName:z8.ZodIntersection,...Z8(j)})};kq=class kq extends k8{_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.parsedType!==Q.array)return F(j,{code:t.invalid_type,expected:Q.array,received:j.parsedType}),O8;if(j.data.lengththis._def.items.length)F(j,{code:t.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_.dirty();let Y=[...j.data].map((f,P)=>{let $=this._def.items[P]||this._def.rest;if(!$)return null;return $._parse(new $q(j,f,j.path,P))}).filter((f)=>!!f);if(j.common.async)return Promise.all(Y).then((f)=>{return H6.mergeArray(_,f)});else return H6.mergeArray(_,Y)}get items(){return this._def.items}rest(q){return new kq({...this._def,rest:q})}};kq.create=(q,_)=>{if(!Array.isArray(q))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new kq({items:q,typeName:z8.ZodTuple,rest:null,...Z8(_)})};pK=class pK extends k8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.parsedType!==Q.object)return F(j,{code:t.invalid_type,expected:Q.object,received:j.parsedType}),O8;let K=[],Y=this._def.keyType,f=this._def.valueType;for(let P in j.data)K.push({key:Y._parse(new $q(j,P,j.path,P)),value:f._parse(new $q(j,j.data[P],j.path,P)),alwaysSet:P in j.data});if(j.common.async)return H6.mergeObjectAsync(_,K);else return H6.mergeObjectSync(_,K)}get element(){return this._def.valueType}static create(q,_,j){if(_ instanceof k8)return new pK({keyType:q,valueType:_,typeName:z8.ZodRecord,...Z8(j)});return new pK({keyType:Pq.create(),valueType:q,typeName:z8.ZodRecord,...Z8(_)})}};LK=class LK extends k8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.parsedType!==Q.map)return F(j,{code:t.invalid_type,expected:Q.map,received:j.parsedType}),O8;let K=this._def.keyType,Y=this._def.valueType,f=[...j.data.entries()].map(([P,$],O)=>{return{key:K._parse(new $q(j,P,j.path,[O,"key"])),value:Y._parse(new $q(j,$,j.path,[O,"value"]))}});if(j.common.async){let P=new Map;return Promise.resolve().then(async()=>{for(let $ of f){let O=await $.key,w=await $.value;if(O.status==="aborted"||w.status==="aborted")return O8;if(O.status==="dirty"||w.status==="dirty")_.dirty();P.set(O.value,w.value)}return{status:_.value,value:P}})}else{let P=new Map;for(let $ of f){let{key:O,value:w}=$;if(O.status==="aborted"||w.status==="aborted")return O8;if(O.status==="dirty"||w.status==="dirty")_.dirty();P.set(O.value,w.value)}return{status:_.value,value:P}}}};LK.create=(q,_,j)=>{return new LK({valueType:_,keyType:q,typeName:z8.ZodMap,...Z8(j)})};f_=class f_ extends k8{_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.parsedType!==Q.set)return F(j,{code:t.invalid_type,expected:Q.set,received:j.parsedType}),O8;let K=this._def;if(K.minSize!==null){if(j.data.sizeK.maxSize.value)F(j,{code:t.too_big,maximum:K.maxSize.value,type:"set",inclusive:!0,exact:!1,message:K.maxSize.message}),_.dirty()}let Y=this._def.valueType;function f($){let O=new Set;for(let w of $){if(w.status==="aborted")return O8;if(w.status==="dirty")_.dirty();O.add(w.value)}return{status:_.value,value:O}}let P=[...j.data.values()].map(($,O)=>Y._parse(new $q(j,$,j.path,O)));if(j.common.async)return Promise.all(P).then(($)=>f($));else return f(P)}min(q,_){return new f_({...this._def,minSize:{value:q,message:P8.toString(_)}})}max(q,_){return new f_({...this._def,maxSize:{value:q,message:P8.toString(_)}})}size(q,_){return this.min(q,_).max(q,_)}nonempty(q){return this.min(1,q)}};f_.create=(q,_)=>{return new f_({valueType:q,minSize:null,maxSize:null,typeName:z8.ZodSet,...Z8(_)})};n_=class n_ extends k8{constructor(){super(...arguments);this.validate=this.implement}_parse(q){let{ctx:_}=this._processInputParams(q);if(_.parsedType!==Q.function)return F(_,{code:t.invalid_type,expected:Q.function,received:_.parsedType}),O8;function j(P,$){return x3({data:P,path:_.path,errorMaps:[_.common.contextualErrorMap,_.schemaErrorMap,n3(),x_].filter((O)=>!!O),issueData:{code:t.invalid_arguments,argumentsError:$}})}function K(P,$){return x3({data:P,path:_.path,errorMaps:[_.common.contextualErrorMap,_.schemaErrorMap,n3(),x_].filter((O)=>!!O),issueData:{code:t.invalid_return_type,returnTypeError:$}})}let Y={errorMap:_.common.contextualErrorMap},f=_.data;if(this._def.returns instanceof $_){let P=this;return D6(async function(...$){let O=new g6([]),w=await P._def.args.parseAsync($,Y).catch((W)=>{throw O.addIssue(j($,W)),O}),v=await Reflect.apply(f,this,w);return await P._def.returns._def.type.parseAsync(v,Y).catch((W)=>{throw O.addIssue(K(v,W)),O})})}else{let P=this;return D6(function(...$){let O=P._def.args.safeParse($,Y);if(!O.success)throw new g6([j($,O.error)]);let w=Reflect.apply(f,this,O.data),v=P._def.returns.safeParse(w,Y);if(!v.success)throw new g6([K(w,v.error)]);return v.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...q){return new n_({...this._def,args:kq.create(q).rest(lq.create())})}returns(q){return new n_({...this._def,returns:q})}implement(q){return this.parse(q)}strictImplement(q){return this.parse(q)}static create(q,_,j){return new n_({args:q?q:kq.create([]).rest(lq.create()),returns:_||lq.create(),typeName:z8.ZodFunction,...Z8(j)})}};B_=class B_ extends k8{get schema(){return this._def.getter()}_parse(q){let{ctx:_}=this._processInputParams(q);return this._def.getter()._parse({data:_.data,path:_.path,parent:_})}};B_.create=(q,_)=>{return new B_({getter:q,typeName:z8.ZodLazy,...Z8(_)})};t_=class t_ extends k8{_parse(q){if(q.data!==this._def.value){let _=this._getOrReturnCtx(q);return F(_,{received:_.data,code:t.invalid_literal,expected:this._def.value}),O8}return{status:"valid",value:q.data}}get value(){return this._def.value}};t_.create=(q,_)=>{return new t_({value:q,typeName:z8.ZodLiteral,...Z8(_)})};cq=class cq extends k8{_parse(q){if(typeof q.data!=="string"){let _=this._getOrReturnCtx(q),j=this._def.values;return F(_,{expected:u8.joinValues(j),received:_.parsedType,code:t.invalid_type}),O8}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(q.data)){let _=this._getOrReturnCtx(q),j=this._def.values;return F(_,{received:_.data,code:t.invalid_enum_value,options:j}),O8}return D6(q.data)}get options(){return this._def.values}get enum(){let q={};for(let _ of this._def.values)q[_]=_;return q}get Values(){let q={};for(let _ of this._def.values)q[_]=_;return q}get Enum(){let q={};for(let _ of this._def.values)q[_]=_;return q}extract(q,_=this._def){return cq.create(q,{...this._def,..._})}exclude(q,_=this._def){return cq.create(this.options.filter((j)=>!q.includes(j)),{...this._def,..._})}};cq.create=t1;e_=class e_ extends k8{_parse(q){let _=u8.getValidEnumValues(this._def.values),j=this._getOrReturnCtx(q);if(j.parsedType!==Q.string&&j.parsedType!==Q.number){let K=u8.objectValues(_);return F(j,{expected:u8.joinValues(K),received:j.parsedType,code:t.invalid_type}),O8}if(!this._cache)this._cache=new Set(u8.getValidEnumValues(this._def.values));if(!this._cache.has(q.data)){let K=u8.objectValues(_);return F(j,{received:j.data,code:t.invalid_enum_value,options:K}),O8}return D6(q.data)}get enum(){return this._def.values}};e_.create=(q,_)=>{return new e_({values:q,typeName:z8.ZodNativeEnum,...Z8(_)})};$_=class $_ extends k8{unwrap(){return this._def.type}_parse(q){let{ctx:_}=this._processInputParams(q);if(_.parsedType!==Q.promise&&_.common.async===!1)return F(_,{code:t.invalid_type,expected:Q.promise,received:_.parsedType}),O8;let j=_.parsedType===Q.promise?_.data:Promise.resolve(_.data);return D6(j.then((K)=>{return this._def.type.parseAsync(K,{path:_.path,errorMap:_.common.contextualErrorMap})}))}};$_.create=(q,_)=>{return new $_({type:q,typeName:z8.ZodPromise,...Z8(_)})};t6=class t6 extends k8{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===z8.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(q){let{status:_,ctx:j}=this._processInputParams(q),K=this._def.effect||null,Y={addIssue:(f)=>{if(F(j,f),f.fatal)_.abort();else _.dirty()},get path(){return j.path}};if(Y.addIssue=Y.addIssue.bind(Y),K.type==="preprocess"){let f=K.transform(j.data,Y);if(j.common.async)return Promise.resolve(f).then(async(P)=>{if(_.value==="aborted")return O8;let $=await this._def.schema._parseAsync({data:P,path:j.path,parent:j});if($.status==="aborted")return O8;if($.status==="dirty")return l_($.value);if(_.value==="dirty")return l_($.value);return $});else{if(_.value==="aborted")return O8;let P=this._def.schema._parseSync({data:f,path:j.path,parent:j});if(P.status==="aborted")return O8;if(P.status==="dirty")return l_(P.value);if(_.value==="dirty")return l_(P.value);return P}}if(K.type==="refinement"){let f=(P)=>{let $=K.refinement(P,Y);if(j.common.async)return Promise.resolve($);if($ instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return P};if(j.common.async===!1){let P=this._def.schema._parseSync({data:j.data,path:j.path,parent:j});if(P.status==="aborted")return O8;if(P.status==="dirty")_.dirty();return f(P.value),{status:_.value,value:P.value}}else return this._def.schema._parseAsync({data:j.data,path:j.path,parent:j}).then((P)=>{if(P.status==="aborted")return O8;if(P.status==="dirty")_.dirty();return f(P.value).then(()=>{return{status:_.value,value:P.value}})})}if(K.type==="transform")if(j.common.async===!1){let f=this._def.schema._parseSync({data:j.data,path:j.path,parent:j});if(!j_(f))return O8;let P=K.transform(f.value,Y);if(P instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:_.value,value:P}}else return this._def.schema._parseAsync({data:j.data,path:j.path,parent:j}).then((f)=>{if(!j_(f))return O8;return Promise.resolve(K.transform(f.value,Y)).then((P)=>({status:_.value,value:P}))});u8.assertNever(K)}};t6.create=(q,_,j)=>{return new t6({schema:q,typeName:z8.ZodEffects,effect:_,...Z8(j)})};t6.createWithPreprocess=(q,_,j)=>{return new t6({schema:_,effect:{type:"preprocess",transform:q},typeName:z8.ZodEffects,...Z8(j)})};fq=class fq extends k8{_parse(q){if(this._getType(q)===Q.undefined)return D6(void 0);return this._def.innerType._parse(q)}unwrap(){return this._def.innerType}};fq.create=(q,_)=>{return new fq({innerType:q,typeName:z8.ZodOptional,...Z8(_)})};mq=class mq extends k8{_parse(q){if(this._getType(q)===Q.null)return D6(null);return this._def.innerType._parse(q)}unwrap(){return this._def.innerType}};mq.create=(q,_)=>{return new mq({innerType:q,typeName:z8.ZodNullable,...Z8(_)})};F_=class F_ extends k8{_parse(q){let{ctx:_}=this._processInputParams(q),j=_.data;if(_.parsedType===Q.undefined)j=this._def.defaultValue();return this._def.innerType._parse({data:j,path:_.path,parent:_})}removeDefault(){return this._def.innerType}};F_.create=(q,_)=>{return new F_({innerType:q,typeName:z8.ZodDefault,defaultValue:typeof _.default==="function"?_.default:()=>_.default,...Z8(_)})};U_=class U_ extends k8{_parse(q){let{ctx:_}=this._processInputParams(q),j={..._,common:{..._.common,issues:[]}},K=this._def.innerType._parse({data:j.data,path:j.path,parent:{...j}});if(gK(K))return K.then((Y)=>{return{status:"valid",value:Y.status==="valid"?Y.value:this._def.catchValue({get error(){return new g6(j.common.issues)},input:j.data})}});else return{status:"valid",value:K.status==="valid"?K.value:this._def.catchValue({get error(){return new g6(j.common.issues)},input:j.data})}}removeCatch(){return this._def.innerType}};U_.create=(q,_)=>{return new U_({innerType:q,typeName:z8.ZodCatch,catchValue:typeof _.catch==="function"?_.catch:()=>_.catch,...Z8(_)})};lK=class lK extends k8{_parse(q){if(this._getType(q)!==Q.nan){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:Q.nan,received:j.parsedType}),O8}return{status:"valid",value:q.data}}};lK.create=(q)=>{return new lK({typeName:z8.ZodNaN,...Z8(q)})};jZ=Symbol("zod_brand");r3=class r3 extends k8{_parse(q){let{ctx:_}=this._processInputParams(q),j=_.data;return this._def.type._parse({data:j,path:_.path,parent:_})}unwrap(){return this._def.type}};nK=class nK extends k8{_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.common.async)return(async()=>{let Y=await this._def.in._parseAsync({data:j.data,path:j.path,parent:j});if(Y.status==="aborted")return O8;if(Y.status==="dirty")return _.dirty(),l_(Y.value);else return this._def.out._parseAsync({data:Y.value,path:j.path,parent:j})})();else{let K=this._def.in._parseSync({data:j.data,path:j.path,parent:j});if(K.status==="aborted")return O8;if(K.status==="dirty")return _.dirty(),{status:"dirty",value:K.value};else return this._def.out._parseSync({data:K.value,path:j.path,parent:j})}}static create(q,_){return new nK({in:q,out:_,typeName:z8.ZodPipeline})}};s_=class s_ extends k8{_parse(q){let _=this._def.innerType._parse(q),j=(K)=>{if(j_(K))K.value=Object.freeze(K.value);return K};return gK(_)?_.then((K)=>j(K)):j(_)}unwrap(){return this._def.innerType}};s_.create=(q,_)=>{return new s_({innerType:q,typeName:z8.ZodReadonly,...Z8(_)})};PZ={object:i8.lazycreate};(function(q){q.ZodString="ZodString",q.ZodNumber="ZodNumber",q.ZodNaN="ZodNaN",q.ZodBigInt="ZodBigInt",q.ZodBoolean="ZodBoolean",q.ZodDate="ZodDate",q.ZodSymbol="ZodSymbol",q.ZodUndefined="ZodUndefined",q.ZodNull="ZodNull",q.ZodAny="ZodAny",q.ZodUnknown="ZodUnknown",q.ZodNever="ZodNever",q.ZodVoid="ZodVoid",q.ZodArray="ZodArray",q.ZodObject="ZodObject",q.ZodUnion="ZodUnion",q.ZodDiscriminatedUnion="ZodDiscriminatedUnion",q.ZodIntersection="ZodIntersection",q.ZodTuple="ZodTuple",q.ZodRecord="ZodRecord",q.ZodMap="ZodMap",q.ZodSet="ZodSet",q.ZodFunction="ZodFunction",q.ZodLazy="ZodLazy",q.ZodLiteral="ZodLiteral",q.ZodEnum="ZodEnum",q.ZodEffects="ZodEffects",q.ZodNativeEnum="ZodNativeEnum",q.ZodOptional="ZodOptional",q.ZodNullable="ZodNullable",q.ZodDefault="ZodDefault",q.ZodCatch="ZodCatch",q.ZodPromise="ZodPromise",q.ZodBranded="ZodBranded",q.ZodPipeline="ZodPipeline",q.ZodReadonly="ZodReadonly"})(z8||(z8={}));F1=Pq.create,U1=nq.create,fZ=lK.create,$Z=xq.create,s1=c_.create,wZ=P_.create,OZ=yK.create,vZ=r_.create,zZ=i_.create,WZ=Y_.create,JZ=lq.create,HZ=Zq.create,TZ=dK.create,ZZ=Yq.create,kZ=i8.create,XZ=i8.strictCreate,AZ=o_.create,GZ=c3.create,uZ=a_.create,hZ=kq.create,DZ=pK.create,CZ=LK.create,VZ=f_.create,MZ=n_.create,NZ=B_.create,bZ=t_.create,SZ=cq.create,EZ=e_.create,RZ=$_.create,I1=t6.create,mZ=fq.create,IZ=mq.create,gZ=t6.createWithPreprocess,yZ=nK.create,lZ={string:(q)=>Pq.create({...q,coerce:!0}),number:(q)=>nq.create({...q,coerce:!0}),boolean:(q)=>c_.create({...q,coerce:!0}),bigint:(q)=>xq.create({...q,coerce:!0}),date:(q)=>P_.create({...q,coerce:!0})},nZ=O8,Q1=Z.union([Z.string(),Z.number().int()]),qP=Z.string(),xZ=Z.object({progressToken:Z.optional(Q1)}).passthrough(),e6=Z.object({_meta:Z.optional(xZ)}).passthrough(),S6=Z.object({method:Z.string(),params:Z.optional(e6)}),xK=Z.object({_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),Xq=Z.object({method:Z.string(),params:Z.optional(xK)}),F6=Z.object({_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),o3=Z.union([Z.string(),Z.number().int()]),cZ=Z.object({jsonrpc:Z.literal(i3),id:o3}).merge(S6).strict(),rZ=Z.object({jsonrpc:Z.literal(i3)}).merge(Xq).strict(),iZ=Z.object({jsonrpc:Z.literal(i3),id:o3,result:F6}).strict();(function(q){q[q.ConnectionClosed=-32000]="ConnectionClosed",q[q.RequestTimeout=-32001]="RequestTimeout",q[q.ParseError=-32700]="ParseError",q[q.InvalidRequest=-32600]="InvalidRequest",q[q.MethodNotFound=-32601]="MethodNotFound",q[q.InvalidParams=-32602]="InvalidParams",q[q.InternalError=-32603]="InternalError"})(g1||(g1={}));oZ=Z.object({jsonrpc:Z.literal(i3),id:o3,error:Z.object({code:Z.number().int(),message:Z.string(),data:Z.optional(Z.unknown())})}).strict(),hC=Z.union([cZ,rZ,iZ,oZ]),_P=F6.strict(),KP=Xq.extend({method:Z.literal("notifications/cancelled"),params:xK.extend({requestId:o3,reason:Z.string().optional()})}),cK=Z.object({name:Z.string(),title:Z.optional(Z.string())}).passthrough(),jP=cK.extend({version:Z.string()}),aZ=Z.object({experimental:Z.optional(Z.object({}).passthrough()),sampling:Z.optional(Z.object({}).passthrough()),elicitation:Z.optional(Z.object({}).passthrough()),roots:Z.optional(Z.object({listChanged:Z.optional(Z.boolean())}).passthrough())}).passthrough(),BZ=S6.extend({method:Z.literal("initialize"),params:e6.extend({protocolVersion:Z.string(),capabilities:aZ,clientInfo:jP})}),tZ=Z.object({experimental:Z.optional(Z.object({}).passthrough()),logging:Z.optional(Z.object({}).passthrough()),completions:Z.optional(Z.object({}).passthrough()),prompts:Z.optional(Z.object({listChanged:Z.optional(Z.boolean())}).passthrough()),resources:Z.optional(Z.object({subscribe:Z.optional(Z.boolean()),listChanged:Z.optional(Z.boolean())}).passthrough()),tools:Z.optional(Z.object({listChanged:Z.optional(Z.boolean())}).passthrough())}).passthrough(),eZ=F6.extend({protocolVersion:Z.string(),capabilities:tZ,serverInfo:jP,instructions:Z.optional(Z.string())}),FZ=Xq.extend({method:Z.literal("notifications/initialized")}),PP=S6.extend({method:Z.literal("ping")}),UZ=Z.object({progress:Z.number(),total:Z.optional(Z.number()),message:Z.optional(Z.string())}).passthrough(),YP=Xq.extend({method:Z.literal("notifications/progress"),params:xK.merge(UZ).extend({progressToken:Q1})}),a3=S6.extend({params:e6.extend({cursor:Z.optional(qP)}).optional()}),B3=F6.extend({nextCursor:Z.optional(qP)}),fP=Z.object({uri:Z.string(),mimeType:Z.optional(Z.string()),_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),$P=fP.extend({text:Z.string()}),Q4=Z.string().refine((q)=>{try{return atob(q),!0}catch(_){return!1}},{message:"Invalid Base64 string"}),wP=fP.extend({blob:Q4}),OP=cK.extend({uri:Z.string(),description:Z.optional(Z.string()),mimeType:Z.optional(Z.string()),_meta:Z.optional(Z.object({}).passthrough())}),sZ=cK.extend({uriTemplate:Z.string(),description:Z.optional(Z.string()),mimeType:Z.optional(Z.string()),_meta:Z.optional(Z.object({}).passthrough())}),QZ=a3.extend({method:Z.literal("resources/list")}),qk=B3.extend({resources:Z.array(OP)}),_k=a3.extend({method:Z.literal("resources/templates/list")}),Kk=B3.extend({resourceTemplates:Z.array(sZ)}),jk=S6.extend({method:Z.literal("resources/read"),params:e6.extend({uri:Z.string()})}),Pk=F6.extend({contents:Z.array(Z.union([$P,wP]))}),Yk=Xq.extend({method:Z.literal("notifications/resources/list_changed")}),fk=S6.extend({method:Z.literal("resources/subscribe"),params:e6.extend({uri:Z.string()})}),$k=S6.extend({method:Z.literal("resources/unsubscribe"),params:e6.extend({uri:Z.string()})}),wk=Xq.extend({method:Z.literal("notifications/resources/updated"),params:xK.extend({uri:Z.string()})}),Ok=Z.object({name:Z.string(),description:Z.optional(Z.string()),required:Z.optional(Z.boolean())}).passthrough(),vk=cK.extend({description:Z.optional(Z.string()),arguments:Z.optional(Z.array(Ok)),_meta:Z.optional(Z.object({}).passthrough())}),zk=a3.extend({method:Z.literal("prompts/list")}),Wk=B3.extend({prompts:Z.array(vk)}),Jk=S6.extend({method:Z.literal("prompts/get"),params:e6.extend({name:Z.string(),arguments:Z.optional(Z.record(Z.string()))})}),q2=Z.object({type:Z.literal("text"),text:Z.string(),_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),_2=Z.object({type:Z.literal("image"),data:Q4,mimeType:Z.string(),_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),K2=Z.object({type:Z.literal("audio"),data:Q4,mimeType:Z.string(),_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),Hk=Z.object({type:Z.literal("resource"),resource:Z.union([$P,wP]),_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),Tk=OP.extend({type:Z.literal("resource_link")}),vP=Z.union([q2,_2,K2,Tk,Hk]),Zk=Z.object({role:Z.enum(["user","assistant"]),content:vP}).passthrough(),kk=F6.extend({description:Z.optional(Z.string()),messages:Z.array(Zk)}),Xk=Xq.extend({method:Z.literal("notifications/prompts/list_changed")}),Ak=Z.object({title:Z.optional(Z.string()),readOnlyHint:Z.optional(Z.boolean()),destructiveHint:Z.optional(Z.boolean()),idempotentHint:Z.optional(Z.boolean()),openWorldHint:Z.optional(Z.boolean())}).passthrough(),Gk=cK.extend({description:Z.optional(Z.string()),inputSchema:Z.object({type:Z.literal("object"),properties:Z.optional(Z.object({}).passthrough()),required:Z.optional(Z.array(Z.string()))}).passthrough(),outputSchema:Z.optional(Z.object({type:Z.literal("object"),properties:Z.optional(Z.object({}).passthrough()),required:Z.optional(Z.array(Z.string()))}).passthrough()),annotations:Z.optional(Ak),_meta:Z.optional(Z.object({}).passthrough())}),uk=a3.extend({method:Z.literal("tools/list")}),hk=B3.extend({tools:Z.array(Gk)}),zP=F6.extend({content:Z.array(vP).default([]),structuredContent:Z.object({}).passthrough().optional(),isError:Z.optional(Z.boolean())}),DC=zP.or(F6.extend({toolResult:Z.unknown()})),Dk=S6.extend({method:Z.literal("tools/call"),params:e6.extend({name:Z.string(),arguments:Z.optional(Z.record(Z.unknown()))})}),Ck=Xq.extend({method:Z.literal("notifications/tools/list_changed")}),WP=Z.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),Vk=S6.extend({method:Z.literal("logging/setLevel"),params:e6.extend({level:WP})}),Mk=Xq.extend({method:Z.literal("notifications/message"),params:xK.extend({level:WP,logger:Z.optional(Z.string()),data:Z.unknown()})}),Nk=Z.object({name:Z.string().optional()}).passthrough(),bk=Z.object({hints:Z.optional(Z.array(Nk)),costPriority:Z.optional(Z.number().min(0).max(1)),speedPriority:Z.optional(Z.number().min(0).max(1)),intelligencePriority:Z.optional(Z.number().min(0).max(1))}).passthrough(),Sk=Z.object({role:Z.enum(["user","assistant"]),content:Z.union([q2,_2,K2])}).passthrough(),Ek=S6.extend({method:Z.literal("sampling/createMessage"),params:e6.extend({messages:Z.array(Sk),systemPrompt:Z.optional(Z.string()),includeContext:Z.optional(Z.enum(["none","thisServer","allServers"])),temperature:Z.optional(Z.number()),maxTokens:Z.number().int(),stopSequences:Z.optional(Z.array(Z.string())),metadata:Z.optional(Z.object({}).passthrough()),modelPreferences:Z.optional(bk)})}),Rk=F6.extend({model:Z.string(),stopReason:Z.optional(Z.enum(["endTurn","stopSequence","maxTokens"]).or(Z.string())),role:Z.enum(["user","assistant"]),content:Z.discriminatedUnion("type",[q2,_2,K2])}),mk=Z.object({type:Z.literal("boolean"),title:Z.optional(Z.string()),description:Z.optional(Z.string()),default:Z.optional(Z.boolean())}).passthrough(),Ik=Z.object({type:Z.literal("string"),title:Z.optional(Z.string()),description:Z.optional(Z.string()),minLength:Z.optional(Z.number()),maxLength:Z.optional(Z.number()),format:Z.optional(Z.enum(["email","uri","date","date-time"]))}).passthrough(),gk=Z.object({type:Z.enum(["number","integer"]),title:Z.optional(Z.string()),description:Z.optional(Z.string()),minimum:Z.optional(Z.number()),maximum:Z.optional(Z.number())}).passthrough(),yk=Z.object({type:Z.literal("string"),title:Z.optional(Z.string()),description:Z.optional(Z.string()),enum:Z.array(Z.string()),enumNames:Z.optional(Z.array(Z.string()))}).passthrough(),dk=Z.union([mk,Ik,gk,yk]),pk=S6.extend({method:Z.literal("elicitation/create"),params:e6.extend({message:Z.string(),requestedSchema:Z.object({type:Z.literal("object"),properties:Z.record(Z.string(),dk),required:Z.optional(Z.array(Z.string()))}).passthrough()})}),Lk=F6.extend({action:Z.enum(["accept","decline","cancel"]),content:Z.optional(Z.record(Z.string(),Z.unknown()))}),lk=Z.object({type:Z.literal("ref/resource"),uri:Z.string()}).passthrough(),nk=Z.object({type:Z.literal("ref/prompt"),name:Z.string()}).passthrough(),xk=S6.extend({method:Z.literal("completion/complete"),params:e6.extend({ref:Z.union([nk,lk]),argument:Z.object({name:Z.string(),value:Z.string()}).passthrough(),context:Z.optional(Z.object({arguments:Z.optional(Z.record(Z.string(),Z.string()))}))})}),ck=F6.extend({completion:Z.object({values:Z.array(Z.string()).max(100),total:Z.optional(Z.number().int()),hasMore:Z.optional(Z.boolean())}).passthrough()}),rk=Z.object({uri:Z.string().startsWith("file://"),name:Z.optional(Z.string()),_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),ik=S6.extend({method:Z.literal("roots/list")}),ok=F6.extend({roots:Z.array(rk)}),ak=Xq.extend({method:Z.literal("notifications/roots/list_changed")}),CC=Z.union([PP,BZ,xk,Vk,Jk,zk,QZ,_k,jk,fk,$k,Dk,uk]),VC=Z.union([KP,YP,FZ,ak]),MC=Z.union([_P,Rk,Lk,ok]),NC=Z.union([PP,Ek,pk,ik]),bC=Z.union([KP,YP,Mk,wk,Yk,Ck,Xk]),SC=Z.union([_P,eZ,ck,kk,Wk,qk,Kk,Pk,zP,hk]),EC=xH(hT(),1),RC=Symbol("Let zodToJsonSchema decide on which parser to use"),mC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");(function(q){q.Completable="McpCompletable"})(t4||(t4={}));e4=class e4 extends k8{_parse(q){let{ctx:_}=this._processInputParams(q),j=_.data;return this._def.type._parse({data:j,path:_.path,parent:_})}unwrap(){return this._def.type}};e4.create=(q,_)=>{return new e4({type:q,typeName:t4.Completable,complete:_.complete,...Bk(_)})}});var HP={};uK(HP,{version:()=>Fk,type:()=>sk,scripts:()=>qX,repository:()=>PX,publishConfig:()=>$X,name:()=>ek,main:()=>Qk,license:()=>jX,keywords:()=>_X,homepage:()=>YX,files:()=>WX,engines:()=>vX,devDependencies:()=>OX,description:()=>Uk,dependencies:()=>wX,default:()=>JX,bugs:()=>fX,bin:()=>zX,author:()=>KX});var ek="claude-mem",Fk="3.5.4",Uk="Memory compression system for Claude Code - persist context across sessions",sk="module",Qk="claude-mem",qX,_X,KX="Alex Newman",jX="SEE LICENSE IN LICENSE",PX,YX="https://github.com/thedotmack/claude-mem#readme",fX,$X,wX,OX,vX,zX,WX,JX;var TP=Y6(()=>{qX={dev:"tsx src/bin/cli.ts","dev:install":"node dist/claude-mem.min.js install --force","dev:status":"node dist/claude-mem.min.js status","dev:compress":"node dist/claude-mem.min.js compress","dev:load":"node dist/claude-mem.min.js load-context","dev:uninstall":"node dist/claude-mem.min.js uninstall",build:"./scripts/build-minified.sh","test:watch":"npm test -- --watch",lint:"eslint 'src/**/*.ts' 'hooks/**/*.ts' 'test/**/*.ts'","lint:fix":"npm run lint -- --fix",format:"prettier --write 'src/**/*.ts' 'hooks/**/*.ts' 'test/**/*.ts'",publish:"./scripts/npm-publish.sh && cd releases/npm-package && npm publish","publish:latest":"npm version patch && ./scripts/npm-publish.sh && cd releases/npm-package && npm publish"},_X=["claude","claude-code","mcp","memory","compression","knowledge-graph","transcript","cli","typescript","bun"],PX={type:"git",url:"https://github.com/thedotmack/claude-mem.git"},fX={url:"https://github.com/thedotmack/claude-mem/issues"},$X={access:"public",registry:"https://registry.npmjs.org/"},wX={"@anthropic-ai/claude-code":"^1.0.88","@clack/prompts":"^0.11.0","@modelcontextprotocol/sdk":"^0.5.0",boxen:"^8.0.1",chalk:"^5.6.0",chromadb:"^3.0.14",commander:"^14.0.0",glob:"^11.0.3","gradient-string":"^3.0.0",handlebars:"^4.7.8","oh-my-logo":"^0.3.2"},OX={"@types/chai":"^4.3.0","@types/handlebars":"^4.0.40","@types/node":"^20.0.0","@typescript-eslint/eslint-plugin":"^6.0.0","@typescript-eslint/parser":"^6.0.0",chai:"^4.3.0",eslint:"^8.0.0",prettier:"^3.0.0","ts-node":"^10.0.0",tsx:"^4.20.5",typescript:"^5.0.0"},vX={node:">=18.0.0",bun:">=1.0.0"},zX={"claude-mem":"dist/claude-mem.min.js"},WX=["dist","hooks","commands","docs"],JX={name:ek,version:Fk,description:Uk,type:sk,main:Qk,scripts:qX,keywords:_X,author:KX,license:jX,repository:PX,homepage:YX,bugs:fX,publishConfig:$X,dependencies:wX,devDependencies:OX,engines:vX,bin:zX,files:WX}});import{join as B8,dirname as t3,sep as HX}from"path";import{homedir as P2}from"os";import{existsSync as rK,statSync as TX}from"fs";import{execSync as ZX}from"child_process";import{fileURLToPath as kX}from"url";class _8{static instance=null;_dataDirectory=null;_packageRoot=null;_claudeConfigDirectory=null;static getInstance(){if(!_8.instance)_8.instance=new _8;return _8.instance}getDataDirectory(){if(this._dataDirectory)return this._dataDirectory;return this._dataDirectory=process.env.CLAUDE_MEM_DATA_DIR||B8(P2(),".claude-mem"),this._dataDirectory}getArchivesDirectory(){return B8(this.getDataDirectory(),"archives")}getHooksDirectory(){return B8(this.getDataDirectory(),"hooks")}getLogsDirectory(){return B8(this.getDataDirectory(),"logs")}getIndexDirectory(){return this.getDataDirectory()}getIndexPath(){return B8(this.getIndexDirectory(),"claude-mem-index.jsonl")}getTrashDirectory(){return B8(this.getDataDirectory(),"trash")}getBackupsDirectory(){return B8(this.getDataDirectory(),"backups")}getChromaDirectory(){return B8(this.getDataDirectory(),"chroma")}getProjectArchiveDirectory(q){return B8(this.getArchivesDirectory(),q)}getUserSettingsPath(){return B8(this.getDataDirectory(),"settings.json")}getClaudeConfigDirectory(){if(this._claudeConfigDirectory)return this._claudeConfigDirectory;return this._claudeConfigDirectory=process.env.CLAUDE_CONFIG_DIR||B8(P2(),".claude"),this._claudeConfigDirectory}getClaudeSettingsPath(){return B8(this.getClaudeConfigDirectory(),"settings.json")}getClaudeCommandsDirectory(){return B8(this.getClaudeConfigDirectory(),"commands")}getClaudeMdPath(){return B8(this.getClaudeConfigDirectory(),"CLAUDE.md")}getMcpConfigPath(){return B8(P2(),".claude.json")}getProjectMcpConfigPath(){return B8(process.cwd(),".mcp.json")}getPackageRoot(){if(this._packageRoot)return this._packageRoot;try{let j=u6.resolve("/Users/alexnewman/Scripts/claude-mem-source/package.json");return this._packageRoot=t3(j),this._packageRoot}catch{}let q=kX(import.meta.url),_=t3(q);for(let j=0;j<10;j++){let K=B8(_,"package.json");if(rK(K))try{if(u6(K).name==="claude-mem")return this._packageRoot=_,this._packageRoot}catch{}let Y=t3(_);if(Y===_)break;_=Y}try{let j=ZX("npm list -g claude-mem --json 2>/dev/null || npm list claude-mem --json 2>/dev/null",{encoding:"utf8"}),K=JSON.parse(j);if(K.dependencies?.["claude-mem"]?.resolved)return this._packageRoot=t3(K.dependencies["claude-mem"].resolved),this._packageRoot}catch{}throw new Error("Cannot locate claude-mem package root. Ensure claude-mem is properly installed.")}findPackageHooksDirectory(){let q=this.getPackageRoot(),_=B8(q,"hooks"),j=["pre-compact.js","session-start.js"];for(let K of j)if(!rK(B8(_,K)))throw new Error(`Package hooks directory missing required file: ${K}`);return _}findPackageCommandsDirectory(){let q=this.getPackageRoot(),_=B8(q,"commands"),j=["save.md"];for(let K of j)if(!rK(B8(_,K)))throw new Error(`Package commands directory missing required file: ${K}`);return _}ensureDirectory(q){if(!rK(q))u6("fs").mkdirSync(q,{recursive:!0})}ensureDirectories(q){q.forEach((_)=>this.ensureDirectory(_))}ensureAllDataDirectories(){this.ensureDirectories([this.getDataDirectory(),this.getArchivesDirectory(),this.getHooksDirectory(),this.getLogsDirectory(),this.getTrashDirectory(),this.getBackupsDirectory(),this.getChromaDirectory()])}ensureAllClaudeDirectories(){this.ensureDirectories([this.getClaudeConfigDirectory(),this.getClaudeCommandsDirectory()])}static extractProjectName(q){let _=q.split(HX),j=["src","lib","app","project","workspace"];for(let K=_.length-1;K>=0;K--)if(j.includes(_[K])&&K>0)return _[K-1];if(_.length>1)return _[_.length-2];return"unknown-project"}static getCurrentProjectName(){return u6("path").basename(process.cwd())}static createBackupFilename(q){let _=new Date().toISOString().replace(/[:.]/g,"-").replace("T","_").slice(0,19);return`${q}.backup.${_}`}static isPathAccessible(q){try{return rK(q)&&TX(q).isDirectory()}catch{return!1}}static getDataDirectory(){return _8.getInstance().getDataDirectory()}static getArchivesDirectory(){return _8.getInstance().getArchivesDirectory()}static getHooksDirectory(){return _8.getInstance().getHooksDirectory()}static getLogsDirectory(){return _8.getInstance().getLogsDirectory()}static getClaudeSettingsPath(){return _8.getInstance().getClaudeSettingsPath()}static getClaudeMdPath(){return _8.getInstance().getClaudeMdPath()}static findPackageHooksDirectory(){return _8.getInstance().findPackageHooksDirectory()}static findPackageCommandsDirectory(){return _8.getInstance().findPackageCommandsDirectory()}}var lC;var C6=Y6(()=>{lC=_8.getInstance()});class Iq{pathDiscovery;constructor(){this.pathDiscovery=_8.getInstance()}getConfigDir(){return this.pathDiscovery.getDataDirectory()}getIndexDir(){return this.pathDiscovery.getIndexDirectory()}getIndexPath(){return this.pathDiscovery.getIndexPath()}getArchiveDir(){return this.pathDiscovery.getArchivesDirectory()}getProjectArchiveDir(q){return this.pathDiscovery.getProjectArchiveDirectory(q)}getLogsDir(){return this.pathDiscovery.getLogsDirectory()}static ensureDirectory(q){_8.getInstance().ensureDirectory(q)}static ensureDirectories(q){_8.getInstance().ensureDirectories(q)}static extractProjectName(q){return _8.extractProjectName(q)}static getCurrentProjectPrefix(){return _8.getCurrentProjectName()}static getCurrentProjectName(){return _8.getCurrentProjectName()}}var Y2=Y6(()=>{C6()});function GX(q,_,j,K){let Y={projectPrefix:q,sessionId:_,timestamp:j||new Date().toISOString(),archiveFilename:K||`${_}.jsonl.archive`};return AX(Y)}function kP(q,_,j,K){let Y=GX(j,_,K),f=` +`))}this.transport.endInput()}catch(_){if(!(_ instanceof L_))throw _}}handleHookCallbacks(q,_,j,K){let Y=this.hookCallbacks.get(q);if(!Y)throw new Error(`No hook callback found for ID: ${q}`);return Y(_,j,{signal:K})}sendMcpServerMessageToCli(q,_){if("id"in _&&_.id!==null&&_.id!==void 0){let j=`${q}:${_.id}`,K=this.pendingMcpResponses.get(j);if(K){K.resolve(_),this.pendingMcpResponses.delete(j);return}}throw new Error("No pending request found")}handleMcpControlRequest(q,_,j){let K="id"in _.message?_.message.id:null,Y=`${q}:${K}`;return new Promise((f,P)=>{let $=null,O=()=>{if($)clearTimeout($);this.pendingMcpResponses.delete(Y)},w=(z)=>{O(),f(z)},v=(z)=>{O(),P(z)};if(this.pendingMcpResponses.set(Y,{resolve:w,reject:v}),j.onmessage)j.onmessage(_.message);else{O(),P(new Error("No message handler registered"));return}$=setTimeout(()=>{if(this.pendingMcpResponses.has(Y))O(),P(new Error("Request timeout"))},30000)})}};Z={};cH(Z,{void:()=>TZ,util:()=>u8,unknown:()=>JZ,union:()=>AZ,undefined:()=>vZ,tuple:()=>hZ,transformer:()=>I1,symbol:()=>OZ,string:()=>F1,strictObject:()=>XZ,setErrorMap:()=>gT,set:()=>VZ,record:()=>DZ,quotelessJson:()=>mT,promise:()=>RZ,preprocess:()=>gZ,pipeline:()=>yZ,ostring:()=>dZ,optional:()=>mZ,onumber:()=>pZ,oboolean:()=>LZ,objectUtil:()=>i4,object:()=>kZ,number:()=>U1,nullable:()=>IZ,null:()=>zZ,never:()=>HZ,nativeEnum:()=>EZ,nan:()=>fZ,map:()=>CZ,makeIssue:()=>x3,literal:()=>bZ,lazy:()=>NZ,late:()=>PZ,isValid:()=>j_,isDirty:()=>a4,isAsync:()=>gK,isAborted:()=>o4,intersection:()=>uZ,instanceof:()=>YZ,getParsedType:()=>Rq,getErrorMap:()=>n3,function:()=>MZ,enum:()=>SZ,effect:()=>I1,discriminatedUnion:()=>GZ,defaultErrorMap:()=>x_,datetimeRegex:()=>B1,date:()=>wZ,custom:()=>e1,coerce:()=>lZ,boolean:()=>s1,bigint:()=>$Z,array:()=>ZZ,any:()=>WZ,addIssueToContext:()=>F,ZodVoid:()=>dK,ZodUnknown:()=>lq,ZodUnion:()=>o_,ZodUndefined:()=>r_,ZodType:()=>k8,ZodTuple:()=>kq,ZodTransformer:()=>t6,ZodSymbol:()=>yK,ZodString:()=>Pq,ZodSet:()=>f_,ZodSchema:()=>k8,ZodRecord:()=>pK,ZodReadonly:()=>s_,ZodPromise:()=>$_,ZodPipeline:()=>nK,ZodParsedType:()=>Q,ZodOptional:()=>fq,ZodObject:()=>i8,ZodNumber:()=>nq,ZodNullable:()=>mq,ZodNull:()=>i_,ZodNever:()=>Zq,ZodNativeEnum:()=>e_,ZodNaN:()=>lK,ZodMap:()=>LK,ZodLiteral:()=>t_,ZodLazy:()=>B_,ZodIssueCode:()=>t,ZodIntersection:()=>a_,ZodFunction:()=>n_,ZodFirstPartyTypeKind:()=>z8,ZodError:()=>g6,ZodEnum:()=>cq,ZodEffects:()=>t6,ZodDiscriminatedUnion:()=>c3,ZodDefault:()=>F_,ZodDate:()=>P_,ZodCatch:()=>U_,ZodBranded:()=>r3,ZodBoolean:()=>c_,ZodBigInt:()=>xq,ZodArray:()=>Yq,ZodAny:()=>Y_,Schema:()=>k8,ParseStatus:()=>H6,OK:()=>D6,NEVER:()=>nZ,INVALID:()=>O8,EMPTY_PATH:()=>yT,DIRTY:()=>l_,BRAND:()=>jZ});(function(q){q.assertEqual=(Y)=>{};function _(Y){}q.assertIs=_;function j(Y){throw new Error}q.assertNever=j,q.arrayToEnum=(Y)=>{let f={};for(let P of Y)f[P]=P;return f},q.getValidEnumValues=(Y)=>{let f=q.objectKeys(Y).filter(($)=>typeof Y[Y[$]]!=="number"),P={};for(let $ of f)P[$]=Y[$];return q.objectValues(P)},q.objectValues=(Y)=>{return q.objectKeys(Y).map(function(f){return Y[f]})},q.objectKeys=typeof Object.keys==="function"?(Y)=>Object.keys(Y):(Y)=>{let f=[];for(let P in Y)if(Object.prototype.hasOwnProperty.call(Y,P))f.push(P);return f},q.find=(Y,f)=>{for(let P of Y)if(f(P))return P;return},q.isInteger=typeof Number.isInteger==="function"?(Y)=>Number.isInteger(Y):(Y)=>typeof Y==="number"&&Number.isFinite(Y)&&Math.floor(Y)===Y;function K(Y,f=" | "){return Y.map((P)=>typeof P==="string"?`'${P}'`:P).join(f)}q.joinValues=K,q.jsonStringifyReplacer=(Y,f)=>{if(typeof f==="bigint")return f.toString();return f}})(u8||(u8={}));(function(q){q.mergeShapes=(_,j)=>{return{..._,...j}}})(i4||(i4={}));Q=u8.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),t=u8.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);g6=class g6 extends Error{get errors(){return this.issues}constructor(q){super();this.issues=[],this.addIssue=(j)=>{this.issues=[...this.issues,j]},this.addIssues=(j=[])=>{this.issues=[...this.issues,...j]};let _=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,_);else this.__proto__=_;this.name="ZodError",this.issues=q}format(q){let _=q||function(Y){return Y.message},j={_errors:[]},K=(Y)=>{for(let f of Y.issues)if(f.code==="invalid_union")f.unionErrors.map(K);else if(f.code==="invalid_return_type")K(f.returnTypeError);else if(f.code==="invalid_arguments")K(f.argumentsError);else if(f.path.length===0)j._errors.push(_(f));else{let P=j,$=0;while($_.message){let _={},j=[];for(let K of this.issues)if(K.path.length>0){let Y=K.path[0];_[Y]=_[Y]||[],_[Y].push(q(K))}else j.push(q(K));return{formErrors:j,fieldErrors:_}}get formErrors(){return this.flatten()}};g6.create=(q)=>{return new g6(q)};x_=IT,i1=x_;yT=[];O8=Object.freeze({status:"aborted"});(function(q){q.errToObj=(_)=>typeof _==="string"?{message:_}:_||{},q.toString=(_)=>typeof _==="string"?_:_?.message})(P8||(P8={}));dT=/^c[^\s-]{8,}$/i,pT=/^[0-9a-z]+$/,LT=/^[0-9A-HJKMNP-TV-Z]{26}$/i,lT=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,nT=/^[a-z0-9_-]{21}$/i,xT=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,cT=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,rT=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,oT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,aT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,BT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,tT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,eT=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,FT=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,UT=new RegExp(`^${o1}$`);Pq=class Pq extends k8{_parse(q){if(this._def.coerce)q.data=String(q.data);if(this._getType(q)!==Q.string){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_type,expected:Q.string,received:Y.parsedType}),O8}let j=new H6,K=void 0;for(let Y of this._def.checks)if(Y.kind==="min"){if(q.data.lengthY.value)K=this._getOrReturnCtx(q,K),F(K,{code:t.too_big,maximum:Y.value,type:"string",inclusive:!0,exact:!1,message:Y.message}),j.dirty()}else if(Y.kind==="length"){let f=q.data.length>Y.value,P=q.data.lengthq.test(K),{validation:_,code:t.invalid_string,...P8.errToObj(j)})}_addCheck(q){return new Pq({...this._def,checks:[...this._def.checks,q]})}email(q){return this._addCheck({kind:"email",...P8.errToObj(q)})}url(q){return this._addCheck({kind:"url",...P8.errToObj(q)})}emoji(q){return this._addCheck({kind:"emoji",...P8.errToObj(q)})}uuid(q){return this._addCheck({kind:"uuid",...P8.errToObj(q)})}nanoid(q){return this._addCheck({kind:"nanoid",...P8.errToObj(q)})}cuid(q){return this._addCheck({kind:"cuid",...P8.errToObj(q)})}cuid2(q){return this._addCheck({kind:"cuid2",...P8.errToObj(q)})}ulid(q){return this._addCheck({kind:"ulid",...P8.errToObj(q)})}base64(q){return this._addCheck({kind:"base64",...P8.errToObj(q)})}base64url(q){return this._addCheck({kind:"base64url",...P8.errToObj(q)})}jwt(q){return this._addCheck({kind:"jwt",...P8.errToObj(q)})}ip(q){return this._addCheck({kind:"ip",...P8.errToObj(q)})}cidr(q){return this._addCheck({kind:"cidr",...P8.errToObj(q)})}datetime(q){if(typeof q==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:q});return this._addCheck({kind:"datetime",precision:typeof q?.precision==="undefined"?null:q?.precision,offset:q?.offset??!1,local:q?.local??!1,...P8.errToObj(q?.message)})}date(q){return this._addCheck({kind:"date",message:q})}time(q){if(typeof q==="string")return this._addCheck({kind:"time",precision:null,message:q});return this._addCheck({kind:"time",precision:typeof q?.precision==="undefined"?null:q?.precision,...P8.errToObj(q?.message)})}duration(q){return this._addCheck({kind:"duration",...P8.errToObj(q)})}regex(q,_){return this._addCheck({kind:"regex",regex:q,...P8.errToObj(_)})}includes(q,_){return this._addCheck({kind:"includes",value:q,position:_?.position,...P8.errToObj(_?.message)})}startsWith(q,_){return this._addCheck({kind:"startsWith",value:q,...P8.errToObj(_)})}endsWith(q,_){return this._addCheck({kind:"endsWith",value:q,...P8.errToObj(_)})}min(q,_){return this._addCheck({kind:"min",value:q,...P8.errToObj(_)})}max(q,_){return this._addCheck({kind:"max",value:q,...P8.errToObj(_)})}length(q,_){return this._addCheck({kind:"length",value:q,...P8.errToObj(_)})}nonempty(q){return this.min(1,P8.errToObj(q))}trim(){return new Pq({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Pq({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Pq({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((q)=>q.kind==="datetime")}get isDate(){return!!this._def.checks.find((q)=>q.kind==="date")}get isTime(){return!!this._def.checks.find((q)=>q.kind==="time")}get isDuration(){return!!this._def.checks.find((q)=>q.kind==="duration")}get isEmail(){return!!this._def.checks.find((q)=>q.kind==="email")}get isURL(){return!!this._def.checks.find((q)=>q.kind==="url")}get isEmoji(){return!!this._def.checks.find((q)=>q.kind==="emoji")}get isUUID(){return!!this._def.checks.find((q)=>q.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((q)=>q.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((q)=>q.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((q)=>q.kind==="cuid2")}get isULID(){return!!this._def.checks.find((q)=>q.kind==="ulid")}get isIP(){return!!this._def.checks.find((q)=>q.kind==="ip")}get isCIDR(){return!!this._def.checks.find((q)=>q.kind==="cidr")}get isBase64(){return!!this._def.checks.find((q)=>q.kind==="base64")}get isBase64url(){return!!this._def.checks.find((q)=>q.kind==="base64url")}get minLength(){let q=null;for(let _ of this._def.checks)if(_.kind==="min"){if(q===null||_.value>q)q=_.value}return q}get maxLength(){let q=null;for(let _ of this._def.checks)if(_.kind==="max"){if(q===null||_.value{return new Pq({checks:[],typeName:z8.ZodString,coerce:q?.coerce??!1,...Z8(q)})};nq=class nq extends k8{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(q){if(this._def.coerce)q.data=Number(q.data);if(this._getType(q)!==Q.number){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_type,expected:Q.number,received:Y.parsedType}),O8}let j=void 0,K=new H6;for(let Y of this._def.checks)if(Y.kind==="int"){if(!u8.isInteger(q.data))j=this._getOrReturnCtx(q,j),F(j,{code:t.invalid_type,expected:"integer",received:"float",message:Y.message}),K.dirty()}else if(Y.kind==="min"){if(Y.inclusive?q.dataY.value:q.data>=Y.value)j=this._getOrReturnCtx(q,j),F(j,{code:t.too_big,maximum:Y.value,type:"number",inclusive:Y.inclusive,exact:!1,message:Y.message}),K.dirty()}else if(Y.kind==="multipleOf"){if(KZ(q.data,Y.value)!==0)j=this._getOrReturnCtx(q,j),F(j,{code:t.not_multiple_of,multipleOf:Y.value,message:Y.message}),K.dirty()}else if(Y.kind==="finite"){if(!Number.isFinite(q.data))j=this._getOrReturnCtx(q,j),F(j,{code:t.not_finite,message:Y.message}),K.dirty()}else u8.assertNever(Y);return{status:K.value,value:q.data}}gte(q,_){return this.setLimit("min",q,!0,P8.toString(_))}gt(q,_){return this.setLimit("min",q,!1,P8.toString(_))}lte(q,_){return this.setLimit("max",q,!0,P8.toString(_))}lt(q,_){return this.setLimit("max",q,!1,P8.toString(_))}setLimit(q,_,j,K){return new nq({...this._def,checks:[...this._def.checks,{kind:q,value:_,inclusive:j,message:P8.toString(K)}]})}_addCheck(q){return new nq({...this._def,checks:[...this._def.checks,q]})}int(q){return this._addCheck({kind:"int",message:P8.toString(q)})}positive(q){return this._addCheck({kind:"min",value:0,inclusive:!1,message:P8.toString(q)})}negative(q){return this._addCheck({kind:"max",value:0,inclusive:!1,message:P8.toString(q)})}nonpositive(q){return this._addCheck({kind:"max",value:0,inclusive:!0,message:P8.toString(q)})}nonnegative(q){return this._addCheck({kind:"min",value:0,inclusive:!0,message:P8.toString(q)})}multipleOf(q,_){return this._addCheck({kind:"multipleOf",value:q,message:P8.toString(_)})}finite(q){return this._addCheck({kind:"finite",message:P8.toString(q)})}safe(q){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:P8.toString(q)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:P8.toString(q)})}get minValue(){let q=null;for(let _ of this._def.checks)if(_.kind==="min"){if(q===null||_.value>q)q=_.value}return q}get maxValue(){let q=null;for(let _ of this._def.checks)if(_.kind==="max"){if(q===null||_.valueq.kind==="int"||q.kind==="multipleOf"&&u8.isInteger(q.value))}get isFinite(){let q=null,_=null;for(let j of this._def.checks)if(j.kind==="finite"||j.kind==="int"||j.kind==="multipleOf")return!0;else if(j.kind==="min"){if(_===null||j.value>_)_=j.value}else if(j.kind==="max"){if(q===null||j.value{return new nq({checks:[],typeName:z8.ZodNumber,coerce:q?.coerce||!1,...Z8(q)})};xq=class xq extends k8{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(q){if(this._def.coerce)try{q.data=BigInt(q.data)}catch{return this._getInvalidInput(q)}if(this._getType(q)!==Q.bigint)return this._getInvalidInput(q);let j=void 0,K=new H6;for(let Y of this._def.checks)if(Y.kind==="min"){if(Y.inclusive?q.dataY.value:q.data>=Y.value)j=this._getOrReturnCtx(q,j),F(j,{code:t.too_big,type:"bigint",maximum:Y.value,inclusive:Y.inclusive,message:Y.message}),K.dirty()}else if(Y.kind==="multipleOf"){if(q.data%Y.value!==BigInt(0))j=this._getOrReturnCtx(q,j),F(j,{code:t.not_multiple_of,multipleOf:Y.value,message:Y.message}),K.dirty()}else u8.assertNever(Y);return{status:K.value,value:q.data}}_getInvalidInput(q){let _=this._getOrReturnCtx(q);return F(_,{code:t.invalid_type,expected:Q.bigint,received:_.parsedType}),O8}gte(q,_){return this.setLimit("min",q,!0,P8.toString(_))}gt(q,_){return this.setLimit("min",q,!1,P8.toString(_))}lte(q,_){return this.setLimit("max",q,!0,P8.toString(_))}lt(q,_){return this.setLimit("max",q,!1,P8.toString(_))}setLimit(q,_,j,K){return new xq({...this._def,checks:[...this._def.checks,{kind:q,value:_,inclusive:j,message:P8.toString(K)}]})}_addCheck(q){return new xq({...this._def,checks:[...this._def.checks,q]})}positive(q){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:P8.toString(q)})}negative(q){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:P8.toString(q)})}nonpositive(q){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:P8.toString(q)})}nonnegative(q){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:P8.toString(q)})}multipleOf(q,_){return this._addCheck({kind:"multipleOf",value:q,message:P8.toString(_)})}get minValue(){let q=null;for(let _ of this._def.checks)if(_.kind==="min"){if(q===null||_.value>q)q=_.value}return q}get maxValue(){let q=null;for(let _ of this._def.checks)if(_.kind==="max"){if(q===null||_.value{return new xq({checks:[],typeName:z8.ZodBigInt,coerce:q?.coerce??!1,...Z8(q)})};c_=class c_ extends k8{_parse(q){if(this._def.coerce)q.data=Boolean(q.data);if(this._getType(q)!==Q.boolean){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:Q.boolean,received:j.parsedType}),O8}return D6(q.data)}};c_.create=(q)=>{return new c_({typeName:z8.ZodBoolean,coerce:q?.coerce||!1,...Z8(q)})};P_=class P_ extends k8{_parse(q){if(this._def.coerce)q.data=new Date(q.data);if(this._getType(q)!==Q.date){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_type,expected:Q.date,received:Y.parsedType}),O8}if(Number.isNaN(q.data.getTime())){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_date}),O8}let j=new H6,K=void 0;for(let Y of this._def.checks)if(Y.kind==="min"){if(q.data.getTime()Y.value)K=this._getOrReturnCtx(q,K),F(K,{code:t.too_big,message:Y.message,inclusive:!0,exact:!1,maximum:Y.value,type:"date"}),j.dirty()}else u8.assertNever(Y);return{status:j.value,value:new Date(q.data.getTime())}}_addCheck(q){return new P_({...this._def,checks:[...this._def.checks,q]})}min(q,_){return this._addCheck({kind:"min",value:q.getTime(),message:P8.toString(_)})}max(q,_){return this._addCheck({kind:"max",value:q.getTime(),message:P8.toString(_)})}get minDate(){let q=null;for(let _ of this._def.checks)if(_.kind==="min"){if(q===null||_.value>q)q=_.value}return q!=null?new Date(q):null}get maxDate(){let q=null;for(let _ of this._def.checks)if(_.kind==="max"){if(q===null||_.value{return new P_({checks:[],coerce:q?.coerce||!1,typeName:z8.ZodDate,...Z8(q)})};yK=class yK extends k8{_parse(q){if(this._getType(q)!==Q.symbol){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:Q.symbol,received:j.parsedType}),O8}return D6(q.data)}};yK.create=(q)=>{return new yK({typeName:z8.ZodSymbol,...Z8(q)})};r_=class r_ extends k8{_parse(q){if(this._getType(q)!==Q.undefined){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:Q.undefined,received:j.parsedType}),O8}return D6(q.data)}};r_.create=(q)=>{return new r_({typeName:z8.ZodUndefined,...Z8(q)})};i_=class i_ extends k8{_parse(q){if(this._getType(q)!==Q.null){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:Q.null,received:j.parsedType}),O8}return D6(q.data)}};i_.create=(q)=>{return new i_({typeName:z8.ZodNull,...Z8(q)})};Y_=class Y_ extends k8{constructor(){super(...arguments);this._any=!0}_parse(q){return D6(q.data)}};Y_.create=(q)=>{return new Y_({typeName:z8.ZodAny,...Z8(q)})};lq=class lq extends k8{constructor(){super(...arguments);this._unknown=!0}_parse(q){return D6(q.data)}};lq.create=(q)=>{return new lq({typeName:z8.ZodUnknown,...Z8(q)})};Zq=class Zq extends k8{_parse(q){let _=this._getOrReturnCtx(q);return F(_,{code:t.invalid_type,expected:Q.never,received:_.parsedType}),O8}};Zq.create=(q)=>{return new Zq({typeName:z8.ZodNever,...Z8(q)})};dK=class dK extends k8{_parse(q){if(this._getType(q)!==Q.undefined){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:Q.void,received:j.parsedType}),O8}return D6(q.data)}};dK.create=(q)=>{return new dK({typeName:z8.ZodVoid,...Z8(q)})};Yq=class Yq extends k8{_parse(q){let{ctx:_,status:j}=this._processInputParams(q),K=this._def;if(_.parsedType!==Q.array)return F(_,{code:t.invalid_type,expected:Q.array,received:_.parsedType}),O8;if(K.exactLength!==null){let f=_.data.length>K.exactLength.value,P=_.data.lengthK.maxLength.value)F(_,{code:t.too_big,maximum:K.maxLength.value,type:"array",inclusive:!0,exact:!1,message:K.maxLength.message}),j.dirty()}if(_.common.async)return Promise.all([..._.data].map((f,P)=>{return K.type._parseAsync(new $q(_,f,_.path,P))})).then((f)=>{return H6.mergeArray(j,f)});let Y=[..._.data].map((f,P)=>{return K.type._parseSync(new $q(_,f,_.path,P))});return H6.mergeArray(j,Y)}get element(){return this._def.type}min(q,_){return new Yq({...this._def,minLength:{value:q,message:P8.toString(_)}})}max(q,_){return new Yq({...this._def,maxLength:{value:q,message:P8.toString(_)}})}length(q,_){return new Yq({...this._def,exactLength:{value:q,message:P8.toString(_)}})}nonempty(q){return this.min(1,q)}};Yq.create=(q,_)=>{return new Yq({type:q,minLength:null,maxLength:null,exactLength:null,typeName:z8.ZodArray,...Z8(_)})};i8=class i8 extends k8{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let q=this._def.shape(),_=u8.objectKeys(q);return this._cached={shape:q,keys:_},this._cached}_parse(q){if(this._getType(q)!==Q.object){let O=this._getOrReturnCtx(q);return F(O,{code:t.invalid_type,expected:Q.object,received:O.parsedType}),O8}let{status:j,ctx:K}=this._processInputParams(q),{shape:Y,keys:f}=this._getCached(),P=[];if(!(this._def.catchall instanceof Zq&&this._def.unknownKeys==="strip")){for(let O in K.data)if(!f.includes(O))P.push(O)}let $=[];for(let O of f){let w=Y[O],v=K.data[O];$.push({key:{status:"valid",value:O},value:w._parse(new $q(K,v,K.path,O)),alwaysSet:O in K.data})}if(this._def.catchall instanceof Zq){let O=this._def.unknownKeys;if(O==="passthrough")for(let w of P)$.push({key:{status:"valid",value:w},value:{status:"valid",value:K.data[w]}});else if(O==="strict"){if(P.length>0)F(K,{code:t.unrecognized_keys,keys:P}),j.dirty()}else if(O==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let O=this._def.catchall;for(let w of P){let v=K.data[w];$.push({key:{status:"valid",value:w},value:O._parse(new $q(K,v,K.path,w)),alwaysSet:w in K.data})}}if(K.common.async)return Promise.resolve().then(async()=>{let O=[];for(let w of $){let v=await w.key,z=await w.value;O.push({key:v,value:z,alwaysSet:w.alwaysSet})}return O}).then((O)=>{return H6.mergeObjectSync(j,O)});else return H6.mergeObjectSync(j,$)}get shape(){return this._def.shape()}strict(q){return P8.errToObj,new i8({...this._def,unknownKeys:"strict",...q!==void 0?{errorMap:(_,j)=>{let K=this._def.errorMap?.(_,j).message??j.defaultError;if(_.code==="unrecognized_keys")return{message:P8.errToObj(q).message??K};return{message:K}}}:{}})}strip(){return new i8({...this._def,unknownKeys:"strip"})}passthrough(){return new i8({...this._def,unknownKeys:"passthrough"})}extend(q){return new i8({...this._def,shape:()=>({...this._def.shape(),...q})})}merge(q){return new i8({unknownKeys:q._def.unknownKeys,catchall:q._def.catchall,shape:()=>({...this._def.shape(),...q._def.shape()}),typeName:z8.ZodObject})}setKey(q,_){return this.augment({[q]:_})}catchall(q){return new i8({...this._def,catchall:q})}pick(q){let _={};for(let j of u8.objectKeys(q))if(q[j]&&this.shape[j])_[j]=this.shape[j];return new i8({...this._def,shape:()=>_})}omit(q){let _={};for(let j of u8.objectKeys(this.shape))if(!q[j])_[j]=this.shape[j];return new i8({...this._def,shape:()=>_})}deepPartial(){return p_(this)}partial(q){let _={};for(let j of u8.objectKeys(this.shape)){let K=this.shape[j];if(q&&!q[j])_[j]=K;else _[j]=K.optional()}return new i8({...this._def,shape:()=>_})}required(q){let _={};for(let j of u8.objectKeys(this.shape))if(q&&!q[j])_[j]=this.shape[j];else{let Y=this.shape[j];while(Y instanceof fq)Y=Y._def.innerType;_[j]=Y}return new i8({...this._def,shape:()=>_})}keyof(){return t1(u8.objectKeys(this.shape))}};i8.create=(q,_)=>{return new i8({shape:()=>q,unknownKeys:"strip",catchall:Zq.create(),typeName:z8.ZodObject,...Z8(_)})};i8.strictCreate=(q,_)=>{return new i8({shape:()=>q,unknownKeys:"strict",catchall:Zq.create(),typeName:z8.ZodObject,...Z8(_)})};i8.lazycreate=(q,_)=>{return new i8({shape:q,unknownKeys:"strip",catchall:Zq.create(),typeName:z8.ZodObject,...Z8(_)})};o_=class o_ extends k8{_parse(q){let{ctx:_}=this._processInputParams(q),j=this._def.options;function K(Y){for(let P of Y)if(P.result.status==="valid")return P.result;for(let P of Y)if(P.result.status==="dirty")return _.common.issues.push(...P.ctx.common.issues),P.result;let f=Y.map((P)=>new g6(P.ctx.common.issues));return F(_,{code:t.invalid_union,unionErrors:f}),O8}if(_.common.async)return Promise.all(j.map(async(Y)=>{let f={..._,common:{..._.common,issues:[]},parent:null};return{result:await Y._parseAsync({data:_.data,path:_.path,parent:f}),ctx:f}})).then(K);else{let Y=void 0,f=[];for(let $ of j){let O={..._,common:{..._.common,issues:[]},parent:null},w=$._parseSync({data:_.data,path:_.path,parent:O});if(w.status==="valid")return w;else if(w.status==="dirty"&&!Y)Y={result:w,ctx:O};if(O.common.issues.length)f.push(O.common.issues)}if(Y)return _.common.issues.push(...Y.ctx.common.issues),Y.result;let P=f.map(($)=>new g6($));return F(_,{code:t.invalid_union,unionErrors:P}),O8}}get options(){return this._def.options}};o_.create=(q,_)=>{return new o_({options:q,typeName:z8.ZodUnion,...Z8(_)})};c3=class c3 extends k8{_parse(q){let{ctx:_}=this._processInputParams(q);if(_.parsedType!==Q.object)return F(_,{code:t.invalid_type,expected:Q.object,received:_.parsedType}),O8;let j=this.discriminator,K=_.data[j],Y=this.optionsMap.get(K);if(!Y)return F(_,{code:t.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[j]}),O8;if(_.common.async)return Y._parseAsync({data:_.data,path:_.path,parent:_});else return Y._parseSync({data:_.data,path:_.path,parent:_})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(q,_,j){let K=new Map;for(let Y of _){let f=Eq(Y.shape[q]);if(!f.length)throw new Error(`A discriminator value for key \`${q}\` could not be extracted from all schema options`);for(let P of f){if(K.has(P))throw new Error(`Discriminator property ${String(q)} has duplicate value ${String(P)}`);K.set(P,Y)}}return new c3({typeName:z8.ZodDiscriminatedUnion,discriminator:q,options:_,optionsMap:K,...Z8(j)})}};a_=class a_ extends k8{_parse(q){let{status:_,ctx:j}=this._processInputParams(q),K=(Y,f)=>{if(o4(Y)||o4(f))return O8;let P=B4(Y.value,f.value);if(!P.valid)return F(j,{code:t.invalid_intersection_types}),O8;if(a4(Y)||a4(f))_.dirty();return{status:_.value,value:P.data}};if(j.common.async)return Promise.all([this._def.left._parseAsync({data:j.data,path:j.path,parent:j}),this._def.right._parseAsync({data:j.data,path:j.path,parent:j})]).then(([Y,f])=>K(Y,f));else return K(this._def.left._parseSync({data:j.data,path:j.path,parent:j}),this._def.right._parseSync({data:j.data,path:j.path,parent:j}))}};a_.create=(q,_,j)=>{return new a_({left:q,right:_,typeName:z8.ZodIntersection,...Z8(j)})};kq=class kq extends k8{_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.parsedType!==Q.array)return F(j,{code:t.invalid_type,expected:Q.array,received:j.parsedType}),O8;if(j.data.lengththis._def.items.length)F(j,{code:t.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_.dirty();let Y=[...j.data].map((f,P)=>{let $=this._def.items[P]||this._def.rest;if(!$)return null;return $._parse(new $q(j,f,j.path,P))}).filter((f)=>!!f);if(j.common.async)return Promise.all(Y).then((f)=>{return H6.mergeArray(_,f)});else return H6.mergeArray(_,Y)}get items(){return this._def.items}rest(q){return new kq({...this._def,rest:q})}};kq.create=(q,_)=>{if(!Array.isArray(q))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new kq({items:q,typeName:z8.ZodTuple,rest:null,...Z8(_)})};pK=class pK extends k8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.parsedType!==Q.object)return F(j,{code:t.invalid_type,expected:Q.object,received:j.parsedType}),O8;let K=[],Y=this._def.keyType,f=this._def.valueType;for(let P in j.data)K.push({key:Y._parse(new $q(j,P,j.path,P)),value:f._parse(new $q(j,j.data[P],j.path,P)),alwaysSet:P in j.data});if(j.common.async)return H6.mergeObjectAsync(_,K);else return H6.mergeObjectSync(_,K)}get element(){return this._def.valueType}static create(q,_,j){if(_ instanceof k8)return new pK({keyType:q,valueType:_,typeName:z8.ZodRecord,...Z8(j)});return new pK({keyType:Pq.create(),valueType:q,typeName:z8.ZodRecord,...Z8(_)})}};LK=class LK extends k8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.parsedType!==Q.map)return F(j,{code:t.invalid_type,expected:Q.map,received:j.parsedType}),O8;let K=this._def.keyType,Y=this._def.valueType,f=[...j.data.entries()].map(([P,$],O)=>{return{key:K._parse(new $q(j,P,j.path,[O,"key"])),value:Y._parse(new $q(j,$,j.path,[O,"value"]))}});if(j.common.async){let P=new Map;return Promise.resolve().then(async()=>{for(let $ of f){let O=await $.key,w=await $.value;if(O.status==="aborted"||w.status==="aborted")return O8;if(O.status==="dirty"||w.status==="dirty")_.dirty();P.set(O.value,w.value)}return{status:_.value,value:P}})}else{let P=new Map;for(let $ of f){let{key:O,value:w}=$;if(O.status==="aborted"||w.status==="aborted")return O8;if(O.status==="dirty"||w.status==="dirty")_.dirty();P.set(O.value,w.value)}return{status:_.value,value:P}}}};LK.create=(q,_,j)=>{return new LK({valueType:_,keyType:q,typeName:z8.ZodMap,...Z8(j)})};f_=class f_ extends k8{_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.parsedType!==Q.set)return F(j,{code:t.invalid_type,expected:Q.set,received:j.parsedType}),O8;let K=this._def;if(K.minSize!==null){if(j.data.sizeK.maxSize.value)F(j,{code:t.too_big,maximum:K.maxSize.value,type:"set",inclusive:!0,exact:!1,message:K.maxSize.message}),_.dirty()}let Y=this._def.valueType;function f($){let O=new Set;for(let w of $){if(w.status==="aborted")return O8;if(w.status==="dirty")_.dirty();O.add(w.value)}return{status:_.value,value:O}}let P=[...j.data.values()].map(($,O)=>Y._parse(new $q(j,$,j.path,O)));if(j.common.async)return Promise.all(P).then(($)=>f($));else return f(P)}min(q,_){return new f_({...this._def,minSize:{value:q,message:P8.toString(_)}})}max(q,_){return new f_({...this._def,maxSize:{value:q,message:P8.toString(_)}})}size(q,_){return this.min(q,_).max(q,_)}nonempty(q){return this.min(1,q)}};f_.create=(q,_)=>{return new f_({valueType:q,minSize:null,maxSize:null,typeName:z8.ZodSet,...Z8(_)})};n_=class n_ extends k8{constructor(){super(...arguments);this.validate=this.implement}_parse(q){let{ctx:_}=this._processInputParams(q);if(_.parsedType!==Q.function)return F(_,{code:t.invalid_type,expected:Q.function,received:_.parsedType}),O8;function j(P,$){return x3({data:P,path:_.path,errorMaps:[_.common.contextualErrorMap,_.schemaErrorMap,n3(),x_].filter((O)=>!!O),issueData:{code:t.invalid_arguments,argumentsError:$}})}function K(P,$){return x3({data:P,path:_.path,errorMaps:[_.common.contextualErrorMap,_.schemaErrorMap,n3(),x_].filter((O)=>!!O),issueData:{code:t.invalid_return_type,returnTypeError:$}})}let Y={errorMap:_.common.contextualErrorMap},f=_.data;if(this._def.returns instanceof $_){let P=this;return D6(async function(...$){let O=new g6([]),w=await P._def.args.parseAsync($,Y).catch((W)=>{throw O.addIssue(j($,W)),O}),v=await Reflect.apply(f,this,w);return await P._def.returns._def.type.parseAsync(v,Y).catch((W)=>{throw O.addIssue(K(v,W)),O})})}else{let P=this;return D6(function(...$){let O=P._def.args.safeParse($,Y);if(!O.success)throw new g6([j($,O.error)]);let w=Reflect.apply(f,this,O.data),v=P._def.returns.safeParse(w,Y);if(!v.success)throw new g6([K(w,v.error)]);return v.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...q){return new n_({...this._def,args:kq.create(q).rest(lq.create())})}returns(q){return new n_({...this._def,returns:q})}implement(q){return this.parse(q)}strictImplement(q){return this.parse(q)}static create(q,_,j){return new n_({args:q?q:kq.create([]).rest(lq.create()),returns:_||lq.create(),typeName:z8.ZodFunction,...Z8(j)})}};B_=class B_ extends k8{get schema(){return this._def.getter()}_parse(q){let{ctx:_}=this._processInputParams(q);return this._def.getter()._parse({data:_.data,path:_.path,parent:_})}};B_.create=(q,_)=>{return new B_({getter:q,typeName:z8.ZodLazy,...Z8(_)})};t_=class t_ extends k8{_parse(q){if(q.data!==this._def.value){let _=this._getOrReturnCtx(q);return F(_,{received:_.data,code:t.invalid_literal,expected:this._def.value}),O8}return{status:"valid",value:q.data}}get value(){return this._def.value}};t_.create=(q,_)=>{return new t_({value:q,typeName:z8.ZodLiteral,...Z8(_)})};cq=class cq extends k8{_parse(q){if(typeof q.data!=="string"){let _=this._getOrReturnCtx(q),j=this._def.values;return F(_,{expected:u8.joinValues(j),received:_.parsedType,code:t.invalid_type}),O8}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(q.data)){let _=this._getOrReturnCtx(q),j=this._def.values;return F(_,{received:_.data,code:t.invalid_enum_value,options:j}),O8}return D6(q.data)}get options(){return this._def.values}get enum(){let q={};for(let _ of this._def.values)q[_]=_;return q}get Values(){let q={};for(let _ of this._def.values)q[_]=_;return q}get Enum(){let q={};for(let _ of this._def.values)q[_]=_;return q}extract(q,_=this._def){return cq.create(q,{...this._def,..._})}exclude(q,_=this._def){return cq.create(this.options.filter((j)=>!q.includes(j)),{...this._def,..._})}};cq.create=t1;e_=class e_ extends k8{_parse(q){let _=u8.getValidEnumValues(this._def.values),j=this._getOrReturnCtx(q);if(j.parsedType!==Q.string&&j.parsedType!==Q.number){let K=u8.objectValues(_);return F(j,{expected:u8.joinValues(K),received:j.parsedType,code:t.invalid_type}),O8}if(!this._cache)this._cache=new Set(u8.getValidEnumValues(this._def.values));if(!this._cache.has(q.data)){let K=u8.objectValues(_);return F(j,{received:j.data,code:t.invalid_enum_value,options:K}),O8}return D6(q.data)}get enum(){return this._def.values}};e_.create=(q,_)=>{return new e_({values:q,typeName:z8.ZodNativeEnum,...Z8(_)})};$_=class $_ extends k8{unwrap(){return this._def.type}_parse(q){let{ctx:_}=this._processInputParams(q);if(_.parsedType!==Q.promise&&_.common.async===!1)return F(_,{code:t.invalid_type,expected:Q.promise,received:_.parsedType}),O8;let j=_.parsedType===Q.promise?_.data:Promise.resolve(_.data);return D6(j.then((K)=>{return this._def.type.parseAsync(K,{path:_.path,errorMap:_.common.contextualErrorMap})}))}};$_.create=(q,_)=>{return new $_({type:q,typeName:z8.ZodPromise,...Z8(_)})};t6=class t6 extends k8{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===z8.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(q){let{status:_,ctx:j}=this._processInputParams(q),K=this._def.effect||null,Y={addIssue:(f)=>{if(F(j,f),f.fatal)_.abort();else _.dirty()},get path(){return j.path}};if(Y.addIssue=Y.addIssue.bind(Y),K.type==="preprocess"){let f=K.transform(j.data,Y);if(j.common.async)return Promise.resolve(f).then(async(P)=>{if(_.value==="aborted")return O8;let $=await this._def.schema._parseAsync({data:P,path:j.path,parent:j});if($.status==="aborted")return O8;if($.status==="dirty")return l_($.value);if(_.value==="dirty")return l_($.value);return $});else{if(_.value==="aborted")return O8;let P=this._def.schema._parseSync({data:f,path:j.path,parent:j});if(P.status==="aborted")return O8;if(P.status==="dirty")return l_(P.value);if(_.value==="dirty")return l_(P.value);return P}}if(K.type==="refinement"){let f=(P)=>{let $=K.refinement(P,Y);if(j.common.async)return Promise.resolve($);if($ instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return P};if(j.common.async===!1){let P=this._def.schema._parseSync({data:j.data,path:j.path,parent:j});if(P.status==="aborted")return O8;if(P.status==="dirty")_.dirty();return f(P.value),{status:_.value,value:P.value}}else return this._def.schema._parseAsync({data:j.data,path:j.path,parent:j}).then((P)=>{if(P.status==="aborted")return O8;if(P.status==="dirty")_.dirty();return f(P.value).then(()=>{return{status:_.value,value:P.value}})})}if(K.type==="transform")if(j.common.async===!1){let f=this._def.schema._parseSync({data:j.data,path:j.path,parent:j});if(!j_(f))return O8;let P=K.transform(f.value,Y);if(P instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:_.value,value:P}}else return this._def.schema._parseAsync({data:j.data,path:j.path,parent:j}).then((f)=>{if(!j_(f))return O8;return Promise.resolve(K.transform(f.value,Y)).then((P)=>({status:_.value,value:P}))});u8.assertNever(K)}};t6.create=(q,_,j)=>{return new t6({schema:q,typeName:z8.ZodEffects,effect:_,...Z8(j)})};t6.createWithPreprocess=(q,_,j)=>{return new t6({schema:_,effect:{type:"preprocess",transform:q},typeName:z8.ZodEffects,...Z8(j)})};fq=class fq extends k8{_parse(q){if(this._getType(q)===Q.undefined)return D6(void 0);return this._def.innerType._parse(q)}unwrap(){return this._def.innerType}};fq.create=(q,_)=>{return new fq({innerType:q,typeName:z8.ZodOptional,...Z8(_)})};mq=class mq extends k8{_parse(q){if(this._getType(q)===Q.null)return D6(null);return this._def.innerType._parse(q)}unwrap(){return this._def.innerType}};mq.create=(q,_)=>{return new mq({innerType:q,typeName:z8.ZodNullable,...Z8(_)})};F_=class F_ extends k8{_parse(q){let{ctx:_}=this._processInputParams(q),j=_.data;if(_.parsedType===Q.undefined)j=this._def.defaultValue();return this._def.innerType._parse({data:j,path:_.path,parent:_})}removeDefault(){return this._def.innerType}};F_.create=(q,_)=>{return new F_({innerType:q,typeName:z8.ZodDefault,defaultValue:typeof _.default==="function"?_.default:()=>_.default,...Z8(_)})};U_=class U_ extends k8{_parse(q){let{ctx:_}=this._processInputParams(q),j={..._,common:{..._.common,issues:[]}},K=this._def.innerType._parse({data:j.data,path:j.path,parent:{...j}});if(gK(K))return K.then((Y)=>{return{status:"valid",value:Y.status==="valid"?Y.value:this._def.catchValue({get error(){return new g6(j.common.issues)},input:j.data})}});else return{status:"valid",value:K.status==="valid"?K.value:this._def.catchValue({get error(){return new g6(j.common.issues)},input:j.data})}}removeCatch(){return this._def.innerType}};U_.create=(q,_)=>{return new U_({innerType:q,typeName:z8.ZodCatch,catchValue:typeof _.catch==="function"?_.catch:()=>_.catch,...Z8(_)})};lK=class lK extends k8{_parse(q){if(this._getType(q)!==Q.nan){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:Q.nan,received:j.parsedType}),O8}return{status:"valid",value:q.data}}};lK.create=(q)=>{return new lK({typeName:z8.ZodNaN,...Z8(q)})};jZ=Symbol("zod_brand");r3=class r3 extends k8{_parse(q){let{ctx:_}=this._processInputParams(q),j=_.data;return this._def.type._parse({data:j,path:_.path,parent:_})}unwrap(){return this._def.type}};nK=class nK extends k8{_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.common.async)return(async()=>{let Y=await this._def.in._parseAsync({data:j.data,path:j.path,parent:j});if(Y.status==="aborted")return O8;if(Y.status==="dirty")return _.dirty(),l_(Y.value);else return this._def.out._parseAsync({data:Y.value,path:j.path,parent:j})})();else{let K=this._def.in._parseSync({data:j.data,path:j.path,parent:j});if(K.status==="aborted")return O8;if(K.status==="dirty")return _.dirty(),{status:"dirty",value:K.value};else return this._def.out._parseSync({data:K.value,path:j.path,parent:j})}}static create(q,_){return new nK({in:q,out:_,typeName:z8.ZodPipeline})}};s_=class s_ extends k8{_parse(q){let _=this._def.innerType._parse(q),j=(K)=>{if(j_(K))K.value=Object.freeze(K.value);return K};return gK(_)?_.then((K)=>j(K)):j(_)}unwrap(){return this._def.innerType}};s_.create=(q,_)=>{return new s_({innerType:q,typeName:z8.ZodReadonly,...Z8(_)})};PZ={object:i8.lazycreate};(function(q){q.ZodString="ZodString",q.ZodNumber="ZodNumber",q.ZodNaN="ZodNaN",q.ZodBigInt="ZodBigInt",q.ZodBoolean="ZodBoolean",q.ZodDate="ZodDate",q.ZodSymbol="ZodSymbol",q.ZodUndefined="ZodUndefined",q.ZodNull="ZodNull",q.ZodAny="ZodAny",q.ZodUnknown="ZodUnknown",q.ZodNever="ZodNever",q.ZodVoid="ZodVoid",q.ZodArray="ZodArray",q.ZodObject="ZodObject",q.ZodUnion="ZodUnion",q.ZodDiscriminatedUnion="ZodDiscriminatedUnion",q.ZodIntersection="ZodIntersection",q.ZodTuple="ZodTuple",q.ZodRecord="ZodRecord",q.ZodMap="ZodMap",q.ZodSet="ZodSet",q.ZodFunction="ZodFunction",q.ZodLazy="ZodLazy",q.ZodLiteral="ZodLiteral",q.ZodEnum="ZodEnum",q.ZodEffects="ZodEffects",q.ZodNativeEnum="ZodNativeEnum",q.ZodOptional="ZodOptional",q.ZodNullable="ZodNullable",q.ZodDefault="ZodDefault",q.ZodCatch="ZodCatch",q.ZodPromise="ZodPromise",q.ZodBranded="ZodBranded",q.ZodPipeline="ZodPipeline",q.ZodReadonly="ZodReadonly"})(z8||(z8={}));F1=Pq.create,U1=nq.create,fZ=lK.create,$Z=xq.create,s1=c_.create,wZ=P_.create,OZ=yK.create,vZ=r_.create,zZ=i_.create,WZ=Y_.create,JZ=lq.create,HZ=Zq.create,TZ=dK.create,ZZ=Yq.create,kZ=i8.create,XZ=i8.strictCreate,AZ=o_.create,GZ=c3.create,uZ=a_.create,hZ=kq.create,DZ=pK.create,CZ=LK.create,VZ=f_.create,MZ=n_.create,NZ=B_.create,bZ=t_.create,SZ=cq.create,EZ=e_.create,RZ=$_.create,I1=t6.create,mZ=fq.create,IZ=mq.create,gZ=t6.createWithPreprocess,yZ=nK.create,lZ={string:(q)=>Pq.create({...q,coerce:!0}),number:(q)=>nq.create({...q,coerce:!0}),boolean:(q)=>c_.create({...q,coerce:!0}),bigint:(q)=>xq.create({...q,coerce:!0}),date:(q)=>P_.create({...q,coerce:!0})},nZ=O8,Q1=Z.union([Z.string(),Z.number().int()]),qP=Z.string(),xZ=Z.object({progressToken:Z.optional(Q1)}).passthrough(),e6=Z.object({_meta:Z.optional(xZ)}).passthrough(),S6=Z.object({method:Z.string(),params:Z.optional(e6)}),xK=Z.object({_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),Xq=Z.object({method:Z.string(),params:Z.optional(xK)}),F6=Z.object({_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),o3=Z.union([Z.string(),Z.number().int()]),cZ=Z.object({jsonrpc:Z.literal(i3),id:o3}).merge(S6).strict(),rZ=Z.object({jsonrpc:Z.literal(i3)}).merge(Xq).strict(),iZ=Z.object({jsonrpc:Z.literal(i3),id:o3,result:F6}).strict();(function(q){q[q.ConnectionClosed=-32000]="ConnectionClosed",q[q.RequestTimeout=-32001]="RequestTimeout",q[q.ParseError=-32700]="ParseError",q[q.InvalidRequest=-32600]="InvalidRequest",q[q.MethodNotFound=-32601]="MethodNotFound",q[q.InvalidParams=-32602]="InvalidParams",q[q.InternalError=-32603]="InternalError"})(g1||(g1={}));oZ=Z.object({jsonrpc:Z.literal(i3),id:o3,error:Z.object({code:Z.number().int(),message:Z.string(),data:Z.optional(Z.unknown())})}).strict(),hC=Z.union([cZ,rZ,iZ,oZ]),_P=F6.strict(),KP=Xq.extend({method:Z.literal("notifications/cancelled"),params:xK.extend({requestId:o3,reason:Z.string().optional()})}),cK=Z.object({name:Z.string(),title:Z.optional(Z.string())}).passthrough(),jP=cK.extend({version:Z.string()}),aZ=Z.object({experimental:Z.optional(Z.object({}).passthrough()),sampling:Z.optional(Z.object({}).passthrough()),elicitation:Z.optional(Z.object({}).passthrough()),roots:Z.optional(Z.object({listChanged:Z.optional(Z.boolean())}).passthrough())}).passthrough(),BZ=S6.extend({method:Z.literal("initialize"),params:e6.extend({protocolVersion:Z.string(),capabilities:aZ,clientInfo:jP})}),tZ=Z.object({experimental:Z.optional(Z.object({}).passthrough()),logging:Z.optional(Z.object({}).passthrough()),completions:Z.optional(Z.object({}).passthrough()),prompts:Z.optional(Z.object({listChanged:Z.optional(Z.boolean())}).passthrough()),resources:Z.optional(Z.object({subscribe:Z.optional(Z.boolean()),listChanged:Z.optional(Z.boolean())}).passthrough()),tools:Z.optional(Z.object({listChanged:Z.optional(Z.boolean())}).passthrough())}).passthrough(),eZ=F6.extend({protocolVersion:Z.string(),capabilities:tZ,serverInfo:jP,instructions:Z.optional(Z.string())}),FZ=Xq.extend({method:Z.literal("notifications/initialized")}),PP=S6.extend({method:Z.literal("ping")}),UZ=Z.object({progress:Z.number(),total:Z.optional(Z.number()),message:Z.optional(Z.string())}).passthrough(),YP=Xq.extend({method:Z.literal("notifications/progress"),params:xK.merge(UZ).extend({progressToken:Q1})}),a3=S6.extend({params:e6.extend({cursor:Z.optional(qP)}).optional()}),B3=F6.extend({nextCursor:Z.optional(qP)}),fP=Z.object({uri:Z.string(),mimeType:Z.optional(Z.string()),_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),$P=fP.extend({text:Z.string()}),Q4=Z.string().refine((q)=>{try{return atob(q),!0}catch(_){return!1}},{message:"Invalid Base64 string"}),wP=fP.extend({blob:Q4}),OP=cK.extend({uri:Z.string(),description:Z.optional(Z.string()),mimeType:Z.optional(Z.string()),_meta:Z.optional(Z.object({}).passthrough())}),sZ=cK.extend({uriTemplate:Z.string(),description:Z.optional(Z.string()),mimeType:Z.optional(Z.string()),_meta:Z.optional(Z.object({}).passthrough())}),QZ=a3.extend({method:Z.literal("resources/list")}),qk=B3.extend({resources:Z.array(OP)}),_k=a3.extend({method:Z.literal("resources/templates/list")}),Kk=B3.extend({resourceTemplates:Z.array(sZ)}),jk=S6.extend({method:Z.literal("resources/read"),params:e6.extend({uri:Z.string()})}),Pk=F6.extend({contents:Z.array(Z.union([$P,wP]))}),Yk=Xq.extend({method:Z.literal("notifications/resources/list_changed")}),fk=S6.extend({method:Z.literal("resources/subscribe"),params:e6.extend({uri:Z.string()})}),$k=S6.extend({method:Z.literal("resources/unsubscribe"),params:e6.extend({uri:Z.string()})}),wk=Xq.extend({method:Z.literal("notifications/resources/updated"),params:xK.extend({uri:Z.string()})}),Ok=Z.object({name:Z.string(),description:Z.optional(Z.string()),required:Z.optional(Z.boolean())}).passthrough(),vk=cK.extend({description:Z.optional(Z.string()),arguments:Z.optional(Z.array(Ok)),_meta:Z.optional(Z.object({}).passthrough())}),zk=a3.extend({method:Z.literal("prompts/list")}),Wk=B3.extend({prompts:Z.array(vk)}),Jk=S6.extend({method:Z.literal("prompts/get"),params:e6.extend({name:Z.string(),arguments:Z.optional(Z.record(Z.string()))})}),q2=Z.object({type:Z.literal("text"),text:Z.string(),_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),_2=Z.object({type:Z.literal("image"),data:Q4,mimeType:Z.string(),_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),K2=Z.object({type:Z.literal("audio"),data:Q4,mimeType:Z.string(),_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),Hk=Z.object({type:Z.literal("resource"),resource:Z.union([$P,wP]),_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),Tk=OP.extend({type:Z.literal("resource_link")}),vP=Z.union([q2,_2,K2,Tk,Hk]),Zk=Z.object({role:Z.enum(["user","assistant"]),content:vP}).passthrough(),kk=F6.extend({description:Z.optional(Z.string()),messages:Z.array(Zk)}),Xk=Xq.extend({method:Z.literal("notifications/prompts/list_changed")}),Ak=Z.object({title:Z.optional(Z.string()),readOnlyHint:Z.optional(Z.boolean()),destructiveHint:Z.optional(Z.boolean()),idempotentHint:Z.optional(Z.boolean()),openWorldHint:Z.optional(Z.boolean())}).passthrough(),Gk=cK.extend({description:Z.optional(Z.string()),inputSchema:Z.object({type:Z.literal("object"),properties:Z.optional(Z.object({}).passthrough()),required:Z.optional(Z.array(Z.string()))}).passthrough(),outputSchema:Z.optional(Z.object({type:Z.literal("object"),properties:Z.optional(Z.object({}).passthrough()),required:Z.optional(Z.array(Z.string()))}).passthrough()),annotations:Z.optional(Ak),_meta:Z.optional(Z.object({}).passthrough())}),uk=a3.extend({method:Z.literal("tools/list")}),hk=B3.extend({tools:Z.array(Gk)}),zP=F6.extend({content:Z.array(vP).default([]),structuredContent:Z.object({}).passthrough().optional(),isError:Z.optional(Z.boolean())}),DC=zP.or(F6.extend({toolResult:Z.unknown()})),Dk=S6.extend({method:Z.literal("tools/call"),params:e6.extend({name:Z.string(),arguments:Z.optional(Z.record(Z.unknown()))})}),Ck=Xq.extend({method:Z.literal("notifications/tools/list_changed")}),WP=Z.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),Vk=S6.extend({method:Z.literal("logging/setLevel"),params:e6.extend({level:WP})}),Mk=Xq.extend({method:Z.literal("notifications/message"),params:xK.extend({level:WP,logger:Z.optional(Z.string()),data:Z.unknown()})}),Nk=Z.object({name:Z.string().optional()}).passthrough(),bk=Z.object({hints:Z.optional(Z.array(Nk)),costPriority:Z.optional(Z.number().min(0).max(1)),speedPriority:Z.optional(Z.number().min(0).max(1)),intelligencePriority:Z.optional(Z.number().min(0).max(1))}).passthrough(),Sk=Z.object({role:Z.enum(["user","assistant"]),content:Z.union([q2,_2,K2])}).passthrough(),Ek=S6.extend({method:Z.literal("sampling/createMessage"),params:e6.extend({messages:Z.array(Sk),systemPrompt:Z.optional(Z.string()),includeContext:Z.optional(Z.enum(["none","thisServer","allServers"])),temperature:Z.optional(Z.number()),maxTokens:Z.number().int(),stopSequences:Z.optional(Z.array(Z.string())),metadata:Z.optional(Z.object({}).passthrough()),modelPreferences:Z.optional(bk)})}),Rk=F6.extend({model:Z.string(),stopReason:Z.optional(Z.enum(["endTurn","stopSequence","maxTokens"]).or(Z.string())),role:Z.enum(["user","assistant"]),content:Z.discriminatedUnion("type",[q2,_2,K2])}),mk=Z.object({type:Z.literal("boolean"),title:Z.optional(Z.string()),description:Z.optional(Z.string()),default:Z.optional(Z.boolean())}).passthrough(),Ik=Z.object({type:Z.literal("string"),title:Z.optional(Z.string()),description:Z.optional(Z.string()),minLength:Z.optional(Z.number()),maxLength:Z.optional(Z.number()),format:Z.optional(Z.enum(["email","uri","date","date-time"]))}).passthrough(),gk=Z.object({type:Z.enum(["number","integer"]),title:Z.optional(Z.string()),description:Z.optional(Z.string()),minimum:Z.optional(Z.number()),maximum:Z.optional(Z.number())}).passthrough(),yk=Z.object({type:Z.literal("string"),title:Z.optional(Z.string()),description:Z.optional(Z.string()),enum:Z.array(Z.string()),enumNames:Z.optional(Z.array(Z.string()))}).passthrough(),dk=Z.union([mk,Ik,gk,yk]),pk=S6.extend({method:Z.literal("elicitation/create"),params:e6.extend({message:Z.string(),requestedSchema:Z.object({type:Z.literal("object"),properties:Z.record(Z.string(),dk),required:Z.optional(Z.array(Z.string()))}).passthrough()})}),Lk=F6.extend({action:Z.enum(["accept","decline","cancel"]),content:Z.optional(Z.record(Z.string(),Z.unknown()))}),lk=Z.object({type:Z.literal("ref/resource"),uri:Z.string()}).passthrough(),nk=Z.object({type:Z.literal("ref/prompt"),name:Z.string()}).passthrough(),xk=S6.extend({method:Z.literal("completion/complete"),params:e6.extend({ref:Z.union([nk,lk]),argument:Z.object({name:Z.string(),value:Z.string()}).passthrough(),context:Z.optional(Z.object({arguments:Z.optional(Z.record(Z.string(),Z.string()))}))})}),ck=F6.extend({completion:Z.object({values:Z.array(Z.string()).max(100),total:Z.optional(Z.number().int()),hasMore:Z.optional(Z.boolean())}).passthrough()}),rk=Z.object({uri:Z.string().startsWith("file://"),name:Z.optional(Z.string()),_meta:Z.optional(Z.object({}).passthrough())}).passthrough(),ik=S6.extend({method:Z.literal("roots/list")}),ok=F6.extend({roots:Z.array(rk)}),ak=Xq.extend({method:Z.literal("notifications/roots/list_changed")}),CC=Z.union([PP,BZ,xk,Vk,Jk,zk,QZ,_k,jk,fk,$k,Dk,uk]),VC=Z.union([KP,YP,FZ,ak]),MC=Z.union([_P,Rk,Lk,ok]),NC=Z.union([PP,Ek,pk,ik]),bC=Z.union([KP,YP,Mk,wk,Yk,Ck,Xk]),SC=Z.union([_P,eZ,ck,kk,Wk,qk,Kk,Pk,zP,hk]),EC=xH(hT(),1),RC=Symbol("Let zodToJsonSchema decide on which parser to use"),mC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");(function(q){q.Completable="McpCompletable"})(t4||(t4={}));e4=class e4 extends k8{_parse(q){let{ctx:_}=this._processInputParams(q),j=_.data;return this._def.type._parse({data:j,path:_.path,parent:_})}unwrap(){return this._def.type}};e4.create=(q,_)=>{return new e4({type:q,typeName:t4.Completable,complete:_.complete,...Bk(_)})}});var HP={};uK(HP,{version:()=>Fk,type:()=>sk,scripts:()=>qX,repository:()=>PX,publishConfig:()=>$X,name:()=>ek,main:()=>Qk,license:()=>jX,keywords:()=>_X,homepage:()=>YX,files:()=>WX,engines:()=>vX,devDependencies:()=>OX,description:()=>Uk,dependencies:()=>wX,default:()=>JX,bugs:()=>fX,bin:()=>zX,author:()=>KX});var ek="claude-mem",Fk="3.5.5",Uk="Memory compression system for Claude Code - persist context across sessions",sk="module",Qk="claude-mem",qX,_X,KX="Alex Newman",jX="SEE LICENSE IN LICENSE",PX,YX="https://github.com/thedotmack/claude-mem#readme",fX,$X,wX,OX,vX,zX,WX,JX;var TP=Y6(()=>{qX={dev:"tsx src/bin/cli.ts","dev:install":"node dist/claude-mem.min.js install --force","dev:status":"node dist/claude-mem.min.js status","dev:compress":"node dist/claude-mem.min.js compress","dev:load":"node dist/claude-mem.min.js load-context","dev:uninstall":"node dist/claude-mem.min.js uninstall",build:"./scripts/build-minified.sh","test:watch":"npm test -- --watch",lint:"eslint 'src/**/*.ts' 'hooks/**/*.ts' 'test/**/*.ts'","lint:fix":"npm run lint -- --fix",format:"prettier --write 'src/**/*.ts' 'hooks/**/*.ts' 'test/**/*.ts'","build:npm":"./scripts/npm-publish.sh",publish:"./scripts/publish-all.sh","publish:latest":"npm version patch && ./scripts/publish-all.sh","publish:github":"./scripts/github-publish.sh"},_X=["claude","claude-code","mcp","memory","compression","knowledge-graph","transcript","cli","typescript","bun"],PX={type:"git",url:"https://github.com/thedotmack/claude-mem.git"},fX={url:"https://github.com/thedotmack/claude-mem/issues"},$X={access:"public",registry:"https://registry.npmjs.org/"},wX={"@anthropic-ai/claude-code":"^1.0.88","@clack/prompts":"^0.11.0","@modelcontextprotocol/sdk":"^0.5.0",boxen:"^8.0.1",chalk:"^5.6.0",chromadb:"^3.0.14",commander:"^14.0.0",glob:"^11.0.3","gradient-string":"^3.0.0",handlebars:"^4.7.8","oh-my-logo":"^0.3.2"},OX={"@types/chai":"^4.3.0","@types/handlebars":"^4.0.40","@types/node":"^20.0.0","@typescript-eslint/eslint-plugin":"^6.0.0","@typescript-eslint/parser":"^6.0.0",chai:"^4.3.0",eslint:"^8.0.0",prettier:"^3.0.0","ts-node":"^10.0.0",tsx:"^4.20.5",typescript:"^5.0.0"},vX={node:">=18.0.0",bun:">=1.0.0"},zX={"claude-mem":"dist/claude-mem.min.js"},WX=["dist","hooks","commands","docs"],JX={name:ek,version:Fk,description:Uk,type:sk,main:Qk,scripts:qX,keywords:_X,author:KX,license:jX,repository:PX,homepage:YX,bugs:fX,publishConfig:$X,dependencies:wX,devDependencies:OX,engines:vX,bin:zX,files:WX}});import{join as B8,dirname as t3,sep as HX}from"path";import{homedir as P2}from"os";import{existsSync as rK,statSync as TX}from"fs";import{execSync as ZX}from"child_process";import{fileURLToPath as kX}from"url";class _8{static instance=null;_dataDirectory=null;_packageRoot=null;_claudeConfigDirectory=null;static getInstance(){if(!_8.instance)_8.instance=new _8;return _8.instance}getDataDirectory(){if(this._dataDirectory)return this._dataDirectory;return this._dataDirectory=process.env.CLAUDE_MEM_DATA_DIR||B8(P2(),".claude-mem"),this._dataDirectory}getArchivesDirectory(){return B8(this.getDataDirectory(),"archives")}getHooksDirectory(){return B8(this.getDataDirectory(),"hooks")}getLogsDirectory(){return B8(this.getDataDirectory(),"logs")}getIndexDirectory(){return this.getDataDirectory()}getIndexPath(){return B8(this.getIndexDirectory(),"claude-mem-index.jsonl")}getTrashDirectory(){return B8(this.getDataDirectory(),"trash")}getBackupsDirectory(){return B8(this.getDataDirectory(),"backups")}getChromaDirectory(){return B8(this.getDataDirectory(),"chroma")}getProjectArchiveDirectory(q){return B8(this.getArchivesDirectory(),q)}getUserSettingsPath(){return B8(this.getDataDirectory(),"settings.json")}getClaudeConfigDirectory(){if(this._claudeConfigDirectory)return this._claudeConfigDirectory;return this._claudeConfigDirectory=process.env.CLAUDE_CONFIG_DIR||B8(P2(),".claude"),this._claudeConfigDirectory}getClaudeSettingsPath(){return B8(this.getClaudeConfigDirectory(),"settings.json")}getClaudeCommandsDirectory(){return B8(this.getClaudeConfigDirectory(),"commands")}getClaudeMdPath(){return B8(this.getClaudeConfigDirectory(),"CLAUDE.md")}getMcpConfigPath(){return B8(P2(),".claude.json")}getProjectMcpConfigPath(){return B8(process.cwd(),".mcp.json")}getPackageRoot(){if(this._packageRoot)return this._packageRoot;try{let j=u6.resolve("/Users/alexnewman/Scripts/claude-mem-source/package.json");return this._packageRoot=t3(j),this._packageRoot}catch{}let q=kX(import.meta.url),_=t3(q);for(let j=0;j<10;j++){let K=B8(_,"package.json");if(rK(K))try{if(u6(K).name==="claude-mem")return this._packageRoot=_,this._packageRoot}catch{}let Y=t3(_);if(Y===_)break;_=Y}try{let j=ZX("npm list -g claude-mem --json 2>/dev/null || npm list claude-mem --json 2>/dev/null",{encoding:"utf8"}),K=JSON.parse(j);if(K.dependencies?.["claude-mem"]?.resolved)return this._packageRoot=t3(K.dependencies["claude-mem"].resolved),this._packageRoot}catch{}throw new Error("Cannot locate claude-mem package root. Ensure claude-mem is properly installed.")}findPackageHooksDirectory(){let q=this.getPackageRoot(),_=B8(q,"hooks"),j=["pre-compact.js","session-start.js"];for(let K of j)if(!rK(B8(_,K)))throw new Error(`Package hooks directory missing required file: ${K}`);return _}findPackageCommandsDirectory(){let q=this.getPackageRoot(),_=B8(q,"commands"),j=["save.md"];for(let K of j)if(!rK(B8(_,K)))throw new Error(`Package commands directory missing required file: ${K}`);return _}ensureDirectory(q){if(!rK(q))u6("fs").mkdirSync(q,{recursive:!0})}ensureDirectories(q){q.forEach((_)=>this.ensureDirectory(_))}ensureAllDataDirectories(){this.ensureDirectories([this.getDataDirectory(),this.getArchivesDirectory(),this.getHooksDirectory(),this.getLogsDirectory(),this.getTrashDirectory(),this.getBackupsDirectory(),this.getChromaDirectory()])}ensureAllClaudeDirectories(){this.ensureDirectories([this.getClaudeConfigDirectory(),this.getClaudeCommandsDirectory()])}static extractProjectName(q){let _=q.split(HX),j=["src","lib","app","project","workspace"];for(let K=_.length-1;K>=0;K--)if(j.includes(_[K])&&K>0)return _[K-1];if(_.length>1)return _[_.length-2];return"unknown-project"}static getCurrentProjectName(){return u6("path").basename(process.cwd())}static createBackupFilename(q){let _=new Date().toISOString().replace(/[:.]/g,"-").replace("T","_").slice(0,19);return`${q}.backup.${_}`}static isPathAccessible(q){try{return rK(q)&&TX(q).isDirectory()}catch{return!1}}static getDataDirectory(){return _8.getInstance().getDataDirectory()}static getArchivesDirectory(){return _8.getInstance().getArchivesDirectory()}static getHooksDirectory(){return _8.getInstance().getHooksDirectory()}static getLogsDirectory(){return _8.getInstance().getLogsDirectory()}static getClaudeSettingsPath(){return _8.getInstance().getClaudeSettingsPath()}static getClaudeMdPath(){return _8.getInstance().getClaudeMdPath()}static findPackageHooksDirectory(){return _8.getInstance().findPackageHooksDirectory()}static findPackageCommandsDirectory(){return _8.getInstance().findPackageCommandsDirectory()}}var lC;var C6=Y6(()=>{lC=_8.getInstance()});class Iq{pathDiscovery;constructor(){this.pathDiscovery=_8.getInstance()}getConfigDir(){return this.pathDiscovery.getDataDirectory()}getIndexDir(){return this.pathDiscovery.getIndexDirectory()}getIndexPath(){return this.pathDiscovery.getIndexPath()}getArchiveDir(){return this.pathDiscovery.getArchivesDirectory()}getProjectArchiveDir(q){return this.pathDiscovery.getProjectArchiveDirectory(q)}getLogsDir(){return this.pathDiscovery.getLogsDirectory()}static ensureDirectory(q){_8.getInstance().ensureDirectory(q)}static ensureDirectories(q){_8.getInstance().ensureDirectories(q)}static extractProjectName(q){return _8.extractProjectName(q)}static getCurrentProjectPrefix(){return _8.getCurrentProjectName()}static getCurrentProjectName(){return _8.getCurrentProjectName()}}var Y2=Y6(()=>{C6()});function GX(q,_,j,K){let Y={projectPrefix:q,sessionId:_,timestamp:j||new Date().toISOString(),archiveFilename:K||`${_}.jsonl.archive`};return AX(Y)}function kP(q,_,j,K){let Y=GX(j,_,K),f=` RESPONSE FORMAT: After storing memories in Chroma, return EXACTLY this JSON structure wrapped in tags: @@ -283,7 +283,7 @@ ${a.default.gray(iq)} ${q} `).filter((w)=>w.trim());if(Y.length===0){if(q.format==="session-start")console.log(IK("NO_MEMORIES",q.project||"this project"));return}let f=[];for(let w of Y)try{if(!w.trim().startsWith("{"))continue;let v=JSON.parse(w);f.push(v)}catch(v){continue}if(f.length===0){if(q.format==="session-start")console.log(IK("NO_MEMORIES",q.project||"this project"));return}let P=f;if(q.project)P=f.filter((w)=>w.project===q.project);let $=q.format==="session-start"?30:10,O=P.slice(-$);if(q.format==="session-start"){let w="recently",v=O.map((z)=>{return z.timestamp?new Date(z.timestamp):null}).filter((z)=>z!==null).sort((z,W)=>W.getTime()-z.getTime());if(v.length>0)w=h1(v[0]);C1({projectName:q.project||"your project",memoryCount:O.length,lastSessionTime:w,recentObjects:O})}else if(q.format==="json")console.log(JSON.stringify(O));else console.log(l3("Context loading",O.length,"recent memories found")),O.forEach((w)=>{if(w.type==="memory")console.log(`${w.text} | ${w.document_id} | ${w.keywords}`);else if(w.type==="overview")console.log(`**Overview:** ${w.content}`);else if(w.type==="session")console.log(`# Session: ${w.session_id} [${w.timestamp}]`);else console.log(JSON.stringify(w))});if(q.format!=="json"){let w=sG();if(!w.isEmpty){let v=UG(w.totalSize);console.log(`\uD83D\uDDD1️ Trash – ${w.folderCount} folders | ${w.fileCount} files | ${v} – use \`$ claude-mem restore\` for more options.`)}}}catch(K){let Y=K instanceof Error?K.message:String(K);if(q.format==="session-start")console.log(IK("CONNECTION_FAILED",Y));else console.log(d_("Context loading",Y,"Check file permissions and try again"))}}var j9=Y6(()=>{C6();x4()});var h$={};uK(h$,{viewTrash:()=>Qh});import{readdirSync as X$,statSync as A$}from"fs";import{join as G$}from"path";function sh(q){let _=q.lastIndexOf(".");if(_===-1)return{name:q,timestamp:0};let j=parseInt(q.substring(_+1));if(isNaN(j))return{name:q,timestamp:0};return{name:q.substring(0,_),timestamp:j}}function k$(q){if(q===0)return"0 B";let _=1024,j=["B","KB","MB","GB"],K=Math.floor(Math.log(q)/Math.log(_));return parseFloat((q/Math.pow(_,K)).toFixed(2))+" "+j[K]}function u$(q){let _=0,j=X$(q);for(let K of j){let Y=G$(q,K),f=A$(Y);if(f.isDirectory())_+=u$(Y);else _+=f.size}return _}async function Qh(){let q=_8.getInstance().getTrashDirectory();try{let _=X$(q);if(_.length===0){Q8.info("\uD83D\uDDD1️ Trash is empty");return}let j=_.map((P)=>{let $=G$(q,P),O=A$($),{name:w,timestamp:v}=sh(P),z=O.isDirectory()?u$($):O.size;return{originalName:w,trashedName:P,size:z,trashedAt:new Date(v),isDirectory:O.isDirectory()}});j.sort((P,$)=>$.trashedAt.getTime()-P.trashedAt.getTime()),console.log(` \uD83D\uDDD1️ Trash Contents `),console.log("─".repeat(80));let K=0,Y=0,f=0;for(let P of j){if(K+=P.size,P.isDirectory)Y++;else f++;let $=P.isDirectory?"\uD83D\uDCC1":"\uD83D\uDCC4",O=P.trashedAt.toLocaleString(),w=k$(P.size);console.log(`${$} ${P.originalName}`),console.log(` Size: ${w} | Trashed: ${O}`),console.log(` ID: ${P.trashedName}`),console.log()}console.log("─".repeat(80)),console.log(`Total: ${Y} folders, ${f} files (${k$(K)})`),console.log(` -To restore files: claude-mem restore`),console.log("To empty trash: claude-mem trash empty")}catch(_){if(_.code==="ENOENT")Q8.info("\uD83D\uDDD1️ Trash is empty");else Q8.error("Failed to read trash directory"),console.error(_)}}var D$=Y6(()=>{KK();C6()});var V$={};uK(V$,{emptyTrash:()=>PD});import{rmSync as qD,readdirSync as _D,existsSync as KD,statSync as jD}from"fs";import{join as C$}from"path";async function PD(q={}){let _=_8.getInstance().getTrashDirectory();if(!KD(_)){Q8.info("\uD83D\uDDD1️ Trash is already empty");return}try{let j=_D(_);if(j.length===0){Q8.info("\uD83D\uDDD1️ Trash is already empty");return}let K=0,Y=0;for(let P of j){let $=C$(_,P);if(jD($).isDirectory())K++;else Y++}if(!q.force){let P=await gq({message:`Permanently delete ${K} folders and ${Y} files from trash?`,initialValue:!1});if(K6(P)||!P){Q8.info("Cancelled - trash not emptied");return}}let f=Y7();f.start("Emptying trash...");for(let P of j){let $=C$(_,P);qD($,{recursive:!0,force:!0})}f.stop(`\uD83D\uDDD1️ Trash emptied - permanently deleted ${K} folders and ${Y} files`)}catch(j){Q8.error("Failed to empty trash"),console.error(j),process.exit(1)}}var M$=Y6(()=>{KK();C6()});var y7={};uK(y7,{sessionStartHook:()=>fD,sessionEndHook:()=>$D,preCompactHook:()=>YD});import{basename as N$}from"path";async function YD(){try{let q="";process.stdin.setEncoding("utf8");for await(let j of process.stdin)q+=j;let _;if(q)try{_=JSON.parse(q).transcript_path}catch(j){_=q.trim()}if(!_)_=process.env.TRANSCRIPT_PATH||process.argv[2];if(!_){console.log("\uD83D\uDDDC️ Compressing session transcript..."),console.log("❌ No transcript path provided to pre-compact hook"),console.log("Hook data received:",q||"none"),console.log("Environment TRANSCRIPT_PATH:",process.env.TRANSCRIPT_PATH||"not set"),console.log("Command line args:",process.argv.slice(2));return}await oK(_,{dryRun:!1})}catch(q){console.error("Pre-compact hook failed:",q.message),process.exit(1)}}async function fD(){try{let q="";process.stdin.setEncoding("utf8");for await(let j of process.stdin)q+=j;let _;if(q)try{let j=JSON.parse(q);if(j.cwd)_=N$(j.cwd)}catch(j){console.error("Failed to parse session-start hook data:",j)}if(!_)_=N$(process.cwd());await T7({format:"session-start",count:"10",project:_})}catch(q){console.error("Session-start hook failed:",q.message),process.exit(1)}}async function $D(){try{let q="";process.stdin.setEncoding("utf8");for await(let _ of process.stdin)q+=_;if(q)try{let _=JSON.parse(q);if(_.reason==="clear"&&_.transcript_path)console.log("\uD83D\uDDDC️ Compressing current session before /clear..."),await oK(_.transcript_path,{dryRun:!1})}catch(_){console.error("Failed to parse hook data:",_)}console.log("Session ended successfully")}catch(q){console.error("Session-end hook failed:",q.message),process.exit(1)}}var d7=Y6(()=>{w2();j9()});var P5=o6(j5(),1),{program:VD,createCommand:MD,createArgument:ND,createOption:bD,CommanderError:SD,InvalidArgumentError:ED,InvalidOptionArgumentError:RD,Command:Y5,Argument:mD,Option:ID,Help:gD}=P5.default;import{readFileSync as cw,existsSync as rw}from"fs";import{join as iw,dirname as ow}from"path";import{fileURLToPath as aw}from"url";var f5="claude-mem",$5="3.5.4",w5="Memory compression system for Claude Code - persist context across sessions",O5=f5,v5=$5,z5=w5;try{let q=aw(import.meta.url),_=ow(q),j=iw(_,"..","..","package.json");if(rw(j)){let K=JSON.parse(cw(j,"utf-8"));O5=K.name||f5,v5=K.version||$5,z5=K.description||w5}}catch{}var pq=O5,W5=v5,J5=z5;w2();KK();import{readFileSync as YK,writeFileSync as H_,existsSync as R8,chmodSync as DG,mkdirSync as $K,copyFileSync as J_,statSync as CG,readdirSync as VG}from"fs";import{join as D8,dirname as fK}from"path";import{homedir as Q2}from"os";import{execSync as W_}from"child_process";import{fileURLToPath as ff}from"url";var _Y=(q=0)=>(_)=>`\x1B[${_+q}m`,KY=(q=0)=>(_)=>`\x1B[${38+q};5;${_}m`,jY=(q=0)=>(_,j,K)=>`\x1B[${38+q};2;${_};${j};${K}m`,l8={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},LV=Object.keys(l8.modifier),vA=Object.keys(l8.color),zA=Object.keys(l8.bgColor),lV=[...vA,...zA];function WA(){let q=new Map;for(let[_,j]of Object.entries(l8)){for(let[K,Y]of Object.entries(j))l8[K]={open:`\x1B[${Y[0]}m`,close:`\x1B[${Y[1]}m`},j[K]=l8[K],q.set(Y[0],Y[1]);Object.defineProperty(l8,_,{value:j,enumerable:!1})}return Object.defineProperty(l8,"codes",{value:q,enumerable:!1}),l8.color.close="\x1B[39m",l8.bgColor.close="\x1B[49m",l8.color.ansi=_Y(),l8.color.ansi256=KY(),l8.color.ansi16m=jY(),l8.bgColor.ansi=_Y(10),l8.bgColor.ansi256=KY(10),l8.bgColor.ansi16m=jY(10),Object.defineProperties(l8,{rgbToAnsi256:{value(_,j,K){if(_===j&&j===K){if(_<8)return 16;if(_>248)return 231;return Math.round((_-8)/247*24)+232}return 16+36*Math.round(_/255*5)+6*Math.round(j/255*5)+Math.round(K/255*5)},enumerable:!1},hexToRgb:{value(_){let j=/[a-f\d]{6}|[a-f\d]{3}/i.exec(_.toString(16));if(!j)return[0,0,0];let[K]=j;if(K.length===3)K=[...K].map((f)=>f+f).join("");let Y=Number.parseInt(K,16);return[Y>>16&255,Y>>8&255,Y&255]},enumerable:!1},hexToAnsi256:{value:(_)=>l8.rgbToAnsi256(...l8.hexToRgb(_)),enumerable:!1},ansi256ToAnsi:{value(_){if(_<8)return 30+_;if(_<16)return 90+(_-8);let j,K,Y;if(_>=232)j=((_-232)*10+8)/255,K=j,Y=j;else{_-=16;let $=_%36;j=Math.floor(_/36)/5,K=Math.floor($/6)/5,Y=$%6/5}let f=Math.max(j,K,Y)*2;if(f===0)return 30;let P=30+(Math.round(Y)<<2|Math.round(K)<<1|Math.round(j));if(f===2)P+=60;return P},enumerable:!1},rgbToAnsi:{value:(_,j,K)=>l8.ansi256ToAnsi(l8.rgbToAnsi256(_,j,K)),enumerable:!1},hexToAnsi:{value:(_)=>l8.ansi256ToAnsi(l8.hexToAnsi256(_)),enumerable:!1}}),l8}var JA=WA(),Oq=JA;import b2 from"node:process";import HA from"node:os";import PY from"node:tty";function U6(q,_=globalThis.Deno?globalThis.Deno.args:b2.argv){let j=q.startsWith("-")?"":q.length===1?"-":"--",K=_.indexOf(j+q),Y=_.indexOf("--");return K!==-1&&(Y===-1||K=2,has16m:q>=3}}function kA(q,{streamIsTTY:_,sniffFlags:j=!0}={}){let K=TA();if(K!==void 0)f7=K;let Y=j?f7:K;if(Y===0)return 0;if(j){if(U6("color=16m")||U6("color=full")||U6("color=truecolor"))return 3;if(U6("color=256"))return 2}if("TF_BUILD"in n8&&"AGENT_NAME"in n8)return 1;if(q&&!_&&Y===void 0)return 0;let f=Y||0;if(n8.TERM==="dumb")return f;if(b2.platform==="win32"){let P=HA.release().split(".");if(Number(P[0])>=10&&Number(P[2])>=10586)return Number(P[2])>=14931?3:2;return 1}if("CI"in n8){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((P)=>(P in n8)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((P)=>(P in n8))||n8.CI_NAME==="codeship")return 1;return f}if("TEAMCITY_VERSION"in n8)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n8.TEAMCITY_VERSION)?1:0;if(n8.COLORTERM==="truecolor")return 3;if(n8.TERM==="xterm-kitty")return 3;if(n8.TERM==="xterm-ghostty")return 3;if(n8.TERM==="wezterm")return 3;if("TERM_PROGRAM"in n8){let P=Number.parseInt((n8.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n8.TERM_PROGRAM){case"iTerm.app":return P>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(n8.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n8.TERM))return 1;if("COLORTERM"in n8)return 1;return f}function YY(q,_={}){let j=kA(q,{streamIsTTY:q&&q.isTTY,..._});return ZA(j)}var XA={stdout:YY({isTTY:PY.isatty(1)}),stderr:YY({isTTY:PY.isatty(2)})},fY=XA;function $Y(q,_,j){let K=q.indexOf(_);if(K===-1)return q;let Y=_.length,f=0,P="";do P+=q.slice(f,K)+_+j,f=K+Y,K=q.indexOf(_,f);while(K!==-1);return P+=q.slice(f),P}function wY(q,_,j,K){let Y=0,f="";do{let P=q[K-1]==="\r";f+=q.slice(Y,P?K-1:K)+_+(P?`\r +To restore files: claude-mem restore`),console.log("To empty trash: claude-mem trash empty")}catch(_){if(_.code==="ENOENT")Q8.info("\uD83D\uDDD1️ Trash is empty");else Q8.error("Failed to read trash directory"),console.error(_)}}var D$=Y6(()=>{KK();C6()});var V$={};uK(V$,{emptyTrash:()=>PD});import{rmSync as qD,readdirSync as _D,existsSync as KD,statSync as jD}from"fs";import{join as C$}from"path";async function PD(q={}){let _=_8.getInstance().getTrashDirectory();if(!KD(_)){Q8.info("\uD83D\uDDD1️ Trash is already empty");return}try{let j=_D(_);if(j.length===0){Q8.info("\uD83D\uDDD1️ Trash is already empty");return}let K=0,Y=0;for(let P of j){let $=C$(_,P);if(jD($).isDirectory())K++;else Y++}if(!q.force){let P=await gq({message:`Permanently delete ${K} folders and ${Y} files from trash?`,initialValue:!1});if(K6(P)||!P){Q8.info("Cancelled - trash not emptied");return}}let f=Y7();f.start("Emptying trash...");for(let P of j){let $=C$(_,P);qD($,{recursive:!0,force:!0})}f.stop(`\uD83D\uDDD1️ Trash emptied - permanently deleted ${K} folders and ${Y} files`)}catch(j){Q8.error("Failed to empty trash"),console.error(j),process.exit(1)}}var M$=Y6(()=>{KK();C6()});var y7={};uK(y7,{sessionStartHook:()=>fD,sessionEndHook:()=>$D,preCompactHook:()=>YD});import{basename as N$}from"path";async function YD(){try{let q="";process.stdin.setEncoding("utf8");for await(let j of process.stdin)q+=j;let _;if(q)try{_=JSON.parse(q).transcript_path}catch(j){_=q.trim()}if(!_)_=process.env.TRANSCRIPT_PATH||process.argv[2];if(!_){console.log("\uD83D\uDDDC️ Compressing session transcript..."),console.log("❌ No transcript path provided to pre-compact hook"),console.log("Hook data received:",q||"none"),console.log("Environment TRANSCRIPT_PATH:",process.env.TRANSCRIPT_PATH||"not set"),console.log("Command line args:",process.argv.slice(2));return}await oK(_,{dryRun:!1})}catch(q){console.error("Pre-compact hook failed:",q.message),process.exit(1)}}async function fD(){try{let q="";process.stdin.setEncoding("utf8");for await(let j of process.stdin)q+=j;let _;if(q)try{let j=JSON.parse(q);if(j.cwd)_=N$(j.cwd)}catch(j){console.error("Failed to parse session-start hook data:",j)}if(!_)_=N$(process.cwd());await T7({format:"session-start",count:"10",project:_})}catch(q){console.error("Session-start hook failed:",q.message),process.exit(1)}}async function $D(){try{let q="";process.stdin.setEncoding("utf8");for await(let _ of process.stdin)q+=_;if(q)try{let _=JSON.parse(q);if(_.reason==="clear"&&_.transcript_path)console.log("\uD83D\uDDDC️ Compressing current session before /clear..."),await oK(_.transcript_path,{dryRun:!1})}catch(_){console.error("Failed to parse hook data:",_)}console.log("Session ended successfully")}catch(q){console.error("Session-end hook failed:",q.message),process.exit(1)}}var d7=Y6(()=>{w2();j9()});var P5=o6(j5(),1),{program:VD,createCommand:MD,createArgument:ND,createOption:bD,CommanderError:SD,InvalidArgumentError:ED,InvalidOptionArgumentError:RD,Command:Y5,Argument:mD,Option:ID,Help:gD}=P5.default;import{readFileSync as cw,existsSync as rw}from"fs";import{join as iw,dirname as ow}from"path";import{fileURLToPath as aw}from"url";var f5="claude-mem",$5="3.5.5",w5="Memory compression system for Claude Code - persist context across sessions",O5=f5,v5=$5,z5=w5;try{let q=aw(import.meta.url),_=ow(q),j=iw(_,"..","..","package.json");if(rw(j)){let K=JSON.parse(cw(j,"utf-8"));O5=K.name||f5,v5=K.version||$5,z5=K.description||w5}}catch{}var pq=O5,W5=v5,J5=z5;w2();KK();import{readFileSync as YK,writeFileSync as H_,existsSync as R8,chmodSync as DG,mkdirSync as $K,copyFileSync as J_,statSync as CG,readdirSync as VG}from"fs";import{join as D8,dirname as fK}from"path";import{homedir as Q2}from"os";import{execSync as W_}from"child_process";import{fileURLToPath as ff}from"url";var _Y=(q=0)=>(_)=>`\x1B[${_+q}m`,KY=(q=0)=>(_)=>`\x1B[${38+q};5;${_}m`,jY=(q=0)=>(_,j,K)=>`\x1B[${38+q};2;${_};${j};${K}m`,l8={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},LV=Object.keys(l8.modifier),vA=Object.keys(l8.color),zA=Object.keys(l8.bgColor),lV=[...vA,...zA];function WA(){let q=new Map;for(let[_,j]of Object.entries(l8)){for(let[K,Y]of Object.entries(j))l8[K]={open:`\x1B[${Y[0]}m`,close:`\x1B[${Y[1]}m`},j[K]=l8[K],q.set(Y[0],Y[1]);Object.defineProperty(l8,_,{value:j,enumerable:!1})}return Object.defineProperty(l8,"codes",{value:q,enumerable:!1}),l8.color.close="\x1B[39m",l8.bgColor.close="\x1B[49m",l8.color.ansi=_Y(),l8.color.ansi256=KY(),l8.color.ansi16m=jY(),l8.bgColor.ansi=_Y(10),l8.bgColor.ansi256=KY(10),l8.bgColor.ansi16m=jY(10),Object.defineProperties(l8,{rgbToAnsi256:{value(_,j,K){if(_===j&&j===K){if(_<8)return 16;if(_>248)return 231;return Math.round((_-8)/247*24)+232}return 16+36*Math.round(_/255*5)+6*Math.round(j/255*5)+Math.round(K/255*5)},enumerable:!1},hexToRgb:{value(_){let j=/[a-f\d]{6}|[a-f\d]{3}/i.exec(_.toString(16));if(!j)return[0,0,0];let[K]=j;if(K.length===3)K=[...K].map((f)=>f+f).join("");let Y=Number.parseInt(K,16);return[Y>>16&255,Y>>8&255,Y&255]},enumerable:!1},hexToAnsi256:{value:(_)=>l8.rgbToAnsi256(...l8.hexToRgb(_)),enumerable:!1},ansi256ToAnsi:{value(_){if(_<8)return 30+_;if(_<16)return 90+(_-8);let j,K,Y;if(_>=232)j=((_-232)*10+8)/255,K=j,Y=j;else{_-=16;let $=_%36;j=Math.floor(_/36)/5,K=Math.floor($/6)/5,Y=$%6/5}let f=Math.max(j,K,Y)*2;if(f===0)return 30;let P=30+(Math.round(Y)<<2|Math.round(K)<<1|Math.round(j));if(f===2)P+=60;return P},enumerable:!1},rgbToAnsi:{value:(_,j,K)=>l8.ansi256ToAnsi(l8.rgbToAnsi256(_,j,K)),enumerable:!1},hexToAnsi:{value:(_)=>l8.ansi256ToAnsi(l8.hexToAnsi256(_)),enumerable:!1}}),l8}var JA=WA(),Oq=JA;import b2 from"node:process";import HA from"node:os";import PY from"node:tty";function U6(q,_=globalThis.Deno?globalThis.Deno.args:b2.argv){let j=q.startsWith("-")?"":q.length===1?"-":"--",K=_.indexOf(j+q),Y=_.indexOf("--");return K!==-1&&(Y===-1||K=2,has16m:q>=3}}function kA(q,{streamIsTTY:_,sniffFlags:j=!0}={}){let K=TA();if(K!==void 0)f7=K;let Y=j?f7:K;if(Y===0)return 0;if(j){if(U6("color=16m")||U6("color=full")||U6("color=truecolor"))return 3;if(U6("color=256"))return 2}if("TF_BUILD"in n8&&"AGENT_NAME"in n8)return 1;if(q&&!_&&Y===void 0)return 0;let f=Y||0;if(n8.TERM==="dumb")return f;if(b2.platform==="win32"){let P=HA.release().split(".");if(Number(P[0])>=10&&Number(P[2])>=10586)return Number(P[2])>=14931?3:2;return 1}if("CI"in n8){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((P)=>(P in n8)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((P)=>(P in n8))||n8.CI_NAME==="codeship")return 1;return f}if("TEAMCITY_VERSION"in n8)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n8.TEAMCITY_VERSION)?1:0;if(n8.COLORTERM==="truecolor")return 3;if(n8.TERM==="xterm-kitty")return 3;if(n8.TERM==="xterm-ghostty")return 3;if(n8.TERM==="wezterm")return 3;if("TERM_PROGRAM"in n8){let P=Number.parseInt((n8.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n8.TERM_PROGRAM){case"iTerm.app":return P>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(n8.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n8.TERM))return 1;if("COLORTERM"in n8)return 1;return f}function YY(q,_={}){let j=kA(q,{streamIsTTY:q&&q.isTTY,..._});return ZA(j)}var XA={stdout:YY({isTTY:PY.isatty(1)}),stderr:YY({isTTY:PY.isatty(2)})},fY=XA;function $Y(q,_,j){let K=q.indexOf(_);if(K===-1)return q;let Y=_.length,f=0,P="";do P+=q.slice(f,K)+_+j,f=K+Y,K=q.indexOf(_,f);while(K!==-1);return P+=q.slice(f),P}function wY(q,_,j,K){let Y=0,f="";do{let P=q[K-1]==="\r";f+=q.slice(Y,P?K-1:K)+_+(P?`\r `:` `)+j,Y=K+1,K=q.indexOf(` `,Y)}while(K!==-1);return f+=q.slice(Y),f}var{stdout:OY,stderr:vY}=fY,S2=Symbol("GENERATOR"),jK=Symbol("STYLER"),eK=Symbol("IS_EMPTY"),zY=["ansi","ansi","ansi256","ansi16m"],PK=Object.create(null),AA=(q,_={})=>{if(_.level&&!(Number.isInteger(_.level)&&_.level>=0&&_.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let j=OY?OY.level:0;q.level=_.level===void 0?j:_.level};var GA=(q)=>{let _=(...j)=>j.join(" ");return AA(_,q),Object.setPrototypeOf(_,FK.prototype),_};function FK(q){return GA(q)}Object.setPrototypeOf(FK.prototype,Function.prototype);for(let[q,_]of Object.entries(Oq))PK[q]={get(){let j=$7(this,R2(_.open,_.close,this[jK]),this[eK]);return Object.defineProperty(this,q,{value:j}),j}};PK.visible={get(){let q=$7(this,this[jK],!0);return Object.defineProperty(this,"visible",{value:q}),q}};var E2=(q,_,j,...K)=>{if(q==="rgb"){if(_==="ansi16m")return Oq[j].ansi16m(...K);if(_==="ansi256")return Oq[j].ansi256(Oq.rgbToAnsi256(...K));return Oq[j].ansi(Oq.rgbToAnsi(...K))}if(q==="hex")return E2("rgb",_,j,...Oq.hexToRgb(...K));return Oq[j][q](...K)},uA=["rgb","hex","ansi256"];for(let q of uA){PK[q]={get(){let{level:j}=this;return function(...K){let Y=R2(E2(q,zY[j],"color",...K),Oq.color.close,this[jK]);return $7(this,Y,this[eK])}}};let _="bg"+q[0].toUpperCase()+q.slice(1);PK[_]={get(){let{level:j}=this;return function(...K){let Y=R2(E2(q,zY[j],"bgColor",...K),Oq.bgColor.close,this[jK]);return $7(this,Y,this[eK])}}}}var hA=Object.defineProperties(()=>{},{...PK,level:{enumerable:!0,get(){return this[S2].level},set(q){this[S2].level=q}}}),R2=(q,_,j)=>{let K,Y;if(j===void 0)K=q,Y=_;else K=j.openAll+q,Y=_+j.closeAll;return{open:q,close:_,openAll:K,closeAll:Y,parent:j}},$7=(q,_,j)=>{let K=(...Y)=>DA(K,Y.length===1?""+Y[0]:Y.join(" "));return Object.setPrototypeOf(K,hA),K[S2]=q,K[jK]=_,K[eK]=j,K},DA=(q,_)=>{if(q.level<=0||!_)return q[eK]?"":_;let j=q[jK];if(j===void 0)return _;let{openAll:K,closeAll:Y}=j;if(_.includes("\x1B"))while(j!==void 0)_=$Y(_,j.close,j.open),j=j.parent;let f=_.indexOf(` diff --git a/package.json b/package.json index aca3671a..33b92a52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "claude-mem", - "version": "3.5.4", + "version": "3.5.5", "description": "Memory compression system for Claude Code - persist context across sessions", "keywords": [ "claude",