diff --git a/CHANGELOG.md b/CHANGELOG.md index e976d669..805c99b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [3.6.6] - 2025-09-14 + +### Fixed +- Resolved compaction errors when processing large conversation histories by reducing chunk size limits to stay within Claude's context window + + ## [3.6.5] - 2025-09-14 ### Changed diff --git a/dist/claude-mem.min.js b/dist/claude-mem.min.js index 33a77d52..9e206d46 100755 --- a/dist/claude-mem.min.js +++ b/dist/claude-mem.min.js @@ -37,7 +37,7 @@ ${j}`:"",f=y_();return g6(`✅ ${q} completed successfully${K}${Y}`,f)}function `))}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 w=`hook_${this.nextCallbackId++}`;this.hookCallbacks.set(w,$),P.push(w)}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,w=()=>{if($)clearTimeout($);this.pendingMcpResponses.delete(Y)},O=(z)=>{w(),f(z)},v=(z)=>{w(),P(z)};if(this.pendingMcpResponses.set(Y,{resolve:O,reject:v}),j.onmessage)j.onmessage(_.message);else{w(),P(new Error("No message handler registered"));return}$=setTimeout(()=>{if(this.pendingMcpResponses.has(Y))w(),P(new Error("Request timeout"))},30000)})}};k={};WO(k,{void:()=>lz,util:()=>h8,unknown:()=>pz,union:()=>rz,undefined:()=>gz,tuple:()=>az,transformer:()=>g5,symbol:()=>Iz,string:()=>U5,strictObject:()=>cz,setErrorMap:()=>Pz,set:()=>ez,record:()=>Bz,quotelessJson:()=>Kz,promise:()=>_v,preprocess:()=>Pv,pipeline:()=>Yv,ostring:()=>fv,optional:()=>Kv,onumber:()=>$v,oboolean:()=>wv,objectUtil:()=>W4,object:()=>nz,number:()=>s5,nullable:()=>jv,null:()=>yz,never:()=>Lz,nativeEnum:()=>qv,nan:()=>Ez,map:()=>tz,makeIssue:()=>L3,literal:()=>sz,lazy:()=>Uz,late:()=>bz,isValid:()=>$_,isDirty:()=>J4,isAsync:()=>IK,isAborted:()=>H4,intersection:()=>oz,instanceof:()=>Sz,getParsedType:()=>mq,getErrorMap:()=>p3,function:()=>Fz,enum:()=>Qz,effect:()=>g5,discriminatedUnion:()=>iz,defaultErrorMap:()=>n_,datetimeRegex:()=>t5,date:()=>mz,custom:()=>F5,coerce:()=>Ov,boolean:()=>Q5,bigint:()=>Rz,array:()=>xz,any:()=>dz,addIssueToContext:()=>F,ZodVoid:()=>yK,ZodUnknown:()=>aq,ZodUnion:()=>o_,ZodUndefined:()=>r_,ZodType:()=>k8,ZodTuple:()=>Aq,ZodTransformer:()=>B6,ZodSymbol:()=>gK,ZodString:()=>Yq,ZodSet:()=>z_,ZodSchema:()=>k8,ZodRecord:()=>dK,ZodReadonly:()=>s_,ZodPromise:()=>v_,ZodPipeline:()=>lK,ZodParsedType:()=>s,ZodOptional:()=>$q,ZodObject:()=>i8,ZodNumber:()=>Bq,ZodNullable:()=>Iq,ZodNull:()=>i_,ZodNever:()=>Xq,ZodNativeEnum:()=>e_,ZodNaN:()=>LK,ZodMap:()=>pK,ZodLiteral:()=>t_,ZodLazy:()=>B_,ZodIssueCode:()=>t,ZodIntersection:()=>a_,ZodFunction:()=>x_,ZodFirstPartyTypeKind:()=>W8,ZodError:()=>y6,ZodEnum:()=>eq,ZodEffects:()=>B6,ZodDiscriminatedUnion:()=>l3,ZodDefault:()=>F_,ZodDate:()=>w_,ZodCatch:()=>U_,ZodBranded:()=>x3,ZodBoolean:()=>c_,ZodBigInt:()=>tq,ZodArray:()=>fq,ZodAny:()=>O_,Schema:()=>k8,ParseStatus:()=>k6,OK:()=>D6,NEVER:()=>zv,INVALID:()=>v8,EMPTY_PATH:()=>Yz,DIRTY:()=>l_,BRAND:()=>Nz});(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}})(h8||(h8={}));(function(q){q.mergeShapes=(_,j)=>{return{..._,...j}}})(W4||(W4={}));s=h8.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),t=h8.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"]);y6=class y6 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()}};y6.create=(q)=>{return new y6(q)};n_=jz,o5=n_;Yz=[];v8=Object.freeze({status:"aborted"});(function(q){q.errToObj=(_)=>typeof _==="string"?{message:_}:_||{},q.toString=(_)=>typeof _==="string"?_:_?.message})(f8||(f8={}));fz=/^c[^\s-]{8,}$/i,$z=/^[0-9a-z]+$/,wz=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Oz=/^[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,zz=/^[a-z0-9_-]{21}$/i,vz=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Wz=/^[-+]?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)?)??$/,Hz=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tz=/^(?:(?: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])$/,Zz=/^(?:(?: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])$/,kz=/^(([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]))$/,Xz=/^(([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])$/,Az=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Gz=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,uz=new RegExp(`^${a5}$`);Yq=class Yq extends k8{_parse(q){if(this._def.coerce)q.data=String(q.data);if(this._getType(q)!==s.string){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_type,expected:s.string,received:Y.parsedType}),v8}let j=new k6,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,...f8.errToObj(j)})}_addCheck(q){return new Yq({...this._def,checks:[...this._def.checks,q]})}email(q){return this._addCheck({kind:"email",...f8.errToObj(q)})}url(q){return this._addCheck({kind:"url",...f8.errToObj(q)})}emoji(q){return this._addCheck({kind:"emoji",...f8.errToObj(q)})}uuid(q){return this._addCheck({kind:"uuid",...f8.errToObj(q)})}nanoid(q){return this._addCheck({kind:"nanoid",...f8.errToObj(q)})}cuid(q){return this._addCheck({kind:"cuid",...f8.errToObj(q)})}cuid2(q){return this._addCheck({kind:"cuid2",...f8.errToObj(q)})}ulid(q){return this._addCheck({kind:"ulid",...f8.errToObj(q)})}base64(q){return this._addCheck({kind:"base64",...f8.errToObj(q)})}base64url(q){return this._addCheck({kind:"base64url",...f8.errToObj(q)})}jwt(q){return this._addCheck({kind:"jwt",...f8.errToObj(q)})}ip(q){return this._addCheck({kind:"ip",...f8.errToObj(q)})}cidr(q){return this._addCheck({kind:"cidr",...f8.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,...f8.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,...f8.errToObj(q?.message)})}duration(q){return this._addCheck({kind:"duration",...f8.errToObj(q)})}regex(q,_){return this._addCheck({kind:"regex",regex:q,...f8.errToObj(_)})}includes(q,_){return this._addCheck({kind:"includes",value:q,position:_?.position,...f8.errToObj(_?.message)})}startsWith(q,_){return this._addCheck({kind:"startsWith",value:q,...f8.errToObj(_)})}endsWith(q,_){return this._addCheck({kind:"endsWith",value:q,...f8.errToObj(_)})}min(q,_){return this._addCheck({kind:"min",value:q,...f8.errToObj(_)})}max(q,_){return this._addCheck({kind:"max",value:q,...f8.errToObj(_)})}length(q,_){return this._addCheck({kind:"length",value:q,...f8.errToObj(_)})}nonempty(q){return this.min(1,f8.errToObj(q))}trim(){return new Yq({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Yq({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Yq({...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 Yq({checks:[],typeName:W8.ZodString,coerce:q?.coerce??!1,...Z8(q)})};Bq=class Bq 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)!==s.number){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_type,expected:s.number,received:Y.parsedType}),v8}let j=void 0,K=new k6;for(let Y of this._def.checks)if(Y.kind==="int"){if(!h8.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(Mz(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 h8.assertNever(Y);return{status:K.value,value:q.data}}gte(q,_){return this.setLimit("min",q,!0,f8.toString(_))}gt(q,_){return this.setLimit("min",q,!1,f8.toString(_))}lte(q,_){return this.setLimit("max",q,!0,f8.toString(_))}lt(q,_){return this.setLimit("max",q,!1,f8.toString(_))}setLimit(q,_,j,K){return new Bq({...this._def,checks:[...this._def.checks,{kind:q,value:_,inclusive:j,message:f8.toString(K)}]})}_addCheck(q){return new Bq({...this._def,checks:[...this._def.checks,q]})}int(q){return this._addCheck({kind:"int",message:f8.toString(q)})}positive(q){return this._addCheck({kind:"min",value:0,inclusive:!1,message:f8.toString(q)})}negative(q){return this._addCheck({kind:"max",value:0,inclusive:!1,message:f8.toString(q)})}nonpositive(q){return this._addCheck({kind:"max",value:0,inclusive:!0,message:f8.toString(q)})}nonnegative(q){return this._addCheck({kind:"min",value:0,inclusive:!0,message:f8.toString(q)})}multipleOf(q,_){return this._addCheck({kind:"multipleOf",value:q,message:f8.toString(_)})}finite(q){return this._addCheck({kind:"finite",message:f8.toString(q)})}safe(q){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:f8.toString(q)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:f8.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"&&h8.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 Bq({checks:[],typeName:W8.ZodNumber,coerce:q?.coerce||!1,...Z8(q)})};tq=class tq 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)!==s.bigint)return this._getInvalidInput(q);let j=void 0,K=new k6;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 h8.assertNever(Y);return{status:K.value,value:q.data}}_getInvalidInput(q){let _=this._getOrReturnCtx(q);return F(_,{code:t.invalid_type,expected:s.bigint,received:_.parsedType}),v8}gte(q,_){return this.setLimit("min",q,!0,f8.toString(_))}gt(q,_){return this.setLimit("min",q,!1,f8.toString(_))}lte(q,_){return this.setLimit("max",q,!0,f8.toString(_))}lt(q,_){return this.setLimit("max",q,!1,f8.toString(_))}setLimit(q,_,j,K){return new tq({...this._def,checks:[...this._def.checks,{kind:q,value:_,inclusive:j,message:f8.toString(K)}]})}_addCheck(q){return new tq({...this._def,checks:[...this._def.checks,q]})}positive(q){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:f8.toString(q)})}negative(q){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:f8.toString(q)})}nonpositive(q){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:f8.toString(q)})}nonnegative(q){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:f8.toString(q)})}multipleOf(q,_){return this._addCheck({kind:"multipleOf",value:q,message:f8.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 tq({checks:[],typeName:W8.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)!==s.boolean){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:s.boolean,received:j.parsedType}),v8}return D6(q.data)}};c_.create=(q)=>{return new c_({typeName:W8.ZodBoolean,coerce:q?.coerce||!1,...Z8(q)})};w_=class w_ extends k8{_parse(q){if(this._def.coerce)q.data=new Date(q.data);if(this._getType(q)!==s.date){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_type,expected:s.date,received:Y.parsedType}),v8}if(Number.isNaN(q.data.getTime())){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_date}),v8}let j=new k6,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 h8.assertNever(Y);return{status:j.value,value:new Date(q.data.getTime())}}_addCheck(q){return new w_({...this._def,checks:[...this._def.checks,q]})}min(q,_){return this._addCheck({kind:"min",value:q.getTime(),message:f8.toString(_)})}max(q,_){return this._addCheck({kind:"max",value:q.getTime(),message:f8.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 w_({checks:[],coerce:q?.coerce||!1,typeName:W8.ZodDate,...Z8(q)})};gK=class gK extends k8{_parse(q){if(this._getType(q)!==s.symbol){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:s.symbol,received:j.parsedType}),v8}return D6(q.data)}};gK.create=(q)=>{return new gK({typeName:W8.ZodSymbol,...Z8(q)})};r_=class r_ extends k8{_parse(q){if(this._getType(q)!==s.undefined){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:s.undefined,received:j.parsedType}),v8}return D6(q.data)}};r_.create=(q)=>{return new r_({typeName:W8.ZodUndefined,...Z8(q)})};i_=class i_ extends k8{_parse(q){if(this._getType(q)!==s.null){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:s.null,received:j.parsedType}),v8}return D6(q.data)}};i_.create=(q)=>{return new i_({typeName:W8.ZodNull,...Z8(q)})};O_=class O_ extends k8{constructor(){super(...arguments);this._any=!0}_parse(q){return D6(q.data)}};O_.create=(q)=>{return new O_({typeName:W8.ZodAny,...Z8(q)})};aq=class aq extends k8{constructor(){super(...arguments);this._unknown=!0}_parse(q){return D6(q.data)}};aq.create=(q)=>{return new aq({typeName:W8.ZodUnknown,...Z8(q)})};Xq=class Xq extends k8{_parse(q){let _=this._getOrReturnCtx(q);return F(_,{code:t.invalid_type,expected:s.never,received:_.parsedType}),v8}};Xq.create=(q)=>{return new Xq({typeName:W8.ZodNever,...Z8(q)})};yK=class yK extends k8{_parse(q){if(this._getType(q)!==s.undefined){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:s.void,received:j.parsedType}),v8}return D6(q.data)}};yK.create=(q)=>{return new yK({typeName:W8.ZodVoid,...Z8(q)})};fq=class fq extends k8{_parse(q){let{ctx:_,status:j}=this._processInputParams(q),K=this._def;if(_.parsedType!==s.array)return F(_,{code:t.invalid_type,expected:s.array,received:_.parsedType}),v8;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 wq(_,f,_.path,P))})).then((f)=>{return k6.mergeArray(j,f)});let Y=[..._.data].map((f,P)=>{return K.type._parseSync(new wq(_,f,_.path,P))});return k6.mergeArray(j,Y)}get element(){return this._def.type}min(q,_){return new fq({...this._def,minLength:{value:q,message:f8.toString(_)}})}max(q,_){return new fq({...this._def,maxLength:{value:q,message:f8.toString(_)}})}length(q,_){return new fq({...this._def,exactLength:{value:q,message:f8.toString(_)}})}nonempty(q){return this.min(1,q)}};fq.create=(q,_)=>{return new fq({type:q,minLength:null,maxLength:null,exactLength:null,typeName:W8.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(),_=h8.objectKeys(q);return this._cached={shape:q,keys:_},this._cached}_parse(q){if(this._getType(q)!==s.object){let w=this._getOrReturnCtx(q);return F(w,{code:t.invalid_type,expected:s.object,received:w.parsedType}),v8}let{status:j,ctx:K}=this._processInputParams(q),{shape:Y,keys:f}=this._getCached(),P=[];if(!(this._def.catchall instanceof Xq&&this._def.unknownKeys==="strip")){for(let w in K.data)if(!f.includes(w))P.push(w)}let $=[];for(let w of f){let O=Y[w],v=K.data[w];$.push({key:{status:"valid",value:w},value:O._parse(new wq(K,v,K.path,w)),alwaysSet:w in K.data})}if(this._def.catchall instanceof Xq){let w=this._def.unknownKeys;if(w==="passthrough")for(let O of P)$.push({key:{status:"valid",value:O},value:{status:"valid",value:K.data[O]}});else if(w==="strict"){if(P.length>0)F(K,{code:t.unrecognized_keys,keys:P}),j.dirty()}else if(w==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let w=this._def.catchall;for(let O of P){let v=K.data[O];$.push({key:{status:"valid",value:O},value:w._parse(new wq(K,v,K.path,O)),alwaysSet:O in K.data})}}if(K.common.async)return Promise.resolve().then(async()=>{let w=[];for(let O of $){let v=await O.key,z=await O.value;w.push({key:v,value:z,alwaysSet:O.alwaysSet})}return w}).then((w)=>{return k6.mergeObjectSync(j,w)});else return k6.mergeObjectSync(j,$)}get shape(){return this._def.shape()}strict(q){return f8.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:f8.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:W8.ZodObject})}setKey(q,_){return this.augment({[q]:_})}catchall(q){return new i8({...this._def,catchall:q})}pick(q){let _={};for(let j of h8.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 h8.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 h8.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 h8.objectKeys(this.shape))if(q&&!q[j])_[j]=this.shape[j];else{let Y=this.shape[j];while(Y instanceof $q)Y=Y._def.innerType;_[j]=Y}return new i8({...this._def,shape:()=>_})}keyof(){return e5(h8.objectKeys(this.shape))}};i8.create=(q,_)=>{return new i8({shape:()=>q,unknownKeys:"strip",catchall:Xq.create(),typeName:W8.ZodObject,...Z8(_)})};i8.strictCreate=(q,_)=>{return new i8({shape:()=>q,unknownKeys:"strict",catchall:Xq.create(),typeName:W8.ZodObject,...Z8(_)})};i8.lazycreate=(q,_)=>{return new i8({shape:q,unknownKeys:"strip",catchall:Xq.create(),typeName:W8.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 y6(P.ctx.common.issues));return F(_,{code:t.invalid_union,unionErrors:f}),v8}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 w={..._,common:{..._.common,issues:[]},parent:null},O=$._parseSync({data:_.data,path:_.path,parent:w});if(O.status==="valid")return O;else if(O.status==="dirty"&&!Y)Y={result:O,ctx:w};if(w.common.issues.length)f.push(w.common.issues)}if(Y)return _.common.issues.push(...Y.ctx.common.issues),Y.result;let P=f.map(($)=>new y6($));return F(_,{code:t.invalid_union,unionErrors:P}),v8}}get options(){return this._def.options}};o_.create=(q,_)=>{return new o_({options:q,typeName:W8.ZodUnion,...Z8(_)})};l3=class l3 extends k8{_parse(q){let{ctx:_}=this._processInputParams(q);if(_.parsedType!==s.object)return F(_,{code:t.invalid_type,expected:s.object,received:_.parsedType}),v8;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]}),v8;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=Rq(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 l3({typeName:W8.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(H4(Y)||H4(f))return v8;let P=T4(Y.value,f.value);if(!P.valid)return F(j,{code:t.invalid_intersection_types}),v8;if(J4(Y)||J4(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:W8.ZodIntersection,...Z8(j)})};Aq=class Aq extends k8{_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.parsedType!==s.array)return F(j,{code:t.invalid_type,expected:s.array,received:j.parsedType}),v8;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 wq(j,f,j.path,P))}).filter((f)=>!!f);if(j.common.async)return Promise.all(Y).then((f)=>{return k6.mergeArray(_,f)});else return k6.mergeArray(_,Y)}get items(){return this._def.items}rest(q){return new Aq({...this._def,rest:q})}};Aq.create=(q,_)=>{if(!Array.isArray(q))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Aq({items:q,typeName:W8.ZodTuple,rest:null,...Z8(_)})};dK=class dK 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!==s.object)return F(j,{code:t.invalid_type,expected:s.object,received:j.parsedType}),v8;let K=[],Y=this._def.keyType,f=this._def.valueType;for(let P in j.data)K.push({key:Y._parse(new wq(j,P,j.path,P)),value:f._parse(new wq(j,j.data[P],j.path,P)),alwaysSet:P in j.data});if(j.common.async)return k6.mergeObjectAsync(_,K);else return k6.mergeObjectSync(_,K)}get element(){return this._def.valueType}static create(q,_,j){if(_ instanceof k8)return new dK({keyType:q,valueType:_,typeName:W8.ZodRecord,...Z8(j)});return new dK({keyType:Yq.create(),valueType:q,typeName:W8.ZodRecord,...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!==s.map)return F(j,{code:t.invalid_type,expected:s.map,received:j.parsedType}),v8;let K=this._def.keyType,Y=this._def.valueType,f=[...j.data.entries()].map(([P,$],w)=>{return{key:K._parse(new wq(j,P,j.path,[w,"key"])),value:Y._parse(new wq(j,$,j.path,[w,"value"]))}});if(j.common.async){let P=new Map;return Promise.resolve().then(async()=>{for(let $ of f){let w=await $.key,O=await $.value;if(w.status==="aborted"||O.status==="aborted")return v8;if(w.status==="dirty"||O.status==="dirty")_.dirty();P.set(w.value,O.value)}return{status:_.value,value:P}})}else{let P=new Map;for(let $ of f){let{key:w,value:O}=$;if(w.status==="aborted"||O.status==="aborted")return v8;if(w.status==="dirty"||O.status==="dirty")_.dirty();P.set(w.value,O.value)}return{status:_.value,value:P}}}};pK.create=(q,_,j)=>{return new pK({valueType:_,keyType:q,typeName:W8.ZodMap,...Z8(j)})};z_=class z_ extends k8{_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.parsedType!==s.set)return F(j,{code:t.invalid_type,expected:s.set,received:j.parsedType}),v8;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 w=new Set;for(let O of $){if(O.status==="aborted")return v8;if(O.status==="dirty")_.dirty();w.add(O.value)}return{status:_.value,value:w}}let P=[...j.data.values()].map(($,w)=>Y._parse(new wq(j,$,j.path,w)));if(j.common.async)return Promise.all(P).then(($)=>f($));else return f(P)}min(q,_){return new z_({...this._def,minSize:{value:q,message:f8.toString(_)}})}max(q,_){return new z_({...this._def,maxSize:{value:q,message:f8.toString(_)}})}size(q,_){return this.min(q,_).max(q,_)}nonempty(q){return this.min(1,q)}};z_.create=(q,_)=>{return new z_({valueType:q,minSize:null,maxSize:null,typeName:W8.ZodSet,...Z8(_)})};x_=class x_ extends k8{constructor(){super(...arguments);this.validate=this.implement}_parse(q){let{ctx:_}=this._processInputParams(q);if(_.parsedType!==s.function)return F(_,{code:t.invalid_type,expected:s.function,received:_.parsedType}),v8;function j(P,$){return L3({data:P,path:_.path,errorMaps:[_.common.contextualErrorMap,_.schemaErrorMap,p3(),n_].filter((w)=>!!w),issueData:{code:t.invalid_arguments,argumentsError:$}})}function K(P,$){return L3({data:P,path:_.path,errorMaps:[_.common.contextualErrorMap,_.schemaErrorMap,p3(),n_].filter((w)=>!!w),issueData:{code:t.invalid_return_type,returnTypeError:$}})}let Y={errorMap:_.common.contextualErrorMap},f=_.data;if(this._def.returns instanceof v_){let P=this;return D6(async function(...$){let w=new y6([]),O=await P._def.args.parseAsync($,Y).catch((W)=>{throw w.addIssue(j($,W)),w}),v=await Reflect.apply(f,this,O);return await P._def.returns._def.type.parseAsync(v,Y).catch((W)=>{throw w.addIssue(K(v,W)),w})})}else{let P=this;return D6(function(...$){let w=P._def.args.safeParse($,Y);if(!w.success)throw new y6([j($,w.error)]);let O=Reflect.apply(f,this,w.data),v=P._def.returns.safeParse(O,Y);if(!v.success)throw new y6([K(O,v.error)]);return v.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...q){return new x_({...this._def,args:Aq.create(q).rest(aq.create())})}returns(q){return new x_({...this._def,returns:q})}implement(q){return this.parse(q)}strictImplement(q){return this.parse(q)}static create(q,_,j){return new x_({args:q?q:Aq.create([]).rest(aq.create()),returns:_||aq.create(),typeName:W8.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:W8.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}),v8}return{status:"valid",value:q.data}}get value(){return this._def.value}};t_.create=(q,_)=>{return new t_({value:q,typeName:W8.ZodLiteral,...Z8(_)})};eq=class eq extends k8{_parse(q){if(typeof q.data!=="string"){let _=this._getOrReturnCtx(q),j=this._def.values;return F(_,{expected:h8.joinValues(j),received:_.parsedType,code:t.invalid_type}),v8}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}),v8}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 eq.create(q,{...this._def,..._})}exclude(q,_=this._def){return eq.create(this.options.filter((j)=>!q.includes(j)),{...this._def,..._})}};eq.create=e5;e_=class e_ extends k8{_parse(q){let _=h8.getValidEnumValues(this._def.values),j=this._getOrReturnCtx(q);if(j.parsedType!==s.string&&j.parsedType!==s.number){let K=h8.objectValues(_);return F(j,{expected:h8.joinValues(K),received:j.parsedType,code:t.invalid_type}),v8}if(!this._cache)this._cache=new Set(h8.getValidEnumValues(this._def.values));if(!this._cache.has(q.data)){let K=h8.objectValues(_);return F(j,{received:j.data,code:t.invalid_enum_value,options:K}),v8}return D6(q.data)}get enum(){return this._def.values}};e_.create=(q,_)=>{return new e_({values:q,typeName:W8.ZodNativeEnum,...Z8(_)})};v_=class v_ extends k8{unwrap(){return this._def.type}_parse(q){let{ctx:_}=this._processInputParams(q);if(_.parsedType!==s.promise&&_.common.async===!1)return F(_,{code:t.invalid_type,expected:s.promise,received:_.parsedType}),v8;let j=_.parsedType===s.promise?_.data:Promise.resolve(_.data);return D6(j.then((K)=>{return this._def.type.parseAsync(K,{path:_.path,errorMap:_.common.contextualErrorMap})}))}};v_.create=(q,_)=>{return new v_({type:q,typeName:W8.ZodPromise,...Z8(_)})};B6=class B6 extends k8{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===W8.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 v8;let $=await this._def.schema._parseAsync({data:P,path:j.path,parent:j});if($.status==="aborted")return v8;if($.status==="dirty")return l_($.value);if(_.value==="dirty")return l_($.value);return $});else{if(_.value==="aborted")return v8;let P=this._def.schema._parseSync({data:f,path:j.path,parent:j});if(P.status==="aborted")return v8;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 v8;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 v8;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(!$_(f))return v8;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(!$_(f))return v8;return Promise.resolve(K.transform(f.value,Y)).then((P)=>({status:_.value,value:P}))});h8.assertNever(K)}};B6.create=(q,_,j)=>{return new B6({schema:q,typeName:W8.ZodEffects,effect:_,...Z8(j)})};B6.createWithPreprocess=(q,_,j)=>{return new B6({schema:_,effect:{type:"preprocess",transform:q},typeName:W8.ZodEffects,...Z8(j)})};$q=class $q extends k8{_parse(q){if(this._getType(q)===s.undefined)return D6(void 0);return this._def.innerType._parse(q)}unwrap(){return this._def.innerType}};$q.create=(q,_)=>{return new $q({innerType:q,typeName:W8.ZodOptional,...Z8(_)})};Iq=class Iq extends k8{_parse(q){if(this._getType(q)===s.null)return D6(null);return this._def.innerType._parse(q)}unwrap(){return this._def.innerType}};Iq.create=(q,_)=>{return new Iq({innerType:q,typeName:W8.ZodNullable,...Z8(_)})};F_=class F_ extends k8{_parse(q){let{ctx:_}=this._processInputParams(q),j=_.data;if(_.parsedType===s.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:W8.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(IK(K))return K.then((Y)=>{return{status:"valid",value:Y.status==="valid"?Y.value:this._def.catchValue({get error(){return new y6(j.common.issues)},input:j.data})}});else return{status:"valid",value:K.status==="valid"?K.value:this._def.catchValue({get error(){return new y6(j.common.issues)},input:j.data})}}removeCatch(){return this._def.innerType}};U_.create=(q,_)=>{return new U_({innerType:q,typeName:W8.ZodCatch,catchValue:typeof _.catch==="function"?_.catch:()=>_.catch,...Z8(_)})};LK=class LK extends k8{_parse(q){if(this._getType(q)!==s.nan){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:s.nan,received:j.parsedType}),v8}return{status:"valid",value:q.data}}};LK.create=(q)=>{return new LK({typeName:W8.ZodNaN,...Z8(q)})};Nz=Symbol("zod_brand");x3=class x3 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}};lK=class lK 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 v8;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 v8;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 lK({in:q,out:_,typeName:W8.ZodPipeline})}};s_=class s_ extends k8{_parse(q){let _=this._def.innerType._parse(q),j=(K)=>{if($_(K))K.value=Object.freeze(K.value);return K};return IK(_)?_.then((K)=>j(K)):j(_)}unwrap(){return this._def.innerType}};s_.create=(q,_)=>{return new s_({innerType:q,typeName:W8.ZodReadonly,...Z8(_)})};bz={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"})(W8||(W8={}));U5=Yq.create,s5=Bq.create,Ez=LK.create,Rz=tq.create,Q5=c_.create,mz=w_.create,Iz=gK.create,gz=r_.create,yz=i_.create,dz=O_.create,pz=aq.create,Lz=Xq.create,lz=yK.create,xz=fq.create,nz=i8.create,cz=i8.strictCreate,rz=o_.create,iz=l3.create,oz=a_.create,az=Aq.create,Bz=dK.create,tz=pK.create,ez=z_.create,Fz=x_.create,Uz=B_.create,sz=t_.create,Qz=eq.create,qv=e_.create,_v=v_.create,g5=B6.create,Kv=$q.create,jv=Iq.create,Pv=B6.createWithPreprocess,Yv=lK.create,Ov={string:(q)=>Yq.create({...q,coerce:!0}),number:(q)=>Bq.create({...q,coerce:!0}),boolean:(q)=>c_.create({...q,coerce:!0}),bigint:(q)=>tq.create({...q,coerce:!0}),date:(q)=>w_.create({...q,coerce:!0})},zv=v8,q1=k.union([k.string(),k.number().int()]),_1=k.string(),vv=k.object({progressToken:k.optional(q1)}).passthrough(),t6=k.object({_meta:k.optional(vv)}).passthrough(),S6=k.object({method:k.string(),params:k.optional(t6)}),xK=k.object({_meta:k.optional(k.object({}).passthrough())}).passthrough(),Gq=k.object({method:k.string(),params:k.optional(xK)}),e6=k.object({_meta:k.optional(k.object({}).passthrough())}).passthrough(),c3=k.union([k.string(),k.number().int()]),Wv=k.object({jsonrpc:k.literal(n3),id:c3}).merge(S6).strict(),Hv=k.object({jsonrpc:k.literal(n3)}).merge(Gq).strict(),Jv=k.object({jsonrpc:k.literal(n3),id:c3,result:e6}).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"})(y5||(y5={}));Tv=k.object({jsonrpc:k.literal(n3),id:c3,error:k.object({code:k.number().int(),message:k.string(),data:k.optional(k.unknown())})}).strict(),OC=k.union([Wv,Hv,Jv,Tv]),K1=e6.strict(),j1=Gq.extend({method:k.literal("notifications/cancelled"),params:xK.extend({requestId:c3,reason:k.string().optional()})}),nK=k.object({name:k.string(),title:k.optional(k.string())}).passthrough(),P1=nK.extend({version:k.string()}),Zv=k.object({experimental:k.optional(k.object({}).passthrough()),sampling:k.optional(k.object({}).passthrough()),elicitation:k.optional(k.object({}).passthrough()),roots:k.optional(k.object({listChanged:k.optional(k.boolean())}).passthrough())}).passthrough(),kv=S6.extend({method:k.literal("initialize"),params:t6.extend({protocolVersion:k.string(),capabilities:Zv,clientInfo:P1})}),Xv=k.object({experimental:k.optional(k.object({}).passthrough()),logging:k.optional(k.object({}).passthrough()),completions:k.optional(k.object({}).passthrough()),prompts:k.optional(k.object({listChanged:k.optional(k.boolean())}).passthrough()),resources:k.optional(k.object({subscribe:k.optional(k.boolean()),listChanged:k.optional(k.boolean())}).passthrough()),tools:k.optional(k.object({listChanged:k.optional(k.boolean())}).passthrough())}).passthrough(),Av=e6.extend({protocolVersion:k.string(),capabilities:Xv,serverInfo:P1,instructions:k.optional(k.string())}),Gv=Gq.extend({method:k.literal("notifications/initialized")}),Y1=S6.extend({method:k.literal("ping")}),uv=k.object({progress:k.number(),total:k.optional(k.number()),message:k.optional(k.string())}).passthrough(),f1=Gq.extend({method:k.literal("notifications/progress"),params:xK.merge(uv).extend({progressToken:q1})}),r3=S6.extend({params:t6.extend({cursor:k.optional(_1)}).optional()}),i3=e6.extend({nextCursor:k.optional(_1)}),$1=k.object({uri:k.string(),mimeType:k.optional(k.string()),_meta:k.optional(k.object({}).passthrough())}).passthrough(),w1=$1.extend({text:k.string()}),u4=k.string().refine((q)=>{try{return atob(q),!0}catch(_){return!1}},{message:"Invalid Base64 string"}),O1=$1.extend({blob:u4}),z1=nK.extend({uri:k.string(),description:k.optional(k.string()),mimeType:k.optional(k.string()),_meta:k.optional(k.object({}).passthrough())}),hv=nK.extend({uriTemplate:k.string(),description:k.optional(k.string()),mimeType:k.optional(k.string()),_meta:k.optional(k.object({}).passthrough())}),Dv=r3.extend({method:k.literal("resources/list")}),Cv=i3.extend({resources:k.array(z1)}),Vv=r3.extend({method:k.literal("resources/templates/list")}),Mv=i3.extend({resourceTemplates:k.array(hv)}),Nv=S6.extend({method:k.literal("resources/read"),params:t6.extend({uri:k.string()})}),bv=e6.extend({contents:k.array(k.union([w1,O1]))}),Sv=Gq.extend({method:k.literal("notifications/resources/list_changed")}),Ev=S6.extend({method:k.literal("resources/subscribe"),params:t6.extend({uri:k.string()})}),Rv=S6.extend({method:k.literal("resources/unsubscribe"),params:t6.extend({uri:k.string()})}),mv=Gq.extend({method:k.literal("notifications/resources/updated"),params:xK.extend({uri:k.string()})}),Iv=k.object({name:k.string(),description:k.optional(k.string()),required:k.optional(k.boolean())}).passthrough(),gv=nK.extend({description:k.optional(k.string()),arguments:k.optional(k.array(Iv)),_meta:k.optional(k.object({}).passthrough())}),yv=r3.extend({method:k.literal("prompts/list")}),dv=i3.extend({prompts:k.array(gv)}),pv=S6.extend({method:k.literal("prompts/get"),params:t6.extend({name:k.string(),arguments:k.optional(k.record(k.string()))})}),h4=k.object({type:k.literal("text"),text:k.string(),_meta:k.optional(k.object({}).passthrough())}).passthrough(),D4=k.object({type:k.literal("image"),data:u4,mimeType:k.string(),_meta:k.optional(k.object({}).passthrough())}).passthrough(),C4=k.object({type:k.literal("audio"),data:u4,mimeType:k.string(),_meta:k.optional(k.object({}).passthrough())}).passthrough(),Lv=k.object({type:k.literal("resource"),resource:k.union([w1,O1]),_meta:k.optional(k.object({}).passthrough())}).passthrough(),lv=z1.extend({type:k.literal("resource_link")}),v1=k.union([h4,D4,C4,lv,Lv]),xv=k.object({role:k.enum(["user","assistant"]),content:v1}).passthrough(),nv=e6.extend({description:k.optional(k.string()),messages:k.array(xv)}),cv=Gq.extend({method:k.literal("notifications/prompts/list_changed")}),rv=k.object({title:k.optional(k.string()),readOnlyHint:k.optional(k.boolean()),destructiveHint:k.optional(k.boolean()),idempotentHint:k.optional(k.boolean()),openWorldHint:k.optional(k.boolean())}).passthrough(),iv=nK.extend({description:k.optional(k.string()),inputSchema:k.object({type:k.literal("object"),properties:k.optional(k.object({}).passthrough()),required:k.optional(k.array(k.string()))}).passthrough(),outputSchema:k.optional(k.object({type:k.literal("object"),properties:k.optional(k.object({}).passthrough()),required:k.optional(k.array(k.string()))}).passthrough()),annotations:k.optional(rv),_meta:k.optional(k.object({}).passthrough())}),ov=r3.extend({method:k.literal("tools/list")}),av=i3.extend({tools:k.array(iv)}),W1=e6.extend({content:k.array(v1).default([]),structuredContent:k.object({}).passthrough().optional(),isError:k.optional(k.boolean())}),zC=W1.or(e6.extend({toolResult:k.unknown()})),Bv=S6.extend({method:k.literal("tools/call"),params:t6.extend({name:k.string(),arguments:k.optional(k.record(k.unknown()))})}),tv=Gq.extend({method:k.literal("notifications/tools/list_changed")}),H1=k.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),ev=S6.extend({method:k.literal("logging/setLevel"),params:t6.extend({level:H1})}),Fv=Gq.extend({method:k.literal("notifications/message"),params:xK.extend({level:H1,logger:k.optional(k.string()),data:k.unknown()})}),Uv=k.object({name:k.string().optional()}).passthrough(),sv=k.object({hints:k.optional(k.array(Uv)),costPriority:k.optional(k.number().min(0).max(1)),speedPriority:k.optional(k.number().min(0).max(1)),intelligencePriority:k.optional(k.number().min(0).max(1))}).passthrough(),Qv=k.object({role:k.enum(["user","assistant"]),content:k.union([h4,D4,C4])}).passthrough(),qW=S6.extend({method:k.literal("sampling/createMessage"),params:t6.extend({messages:k.array(Qv),systemPrompt:k.optional(k.string()),includeContext:k.optional(k.enum(["none","thisServer","allServers"])),temperature:k.optional(k.number()),maxTokens:k.number().int(),stopSequences:k.optional(k.array(k.string())),metadata:k.optional(k.object({}).passthrough()),modelPreferences:k.optional(sv)})}),_W=e6.extend({model:k.string(),stopReason:k.optional(k.enum(["endTurn","stopSequence","maxTokens"]).or(k.string())),role:k.enum(["user","assistant"]),content:k.discriminatedUnion("type",[h4,D4,C4])}),KW=k.object({type:k.literal("boolean"),title:k.optional(k.string()),description:k.optional(k.string()),default:k.optional(k.boolean())}).passthrough(),jW=k.object({type:k.literal("string"),title:k.optional(k.string()),description:k.optional(k.string()),minLength:k.optional(k.number()),maxLength:k.optional(k.number()),format:k.optional(k.enum(["email","uri","date","date-time"]))}).passthrough(),PW=k.object({type:k.enum(["number","integer"]),title:k.optional(k.string()),description:k.optional(k.string()),minimum:k.optional(k.number()),maximum:k.optional(k.number())}).passthrough(),YW=k.object({type:k.literal("string"),title:k.optional(k.string()),description:k.optional(k.string()),enum:k.array(k.string()),enumNames:k.optional(k.array(k.string()))}).passthrough(),fW=k.union([KW,jW,PW,YW]),$W=S6.extend({method:k.literal("elicitation/create"),params:t6.extend({message:k.string(),requestedSchema:k.object({type:k.literal("object"),properties:k.record(k.string(),fW),required:k.optional(k.array(k.string()))}).passthrough()})}),wW=e6.extend({action:k.enum(["accept","decline","cancel"]),content:k.optional(k.record(k.string(),k.unknown()))}),OW=k.object({type:k.literal("ref/resource"),uri:k.string()}).passthrough(),zW=k.object({type:k.literal("ref/prompt"),name:k.string()}).passthrough(),vW=S6.extend({method:k.literal("completion/complete"),params:t6.extend({ref:k.union([zW,OW]),argument:k.object({name:k.string(),value:k.string()}).passthrough(),context:k.optional(k.object({arguments:k.optional(k.record(k.string(),k.string()))}))})}),WW=e6.extend({completion:k.object({values:k.array(k.string()).max(100),total:k.optional(k.number().int()),hasMore:k.optional(k.boolean())}).passthrough()}),HW=k.object({uri:k.string().startsWith("file://"),name:k.optional(k.string()),_meta:k.optional(k.object({}).passthrough())}).passthrough(),JW=S6.extend({method:k.literal("roots/list")}),TW=e6.extend({roots:k.array(HW)}),ZW=Gq.extend({method:k.literal("notifications/roots/list_changed")}),vC=k.union([Y1,kv,vW,ev,pv,yv,Dv,Vv,Nv,Ev,Rv,Bv,ov]),WC=k.union([j1,f1,Gv,ZW]),HC=k.union([K1,_W,wW,TW]),JC=k.union([Y1,qW,$W,JW]),TC=k.union([j1,f1,Fv,mv,Sv,tv,cv]),ZC=k.union([K1,Av,WW,nv,dv,Cv,Mv,bv,W1,av]),kC=vO(aO(),1),XC=Symbol("Let zodToJsonSchema decide on which parser to use"),AC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");(function(q){q.Completable="McpCompletable"})(Z4||(Z4={}));k4=class k4 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}};k4.create=(q,_)=>{return new k4({type:q,typeName:Z4.Completable,complete:_.complete,...kW(_)})}});var J1={};EK(J1,{version:()=>GW,type:()=>hW,scripts:()=>CW,repository:()=>bW,publishConfig:()=>RW,name:()=>AW,main:()=>DW,license:()=>NW,keywords:()=>VW,homepage:()=>SW,files:()=>dW,engines:()=>gW,devDependencies:()=>IW,description:()=>uW,dependencies:()=>mW,default:()=>pW,bugs:()=>EW,bin:()=>yW,author:()=>MW});var AW="claude-mem",GW="3.6.5",uW="Memory compression system for Claude Code - persist context across sessions",hW="module",DW="claude-mem",CW,VW,MW="Alex Newman",NW="SEE LICENSE IN LICENSE",bW,SW="https://github.com/thedotmack/claude-mem#readme",EW,RW,mW,IW,gW,yW,dW,pW;var T1=f6(()=>{CW={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-with-changelog.sh","publish:latest":"./scripts/publish-with-changelog.sh bump","publish:github":"./scripts/github-publish.sh"},VW=["claude","claude-code","mcp","memory","compression","knowledge-graph","transcript","cli","typescript","bun"],bW={type:"git",url:"https://github.com/thedotmack/claude-mem.git"},EW={url:"https://github.com/thedotmack/claude-mem/issues"},RW={access:"public",registry:"https://registry.npmjs.org/"},mW={"@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",cors:"^2.8.5",express:"^5.1.0",glob:"^11.0.3","gradient-string":"^3.0.0",handlebars:"^4.7.8",http:"^0.0.1-security","oh-my-logo":"^0.3.2",open:"^10.2.0"},IW={"@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"},gW={node:">=18.0.0",bun:">=1.0.0"},yW={"claude-mem":"dist/claude-mem.min.js"},dW=["dist","hooks","commands","docs","src","CHANGELOG.md"],pW={name:AW,version:GW,description:uW,type:hW,main:DW,scripts:CW,keywords:VW,author:MW,license:NW,repository:bW,homepage:SW,bugs:EW,publishConfig:RW,dependencies:mW,devDependencies:IW,engines:gW,bin:yW,files:dW}});import{join as F8,dirname as a3,sep as LW}from"path";import{homedir as V4}from"os";import{existsSync as cK,statSync as lW}from"fs";import{execSync as xW}from"child_process";import{fileURLToPath as nW}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||F8(V4(),".claude-mem"),this._dataDirectory}getArchivesDirectory(){return F8(this.getDataDirectory(),"archives")}getHooksDirectory(){return F8(this.getDataDirectory(),"hooks")}getLogsDirectory(){return F8(this.getDataDirectory(),"logs")}getIndexDirectory(){return this.getDataDirectory()}getIndexPath(){return F8(this.getIndexDirectory(),"claude-mem-index.jsonl")}getTrashDirectory(){return F8(this.getDataDirectory(),"trash")}getBackupsDirectory(){return F8(this.getDataDirectory(),"backups")}getChromaDirectory(){return F8(this.getDataDirectory(),"chroma")}getProjectArchiveDirectory(q){return F8(this.getArchivesDirectory(),q)}getUserSettingsPath(){return F8(this.getDataDirectory(),"settings.json")}getClaudeConfigDirectory(){if(this._claudeConfigDirectory)return this._claudeConfigDirectory;return this._claudeConfigDirectory=process.env.CLAUDE_CONFIG_DIR||F8(V4(),".claude"),this._claudeConfigDirectory}getClaudeSettingsPath(){return F8(this.getClaudeConfigDirectory(),"settings.json")}getClaudeCommandsDirectory(){return F8(this.getClaudeConfigDirectory(),"commands")}getClaudeMdPath(){return F8(this.getClaudeConfigDirectory(),"CLAUDE.md")}getMcpConfigPath(){return F8(V4(),".claude.json")}getProjectMcpConfigPath(){return F8(process.cwd(),".mcp.json")}getPackageRoot(){if(this._packageRoot)return this._packageRoot;try{let j=h6.resolve("/Users/alexnewman/Scripts/claude-mem-source/package.json");return this._packageRoot=a3(j),this._packageRoot}catch{}let q=nW(import.meta.url),_=a3(q);for(let j=0;j<10;j++){let K=F8(_,"package.json");if(cK(K))try{if(h6(K).name==="claude-mem")return this._packageRoot=_,this._packageRoot}catch{}let Y=a3(_);if(Y===_)break;_=Y}try{let j=xW("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=a3(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(),_=F8(q,"hooks"),j=["pre-compact.js","session-start.js"];for(let K of j)if(!cK(F8(_,K)))throw new Error(`Package hooks directory missing required file: ${K}`);return _}findPackageCommandsDirectory(){let q=this.getPackageRoot(),_=F8(q,"commands"),j=["save.md"];for(let K of j)if(!cK(F8(_,K)))throw new Error(`Package commands directory missing required file: ${K}`);return _}ensureDirectory(q){if(!cK(q))h6("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(LW),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 h6("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 cK(q)&&lW(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 MC;var d6=f6(()=>{MC=$8.getInstance()});class yq{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 M4=f6(()=>{d6()});var C6=_8((sW)=>{sW.__esModule=!0;sW.extend=Z1;sW.indexOf=aW;sW.escapeExpression=BW;sW.isEmpty=tW;sW.createFrame=eW;sW.blockParams=FW;sW.appendContextPath=UW;var cW={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},rW=/[&<>"'`=]/g,iW=/[&<>"'`=]/;function oW(q){return cW[q]}function Z1(q){for(var _=1;_{X1.__esModule=!0;var S4=["description","fileName","lineNumber","endLineNumber","message","name","number","stack"];function E4(q,_){var j=_&&_.loc,K=void 0,Y=void 0,f=void 0,P=void 0;if(j)K=j.start.line,Y=j.end.line,f=j.start.column,P=j.end.column,q+=" - "+K+":"+f;var $=Error.prototype.constructor.call(this,q);for(var w=0;w{G1.__esModule=!0;var R4=C6();G1.default=function(q){q.registerHelper("blockHelperMissing",function(_,j){var{inverse:K,fn:Y}=j;if(_===!0)return Y(this);else if(_===!1||_==null)return K(this);else if(R4.isArray(_))if(_.length>0){if(j.ids)j.ids=[j.name];return q.helpers.each(_,j)}else return K(this);else{if(j.data&&j.ids){var f=R4.createFrame(j.data);f.contextPath=R4.appendContextPath(j.data.contextPath,j.name),j={data:f}}return Y(_,j)}})};u1.exports=G1.default});var V1=_8((D1,C1)=>{D1.__esModule=!0;function JH(q){return q&&q.__esModule?q:{default:q}}var rK=C6(),TH=F6(),ZH=JH(TH);D1.default=function(q){q.registerHelper("each",function(_,j){if(!j)throw new ZH.default("Must pass iterator to #each");var{fn:K,inverse:Y}=j,f=0,P="",$=void 0,w=void 0;if(j.data&&j.ids)w=rK.appendContextPath(j.data.contextPath,j.ids[0])+".";if(rK.isFunction(_))_=_.call(this);if(j.data)$=rK.createFrame(j.data);function O(T,H,X){if($){if($.key=T,$.index=H,$.first=H===0,$.last=!!X,w)$.contextPath=w+T}P=P+K(_[T],{data:$,blockParams:rK.blockParams([_[T],T],[w+T,null])})}if(_&&typeof _==="object")if(rK.isArray(_)){for(var v=_.length;f{M1.__esModule=!0;function AH(q){return q&&q.__esModule?q:{default:q}}var GH=F6(),uH=AH(GH);M1.default=function(q){q.registerHelper("helperMissing",function(){if(arguments.length===1)return;else throw new uH.default('Missing helper: "'+arguments[arguments.length-1].name+'"')})};N1.exports=M1.default});var I1=_8((R1,m1)=>{R1.__esModule=!0;function CH(q){return q&&q.__esModule?q:{default:q}}var S1=C6(),VH=F6(),E1=CH(VH);R1.default=function(q){q.registerHelper("if",function(_,j){if(arguments.length!=2)throw new E1.default("#if requires exactly one argument");if(S1.isFunction(_))_=_.call(this);if(!j.hash.includeZero&&!_||S1.isEmpty(_))return j.inverse(this);else return j.fn(this)}),q.registerHelper("unless",function(_,j){if(arguments.length!=2)throw new E1.default("#unless requires exactly one argument");return q.helpers.if.call(this,_,{fn:j.inverse,inverse:j.fn,hash:j.hash})})};m1.exports=R1.default});var d1=_8((g1,y1)=>{g1.__esModule=!0;g1.default=function(q){q.registerHelper("log",function(){var _=[void 0],j=arguments[arguments.length-1];for(var K=0;K{p1.__esModule=!0;p1.default=function(q){q.registerHelper("lookup",function(_,j,K){if(!_)return _;return K.lookupProperty(_,j)})};L1.exports=p1.default});var c1=_8((x1,n1)=>{x1.__esModule=!0;function mH(q){return q&&q.__esModule?q:{default:q}}var iK=C6(),IH=F6(),gH=mH(IH);x1.default=function(q){q.registerHelper("with",function(_,j){if(arguments.length!=2)throw new gH.default("#with requires exactly one argument");if(iK.isFunction(_))_=_.call(this);var K=j.fn;if(!iK.isEmpty(_)){var Y=j.data;if(j.data&&j.ids)Y=iK.createFrame(j.data),Y.contextPath=iK.appendContextPath(j.data.contextPath,j.ids[0]);return K(_,{data:Y,blockParams:iK.blockParams([_],[Y&&Y.contextPath])})}else return j.inverse(this)})};n1.exports=x1.default});var m4=_8((QH)=>{QH.__esModule=!0;QH.registerDefaultHelpers=UH;QH.moveHelperToHooks=sH;function W_(q){return q&&q.__esModule?q:{default:q}}var pH=h1(),LH=W_(pH),lH=V1(),xH=W_(lH),nH=b1(),cH=W_(nH),rH=I1(),iH=W_(rH),oH=d1(),aH=W_(oH),BH=l1(),tH=W_(BH),eH=c1(),FH=W_(eH);function UH(q){LH.default(q),xH.default(q),cH.default(q),iH.default(q),aH.default(q),tH.default(q),FH.default(q)}function sH(q,_,j){if(q.helpers[_]){if(q.hooks[_]=q.helpers[_],!j)delete q.helpers[_]}}});var o1=_8((r1,i1)=>{r1.__esModule=!0;var jJ=C6();r1.default=function(q){q.registerDecorator("inline",function(_,j,K,Y){var f=_;if(!j.partials)j.partials={},f=function(P,$){var w=K.partials;K.partials=jJ.extend({},w,j.partials);var O=_(P,$);return K.partials=w,O};return j.partials[Y.args[0]]=Y.fn,f})};i1.exports=r1.default});var a1=_8((zJ)=>{zJ.__esModule=!0;zJ.registerDefaultDecorators=OJ;function fJ(q){return q&&q.__esModule?q:{default:q}}var $J=o1(),wJ=fJ($J);function OJ(q){wJ.default(q)}});var I4=_8((B1,t1)=>{B1.__esModule=!0;var HJ=C6(),qK={methodMap:["debug","info","warn","error"],level:"info",lookupLevel:function q(_){if(typeof _==="string"){var j=HJ.indexOf(qK.methodMap,_.toLowerCase());if(j>=0)_=j;else _=parseInt(_,10)}return _},log:function q(_){if(_=qK.lookupLevel(_),typeof console!=="undefined"&&qK.lookupLevel(qK.level)<=_){var j=qK.methodMap[_];if(!console[j])j="log";for(var K=arguments.length,Y=Array(K>1?K-1:0),f=1;f{XJ.__esModule=!0;XJ.createNewLookupObject=kJ;var ZJ=C6();function kJ(){for(var q=arguments.length,_=Array(q),j=0;j{bJ.__esModule=!0;bJ.createProtoAccessControl=CJ;bJ.resultIsAllowed=VJ;bJ.resetLoggedProperties=NJ;function uJ(q){return q&&q.__esModule?q:{default:q}}var F1=e1(),hJ=I4(),DJ=uJ(hJ),B3=Object.create(null);function CJ(q){var _=Object.create(null);_.constructor=!1,_.__defineGetter__=!1,_.__defineSetter__=!1,_.__lookupGetter__=!1;var j=Object.create(null);return j.__proto__=!1,{properties:{whitelist:F1.createNewLookupObject(j,q.allowedProtoProperties),defaultValue:q.allowProtoPropertiesByDefault},methods:{whitelist:F1.createNewLookupObject(_,q.allowedProtoMethods),defaultValue:q.allowProtoMethodsByDefault}}}function VJ(q,_,j){if(typeof q==="function")return U1(_.methods,j);else return U1(_.properties,j)}function U1(q,_){if(q.whitelist[_]!==void 0)return q.whitelist[_]===!0;if(q.defaultValue!==void 0)return q.defaultValue;return MJ(_),!1}function MJ(q){if(B3[q]!==!0)B3[q]=!0,DJ.default.log("error",'Handlebars: Access has been denied to resolve the property "'+q+`" because it is not an "own property" of its parent. +`))}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,w=()=>{if($)clearTimeout($);this.pendingMcpResponses.delete(Y)},O=(z)=>{w(),f(z)},v=(z)=>{w(),P(z)};if(this.pendingMcpResponses.set(Y,{resolve:O,reject:v}),j.onmessage)j.onmessage(_.message);else{w(),P(new Error("No message handler registered"));return}$=setTimeout(()=>{if(this.pendingMcpResponses.has(Y))w(),P(new Error("Request timeout"))},30000)})}};k={};WO(k,{void:()=>lz,util:()=>h8,unknown:()=>pz,union:()=>rz,undefined:()=>gz,tuple:()=>az,transformer:()=>g5,symbol:()=>Iz,string:()=>U5,strictObject:()=>cz,setErrorMap:()=>Pz,set:()=>ez,record:()=>Bz,quotelessJson:()=>Kz,promise:()=>_v,preprocess:()=>Pv,pipeline:()=>Yv,ostring:()=>fv,optional:()=>Kv,onumber:()=>$v,oboolean:()=>wv,objectUtil:()=>W4,object:()=>nz,number:()=>s5,nullable:()=>jv,null:()=>yz,never:()=>Lz,nativeEnum:()=>qv,nan:()=>Ez,map:()=>tz,makeIssue:()=>L3,literal:()=>sz,lazy:()=>Uz,late:()=>bz,isValid:()=>$_,isDirty:()=>J4,isAsync:()=>IK,isAborted:()=>H4,intersection:()=>oz,instanceof:()=>Sz,getParsedType:()=>mq,getErrorMap:()=>p3,function:()=>Fz,enum:()=>Qz,effect:()=>g5,discriminatedUnion:()=>iz,defaultErrorMap:()=>n_,datetimeRegex:()=>t5,date:()=>mz,custom:()=>F5,coerce:()=>Ov,boolean:()=>Q5,bigint:()=>Rz,array:()=>xz,any:()=>dz,addIssueToContext:()=>F,ZodVoid:()=>yK,ZodUnknown:()=>aq,ZodUnion:()=>o_,ZodUndefined:()=>r_,ZodType:()=>k8,ZodTuple:()=>Aq,ZodTransformer:()=>B6,ZodSymbol:()=>gK,ZodString:()=>Yq,ZodSet:()=>z_,ZodSchema:()=>k8,ZodRecord:()=>dK,ZodReadonly:()=>s_,ZodPromise:()=>v_,ZodPipeline:()=>lK,ZodParsedType:()=>s,ZodOptional:()=>$q,ZodObject:()=>i8,ZodNumber:()=>Bq,ZodNullable:()=>Iq,ZodNull:()=>i_,ZodNever:()=>Xq,ZodNativeEnum:()=>e_,ZodNaN:()=>LK,ZodMap:()=>pK,ZodLiteral:()=>t_,ZodLazy:()=>B_,ZodIssueCode:()=>t,ZodIntersection:()=>a_,ZodFunction:()=>x_,ZodFirstPartyTypeKind:()=>W8,ZodError:()=>y6,ZodEnum:()=>eq,ZodEffects:()=>B6,ZodDiscriminatedUnion:()=>l3,ZodDefault:()=>F_,ZodDate:()=>w_,ZodCatch:()=>U_,ZodBranded:()=>x3,ZodBoolean:()=>c_,ZodBigInt:()=>tq,ZodArray:()=>fq,ZodAny:()=>O_,Schema:()=>k8,ParseStatus:()=>k6,OK:()=>D6,NEVER:()=>zv,INVALID:()=>v8,EMPTY_PATH:()=>Yz,DIRTY:()=>l_,BRAND:()=>Nz});(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}})(h8||(h8={}));(function(q){q.mergeShapes=(_,j)=>{return{..._,...j}}})(W4||(W4={}));s=h8.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),t=h8.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"]);y6=class y6 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()}};y6.create=(q)=>{return new y6(q)};n_=jz,o5=n_;Yz=[];v8=Object.freeze({status:"aborted"});(function(q){q.errToObj=(_)=>typeof _==="string"?{message:_}:_||{},q.toString=(_)=>typeof _==="string"?_:_?.message})(f8||(f8={}));fz=/^c[^\s-]{8,}$/i,$z=/^[0-9a-z]+$/,wz=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Oz=/^[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,zz=/^[a-z0-9_-]{21}$/i,vz=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Wz=/^[-+]?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)?)??$/,Hz=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tz=/^(?:(?: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])$/,Zz=/^(?:(?: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])$/,kz=/^(([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]))$/,Xz=/^(([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])$/,Az=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Gz=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,uz=new RegExp(`^${a5}$`);Yq=class Yq extends k8{_parse(q){if(this._def.coerce)q.data=String(q.data);if(this._getType(q)!==s.string){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_type,expected:s.string,received:Y.parsedType}),v8}let j=new k6,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,...f8.errToObj(j)})}_addCheck(q){return new Yq({...this._def,checks:[...this._def.checks,q]})}email(q){return this._addCheck({kind:"email",...f8.errToObj(q)})}url(q){return this._addCheck({kind:"url",...f8.errToObj(q)})}emoji(q){return this._addCheck({kind:"emoji",...f8.errToObj(q)})}uuid(q){return this._addCheck({kind:"uuid",...f8.errToObj(q)})}nanoid(q){return this._addCheck({kind:"nanoid",...f8.errToObj(q)})}cuid(q){return this._addCheck({kind:"cuid",...f8.errToObj(q)})}cuid2(q){return this._addCheck({kind:"cuid2",...f8.errToObj(q)})}ulid(q){return this._addCheck({kind:"ulid",...f8.errToObj(q)})}base64(q){return this._addCheck({kind:"base64",...f8.errToObj(q)})}base64url(q){return this._addCheck({kind:"base64url",...f8.errToObj(q)})}jwt(q){return this._addCheck({kind:"jwt",...f8.errToObj(q)})}ip(q){return this._addCheck({kind:"ip",...f8.errToObj(q)})}cidr(q){return this._addCheck({kind:"cidr",...f8.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,...f8.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,...f8.errToObj(q?.message)})}duration(q){return this._addCheck({kind:"duration",...f8.errToObj(q)})}regex(q,_){return this._addCheck({kind:"regex",regex:q,...f8.errToObj(_)})}includes(q,_){return this._addCheck({kind:"includes",value:q,position:_?.position,...f8.errToObj(_?.message)})}startsWith(q,_){return this._addCheck({kind:"startsWith",value:q,...f8.errToObj(_)})}endsWith(q,_){return this._addCheck({kind:"endsWith",value:q,...f8.errToObj(_)})}min(q,_){return this._addCheck({kind:"min",value:q,...f8.errToObj(_)})}max(q,_){return this._addCheck({kind:"max",value:q,...f8.errToObj(_)})}length(q,_){return this._addCheck({kind:"length",value:q,...f8.errToObj(_)})}nonempty(q){return this.min(1,f8.errToObj(q))}trim(){return new Yq({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Yq({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Yq({...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 Yq({checks:[],typeName:W8.ZodString,coerce:q?.coerce??!1,...Z8(q)})};Bq=class Bq 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)!==s.number){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_type,expected:s.number,received:Y.parsedType}),v8}let j=void 0,K=new k6;for(let Y of this._def.checks)if(Y.kind==="int"){if(!h8.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(Mz(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 h8.assertNever(Y);return{status:K.value,value:q.data}}gte(q,_){return this.setLimit("min",q,!0,f8.toString(_))}gt(q,_){return this.setLimit("min",q,!1,f8.toString(_))}lte(q,_){return this.setLimit("max",q,!0,f8.toString(_))}lt(q,_){return this.setLimit("max",q,!1,f8.toString(_))}setLimit(q,_,j,K){return new Bq({...this._def,checks:[...this._def.checks,{kind:q,value:_,inclusive:j,message:f8.toString(K)}]})}_addCheck(q){return new Bq({...this._def,checks:[...this._def.checks,q]})}int(q){return this._addCheck({kind:"int",message:f8.toString(q)})}positive(q){return this._addCheck({kind:"min",value:0,inclusive:!1,message:f8.toString(q)})}negative(q){return this._addCheck({kind:"max",value:0,inclusive:!1,message:f8.toString(q)})}nonpositive(q){return this._addCheck({kind:"max",value:0,inclusive:!0,message:f8.toString(q)})}nonnegative(q){return this._addCheck({kind:"min",value:0,inclusive:!0,message:f8.toString(q)})}multipleOf(q,_){return this._addCheck({kind:"multipleOf",value:q,message:f8.toString(_)})}finite(q){return this._addCheck({kind:"finite",message:f8.toString(q)})}safe(q){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:f8.toString(q)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:f8.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"&&h8.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 Bq({checks:[],typeName:W8.ZodNumber,coerce:q?.coerce||!1,...Z8(q)})};tq=class tq 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)!==s.bigint)return this._getInvalidInput(q);let j=void 0,K=new k6;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 h8.assertNever(Y);return{status:K.value,value:q.data}}_getInvalidInput(q){let _=this._getOrReturnCtx(q);return F(_,{code:t.invalid_type,expected:s.bigint,received:_.parsedType}),v8}gte(q,_){return this.setLimit("min",q,!0,f8.toString(_))}gt(q,_){return this.setLimit("min",q,!1,f8.toString(_))}lte(q,_){return this.setLimit("max",q,!0,f8.toString(_))}lt(q,_){return this.setLimit("max",q,!1,f8.toString(_))}setLimit(q,_,j,K){return new tq({...this._def,checks:[...this._def.checks,{kind:q,value:_,inclusive:j,message:f8.toString(K)}]})}_addCheck(q){return new tq({...this._def,checks:[...this._def.checks,q]})}positive(q){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:f8.toString(q)})}negative(q){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:f8.toString(q)})}nonpositive(q){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:f8.toString(q)})}nonnegative(q){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:f8.toString(q)})}multipleOf(q,_){return this._addCheck({kind:"multipleOf",value:q,message:f8.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 tq({checks:[],typeName:W8.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)!==s.boolean){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:s.boolean,received:j.parsedType}),v8}return D6(q.data)}};c_.create=(q)=>{return new c_({typeName:W8.ZodBoolean,coerce:q?.coerce||!1,...Z8(q)})};w_=class w_ extends k8{_parse(q){if(this._def.coerce)q.data=new Date(q.data);if(this._getType(q)!==s.date){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_type,expected:s.date,received:Y.parsedType}),v8}if(Number.isNaN(q.data.getTime())){let Y=this._getOrReturnCtx(q);return F(Y,{code:t.invalid_date}),v8}let j=new k6,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 h8.assertNever(Y);return{status:j.value,value:new Date(q.data.getTime())}}_addCheck(q){return new w_({...this._def,checks:[...this._def.checks,q]})}min(q,_){return this._addCheck({kind:"min",value:q.getTime(),message:f8.toString(_)})}max(q,_){return this._addCheck({kind:"max",value:q.getTime(),message:f8.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 w_({checks:[],coerce:q?.coerce||!1,typeName:W8.ZodDate,...Z8(q)})};gK=class gK extends k8{_parse(q){if(this._getType(q)!==s.symbol){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:s.symbol,received:j.parsedType}),v8}return D6(q.data)}};gK.create=(q)=>{return new gK({typeName:W8.ZodSymbol,...Z8(q)})};r_=class r_ extends k8{_parse(q){if(this._getType(q)!==s.undefined){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:s.undefined,received:j.parsedType}),v8}return D6(q.data)}};r_.create=(q)=>{return new r_({typeName:W8.ZodUndefined,...Z8(q)})};i_=class i_ extends k8{_parse(q){if(this._getType(q)!==s.null){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:s.null,received:j.parsedType}),v8}return D6(q.data)}};i_.create=(q)=>{return new i_({typeName:W8.ZodNull,...Z8(q)})};O_=class O_ extends k8{constructor(){super(...arguments);this._any=!0}_parse(q){return D6(q.data)}};O_.create=(q)=>{return new O_({typeName:W8.ZodAny,...Z8(q)})};aq=class aq extends k8{constructor(){super(...arguments);this._unknown=!0}_parse(q){return D6(q.data)}};aq.create=(q)=>{return new aq({typeName:W8.ZodUnknown,...Z8(q)})};Xq=class Xq extends k8{_parse(q){let _=this._getOrReturnCtx(q);return F(_,{code:t.invalid_type,expected:s.never,received:_.parsedType}),v8}};Xq.create=(q)=>{return new Xq({typeName:W8.ZodNever,...Z8(q)})};yK=class yK extends k8{_parse(q){if(this._getType(q)!==s.undefined){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:s.void,received:j.parsedType}),v8}return D6(q.data)}};yK.create=(q)=>{return new yK({typeName:W8.ZodVoid,...Z8(q)})};fq=class fq extends k8{_parse(q){let{ctx:_,status:j}=this._processInputParams(q),K=this._def;if(_.parsedType!==s.array)return F(_,{code:t.invalid_type,expected:s.array,received:_.parsedType}),v8;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 wq(_,f,_.path,P))})).then((f)=>{return k6.mergeArray(j,f)});let Y=[..._.data].map((f,P)=>{return K.type._parseSync(new wq(_,f,_.path,P))});return k6.mergeArray(j,Y)}get element(){return this._def.type}min(q,_){return new fq({...this._def,minLength:{value:q,message:f8.toString(_)}})}max(q,_){return new fq({...this._def,maxLength:{value:q,message:f8.toString(_)}})}length(q,_){return new fq({...this._def,exactLength:{value:q,message:f8.toString(_)}})}nonempty(q){return this.min(1,q)}};fq.create=(q,_)=>{return new fq({type:q,minLength:null,maxLength:null,exactLength:null,typeName:W8.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(),_=h8.objectKeys(q);return this._cached={shape:q,keys:_},this._cached}_parse(q){if(this._getType(q)!==s.object){let w=this._getOrReturnCtx(q);return F(w,{code:t.invalid_type,expected:s.object,received:w.parsedType}),v8}let{status:j,ctx:K}=this._processInputParams(q),{shape:Y,keys:f}=this._getCached(),P=[];if(!(this._def.catchall instanceof Xq&&this._def.unknownKeys==="strip")){for(let w in K.data)if(!f.includes(w))P.push(w)}let $=[];for(let w of f){let O=Y[w],v=K.data[w];$.push({key:{status:"valid",value:w},value:O._parse(new wq(K,v,K.path,w)),alwaysSet:w in K.data})}if(this._def.catchall instanceof Xq){let w=this._def.unknownKeys;if(w==="passthrough")for(let O of P)$.push({key:{status:"valid",value:O},value:{status:"valid",value:K.data[O]}});else if(w==="strict"){if(P.length>0)F(K,{code:t.unrecognized_keys,keys:P}),j.dirty()}else if(w==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let w=this._def.catchall;for(let O of P){let v=K.data[O];$.push({key:{status:"valid",value:O},value:w._parse(new wq(K,v,K.path,O)),alwaysSet:O in K.data})}}if(K.common.async)return Promise.resolve().then(async()=>{let w=[];for(let O of $){let v=await O.key,z=await O.value;w.push({key:v,value:z,alwaysSet:O.alwaysSet})}return w}).then((w)=>{return k6.mergeObjectSync(j,w)});else return k6.mergeObjectSync(j,$)}get shape(){return this._def.shape()}strict(q){return f8.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:f8.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:W8.ZodObject})}setKey(q,_){return this.augment({[q]:_})}catchall(q){return new i8({...this._def,catchall:q})}pick(q){let _={};for(let j of h8.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 h8.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 h8.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 h8.objectKeys(this.shape))if(q&&!q[j])_[j]=this.shape[j];else{let Y=this.shape[j];while(Y instanceof $q)Y=Y._def.innerType;_[j]=Y}return new i8({...this._def,shape:()=>_})}keyof(){return e5(h8.objectKeys(this.shape))}};i8.create=(q,_)=>{return new i8({shape:()=>q,unknownKeys:"strip",catchall:Xq.create(),typeName:W8.ZodObject,...Z8(_)})};i8.strictCreate=(q,_)=>{return new i8({shape:()=>q,unknownKeys:"strict",catchall:Xq.create(),typeName:W8.ZodObject,...Z8(_)})};i8.lazycreate=(q,_)=>{return new i8({shape:q,unknownKeys:"strip",catchall:Xq.create(),typeName:W8.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 y6(P.ctx.common.issues));return F(_,{code:t.invalid_union,unionErrors:f}),v8}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 w={..._,common:{..._.common,issues:[]},parent:null},O=$._parseSync({data:_.data,path:_.path,parent:w});if(O.status==="valid")return O;else if(O.status==="dirty"&&!Y)Y={result:O,ctx:w};if(w.common.issues.length)f.push(w.common.issues)}if(Y)return _.common.issues.push(...Y.ctx.common.issues),Y.result;let P=f.map(($)=>new y6($));return F(_,{code:t.invalid_union,unionErrors:P}),v8}}get options(){return this._def.options}};o_.create=(q,_)=>{return new o_({options:q,typeName:W8.ZodUnion,...Z8(_)})};l3=class l3 extends k8{_parse(q){let{ctx:_}=this._processInputParams(q);if(_.parsedType!==s.object)return F(_,{code:t.invalid_type,expected:s.object,received:_.parsedType}),v8;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]}),v8;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=Rq(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 l3({typeName:W8.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(H4(Y)||H4(f))return v8;let P=T4(Y.value,f.value);if(!P.valid)return F(j,{code:t.invalid_intersection_types}),v8;if(J4(Y)||J4(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:W8.ZodIntersection,...Z8(j)})};Aq=class Aq extends k8{_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.parsedType!==s.array)return F(j,{code:t.invalid_type,expected:s.array,received:j.parsedType}),v8;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 wq(j,f,j.path,P))}).filter((f)=>!!f);if(j.common.async)return Promise.all(Y).then((f)=>{return k6.mergeArray(_,f)});else return k6.mergeArray(_,Y)}get items(){return this._def.items}rest(q){return new Aq({...this._def,rest:q})}};Aq.create=(q,_)=>{if(!Array.isArray(q))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Aq({items:q,typeName:W8.ZodTuple,rest:null,...Z8(_)})};dK=class dK 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!==s.object)return F(j,{code:t.invalid_type,expected:s.object,received:j.parsedType}),v8;let K=[],Y=this._def.keyType,f=this._def.valueType;for(let P in j.data)K.push({key:Y._parse(new wq(j,P,j.path,P)),value:f._parse(new wq(j,j.data[P],j.path,P)),alwaysSet:P in j.data});if(j.common.async)return k6.mergeObjectAsync(_,K);else return k6.mergeObjectSync(_,K)}get element(){return this._def.valueType}static create(q,_,j){if(_ instanceof k8)return new dK({keyType:q,valueType:_,typeName:W8.ZodRecord,...Z8(j)});return new dK({keyType:Yq.create(),valueType:q,typeName:W8.ZodRecord,...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!==s.map)return F(j,{code:t.invalid_type,expected:s.map,received:j.parsedType}),v8;let K=this._def.keyType,Y=this._def.valueType,f=[...j.data.entries()].map(([P,$],w)=>{return{key:K._parse(new wq(j,P,j.path,[w,"key"])),value:Y._parse(new wq(j,$,j.path,[w,"value"]))}});if(j.common.async){let P=new Map;return Promise.resolve().then(async()=>{for(let $ of f){let w=await $.key,O=await $.value;if(w.status==="aborted"||O.status==="aborted")return v8;if(w.status==="dirty"||O.status==="dirty")_.dirty();P.set(w.value,O.value)}return{status:_.value,value:P}})}else{let P=new Map;for(let $ of f){let{key:w,value:O}=$;if(w.status==="aborted"||O.status==="aborted")return v8;if(w.status==="dirty"||O.status==="dirty")_.dirty();P.set(w.value,O.value)}return{status:_.value,value:P}}}};pK.create=(q,_,j)=>{return new pK({valueType:_,keyType:q,typeName:W8.ZodMap,...Z8(j)})};z_=class z_ extends k8{_parse(q){let{status:_,ctx:j}=this._processInputParams(q);if(j.parsedType!==s.set)return F(j,{code:t.invalid_type,expected:s.set,received:j.parsedType}),v8;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 w=new Set;for(let O of $){if(O.status==="aborted")return v8;if(O.status==="dirty")_.dirty();w.add(O.value)}return{status:_.value,value:w}}let P=[...j.data.values()].map(($,w)=>Y._parse(new wq(j,$,j.path,w)));if(j.common.async)return Promise.all(P).then(($)=>f($));else return f(P)}min(q,_){return new z_({...this._def,minSize:{value:q,message:f8.toString(_)}})}max(q,_){return new z_({...this._def,maxSize:{value:q,message:f8.toString(_)}})}size(q,_){return this.min(q,_).max(q,_)}nonempty(q){return this.min(1,q)}};z_.create=(q,_)=>{return new z_({valueType:q,minSize:null,maxSize:null,typeName:W8.ZodSet,...Z8(_)})};x_=class x_ extends k8{constructor(){super(...arguments);this.validate=this.implement}_parse(q){let{ctx:_}=this._processInputParams(q);if(_.parsedType!==s.function)return F(_,{code:t.invalid_type,expected:s.function,received:_.parsedType}),v8;function j(P,$){return L3({data:P,path:_.path,errorMaps:[_.common.contextualErrorMap,_.schemaErrorMap,p3(),n_].filter((w)=>!!w),issueData:{code:t.invalid_arguments,argumentsError:$}})}function K(P,$){return L3({data:P,path:_.path,errorMaps:[_.common.contextualErrorMap,_.schemaErrorMap,p3(),n_].filter((w)=>!!w),issueData:{code:t.invalid_return_type,returnTypeError:$}})}let Y={errorMap:_.common.contextualErrorMap},f=_.data;if(this._def.returns instanceof v_){let P=this;return D6(async function(...$){let w=new y6([]),O=await P._def.args.parseAsync($,Y).catch((W)=>{throw w.addIssue(j($,W)),w}),v=await Reflect.apply(f,this,O);return await P._def.returns._def.type.parseAsync(v,Y).catch((W)=>{throw w.addIssue(K(v,W)),w})})}else{let P=this;return D6(function(...$){let w=P._def.args.safeParse($,Y);if(!w.success)throw new y6([j($,w.error)]);let O=Reflect.apply(f,this,w.data),v=P._def.returns.safeParse(O,Y);if(!v.success)throw new y6([K(O,v.error)]);return v.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...q){return new x_({...this._def,args:Aq.create(q).rest(aq.create())})}returns(q){return new x_({...this._def,returns:q})}implement(q){return this.parse(q)}strictImplement(q){return this.parse(q)}static create(q,_,j){return new x_({args:q?q:Aq.create([]).rest(aq.create()),returns:_||aq.create(),typeName:W8.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:W8.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}),v8}return{status:"valid",value:q.data}}get value(){return this._def.value}};t_.create=(q,_)=>{return new t_({value:q,typeName:W8.ZodLiteral,...Z8(_)})};eq=class eq extends k8{_parse(q){if(typeof q.data!=="string"){let _=this._getOrReturnCtx(q),j=this._def.values;return F(_,{expected:h8.joinValues(j),received:_.parsedType,code:t.invalid_type}),v8}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}),v8}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 eq.create(q,{...this._def,..._})}exclude(q,_=this._def){return eq.create(this.options.filter((j)=>!q.includes(j)),{...this._def,..._})}};eq.create=e5;e_=class e_ extends k8{_parse(q){let _=h8.getValidEnumValues(this._def.values),j=this._getOrReturnCtx(q);if(j.parsedType!==s.string&&j.parsedType!==s.number){let K=h8.objectValues(_);return F(j,{expected:h8.joinValues(K),received:j.parsedType,code:t.invalid_type}),v8}if(!this._cache)this._cache=new Set(h8.getValidEnumValues(this._def.values));if(!this._cache.has(q.data)){let K=h8.objectValues(_);return F(j,{received:j.data,code:t.invalid_enum_value,options:K}),v8}return D6(q.data)}get enum(){return this._def.values}};e_.create=(q,_)=>{return new e_({values:q,typeName:W8.ZodNativeEnum,...Z8(_)})};v_=class v_ extends k8{unwrap(){return this._def.type}_parse(q){let{ctx:_}=this._processInputParams(q);if(_.parsedType!==s.promise&&_.common.async===!1)return F(_,{code:t.invalid_type,expected:s.promise,received:_.parsedType}),v8;let j=_.parsedType===s.promise?_.data:Promise.resolve(_.data);return D6(j.then((K)=>{return this._def.type.parseAsync(K,{path:_.path,errorMap:_.common.contextualErrorMap})}))}};v_.create=(q,_)=>{return new v_({type:q,typeName:W8.ZodPromise,...Z8(_)})};B6=class B6 extends k8{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===W8.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 v8;let $=await this._def.schema._parseAsync({data:P,path:j.path,parent:j});if($.status==="aborted")return v8;if($.status==="dirty")return l_($.value);if(_.value==="dirty")return l_($.value);return $});else{if(_.value==="aborted")return v8;let P=this._def.schema._parseSync({data:f,path:j.path,parent:j});if(P.status==="aborted")return v8;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 v8;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 v8;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(!$_(f))return v8;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(!$_(f))return v8;return Promise.resolve(K.transform(f.value,Y)).then((P)=>({status:_.value,value:P}))});h8.assertNever(K)}};B6.create=(q,_,j)=>{return new B6({schema:q,typeName:W8.ZodEffects,effect:_,...Z8(j)})};B6.createWithPreprocess=(q,_,j)=>{return new B6({schema:_,effect:{type:"preprocess",transform:q},typeName:W8.ZodEffects,...Z8(j)})};$q=class $q extends k8{_parse(q){if(this._getType(q)===s.undefined)return D6(void 0);return this._def.innerType._parse(q)}unwrap(){return this._def.innerType}};$q.create=(q,_)=>{return new $q({innerType:q,typeName:W8.ZodOptional,...Z8(_)})};Iq=class Iq extends k8{_parse(q){if(this._getType(q)===s.null)return D6(null);return this._def.innerType._parse(q)}unwrap(){return this._def.innerType}};Iq.create=(q,_)=>{return new Iq({innerType:q,typeName:W8.ZodNullable,...Z8(_)})};F_=class F_ extends k8{_parse(q){let{ctx:_}=this._processInputParams(q),j=_.data;if(_.parsedType===s.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:W8.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(IK(K))return K.then((Y)=>{return{status:"valid",value:Y.status==="valid"?Y.value:this._def.catchValue({get error(){return new y6(j.common.issues)},input:j.data})}});else return{status:"valid",value:K.status==="valid"?K.value:this._def.catchValue({get error(){return new y6(j.common.issues)},input:j.data})}}removeCatch(){return this._def.innerType}};U_.create=(q,_)=>{return new U_({innerType:q,typeName:W8.ZodCatch,catchValue:typeof _.catch==="function"?_.catch:()=>_.catch,...Z8(_)})};LK=class LK extends k8{_parse(q){if(this._getType(q)!==s.nan){let j=this._getOrReturnCtx(q);return F(j,{code:t.invalid_type,expected:s.nan,received:j.parsedType}),v8}return{status:"valid",value:q.data}}};LK.create=(q)=>{return new LK({typeName:W8.ZodNaN,...Z8(q)})};Nz=Symbol("zod_brand");x3=class x3 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}};lK=class lK 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 v8;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 v8;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 lK({in:q,out:_,typeName:W8.ZodPipeline})}};s_=class s_ extends k8{_parse(q){let _=this._def.innerType._parse(q),j=(K)=>{if($_(K))K.value=Object.freeze(K.value);return K};return IK(_)?_.then((K)=>j(K)):j(_)}unwrap(){return this._def.innerType}};s_.create=(q,_)=>{return new s_({innerType:q,typeName:W8.ZodReadonly,...Z8(_)})};bz={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"})(W8||(W8={}));U5=Yq.create,s5=Bq.create,Ez=LK.create,Rz=tq.create,Q5=c_.create,mz=w_.create,Iz=gK.create,gz=r_.create,yz=i_.create,dz=O_.create,pz=aq.create,Lz=Xq.create,lz=yK.create,xz=fq.create,nz=i8.create,cz=i8.strictCreate,rz=o_.create,iz=l3.create,oz=a_.create,az=Aq.create,Bz=dK.create,tz=pK.create,ez=z_.create,Fz=x_.create,Uz=B_.create,sz=t_.create,Qz=eq.create,qv=e_.create,_v=v_.create,g5=B6.create,Kv=$q.create,jv=Iq.create,Pv=B6.createWithPreprocess,Yv=lK.create,Ov={string:(q)=>Yq.create({...q,coerce:!0}),number:(q)=>Bq.create({...q,coerce:!0}),boolean:(q)=>c_.create({...q,coerce:!0}),bigint:(q)=>tq.create({...q,coerce:!0}),date:(q)=>w_.create({...q,coerce:!0})},zv=v8,q1=k.union([k.string(),k.number().int()]),_1=k.string(),vv=k.object({progressToken:k.optional(q1)}).passthrough(),t6=k.object({_meta:k.optional(vv)}).passthrough(),S6=k.object({method:k.string(),params:k.optional(t6)}),xK=k.object({_meta:k.optional(k.object({}).passthrough())}).passthrough(),Gq=k.object({method:k.string(),params:k.optional(xK)}),e6=k.object({_meta:k.optional(k.object({}).passthrough())}).passthrough(),c3=k.union([k.string(),k.number().int()]),Wv=k.object({jsonrpc:k.literal(n3),id:c3}).merge(S6).strict(),Hv=k.object({jsonrpc:k.literal(n3)}).merge(Gq).strict(),Jv=k.object({jsonrpc:k.literal(n3),id:c3,result:e6}).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"})(y5||(y5={}));Tv=k.object({jsonrpc:k.literal(n3),id:c3,error:k.object({code:k.number().int(),message:k.string(),data:k.optional(k.unknown())})}).strict(),OC=k.union([Wv,Hv,Jv,Tv]),K1=e6.strict(),j1=Gq.extend({method:k.literal("notifications/cancelled"),params:xK.extend({requestId:c3,reason:k.string().optional()})}),nK=k.object({name:k.string(),title:k.optional(k.string())}).passthrough(),P1=nK.extend({version:k.string()}),Zv=k.object({experimental:k.optional(k.object({}).passthrough()),sampling:k.optional(k.object({}).passthrough()),elicitation:k.optional(k.object({}).passthrough()),roots:k.optional(k.object({listChanged:k.optional(k.boolean())}).passthrough())}).passthrough(),kv=S6.extend({method:k.literal("initialize"),params:t6.extend({protocolVersion:k.string(),capabilities:Zv,clientInfo:P1})}),Xv=k.object({experimental:k.optional(k.object({}).passthrough()),logging:k.optional(k.object({}).passthrough()),completions:k.optional(k.object({}).passthrough()),prompts:k.optional(k.object({listChanged:k.optional(k.boolean())}).passthrough()),resources:k.optional(k.object({subscribe:k.optional(k.boolean()),listChanged:k.optional(k.boolean())}).passthrough()),tools:k.optional(k.object({listChanged:k.optional(k.boolean())}).passthrough())}).passthrough(),Av=e6.extend({protocolVersion:k.string(),capabilities:Xv,serverInfo:P1,instructions:k.optional(k.string())}),Gv=Gq.extend({method:k.literal("notifications/initialized")}),Y1=S6.extend({method:k.literal("ping")}),uv=k.object({progress:k.number(),total:k.optional(k.number()),message:k.optional(k.string())}).passthrough(),f1=Gq.extend({method:k.literal("notifications/progress"),params:xK.merge(uv).extend({progressToken:q1})}),r3=S6.extend({params:t6.extend({cursor:k.optional(_1)}).optional()}),i3=e6.extend({nextCursor:k.optional(_1)}),$1=k.object({uri:k.string(),mimeType:k.optional(k.string()),_meta:k.optional(k.object({}).passthrough())}).passthrough(),w1=$1.extend({text:k.string()}),u4=k.string().refine((q)=>{try{return atob(q),!0}catch(_){return!1}},{message:"Invalid Base64 string"}),O1=$1.extend({blob:u4}),z1=nK.extend({uri:k.string(),description:k.optional(k.string()),mimeType:k.optional(k.string()),_meta:k.optional(k.object({}).passthrough())}),hv=nK.extend({uriTemplate:k.string(),description:k.optional(k.string()),mimeType:k.optional(k.string()),_meta:k.optional(k.object({}).passthrough())}),Dv=r3.extend({method:k.literal("resources/list")}),Cv=i3.extend({resources:k.array(z1)}),Vv=r3.extend({method:k.literal("resources/templates/list")}),Mv=i3.extend({resourceTemplates:k.array(hv)}),Nv=S6.extend({method:k.literal("resources/read"),params:t6.extend({uri:k.string()})}),bv=e6.extend({contents:k.array(k.union([w1,O1]))}),Sv=Gq.extend({method:k.literal("notifications/resources/list_changed")}),Ev=S6.extend({method:k.literal("resources/subscribe"),params:t6.extend({uri:k.string()})}),Rv=S6.extend({method:k.literal("resources/unsubscribe"),params:t6.extend({uri:k.string()})}),mv=Gq.extend({method:k.literal("notifications/resources/updated"),params:xK.extend({uri:k.string()})}),Iv=k.object({name:k.string(),description:k.optional(k.string()),required:k.optional(k.boolean())}).passthrough(),gv=nK.extend({description:k.optional(k.string()),arguments:k.optional(k.array(Iv)),_meta:k.optional(k.object({}).passthrough())}),yv=r3.extend({method:k.literal("prompts/list")}),dv=i3.extend({prompts:k.array(gv)}),pv=S6.extend({method:k.literal("prompts/get"),params:t6.extend({name:k.string(),arguments:k.optional(k.record(k.string()))})}),h4=k.object({type:k.literal("text"),text:k.string(),_meta:k.optional(k.object({}).passthrough())}).passthrough(),D4=k.object({type:k.literal("image"),data:u4,mimeType:k.string(),_meta:k.optional(k.object({}).passthrough())}).passthrough(),C4=k.object({type:k.literal("audio"),data:u4,mimeType:k.string(),_meta:k.optional(k.object({}).passthrough())}).passthrough(),Lv=k.object({type:k.literal("resource"),resource:k.union([w1,O1]),_meta:k.optional(k.object({}).passthrough())}).passthrough(),lv=z1.extend({type:k.literal("resource_link")}),v1=k.union([h4,D4,C4,lv,Lv]),xv=k.object({role:k.enum(["user","assistant"]),content:v1}).passthrough(),nv=e6.extend({description:k.optional(k.string()),messages:k.array(xv)}),cv=Gq.extend({method:k.literal("notifications/prompts/list_changed")}),rv=k.object({title:k.optional(k.string()),readOnlyHint:k.optional(k.boolean()),destructiveHint:k.optional(k.boolean()),idempotentHint:k.optional(k.boolean()),openWorldHint:k.optional(k.boolean())}).passthrough(),iv=nK.extend({description:k.optional(k.string()),inputSchema:k.object({type:k.literal("object"),properties:k.optional(k.object({}).passthrough()),required:k.optional(k.array(k.string()))}).passthrough(),outputSchema:k.optional(k.object({type:k.literal("object"),properties:k.optional(k.object({}).passthrough()),required:k.optional(k.array(k.string()))}).passthrough()),annotations:k.optional(rv),_meta:k.optional(k.object({}).passthrough())}),ov=r3.extend({method:k.literal("tools/list")}),av=i3.extend({tools:k.array(iv)}),W1=e6.extend({content:k.array(v1).default([]),structuredContent:k.object({}).passthrough().optional(),isError:k.optional(k.boolean())}),zC=W1.or(e6.extend({toolResult:k.unknown()})),Bv=S6.extend({method:k.literal("tools/call"),params:t6.extend({name:k.string(),arguments:k.optional(k.record(k.unknown()))})}),tv=Gq.extend({method:k.literal("notifications/tools/list_changed")}),H1=k.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),ev=S6.extend({method:k.literal("logging/setLevel"),params:t6.extend({level:H1})}),Fv=Gq.extend({method:k.literal("notifications/message"),params:xK.extend({level:H1,logger:k.optional(k.string()),data:k.unknown()})}),Uv=k.object({name:k.string().optional()}).passthrough(),sv=k.object({hints:k.optional(k.array(Uv)),costPriority:k.optional(k.number().min(0).max(1)),speedPriority:k.optional(k.number().min(0).max(1)),intelligencePriority:k.optional(k.number().min(0).max(1))}).passthrough(),Qv=k.object({role:k.enum(["user","assistant"]),content:k.union([h4,D4,C4])}).passthrough(),qW=S6.extend({method:k.literal("sampling/createMessage"),params:t6.extend({messages:k.array(Qv),systemPrompt:k.optional(k.string()),includeContext:k.optional(k.enum(["none","thisServer","allServers"])),temperature:k.optional(k.number()),maxTokens:k.number().int(),stopSequences:k.optional(k.array(k.string())),metadata:k.optional(k.object({}).passthrough()),modelPreferences:k.optional(sv)})}),_W=e6.extend({model:k.string(),stopReason:k.optional(k.enum(["endTurn","stopSequence","maxTokens"]).or(k.string())),role:k.enum(["user","assistant"]),content:k.discriminatedUnion("type",[h4,D4,C4])}),KW=k.object({type:k.literal("boolean"),title:k.optional(k.string()),description:k.optional(k.string()),default:k.optional(k.boolean())}).passthrough(),jW=k.object({type:k.literal("string"),title:k.optional(k.string()),description:k.optional(k.string()),minLength:k.optional(k.number()),maxLength:k.optional(k.number()),format:k.optional(k.enum(["email","uri","date","date-time"]))}).passthrough(),PW=k.object({type:k.enum(["number","integer"]),title:k.optional(k.string()),description:k.optional(k.string()),minimum:k.optional(k.number()),maximum:k.optional(k.number())}).passthrough(),YW=k.object({type:k.literal("string"),title:k.optional(k.string()),description:k.optional(k.string()),enum:k.array(k.string()),enumNames:k.optional(k.array(k.string()))}).passthrough(),fW=k.union([KW,jW,PW,YW]),$W=S6.extend({method:k.literal("elicitation/create"),params:t6.extend({message:k.string(),requestedSchema:k.object({type:k.literal("object"),properties:k.record(k.string(),fW),required:k.optional(k.array(k.string()))}).passthrough()})}),wW=e6.extend({action:k.enum(["accept","decline","cancel"]),content:k.optional(k.record(k.string(),k.unknown()))}),OW=k.object({type:k.literal("ref/resource"),uri:k.string()}).passthrough(),zW=k.object({type:k.literal("ref/prompt"),name:k.string()}).passthrough(),vW=S6.extend({method:k.literal("completion/complete"),params:t6.extend({ref:k.union([zW,OW]),argument:k.object({name:k.string(),value:k.string()}).passthrough(),context:k.optional(k.object({arguments:k.optional(k.record(k.string(),k.string()))}))})}),WW=e6.extend({completion:k.object({values:k.array(k.string()).max(100),total:k.optional(k.number().int()),hasMore:k.optional(k.boolean())}).passthrough()}),HW=k.object({uri:k.string().startsWith("file://"),name:k.optional(k.string()),_meta:k.optional(k.object({}).passthrough())}).passthrough(),JW=S6.extend({method:k.literal("roots/list")}),TW=e6.extend({roots:k.array(HW)}),ZW=Gq.extend({method:k.literal("notifications/roots/list_changed")}),vC=k.union([Y1,kv,vW,ev,pv,yv,Dv,Vv,Nv,Ev,Rv,Bv,ov]),WC=k.union([j1,f1,Gv,ZW]),HC=k.union([K1,_W,wW,TW]),JC=k.union([Y1,qW,$W,JW]),TC=k.union([j1,f1,Fv,mv,Sv,tv,cv]),ZC=k.union([K1,Av,WW,nv,dv,Cv,Mv,bv,W1,av]),kC=vO(aO(),1),XC=Symbol("Let zodToJsonSchema decide on which parser to use"),AC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");(function(q){q.Completable="McpCompletable"})(Z4||(Z4={}));k4=class k4 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}};k4.create=(q,_)=>{return new k4({type:q,typeName:Z4.Completable,complete:_.complete,...kW(_)})}});var J1={};EK(J1,{version:()=>GW,type:()=>hW,scripts:()=>CW,repository:()=>bW,publishConfig:()=>RW,name:()=>AW,main:()=>DW,license:()=>NW,keywords:()=>VW,homepage:()=>SW,files:()=>dW,engines:()=>gW,devDependencies:()=>IW,description:()=>uW,dependencies:()=>mW,default:()=>pW,bugs:()=>EW,bin:()=>yW,author:()=>MW});var AW="claude-mem",GW="3.6.6",uW="Memory compression system for Claude Code - persist context across sessions",hW="module",DW="claude-mem",CW,VW,MW="Alex Newman",NW="SEE LICENSE IN LICENSE",bW,SW="https://github.com/thedotmack/claude-mem#readme",EW,RW,mW,IW,gW,yW,dW,pW;var T1=f6(()=>{CW={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-with-changelog.sh","publish:latest":"./scripts/publish-with-changelog.sh bump","publish:github":"./scripts/github-publish.sh"},VW=["claude","claude-code","mcp","memory","compression","knowledge-graph","transcript","cli","typescript","bun"],bW={type:"git",url:"https://github.com/thedotmack/claude-mem.git"},EW={url:"https://github.com/thedotmack/claude-mem/issues"},RW={access:"public",registry:"https://registry.npmjs.org/"},mW={"@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",cors:"^2.8.5",express:"^5.1.0",glob:"^11.0.3","gradient-string":"^3.0.0",handlebars:"^4.7.8",http:"^0.0.1-security","oh-my-logo":"^0.3.2",open:"^10.2.0"},IW={"@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"},gW={node:">=18.0.0",bun:">=1.0.0"},yW={"claude-mem":"dist/claude-mem.min.js"},dW=["dist","hooks","commands","docs","src","CHANGELOG.md"],pW={name:AW,version:GW,description:uW,type:hW,main:DW,scripts:CW,keywords:VW,author:MW,license:NW,repository:bW,homepage:SW,bugs:EW,publishConfig:RW,dependencies:mW,devDependencies:IW,engines:gW,bin:yW,files:dW}});import{join as F8,dirname as a3,sep as LW}from"path";import{homedir as V4}from"os";import{existsSync as cK,statSync as lW}from"fs";import{execSync as xW}from"child_process";import{fileURLToPath as nW}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||F8(V4(),".claude-mem"),this._dataDirectory}getArchivesDirectory(){return F8(this.getDataDirectory(),"archives")}getHooksDirectory(){return F8(this.getDataDirectory(),"hooks")}getLogsDirectory(){return F8(this.getDataDirectory(),"logs")}getIndexDirectory(){return this.getDataDirectory()}getIndexPath(){return F8(this.getIndexDirectory(),"claude-mem-index.jsonl")}getTrashDirectory(){return F8(this.getDataDirectory(),"trash")}getBackupsDirectory(){return F8(this.getDataDirectory(),"backups")}getChromaDirectory(){return F8(this.getDataDirectory(),"chroma")}getProjectArchiveDirectory(q){return F8(this.getArchivesDirectory(),q)}getUserSettingsPath(){return F8(this.getDataDirectory(),"settings.json")}getClaudeConfigDirectory(){if(this._claudeConfigDirectory)return this._claudeConfigDirectory;return this._claudeConfigDirectory=process.env.CLAUDE_CONFIG_DIR||F8(V4(),".claude"),this._claudeConfigDirectory}getClaudeSettingsPath(){return F8(this.getClaudeConfigDirectory(),"settings.json")}getClaudeCommandsDirectory(){return F8(this.getClaudeConfigDirectory(),"commands")}getClaudeMdPath(){return F8(this.getClaudeConfigDirectory(),"CLAUDE.md")}getMcpConfigPath(){return F8(V4(),".claude.json")}getProjectMcpConfigPath(){return F8(process.cwd(),".mcp.json")}getPackageRoot(){if(this._packageRoot)return this._packageRoot;try{let j=h6.resolve("/Users/alexnewman/Scripts/claude-mem-source/package.json");return this._packageRoot=a3(j),this._packageRoot}catch{}let q=nW(import.meta.url),_=a3(q);for(let j=0;j<10;j++){let K=F8(_,"package.json");if(cK(K))try{if(h6(K).name==="claude-mem")return this._packageRoot=_,this._packageRoot}catch{}let Y=a3(_);if(Y===_)break;_=Y}try{let j=xW("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=a3(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(),_=F8(q,"hooks"),j=["pre-compact.js","session-start.js"];for(let K of j)if(!cK(F8(_,K)))throw new Error(`Package hooks directory missing required file: ${K}`);return _}findPackageCommandsDirectory(){let q=this.getPackageRoot(),_=F8(q,"commands"),j=["save.md"];for(let K of j)if(!cK(F8(_,K)))throw new Error(`Package commands directory missing required file: ${K}`);return _}ensureDirectory(q){if(!cK(q))h6("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(LW),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 h6("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 cK(q)&&lW(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 MC;var d6=f6(()=>{MC=$8.getInstance()});class yq{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 M4=f6(()=>{d6()});var C6=_8((sW)=>{sW.__esModule=!0;sW.extend=Z1;sW.indexOf=aW;sW.escapeExpression=BW;sW.isEmpty=tW;sW.createFrame=eW;sW.blockParams=FW;sW.appendContextPath=UW;var cW={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},rW=/[&<>"'`=]/g,iW=/[&<>"'`=]/;function oW(q){return cW[q]}function Z1(q){for(var _=1;_{X1.__esModule=!0;var S4=["description","fileName","lineNumber","endLineNumber","message","name","number","stack"];function E4(q,_){var j=_&&_.loc,K=void 0,Y=void 0,f=void 0,P=void 0;if(j)K=j.start.line,Y=j.end.line,f=j.start.column,P=j.end.column,q+=" - "+K+":"+f;var $=Error.prototype.constructor.call(this,q);for(var w=0;w{G1.__esModule=!0;var R4=C6();G1.default=function(q){q.registerHelper("blockHelperMissing",function(_,j){var{inverse:K,fn:Y}=j;if(_===!0)return Y(this);else if(_===!1||_==null)return K(this);else if(R4.isArray(_))if(_.length>0){if(j.ids)j.ids=[j.name];return q.helpers.each(_,j)}else return K(this);else{if(j.data&&j.ids){var f=R4.createFrame(j.data);f.contextPath=R4.appendContextPath(j.data.contextPath,j.name),j={data:f}}return Y(_,j)}})};u1.exports=G1.default});var V1=_8((D1,C1)=>{D1.__esModule=!0;function JH(q){return q&&q.__esModule?q:{default:q}}var rK=C6(),TH=F6(),ZH=JH(TH);D1.default=function(q){q.registerHelper("each",function(_,j){if(!j)throw new ZH.default("Must pass iterator to #each");var{fn:K,inverse:Y}=j,f=0,P="",$=void 0,w=void 0;if(j.data&&j.ids)w=rK.appendContextPath(j.data.contextPath,j.ids[0])+".";if(rK.isFunction(_))_=_.call(this);if(j.data)$=rK.createFrame(j.data);function O(T,H,X){if($){if($.key=T,$.index=H,$.first=H===0,$.last=!!X,w)$.contextPath=w+T}P=P+K(_[T],{data:$,blockParams:rK.blockParams([_[T],T],[w+T,null])})}if(_&&typeof _==="object")if(rK.isArray(_)){for(var v=_.length;f{M1.__esModule=!0;function AH(q){return q&&q.__esModule?q:{default:q}}var GH=F6(),uH=AH(GH);M1.default=function(q){q.registerHelper("helperMissing",function(){if(arguments.length===1)return;else throw new uH.default('Missing helper: "'+arguments[arguments.length-1].name+'"')})};N1.exports=M1.default});var I1=_8((R1,m1)=>{R1.__esModule=!0;function CH(q){return q&&q.__esModule?q:{default:q}}var S1=C6(),VH=F6(),E1=CH(VH);R1.default=function(q){q.registerHelper("if",function(_,j){if(arguments.length!=2)throw new E1.default("#if requires exactly one argument");if(S1.isFunction(_))_=_.call(this);if(!j.hash.includeZero&&!_||S1.isEmpty(_))return j.inverse(this);else return j.fn(this)}),q.registerHelper("unless",function(_,j){if(arguments.length!=2)throw new E1.default("#unless requires exactly one argument");return q.helpers.if.call(this,_,{fn:j.inverse,inverse:j.fn,hash:j.hash})})};m1.exports=R1.default});var d1=_8((g1,y1)=>{g1.__esModule=!0;g1.default=function(q){q.registerHelper("log",function(){var _=[void 0],j=arguments[arguments.length-1];for(var K=0;K{p1.__esModule=!0;p1.default=function(q){q.registerHelper("lookup",function(_,j,K){if(!_)return _;return K.lookupProperty(_,j)})};L1.exports=p1.default});var c1=_8((x1,n1)=>{x1.__esModule=!0;function mH(q){return q&&q.__esModule?q:{default:q}}var iK=C6(),IH=F6(),gH=mH(IH);x1.default=function(q){q.registerHelper("with",function(_,j){if(arguments.length!=2)throw new gH.default("#with requires exactly one argument");if(iK.isFunction(_))_=_.call(this);var K=j.fn;if(!iK.isEmpty(_)){var Y=j.data;if(j.data&&j.ids)Y=iK.createFrame(j.data),Y.contextPath=iK.appendContextPath(j.data.contextPath,j.ids[0]);return K(_,{data:Y,blockParams:iK.blockParams([_],[Y&&Y.contextPath])})}else return j.inverse(this)})};n1.exports=x1.default});var m4=_8((QH)=>{QH.__esModule=!0;QH.registerDefaultHelpers=UH;QH.moveHelperToHooks=sH;function W_(q){return q&&q.__esModule?q:{default:q}}var pH=h1(),LH=W_(pH),lH=V1(),xH=W_(lH),nH=b1(),cH=W_(nH),rH=I1(),iH=W_(rH),oH=d1(),aH=W_(oH),BH=l1(),tH=W_(BH),eH=c1(),FH=W_(eH);function UH(q){LH.default(q),xH.default(q),cH.default(q),iH.default(q),aH.default(q),tH.default(q),FH.default(q)}function sH(q,_,j){if(q.helpers[_]){if(q.hooks[_]=q.helpers[_],!j)delete q.helpers[_]}}});var o1=_8((r1,i1)=>{r1.__esModule=!0;var jJ=C6();r1.default=function(q){q.registerDecorator("inline",function(_,j,K,Y){var f=_;if(!j.partials)j.partials={},f=function(P,$){var w=K.partials;K.partials=jJ.extend({},w,j.partials);var O=_(P,$);return K.partials=w,O};return j.partials[Y.args[0]]=Y.fn,f})};i1.exports=r1.default});var a1=_8((zJ)=>{zJ.__esModule=!0;zJ.registerDefaultDecorators=OJ;function fJ(q){return q&&q.__esModule?q:{default:q}}var $J=o1(),wJ=fJ($J);function OJ(q){wJ.default(q)}});var I4=_8((B1,t1)=>{B1.__esModule=!0;var HJ=C6(),qK={methodMap:["debug","info","warn","error"],level:"info",lookupLevel:function q(_){if(typeof _==="string"){var j=HJ.indexOf(qK.methodMap,_.toLowerCase());if(j>=0)_=j;else _=parseInt(_,10)}return _},log:function q(_){if(_=qK.lookupLevel(_),typeof console!=="undefined"&&qK.lookupLevel(qK.level)<=_){var j=qK.methodMap[_];if(!console[j])j="log";for(var K=arguments.length,Y=Array(K>1?K-1:0),f=1;f{XJ.__esModule=!0;XJ.createNewLookupObject=kJ;var ZJ=C6();function kJ(){for(var q=arguments.length,_=Array(q),j=0;j{bJ.__esModule=!0;bJ.createProtoAccessControl=CJ;bJ.resultIsAllowed=VJ;bJ.resetLoggedProperties=NJ;function uJ(q){return q&&q.__esModule?q:{default:q}}var F1=e1(),hJ=I4(),DJ=uJ(hJ),B3=Object.create(null);function CJ(q){var _=Object.create(null);_.constructor=!1,_.__defineGetter__=!1,_.__defineSetter__=!1,_.__lookupGetter__=!1;var j=Object.create(null);return j.__proto__=!1,{properties:{whitelist:F1.createNewLookupObject(j,q.allowedProtoProperties),defaultValue:q.allowProtoPropertiesByDefault},methods:{whitelist:F1.createNewLookupObject(_,q.allowedProtoMethods),defaultValue:q.allowProtoMethodsByDefault}}}function VJ(q,_,j){if(typeof q==="function")return U1(_.methods,j);else return U1(_.properties,j)}function U1(q,_){if(q.whitelist[_]!==void 0)return q.whitelist[_]===!0;if(q.defaultValue!==void 0)return q.defaultValue;return MJ(_),!1}function MJ(q){if(B3[q]!==!0)B3[q]=!0,DJ.default.log("error",'Handlebars: Access has been denied to resolve the property "'+q+`" because it is not an "own property" of its parent. You can add a runtime option to disable the check or this warning: See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details`)}function NJ(){Object.keys(B3).forEach(function(q){delete B3[q]})}});var e3=_8((rJ)=>{rJ.__esModule=!0;rJ.HandlebarsEnvironment=p4;function s1(q){return q&&q.__esModule?q:{default:q}}var H_=C6(),IJ=F6(),y4=s1(IJ),gJ=m4(),yJ=a1(),dJ=I4(),t3=s1(dJ),pJ=g4(),LJ="4.7.8";rJ.VERSION=LJ;var lJ=8;rJ.COMPILER_REVISION=lJ;var xJ=7;rJ.LAST_COMPATIBLE_COMPILER_REVISION=xJ;var nJ={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:"== 1.x.x",5:"== 2.0.0-alpha.x",6:">= 2.0.0-beta.1",7:">= 4.0.0 <4.3.0",8:">= 4.3.0"};rJ.REVISION_CHANGES=nJ;var d4="[object Object]";function p4(q,_,j){this.helpers=q||{},this.partials=_||{},this.decorators=j||{},gJ.registerDefaultHelpers(this),yJ.registerDefaultDecorators(this)}p4.prototype={constructor:p4,logger:t3.default,log:t3.default.log,registerHelper:function q(_,j){if(H_.toString.call(_)===d4){if(j)throw new y4.default("Arg not supported with multiple helpers");H_.extend(this.helpers,_)}else this.helpers[_]=j},unregisterHelper:function q(_){delete this.helpers[_]},registerPartial:function q(_,j){if(H_.toString.call(_)===d4)H_.extend(this.partials,_);else{if(typeof j==="undefined")throw new y4.default('Attempting to register a partial called "'+_+'" as undefined');this.partials[_]=j}},unregisterPartial:function q(_){delete this.partials[_]},registerDecorator:function q(_,j){if(H_.toString.call(_)===d4){if(j)throw new y4.default("Arg not supported with multiple decorators");H_.extend(this.decorators,_)}else this.decorators[_]=j},unregisterDecorator:function q(_){delete this.decorators[_]},resetLoggedPropertyAccesses:function q(){pJ.resetLoggedProperties()}};var cJ=t3.default.log;rJ.log=cJ;rJ.createFrame=H_.createFrame;rJ.logger=t3.default});var _j=_8((Q1,qj)=>{Q1.__esModule=!0;function L4(q){this.string=q}L4.prototype.toString=L4.prototype.toHTML=function(){return""+this.string};Q1.default=L4;qj.exports=Q1.default});var Kj=_8((KT)=>{KT.__esModule=!0;KT.wrapHelper=_T;function _T(q,_){if(typeof q!=="function")return q;var j=function K(){var Y=arguments[arguments.length-1];return arguments[arguments.length-1]=_(Y),q.apply(this,arguments)};return j}});var $j=_8((kT)=>{kT.__esModule=!0;kT.checkRevision=zT;kT.template=vT;kT.wrapProgram=F3;kT.resolvePartial=WT;kT.invokePartial=HT;kT.noop=Yj;function YT(q){return q&&q.__esModule?q:{default:q}}function fT(q){if(q&&q.__esModule)return q;else{var _={};if(q!=null){for(var j in q)if(Object.prototype.hasOwnProperty.call(q,j))_[j]=q[j]}return _.default=q,_}}var $T=C6(),dq=fT($T),wT=F6(),pq=YT(wT),Lq=e3(),jj=m4(),OT=Kj(),Pj=g4();function zT(q){var _=q&&q[0]||1,j=Lq.COMPILER_REVISION;if(_>=Lq.LAST_COMPATIBLE_COMPILER_REVISION&&_<=Lq.COMPILER_REVISION)return;if(_{hP=Pq(uP(),1),NX=hP.default.compile ${Y}`;return $+=` Memory system is active and ready to preserve context across sessions.`,$}buildHookResponse(q){let{hookEventName:_,success:j,message:K,data:Y,shouldContinue:f=j,stopReason:P}=q,$={continue:f,suppressOutput:!1};if(!f&&P)$.stopReason=P;if(_==="SessionStart")$.hookSpecificOutput={hookEventName:"SessionStart",additionalContext:K,...Y};else if(Y)$.hookSpecificOutput=Y;return $}validateAnalysisContext(q){return!!(q.transcriptContent&&q.sessionId)}validateSessionContext(q){return!!(q.sessionId&&q.source)}validateHookContext(q){return!!(q.hookEventName&&q.sessionId&&typeof q.success==="boolean")}getProjectName(){return this.projectName}setProjectName(q){this.projectName=q}}function VP(q,_,j={}){return{transcriptContent:q,sessionId:_,...j}}var MP=f6(()=>{CP()});var k_;var NP=f6(()=>{k_={COMPRESSION_STARTED:"\uD83D\uDE80 COMPRESSION STARTED",TRANSCRIPT_PATH:(q)=>`\uD83D\uDCC1 Transcript Path: ${q}`,SESSION_ID:(q)=>`\uD83D\uDD0D Session ID: ${q}`,PROJECT_NAME:(q)=>`\uD83D\uDCDD PROJECT NAME: ${q}`,CLAUDE_SDK_CALL:"\uD83E\uDD16 Calling Claude SDK to analyze and populate memory database...",TRANSCRIPT_STATS:(q,_)=>`\uD83D\uDCCA Transcript size: ${q} characters, ${_} messages`,COMPRESSION_COMPLETE:(q)=>`✅ COMPRESSION COMPLETE - Total summaries extracted: ${q}`,CLAUDE_PATH_FOUND:(q)=>`\uD83C\uDFAF Found Claude Code at: ${q}`,MCP_CONFIG_USED:(q)=>`\uD83D\uDCCB Using MCP config: ${q}`}});class bP{level=OK.INFO;setLevel(q){this.level=OK[q]}debug(q,..._){if(this.level<=OK.DEBUG)console.debug(`[DEBUG] ${q}`,..._)}info(q,..._){if(this.level<=OK.INFO)console.info(`[INFO] ${q}`,..._)}warn(q,..._){if(this.level<=OK.WARN)console.warn(`[WARN] ${q}`,..._)}error(q,_,j){if(this.level<=OK.ERROR){if(console.error(`[ERROR] ${q}`),_)console.error(_);if(j)console.error("Context:",j)}}}var OK,t8;var SP=f6(()=>{OK={DEBUG:0,INFO:1,WARN:2,ERROR:3};t8=new bP});import{readFileSync as SX,existsSync as EX}from"fs";import{join as RX}from"path";function zq(){return EP.getClaudePath()}var EP;var Y7=f6(()=>{M4();EP=class EP{static settingsPath;static cachedSettings=null;static{let q=new yq;this.settingsPath=RX(q.getConfigDir(),"settings.json")}static readSettings(){if(this.cachedSettings!==null)return this.cachedSettings;try{if(EX(this.settingsPath)){let _=SX(this.settingsPath,"utf-8"),j=JSON.parse(_);return this.cachedSettings=j,j}}catch{}let q={};return this.cachedSettings=q,q}static getSetting(q,_){return this.readSettings()[q]??_}static getClaudePath(){return this.getSetting("claudePath","claude")}static clearCache(){this.cachedSettings=null}}});class X_{static DEFAULT_MAX_TOKENS=28000;static DEFAULT_MAX_BYTES=98000;static DEFAULT_CONTEXT_OVERLAP=2;static CHARS_PER_TOKEN_ESTIMATE=3.5;options;constructor(q={}){this.options={maxTokensPerChunk:q.maxTokensPerChunk??X_.DEFAULT_MAX_TOKENS,maxBytesPerChunk:q.maxBytesPerChunk??X_.DEFAULT_MAX_BYTES,preserveContext:q.preserveContext??!0,contextOverlap:q.contextOverlap??X_.DEFAULT_CONTEXT_OVERLAP,parallel:q.parallel??!1}}estimateTokenCount(q){return Math.ceil(q.length/X_.CHARS_PER_TOKEN_ESTIMATE)}parseFilteredOutput(q){let _=q.split(` + Total summaries extracted: ${q}`,CLAUDE_PATH_FOUND:(q)=>`\uD83C\uDFAF Found Claude Code at: ${q}`,MCP_CONFIG_USED:(q)=>`\uD83D\uDCCB Using MCP config: ${q}`}});class bP{level=OK.INFO;setLevel(q){this.level=OK[q]}debug(q,..._){if(this.level<=OK.DEBUG)console.debug(`[DEBUG] ${q}`,..._)}info(q,..._){if(this.level<=OK.INFO)console.info(`[INFO] ${q}`,..._)}warn(q,..._){if(this.level<=OK.WARN)console.warn(`[WARN] ${q}`,..._)}error(q,_,j){if(this.level<=OK.ERROR){if(console.error(`[ERROR] ${q}`),_)console.error(_);if(j)console.error("Context:",j)}}}var OK,t8;var SP=f6(()=>{OK={DEBUG:0,INFO:1,WARN:2,ERROR:3};t8=new bP});import{readFileSync as SX,existsSync as EX}from"fs";import{join as RX}from"path";function zq(){return EP.getClaudePath()}var EP;var Y7=f6(()=>{M4();EP=class EP{static settingsPath;static cachedSettings=null;static{let q=new yq;this.settingsPath=RX(q.getConfigDir(),"settings.json")}static readSettings(){if(this.cachedSettings!==null)return this.cachedSettings;try{if(EX(this.settingsPath)){let _=SX(this.settingsPath,"utf-8"),j=JSON.parse(_);return this.cachedSettings=j,j}}catch{}let q={};return this.cachedSettings=q,q}static getSetting(q,_){return this.readSettings()[q]??_}static getClaudePath(){return this.getSetting("claudePath","claude")}static clearCache(){this.cachedSettings=null}}});class X_{static DEFAULT_MAX_TOKENS=22400;static DEFAULT_MAX_BYTES=78400;static DEFAULT_CONTEXT_OVERLAP=2;static CHARS_PER_TOKEN_ESTIMATE=3.5;options;constructor(q={}){this.options={maxTokensPerChunk:q.maxTokensPerChunk??X_.DEFAULT_MAX_TOKENS,maxBytesPerChunk:q.maxBytesPerChunk??X_.DEFAULT_MAX_BYTES,preserveContext:q.preserveContext??!0,contextOverlap:q.contextOverlap??X_.DEFAULT_CONTEXT_OVERLAP,parallel:q.parallel??!1}}estimateTokenCount(q){return Math.ceil(q.length/X_.CHARS_PER_TOKEN_ESTIMATE)}parseFilteredOutput(q){let _=q.split(` `).filter((K)=>K.trim()),j=[];for(let K of _)if(K.startsWith("- ")){let Y=K.substring(2);j.push({content:Y,estimatedTokens:this.estimateTokenCount(Y)})}return j}chunkTranscript(q){let _=this.parseFilteredOutput(q),j=[],K=[],Y=0,f=0,P=0;for(let $=0;$<_.length;$++){let w=_[$],O=this.formatMessage(w),v=Buffer.byteLength(O,"utf8"),z=w.estimatedTokens;if(K.length>0&&(Y+z>this.options.maxTokensPerChunk||f+v>this.options.maxBytesPerChunk)){let W=this.formatChunk(K);if(j.push({content:W,metadata:{chunkNumber:j.length+1,totalChunks:0,startIndex:P,endIndex:$-1,messageCount:K.length,estimatedTokens:Y,sizeBytes:f,hasOverlap:!1}}),K=[],Y=0,f=0,P=$,this.options.preserveContext&&j.length>0){let J=Math.max(0,$-this.options.contextOverlap);for(let T=J;T<$;T++){let H=_[T],X=this.formatMessage(H);K.push(H),Y+=H.estimatedTokens,f+=Buffer.byteLength(X,"utf8")}if(K.length>0)P=J}}K.push(w),Y+=z,f+=v}if(K.length>0){let $=this.formatChunk(K);j.push({content:$,metadata:{chunkNumber:j.length+1,totalChunks:0,startIndex:P,endIndex:_.length-1,messageCount:K.length,estimatedTokens:Y,sizeBytes:f,hasOverlap:this.options.preserveContext&&j.length>0}})}return j.forEach(($)=>{$.metadata.totalChunks=j.length}),j}formatMessage(q){return`- ${q.content}`}formatChunk(q){return q.map((_)=>this.formatMessage(_)).join(` `)}createChunkHeader(q){let _=[];if(q.firstTimestamp&&q.lastTimestamp)_.push(`# ${q.firstTimestamp} to ${q.lastTimestamp} (chunk ${q.chunkNumber}/${q.totalChunks})`);else _.push(`# Chunk ${q.chunkNumber} of ${q.totalChunks}`);return _.join(` `)+` @@ -258,7 +258,7 @@ ${o.default.gray(sq)} ${q} `).filter((z)=>z.trim());if(Y.length===0){if(q.format==="session-start")console.log(mK("NO_MEMORIES",q.project||"this project"));return}let f=[];for(let z of Y)try{if(!z.trim().startsWith("{"))continue;let W=JSON.parse(z);f.push(W)}catch(W){continue}if(f.length===0){if(q.format==="session-start")console.log(mK("NO_MEMORIES",q.project||"this project"));return}let P=f.filter((z)=>z.type==="memory"),$=f.filter((z)=>z.type==="overview"),w=f.filter((z)=>z.type==="session"),O=P,v=$;if(q.project)O=P.filter((z)=>z.project===q.project),v=$.filter((z)=>z.project===q.project);if(q.format==="session-start"){let z=O.slice(-10),W=v.slice(-5),J=[...z,...W],T="recently",H=J.map((X)=>{return X.timestamp?new Date(X.timestamp):null}).filter((X)=>X!==null).sort((X,A)=>A.getTime()-X.getTime());if(H.length>0)T=D5(H[0]);V5({projectName:q.project||"your project",memoryCount:z.length,lastSessionTime:T,recentObjects:J})}else if(q.format==="json"){let z=O.slice(-10),W=v.slice(-3),J=[...z,...W];console.log(JSON.stringify(J))}else{let z=O.slice(-10),W=v.slice(-3),J=z.length+W.length;console.log(d3("Context loading",J,"recent entries found")),z.forEach((T)=>{console.log(`${T.text} | ${T.document_id} | ${T.keywords}`)}),W.forEach((T)=>{console.log(`**Overview:** ${T.content}`)})}if(q.format!=="json"){let z=vu();if(!z.isEmpty){let W=zu(z.totalSize);console.log(`\uD83D\uDDD1️ Trash – ${z.folderCount} folders | ${z.fileCount} files | ${W} – use \`$ claude-mem restore\``),console.log("")}}}catch(K){let Y=K instanceof Error?K.message:String(K);if(q.format==="session-start")console.log(mK("CONNECTION_FAILED",Y));else console.log(d_("Context loading",Y,"Check file permissions and try again"))}}var T9=f6(()=>{d6();O4()});var E$={};EK(E$,{viewTrash:()=>HD});import{readdirSync as M$,statSync as N$}from"fs";import{join as b$}from"path";function WD(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 V$(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 S$(q){let _=0,j=M$(q);for(let K of j){let Y=b$(q,K),f=N$(Y);if(f.isDirectory())_+=S$(Y);else _+=f.size}return _}async function HD(){let q=$8.getInstance().getTrashDirectory();try{let _=M$(q);if(_.length===0){K6.info("\uD83D\uDDD1️ Trash is empty");return}let j=_.map((P)=>{let $=b$(q,P),w=N$($),{name:O,timestamp:v}=WD(P),z=w.isDirectory()?S$($):w.size;return{originalName:O,trashedName:P,size:z,trashedAt:new Date(v),isDirectory:w.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",w=P.trashedAt.toLocaleString(),O=V$(P.size);console.log(`${$} ${P.originalName}`),console.log(` Size: ${O} | Trashed: ${w}`),console.log(` ID: ${P.trashedName}`),console.log()}console.log("─".repeat(80)),console.log(`Total: ${Y} folders, ${f} files (${V$(K)})`),console.log(` -To restore files: claude-mem restore`),console.log("To empty trash: claude-mem trash empty")}catch(_){if(_.code==="ENOENT")K6.info("\uD83D\uDDD1️ Trash is empty");else K6.error("Failed to read trash directory"),console.error(_)}}var R$=f6(()=>{vK();d6()});var I$={};EK(I$,{emptyTrash:()=>XD});import{rmSync as JD,readdirSync as TD,existsSync as ZD,statSync as kD}from"fs";import{join as m$}from"path";async function XD(q={}){let _=$8.getInstance().getTrashDirectory();if(!ZD(_)){K6.info("\uD83D\uDDD1️ Trash is already empty");return}try{let j=TD(_);if(j.length===0){K6.info("\uD83D\uDDD1️ Trash is already empty");return}let K=0,Y=0;for(let P of j){let $=m$(_,P);if(kD($).isDirectory())K++;else Y++}if(!q.force){let P=await hq({message:`Permanently delete ${K} folders and ${Y} files from trash?`,initialValue:!1});if(L8(P)||!P){K6.info("Cancelled - trash not emptied");return}}let f=Qq();f.start("Emptying trash...");for(let P of j){let $=m$(_,P);JD($,{recursive:!0,force:!0})}f.stop(`\uD83D\uDDD1️ Trash emptied - permanently deleted ${K} folders and ${Y} files`)}catch(j){K6.error("Failed to empty trash"),console.error(j),process.exit(1)}}var g$=f6(()=>{vK();d6()});var o7={};EK(o7,{sessionStartHook:()=>GD,sessionEndHook:()=>uD,preCompactHook:()=>AD});import{basename as y$}from"path";async function AD(){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 QK(_,{dryRun:!1})}catch(q){console.error("Pre-compact hook failed:",q.message),process.exit(1)}}async function GD(){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)_=y$(j.cwd)}catch(j){console.error("Failed to parse session-start hook data:",j)}if(!_)_=y$(process.cwd());await V7({format:"session-start",count:"10",project:_})}catch(q){console.error("Session-start hook failed:",q.message),process.exit(1)}}async function uD(){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 QK(_.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 a7=f6(()=>{k2();T9()});var v5=Pq(z5(),1),{program:lD,createCommand:xD,createArgument:nD,createOption:cD,CommanderError:rD,InvalidArgumentError:iD,InvalidOptionArgumentError:oD,Command:W5,Argument:aD,Option:BD,Help:tD}=v5.default;import{readFileSync as Fw,existsSync as Uw}from"fs";import{join as sw,dirname as Qw}from"path";import{fileURLToPath as qO}from"url";var H5="claude-mem",J5="3.6.5",T5="Memory compression system for Claude Code - persist context across sessions",Z5=H5,k5=J5,X5=T5;try{let q=qO(import.meta.url),_=Qw(q),j=sw(_,"..","..","package.json");if(Uw(j)){let K=JSON.parse(Fw(j,"utf-8"));Z5=K.name||H5,k5=K.version||J5,X5=K.description||T5}}catch{}var oq=Z5,A5=k5,G5=X5;k2();vK();import{readFileSync as JK,writeFileSync as h_,existsSync as R8,chmodSync as yG,mkdirSync as ZK,copyFileSync as u_,statSync as dG,readdirSync as pG}from"fs";import{join as V8,dirname as TK}from"path";import{homedir as v9,platform as zf}from"os";import{execSync as G_}from"child_process";import{fileURLToPath as vf}from"url";var fY=(q=0)=>(_)=>`\x1B[${_+q}m`,$Y=(q=0)=>(_)=>`\x1B[${38+q};5;${_}m`,wY=(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]}},aV=Object.keys(l8.modifier),hA=Object.keys(l8.color),DA=Object.keys(l8.bgColor),BV=[...hA,...DA];function CA(){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=fY(),l8.color.ansi256=$Y(),l8.color.ansi16m=wY(),l8.bgColor.ansi=fY(10),l8.bgColor.ansi256=$Y(10),l8.bgColor.ansi16m=wY(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 VA=CA(),Wq=VA;import l2 from"node:process";import MA from"node:os";import OY from"node:tty";function s6(q,_=globalThis.Deno?globalThis.Deno.args:l2.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 SA(q,{streamIsTTY:_,sniffFlags:j=!0}={}){let K=NA();if(K!==void 0)Z7=K;let Y=j?Z7:K;if(Y===0)return 0;if(j){if(s6("color=16m")||s6("color=full")||s6("color=truecolor"))return 3;if(s6("color=256"))return 2}if("TF_BUILD"in x8&&"AGENT_NAME"in x8)return 1;if(q&&!_&&Y===void 0)return 0;let f=Y||0;if(x8.TERM==="dumb")return f;if(l2.platform==="win32"){let P=MA.release().split(".");if(Number(P[0])>=10&&Number(P[2])>=10586)return Number(P[2])>=14931?3:2;return 1}if("CI"in x8){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((P)=>(P in x8)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((P)=>(P in x8))||x8.CI_NAME==="codeship")return 1;return f}if("TEAMCITY_VERSION"in x8)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(x8.TEAMCITY_VERSION)?1:0;if(x8.COLORTERM==="truecolor")return 3;if(x8.TERM==="xterm-kitty")return 3;if(x8.TERM==="xterm-ghostty")return 3;if(x8.TERM==="wezterm")return 3;if("TERM_PROGRAM"in x8){let P=Number.parseInt((x8.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(x8.TERM_PROGRAM){case"iTerm.app":return P>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(x8.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(x8.TERM))return 1;if("COLORTERM"in x8)return 1;return f}function zY(q,_={}){let j=SA(q,{streamIsTTY:q&&q.isTTY,..._});return bA(j)}var EA={stdout:zY({isTTY:OY.isatty(1)}),stderr:zY({isTTY:OY.isatty(2)})},vY=EA;function WY(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 HY(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")K6.info("\uD83D\uDDD1️ Trash is empty");else K6.error("Failed to read trash directory"),console.error(_)}}var R$=f6(()=>{vK();d6()});var I$={};EK(I$,{emptyTrash:()=>XD});import{rmSync as JD,readdirSync as TD,existsSync as ZD,statSync as kD}from"fs";import{join as m$}from"path";async function XD(q={}){let _=$8.getInstance().getTrashDirectory();if(!ZD(_)){K6.info("\uD83D\uDDD1️ Trash is already empty");return}try{let j=TD(_);if(j.length===0){K6.info("\uD83D\uDDD1️ Trash is already empty");return}let K=0,Y=0;for(let P of j){let $=m$(_,P);if(kD($).isDirectory())K++;else Y++}if(!q.force){let P=await hq({message:`Permanently delete ${K} folders and ${Y} files from trash?`,initialValue:!1});if(L8(P)||!P){K6.info("Cancelled - trash not emptied");return}}let f=Qq();f.start("Emptying trash...");for(let P of j){let $=m$(_,P);JD($,{recursive:!0,force:!0})}f.stop(`\uD83D\uDDD1️ Trash emptied - permanently deleted ${K} folders and ${Y} files`)}catch(j){K6.error("Failed to empty trash"),console.error(j),process.exit(1)}}var g$=f6(()=>{vK();d6()});var o7={};EK(o7,{sessionStartHook:()=>GD,sessionEndHook:()=>uD,preCompactHook:()=>AD});import{basename as y$}from"path";async function AD(){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 QK(_,{dryRun:!1})}catch(q){console.error("Pre-compact hook failed:",q.message),process.exit(1)}}async function GD(){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)_=y$(j.cwd)}catch(j){console.error("Failed to parse session-start hook data:",j)}if(!_)_=y$(process.cwd());await V7({format:"session-start",count:"10",project:_})}catch(q){console.error("Session-start hook failed:",q.message),process.exit(1)}}async function uD(){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 QK(_.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 a7=f6(()=>{k2();T9()});var v5=Pq(z5(),1),{program:lD,createCommand:xD,createArgument:nD,createOption:cD,CommanderError:rD,InvalidArgumentError:iD,InvalidOptionArgumentError:oD,Command:W5,Argument:aD,Option:BD,Help:tD}=v5.default;import{readFileSync as Fw,existsSync as Uw}from"fs";import{join as sw,dirname as Qw}from"path";import{fileURLToPath as qO}from"url";var H5="claude-mem",J5="3.6.6",T5="Memory compression system for Claude Code - persist context across sessions",Z5=H5,k5=J5,X5=T5;try{let q=qO(import.meta.url),_=Qw(q),j=sw(_,"..","..","package.json");if(Uw(j)){let K=JSON.parse(Fw(j,"utf-8"));Z5=K.name||H5,k5=K.version||J5,X5=K.description||T5}}catch{}var oq=Z5,A5=k5,G5=X5;k2();vK();import{readFileSync as JK,writeFileSync as h_,existsSync as R8,chmodSync as yG,mkdirSync as ZK,copyFileSync as u_,statSync as dG,readdirSync as pG}from"fs";import{join as V8,dirname as TK}from"path";import{homedir as v9,platform as zf}from"os";import{execSync as G_}from"child_process";import{fileURLToPath as vf}from"url";var fY=(q=0)=>(_)=>`\x1B[${_+q}m`,$Y=(q=0)=>(_)=>`\x1B[${38+q};5;${_}m`,wY=(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]}},aV=Object.keys(l8.modifier),hA=Object.keys(l8.color),DA=Object.keys(l8.bgColor),BV=[...hA,...DA];function CA(){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=fY(),l8.color.ansi256=$Y(),l8.color.ansi16m=wY(),l8.bgColor.ansi=fY(10),l8.bgColor.ansi256=$Y(10),l8.bgColor.ansi16m=wY(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 VA=CA(),Wq=VA;import l2 from"node:process";import MA from"node:os";import OY from"node:tty";function s6(q,_=globalThis.Deno?globalThis.Deno.args:l2.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 SA(q,{streamIsTTY:_,sniffFlags:j=!0}={}){let K=NA();if(K!==void 0)Z7=K;let Y=j?Z7:K;if(Y===0)return 0;if(j){if(s6("color=16m")||s6("color=full")||s6("color=truecolor"))return 3;if(s6("color=256"))return 2}if("TF_BUILD"in x8&&"AGENT_NAME"in x8)return 1;if(q&&!_&&Y===void 0)return 0;let f=Y||0;if(x8.TERM==="dumb")return f;if(l2.platform==="win32"){let P=MA.release().split(".");if(Number(P[0])>=10&&Number(P[2])>=10586)return Number(P[2])>=14931?3:2;return 1}if("CI"in x8){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((P)=>(P in x8)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((P)=>(P in x8))||x8.CI_NAME==="codeship")return 1;return f}if("TEAMCITY_VERSION"in x8)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(x8.TEAMCITY_VERSION)?1:0;if(x8.COLORTERM==="truecolor")return 3;if(x8.TERM==="xterm-kitty")return 3;if(x8.TERM==="xterm-ghostty")return 3;if(x8.TERM==="wezterm")return 3;if("TERM_PROGRAM"in x8){let P=Number.parseInt((x8.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(x8.TERM_PROGRAM){case"iTerm.app":return P>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(x8.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(x8.TERM))return 1;if("COLORTERM"in x8)return 1;return f}function zY(q,_={}){let j=SA(q,{streamIsTTY:q&&q.isTTY,..._});return bA(j)}var EA={stdout:zY({isTTY:OY.isatty(1)}),stderr:zY({isTTY:OY.isatty(2)})},vY=EA;function WY(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 HY(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:JY,stderr:TY}=vY,x2=Symbol("GENERATOR"),WK=Symbol("STYLER"),P3=Symbol("IS_EMPTY"),ZY=["ansi","ansi","ansi256","ansi16m"],HK=Object.create(null),RA=(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=JY?JY.level:0;q.level=_.level===void 0?j:_.level};var mA=(q)=>{let _=(...j)=>j.join(" ");return RA(_,q),Object.setPrototypeOf(_,Y3.prototype),_};function Y3(q){return mA(q)}Object.setPrototypeOf(Y3.prototype,Function.prototype);for(let[q,_]of Object.entries(Wq))HK[q]={get(){let j=k7(this,c2(_.open,_.close,this[WK]),this[P3]);return Object.defineProperty(this,q,{value:j}),j}};HK.visible={get(){let q=k7(this,this[WK],!0);return Object.defineProperty(this,"visible",{value:q}),q}};var n2=(q,_,j,...K)=>{if(q==="rgb"){if(_==="ansi16m")return Wq[j].ansi16m(...K);if(_==="ansi256")return Wq[j].ansi256(Wq.rgbToAnsi256(...K));return Wq[j].ansi(Wq.rgbToAnsi(...K))}if(q==="hex")return n2("rgb",_,j,...Wq.hexToRgb(...K));return Wq[j][q](...K)},IA=["rgb","hex","ansi256"];for(let q of IA){HK[q]={get(){let{level:j}=this;return function(...K){let Y=c2(n2(q,ZY[j],"color",...K),Wq.color.close,this[WK]);return k7(this,Y,this[P3])}}};let _="bg"+q[0].toUpperCase()+q.slice(1);HK[_]={get(){let{level:j}=this;return function(...K){let Y=c2(n2(q,ZY[j],"bgColor",...K),Wq.bgColor.close,this[WK]);return k7(this,Y,this[P3])}}}}var gA=Object.defineProperties(()=>{},{...HK,level:{enumerable:!0,get(){return this[x2].level},set(q){this[x2].level=q}}}),c2=(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}},k7=(q,_,j)=>{let K=(...Y)=>yA(K,Y.length===1?""+Y[0]:Y.join(" "));return Object.setPrototypeOf(K,gA),K[x2]=q,K[WK]=_,K[P3]=j,K},yA=(q,_)=>{if(q.level<=0||!_)return q[P3]?"":_;let j=q[WK];if(j===void 0)return _;let{openAll:K,closeAll:Y}=j;if(_.includes("\x1B"))while(j!==void 0)_=WY(_,j.close,j.open),j=j.parent;let f=_.indexOf(` diff --git a/package.json b/package.json index 91079e53..c7c28937 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "claude-mem", - "version": "3.6.5", + "version": "3.6.6", "description": "Memory compression system for Claude Code - persist context across sessions", "keywords": [ "claude", diff --git a/src/core/compression/ChunkManager.ts b/src/core/compression/ChunkManager.ts index 980e188b..53fcee70 100644 --- a/src/core/compression/ChunkManager.ts +++ b/src/core/compression/ChunkManager.ts @@ -34,8 +34,8 @@ export interface ChunkedMessage { } export class ChunkManager { - private static readonly DEFAULT_MAX_TOKENS = 28000; - private static readonly DEFAULT_MAX_BYTES = 98000; + private static readonly DEFAULT_MAX_TOKENS = 22400; // Reduced by 20% from 28000 + private static readonly DEFAULT_MAX_BYTES = 78400; // Reduced by 20% from 98000 private static readonly DEFAULT_CONTEXT_OVERLAP = 2; private static readonly CHARS_PER_TOKEN_ESTIMATE = 3.5;