vibelearn 0.1.1 → 0.1.2
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/package.json
CHANGED
package/plugin/package.json
CHANGED
|
@@ -54,7 +54,7 @@ ${i.stack}`:` ${i.message}`:this.getLevel()===0&&typeof i=="object"?l=`
|
|
|
54
54
|
|
|
55
55
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of t.seen.entries()){let s=a[1];if(e===a[0]){i(a);continue}if(t.external){let u=t.external.registry.get(a[0])?.id;if(e!==a[0]&&u){i(a);continue}}if(t.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}if(s.count>1&&t.reused==="ref"){i(a);continue}}}function ca(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let s=t.seen.get(a);if(s.ref===null)return;let c=s.def??s.schema,u={...c},l=s.ref;if(s.ref=null,l){n(l);let p=t.seen.get(l),f=p.schema;if(f.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(f)):Object.assign(c,f),Object.assign(c,u),a._zod.parent===l)for(let h in c)h==="$ref"||h==="allOf"||h in u||delete c[h];if(f.$ref&&p.def)for(let h in c)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(c[h])===JSON.stringify(p.def[h])&&delete c[h]}let d=a._zod.parent;if(d&&d!==l){n(d);let p=t.seen.get(d);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(let f in c)f==="$ref"||f==="allOf"||f in p.def&&JSON.stringify(c[f])===JSON.stringify(p.def[f])&&delete c[f]}t.override({zodSchema:a,jsonSchema:c,path:s.path??[]})};for(let a of[...t.seen.entries()].reverse())n(a[0]);let o={};if(t.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=t.external.uri(a)}Object.assign(o,r.def??r.schema);let i=t.external?.defs??{};for(let a of t.seen.entries()){let s=a[1];s.def&&s.defId&&(i[s.defId]=s.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:bo(e,"input",t.processors),output:bo(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ce(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let n=t._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ce(n.element,r);if(n.type==="set")return Ce(n.valueType,r);if(n.type==="lazy")return Ce(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Ce(n.innerType,r);if(n.type==="intersection")return Ce(n.left,r)||Ce(n.right,r);if(n.type==="record"||n.type==="map")return Ce(n.keyType,r)||Ce(n.valueType,r);if(n.type==="pipe")return Ce(n.in,r)||Ce(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Ce(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Ce(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Ce(o,r))return!0;return!!(n.rest&&Ce(n.rest,r))}return!1}var Ym=(t,e={})=>r=>{let n=aa({...r,processors:e});return pe(t,n),sa(n,t),ca(n,t)},bo=(t,e,r={})=>n=>{let{libraryOptions:o,target:i}=n??{},a=aa({...o??{},target:i,io:e,processors:r});return pe(t,a),sa(a,t),ca(a,t)};var Hb={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Qm=(t,e,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:a,format:s,patterns:c,contentEncoding:u}=t._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),s&&(o.format=Hb[s]??s,o.format===""&&delete o.format,s==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},eh=(t,e,r,n)=>{let o=r,{minimum:i,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=t._zod.bag;typeof s=="string"&&s.includes("int")?o.type="integer":o.type="number",typeof l=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l),typeof i=="number"&&(o.minimum=i,typeof l=="number"&&e.target!=="draft-04"&&(l>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof a=="number"&&(o.maximum=a,typeof u=="number"&&e.target!=="draft-04"&&(u<=a?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},th=(t,e,r,n)=>{r.type="boolean"},rh=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},nh=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},oh=(t,e,r,n)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},ih=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},ah=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},sh=(t,e,r,n)=>{r.not={}},ch=(t,e,r,n)=>{},uh=(t,e,r,n)=>{},lh=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},dh=(t,e,r,n)=>{let o=t._zod.def,i=qn(o.entries);i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},ph=(t,e,r,n)=>{let o=t._zod.def,i=[];for(let a of o.values)if(a===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){let a=i[0];r.type=a===null?"null":typeof a,e.target==="draft-04"||e.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},fh=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},mh=(t,e,r,n)=>{let o=r,i=t._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},hh=(t,e,r,n)=>{let o=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=t._zod.bag;a!==void 0&&(i.minLength=a),s!==void 0&&(i.maxLength=s),c?c.length===1?(i.contentMediaType=c[0],Object.assign(o,i)):(Object.assign(o,i),o.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(o,i)},gh=(t,e,r,n)=>{r.type="boolean"},vh=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},_h=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},yh=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},$h=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},bh=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},xh=(t,e,r,n)=>{let o=r,i=t._zod.def,{minimum:a,maximum:s}=t._zod.bag;typeof a=="number"&&(o.minItems=a),typeof s=="number"&&(o.maxItems=s),o.type="array",o.items=pe(i.element,e,{...n,path:[...n.path,"items"]})},kh=(t,e,r,n)=>{let o=r,i=t._zod.def;o.type="object",o.properties={};let a=i.shape;for(let u in a)o.properties[u]=pe(a[u],e,{...n,path:[...n.path,"properties",u]});let s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{let l=i.shape[u]._zod;return e.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=pe(i.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(o.additionalProperties=!1)},Il=(t,e,r,n)=>{let o=t._zod.def,i=o.inclusive===!1,a=o.options.map((s,c)=>pe(s,e,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=a:r.anyOf=a},Sh=(t,e,r,n)=>{let o=t._zod.def,i=pe(o.left,e,{...n,path:[...n.path,"allOf",0]}),a=pe(o.right,e,{...n,path:[...n.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]];r.allOf=c},wh=(t,e,r,n)=>{let o=r,i=t._zod.def;o.type="array";let a=e.target==="draft-2020-12"?"prefixItems":"items",s=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((p,f)=>pe(p,e,{...n,path:[...n.path,a,f]})),u=i.rest?pe(i.rest,e,{...n,path:[...n.path,s,...e.target==="openapi-3.0"?[i.items.length]:[]]}):null;e.target==="draft-2020-12"?(o.prefixItems=c,u&&(o.items=u)):e.target==="openapi-3.0"?(o.items={anyOf:c},u&&o.items.anyOf.push(u),o.minItems=c.length,u||(o.maxItems=c.length)):(o.items=c,u&&(o.additionalItems=u));let{minimum:l,maximum:d}=t._zod.bag;typeof l=="number"&&(o.minItems=l),typeof d=="number"&&(o.maxItems=d)},zh=(t,e,r,n)=>{let o=r,i=t._zod.def;o.type="object";let a=i.keyType,c=a._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let l=pe(i.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of c)o.patternProperties[d.source]=l}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(o.propertyNames=pe(i.keyType,e,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=pe(i.valueType,e,{...n,path:[...n.path,"additionalProperties"]});let u=a._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l)}},Ih=(t,e,r,n)=>{let o=t._zod.def,i=pe(o.innerType,e,n),a=e.seen.get(t);e.target==="openapi-3.0"?(a.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Eh=(t,e,r,n)=>{let o=t._zod.def;pe(o.innerType,e,n);let i=e.seen.get(t);i.ref=o.innerType},Th=(t,e,r,n)=>{let o=t._zod.def;pe(o.innerType,e,n);let i=e.seen.get(t);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Ph=(t,e,r,n)=>{let o=t._zod.def;pe(o.innerType,e,n);let i=e.seen.get(t);i.ref=o.innerType,e.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Oh=(t,e,r,n)=>{let o=t._zod.def;pe(o.innerType,e,n);let i=e.seen.get(t);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},jh=(t,e,r,n)=>{let o=t._zod.def,i=e.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;pe(i,e,n);let a=e.seen.get(t);a.ref=i},Nh=(t,e,r,n)=>{let o=t._zod.def;pe(o.innerType,e,n);let i=e.seen.get(t);i.ref=o.innerType,r.readOnly=!0},Rh=(t,e,r,n)=>{let o=t._zod.def;pe(o.innerType,e,n);let i=e.seen.get(t);i.ref=o.innerType},El=(t,e,r,n)=>{let o=t._zod.def;pe(o.innerType,e,n);let i=e.seen.get(t);i.ref=o.innerType},Dh=(t,e,r,n)=>{let o=t._zod.innerType;pe(o,e,n);let i=e.seen.get(t);i.ref=o};function tn(t){return!!t._zod}function rr(t,e){return tn(t)?Hr(t,e):t.safeParse(e)}function ua(t){if(!t)return;let e;if(tn(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Uh(t){if(tn(t)){let i=t._zod?.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}var xo={};In(xo,{ZodAny:()=>ng,ZodArray:()=>sg,ZodBase64:()=>Yl,ZodBase64URL:()=>Ql,ZodBigInt:()=>_a,ZodBigIntFormat:()=>rd,ZodBoolean:()=>va,ZodCIDRv4:()=>Hl,ZodCIDRv6:()=>Xl,ZodCUID:()=>Vl,ZodCUID2:()=>Fl,ZodCatch:()=>Ig,ZodCodec:()=>ud,ZodCustom:()=>ka,ZodCustomStringFormat:()=>So,ZodDate:()=>od,ZodDefault:()=>bg,ZodDiscriminatedUnion:()=>ug,ZodE164:()=>ed,ZodEmail:()=>Ml,ZodEmoji:()=>Ll,ZodEnum:()=>ko,ZodExactOptional:()=>_g,ZodFile:()=>gg,ZodFunction:()=>Ag,ZodGUID:()=>da,ZodIPv4:()=>Kl,ZodIPv6:()=>Gl,ZodIntersection:()=>lg,ZodJWT:()=>td,ZodKSUID:()=>Wl,ZodLazy:()=>Ng,ZodLiteral:()=>hg,ZodMAC:()=>Qh,ZodMap:()=>fg,ZodNaN:()=>Tg,ZodNanoID:()=>ql,ZodNever:()=>ig,ZodNonOptional:()=>sd,ZodNull:()=>rg,ZodNullable:()=>$g,ZodNumber:()=>ga,ZodNumberFormat:()=>rn,ZodObject:()=>ya,ZodOptional:()=>ad,ZodPipe:()=>cd,ZodPrefault:()=>kg,ZodPromise:()=>Dg,ZodReadonly:()=>Pg,ZodRecord:()=>xa,ZodSet:()=>mg,ZodString:()=>ma,ZodStringFormat:()=>ce,ZodSuccess:()=>zg,ZodSymbol:()=>eg,ZodTemplateLiteral:()=>jg,ZodTransform:()=>vg,ZodTuple:()=>dg,ZodType:()=>V,ZodULID:()=>Jl,ZodURL:()=>ha,ZodUUID:()=>Ct,ZodUndefined:()=>tg,ZodUnion:()=>$a,ZodUnknown:()=>og,ZodVoid:()=>ag,ZodXID:()=>Bl,ZodXor:()=>cg,_ZodString:()=>Ul,_default:()=>xg,_function:()=>mk,any:()=>Hx,array:()=>G,base64:()=>Nx,base64url:()=>Rx,bigint:()=>Jx,boolean:()=>$e,catch:()=>Eg,check:()=>hk,cidrv4:()=>Ox,cidrv6:()=>jx,codec:()=>dk,cuid:()=>kx,cuid2:()=>Sx,custom:()=>ld,date:()=>Yx,describe:()=>gk,discriminatedUnion:()=>ba,e164:()=>Dx,email:()=>fx,emoji:()=>bx,enum:()=>Pe,exactOptional:()=>yg,file:()=>sk,float32:()=>Lx,float64:()=>qx,function:()=>mk,guid:()=>mx,hash:()=>Mx,hex:()=>Ux,hostname:()=>Cx,httpUrl:()=>$x,instanceof:()=>_k,int:()=>Cl,int32:()=>Vx,int64:()=>Bx,intersection:()=>zo,ipv4:()=>Ex,ipv6:()=>Px,json:()=>$k,jwt:()=>Ax,keyof:()=>Qx,ksuid:()=>Ix,lazy:()=>Rg,literal:()=>P,looseObject:()=>Te,looseRecord:()=>nk,mac:()=>Tx,map:()=>ok,meta:()=>vk,nan:()=>lk,nanoid:()=>xx,nativeEnum:()=>ak,never:()=>nd,nonoptional:()=>wg,null:()=>wo,nullable:()=>pa,nullish:()=>ck,number:()=>ne,object:()=>z,optional:()=>me,partialRecord:()=>rk,pipe:()=>fa,prefault:()=>Sg,preprocess:()=>Sa,promise:()=>fk,readonly:()=>Og,record:()=>fe,refine:()=>Zg,set:()=>ik,strictObject:()=>ek,string:()=>v,stringFormat:()=>Zx,stringbool:()=>yk,success:()=>uk,superRefine:()=>Cg,symbol:()=>Kx,templateLiteral:()=>pk,transform:()=>id,tuple:()=>pg,uint32:()=>Fx,uint64:()=>Wx,ulid:()=>wx,undefined:()=>Gx,union:()=>ie,unknown:()=>ue,url:()=>yx,uuid:()=>hx,uuidv4:()=>gx,uuidv6:()=>vx,uuidv7:()=>_x,void:()=>Xx,xid:()=>zx,xor:()=>tk});var la={};In(la,{endsWith:()=>ho,gt:()=>At,gte:()=>Ze,includes:()=>fo,length:()=>Qr,lowercase:()=>lo,lt:()=>Dt,lte:()=>He,maxLength:()=>Yr,maxSize:()=>$r,mime:()=>go,minLength:()=>tr,minSize:()=>Zt,multipleOf:()=>yr,negative:()=>gl,nonnegative:()=>_l,nonpositive:()=>vl,normalize:()=>vo,overwrite:()=>yt,positive:()=>hl,property:()=>yl,regex:()=>uo,size:()=>Xr,slugify:()=>ia,startsWith:()=>mo,toLowerCase:()=>yo,toUpperCase:()=>$o,trim:()=>_o,uppercase:()=>po});var br={};In(br,{ZodISODate:()=>jl,ZodISODateTime:()=>Pl,ZodISODuration:()=>Al,ZodISOTime:()=>Rl,date:()=>Nl,datetime:()=>Ol,duration:()=>Zl,time:()=>Dl});var Pl=m("ZodISODateTime",(t,e)=>{Fc.init(t,e),ce.init(t,e)});function Ol(t){return Bu(Pl,t)}var jl=m("ZodISODate",(t,e)=>{Jc.init(t,e),ce.init(t,e)});function Nl(t){return Wu(jl,t)}var Rl=m("ZodISOTime",(t,e)=>{Bc.init(t,e),ce.init(t,e)});function Dl(t){return Ku(Rl,t)}var Al=m("ZodISODuration",(t,e)=>{Wc.init(t,e),ce.init(t,e)});function Zl(t){return Gu(Al,t)}var Mh=(t,e)=>{Si.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>zi(t,r)},flatten:{value:r=>wi(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,Wr,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,Wr,2)}},isEmpty:{get(){return t.issues.length===0}}})},ND=m("ZodError",Mh),Xe=m("ZodError",Mh,{Parent:Error});var Lh=Kn(Xe),qh=Hn(Xe),Vh=Yn(Xe),Fh=Qn(Xe),Jh=tm(Xe),Bh=rm(Xe),Wh=nm(Xe),Kh=om(Xe),Gh=im(Xe),Hh=am(Xe),Xh=sm(Xe),Yh=cm(Xe);var V=m("ZodType",(t,e)=>(M.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:bo(t,"input"),output:bo(t,"output")}}),t.toJSONSchema=Ym(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone($.mergeDefs(e,{checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),t.with=t.check,t.clone=(r,n)=>De(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>Lh(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Vh(t,r,n),t.parseAsync=async(r,n)=>qh(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Fh(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>Jh(t,r,n),t.decode=(r,n)=>Bh(t,r,n),t.encodeAsync=async(r,n)=>Wh(t,r,n),t.decodeAsync=async(r,n)=>Kh(t,r,n),t.safeEncode=(r,n)=>Gh(t,r,n),t.safeDecode=(r,n)=>Hh(t,r,n),t.safeEncodeAsync=async(r,n)=>Xh(t,r,n),t.safeDecodeAsync=async(r,n)=>Yh(t,r,n),t.refine=(r,n)=>t.check(Zg(r,n)),t.superRefine=r=>t.check(Cg(r)),t.overwrite=r=>t.check(yt(r)),t.optional=()=>me(t),t.exactOptional=()=>yg(t),t.nullable=()=>pa(t),t.nullish=()=>me(pa(t)),t.nonoptional=r=>wg(t,r),t.array=()=>G(t),t.or=r=>ie([t,r]),t.and=r=>zo(t,r),t.transform=r=>fa(t,id(r)),t.default=r=>xg(t,r),t.prefault=r=>Sg(t,r),t.catch=r=>Eg(t,r),t.pipe=r=>fa(t,r),t.readonly=()=>Og(t),t.describe=r=>{let n=t.clone();return Ae.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Ae.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Ae.get(t);let n=t.clone();return Ae.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=r=>r(t),t)),Ul=m("_ZodString",(t,e)=>{_r.init(t,e),V.init(t,e),t._zod.processJSONSchema=(n,o,i)=>Qm(t,n,o,i);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(uo(...n)),t.includes=(...n)=>t.check(fo(...n)),t.startsWith=(...n)=>t.check(mo(...n)),t.endsWith=(...n)=>t.check(ho(...n)),t.min=(...n)=>t.check(tr(...n)),t.max=(...n)=>t.check(Yr(...n)),t.length=(...n)=>t.check(Qr(...n)),t.nonempty=(...n)=>t.check(tr(1,...n)),t.lowercase=n=>t.check(lo(n)),t.uppercase=n=>t.check(po(n)),t.trim=()=>t.check(_o()),t.normalize=(...n)=>t.check(vo(...n)),t.toLowerCase=()=>t.check(yo()),t.toUpperCase=()=>t.check($o()),t.slugify=()=>t.check(ia())}),ma=m("ZodString",(t,e)=>{_r.init(t,e),Ul.init(t,e),t.email=r=>t.check(Ui(Ml,r)),t.url=r=>t.check(co(ha,r)),t.jwt=r=>t.check(oa(td,r)),t.emoji=r=>t.check(Fi(Ll,r)),t.guid=r=>t.check(so(da,r)),t.uuid=r=>t.check(Mi(Ct,r)),t.uuidv4=r=>t.check(Li(Ct,r)),t.uuidv6=r=>t.check(qi(Ct,r)),t.uuidv7=r=>t.check(Vi(Ct,r)),t.nanoid=r=>t.check(Ji(ql,r)),t.guid=r=>t.check(so(da,r)),t.cuid=r=>t.check(Bi(Vl,r)),t.cuid2=r=>t.check(Wi(Fl,r)),t.ulid=r=>t.check(Ki(Jl,r)),t.base64=r=>t.check(ta(Yl,r)),t.base64url=r=>t.check(ra(Ql,r)),t.xid=r=>t.check(Gi(Bl,r)),t.ksuid=r=>t.check(Hi(Wl,r)),t.ipv4=r=>t.check(Xi(Kl,r)),t.ipv6=r=>t.check(Yi(Gl,r)),t.cidrv4=r=>t.check(Qi(Hl,r)),t.cidrv6=r=>t.check(ea(Xl,r)),t.e164=r=>t.check(na(ed,r)),t.datetime=r=>t.check(Ol(r)),t.date=r=>t.check(Nl(r)),t.time=r=>t.check(Dl(r)),t.duration=r=>t.check(Zl(r))});function v(t){return Fu(ma,t)}var ce=m("ZodStringFormat",(t,e)=>{oe.init(t,e),Ul.init(t,e)}),Ml=m("ZodEmail",(t,e)=>{Dc.init(t,e),ce.init(t,e)});function fx(t){return Ui(Ml,t)}var da=m("ZodGUID",(t,e)=>{Nc.init(t,e),ce.init(t,e)});function mx(t){return so(da,t)}var Ct=m("ZodUUID",(t,e)=>{Rc.init(t,e),ce.init(t,e)});function hx(t){return Mi(Ct,t)}function gx(t){return Li(Ct,t)}function vx(t){return qi(Ct,t)}function _x(t){return Vi(Ct,t)}var ha=m("ZodURL",(t,e)=>{Ac.init(t,e),ce.init(t,e)});function yx(t){return co(ha,t)}function $x(t){return co(ha,{protocol:/^https?$/,hostname:rt.domain,...$.normalizeParams(t)})}var Ll=m("ZodEmoji",(t,e)=>{Zc.init(t,e),ce.init(t,e)});function bx(t){return Fi(Ll,t)}var ql=m("ZodNanoID",(t,e)=>{Cc.init(t,e),ce.init(t,e)});function xx(t){return Ji(ql,t)}var Vl=m("ZodCUID",(t,e)=>{Uc.init(t,e),ce.init(t,e)});function kx(t){return Bi(Vl,t)}var Fl=m("ZodCUID2",(t,e)=>{Mc.init(t,e),ce.init(t,e)});function Sx(t){return Wi(Fl,t)}var Jl=m("ZodULID",(t,e)=>{Lc.init(t,e),ce.init(t,e)});function wx(t){return Ki(Jl,t)}var Bl=m("ZodXID",(t,e)=>{qc.init(t,e),ce.init(t,e)});function zx(t){return Gi(Bl,t)}var Wl=m("ZodKSUID",(t,e)=>{Vc.init(t,e),ce.init(t,e)});function Ix(t){return Hi(Wl,t)}var Kl=m("ZodIPv4",(t,e)=>{Kc.init(t,e),ce.init(t,e)});function Ex(t){return Xi(Kl,t)}var Qh=m("ZodMAC",(t,e)=>{Hc.init(t,e),ce.init(t,e)});function Tx(t){return Ju(Qh,t)}var Gl=m("ZodIPv6",(t,e)=>{Gc.init(t,e),ce.init(t,e)});function Px(t){return Yi(Gl,t)}var Hl=m("ZodCIDRv4",(t,e)=>{Xc.init(t,e),ce.init(t,e)});function Ox(t){return Qi(Hl,t)}var Xl=m("ZodCIDRv6",(t,e)=>{Yc.init(t,e),ce.init(t,e)});function jx(t){return ea(Xl,t)}var Yl=m("ZodBase64",(t,e)=>{Qc.init(t,e),ce.init(t,e)});function Nx(t){return ta(Yl,t)}var Ql=m("ZodBase64URL",(t,e)=>{eu.init(t,e),ce.init(t,e)});function Rx(t){return ra(Ql,t)}var ed=m("ZodE164",(t,e)=>{tu.init(t,e),ce.init(t,e)});function Dx(t){return na(ed,t)}var td=m("ZodJWT",(t,e)=>{ru.init(t,e),ce.init(t,e)});function Ax(t){return oa(td,t)}var So=m("ZodCustomStringFormat",(t,e)=>{nu.init(t,e),ce.init(t,e)});function Zx(t,e,r={}){return en(So,t,e,r)}function Cx(t){return en(So,"hostname",rt.hostname,t)}function Ux(t){return en(So,"hex",rt.hex,t)}function Mx(t,e){let r=e?.enc??"hex",n=`${t}_${r}`,o=rt[n];if(!o)throw new Error(`Unrecognized hash format: ${n}`);return en(So,n,o,e)}var ga=m("ZodNumber",(t,e)=>{Di.init(t,e),V.init(t,e),t._zod.processJSONSchema=(n,o,i)=>eh(t,n,o,i),t.gt=(n,o)=>t.check(At(n,o)),t.gte=(n,o)=>t.check(Ze(n,o)),t.min=(n,o)=>t.check(Ze(n,o)),t.lt=(n,o)=>t.check(Dt(n,o)),t.lte=(n,o)=>t.check(He(n,o)),t.max=(n,o)=>t.check(He(n,o)),t.int=n=>t.check(Cl(n)),t.safe=n=>t.check(Cl(n)),t.positive=n=>t.check(At(0,n)),t.nonnegative=n=>t.check(Ze(0,n)),t.negative=n=>t.check(Dt(0,n)),t.nonpositive=n=>t.check(He(0,n)),t.multipleOf=(n,o)=>t.check(yr(n,o)),t.step=(n,o)=>t.check(yr(n,o)),t.finite=()=>t;let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function ne(t){return Hu(ga,t)}var rn=m("ZodNumberFormat",(t,e)=>{ou.init(t,e),ga.init(t,e)});function Cl(t){return Xu(rn,t)}function Lx(t){return Yu(rn,t)}function qx(t){return Qu(rn,t)}function Vx(t){return el(rn,t)}function Fx(t){return tl(rn,t)}var va=m("ZodBoolean",(t,e)=>{oo.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>th(t,r,n,o)});function $e(t){return rl(va,t)}var _a=m("ZodBigInt",(t,e)=>{Ai.init(t,e),V.init(t,e),t._zod.processJSONSchema=(n,o,i)=>rh(t,n,o,i),t.gte=(n,o)=>t.check(Ze(n,o)),t.min=(n,o)=>t.check(Ze(n,o)),t.gt=(n,o)=>t.check(At(n,o)),t.gte=(n,o)=>t.check(Ze(n,o)),t.min=(n,o)=>t.check(Ze(n,o)),t.lt=(n,o)=>t.check(Dt(n,o)),t.lte=(n,o)=>t.check(He(n,o)),t.max=(n,o)=>t.check(He(n,o)),t.positive=n=>t.check(At(BigInt(0),n)),t.negative=n=>t.check(Dt(BigInt(0),n)),t.nonpositive=n=>t.check(He(BigInt(0),n)),t.nonnegative=n=>t.check(Ze(BigInt(0),n)),t.multipleOf=(n,o)=>t.check(yr(n,o));let r=t._zod.bag;t.minValue=r.minimum??null,t.maxValue=r.maximum??null,t.format=r.format??null});function Jx(t){return nl(_a,t)}var rd=m("ZodBigIntFormat",(t,e)=>{iu.init(t,e),_a.init(t,e)});function Bx(t){return ol(rd,t)}function Wx(t){return il(rd,t)}var eg=m("ZodSymbol",(t,e)=>{au.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>nh(t,r,n,o)});function Kx(t){return al(eg,t)}var tg=m("ZodUndefined",(t,e)=>{su.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ih(t,r,n,o)});function Gx(t){return sl(tg,t)}var rg=m("ZodNull",(t,e)=>{cu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>oh(t,r,n,o)});function wo(t){return cl(rg,t)}var ng=m("ZodAny",(t,e)=>{uu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ch(t,r,n,o)});function Hx(){return ul(ng)}var og=m("ZodUnknown",(t,e)=>{lu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>uh(t,r,n,o)});function ue(){return ll(og)}var ig=m("ZodNever",(t,e)=>{du.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>sh(t,r,n,o)});function nd(t){return dl(ig,t)}var ag=m("ZodVoid",(t,e)=>{pu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ah(t,r,n,o)});function Xx(t){return pl(ag,t)}var od=m("ZodDate",(t,e)=>{fu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(n,o,i)=>lh(t,n,o,i),t.min=(n,o)=>t.check(Ze(n,o)),t.max=(n,o)=>t.check(He(n,o));let r=t._zod.bag;t.minDate=r.minimum?new Date(r.minimum):null,t.maxDate=r.maximum?new Date(r.maximum):null});function Yx(t){return fl(od,t)}var sg=m("ZodArray",(t,e)=>{mu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>xh(t,r,n,o),t.element=e.element,t.min=(r,n)=>t.check(tr(r,n)),t.nonempty=r=>t.check(tr(1,r)),t.max=(r,n)=>t.check(Yr(r,n)),t.length=(r,n)=>t.check(Qr(r,n)),t.unwrap=()=>t.element});function G(t,e){return Xm(sg,t,e)}function Qx(t){let e=t._zod.def.shape;return Pe(Object.keys(e))}var ya=m("ZodObject",(t,e)=>{Gm.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>kh(t,r,n,o),$.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>Pe(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:ue()}),t.loose=()=>t.clone({...t._zod.def,catchall:ue()}),t.strict=()=>t.clone({...t._zod.def,catchall:nd()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>$.extend(t,r),t.safeExtend=r=>$.safeExtend(t,r),t.merge=r=>$.merge(t,r),t.pick=r=>$.pick(t,r),t.omit=r=>$.omit(t,r),t.partial=(...r)=>$.partial(ad,t,r[0]),t.required=(...r)=>$.required(sd,t,r[0])});function z(t,e){let r={type:"object",shape:t??{},...$.normalizeParams(e)};return new ya(r)}function ek(t,e){return new ya({type:"object",shape:t,catchall:nd(),...$.normalizeParams(e)})}function Te(t,e){return new ya({type:"object",shape:t,catchall:ue(),...$.normalizeParams(e)})}var $a=m("ZodUnion",(t,e)=>{io.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Il(t,r,n,o),t.options=e.options});function ie(t,e){return new $a({type:"union",options:t,...$.normalizeParams(e)})}var cg=m("ZodXor",(t,e)=>{$a.init(t,e),hu.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Il(t,r,n,o),t.options=e.options});function tk(t,e){return new cg({type:"union",options:t,inclusive:!1,...$.normalizeParams(e)})}var ug=m("ZodDiscriminatedUnion",(t,e)=>{$a.init(t,e),gu.init(t,e)});function ba(t,e,r){return new ug({type:"union",options:e,discriminator:t,...$.normalizeParams(r)})}var lg=m("ZodIntersection",(t,e)=>{vu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Sh(t,r,n,o)});function zo(t,e){return new lg({type:"intersection",left:t,right:e})}var dg=m("ZodTuple",(t,e)=>{Zi.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>wh(t,r,n,o),t.rest=r=>t.clone({...t._zod.def,rest:r})});function pg(t,e,r){let n=e instanceof M,o=n?r:e,i=n?e:null;return new dg({type:"tuple",items:t,rest:i,...$.normalizeParams(o)})}var xa=m("ZodRecord",(t,e)=>{_u.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>zh(t,r,n,o),t.keyType=e.keyType,t.valueType=e.valueType});function fe(t,e,r){return new xa({type:"record",keyType:t,valueType:e,...$.normalizeParams(r)})}function rk(t,e,r){let n=De(t);return n._zod.values=void 0,new xa({type:"record",keyType:n,valueType:e,...$.normalizeParams(r)})}function nk(t,e,r){return new xa({type:"record",keyType:t,valueType:e,mode:"loose",...$.normalizeParams(r)})}var fg=m("ZodMap",(t,e)=>{yu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>$h(t,r,n,o),t.keyType=e.keyType,t.valueType=e.valueType,t.min=(...r)=>t.check(Zt(...r)),t.nonempty=r=>t.check(Zt(1,r)),t.max=(...r)=>t.check($r(...r)),t.size=(...r)=>t.check(Xr(...r))});function ok(t,e,r){return new fg({type:"map",keyType:t,valueType:e,...$.normalizeParams(r)})}var mg=m("ZodSet",(t,e)=>{$u.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>bh(t,r,n,o),t.min=(...r)=>t.check(Zt(...r)),t.nonempty=r=>t.check(Zt(1,r)),t.max=(...r)=>t.check($r(...r)),t.size=(...r)=>t.check(Xr(...r))});function ik(t,e){return new mg({type:"set",valueType:t,...$.normalizeParams(e)})}var ko=m("ZodEnum",(t,e)=>{bu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(n,o,i)=>dh(t,n,o,i),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let i={};for(let a of n)if(r.has(a))i[a]=e.entries[a];else throw new Error(`Key ${a} not found in enum`);return new ko({...e,checks:[],...$.normalizeParams(o),entries:i})},t.exclude=(n,o)=>{let i={...e.entries};for(let a of n)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new ko({...e,checks:[],...$.normalizeParams(o),entries:i})}});function Pe(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new ko({type:"enum",entries:r,...$.normalizeParams(e)})}function ak(t,e){return new ko({type:"enum",entries:t,...$.normalizeParams(e)})}var hg=m("ZodLiteral",(t,e)=>{xu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ph(t,r,n,o),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function P(t,e){return new hg({type:"literal",values:Array.isArray(t)?t:[t],...$.normalizeParams(e)})}var gg=m("ZodFile",(t,e)=>{ku.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>hh(t,r,n,o),t.min=(r,n)=>t.check(Zt(r,n)),t.max=(r,n)=>t.check($r(r,n)),t.mime=(r,n)=>t.check(go(Array.isArray(r)?r:[r],n))});function sk(t){return $l(gg,t)}var vg=m("ZodTransform",(t,e)=>{Su.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>yh(t,r,n,o),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new hr(t.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push($.issue(i,r.value,e));else{let a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=t),r.issues.push($.issue(a))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(i=>(r.value=i,r)):(r.value=o,r)}});function id(t){return new vg({type:"transform",transform:t})}var ad=m("ZodOptional",(t,e)=>{Ci.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>El(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function me(t){return new ad({type:"optional",innerType:t})}var _g=m("ZodExactOptional",(t,e)=>{wu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>El(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function yg(t){return new _g({type:"optional",innerType:t})}var $g=m("ZodNullable",(t,e)=>{zu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ih(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function pa(t){return new $g({type:"nullable",innerType:t})}function ck(t){return me(pa(t))}var bg=m("ZodDefault",(t,e)=>{Iu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Th(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function xg(t,e){return new bg({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():$.shallowClone(e)}})}var kg=m("ZodPrefault",(t,e)=>{Eu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ph(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Sg(t,e){return new kg({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():$.shallowClone(e)}})}var sd=m("ZodNonOptional",(t,e)=>{Tu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Eh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function wg(t,e){return new sd({type:"nonoptional",innerType:t,...$.normalizeParams(e)})}var zg=m("ZodSuccess",(t,e)=>{Pu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>gh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function uk(t){return new zg({type:"success",innerType:t})}var Ig=m("ZodCatch",(t,e)=>{Ou.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Oh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Eg(t,e){return new Ig({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var Tg=m("ZodNaN",(t,e)=>{ju.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>fh(t,r,n,o)});function lk(t){return ml(Tg,t)}var cd=m("ZodPipe",(t,e)=>{Nu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>jh(t,r,n,o),t.in=e.in,t.out=e.out});function fa(t,e){return new cd({type:"pipe",in:t,out:e})}var ud=m("ZodCodec",(t,e)=>{cd.init(t,e),ao.init(t,e)});function dk(t,e,r){return new ud({type:"pipe",in:t,out:e,transform:r.decode,reverseTransform:r.encode})}var Pg=m("ZodReadonly",(t,e)=>{Ru.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Nh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Og(t){return new Pg({type:"readonly",innerType:t})}var jg=m("ZodTemplateLiteral",(t,e)=>{Du.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>mh(t,r,n,o)});function pk(t,e){return new jg({type:"template_literal",parts:t,...$.normalizeParams(e)})}var Ng=m("ZodLazy",(t,e)=>{Cu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Dh(t,r,n,o),t.unwrap=()=>t._zod.def.getter()});function Rg(t){return new Ng({type:"lazy",getter:t})}var Dg=m("ZodPromise",(t,e)=>{Zu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Rh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function fk(t){return new Dg({type:"promise",innerType:t})}var Ag=m("ZodFunction",(t,e)=>{Au.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>_h(t,r,n,o)});function mk(t){return new Ag({type:"function",input:Array.isArray(t?.input)?pg(t?.input):t?.input??G(ue()),output:t?.output??ue()})}var ka=m("ZodCustom",(t,e)=>{Uu.init(t,e),V.init(t,e),t._zod.processJSONSchema=(r,n,o)=>vh(t,r,n,o)});function hk(t){let e=new se({check:"custom"});return e._zod.check=t,e}function ld(t,e){return bl(ka,t??(()=>!0),e)}function Zg(t,e={}){return xl(ka,t,e)}function Cg(t){return kl(t)}var gk=Sl,vk=wl;function _k(t,e={}){let r=new ka({type:"custom",check:"custom",fn:n=>n instanceof t,abort:!0,...$.normalizeParams(e)});return r._zod.bag.Class=t,r._zod.check=n=>{n.value instanceof t||n.issues.push({code:"invalid_type",expected:t.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var yk=(...t)=>zl({Codec:ud,Boolean:va,String:ma},...t);function $k(t){let e=Rg(()=>ie([v(t),ne(),$e(),wo(),G(e),fe(v(),e)]));return e}function Sa(t,e){return fa(id(t),e)}var Ug;Ug||(Ug={});var LD={...xo,...la,iso:br};be(Mu());var pd="2025-11-25";var Mg=[pd,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],nr="io.modelcontextprotocol/related-task",za="2.0",xe=ld(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Lg=ie([v(),ne().int()]),qg=v(),a1=Te({ttl:ie([ne(),wo()]).optional(),pollInterval:ne().optional()}),Sk=z({ttl:ne().optional()}),wk=z({taskId:v()}),fd=Te({progressToken:Lg.optional(),[nr]:wk.optional()}),Ye=z({_meta:fd.optional()}),Io=Ye.extend({task:Sk.optional()}),Vg=t=>Io.safeParse(t).success,ke=z({method:v(),params:Ye.loose().optional()}),nt=z({_meta:fd.optional()}),ot=z({method:v(),params:nt.loose().optional()}),Se=Te({_meta:fd.optional()}),Ia=ie([v(),ne().int()]),Fg=z({jsonrpc:P(za),id:Ia,...ke.shape}).strict(),md=t=>Fg.safeParse(t).success,Jg=z({jsonrpc:P(za),...ot.shape}).strict(),Bg=t=>Jg.safeParse(t).success,hd=z({jsonrpc:P(za),id:Ia,result:Se}).strict(),Eo=t=>hd.safeParse(t).success;var Y;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(Y||(Y={}));var gd=z({jsonrpc:P(za),id:Ia.optional(),error:z({code:ne().int(),message:v(),data:ue().optional()})}).strict();var Wg=t=>gd.safeParse(t).success;var Kg=ie([Fg,Jg,hd,gd]),s1=ie([hd,gd]),Ea=Se.strict(),zk=nt.extend({requestId:Ia.optional(),reason:v().optional()}),Ta=ot.extend({method:P("notifications/cancelled"),params:zk}),Ik=z({src:v(),mimeType:v().optional(),sizes:G(v()).optional(),theme:Pe(["light","dark"]).optional()}),To=z({icons:G(Ik).optional()}),nn=z({name:v(),title:v().optional()}),Gg=nn.extend({...nn.shape,...To.shape,version:v(),websiteUrl:v().optional(),description:v().optional()}),Ek=zo(z({applyDefaults:$e().optional()}),fe(v(),ue())),Tk=Sa(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,zo(z({form:Ek.optional(),url:xe.optional()}),fe(v(),ue()).optional())),Pk=Te({list:xe.optional(),cancel:xe.optional(),requests:Te({sampling:Te({createMessage:xe.optional()}).optional(),elicitation:Te({create:xe.optional()}).optional()}).optional()}),Ok=Te({list:xe.optional(),cancel:xe.optional(),requests:Te({tools:Te({call:xe.optional()}).optional()}).optional()}),jk=z({experimental:fe(v(),xe).optional(),sampling:z({context:xe.optional(),tools:xe.optional()}).optional(),elicitation:Tk.optional(),roots:z({listChanged:$e().optional()}).optional(),tasks:Pk.optional()}),Nk=Ye.extend({protocolVersion:v(),capabilities:jk,clientInfo:Gg}),vd=ke.extend({method:P("initialize"),params:Nk});var Rk=z({experimental:fe(v(),xe).optional(),logging:xe.optional(),completions:xe.optional(),prompts:z({listChanged:$e().optional()}).optional(),resources:z({subscribe:$e().optional(),listChanged:$e().optional()}).optional(),tools:z({listChanged:$e().optional()}).optional(),tasks:Ok.optional()}),Dk=Se.extend({protocolVersion:v(),capabilities:Rk,serverInfo:Gg,instructions:v().optional()}),_d=ot.extend({method:P("notifications/initialized"),params:nt.optional()});var Pa=ke.extend({method:P("ping"),params:Ye.optional()}),Ak=z({progress:ne(),total:me(ne()),message:me(v())}),Zk=z({...nt.shape,...Ak.shape,progressToken:Lg}),Oa=ot.extend({method:P("notifications/progress"),params:Zk}),Ck=Ye.extend({cursor:qg.optional()}),Po=ke.extend({params:Ck.optional()}),Oo=Se.extend({nextCursor:qg.optional()}),Uk=Pe(["working","input_required","completed","failed","cancelled"]),jo=z({taskId:v(),status:Uk,ttl:ie([ne(),wo()]),createdAt:v(),lastUpdatedAt:v(),pollInterval:me(ne()),statusMessage:me(v())}),on=Se.extend({task:jo}),Mk=nt.merge(jo),No=ot.extend({method:P("notifications/tasks/status"),params:Mk}),ja=ke.extend({method:P("tasks/get"),params:Ye.extend({taskId:v()})}),Na=Se.merge(jo),Ra=ke.extend({method:P("tasks/result"),params:Ye.extend({taskId:v()})}),c1=Se.loose(),Da=Po.extend({method:P("tasks/list")}),Aa=Oo.extend({tasks:G(jo)}),Za=ke.extend({method:P("tasks/cancel"),params:Ye.extend({taskId:v()})}),Hg=Se.merge(jo),Xg=z({uri:v(),mimeType:me(v()),_meta:fe(v(),ue()).optional()}),Yg=Xg.extend({text:v()}),yd=v().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Qg=Xg.extend({blob:yd}),Ro=Pe(["user","assistant"]),an=z({audience:G(Ro).optional(),priority:ne().min(0).max(1).optional(),lastModified:br.datetime({offset:!0}).optional()}),ev=z({...nn.shape,...To.shape,uri:v(),description:me(v()),mimeType:me(v()),annotations:an.optional(),_meta:me(Te({}))}),Lk=z({...nn.shape,...To.shape,uriTemplate:v(),description:me(v()),mimeType:me(v()),annotations:an.optional(),_meta:me(Te({}))}),qk=Po.extend({method:P("resources/list")}),Vk=Oo.extend({resources:G(ev)}),Fk=Po.extend({method:P("resources/templates/list")}),Jk=Oo.extend({resourceTemplates:G(Lk)}),$d=Ye.extend({uri:v()}),Bk=$d,Wk=ke.extend({method:P("resources/read"),params:Bk}),Kk=Se.extend({contents:G(ie([Yg,Qg]))}),Gk=ot.extend({method:P("notifications/resources/list_changed"),params:nt.optional()}),Hk=$d,Xk=ke.extend({method:P("resources/subscribe"),params:Hk}),Yk=$d,Qk=ke.extend({method:P("resources/unsubscribe"),params:Yk}),eS=nt.extend({uri:v()}),tS=ot.extend({method:P("notifications/resources/updated"),params:eS}),rS=z({name:v(),description:me(v()),required:me($e())}),nS=z({...nn.shape,...To.shape,description:me(v()),arguments:me(G(rS)),_meta:me(Te({}))}),oS=Po.extend({method:P("prompts/list")}),iS=Oo.extend({prompts:G(nS)}),aS=Ye.extend({name:v(),arguments:fe(v(),v()).optional()}),sS=ke.extend({method:P("prompts/get"),params:aS}),bd=z({type:P("text"),text:v(),annotations:an.optional(),_meta:fe(v(),ue()).optional()}),xd=z({type:P("image"),data:yd,mimeType:v(),annotations:an.optional(),_meta:fe(v(),ue()).optional()}),kd=z({type:P("audio"),data:yd,mimeType:v(),annotations:an.optional(),_meta:fe(v(),ue()).optional()}),cS=z({type:P("tool_use"),name:v(),id:v(),input:fe(v(),ue()),_meta:fe(v(),ue()).optional()}),uS=z({type:P("resource"),resource:ie([Yg,Qg]),annotations:an.optional(),_meta:fe(v(),ue()).optional()}),lS=ev.extend({type:P("resource_link")}),Sd=ie([bd,xd,kd,lS,uS]),dS=z({role:Ro,content:Sd}),pS=Se.extend({description:v().optional(),messages:G(dS)}),fS=ot.extend({method:P("notifications/prompts/list_changed"),params:nt.optional()}),mS=z({title:v().optional(),readOnlyHint:$e().optional(),destructiveHint:$e().optional(),idempotentHint:$e().optional(),openWorldHint:$e().optional()}),hS=z({taskSupport:Pe(["required","optional","forbidden"]).optional()}),tv=z({...nn.shape,...To.shape,description:v().optional(),inputSchema:z({type:P("object"),properties:fe(v(),xe).optional(),required:G(v()).optional()}).catchall(ue()),outputSchema:z({type:P("object"),properties:fe(v(),xe).optional(),required:G(v()).optional()}).catchall(ue()).optional(),annotations:mS.optional(),execution:hS.optional(),_meta:fe(v(),ue()).optional()}),wd=Po.extend({method:P("tools/list")}),gS=Oo.extend({tools:G(tv)}),Ca=Se.extend({content:G(Sd).default([]),structuredContent:fe(v(),ue()).optional(),isError:$e().optional()}),u1=Ca.or(Se.extend({toolResult:ue()})),vS=Io.extend({name:v(),arguments:fe(v(),ue()).optional()}),Do=ke.extend({method:P("tools/call"),params:vS}),_S=ot.extend({method:P("notifications/tools/list_changed"),params:nt.optional()}),l1=z({autoRefresh:$e().default(!0),debounceMs:ne().int().nonnegative().default(300)}),Ao=Pe(["debug","info","notice","warning","error","critical","alert","emergency"]),yS=Ye.extend({level:Ao}),zd=ke.extend({method:P("logging/setLevel"),params:yS}),$S=nt.extend({level:Ao,logger:v().optional(),data:ue()}),bS=ot.extend({method:P("notifications/message"),params:$S}),xS=z({name:v().optional()}),kS=z({hints:G(xS).optional(),costPriority:ne().min(0).max(1).optional(),speedPriority:ne().min(0).max(1).optional(),intelligencePriority:ne().min(0).max(1).optional()}),SS=z({mode:Pe(["auto","required","none"]).optional()}),wS=z({type:P("tool_result"),toolUseId:v().describe("The unique identifier for the corresponding tool call."),content:G(Sd).default([]),structuredContent:z({}).loose().optional(),isError:$e().optional(),_meta:fe(v(),ue()).optional()}),zS=ba("type",[bd,xd,kd]),wa=ba("type",[bd,xd,kd,cS,wS]),IS=z({role:Ro,content:ie([wa,G(wa)]),_meta:fe(v(),ue()).optional()}),ES=Io.extend({messages:G(IS),modelPreferences:kS.optional(),systemPrompt:v().optional(),includeContext:Pe(["none","thisServer","allServers"]).optional(),temperature:ne().optional(),maxTokens:ne().int(),stopSequences:G(v()).optional(),metadata:xe.optional(),tools:G(tv).optional(),toolChoice:SS.optional()}),TS=ke.extend({method:P("sampling/createMessage"),params:ES}),Zo=Se.extend({model:v(),stopReason:me(Pe(["endTurn","stopSequence","maxTokens"]).or(v())),role:Ro,content:zS}),Id=Se.extend({model:v(),stopReason:me(Pe(["endTurn","stopSequence","maxTokens","toolUse"]).or(v())),role:Ro,content:ie([wa,G(wa)])}),PS=z({type:P("boolean"),title:v().optional(),description:v().optional(),default:$e().optional()}),OS=z({type:P("string"),title:v().optional(),description:v().optional(),minLength:ne().optional(),maxLength:ne().optional(),format:Pe(["email","uri","date","date-time"]).optional(),default:v().optional()}),jS=z({type:Pe(["number","integer"]),title:v().optional(),description:v().optional(),minimum:ne().optional(),maximum:ne().optional(),default:ne().optional()}),NS=z({type:P("string"),title:v().optional(),description:v().optional(),enum:G(v()),default:v().optional()}),RS=z({type:P("string"),title:v().optional(),description:v().optional(),oneOf:G(z({const:v(),title:v()})),default:v().optional()}),DS=z({type:P("string"),title:v().optional(),description:v().optional(),enum:G(v()),enumNames:G(v()).optional(),default:v().optional()}),AS=ie([NS,RS]),ZS=z({type:P("array"),title:v().optional(),description:v().optional(),minItems:ne().optional(),maxItems:ne().optional(),items:z({type:P("string"),enum:G(v())}),default:G(v()).optional()}),CS=z({type:P("array"),title:v().optional(),description:v().optional(),minItems:ne().optional(),maxItems:ne().optional(),items:z({anyOf:G(z({const:v(),title:v()}))}),default:G(v()).optional()}),US=ie([ZS,CS]),MS=ie([DS,AS,US]),LS=ie([MS,PS,OS,jS]),qS=Io.extend({mode:P("form").optional(),message:v(),requestedSchema:z({type:P("object"),properties:fe(v(),LS),required:G(v()).optional()})}),VS=Io.extend({mode:P("url"),message:v(),elicitationId:v(),url:v().url()}),FS=ie([qS,VS]),JS=ke.extend({method:P("elicitation/create"),params:FS}),BS=nt.extend({elicitationId:v()}),WS=ot.extend({method:P("notifications/elicitation/complete"),params:BS}),sn=Se.extend({action:Pe(["accept","decline","cancel"]),content:Sa(t=>t===null?void 0:t,fe(v(),ie([v(),ne(),$e(),G(v())])).optional())}),KS=z({type:P("ref/resource"),uri:v()});var GS=z({type:P("ref/prompt"),name:v()}),HS=Ye.extend({ref:ie([GS,KS]),argument:z({name:v(),value:v()}),context:z({arguments:fe(v(),v()).optional()}).optional()}),XS=ke.extend({method:P("completion/complete"),params:HS});var YS=Se.extend({completion:Te({values:G(v()).max(100),total:me(ne().int()),hasMore:me($e())})}),QS=z({uri:v().startsWith("file://"),name:v().optional(),_meta:fe(v(),ue()).optional()}),ew=ke.extend({method:P("roots/list"),params:Ye.optional()}),Ed=Se.extend({roots:G(QS)}),tw=ot.extend({method:P("notifications/roots/list_changed"),params:nt.optional()}),d1=ie([Pa,vd,XS,zd,sS,oS,qk,Fk,Wk,Xk,Qk,Do,wd,ja,Ra,Da,Za]),p1=ie([Ta,Oa,_d,tw,No]),f1=ie([Ea,Zo,Id,sn,Ed,Na,Aa,on]),m1=ie([Pa,TS,JS,ew,ja,Ra,Da,Za]),h1=ie([Ta,Oa,bS,tS,Gk,_S,fS,No,WS]),g1=ie([Ea,Dk,YS,pS,iS,Vk,Jk,Kk,Ca,gS,Na,Aa,on]),F=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===Y.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new dd(o.elicitations,r)}return new t(e,r,n)}},dd=class extends F{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(Y.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function or(t){return t==="completed"||t==="failed"||t==="cancelled"}var H1=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Td(t){let r=ua(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Uh(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Pd(t,e){let r=rr(t,e);if(!r.success)throw r.error;return r.data}var sw=6e4,Ua=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ta,r=>{this._oncancel(r)}),this.setNotificationHandler(Oa,r=>{this._onprogress(r)}),this.setRequestHandler(Pa,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ja,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new F(Y.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Ra,async(r,n)=>{let o=async()=>{let i=r.params.taskId;if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(i,n.sessionId);){if(s.type==="response"||s.type==="error"){let c=s.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),s.type==="response")l(c);else{let d=c,p=new F(d.error.code,d.error.message,d.error.data);l(p)}else{let d=s.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(s.message,{relatedRequestId:n.requestId})}}let a=await this._taskStore.getTask(i,n.sessionId);if(!a)throw new F(Y.InvalidParams,`Task not found: ${i}`);if(!or(a.status))return await this._waitForTaskUpdate(i,n.signal),await o();if(or(a.status)){let s=await this._taskStore.getTaskResult(i,n.sessionId);return this._clearTaskQueue(i),{...s,_meta:{...s._meta,[nr]:{taskId:i}}}}return await o()};return await o()}),this.setRequestHandler(Da,async(r,n)=>{try{let{tasks:o,nextCursor:i}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:i,_meta:{}}}catch(o){throw new F(Y.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Za,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new F(Y.InvalidParams,`Task not found: ${r.params.taskId}`);if(or(o.status))throw new F(Y.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new F(Y.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...i}}catch(o){throw o instanceof F?o:new F(Y.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),F.fromError(Y.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=i=>{n?.(i),this._onerror(i)};let o=this._transport?.onmessage;this._transport.onmessage=(i,a)=>{o?.(i,a),Eo(i)||Wg(i)?this._onresponse(i):md(i)?this._onrequest(i,a):Bg(i)?this._onnotification(i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(i)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=F.fromError(Y.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,i=e.params?._meta?.[nr]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:Y.MethodNotFound,message:"Method not found"}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let s=Vg(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:a.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(a.signal.aborted)return;let d={relatedRequestId:e.id};i&&(d.relatedTask={taskId:i}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(a.signal.aborted)throw new F(Y.ConnectionClosed,"Request was cancelled");let f={...p,relatedRequestId:e.id};i&&!f.relatedTask&&(f.relatedTask={taskId:i});let g=f.relatedTask?.taskId??i;return g&&c&&await c.updateTaskStatus(g,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:i,taskStore:c,taskRequestedTtl:s?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{s&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(a.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(a.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:Y.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,o=Number(r),i=this._progressHandlers.get(o);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(o),s=this._timeoutInfo.get(o);if(s&&a&&s.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),a(c);return}i(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Eo(e))n(e);else{let a=new F(e.error.code,e.error.message,e.error.data);n(a)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let i=!1;if(Eo(e)&&e.result&&typeof e.result=="object"){let a=e.result;if(a.task&&typeof a.task=="object"){let s=a.task;typeof s.taskId=="string"&&(i=!0,this._taskProgressTokens.set(s.taskId,r))}}if(i||this._progressHandlers.delete(r),Eo(e))o(e);else{let a=F.fromError(e.error.code,e.error.message,e.error.data);o(a)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(a){yield{type:"error",error:a instanceof F?a:new F(Y.InternalError,String(a))}}return}let i;try{let a=await this.request(e,on,n);if(a.task)i=a.task.taskId,yield{type:"taskCreated",task:a.task};else throw new F(Y.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:i},n);if(yield{type:"taskStatus",task:s},or(s.status)){s.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:i},r,n)}:s.status==="failed"?yield{type:"error",error:new F(Y.InternalError,`Task ${i} failed`)}:s.status==="cancelled"&&(yield{type:"error",error:new F(Y.InternalError,`Task ${i} was cancelled`)});return}if(s.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:i},r,n)};return}let c=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(a){yield{type:"error",error:a instanceof F?a:new F(Y.InternalError,String(a))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:i,onresumptiontoken:a,task:s,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=E=>{l(E)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),s&&this.assertTaskCapability(e.method)}catch(E){d(E);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...e,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),s&&(f.params={...f.params,task:s}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[nr]:c}});let g=E=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(E)}},{relatedRequestId:o,resumptionToken:i,onresumptiontoken:a}).catch(A=>this._onerror(new Error(`Failed to send cancellation: ${A}`)));let I=E instanceof F?E:new F(Y.RequestTimeout,String(E));l(I)};this._responseHandlers.set(p,E=>{if(!n?.signal?.aborted){if(E instanceof Error)return l(E);try{let I=rr(r,E.result);I.success?u(I.data):l(I.error)}catch(I){l(I)}}}),n?.signal?.addEventListener("abort",()=>{g(n?.signal?.reason)});let h=n?.timeout??sw,_=()=>g(F.fromError(Y.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(p,h,n?.maxTotalTimeout,_,n?.resetTimeoutOnProgress??!1);let b=c?.taskId;if(b){let E=I=>{let A=this._responseHandlers.get(p);A?A(I):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,E),this._enqueueTaskMessage(b,{type:"request",message:f,timestamp:Date.now()}).catch(I=>{this._cleanupTimeout(p),l(I)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:i,onresumptiontoken:a}).catch(E=>{this._cleanupTimeout(p),l(E)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Na,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Aa,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Hg,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let s={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[nr]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:s,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let s={...e,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[nr]:r.relatedTask}}}),this._transport?.send(s,r).catch(c=>this._onerror(c))});return}let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[nr]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(e,r){let n=Td(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,i)=>{let a=Pd(e,o);return Promise.resolve(r(a,i))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=Td(e);this._notificationHandlers.set(n,o=>{let i=Pd(e,o);return Promise.resolve(r(i))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&md(o.message)){let i=o.message.id,a=this._requestResolvers.get(i);a?(a(new F(Y.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,i)=>{if(r.aborted){i(new F(Y.InvalidRequest,"Request cancelled"));return}let a=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(a),i(new F(Y.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let i=await n.getTask(o,r);if(!i)throw new F(Y.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(o,i,a)=>{await n.storeTaskResult(o,i,a,r);let s=await n.getTask(o,r);if(s){let c=No.parse({method:"notifications/tasks/status",params:s});await this.notification(c),or(s.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,i,a)=>{let s=await n.getTask(o,r);if(!s)throw new F(Y.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(or(s.status))throw new F(Y.InvalidParams,`Cannot update task "${o}" from terminal status "${s.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,i,a,r);let c=await n.getTask(o,r);if(c){let u=No.parse({method:"notifications/tasks/status",params:c});await this.notification(u),or(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function rv(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function nv(t,e){let r={...t};for(let n in e){let o=n,i=e[o];if(i===void 0)continue;let a=r[o];rv(a)&&rv(i)?r[o]={...a,...i}:r[o]=i}return r}var Vy=vi(gf(),1),Fy=vi(qy(),1);function YT(){let t=new Vy.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Fy.default)(t),t}var bs=class{constructor(e){this._ajv=e??YT()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var xs=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],i=Array.isArray(o.content)?o.content:[o.content],a=i.some(l=>l.type==="tool_result"),s=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=s?Array.isArray(s.content)?s.content:[s.content]:[],u=c.some(l=>l.type==="tool_use");if(a){if(i.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(i.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},Zo,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),o=e.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let i=o==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:i},sn,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function Jy(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function By(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var ks=class extends Ua{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Ao.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let i=this._loggingLevels.get(o);return i?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(i):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new bs,this.setRequestHandler(vd,n=>this._oninitialize(n)),this.setNotificationHandler(_d,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(zd,async(n,o)=>{let i=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:a}=n.params,s=Ao.safeParse(a);return s.success&&this._loggingLevels.set(i,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new xs(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=nv(this._capabilities,e)}setRequestHandler(e,r){let o=ua(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let i;if(tn(o)){let s=o;i=s._zod?.def?.value??s.value}else{let s=o;i=s._def?.value??s.value}if(typeof i!="string")throw new Error("Schema method literal must be a string");if(i==="tools/call"){let s=async(c,u)=>{let l=rr(Do,c);if(!l.success){let g=l.error instanceof Error?l.error.message:String(l.error);throw new F(Y.InvalidParams,`Invalid tools/call request: ${g}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let g=rr(on,p);if(!g.success){let h=g.error instanceof Error?g.error.message:String(g.error);throw new F(Y.InvalidParams,`Invalid task creation result: ${h}`)}return g.data}let f=rr(Ca,p);if(!f.success){let g=f.error instanceof Error?f.error.message:String(f.error);throw new F(Y.InvalidParams,`Invalid tools/call result: ${g}`)}return f.data};return super.setRequestHandler(e,s)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){By(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&Jy(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Mg.includes(r)?r:pd,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Ea)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],i=o.some(u=>u.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,s=a?Array.isArray(a.content)?a.content:[a.content]:[],c=s.some(u=>u.type==="tool_use");if(i){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(s.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},Id,r):this.request({method:"sampling/createMessage",params:e},Zo,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=e;return this.request({method:"elicitation/create",params:o},sn,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=e.mode==="form"?e:{...e,mode:"form"},i=await this.request({method:"elicitation/create",params:o},sn,r);if(i.action==="accept"&&i.content&&o.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(o.requestedSchema)(i.content);if(!s.valid)throw new F(Y.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(a){throw a instanceof F?a:new F(Y.InternalError,`Error validating elicitation response: ${a instanceof Error?a.message:String(a)}`)}return i}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},Ed,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var Sf=vi(require("node:process"),1);var Ss=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
56
56
|
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),QT(r)}clear(){this._buffer=void 0}};function QT(t){return Kg.parse(JSON.parse(t))}function Wy(t){return JSON.stringify(t)+`
|
|
57
|
-
`}var ws=class{constructor(e=Sf.default.stdin,r=Sf.default.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new Ss,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=Wy(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var If=vi(require("path"),1);var wf={DEFAULT:3e5,HEALTH_CHECK:3e3,POST_SPAWN_WAIT:5e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,WORKER_STARTUP_WAIT:1e3,PRE_RESTART_SETTLE_DELAY:2e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5};function Ky(t){return process.platform==="win32"?Math.round(t*wf.WINDOWS_MULTIPLIER):t}var zt=require("fs"),zs=require("path"),Gy=require("os"),jr=class{static DEFAULTS={VIBELEARN_MODEL:"claude-sonnet-4-5",VIBELEARN_WORKER_PORT:"37778",VIBELEARN_WORKER_HOST:"127.0.0.1",VIBELEARN_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",VIBELEARN_PROVIDER:"claude",VIBELEARN_CLAUDE_AUTH_METHOD:"cli",VIBELEARN_GEMINI_API_KEY:"",VIBELEARN_GEMINI_MODEL:"gemini-2.5-flash-lite",VIBELEARN_GEMINI_RATE_LIMITING_ENABLED:"true",VIBELEARN_OPENROUTER_API_KEY:"",VIBELEARN_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",VIBELEARN_OPENROUTER_SITE_URL:"",VIBELEARN_OPENROUTER_APP_NAME:"vibelearn",VIBELEARN_OPENROUTER_MAX_CONTEXT_MESSAGES:"20",VIBELEARN_OPENROUTER_MAX_TOKENS:"100000",VIBELEARN_DATA_DIR:(0,zs.join)((0,Gy.homedir)(),".vibelearn"),VIBELEARN_LOG_LEVEL:"INFO",VIBELEARN_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",VIBELEARN_MAX_CONCURRENT_AGENTS:"2",VIBELEARN_EXCLUDED_PROJECTS:"",VIBELEARN_CONTEXT_OBSERVATIONS:"50",VIBELEARN_CONTEXT_FULL_COUNT:"3",VIBELEARN_CONTEXT_FULL_FIELD:"narrative",VIBELEARN_CONTEXT_SESSION_COUNT:"10",VIBELEARN_CONTEXT_SHOW_READ_TOKENS:"true",VIBELEARN_CONTEXT_SHOW_WORK_TOKENS:"true",VIBELEARN_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",VIBELEARN_CONTEXT_SHOW_SAVINGS_PERCENT:"true",VIBELEARN_CONTEXT_SHOW_LAST_SUMMARY:"true",VIBELEARN_CONTEXT_SHOW_LAST_MESSAGE:"true",VIBELEARN_CONTEXT_OBSERVATION_TYPES:"",VIBELEARN_CONTEXT_OBSERVATION_CONCEPTS:"",VIBELEARN_FOLDER_CLAUDEMD_ENABLED:"false",VIBELEARN_FOLDER_MD_EXCLUDE:"[]",VIBELEARN_API_KEY:"",VIBELEARN_API_URL:"https://
|
|
57
|
+
`}var ws=class{constructor(e=Sf.default.stdin,r=Sf.default.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new Ss,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=Wy(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var If=vi(require("path"),1);var wf={DEFAULT:3e5,HEALTH_CHECK:3e3,POST_SPAWN_WAIT:5e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,WORKER_STARTUP_WAIT:1e3,PRE_RESTART_SETTLE_DELAY:2e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5};function Ky(t){return process.platform==="win32"?Math.round(t*wf.WINDOWS_MULTIPLIER):t}var zt=require("fs"),zs=require("path"),Gy=require("os"),jr=class{static DEFAULTS={VIBELEARN_MODEL:"claude-sonnet-4-5",VIBELEARN_WORKER_PORT:"37778",VIBELEARN_WORKER_HOST:"127.0.0.1",VIBELEARN_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",VIBELEARN_PROVIDER:"claude",VIBELEARN_CLAUDE_AUTH_METHOD:"cli",VIBELEARN_GEMINI_API_KEY:"",VIBELEARN_GEMINI_MODEL:"gemini-2.5-flash-lite",VIBELEARN_GEMINI_RATE_LIMITING_ENABLED:"true",VIBELEARN_OPENROUTER_API_KEY:"",VIBELEARN_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",VIBELEARN_OPENROUTER_SITE_URL:"",VIBELEARN_OPENROUTER_APP_NAME:"vibelearn",VIBELEARN_OPENROUTER_MAX_CONTEXT_MESSAGES:"20",VIBELEARN_OPENROUTER_MAX_TOKENS:"100000",VIBELEARN_DATA_DIR:(0,zs.join)((0,Gy.homedir)(),".vibelearn"),VIBELEARN_LOG_LEVEL:"INFO",VIBELEARN_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",VIBELEARN_MAX_CONCURRENT_AGENTS:"2",VIBELEARN_EXCLUDED_PROJECTS:"",VIBELEARN_CONTEXT_OBSERVATIONS:"50",VIBELEARN_CONTEXT_FULL_COUNT:"3",VIBELEARN_CONTEXT_FULL_FIELD:"narrative",VIBELEARN_CONTEXT_SESSION_COUNT:"10",VIBELEARN_CONTEXT_SHOW_READ_TOKENS:"true",VIBELEARN_CONTEXT_SHOW_WORK_TOKENS:"true",VIBELEARN_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",VIBELEARN_CONTEXT_SHOW_SAVINGS_PERCENT:"true",VIBELEARN_CONTEXT_SHOW_LAST_SUMMARY:"true",VIBELEARN_CONTEXT_SHOW_LAST_MESSAGE:"true",VIBELEARN_CONTEXT_OBSERVATION_TYPES:"",VIBELEARN_CONTEXT_OBSERVATION_CONCEPTS:"",VIBELEARN_FOLDER_CLAUDEMD_ENABLED:"false",VIBELEARN_FOLDER_MD_EXCLUDE:"[]",VIBELEARN_API_KEY:"",VIBELEARN_API_URL:"https://vibelearn.dev",VIBELEARN_AUTO_SYNC:"true",VIBELEARN_SYNC_SNIPPETS:"true"};static getAllDefaults(){return{...this.DEFAULTS}}static get(e){return process.env[e]??this.DEFAULTS[e]}static getInt(e){let r=this.get(e);return parseInt(r,10)}static getBool(e){let r=this.get(e);return r==="true"||r===!0}static applyEnvOverrides(e){let r={...e};for(let n of Object.keys(this.DEFAULTS))process.env[n]!==void 0&&(r[n]=process.env[n]);return r}static loadFromFile(e){try{if(!(0,zt.existsSync)(e)){let a=this.getAllDefaults();try{let s=(0,zs.dirname)(e);(0,zt.existsSync)(s)||(0,zt.mkdirSync)(s,{recursive:!0}),(0,zt.writeFileSync)(e,JSON.stringify(a,null,2),"utf-8"),console.log("[SETTINGS] Created settings file with defaults:",e)}catch(s){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",e,s)}return this.applyEnvOverrides(a)}let r=(0,zt.readFileSync)(e,"utf-8"),n=JSON.parse(r),o=n;if(n.env&&typeof n.env=="object"){o=n.env;try{(0,zt.writeFileSync)(e,JSON.stringify(o,null,2),"utf-8"),console.log("[SETTINGS] Migrated settings file from nested to flat schema:",e)}catch(a){console.warn("[SETTINGS] Failed to auto-migrate settings file:",e,a)}}let i={...this.DEFAULTS};for(let a of Object.keys(this.DEFAULTS))o[a]!==void 0&&(i[a]=o[a]);return this.applyEnvOverrides(i)}catch(r){return console.warn("[SETTINGS] Failed to load settings, using defaults:",e,r),this.applyEnvOverrides(this.getAllDefaults())}}};var ye=require("path"),Is=require("os"),zf=require("fs");var Hy=require("url");var nP={};function eP(){return typeof __dirname<"u"?__dirname:(0,ye.dirname)((0,Hy.fileURLToPath)(nP.url))}var OU=eP();function tP(){if(process.env.VIBELEARN_DATA_DIR)return process.env.VIBELEARN_DATA_DIR.replace(/^~(?=$|\/)/,(0,Is.homedir)());let t=(0,ye.join)((0,Is.homedir)(),".vibelearn"),e=(0,ye.join)(t,"settings.json");try{if((0,zf.existsSync)(e)){let{readFileSync:r}=require("fs"),n=JSON.parse(r(e,"utf-8")),o=n.env??n;if(o.VIBELEARN_DATA_DIR)return o.VIBELEARN_DATA_DIR}}catch{}return t}var It=tP(),Es=process.env.CLAUDE_CONFIG_DIR||(0,ye.join)((0,Is.homedir)(),".claude"),rP=(0,ye.join)(Es,"plugins","marketplaces","vibelearn"),jU=(0,ye.join)(It,"archives"),NU=(0,ye.join)(It,"logs"),RU=(0,ye.join)(It,"trash"),DU=(0,ye.join)(It,"backups"),AU=(0,ye.join)(It,"modes"),ZU=(0,ye.join)(It,"settings.json"),CU=(0,ye.join)(It,"vibelearn.db"),UU=(0,ye.join)(It,"config.json"),MU=(0,ye.join)(It,"vector-db"),LU=(0,ye.join)(It,"observer-sessions"),qU=(0,ye.join)(Es,"settings.json"),VU=(0,ye.join)(Es,"commands"),FU=(0,ye.join)(Es,"CLAUDE.md");var oP=(()=>{let t=process.env.VIBELEARN_HEALTH_TIMEOUT_MS;if(t){let e=parseInt(t,10);if(Number.isFinite(e)&&e>=500&&e<=3e5)return e;ve.warn("SYSTEM","Invalid VIBELEARN_HEALTH_TIMEOUT_MS, using default",{value:t,min:500,max:3e5})}return Ky(wf.HEALTH_CHECK)})();function iP(t,e={},r){return new Promise((n,o)=>{let i=setTimeout(()=>o(new Error(`Request timed out after ${r}ms`)),r);fetch(t,e).then(a=>{clearTimeout(i),n(a)},a=>{clearTimeout(i),o(a)})})}var Ts=null,Ps=null;function aP(){if(Ts!==null)return Ts;let t=If.default.join(jr.get("VIBELEARN_DATA_DIR"),"settings.json"),e=jr.loadFromFile(t);return Ts=parseInt(e.VIBELEARN_WORKER_PORT,10),Ts}function sP(){if(Ps!==null)return Ps;let t=If.default.join(jr.get("VIBELEARN_DATA_DIR"),"settings.json");return Ps=jr.loadFromFile(t).VIBELEARN_WORKER_HOST,Ps}function cP(t){return`http://${sP()}:${aP()}${t}`}function Os(t,e={}){let r=e.method??"GET",n=e.timeoutMs??oP,o=cP(t),i={method:r};return e.headers&&(i.headers=e.headers),e.body&&(i.body=e.body),n>0?iP(o,i,n):fetch(o,i)}var zn=require("node:fs/promises"),hi=require("node:path");var Yy=require("node:child_process"),Et=require("node:fs"),Jt=require("node:path"),Of=require("node:os"),Pf=require("node:module"),bP={},Qy=typeof __filename<"u"?(0,Pf.createRequire)(__filename):(0,Pf.createRequire)(bP.url),uP={".js":"javascript",".mjs":"javascript",".cjs":"javascript",".jsx":"tsx",".ts":"typescript",".tsx":"tsx",".py":"python",".pyw":"python",".go":"go",".rs":"rust",".rb":"ruby",".java":"java",".c":"c",".h":"c",".cpp":"cpp",".cc":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp"};function e$(t){let e=t.slice(t.lastIndexOf("."));return uP[e]||"unknown"}var lP={javascript:"tree-sitter-javascript",typescript:"tree-sitter-typescript/typescript",tsx:"tree-sitter-typescript/tsx",python:"tree-sitter-python",go:"tree-sitter-go",rust:"tree-sitter-rust",ruby:"tree-sitter-ruby",java:"tree-sitter-java",c:"tree-sitter-c",cpp:"tree-sitter-cpp"};function t$(t){let e=lP[t];if(!e)return null;try{let r=Qy.resolve(e+"/package.json");return(0,Jt.dirname)(r)}catch{return null}}var dP={jsts:`
|
|
58
58
|
(function_declaration name: (identifier) @name) @func
|
|
59
59
|
(lexical_declaration (variable_declarator name: (identifier) @name value: [(arrow_function) (function_expression)])) @const_func
|
|
60
60
|
(class_declaration name: (type_identifier) @name) @cls
|
|
@@ -114,7 +114,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
114
114
|
${c}`}var xP=new Set([".js",".jsx",".ts",".tsx",".mjs",".cjs",".py",".pyw",".go",".rs",".rb",".java",".cs",".cpp",".c",".h",".hpp",".swift",".kt",".php",".vue",".svelte"]),kP=new Set(["node_modules",".git","dist","build",".next","__pycache__",".venv","venv","env",".env","target","vendor",".cache",".turbo","coverage",".nyc_output",".claude",".smart-file-read"]),SP=512*1024;async function*u$(t,e,r=20){if(r<=0)return;let n;try{n=await(0,zn.readdir)(t,{withFileTypes:!0})}catch{return}for(let o of n){if(o.name.startsWith(".")&&o.name!=="."||kP.has(o.name))continue;let i=(0,hi.join)(t,o.name);if(o.isDirectory())yield*u$(i,e,r-1);else if(o.isFile()){let a=o.name.slice(o.name.lastIndexOf("."));xP.has(a)&&(yield i)}}}async function wP(t){try{let e=await(0,zn.stat)(t);if(e.size>SP||e.size===0)return null;let r=await(0,zn.readFile)(t,"utf-8");return r.slice(0,1e3).includes("\0")?null:r}catch{return null}}async function l$(t,e,r={}){let n=r.maxResults||20,o=e.toLowerCase(),i=o.split(/[\s_\-./]+/).filter(h=>h.length>0),a=[];for await(let h of u$(t,t)){if(r.filePattern&&!(0,hi.relative)(t,h).toLowerCase().includes(r.filePattern.toLowerCase()))continue;let _=await wP(h);_&&a.push({absolutePath:h,relativePath:(0,hi.relative)(t,h),content:_})}let s=a$(a),c=[],u=[],l=0;for(let[h,_]of s){l+=zP(_);let E=Ns(h.toLowerCase(),i)>0,I=[],A=(j,Le)=>{for(let de of j){let Bt=0,Qe="",Wt=Ns(de.name.toLowerCase(),i);Wt>0&&(Bt+=Wt*3,Qe="name match"),de.signature.toLowerCase().includes(o)&&(Bt+=2,Qe=Qe?`${Qe} + signature`:"signature match"),de.jsdoc&&de.jsdoc.toLowerCase().includes(o)&&(Bt+=1,Qe=Qe?`${Qe} + jsdoc`:"jsdoc match"),Bt>0&&(E=!0,I.push({filePath:h,symbolName:Le?`${Le}.${de.name}`:de.name,kind:de.kind,signature:de.signature,jsdoc:de.jsdoc,lineStart:de.lineStart,lineEnd:de.lineEnd,matchReason:Qe})),de.children&&A(de.children,de.name)}};A(_.symbols),E&&(c.push(_),u.push(...I))}u.sort((h,_)=>{let b=Ns(h.symbolName.toLowerCase(),i);return Ns(_.symbolName.toLowerCase(),i)-b});let d=u.slice(0,n),p=new Set(d.map(h=>h.filePath)),f=c.filter(h=>p.has(h.filePath)).slice(0,n),g=f.reduce((h,_)=>h+_.foldedTokenEstimate,0);return{foldedFiles:f,matchingSymbols:d,totalFilesScanned:a.length,totalSymbolsFound:l,tokenEstimate:g}}function Ns(t,e){let r=0;for(let n of e)if(t===n)r+=10;else if(t.includes(n))r+=5;else{let o=0,i=0;for(let a of n){let s=t.indexOf(a,o);s!==-1&&(i++,o=s+1)}i===n.length&&(r+=1)}return r}function zP(t){let e=t.symbols.length;for(let r of t.symbols)r.children&&(e+=r.children.length);return e}function d$(t,e){let r=[];if(r.push(`\u{1F50D} Smart Search: "${e}"`),r.push(` Scanned ${t.totalFilesScanned} files, found ${t.totalSymbolsFound} symbols`),r.push(` ${t.matchingSymbols.length} matches across ${t.foldedFiles.length} files (~${t.tokenEstimate} tokens for folded view)`),r.push(""),t.matchingSymbols.length===0)return r.push(" No matching symbols found."),r.join(`
|
|
115
115
|
`);r.push("\u2500\u2500 Matching Symbols \u2500\u2500"),r.push("");for(let n of t.matchingSymbols){if(r.push(` ${n.kind} ${n.symbolName} (${n.filePath}:${n.lineStart+1})`),r.push(` ${n.signature}`),n.jsdoc){let o=n.jsdoc.split(`
|
|
116
116
|
`).find(i=>i.replace(/^[\s*/]+/,"").trim().length>0);o&&r.push(` \u{1F4AC} ${o.replace(/^[\s*/]+/,"").trim()}`)}r.push("")}r.push("\u2500\u2500 Folded File Views \u2500\u2500"),r.push("");for(let n of t.foldedFiles)r.push(wn(n)),r.push("");return r.push("\u2500\u2500 Actions \u2500\u2500"),r.push(" To see full implementation: use smart_unfold with file path and symbol name"),r.join(`
|
|
117
|
-
`)}var jf=require("node:fs/promises"),Rs=require("node:path"),IP="0.1.
|
|
117
|
+
`)}var jf=require("node:fs/promises"),Rs=require("node:path"),IP="0.1.2";console.log=(...t)=>{ve.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:t})};var p$={search:"/api/search",timeline:"/api/timeline"};async function f$(t,e){ve.debug("SYSTEM","\u2192 Worker API",void 0,{endpoint:t,params:e});try{let r=new URLSearchParams;for(let[a,s]of Object.entries(e))s!=null&&r.append(a,String(s));let n=`${t}?${r}`,o=await Os(n);if(!o.ok){let a=await o.text();throw new Error(`Worker API error (${o.status}): ${a}`)}let i=await o.json();return ve.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:t}),i}catch(r){return ve.error("SYSTEM","\u2190 Worker API error",{endpoint:t},r),{content:[{type:"text",text:`Error calling Worker API: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}}async function EP(t,e){ve.debug("HTTP","Worker API request (POST)",void 0,{endpoint:t});try{let r=await Os(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){let o=await r.text();throw new Error(`Worker API error (${r.status}): ${o}`)}let n=await r.json();return ve.debug("HTTP","Worker API success (POST)",void 0,{endpoint:t}),{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}catch(r){return ve.error("HTTP","Worker API error (POST)",{endpoint:t},r),{content:[{type:"text",text:`Error calling Worker API: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}}async function TP(){try{return(await Os("/api/health")).ok}catch(t){return ve.debug("SYSTEM","Worker health check failed",{},t),!1}}var m$=[{name:"__IMPORTANT",description:`3-LAYER WORKFLOW (ALWAYS FOLLOW):
|
|
118
118
|
1. search(query) \u2192 Get index with IDs (~50-100 tokens/result)
|
|
119
119
|
2. timeline(anchor=ID) \u2192 Get context around interesting results
|
|
120
120
|
3. get_observations([IDs]) \u2192 Fetch full details ONLY for filtered IDs
|