@anmol-srv/sigil 0.18.2 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -25
- package/dist/cli.js +1191 -790
- package/dist/daemon.js +664 -302
- package/dist/hooks/post-tool-use.js +1 -69
- package/dist/hooks/session-end.js +13 -236
- package/dist/hooks/stop.js +36 -246
- package/dist/hooks/user-prompt-submit.js +25 -288
- package/dist/mcp/worker-server.js +6 -0
- package/dist/npm-entry.js +10 -0
- package/dist/server.js +64 -56
- package/install.sh +207 -0
- package/integrations/hermes/README.md +30 -24
- package/integrations/hermes/plugin/README.md +1 -1
- package/integrations/hermes/plugin/__init__.py +68 -24
- package/knexfile.js +19 -22
- package/package.json +9 -28
- package/prompts/audm-decision.md +26 -1
- package/prompts/entity-extraction.md +32 -30
- package/prompts/graph-extraction.md +20 -2
- package/src/db/drivers/index.js +38 -15
- package/src/db/migrations/20260629120000_add-trace-event-attribution.cjs +29 -0
- package/src/db/migrations/20260629120001_add-llm-log-session-correlation.cjs +29 -0
- package/src/db/migrations/20260806120000_add-document-content.cjs +27 -0
- package/src/db/migrations/20260806120001_llm-log-model-nullable.cjs +36 -0
- package/src/db/migrations/20260811120000_add-relation-provenance.cjs +42 -0
- package/src/db/migrations/20260811130000_add-fact-visibility.cjs +67 -0
- package/src/db/migrations/20260813090000_rescore-defaulted-vital.cjs +57 -0
- package/src/db/migrations/20260814120000_create-ingestion-job.cjs +52 -0
- package/src/db/migrations/20260814120100_add-llm-log-queued-ms.cjs +8 -0
- package/src/db/migrations/20260814120200_add-active-fact-content-hash-index.cjs +16 -0
- package/src/db/migrations/20260814120300_create-relation-candidate-judgment.cjs +25 -0
- package/src/gui/web/app.css +851 -84
- package/src/gui/web/app.js +796 -383
- package/src/gui/web/cmdk.js +238 -0
- package/src/gui/web/components.js +64 -0
- package/src/gui/web/design/colors_and_type.css +6 -1
- package/src/gui/web/graph/GraphIsland.jsx +450 -0
- package/src/gui/web/graph/cluster.js +305 -0
- package/src/gui/web/graph/cluster.test.js +219 -0
- package/src/gui/web/health.js +117 -0
- package/src/gui/web/health.test.js +159 -0
- package/src/gui/web/icons.js +65 -0
- package/src/gui/web/index.html +310 -115
- package/src/gui/web/settings.js +386 -0
- package/src/gui/web/setup.js +2 -2
- package/src/gui/web/toast.js +6 -3
- package/src/gui/web/vendor/graph-island.js +52 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __sigilCreateRequire } from 'node:module'; const require = __sigilCreateRequire(import.meta.url);
|
|
3
|
+
var et=Object.defineProperty;var tt=(r,e)=>{for(var t in e)et(r,t,{get:e[t],enumerable:!0})};import{StdioServerTransport as yr}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as gr}from"@modelcontextprotocol/sdk/server/mcp.js";var ge={};tt(ge,{BRAND:()=>Ot,DIRTY:()=>B,EMPTY_PATH:()=>at,INVALID:()=>h,NEVER:()=>lr,OK:()=>T,ParseStatus:()=>w,Schema:()=>g,ZodAny:()=>U,ZodArray:()=>D,ZodBigInt:()=>F,ZodBoolean:()=>H,ZodBranded:()=>_e,ZodCatch:()=>ne,ZodDate:()=>q,ZodDefault:()=>se,ZodDiscriminatedUnion:()=>we,ZodEffects:()=>E,ZodEnum:()=>te,ZodError:()=>I,ZodFirstPartyTypeKind:()=>_,ZodFunction:()=>Se,ZodIntersection:()=>Q,ZodIssueCode:()=>c,ZodLazy:()=>X,ZodLiteral:()=>ee,ZodMap:()=>fe,ZodNaN:()=>he,ZodNativeEnum:()=>re,ZodNever:()=>R,ZodNull:()=>K,ZodNullable:()=>L,ZodNumber:()=>W,ZodObject:()=>O,ZodOptional:()=>A,ZodParsedType:()=>u,ZodPipeline:()=>ye,ZodPromise:()=>G,ZodReadonly:()=>ae,ZodRecord:()=>Te,ZodSchema:()=>g,ZodSet:()=>pe,ZodString:()=>z,ZodSymbol:()=>ue,ZodTransformer:()=>E,ZodTuple:()=>j,ZodType:()=>g,ZodUndefined:()=>J,ZodUnion:()=>Y,ZodUnknown:()=>Z,ZodVoid:()=>le,addIssueToContext:()=>d,any:()=>$t,array:()=>Vt,bigint:()=>Rt,boolean:()=>Ge,coerce:()=>ur,custom:()=>Ve,date:()=>Nt,datetimeRegex:()=>De,defaultErrorMap:()=>M,discriminatedUnion:()=>Bt,effect:()=>rr,enum:()=>Xt,function:()=>Kt,getErrorMap:()=>oe,getParsedType:()=>N,instanceof:()=>Ct,intersection:()=>Wt,isAborted:()=>ke,isAsync:()=>ce,isDirty:()=>be,isValid:()=>V,late:()=>At,lazy:()=>Yt,literal:()=>Qt,makeIssue:()=>me,map:()=>qt,nan:()=>Et,nativeEnum:()=>er,never:()=>Dt,null:()=>Mt,nullable:()=>nr,number:()=>Ue,object:()=>zt,objectUtil:()=>Oe,oboolean:()=>dr,onumber:()=>cr,optional:()=>sr,ostring:()=>or,pipeline:()=>ir,preprocess:()=>ar,promise:()=>tr,quotelessJson:()=>rt,record:()=>Ht,set:()=>Jt,setErrorMap:()=>nt,strictObject:()=>Ut,string:()=>ze,symbol:()=>jt,transformer:()=>rr,tuple:()=>Ft,undefined:()=>Lt,union:()=>Gt,unknown:()=>Zt,util:()=>v,void:()=>Pt});var v;(function(r){r.assertEqual=n=>{};function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{let a={};for(let i of n)a[i]=i;return a},r.getValidEnumValues=n=>{let a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(let o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(let i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(v||(v={}));var Oe;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Oe||(Oe={}));var u=v.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),N=r=>{switch(typeof r){case"undefined":return u.undefined;case"string":return u.string;case"number":return Number.isNaN(r)?u.nan:u.number;case"boolean":return u.boolean;case"function":return u.function;case"bigint":return u.bigint;case"symbol":return u.symbol;case"object":return Array.isArray(r)?u.array:r===null?u.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?u.promise:typeof Map<"u"&&r instanceof Map?u.map:typeof Set<"u"&&r instanceof Set?u.set:typeof Date<"u"&&r instanceof Date?u.date:u.object;default:return u.unknown}};var c=v.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"]),rt=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),I=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,l=0;for(;l<i.path.length;){let f=i.path[l];l===i.path.length-1?(o[f]=o[f]||{_errors:[]},o[f]._errors.push(t(i))):o[f]=o[f]||{_errors:[]},o=o[f],l++}}};return n(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,v.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},s=[];for(let n of this.issues)if(n.path.length>0){let a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};I.create=r=>new I(r);var st=(r,e)=>{let t;switch(r.code){case c.invalid_type:r.received===u.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,v.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${v.joinValues(r.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${v.joinValues(r.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${v.joinValues(r.options)}, received '${r.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:v.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case c.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case c.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,v.assertNever(r)}return{message:t}},M=st;var je=M;function nt(r){je=r}function oe(){return je}var me=r=>{let{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let o="",l=s.filter(f=>!!f).slice().reverse();for(let f of l)o=f(i,{data:e,defaultError:o}).message;return{...n,path:a,message:o}},at=[];function d(r,e){let t=oe(),s=me({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===M?void 0:M].filter(n=>!!n)});r.common.issues.push(s)}var w=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let n of t){if(n.status==="aborted")return h;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let n of t){let a=await n.key,i=await n.value;s.push({key:a,value:i})}return r.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let n of t){let{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return h;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}},h=Object.freeze({status:"aborted"}),B=r=>({status:"dirty",value:r}),T=r=>({status:"valid",value:r}),ke=r=>r.status==="aborted",be=r=>r.status==="dirty",V=r=>r.status==="valid",ce=r=>typeof Promise<"u"&&r instanceof Promise;var p;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}));var C=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Le=(r,e)=>{if(V(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new I(r.common.issues);return this._error=t,this._error}}};function y(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{let{message:l}=r;return i.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:l??t??o.defaultError}},description:n}}var g=class{get description(){return this._def.description}_getType(e){return N(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:N(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new w,ctx:{common:e.parent.common,data:e.data,parsedType:N(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ce(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:N(e)},n=this._parseSync({data:e,path:s.path,parent:s});return Le(s,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:N(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return V(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>V(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:N(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(ce(n)?n:Promise.resolve(n));return Le(s,a)}refine(e,t){let s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{let i=e(n),o=()=>a.addIssue({code:c.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new E({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return A.create(this,this._def)}nullable(){return L.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return D.create(this)}promise(){return G.create(this,this._def)}or(e){return Y.create([this,e],this._def)}and(e){return Q.create(this,e,this._def)}transform(e){return new E({...y(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new se({...y(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new _e({typeName:_.ZodBranded,type:this,...y(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new ne({...y(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ye.create(this,e)}readonly(){return ae.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},it=/^c[^\s-]{8,}$/i,ot=/^[0-9a-z]+$/,ct=/^[0-9A-HJKMNP-TV-Z]{26}$/i,dt=/^[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,ut=/^[a-z0-9_-]{21}$/i,lt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ft=/^[-+]?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)?)??$/,pt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ht="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ae,mt=/^(?:(?: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])$/,_t=/^(?:(?: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])$/,yt=/^(([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]))$/,gt=/^(([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])$/,vt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,$e="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",kt=new RegExp(`^${$e}$`);function Ze(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function bt(r){return new RegExp(`^${Ze(r)}$`)}function De(r){let e=`${$e}T${Ze(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function wt(r,e){return!!((e==="v4"||!e)&&mt.test(r)||(e==="v6"||!e)&&yt.test(r))}function Tt(r,e){if(!lt.test(r))return!1;try{let[t]=r.split(".");if(!t)return!1;let s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function St(r,e){return!!((e==="v4"||!e)&&_t.test(r)||(e==="v6"||!e)&>.test(r))}var z=class r extends g{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==u.string){let a=this._getOrReturnCtx(e);return d(a,{code:c.invalid_type,expected:u.string,received:a.parsedType}),h}let s=new w,n;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),d(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),d(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?d(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&d(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")pt.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"email",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")Ae||(Ae=new RegExp(ht,"u")),Ae.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"emoji",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")dt.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"uuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")ut.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"nanoid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")it.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"cuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")ot.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"cuid2",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")ct.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"ulid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),d(n,{validation:"url",code:c.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"regex",code:c.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),d(n,{code:c.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),d(n,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),d(n,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?De(a).test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:c.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?kt.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:c.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?bt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:c.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?ft.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"duration",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?wt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"ip",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Tt(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"jwt",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?St(e.data,a.version)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"cidr",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?vt.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"base64",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?xt.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"base64url",code:c.invalid_string,message:a.message}),s.dirty()):v.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:c.invalid_string,...p.errToObj(s)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...p.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...p.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};z.create=r=>new z({checks:[],typeName:_.ZodString,coerce:r?.coerce??!1,...y(r)});function It(r,e){let t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=Number.parseInt(r.toFixed(n).replace(".","")),i=Number.parseInt(e.toFixed(n).replace(".",""));return a%i/10**n}var W=class r extends g{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==u.number){let a=this._getOrReturnCtx(e);return d(a,{code:c.invalid_type,expected:u.number,received:a.parsedType}),h}let s,n=new w;for(let a of this._def.checks)a.kind==="int"?v.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:c.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:c.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?It(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),d(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:c.not_finite,message:a.message}),n.dirty()):v.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&v.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};W.create=r=>new W({checks:[],typeName:_.ZodNumber,coerce:r?.coerce||!1,...y(r)});var F=class r extends g{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==u.bigint)return this._getInvalidInput(e);let s,n=new w;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:c.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:c.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),d(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):v.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return d(t,{code:c.invalid_type,expected:u.bigint,received:t.parsedType}),h}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};F.create=r=>new F({checks:[],typeName:_.ZodBigInt,coerce:r?.coerce??!1,...y(r)});var H=class extends g{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==u.boolean){let s=this._getOrReturnCtx(e);return d(s,{code:c.invalid_type,expected:u.boolean,received:s.parsedType}),h}return T(e.data)}};H.create=r=>new H({typeName:_.ZodBoolean,coerce:r?.coerce||!1,...y(r)});var q=class r extends g{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==u.date){let a=this._getOrReturnCtx(e);return d(a,{code:c.invalid_type,expected:u.date,received:a.parsedType}),h}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return d(a,{code:c.invalid_date}),h}let s=new w,n;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),d(n,{code:c.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),d(n,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):v.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};q.create=r=>new q({checks:[],coerce:r?.coerce||!1,typeName:_.ZodDate,...y(r)});var ue=class extends g{_parse(e){if(this._getType(e)!==u.symbol){let s=this._getOrReturnCtx(e);return d(s,{code:c.invalid_type,expected:u.symbol,received:s.parsedType}),h}return T(e.data)}};ue.create=r=>new ue({typeName:_.ZodSymbol,...y(r)});var J=class extends g{_parse(e){if(this._getType(e)!==u.undefined){let s=this._getOrReturnCtx(e);return d(s,{code:c.invalid_type,expected:u.undefined,received:s.parsedType}),h}return T(e.data)}};J.create=r=>new J({typeName:_.ZodUndefined,...y(r)});var K=class extends g{_parse(e){if(this._getType(e)!==u.null){let s=this._getOrReturnCtx(e);return d(s,{code:c.invalid_type,expected:u.null,received:s.parsedType}),h}return T(e.data)}};K.create=r=>new K({typeName:_.ZodNull,...y(r)});var U=class extends g{constructor(){super(...arguments),this._any=!0}_parse(e){return T(e.data)}};U.create=r=>new U({typeName:_.ZodAny,...y(r)});var Z=class extends g{constructor(){super(...arguments),this._unknown=!0}_parse(e){return T(e.data)}};Z.create=r=>new Z({typeName:_.ZodUnknown,...y(r)});var R=class extends g{_parse(e){let t=this._getOrReturnCtx(e);return d(t,{code:c.invalid_type,expected:u.never,received:t.parsedType}),h}};R.create=r=>new R({typeName:_.ZodNever,...y(r)});var le=class extends g{_parse(e){if(this._getType(e)!==u.undefined){let s=this._getOrReturnCtx(e);return d(s,{code:c.invalid_type,expected:u.void,received:s.parsedType}),h}return T(e.data)}};le.create=r=>new le({typeName:_.ZodVoid,...y(r)});var D=class r extends g{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==u.array)return d(t,{code:c.invalid_type,expected:u.array,received:t.parsedType}),h;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(d(t,{code:i?c.too_big:c.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(d(t,{code:c.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(d(t,{code:c.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new C(t,i,t.path,o)))).then(i=>w.mergeArray(s,i));let a=[...t.data].map((i,o)=>n.type._parseSync(new C(t,i,t.path,o)));return w.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}};D.create=(r,e)=>new D({type:r,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...y(e)});function de(r){if(r instanceof O){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=A.create(de(s))}return new O({...r._def,shape:()=>e})}else return r instanceof D?new D({...r._def,type:de(r.element)}):r instanceof A?A.create(de(r.unwrap())):r instanceof L?L.create(de(r.unwrap())):r instanceof j?j.create(r.items.map(e=>de(e))):r}var O=class r extends g{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=v.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==u.object){let f=this._getOrReturnCtx(e);return d(f,{code:c.invalid_type,expected:u.object,received:f.parsedType}),h}let{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof R&&this._def.unknownKeys==="strip"))for(let f in n.data)i.includes(f)||o.push(f);let l=[];for(let f of i){let m=a[f],b=n.data[f];l.push({key:{status:"valid",value:f},value:m._parse(new C(n,b,n.path,f)),alwaysSet:f in n.data})}if(this._def.catchall instanceof R){let f=this._def.unknownKeys;if(f==="passthrough")for(let m of o)l.push({key:{status:"valid",value:m},value:{status:"valid",value:n.data[m]}});else if(f==="strict")o.length>0&&(d(n,{code:c.unrecognized_keys,keys:o}),s.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let f=this._def.catchall;for(let m of o){let b=n.data[m];l.push({key:{status:"valid",value:m},value:f._parse(new C(n,b,n.path,m)),alwaysSet:m in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let f=[];for(let m of l){let b=await m.key,P=await m.value;f.push({key:b,value:P,alwaysSet:m.alwaysSet})}return f}).then(f=>w.mergeObjectSync(s,f)):w.mergeObjectSync(s,l)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{let n=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:p.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let s of v.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let s of v.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}deepPartial(){return de(this)}partial(e){let t={};for(let s of v.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let s of v.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof A;)a=a._def.innerType;t[s]=a}return new r({...this._def,shape:()=>t})}keyof(){return Pe(v.objectKeys(this.shape))}};O.create=(r,e)=>new O({shape:()=>r,unknownKeys:"strip",catchall:R.create(),typeName:_.ZodObject,...y(e)});O.strictCreate=(r,e)=>new O({shape:()=>r,unknownKeys:"strict",catchall:R.create(),typeName:_.ZodObject,...y(e)});O.lazycreate=(r,e)=>new O({shape:r,unknownKeys:"strip",catchall:R.create(),typeName:_.ZodObject,...y(e)});var Y=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new I(o.ctx.common.issues));return d(t,{code:c.invalid_union,unionErrors:i}),h}if(t.common.async)return Promise.all(s.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a,i=[];for(let l of s){let f={...t,common:{...t.common,issues:[]},parent:null},m=l._parseSync({data:t.data,path:t.path,parent:f});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:f}),f.common.issues.length&&i.push(f.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(l=>new I(l));return d(t,{code:c.invalid_union,unionErrors:o}),h}}get options(){return this._def.options}};Y.create=(r,e)=>new Y({options:r,typeName:_.ZodUnion,...y(e)});var $=r=>r instanceof X?$(r.schema):r instanceof E?$(r.innerType()):r instanceof ee?[r.value]:r instanceof te?r.options:r instanceof re?v.objectValues(r.enum):r instanceof se?$(r._def.innerType):r instanceof J?[void 0]:r instanceof K?[null]:r instanceof A?[void 0,...$(r.unwrap())]:r instanceof L?[null,...$(r.unwrap())]:r instanceof _e||r instanceof ae?$(r.unwrap()):r instanceof ne?$(r._def.innerType):[],we=class r extends g{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.object)return d(t,{code:c.invalid_type,expected:u.object,received:t.parsedType}),h;let s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(d(t,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),h)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let n=new Map;for(let a of t){let i=$(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new r({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...y(s)})}};function Ce(r,e){let t=N(r),s=N(e);if(r===e)return{valid:!0,data:r};if(t===u.object&&s===u.object){let n=v.objectKeys(e),a=v.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(let o of a){let l=Ce(r[o],e[o]);if(!l.valid)return{valid:!1};i[o]=l.data}return{valid:!0,data:i}}else if(t===u.array&&s===u.array){if(r.length!==e.length)return{valid:!1};let n=[];for(let a=0;a<r.length;a++){let i=r[a],o=e[a],l=Ce(i,o);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return t===u.date&&s===u.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var Q=class extends g{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(ke(a)||ke(i))return h;let o=Ce(a.value,i.value);return o.valid?((be(a)||be(i))&&t.dirty(),{status:t.value,value:o.data}):(d(s,{code:c.invalid_intersection_types}),h)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};Q.create=(r,e,t)=>new Q({left:r,right:e,typeName:_.ZodIntersection,...y(t)});var j=class r extends g{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.array)return d(s,{code:c.invalid_type,expected:u.array,received:s.parsedType}),h;if(s.data.length<this._def.items.length)return d(s,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),h;!this._def.rest&&s.data.length>this._def.items.length&&(d(s,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...s.data].map((i,o)=>{let l=this._def.items[o]||this._def.rest;return l?l._parse(new C(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>w.mergeArray(t,i)):w.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};j.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new j({items:r,typeName:_.ZodTuple,rest:null,...y(e)})};var Te=class r extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.object)return d(s,{code:c.invalid_type,expected:u.object,received:s.parsedType}),h;let n=[],a=this._def.keyType,i=this._def.valueType;for(let o in s.data)n.push({key:a._parse(new C(s,o,s.path,o)),value:i._parse(new C(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?w.mergeObjectAsync(t,n):w.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof g?new r({keyType:e,valueType:t,typeName:_.ZodRecord,...y(s)}):new r({keyType:z.create(),valueType:e,typeName:_.ZodRecord,...y(t)})}},fe=class extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.map)return d(s,{code:c.invalid_type,expected:u.map,received:s.parsedType}),h;let n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,l],f)=>({key:n._parse(new C(s,o,s.path,[f,"key"])),value:a._parse(new C(s,l,s.path,[f,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let l of i){let f=await l.key,m=await l.value;if(f.status==="aborted"||m.status==="aborted")return h;(f.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(f.value,m.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let l of i){let f=l.key,m=l.value;if(f.status==="aborted"||m.status==="aborted")return h;(f.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(f.value,m.value)}return{status:t.value,value:o}}}};fe.create=(r,e,t)=>new fe({valueType:e,keyType:r,typeName:_.ZodMap,...y(t)});var pe=class r extends g{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.set)return d(s,{code:c.invalid_type,expected:u.set,received:s.parsedType}),h;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(d(s,{code:c.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(d(s,{code:c.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function i(l){let f=new Set;for(let m of l){if(m.status==="aborted")return h;m.status==="dirty"&&t.dirty(),f.add(m.value)}return{status:t.value,value:f}}let o=[...s.data.values()].map((l,f)=>a._parse(new C(s,l,s.path,f)));return s.common.async?Promise.all(o).then(l=>i(l)):i(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:p.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};pe.create=(r,e)=>new pe({valueType:r,minSize:null,maxSize:null,typeName:_.ZodSet,...y(e)});var Se=class r extends g{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.function)return d(t,{code:c.invalid_type,expected:u.function,received:t.parsedType}),h;function s(o,l){return me({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,oe(),M].filter(f=>!!f),issueData:{code:c.invalid_arguments,argumentsError:l}})}function n(o,l){return me({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,oe(),M].filter(f=>!!f),issueData:{code:c.invalid_return_type,returnTypeError:l}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof G){let o=this;return T(async function(...l){let f=new I([]),m=await o._def.args.parseAsync(l,a).catch(S=>{throw f.addIssue(s(l,S)),f}),b=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(b,a).catch(S=>{throw f.addIssue(n(b,S)),f})})}else{let o=this;return T(function(...l){let f=o._def.args.safeParse(l,a);if(!f.success)throw new I([s(l,f.error)]);let m=Reflect.apply(i,this,f.data),b=o._def.returns.safeParse(m,a);if(!b.success)throw new I([n(m,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:j.create(e).rest(Z.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new r({args:e||j.create([]).rest(Z.create()),returns:t||Z.create(),typeName:_.ZodFunction,...y(s)})}},X=class extends g{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};X.create=(r,e)=>new X({getter:r,typeName:_.ZodLazy,...y(e)});var ee=class extends g{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return d(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),h}return{status:"valid",value:e.data}}get value(){return this._def.value}};ee.create=(r,e)=>new ee({value:r,typeName:_.ZodLiteral,...y(e)});function Pe(r,e){return new te({values:r,typeName:_.ZodEnum,...y(e)})}var te=class r extends g{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return d(t,{expected:v.joinValues(s),received:t.parsedType,code:c.invalid_type}),h}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return d(t,{received:t.data,code:c.invalid_enum_value,options:s}),h}return T(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};te.create=Pe;var re=class extends g{_parse(e){let t=v.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==u.string&&s.parsedType!==u.number){let n=v.objectValues(t);return d(s,{expected:v.joinValues(n),received:s.parsedType,code:c.invalid_type}),h}if(this._cache||(this._cache=new Set(v.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=v.objectValues(t);return d(s,{received:s.data,code:c.invalid_enum_value,options:n}),h}return T(e.data)}get enum(){return this._def.values}};re.create=(r,e)=>new re({values:r,typeName:_.ZodNativeEnum,...y(e)});var G=class extends g{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.promise&&t.common.async===!1)return d(t,{code:c.invalid_type,expected:u.promise,received:t.parsedType}),h;let s=t.parsedType===u.promise?t.data:Promise.resolve(t.data);return T(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};G.create=(r,e)=>new G({type:r,typeName:_.ZodPromise,...y(e)});var E=class extends g{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{d(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let i=n.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return h;let l=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return l.status==="aborted"?h:l.status==="dirty"?B(l.value):t.value==="dirty"?B(l.value):l});{if(t.value==="aborted")return h;let o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?h:o.status==="dirty"?B(o.value):t.value==="dirty"?B(o.value):o}}if(n.type==="refinement"){let i=o=>{let l=n.refinement(o,a);if(s.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?h:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?h:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!V(i))return h;let o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>V(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):h);v.assertNever(n)}};E.create=(r,e,t)=>new E({schema:r,typeName:_.ZodEffects,effect:e,...y(t)});E.createWithPreprocess=(r,e,t)=>new E({schema:e,effect:{type:"preprocess",transform:r},typeName:_.ZodEffects,...y(t)});var A=class extends g{_parse(e){return this._getType(e)===u.undefined?T(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};A.create=(r,e)=>new A({innerType:r,typeName:_.ZodOptional,...y(e)});var L=class extends g{_parse(e){return this._getType(e)===u.null?T(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};L.create=(r,e)=>new L({innerType:r,typeName:_.ZodNullable,...y(e)});var se=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===u.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};se.create=(r,e)=>new se({innerType:r,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});var ne=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ce(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new I(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new I(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};ne.create=(r,e)=>new ne({innerType:r,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});var he=class extends g{_parse(e){if(this._getType(e)!==u.nan){let s=this._getOrReturnCtx(e);return d(s,{code:c.invalid_type,expected:u.nan,received:s.parsedType}),h}return{status:"valid",value:e.data}}};he.create=r=>new he({typeName:_.ZodNaN,...y(r)});var Ot=Symbol("zod_brand"),_e=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},ye=class r extends g{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?h:a.status==="dirty"?(t.dirty(),B(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?h:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new r({in:e,out:t,typeName:_.ZodPipeline})}},ae=class extends g{_parse(e){let t=this._def.innerType._parse(e),s=n=>(V(n)&&(n.value=Object.freeze(n.value)),n);return ce(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}};ae.create=(r,e)=>new ae({innerType:r,typeName:_.ZodReadonly,...y(e)});function Me(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function Ve(r,e={},t){return r?U.create().superRefine((s,n)=>{let a=r(s);if(a instanceof Promise)return a.then(i=>{if(!i){let o=Me(e,s),l=o.fatal??t??!0;n.addIssue({code:"custom",...o,fatal:l})}});if(!a){let i=Me(e,s),o=i.fatal??t??!0;n.addIssue({code:"custom",...i,fatal:o})}}):U.create()}var At={object:O.lazycreate},_;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(_||(_={}));var Ct=(r,e={message:`Input not instance of ${r.name}`})=>Ve(t=>t instanceof r,e),ze=z.create,Ue=W.create,Et=he.create,Rt=F.create,Ge=H.create,Nt=q.create,jt=ue.create,Lt=J.create,Mt=K.create,$t=U.create,Zt=Z.create,Dt=R.create,Pt=le.create,Vt=D.create,zt=O.create,Ut=O.strictCreate,Gt=Y.create,Bt=we.create,Wt=Q.create,Ft=j.create,Ht=Te.create,qt=fe.create,Jt=pe.create,Kt=Se.create,Yt=X.create,Qt=ee.create,Xt=te.create,er=re.create,tr=G.create,rr=E.create,sr=A.create,nr=L.create,ar=E.createWithPreprocess,ir=ye.create,or=()=>ze().optional(),cr=()=>Ue().optional(),dr=()=>Ge().optional(),ur={string:(r=>z.create({...r,coerce:!0})),number:(r=>W.create({...r,coerce:!0})),boolean:(r=>H.create({...r,coerce:!0})),bigint:(r=>F.create({...r,coerce:!0})),date:(r=>q.create({...r,coerce:!0}))};var lr=h;import{connect as mr}from"node:net";import{randomUUID as _r}from"node:crypto";import{fileURLToPath as fr}from"node:url";import{dirname as Be,join as x,sep as Kr}from"node:path";import{existsSync as We}from"node:fs";import{homedir as pr,tmpdir as Xr}from"node:os";function hr(){let r=Be(fr(import.meta.url));for(let e=0;e<10;e++){if(We(x(r,"package.json"))&&We(x(r,"prompts")))return r;let t=Be(r);if(t===r)break;r=t}return process.cwd()}var Ie=hr();var es=x(Ie,"prompts"),ts=x(Ie,"src","db","migrations"),Fe=pr(),k=x(Fe,".sigil"),rs=x(k,".env"),ss=x(k,"config.json"),ns=x(k,"db"),as=x(k,"snapshots"),is=x(k,"CLAUDE.md"),os=x(k,"schemas"),cs=x(k,".hook-errors.log"),ds=x(k,".update-available"),us=x(k,".last-clean-doctor"),ls=x(k,".active-session.json"),fs=x(k,".stop-cursor.json"),ps=x(k,".stop-spool.jsonl"),hs=x(k,".hook-dedup.json"),He=x(k,"sock"),ms=x(k,"sigild.pid"),_s=x(k,"sigild.log"),ys=x(k,"heartbeat.json"),gs=x(k,".spawn.lock"),vs=x(k,".daemon-breaker.json"),xs=x(k,"gui.token"),ks=x(Ie,"dist","gui"),bs=x(Ie,"src","gui","web");var ws=x(k,"iroh"),Ts=x(k,"identity.key"),qe=x(Fe,".claude"),Ss=x(qe,"settings.json"),Is=x(qe,"CLAUDE.md");var Ee=class extends Error{constructor({code:e,message:t,stack:s}){super(t||e||"rpc error"),this.name="SigilRpcError",this.code=e||"handler_error",s&&(this.remoteStack=s)}};function Je({path:r=He,timeoutMs:e=3e4}={}){return new Promise((t,s)=>{let n=mr(r),a=new Map,i="",o=!1;n.setEncoding("utf8"),n.once("connect",()=>{n.off("error",l),t(f())});function l(m){s(m)}n.once("error",l),n.on("data",m=>{i+=m;let b;for(;(b=i.indexOf(`
|
|
4
|
+
`))!==-1;){let P=i.slice(0,b);if(i=i.slice(b+1),!P.trim())continue;let S;try{S=JSON.parse(P)}catch{continue}let ie=a.get(S.id);ie&&(a.delete(S.id),clearTimeout(ie.timer),S.ok?ie.resolve(S):ie.reject(new Ee(S.error||{})))}}),n.on("close",()=>{o=!0;for(let[,m]of a){clearTimeout(m.timer);let b=new Error("daemon connection closed");b.code="ECLOSED",m.reject(b)}a.clear()}),n.on("error",()=>{});function f(){return{call(m,b,{timeoutMs:P=e}={}){if(o){let xe=new Error("client is closed");return xe.code="ECLOSED",Promise.reject(xe)}let S=_r(),ie=process.env.SIGIL_AGENT||null,Qe=JSON.stringify({id:S,method:m,params:b,agent:ie})+`
|
|
5
|
+
`;return new Promise((xe,Ne)=>{let Xe=setTimeout(()=>{a.delete(S)&&Ne(new Error(`rpc timeout after ${P}ms: ${m}`))},P);a.set(S,{resolve:xe,reject:Ne,timer:Xe}),n.write(Qe)})},close(){return new Promise(m=>{if(o)return m();n.end(()=>m())})}}}})}function Re(r){return{content:[{type:"text",text:r}]}}var Ke=process.env.SIGIL_WORKER_ID||"unknown",ve=null;async function Ye(r,e){ve||(ve=Je({timeoutMs:1e4}).catch(n=>{throw ve=null,n}));let t=await ve,{data:s}=await t.call(r,e);return s}function vr(){let r=new gr({name:"sigil-worker",version:"0.1.0"});return r.tool("get_task","Pull the next task assigned to this worker. Returns {reqId, prompt} to process, or {empty:true} when there is nothing to do (then stop and wait).",{},async()=>{let e=await Ye("managedSession.getTask",{workerId:Ke});return Re(JSON.stringify(e))}),r.tool("submit_result","Return the result for a task. Call exactly once per task with the reqId from get_task and your answer as a string.",{reqId:ge.string().describe("The reqId from get_task this result is for."),result:ge.string().describe("Your answer for the task, as a plain string.")},async({reqId:e,result:t})=>{let s=await Ye("managedSession.submitResult",{workerId:Ke,reqId:e,result:t});return Re(JSON.stringify(s))}),r}async function xr(){let r=vr(),e=new yr;await r.connect(e);let t=async()=>{try{let s=await ve;s&&await s.close()}catch{}};return process.on("SIGTERM",t),process.on("SIGINT",t),process.on("beforeExit",t),r}import.meta.url===`file://${process.argv[1]}`&&xr().catch(r=>{process.stderr.write(`[sigil-worker-mcp] fatal: ${r.message}
|
|
6
|
+
`),process.exit(1)});export{vr as createWorkerMcpServer,xr as startWorkerMcp};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __sigilCreateRequire } from 'node:module'; const require = __sigilCreateRequire(import.meta.url);
|
|
3
|
+
import{dirname as D,join as S}from"node:path";import{fileURLToPath as A,pathToFileURL as E}from"node:url";import{homedir as T}from"node:os";import{readFileSync as U}from"node:fs";import{spawnSync as d}from"node:child_process";import{existsSync as l,readFileSync as g,rmSync as N,writeFileSync as w}from"node:fs";import{homedir as V}from"node:os";import{join as n,sep as b}from"node:path";function O(r,t){let o=s=>String(s||"0").replace(/^v/,"").split(/[-+]/)[0].split(".").map(a=>Number(a)||0),e=o(r),i=o(t);for(let s=0;s<3;s++){let a=(e[s]||0)-(i[s]||0);if(a!==0)return a>0?1:-1}return 0}function m(r){return String(r).replace(/[/\\]+$/,"")}function x(r,t){return!r||m(r)===m(t)?!1:m(r).split(b).includes("node_modules")}function h(r){try{return JSON.parse(g(n(r,"package.json"),"utf8")).version||null}catch{return null}}function C({doorVersion:r,appInstalled:t,appVersion:o,hasDatabase:e,attempted:i=!1}){return t?O(o,r)<0?i?{install:!1,finish:!1,reason:"catch-up-tried"}:{install:!0,finish:!!e,reason:"update"}:{install:!1,finish:!1,reason:"current"}:{install:!0,finish:!!e,reason:e?"migrate-legacy":"fresh"}}function G(r){if(l(n(r,".env"))||l(n(r,"db")))return!0;try{return JSON.parse(g(n(r,"config.json"),"utf8"))?.setup?.steps?.database==="done"}catch{return!1}}function f(r,t,o){let e=d(r,t,{stdio:["inherit",2,"inherit"],env:o});if(e.error)throw e.error;return e.status??1}function j({pkgRoot:r,appDir:t,launcher:o,finish:e}){let i=d("git",["-C",t,"rev-parse","--short","HEAD"],{encoding:"utf8"}),s=i.status===0?i.stdout.trim():null;try{let a={...process.env,SIGIL_NO_LAUNCH:"1",SIGIL_SKIP_TMUX:"1"};if(f("sh",[n(r,"install.sh")],a)!==0)return!1;if(!e)return!0;let c=["update","--finish"];return s&&c.push("--from",s),f(o,c,process.env)===0}catch{return!1}}function R({pkgRoot:r,version:t,args:o}){process.env.SIGIL_DOOR_ACTIVE==="1"&&(process.stderr.write(`Sigil install at ~/.sigil/app is broken (its CLI is missing).
|
|
4
|
+
Repair it: rm -rf ~/.sigil/app && sigil (your memories and config are kept)
|
|
5
|
+
`),process.exit(1));let e=n(V(),".sigil"),i=n(e,"app"),s=n(e,"bin","sigil"),a=n(e,".npm-catch-up"),c=!1;try{c=g(a,"utf8").trim()===t}catch{}let y=l(n(i,".git")),p=C({doorVersion:t,appInstalled:y,appVersion:h(i),hasDatabase:G(e),attempted:c});if(p.install&&y){try{w(a,t+`
|
|
6
|
+
`)}catch{}if(!j({pkgRoot:r,appDir:i,launcher:s,finish:p.finish}))process.stderr.write(`(warning) could not update Sigil to ${t} \u2014 continuing with ${h(i)||"the installed version"}. Run \`sigil update\` to retry.
|
|
7
|
+
`);else if(O(h(i),t)>=0)try{N(a,{force:!0})}catch{}}else if(p.install){let v=f("sh",[n(r,"install.sh")],{...process.env,SIGIL_NO_LAUNCH:"1"});if(v!==0&&process.exit(v),p.finish){let _=f(s,["update","--finish"],process.env);_!==0&&process.exit(_)}}l(s)||(process.stderr.write(`Sigil install is incomplete \u2014 ${s} is missing.
|
|
8
|
+
Re-run: npm i -g @anmol-srv/sigil (or the curl installer)
|
|
9
|
+
`),process.exit(1));let u=d(s,o,{stdio:"inherit",env:{...process.env,SIGIL_DOOR_ACTIVE:"1"}});u.error&&(process.stderr.write(`Could not start Sigil: ${u.error.message}
|
|
10
|
+
`),process.exit(1)),process.exit(u.status??1)}var L=D(A(import.meta.url)),I=D(L);if(process.env.SIGIL_NO_DOOR!=="1"&&x(I,S(T(),".sigil","app"))){let r="0.0.0";try{r=JSON.parse(U(S(I,"package.json"),"utf8")).version}catch{}R({pkgRoot:I,version:r,args:process.argv.slice(2)})}else{let r=S(L,"cli.js");await import(E(r).href)}
|