@reddb-io/red-skills 4.1.2 → 4.1.4

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.
@@ -50,7 +50,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
50
50
  `:`[${n[c]}\r
51
51
  ]`;continue}o+=n[c],n[c]==="\\"?i=!0:s&&n[c]==="]"?s=!1:!s&&n[c]==="["&&(s=!0)}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return o}function Qa(e,t){if(t.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),t.target==="openApi3"&&e.keyType?._def.typeName===E.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,o)=>({...n,[o]:W(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",o]})??je(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:W(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===E.ZodString&&e.keyType._def.checks?.length){let{type:n,...o}=Ya(e.keyType._def,t);return{...r,propertyNames:o}}else{if(e.keyType?._def.typeName===E.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===E.ZodBranded&&e.keyType._def.type._def.typeName===E.ZodString&&e.keyType._def.type._def.checks?.length){let{type:n,...o}=Xa(e.keyType._def,t);return{...r,propertyNames:o}}}return r}function Qv(e,t){if(t.mapStrategy==="record")return Qa(e,t);let r=W(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||je(t),n=W(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||je(t);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function eb(e){let t=e.values,n=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),o=Array.from(new Set(n.map(i=>typeof i)));return{type:o.length===1?o[0]==="string"?"string":"number":["string","number"],enum:n}}function tb(e){return e.target==="openAi"?void 0:{not:je({...e,currentPath:[...e.currentPath,"not"]})}}function rb(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Qi={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function ob(e,t){if(t.target==="openApi3")return nb(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in Qi&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((o,i)=>{let s=Qi[i._def.typeName];return s&&!o.includes(s)?[...o,s]:o},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((o,i)=>{let s=typeof i._def.value;switch(s){case"string":case"number":case"boolean":return[...o,s];case"bigint":return[...o,"integer"];case"object":if(i._def.value===null)return[...o,"null"];default:return o}},[]);if(n.length===r.length){let o=n.filter((i,s,a)=>a.indexOf(i)===s);return{type:o.length>1?o:o[0],enum:r.reduce((i,s)=>i.includes(s._def.value)?i:[...i,s._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,o)=>[...n,...o._def.values.filter(i=>!n.includes(i))],[])};return nb(e,t)}var nb=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,o)=>W(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${o}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function ib(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"?{type:Qi[e.innerType._def.typeName],nullable:!0}:{type:[Qi[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=W(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=W(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function sb(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",lf(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?ie(r,"minimum",n.value,n.message,t):ie(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),ie(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?ie(r,"maximum",n.value,n.message,t):ie(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),ie(r,"maximum",n.value,n.message,t));break;case"multipleOf":ie(r,"multipleOf",n.value,n.message,t);break}return r}function ab(e,t){let r=t.target==="openAi",n={type:"object",properties:{}},o=[],i=e.shape();for(let a in i){let c=i[a];if(c===void 0||c._def===void 0)continue;let u=vO(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=W(c._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,u||o.push(a))}o.length&&(n.required=o);let s=_O(e,t);return s!==void 0&&(n.additionalProperties=s),n}function _O(e,t){if(e.catchall._def.typeName!=="ZodNever")return W(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function vO(e){try{return e.isOptional()}catch{return!0}}var cb=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return W(e.innerType._def,t);let r=W(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:je(t)},r]}:je(t)};var ub=(e,t)=>{if(t.pipeStrategy==="input")return W(e.in._def,t);if(t.pipeStrategy==="output")return W(e.out._def,t);let r=W(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=W(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(o=>o!==void 0)}};function lb(e,t){return W(e.type._def,t)}function db(e,t){let n={type:"array",uniqueItems:!0,items:W(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&ie(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&ie(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}function fb(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>W(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:W(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>W(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function pb(e){return{not:je(e)}}function mb(e){return je(e)}var hb=(e,t)=>W(e.innerType._def,t);var gb=(e,t,r)=>{switch(t){case E.ZodString:return Ya(e,r);case E.ZodNumber:return sb(e,r);case E.ZodObject:return ab(e,r);case E.ZodBigInt:return Vv(e,r);case E.ZodBoolean:return Hv();case E.ZodDate:return df(e,r);case E.ZodUndefined:return pb(r);case E.ZodNull:return rb(r);case E.ZodArray:return Uv(e,r);case E.ZodUnion:case E.ZodDiscriminatedUnion:return ob(e,r);case E.ZodIntersection:return Kv(e,r);case E.ZodTuple:return fb(e,r);case E.ZodRecord:return Qa(e,r);case E.ZodLiteral:return Xv(e,r);case E.ZodEnum:return Gv(e);case E.ZodNativeEnum:return eb(e);case E.ZodNullable:return ib(e,r);case E.ZodOptional:return cb(e,r);case E.ZodMap:return Qv(e,r);case E.ZodSet:return db(e,r);case E.ZodLazy:return()=>e.getter()._def;case E.ZodPromise:return lb(e,r);case E.ZodNaN:case E.ZodNever:return tb(r);case E.ZodEffects:return Jv(e,r);case E.ZodAny:return je(r);case E.ZodUnknown:return mb(r);case E.ZodDefault:return Wv(e,r);case E.ZodBranded:return Xa(e,r);case E.ZodReadonly:return hb(e,r);case E.ZodCatch:return Bv(e,r);case E.ZodPipeline:return ub(e,r);case E.ZodFunction:case E.ZodVoid:case E.ZodSymbol:return;default:return(n=>{})(t)}};function W(e,t,r=!1){let n=t.seen.get(e);if(t.override){let a=t.override?.(e,t,n,r);if(a!==Zv)return a}if(n&&!r){let a=bO(n,t);if(a!==void 0)return a}let o={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,o);let i=gb(e,e.typeName,t),s=typeof i=="function"?W(i(),t):i;if(s&&wO(e,t,s),t.postProcess){let a=t.postProcess(s,e,t);return o.jsonSchema=s,a}return o.jsonSchema=s,s}var bO=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Ka(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),je(t)):t.$refStrategy==="seen"?je(t):void 0}},wO=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var mf=(e,t)=>{let r=Fv(t),n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[u,l])=>({...c,[u]:W(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??je(r)}),{}):void 0,o=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,i=W(e._def,o===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,o]},!1)??je(r),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(i.title=s),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=o===void 0?n?{...i,[r.definitionPath]:n}:i:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,o].join("/"),[r.definitionPath]:{...n,[o]:i}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function xO(e){return!e||e==="jsonSchema7"||e==="draft-7"?"draft-7":e==="jsonSchema2019-09"||e==="draft-2020-12"?"draft-2020-12":"draft-7"}function hf(e,t){return At(e)?Md(e,{target:xO(t?.target),io:t?.pipeStrategy??"input"}):mf(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"})}function gf(e){let r=Jr(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Pa(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function yf(e,t){let r=Wr(e,t);if(!r.success)throw r.error;return r.data}var $O=6e4,ec=class{constructor(t){this._options=t,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(ja,r=>{this._oncancel(r)}),this.setNotificationHandler(Ia,r=>{this._onprogress(r)}),this.setRequestHandler(Na,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ma,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new Z(U.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Aa,async(r,n)=>{let o=async()=>{let i=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(i,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,h=new Z(d.error.code,d.error.message,d.error.data);l(h)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let s=await this._taskStore.getTask(i,n.sessionId);if(!s)throw new Z(U.InvalidParams,`Task not found: ${i}`);if(!Kr(s.status))return await this._waitForTaskUpdate(i,n.signal),await o();if(Kr(s.status)){let a=await this._taskStore.getTaskResult(i,n.sessionId);return this._clearTaskQueue(i),{...a,_meta:{...a._meta,[Gr]:{taskId:i}}}}return await o()};return await o()}),this.setRequestHandler(qa,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 Z(U.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(La,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new Z(U.InvalidParams,`Task not found: ${r.params.taskId}`);if(Kr(o.status))throw new Z(U.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 Z(U.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...i}}catch(o){throw o instanceof Z?o:new Z(U.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,i=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),Z.fromError(U.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){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=t;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,s)=>{o?.(i,s),Vi(i)||Rv(i)?this._onresponse(i):Gd(i)?this._onrequest(i,s):Tv(i)?this._onnotification(i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(i)}`))},await this._transport.start()}_onclose(){let t=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=Z.fromError(U.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,i=t.params?._meta?.[Gr]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:U.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 s=new AbortController;this._requestHandlerAbortControllers.set(t.id,s);let a=Sv(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:s.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(s.signal.aborted)return;let d={relatedRequestId:t.id};i&&(d.relatedTask={taskId:i}),await this.notification(l,d)},sendRequest:async(l,d,h)=>{if(s.signal.aborted)throw new Z(U.ConnectionClosed,"Request was cancelled");let m={...h,relatedRequestId:t.id};i&&!m.relatedTask&&(m.relatedTask={taskId:i});let p=m.relatedTask?.taskId??i;return p&&c&&await c.updateTaskStatus(p,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:i,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async l=>{if(s.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(s.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:U.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(t.id)===s&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.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(t)}`));return}let s=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),s(c);return}i(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Vi(t))n(t);else{let s=new Z(t.error.code,t.error.message,t.error.data);n(s)}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(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let i=!1;if(Vi(t)&&t.result&&typeof t.result=="object"){let s=t.result;if(s.task&&typeof s.task=="object"){let a=s.task;typeof a.taskId=="string"&&(i=!0,this._taskProgressTokens.set(a.taskId,r))}}if(i||this._progressHandlers.delete(r),Vi(t))o(t);else{let s=Z.fromError(t.error.code,t.error.message,t.error.data);o(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(s){yield{type:"error",error:s instanceof Z?s:new Z(U.InternalError,String(s))}}return}let i;try{let s=await this.request(t,zo,n);if(s.task)i=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new Z(U.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:i},n);if(yield{type:"taskStatus",task:a},Kr(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:i},r,n)}:a.status==="failed"?yield{type:"error",error:new Z(U.InternalError,`Task ${i} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new Z(U.InternalError,`Task ${i} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:i},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof Z?s:new Z(U.InternalError,String(s))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:i,onresumptiontoken:s,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=T=>{l(T)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(T){d(T);return}n?.signal?.throwIfAborted();let h=this._requestMessageId++,m={...t,jsonrpc:"2.0",id:h};n?.onprogress&&(this._progressHandlers.set(h,n.onprogress),m.params={...t.params,_meta:{...t.params?._meta||{},progressToken:h}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[Gr]:c}});let p=T=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(T)}},{relatedRequestId:o,resumptionToken:i,onresumptiontoken:s}).catch(M=>this._onerror(new Error(`Failed to send cancellation: ${M}`)));let z=T instanceof Z?T:new Z(U.RequestTimeout,String(T));l(z)};this._responseHandlers.set(h,T=>{if(!n?.signal?.aborted){if(T instanceof Error)return l(T);try{let z=Wr(r,T.result);z.success?u(z.data):l(z.error)}catch(z){l(z)}}}),n?.signal?.addEventListener("abort",()=>{p(n?.signal?.reason)});let y=n?.timeout??$O,v=()=>p(Z.fromError(U.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(h,y,n?.maxTotalTimeout,v,n?.resetTimeoutOnProgress??!1);let P=c?.taskId;if(P){let T=z=>{let M=this._responseHandlers.get(h);M?M(z):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,T),this._enqueueTaskMessage(P,{type:"request",message:m,timestamp:Date.now()}).catch(z=>{this._cleanupTimeout(h),l(z)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:i,onresumptiontoken:s}).catch(T=>{this._cleanupTimeout(h),l(T)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Da,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},Za,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Ov,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Gr]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Gr]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let s={...t,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Gr]:r.relatedTask}}}),await this._transport.send(s,r)}setRequestHandler(t,r){let n=gf(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,i)=>{let s=yf(t,o);return Promise.resolve(r(s,i))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=gf(t);this._notificationHandlers.set(n,o=>{let i=yf(t,o);return Promise.resolve(r(i))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,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(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&Gd(o.message)){let i=o.message.id,s=this._requestResolvers.get(i);s?(s(new Z(U.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,i)=>{if(r.aborted){i(new Z(U.InvalidRequest,"Request cancelled"));return}let s=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(s),i(new Z(U.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let i=await n.getTask(o,r);if(!i)throw new Z(U.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(o,i,s)=>{await n.storeTaskResult(o,i,s,r);let a=await n.getTask(o,r);if(a){let c=Gi.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Kr(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,i,s)=>{let a=await n.getTask(o,r);if(!a)throw new Z(U.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Kr(a.status))throw new Z(U.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,i,s,r);let c=await n.getTask(o,r);if(c){let u=Gi.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Kr(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function yb(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function _b(e,t){let r={...e};for(let n in t){let o=n,i=t[o];if(i===void 0)continue;let s=r[o];yb(s)&&yb(i)?r[o]={...s,...i}:r[o]=i}return r}var u$=ea(nm(),1),l$=ea(c$(),1);function P1(){let e=new u$.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,l$.default)(e),e}var Ic=class{constructor(t){this._ajv=t??P1()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Mc=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],i=Array.isArray(o.content)?o.content:[o.content],s=i.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(s){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(h=>h.type==="tool_use").map(h=>h.id)),d=new Set(i.filter(h=>h.type==="tool_result").map(h=>h.toolUseId));if(l.size!==d.size||![...l].every(h=>d.has(h)))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:t},Yi,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.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"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:i},Co,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function d$(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function f$(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var Dc=class extends ec{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Xi.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 Ic,this.setRequestHandler(Yd,n=>this._oninitialize(n)),this.setNotificationHandler(Qd,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(af,async(n,o)=>{let i=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:s}=n.params,a=Xi.safeParse(s);return a.success&&this._loggingLevels.set(i,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Mc(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=_b(this._capabilities,t)}setRequestHandler(t,r){let o=Jr(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let i;if(At(o)){let a=o;i=a._zod?.def?.value??a.value}else{let a=o;i=a._def?.value??a.value}if(typeof i!="string")throw new Error("Schema method literal must be a string");if(i==="tools/call"){let a=async(c,u)=>{let l=Wr(Oo,c);if(!l.success){let p=l.error instanceof Error?l.error.message:String(l.error);throw new Z(U.InvalidParams,`Invalid tools/call request: ${p}`)}let{params:d}=l.data,h=await Promise.resolve(r(c,u));if(d.task){let p=Wr(zo,h);if(!p.success){let y=p.error instanceof Error?p.error.message:String(p.error);throw new Z(U.InvalidParams,`Invalid task creation result: ${y}`)}return p.data}let m=Wr(Ja,h);if(!m.success){let p=m.error instanceof Error?m.error.message:String(m.error);throw new Z(U.InvalidParams,`Invalid tools/call result: ${p}`)}return m.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);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 ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);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 ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);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 ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){f$(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&d$(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:wv.includes(r)?r:Wd,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"},Ca)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],i=o.some(u=>u.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=s?Array.isArray(s.content)?s.content:[s.content]:[],c=a.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(a.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 t.tools?this.request({method:"sampling/createMessage",params:t},cf,r):this.request({method:"sampling/createMessage",params:t},Yi,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},Co,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},i=await this.request({method:"elicitation/create",params:o},Co,r);if(i.action==="accept"&&i.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(i.content);if(!a.valid)throw new Z(U.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(s){throw s instanceof Z?s:new Z(U.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}return i}}}createElicitationCompletionNotifier(t,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:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},uf,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}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 m$=Symbol.for("mcp.completable");function dm(e){return!!e&&typeof e=="object"&&m$ in e}function h$(e){return e[m$]?.complete}var p$;(function(e){e.Completable="McpCompletable"})(p$||(p$={}));var T1=/^[A-Za-z0-9._-]{1,128}$/;function R1(e){let t=[];if(e.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!T1.test(e)){let r=e.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,o,i)=>i.indexOf(n)===o);return t.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function z1(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function fm(e){let t=R1(e);return z1(e,t.warnings),t.isValid}var Ac=class{constructor(t){this._mcpServer=t}registerToolTask(t,r,n){let o={taskSupport:"required",...r.execution};if(o.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,o,r._meta,n)}};var qc=class{constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Dc(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Ac(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(sn(Wa)),this.server.assertCanSetRequestHandler(sn(Oo)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Wa,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let n={name:t,title:r.title,description:r.description,inputSchema:(()=>{let o=To(r.inputSchema);return o?hf(o,{strictUnions:!0,pipeStrategy:"input"}):E1})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=To(r.outputSchema);o&&(n.outputSchema=hf(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Oo,async(t,r)=>{try{let n=this._registeredTools[t.params.name];if(!n)throw new Z(U.InvalidParams,`Tool ${t.params.name} not found`);if(!n.enabled)throw new Z(U.InvalidParams,`Tool ${t.params.name} disabled`);let o=!!t.params.task,i=n.execution?.taskSupport,s="createTask"in n.handler;if((i==="required"||i==="optional")&&!s)throw new Z(U.InternalError,`Tool ${t.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if(i==="required"&&!o)throw new Z(U.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(i==="optional"&&!o&&s)return await this.handleAutomaticTaskPolling(n,t,r);let a=await this.validateToolInput(n,t.params.arguments,t.params.name),c=await this.executeToolHandler(n,a,r);return o||await this.validateToolOutput(n,c,t.params.name),c}catch(n){if(n instanceof Z&&n.code===U.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,n){if(!t.inputSchema)return;let i=To(t.inputSchema)??t.inputSchema,s=await Sa(i,r);if(!s.success){let a="error"in s?s.error:"Unknown error",c=ka(a);throw new Z(U.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return s.data}async validateToolOutput(t,r,n){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new Z(U.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=To(t.outputSchema),i=await Sa(o,r.structuredContent);if(!i.success){let s="error"in i?i.error:"Unknown error",a=ka(s);throw new Z(U.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(t,r,n){let o=t.handler;if("createTask"in o){if(!n.taskStore)throw new Error("No task store provided.");let s={...n,taskStore:n.taskStore};if(t.inputSchema){let a=o;return await Promise.resolve(a.createTask(r,s))}else{let a=o;return await Promise.resolve(a.createTask(s))}}if(t.inputSchema){let s=o;return await Promise.resolve(s(r,n))}else{let s=o;return await Promise.resolve(s(n))}}async handleAutomaticTaskPolling(t,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let o=await this.validateToolInput(t,r.params.arguments,r.params.name),i=t.handler,s={...n,taskStore:n.taskStore},a=o?await Promise.resolve(i.createTask(o,s)):await Promise.resolve(i.createTask(s)),c=a.task.taskId,u=a.task,l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(h=>setTimeout(h,l));let d=await n.taskStore.getTask(c);if(!d)throw new Z(U.InternalError,`Task ${c} not found during polling`);u=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(sn(Ga)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Ga,async t=>{switch(t.params.ref.type){case"ref/prompt":return Dv(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return Av(t),this.handleResourceCompletion(t,t.params.ref);default:throw new Z(U.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let n=this._registeredPrompts[r.name];if(!n)throw new Z(U.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new Z(U.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return zs;let i=Jr(n.argsSchema)?.[t.params.argument.name];if(!dm(i))return zs;let s=h$(i);if(!s)return zs;let a=await s(t.params.argument.value,t.params.context);return y$(a)}async handleResourceCompletion(t,r){let n=Object.values(this._registeredResourceTemplates).find(s=>s.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return zs;throw new Z(U.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(t.params.argument.name);if(!o)return zs;let i=await o(t.params.argument.value,t.params.context);return y$(i)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(sn(Fa)),this.server.assertCanSetRequestHandler(sn(Ua)),this.server.assertCanSetRequestHandler(sn(Va)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Fa,async(t,r)=>{let n=Object.entries(this._registeredResources).filter(([i,s])=>s.enabled).map(([i,s])=>({uri:i,name:s.name,...s.metadata})),o=[];for(let i of Object.values(this._registeredResourceTemplates)){if(!i.resourceTemplate.listCallback)continue;let s=await i.resourceTemplate.listCallback(r);for(let a of s.resources)o.push({...i.metadata,...a})}return{resources:[...n,...o]}}),this.server.setRequestHandler(Ua,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Va,async(t,r)=>{let n=new URL(t.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new Z(U.InvalidParams,`Resource ${n} disabled`);return o.readCallback(n,r)}for(let i of Object.values(this._registeredResourceTemplates)){let s=i.resourceTemplate.uriTemplate.match(n.toString());if(s)return i.readCallback(n,s,r)}throw new Z(U.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(sn(Ha)),this.server.assertCanSetRequestHandler(sn(Ba)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Ha,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?O1(r.argsSchema):void 0}))})),this.server.setRequestHandler(Ba,async(t,r)=>{let n=this._registeredPrompts[t.params.name];if(!n)throw new Z(U.InvalidParams,`Prompt ${t.params.name} not found`);if(!n.enabled)throw new Z(U.InvalidParams,`Prompt ${t.params.name} disabled`);if(n.argsSchema){let o=To(n.argsSchema),i=await Sa(o,t.params.arguments);if(!i.success){let c="error"in i?i.error:"Unknown error",u=ka(c);throw new Z(U.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${u}`)}let s=i.data,a=n.callback;return await Promise.resolve(a(s,r))}else{let o=n.callback;return await Promise.resolve(o(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...n){let o;typeof n[0]=="object"&&(o=n.shift());let i=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(t,void 0,r,o,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let s=this._createRegisteredResourceTemplate(t,void 0,r,o,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}registerResource(t,r,n,o){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(t,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let i=this._createRegisteredResourceTemplate(t,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}_createRegisteredResource(t,r,n,o,i){let s={name:t,title:r,metadata:o,readCallback:i,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=s)),typeof a.name<"u"&&(s.name=a.name),typeof a.title<"u"&&(s.title=a.title),typeof a.metadata<"u"&&(s.metadata=a.metadata),typeof a.callback<"u"&&(s.readCallback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=s,s}_createRegisteredResourceTemplate(t,r,n,o,i){let s={resourceTemplate:n,title:r,metadata:o,readCallback:i,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==t&&(delete this._registeredResourceTemplates[t],u.name&&(this._registeredResourceTemplates[u.name]=s)),typeof u.title<"u"&&(s.title=u.title),typeof u.template<"u"&&(s.resourceTemplate=u.template),typeof u.metadata<"u"&&(s.metadata=u.metadata),typeof u.callback<"u"&&(s.readCallback=u.callback),typeof u.enabled<"u"&&(s.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[t]=s;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(t,r,n,o,i){let s={title:r,description:n,argsSchema:o===void 0?void 0:Hn(o),callback:i,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==t&&(delete this._registeredPrompts[t],a.name&&(this._registeredPrompts[a.name]=s)),typeof a.title<"u"&&(s.title=a.title),typeof a.description<"u"&&(s.description=a.description),typeof a.argsSchema<"u"&&(s.argsSchema=Hn(a.argsSchema)),typeof a.callback<"u"&&(s.callback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=s,o&&Object.values(o).some(c=>{let u=c instanceof bt?c._def?.innerType:c;return dm(u)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,n,o,i,s,a,c,u){fm(t);let l={title:r,description:n,inputSchema:g$(o),outputSchema:g$(i),annotations:s,execution:a,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==t&&(typeof d.name=="string"&&fm(d.name),delete this._registeredTools[t],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=Hn(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=Hn(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[t]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let n,o,i,s;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];if(pm(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!pm(r[0])&&(s=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(u=>typeof u=="object"&&u!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);s=r.shift()}}let a=r[0];return this._createRegisteredTool(t,void 0,n,o,i,s,{taskSupport:"forbidden"},void 0,a)}registerTool(t,r,n){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:o,description:i,inputSchema:s,outputSchema:a,annotations:c,_meta:u}=r;return this._createRegisteredTool(t,o,i,s,a,c,{taskSupport:"forbidden"},u,n)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let o;r.length>1&&(o=r.shift());let i=r[0],s=this._createRegisteredPrompt(t,void 0,n,o,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}registerPrompt(t,r,n){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:o,description:i,argsSchema:s}=r,a=this._createRegisteredPrompt(t,o,i,s,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var E1={type:"object",properties:{}};function _$(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function v$(e){return"_def"in e||"_zod"in e||_$(e)}function pm(e){return typeof e!="object"||e===null||v$(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(_$)}function g$(e){if(e){if(pm(e))return Hn(e);if(!v$(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function O1(e){let t=Jr(e);return t?Object.entries(t).map(([r,n])=>{let o=X_(n),i=Y_(n);return{name:r,description:o,required:!i}}):[]}function sn(e){let r=Jr(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Pa(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function y$(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var zs={completion:{values:[],hasMore:!1}};import w$ from"node:process";var Zc=class{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
52
52
  `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),C1(r)}clear(){this._buffer=void 0}};function C1(e){return zv.parse(JSON.parse(e))}function b$(e){return JSON.stringify(e)+`
53
- `}var Lc=class{constructor(t=w$.stdin,r=w$.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new Zc,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 t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}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(t){return new Promise(r=>{let n=b$(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function mm(e){let t={app:e,version:j1(Xo("__RED_BUILD_VERSION__",()=>"4.1.2")??"0.0.0-dev"),gitSha:Xo("__RED_BUILD_GIT_SHA__",()=>"e0207162bf17ccfd2123d1b1bb9d642332b42415")??"unknown",buildTime:Xo("__RED_BUILD_TIME__",()=>"2026-08-20T15:24:45-03:00")??"unknown",bundleAsset:Xo("__RED_BUNDLE_ASSET__",()=>"code-nav.bundle.min.mjs")??"unknown"},r=Xo("__REDDB_SDK_VERSION__",()=>""),n=Xo("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function j1(e){return e.startsWith("v")?e.slice(1):e}function x$(e){return`${e.app} ${e.version} ${e.gitSha}`}function Xo(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}var $$={"=":"data",":=":{to:"data",typed:!0},":":"meta"},N1=/^[a-z][a-z0-9+.-]*:\/\//i;function I1(e,t){return typeof t=="string"?{separator:e,to:t,typed:!1,prefix:!1}:{separator:e,to:t.to,typed:t.typed??!1,prefix:t.prefix??!1}}function M1(e=$$){return Object.entries(e).map(([t,r])=>I1(t,r)).sort((t,r)=>r.separator.length-t.separator.length)}function D1(e){return/^-\d+(\.\d+)?$/.test(e)}function Es(e){return!(!e||e.startsWith("-")&&!D1(e))}function Fc(e){if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;let t=Number(e);return!Number.isNaN(t)&&Number.isFinite(t)&&e.trim()!==""?t:e}function S$(e){if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}"))try{return JSON.parse(e)}catch{}let t=Number(e);return!Number.isNaN(t)&&Number.isFinite(t)&&e.trim()!==""?t:e.includes(",")?e.split(",").map(r=>S$(r.trim())):e}function no(e,t){switch(t){case"boolean":return A1(e);case"number":return q1(e);case"array":return e.split(",").map(r=>Fc(r.trim()));default:return e}}function A1(e){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"||t==="on"}function q1(e){if(e.trim()==="")throw new TypeError(`Cannot convert "${e}" to number`);let t=Number(e);if(Number.isNaN(t))throw new TypeError(`Cannot convert "${e}" to number`);return t}function an(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Z1(e,t={}){return e.map(r=>{let n=t[r.type];return n?n(r.value):r.value}).join("")}function $e(e,t){return{type:e,value:t}}function L1(e){let t=[],r=U1(e);if(t.push($e("section-header","Usage:"),$e("text"," "),$e("usage-text",r),$e("newline",`
53
+ `}var Lc=class{constructor(t=w$.stdin,r=w$.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new Zc,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 t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}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(t){return new Promise(r=>{let n=b$(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function mm(e){let t={app:e,version:j1(Xo("__RED_BUILD_VERSION__",()=>"4.1.4")??"0.0.0-dev"),gitSha:Xo("__RED_BUILD_GIT_SHA__",()=>"0dfb73a658a713b4c4c54b8caf121ca19825a277")??"unknown",buildTime:Xo("__RED_BUILD_TIME__",()=>"2026-08-20T15:51:31-03:00")??"unknown",bundleAsset:Xo("__RED_BUNDLE_ASSET__",()=>"code-nav.bundle.min.mjs")??"unknown"},r=Xo("__REDDB_SDK_VERSION__",()=>""),n=Xo("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function j1(e){return e.startsWith("v")?e.slice(1):e}function x$(e){return`${e.app} ${e.version} ${e.gitSha}`}function Xo(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}var $$={"=":"data",":=":{to:"data",typed:!0},":":"meta"},N1=/^[a-z][a-z0-9+.-]*:\/\//i;function I1(e,t){return typeof t=="string"?{separator:e,to:t,typed:!1,prefix:!1}:{separator:e,to:t.to,typed:t.typed??!1,prefix:t.prefix??!1}}function M1(e=$$){return Object.entries(e).map(([t,r])=>I1(t,r)).sort((t,r)=>r.separator.length-t.separator.length)}function D1(e){return/^-\d+(\.\d+)?$/.test(e)}function Es(e){return!(!e||e.startsWith("-")&&!D1(e))}function Fc(e){if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;let t=Number(e);return!Number.isNaN(t)&&Number.isFinite(t)&&e.trim()!==""?t:e}function S$(e){if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}"))try{return JSON.parse(e)}catch{}let t=Number(e);return!Number.isNaN(t)&&Number.isFinite(t)&&e.trim()!==""?t:e.includes(",")?e.split(",").map(r=>S$(r.trim())):e}function no(e,t){switch(t){case"boolean":return A1(e);case"number":return q1(e);case"array":return e.split(",").map(r=>Fc(r.trim()));default:return e}}function A1(e){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"||t==="on"}function q1(e){if(e.trim()==="")throw new TypeError(`Cannot convert "${e}" to number`);let t=Number(e);if(Number.isNaN(t))throw new TypeError(`Cannot convert "${e}" to number`);return t}function an(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Z1(e,t={}){return e.map(r=>{let n=t[r.type];return n?n(r.value):r.value}).join("")}function $e(e,t){return{type:e,value:t}}function L1(e){let t=[],r=U1(e);if(t.push($e("section-header","Usage:"),$e("text"," "),$e("usage-text",r),$e("newline",`
54
54
  `),$e("newline",`
55
55
  `)),e.positional&&e.positional.length>0){t.push($e("section-header","Arguments:"),$e("newline",`
56
56
  `));for(let n of e.positional)if(n.description){let o=n.variadic?`${n.name}...`:n.name;t.push($e("indent"," "),$e("positional-name",`<${o}>`)),n.required||t.push($e("positional-optional"," (optional)")),t.push($e("newline",`
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{mkdirSync as Pe,readFileSync as nn,writeFileSync as on}from"node:fs";import{dirname as sn,resolve as V}from"node:path";function W(e){let t={app:e,version:Ce(b("__RED_BUILD_VERSION__",()=>"4.1.2")??"0.0.0-dev"),gitSha:b("__RED_BUILD_GIT_SHA__",()=>"e0207162bf17ccfd2123d1b1bb9d642332b42415")??"unknown",buildTime:b("__RED_BUILD_TIME__",()=>"2026-08-20T15:24:45-03:00")??"unknown",bundleAsset:b("__RED_BUNDLE_ASSET__",()=>"opencode-host.bundle.min.mjs")??"unknown"},n=b("__REDDB_SDK_VERSION__",()=>""),s=b("__REDDB_BINARY_TAG__",()=>"");return n&&(t.reddbSdkVersion=n),s&&(t.reddbBinaryTag=s),t}function Ce(e){return e.startsWith("v")?e.slice(1):e}function G(e){return`${e.app} ${e.version} ${e.gitSha}`}function b(e,t){try{let n=t();return typeof n=="string"&&n.length>0?n:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}var ne={"=":"data",":=":{to:"data",typed:!0},":":"meta"},Te=/^[a-z][a-z0-9+.-]*:\/\//i;function Ie(e,t){return typeof t=="string"?{separator:e,to:t,typed:!1,prefix:!1}:{separator:e,to:t.to,typed:t.typed??!1,prefix:t.prefix??!1}}function je(e=ne){return Object.entries(e).map(([t,n])=>Ie(t,n)).sort((t,n)=>n.separator.length-t.separator.length)}function Fe(e){return/^-\d+(\.\d+)?$/.test(e)}function $(e){return!(!e||e.startsWith("-")&&!Fe(e))}function A(e){if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;let t=Number(e);return!Number.isNaN(t)&&Number.isFinite(t)&&e.trim()!==""?t:e}function oe(e){if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}"))try{return JSON.parse(e)}catch{}let t=Number(e);return!Number.isNaN(t)&&Number.isFinite(t)&&e.trim()!==""?t:e.includes(",")?e.split(",").map(n=>oe(n.trim())):e}function k(e,t){switch(t){case"boolean":return Ne(e);case"number":return De(e);case"array":return e.split(",").map(n=>A(n.trim()));case"string":default:return e}}function Ne(e){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"||t==="on"}function De(e){if(e.trim()==="")throw new TypeError(`Cannot convert "${e}" to number`);let t=Number(e);if(Number.isNaN(t))throw new TypeError(`Cannot convert "${e}" to number`);return t}function _(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Me(e,t={}){return e.map(n=>{let s=t[n.type];return s?s(n.value):n.value}).join("")}function g(e,t){return{type:e,value:t}}function Le(e){let t=[],n=Ve(e);if(t.push(g("section-header","Usage:"),g("text"," "),g("usage-text",n),g("newline",`
2
+ import{mkdirSync as Pe,readFileSync as nn,writeFileSync as on}from"node:fs";import{dirname as sn,resolve as V}from"node:path";function W(e){let t={app:e,version:Ce(b("__RED_BUILD_VERSION__",()=>"4.1.4")??"0.0.0-dev"),gitSha:b("__RED_BUILD_GIT_SHA__",()=>"0dfb73a658a713b4c4c54b8caf121ca19825a277")??"unknown",buildTime:b("__RED_BUILD_TIME__",()=>"2026-08-20T15:51:31-03:00")??"unknown",bundleAsset:b("__RED_BUNDLE_ASSET__",()=>"opencode-host.bundle.min.mjs")??"unknown"},n=b("__REDDB_SDK_VERSION__",()=>""),s=b("__REDDB_BINARY_TAG__",()=>"");return n&&(t.reddbSdkVersion=n),s&&(t.reddbBinaryTag=s),t}function Ce(e){return e.startsWith("v")?e.slice(1):e}function G(e){return`${e.app} ${e.version} ${e.gitSha}`}function b(e,t){try{let n=t();return typeof n=="string"&&n.length>0?n:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}var ne={"=":"data",":=":{to:"data",typed:!0},":":"meta"},Te=/^[a-z][a-z0-9+.-]*:\/\//i;function Ie(e,t){return typeof t=="string"?{separator:e,to:t,typed:!1,prefix:!1}:{separator:e,to:t.to,typed:t.typed??!1,prefix:t.prefix??!1}}function je(e=ne){return Object.entries(e).map(([t,n])=>Ie(t,n)).sort((t,n)=>n.separator.length-t.separator.length)}function Fe(e){return/^-\d+(\.\d+)?$/.test(e)}function $(e){return!(!e||e.startsWith("-")&&!Fe(e))}function A(e){if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;let t=Number(e);return!Number.isNaN(t)&&Number.isFinite(t)&&e.trim()!==""?t:e}function oe(e){if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}"))try{return JSON.parse(e)}catch{}let t=Number(e);return!Number.isNaN(t)&&Number.isFinite(t)&&e.trim()!==""?t:e.includes(",")?e.split(",").map(n=>oe(n.trim())):e}function k(e,t){switch(t){case"boolean":return Ne(e);case"number":return De(e);case"array":return e.split(",").map(n=>A(n.trim()));case"string":default:return e}}function Ne(e){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"||t==="on"}function De(e){if(e.trim()==="")throw new TypeError(`Cannot convert "${e}" to number`);let t=Number(e);if(Number.isNaN(t))throw new TypeError(`Cannot convert "${e}" to number`);return t}function _(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Me(e,t={}){return e.map(n=>{let s=t[n.type];return s?s(n.value):n.value}).join("")}function g(e,t){return{type:e,value:t}}function Le(e){let t=[],n=Ve(e);if(t.push(g("section-header","Usage:"),g("text"," "),g("usage-text",n),g("newline",`
3
3
  `),g("newline",`
4
4
  `)),e.positional&&e.positional.length>0){t.push(g("section-header","Arguments:"),g("newline",`
5
5
  `));for(let s of e.positional)if(s.description){let o=s.variadic?`${s.name}...`:s.name;t.push(g("indent"," "),g("positional-name",`<${o}>`)),s.required||t.push(g("positional-optional"," (optional)")),t.push(g("newline",`
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
3
- var Adt=Object.create;var VW=Object.defineProperty;var Odt=Object.getOwnPropertyDescriptor;var $dt=Object.getOwnPropertyNames;var Mdt=Object.getPrototypeOf,Ddt=Object.prototype.hasOwnProperty;var On=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var p=(e,t)=>()=>(e&&(t=e(e=0)),t);var ee=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Vn=(e,t)=>{for(var r in t)VW(e,r,{get:t[r],enumerable:!0})},Ndt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $dt(t))!Ddt.call(e,o)&&o!==r&&VW(e,o,{get:()=>t[o],enumerable:!(n=Odt(t,o))||n.enumerable});return e};var Cp=(e,t,r)=>(r=e!=null?Adt(Mdt(e)):{},Ndt(t||!e||!e.__esModule?VW(r,"default",{value:e,enumerable:!0}):r,e));function KW(e){let t={app:e,version:zdt(fk("__RED_BUILD_VERSION__",()=>"4.1.2")??"0.0.0-dev"),gitSha:fk("__RED_BUILD_GIT_SHA__",()=>"e0207162bf17ccfd2123d1b1bb9d642332b42415")??"unknown",buildTime:fk("__RED_BUILD_TIME__",()=>"2026-08-20T15:24:45-03:00")??"unknown",bundleAsset:fk("__RED_BUNDLE_ASSET__",()=>"redskilled-mcp.bundle.min.mjs")??"unknown"},r=fk("__REDDB_SDK_VERSION__",()=>""),n=fk("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function zdt(e){return e.startsWith("v")?e.slice(1):e}function nSe(e){return`${e.app} ${e.version} ${e.gitSha}`}function fk(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}var ZW=p(()=>{});function K(e,t,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let f=u[d];f in a||(a[f]=l[f].bind(a))}}let o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let l=r?.Parent?new i:this;n(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}function yo(e){return e&&Object.assign(jy,e),jy}var oSe,QW,YW,Hl,qm,jy,Uy=p(()=>{QW=Object.freeze({status:"aborted"});YW=Symbol("zod_brand"),Hl=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},qm=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(oSe=globalThis).__zod_globalConfig??(oSe.__zod_globalConfig={});jy=globalThis.__zod_globalConfig});var Re={};Vn(Re,{BIGINT_FORMAT_RANGES:()=>c4,Class:()=>e4,NUMBER_FORMAT_RANGES:()=>a4,aborted:()=>Vm,allowsEval:()=>n4,assert:()=>qdt,assertEqual:()=>Fdt,assertIs:()=>Udt,assertNever:()=>Hdt,assertNotEqual:()=>jdt,assignProp:()=>Bm,base64ToUint8Array:()=>sSe,base64urlToUint8Array:()=>spt,cached:()=>hk,captureStackTrace:()=>T$,cleanEnum:()=>ipt,cleanRegex:()=>C0,clone:()=>Cs,cloneDef:()=>Bdt,createTransparentProxy:()=>Qdt,defineLazy:()=>Jt,esc:()=>R$,escapeRegex:()=>$c,explicitlyAborted:()=>l4,extend:()=>ept,finalizeIssue:()=>Ps,floatSafeRemainder:()=>t4,getElementAtPath:()=>Wdt,getEnumValues:()=>T0,getLengthableOrigin:()=>A0,getParsedType:()=>Jdt,getSizableOrigin:()=>I0,hexToUint8Array:()=>cpt,isObject:()=>Hy,isPlainObject:()=>Wm,issue:()=>gk,joinValues:()=>ne,jsonStringifyReplacer:()=>mk,merge:()=>rpt,mergeDefs:()=>Pp,normalizeParams:()=>Ie,nullish:()=>Gm,numKeys:()=>Zdt,objectClone:()=>Gdt,omit:()=>Xdt,optionalKeys:()=>s4,parsedType:()=>Ee,partial:()=>npt,pick:()=>Ydt,prefixIssues:()=>ca,primitiveTypes:()=>i4,promiseAllObject:()=>Vdt,propertyKeyTypes:()=>P0,randomString:()=>Kdt,required:()=>opt,safeExtend:()=>tpt,shallowClone:()=>o4,slugify:()=>r4,stringifyPrimitive:()=>ve,uint8ArrayToBase64:()=>aSe,uint8ArrayToBase64url:()=>apt,uint8ArrayToHex:()=>lpt,unwrapMessage:()=>R0});function Fdt(e){return e}function jdt(e){return e}function Udt(e){}function Hdt(e){throw new Error("Unexpected value in exhaustive check")}function qdt(e){}function T0(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function ne(e,t="|"){return e.map(r=>ve(r)).join(t)}function mk(e,t){return typeof t=="bigint"?t.toString():t}function hk(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Gm(e){return e==null}function C0(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function t4(e,t){let r=e/t,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}function Jt(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==iSe)return n===void 0&&(n=iSe,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Gdt(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Bm(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Pp(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Bdt(e){return Pp(e._zod.def)}function Wdt(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Vdt(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[i];return o})}function Kdt(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function R$(e){return JSON.stringify(e)}function r4(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function Hy(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Wm(e){if(Hy(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Hy(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function o4(e){return Wm(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Zdt(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function $c(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cs(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function Ie(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Qdt(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,i){return t??(t=e()),Reflect.set(t,n,o,i)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function ve(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function s4(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function Ydt(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=Pp(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=r.shape[a])}return Bm(this,"shape",s),s},checks:[]});return Cs(e,i)}function Xdt(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=Pp(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return Bm(this,"shape",s),s},checks:[]});return Cs(e,i)}function ept(e,t){if(!Wm(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=Pp(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Bm(this,"shape",i),i}});return Cs(e,o)}function tpt(e,t){if(!Wm(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Pp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Bm(this,"shape",n),n}});return Cs(e,r)}function rpt(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=Pp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Bm(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Cs(e,r)}function npt(e,t,r){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=Pp(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let l in r){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);r[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(let l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return Bm(this,"shape",c),c},checks:[]});return Cs(t,s)}function opt(e,t,r){let n=Pp(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};if(r)for(let s in r){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(let s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return Bm(this,"shape",i),i}});return Cs(t,n)}function Vm(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function l4(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ca(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function R0(e){return typeof e=="string"?e:e?.message}function Ps(e,t,r){let n=e.message?e.message:R0(e.inst?._zod.def?.error?.(e))??R0(t?.error?.(e))??R0(r.customError?.(e))??R0(r.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=n,t?.reportInput&&(a.input=s),a}function I0(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function A0(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ee(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function gk(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function ipt(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function sSe(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function aSe(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function spt(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return sSe(t+r)}function apt(e){return aSe(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function cpt(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function lpt(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var iSe,T$,n4,Jdt,P0,i4,a4,c4,e4,ot=p(()=>{Uy();iSe=Symbol("evaluating");T$="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};n4=hk(()=>{if(jy.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});Jdt=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},P0=new Set(["string","number","symbol"]),i4=new Set(["string","number","bigint","boolean","symbol","undefined"]);a4={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},c4={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};e4=class{constructor(...t){}}});function $0(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function M0(e,t=r=>r.message){let r={_errors:[]},n=(o,i=[])=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>n({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")n({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")n({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,l=0;for(;l<a.length;){let u=a[l];l===a.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(s))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}}};return n(e),r}function u4(e,t=r=>r.message){let r={errors:[]},n=(o,i=[])=>{var s,a;for(let c of o.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>n({issues:l},[...i,...c.path]));else if(c.code==="invalid_key")n({issues:c.issues},[...i,...c.path]);else if(c.code==="invalid_element")n({issues:c.issues},[...i,...c.path]);else{let l=[...i,...c.path];if(l.length===0){r.errors.push(t(c));continue}let u=r,d=0;for(;d<l.length;){let f=l[d],m=d===l.length-1;typeof f=="string"?(u.properties??(u.properties={}),(s=u.properties)[f]??(s[f]={errors:[]}),u=u.properties[f]):(u.items??(u.items=[]),(a=u.items)[f]??(a[f]={errors:[]}),u=u.items[f]),m&&u.errors.push(t(c)),d++}}};return n(e),r}function lSe(e){let t=[],r=e.map(n=>typeof n=="object"?n.key:n);for(let n of r)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function d4(e){let t=[],r=[...e.issues].sort((n,o)=>(n.path??[]).length-(o.path??[]).length);for(let n of r)t.push(`\u2716 ${n.message}`),n.path?.length&&t.push(` \u2192 at ${lSe(n.path)}`);return t.join(`
3
+ var Adt=Object.create;var VW=Object.defineProperty;var Odt=Object.getOwnPropertyDescriptor;var $dt=Object.getOwnPropertyNames;var Mdt=Object.getPrototypeOf,Ddt=Object.prototype.hasOwnProperty;var On=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var p=(e,t)=>()=>(e&&(t=e(e=0)),t);var ee=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Vn=(e,t)=>{for(var r in t)VW(e,r,{get:t[r],enumerable:!0})},Ndt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $dt(t))!Ddt.call(e,o)&&o!==r&&VW(e,o,{get:()=>t[o],enumerable:!(n=Odt(t,o))||n.enumerable});return e};var Cp=(e,t,r)=>(r=e!=null?Adt(Mdt(e)):{},Ndt(t||!e||!e.__esModule?VW(r,"default",{value:e,enumerable:!0}):r,e));function KW(e){let t={app:e,version:zdt(fk("__RED_BUILD_VERSION__",()=>"4.1.4")??"0.0.0-dev"),gitSha:fk("__RED_BUILD_GIT_SHA__",()=>"0dfb73a658a713b4c4c54b8caf121ca19825a277")??"unknown",buildTime:fk("__RED_BUILD_TIME__",()=>"2026-08-20T15:51:31-03:00")??"unknown",bundleAsset:fk("__RED_BUNDLE_ASSET__",()=>"redskilled-mcp.bundle.min.mjs")??"unknown"},r=fk("__REDDB_SDK_VERSION__",()=>""),n=fk("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function zdt(e){return e.startsWith("v")?e.slice(1):e}function nSe(e){return`${e.app} ${e.version} ${e.gitSha}`}function fk(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}var ZW=p(()=>{});function K(e,t,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let f=u[d];f in a||(a[f]=l[f].bind(a))}}let o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let l=r?.Parent?new i:this;n(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}function yo(e){return e&&Object.assign(jy,e),jy}var oSe,QW,YW,Hl,qm,jy,Uy=p(()=>{QW=Object.freeze({status:"aborted"});YW=Symbol("zod_brand"),Hl=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},qm=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(oSe=globalThis).__zod_globalConfig??(oSe.__zod_globalConfig={});jy=globalThis.__zod_globalConfig});var Re={};Vn(Re,{BIGINT_FORMAT_RANGES:()=>c4,Class:()=>e4,NUMBER_FORMAT_RANGES:()=>a4,aborted:()=>Vm,allowsEval:()=>n4,assert:()=>qdt,assertEqual:()=>Fdt,assertIs:()=>Udt,assertNever:()=>Hdt,assertNotEqual:()=>jdt,assignProp:()=>Bm,base64ToUint8Array:()=>sSe,base64urlToUint8Array:()=>spt,cached:()=>hk,captureStackTrace:()=>T$,cleanEnum:()=>ipt,cleanRegex:()=>C0,clone:()=>Cs,cloneDef:()=>Bdt,createTransparentProxy:()=>Qdt,defineLazy:()=>Jt,esc:()=>R$,escapeRegex:()=>$c,explicitlyAborted:()=>l4,extend:()=>ept,finalizeIssue:()=>Ps,floatSafeRemainder:()=>t4,getElementAtPath:()=>Wdt,getEnumValues:()=>T0,getLengthableOrigin:()=>A0,getParsedType:()=>Jdt,getSizableOrigin:()=>I0,hexToUint8Array:()=>cpt,isObject:()=>Hy,isPlainObject:()=>Wm,issue:()=>gk,joinValues:()=>ne,jsonStringifyReplacer:()=>mk,merge:()=>rpt,mergeDefs:()=>Pp,normalizeParams:()=>Ie,nullish:()=>Gm,numKeys:()=>Zdt,objectClone:()=>Gdt,omit:()=>Xdt,optionalKeys:()=>s4,parsedType:()=>Ee,partial:()=>npt,pick:()=>Ydt,prefixIssues:()=>ca,primitiveTypes:()=>i4,promiseAllObject:()=>Vdt,propertyKeyTypes:()=>P0,randomString:()=>Kdt,required:()=>opt,safeExtend:()=>tpt,shallowClone:()=>o4,slugify:()=>r4,stringifyPrimitive:()=>ve,uint8ArrayToBase64:()=>aSe,uint8ArrayToBase64url:()=>apt,uint8ArrayToHex:()=>lpt,unwrapMessage:()=>R0});function Fdt(e){return e}function jdt(e){return e}function Udt(e){}function Hdt(e){throw new Error("Unexpected value in exhaustive check")}function qdt(e){}function T0(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function ne(e,t="|"){return e.map(r=>ve(r)).join(t)}function mk(e,t){return typeof t=="bigint"?t.toString():t}function hk(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Gm(e){return e==null}function C0(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function t4(e,t){let r=e/t,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}function Jt(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==iSe)return n===void 0&&(n=iSe,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Gdt(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Bm(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Pp(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Bdt(e){return Pp(e._zod.def)}function Wdt(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Vdt(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[i];return o})}function Kdt(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function R$(e){return JSON.stringify(e)}function r4(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function Hy(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Wm(e){if(Hy(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Hy(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function o4(e){return Wm(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Zdt(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function $c(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cs(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function Ie(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Qdt(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,i){return t??(t=e()),Reflect.set(t,n,o,i)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function ve(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function s4(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function Ydt(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=Pp(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=r.shape[a])}return Bm(this,"shape",s),s},checks:[]});return Cs(e,i)}function Xdt(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=Pp(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return Bm(this,"shape",s),s},checks:[]});return Cs(e,i)}function ept(e,t){if(!Wm(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=Pp(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Bm(this,"shape",i),i}});return Cs(e,o)}function tpt(e,t){if(!Wm(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Pp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Bm(this,"shape",n),n}});return Cs(e,r)}function rpt(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=Pp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Bm(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Cs(e,r)}function npt(e,t,r){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=Pp(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let l in r){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);r[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(let l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return Bm(this,"shape",c),c},checks:[]});return Cs(t,s)}function opt(e,t,r){let n=Pp(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};if(r)for(let s in r){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(let s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return Bm(this,"shape",i),i}});return Cs(t,n)}function Vm(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function l4(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ca(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function R0(e){return typeof e=="string"?e:e?.message}function Ps(e,t,r){let n=e.message?e.message:R0(e.inst?._zod.def?.error?.(e))??R0(t?.error?.(e))??R0(r.customError?.(e))??R0(r.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=n,t?.reportInput&&(a.input=s),a}function I0(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function A0(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ee(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function gk(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function ipt(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function sSe(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function aSe(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function spt(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return sSe(t+r)}function apt(e){return aSe(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function cpt(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function lpt(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var iSe,T$,n4,Jdt,P0,i4,a4,c4,e4,ot=p(()=>{Uy();iSe=Symbol("evaluating");T$="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};n4=hk(()=>{if(jy.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});Jdt=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},P0=new Set(["string","number","symbol"]),i4=new Set(["string","number","bigint","boolean","symbol","undefined"]);a4={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},c4={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};e4=class{constructor(...t){}}});function $0(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function M0(e,t=r=>r.message){let r={_errors:[]},n=(o,i=[])=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>n({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")n({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")n({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,l=0;for(;l<a.length;){let u=a[l];l===a.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(s))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}}};return n(e),r}function u4(e,t=r=>r.message){let r={errors:[]},n=(o,i=[])=>{var s,a;for(let c of o.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>n({issues:l},[...i,...c.path]));else if(c.code==="invalid_key")n({issues:c.issues},[...i,...c.path]);else if(c.code==="invalid_element")n({issues:c.issues},[...i,...c.path]);else{let l=[...i,...c.path];if(l.length===0){r.errors.push(t(c));continue}let u=r,d=0;for(;d<l.length;){let f=l[d],m=d===l.length-1;typeof f=="string"?(u.properties??(u.properties={}),(s=u.properties)[f]??(s[f]={errors:[]}),u=u.properties[f]):(u.items??(u.items=[]),(a=u.items)[f]??(a[f]={errors:[]}),u=u.items[f]),m&&u.errors.push(t(c)),d++}}};return n(e),r}function lSe(e){let t=[],r=e.map(n=>typeof n=="object"?n.key:n);for(let n of r)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function d4(e){let t=[],r=[...e.issues].sort((n,o)=>(n.path??[]).length-(o.path??[]).length);for(let n of r)t.push(`\u2716 ${n.message}`),n.path?.length&&t.push(` \u2192 at ${lSe(n.path)}`);return t.join(`
4
4
  `)}var cSe,O0,la,p4=p(()=>{Uy();ot();cSe=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,mk,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},O0=K("$ZodError",cSe),la=K("$ZodError",cSe,{Parent:Error})});var yk,C$,bk,P$,xk,f4,Sk,m4,I$,dpt,A$,ppt,O$,fpt,$$,mpt,M$,hpt,D$,gpt,N$,ypt,z$,bpt,h4=p(()=>{Uy();p4();ot();yk=e=>(t,r,n,o)=>{let i=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new Hl;if(s.issues.length){let a=new(o?.Err??e)(s.issues.map(c=>Ps(c,i,yo())));throw T$(a,o?.callee),a}return s.value},C$=yk(la),bk=e=>async(t,r,n,o)=>{let i=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(o?.Err??e)(s.issues.map(c=>Ps(c,i,yo())));throw T$(a,o?.callee),a}return s.value},P$=bk(la),xk=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new Hl;return i.issues.length?{success:!1,error:new(e??O0)(i.issues.map(s=>Ps(s,o,yo())))}:{success:!0,data:i.value}},f4=xk(la),Sk=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>Ps(s,o,yo())))}:{success:!0,data:i.value}},m4=Sk(la),I$=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return yk(e)(t,r,o)},dpt=I$(la),A$=e=>(t,r,n)=>yk(e)(t,r,n),ppt=A$(la),O$=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return bk(e)(t,r,o)},fpt=O$(la),$$=e=>async(t,r,n)=>bk(e)(t,r,n),mpt=$$(la),M$=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return xk(e)(t,r,o)},hpt=M$(la),D$=e=>(t,r,n)=>xk(e)(t,r,n),gpt=D$(la),N$=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Sk(e)(t,r,o)},ypt=N$(la),z$=e=>async(t,r,n)=>Sk(e)(t,r,n),bpt=z$(la)});var Va={};Vn(Va,{base64:()=>A4,base64url:()=>L$,bigint:()=>L4,boolean:()=>j4,browserEmail:()=>Rpt,cidrv4:()=>P4,cidrv6:()=>I4,cuid:()=>g4,cuid2:()=>y4,date:()=>M4,datetime:()=>N4,domain:()=>Ppt,duration:()=>_4,e164:()=>$4,email:()=>v4,emoji:()=>E4,extendedDuration:()=>xpt,guid:()=>w4,hex:()=>Ipt,hostname:()=>Cpt,html5Email:()=>wpt,httpProtocol:()=>O4,idnEmail:()=>Ept,integer:()=>F4,ipv4:()=>R4,ipv6:()=>T4,ksuid:()=>S4,lowercase:()=>q4,mac:()=>C4,md5_base64:()=>Opt,md5_base64url:()=>$pt,md5_hex:()=>Apt,nanoid:()=>k4,null:()=>U4,number:()=>F$,rfc5322Email:()=>vpt,sha1_base64:()=>Dpt,sha1_base64url:()=>Npt,sha1_hex:()=>Mpt,sha256_base64:()=>Lpt,sha256_base64url:()=>Fpt,sha256_hex:()=>zpt,sha384_base64:()=>Upt,sha384_base64url:()=>Hpt,sha384_hex:()=>jpt,sha512_base64:()=>Gpt,sha512_base64url:()=>Bpt,sha512_hex:()=>qpt,string:()=>z4,time:()=>D4,ulid:()=>b4,undefined:()=>H4,unicodeEmail:()=>uSe,uppercase:()=>G4,uuid:()=>qy,uuid4:()=>Spt,uuid6:()=>kpt,uuid7:()=>_pt,xid:()=>x4});function E4(){return new RegExp(Tpt,"u")}function pSe(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function D4(e){return new RegExp(`^${pSe(e)}$`)}function N4(e){let t=pSe({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${dSe}T(?:${n})$`)}function D0(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function N0(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var g4,y4,b4,x4,S4,k4,_4,xpt,w4,qy,Spt,kpt,_pt,v4,wpt,vpt,uSe,Ept,Rpt,Tpt,R4,T4,C4,P4,I4,A4,L$,Cpt,Ppt,O4,$4,dSe,M4,z4,L4,F4,F$,j4,U4,H4,q4,G4,Ipt,Apt,Opt,$pt,Mpt,Dpt,Npt,zpt,Lpt,Fpt,jpt,Upt,Hpt,qpt,Gpt,Bpt,j$=p(()=>{ot();g4=/^[cC][0-9a-z]{6,}$/,y4=/^[0-9a-z]+$/,b4=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,x4=/^[0-9a-vA-V]{20}$/,S4=/^[A-Za-z0-9]{27}$/,k4=/^[a-zA-Z0-9_-]{21}$/,_4=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,xpt=/^[-+]?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)?)??$/,w4=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,qy=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Spt=qy(4),kpt=qy(6),_pt=qy(7),v4=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,wpt=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,vpt=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,uSe=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Ept=uSe,Rpt=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Tpt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";R4=/^(?:(?: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])$/,T4=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,C4=e=>{let t=$c(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},P4=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,I4=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,A4=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,L$=/^[A-Za-z0-9_-]*$/,Cpt=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Ppt=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,O4=/^https?$/,$4=/^\+[1-9]\d{6,14}$/,dSe="(?:(?:\\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])))",M4=new RegExp(`^${dSe}$`);z4=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},L4=/^-?\d+n?$/,F4=/^-?\d+$/,F$=/^-?\d+(?:\.\d+)?$/,j4=/^(?:true|false)$/i,U4=/^null$/i,H4=/^undefined$/i,q4=/^[^A-Z]*$/,G4=/^[^a-z]*$/,Ipt=/^[0-9a-fA-F]*$/;Apt=/^[0-9a-fA-F]{32}$/,Opt=D0(22,"=="),$pt=N0(22),Mpt=/^[0-9a-fA-F]{40}$/,Dpt=D0(27,"="),Npt=N0(27),zpt=/^[0-9a-fA-F]{64}$/,Lpt=D0(43,"="),Fpt=N0(43),jpt=/^[0-9a-fA-F]{96}$/,Upt=D0(64,""),Hpt=N0(64),qpt=/^[0-9a-fA-F]{128}$/,Gpt=D0(86,"=="),Bpt=N0(86)});function fSe(e,t,r){e.issues.length&&t.issues.push(...ca(r,e.issues))}var un,mSe,U$,H$,B4,W4,V4,K4,Z4,J4,Q4,Y4,X4,kk,eV,tV,rV,nV,oV,iV,sV,aV,cV,q$=p(()=>{Uy();j$();ot();un=K("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),mSe={number:"number",bigint:"bigint",object:"date"},U$=K("$ZodCheckLessThan",(e,t)=>{un.init(e,t);let r=mSe[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),H$=K("$ZodCheckGreaterThan",(e,t)=>{un.init(e,t);let r=mSe[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),B4=K("$ZodCheckMultipleOf",(e,t)=>{un.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):t4(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),W4=K("$ZodCheckNumberFormat",(e,t)=>{un.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,i]=a4[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,r&&(a.pattern=F4)}),e._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),V4=K("$ZodCheckBigIntFormat",(e,t)=>{un.init(e,t);let[r,n]=c4[t.format];e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,i.minimum=r,i.maximum=n}),e._zod.check=o=>{let i=o.value;i<r&&o.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>n&&o.issues.push({origin:"bigint",input:i,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),K4=K("$ZodCheckMaxSize",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Gm(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;o.size<=t.maximum||n.issues.push({origin:I0(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Z4=K("$ZodCheckMinSize",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Gm(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;o.size>=t.minimum||n.issues.push({origin:I0(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),J4=K("$ZodCheckSizeEquals",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Gm(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.size,o.maximum=t.size,o.size=t.size}),e._zod.check=n=>{let o=n.value,i=o.size;if(i===t.size)return;let s=i>t.size;n.issues.push({origin:I0(o),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Q4=K("$ZodCheckMaxLength",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Gm(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;if(o.length<=t.maximum)return;let s=A0(o);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Y4=K("$ZodCheckMinLength",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Gm(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;if(o.length>=t.minimum)return;let s=A0(o);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),X4=K("$ZodCheckLengthEquals",(e,t)=>{var r;un.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Gm(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{let o=n.value,i=o.length;if(i===t.length)return;let s=A0(o),a=i>t.length;n.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),kk=K("$ZodCheckStringFormat",(e,t)=>{var r,n;un.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),eV=K("$ZodCheckRegex",(e,t)=>{kk.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),tV=K("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=q4),kk.init(e,t)}),rV=K("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=G4),kk.init(e,t)}),nV=K("$ZodCheckIncludes",(e,t)=>{un.init(e,t);let r=$c(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{let i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),oV=K("$ZodCheckStartsWith",(e,t)=>{un.init(e,t);let r=new RegExp(`^${$c(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),iV=K("$ZodCheckEndsWith",(e,t)=>{un.init(e,t);let r=new RegExp(`.*${$c(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});sV=K("$ZodCheckProperty",(e,t)=>{un.init(e,t),e._zod.check=r=>{let n=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(o=>fSe(o,r,t.property));fSe(n,r,t.property)}}),aV=K("$ZodCheckMimeType",(e,t)=>{un.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(n=>{n._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),cV=K("$ZodCheckOverwrite",(e,t)=>{un.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}})});var z0,lV=p(()=>{z0=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
5
5
  `).filter(s=>s),o=Math.min(...n.map(s=>s.length-s.trimStart().length)),i=n.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(let s of i)this.content.push(s)}compile(){let t=Function,r=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...r,o.join(`
6
6
  `))}}});var uV,dV=p(()=>{uV={major:4,minor:4,patch:3}});function $V(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}function ISe(e){if(!L$.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return $V(r)}function ASe(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}function gSe(e,t,r){e.issues.length&&t.issues.push(...ca(r,e.issues)),t.value[r]=e.value}function V$(e,t,r,n,o,i){let s=r in n;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...ca(r,e.issues))}if(!s&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?s&&(t.value[r]=void 0):t.value[r]=e.value}function OSe(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=s4(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function $Se(e,t,r,n,o,i){let s=[],a=o.keySet,c=o.catchall._zod,l=c.def.type,u=c.optin==="optional",d=c.optout==="optional";for(let f in t){if(f==="__proto__"||a.has(f))continue;if(l==="never"){s.push(f);continue}let m=c.run({value:t[f],issues:[]},n);m instanceof Promise?e.push(m.then(b=>V$(b,r,f,t,u,d))):V$(m,r,f,t,u,d)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}function ySe(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!Vm(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(s=>Ps(s,n,yo())))}),t)}function bSe(e,t,r,n){let o=e.filter(i=>i.issues.length===0);return o.length===1?(t.value=o[0].value,t):(o.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(s=>Ps(s,n,yo())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}function pV(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Wm(e)&&Wm(t)){let r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(let i of n){let s=pV(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],i=t[n],s=pV(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function xSe(e,t,r){let n=new Map,o;for(let a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(a);let i=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),Vm(e))return e;let s=pV(t.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}function SSe(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function kSe(e,t,r){e.issues.length&&t.issues.push(...ca(r,e.issues)),t.value[r]=e.value}function _Se(e,t,r,n,o){for(let i=0;i<r.length;i++){let s=e[i],a=i<n.length;if(s.issues.length){if(!a&&i>=o){t.value.length=i;break}t.issues.push(...ca(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=n.length&&(r[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}function wSe(e,t,r,n,o,i,s){e.issues.length&&(P0.has(typeof n)?r.issues.push(...ca(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:o,inst:i,issues:e.issues.map(a=>Ps(a,s,yo()))})),t.issues.length&&(P0.has(typeof n)?r.issues.push(...ca(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:o,inst:i,key:n,issues:t.issues.map(a=>Ps(a,s,yo()))})),r.value.set(e.value,t.value)}function vSe(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}function ESe(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}function RSe(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function TSe(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function G$(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}function B$(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let o=t.transform(e.value,e);return o instanceof Promise?o.then(i=>W$(e,i,t.out,r)):W$(e,o,t.out,r)}else{let o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(i=>W$(e,i,t.in,r)):W$(e,o,t.in,r)}}function W$(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}function CSe(e){return e.value=Object.freeze(e.value),e}function PSe(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(gk(o))}}var At,Gy,Qr,fV,mV,hV,gV,yV,bV,xV,SV,kV,_V,wV,vV,EV,RV,TV,CV,PV,IV,AV,OV,MV,DV,NV,zV,LV,K$,FV,L0,Z$,jV,UV,HV,qV,GV,BV,WV,VV,KV,ZV,MSe,JV,F0,QV,YV,XV,J$,e6,t6,r6,n6,o6,i6,s6,Q$,a6,c6,l6,u6,d6,p6,f6,m6,Y$,j0,h6,g6,y6,b6,x6,S6,k6,_6=p(()=>{q$();Uy();lV();h4();j$();ot();dV();ot();At=K("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=uV;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,a,c)=>{let l=Vm(s),u;for(let d of a){if(d._zod.def.when){if(l4(s)||!d._zod.def.when(s))continue}else if(l)continue;let f=s.issues.length,m=d._zod.check(s);if(m instanceof Promise&&c?.async===!1)throw new Hl;if(u||m instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await m,s.issues.length!==f&&(l||(l=Vm(s,f)))});else{if(s.issues.length===f)continue;l||(l=Vm(s,f))}}return u?u.then(()=>s):s},i=(s,a,c)=>{if(Vm(s))return s.aborted=!0,s;let l=o(a,n,c);if(l instanceof Promise){if(c.async===!1)throw new Hl;return l.then(u=>e._zod.parse(u,c))}return e._zod.parse(l,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let l=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(u=>i(u,s,a)):i(l,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new Hl;return c.then(l=>o(l,n,a))}return o(c,n,a)}}Jt(e,"~standard",()=>({validate:o=>{try{let i=f4(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return m4(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Gy=K("$ZodString",(e,t)=>{At.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??z4(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Qr=K("$ZodStringFormat",(e,t)=>{kk.init(e,t),Gy.init(e,t)}),fV=K("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=w4),Qr.init(e,t)}),mV=K("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=qy(n))}else t.pattern??(t.pattern=qy());Qr.init(e,t)}),hV=K("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=v4),Qr.init(e,t)}),gV=K("$ZodURL",(e,t)=>{Qr.init(e,t),e._zod.check=r=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===O4.source&&!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}let o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),yV=K("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=E4()),Qr.init(e,t)}),bV=K("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=k4),Qr.init(e,t)}),xV=K("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=g4),Qr.init(e,t)}),SV=K("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=y4),Qr.init(e,t)}),kV=K("$ZodULID",(e,t)=>{t.pattern??(t.pattern=b4),Qr.init(e,t)}),_V=K("$ZodXID",(e,t)=>{t.pattern??(t.pattern=x4),Qr.init(e,t)}),wV=K("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=S4),Qr.init(e,t)}),vV=K("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=N4(t)),Qr.init(e,t)}),EV=K("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=M4),Qr.init(e,t)}),RV=K("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=D4(t)),Qr.init(e,t)}),TV=K("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=_4),Qr.init(e,t)}),CV=K("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=R4),Qr.init(e,t),e._zod.bag.format="ipv4"}),PV=K("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=T4),Qr.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),IV=K("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=C4(t.delimiter)),Qr.init(e,t),e._zod.bag.format="mac"}),AV=K("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=P4),Qr.init(e,t)}),OV=K("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=I4),Qr.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[o,i]=n;if(!i)throw new Error;let s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});MV=K("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=A4),Qr.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{$V(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});DV=K("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=L$),Qr.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{ISe(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),NV=K("$ZodE164",(e,t)=>{t.pattern??(t.pattern=$4),Qr.init(e,t)});zV=K("$ZodJWT",(e,t)=>{Qr.init(e,t),e._zod.check=r=>{ASe(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),LV=K("$ZodCustomStringFormat",(e,t)=>{Qr.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),K$=K("$ZodNumber",(e,t)=>{At.init(e,t),e._zod.pattern=e._zod.bag.pattern??F$,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),FV=K("$ZodNumberFormat",(e,t)=>{W4.init(e,t),K$.init(e,t)}),L0=K("$ZodBoolean",(e,t)=>{At.init(e,t),e._zod.pattern=j4,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),Z$=K("$ZodBigInt",(e,t)=>{At.init(e,t),e._zod.pattern=L4,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),jV=K("$ZodBigIntFormat",(e,t)=>{V4.init(e,t),Z$.init(e,t)}),UV=K("$ZodSymbol",(e,t)=>{At.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),r}}),HV=K("$ZodUndefined",(e,t)=>{At.init(e,t),e._zod.pattern=H4,e._zod.values=new Set([void 0]),e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),r}}),qV=K("$ZodNull",(e,t)=>{At.init(e,t),e._zod.pattern=U4,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),GV=K("$ZodAny",(e,t)=>{At.init(e,t),e._zod.parse=r=>r}),BV=K("$ZodUnknown",(e,t)=>{At.init(e,t),e._zod.parse=r=>r}),WV=K("$ZodNever",(e,t)=>{At.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),VV=K("$ZodVoid",(e,t)=>{At.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),r}}),KV=K("$ZodDate",(e,t)=>{At.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),r}});ZV=K("$ZodArray",(e,t)=>{At.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let i=[];for(let s=0;s<o.length;s++){let a=o[s],c=t.element._zod.run({value:a,issues:[]},n);c instanceof Promise?i.push(c.then(l=>gSe(l,r,s))):gSe(c,r,s)}return i.length?Promise.all(i).then(()=>r):r}});MSe=K("$ZodObject",(e,t)=>{if(At.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let n=hk(()=>OSe(t));Jt(e._zod,"propValues",()=>{let a=t.shape,c={};for(let l in a){let u=a[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(let d of u.values)c[l].add(d)}}return c});let o=Hy,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=n.value);let l=a.value;if(!o(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};let u=[],d=s.shape;for(let f of s.keys){let m=d[f],b=m._zod.optin==="optional",S=m._zod.optout==="optional",_=m._zod.run({value:l[f],issues:[]},c);_ instanceof Promise?u.push(_.then(E=>V$(E,a,f,l,b,S))):V$(_,a,f,l,b,S)}return i?$Se(u,l,a,c,n.value,e):u.length?Promise.all(u).then(()=>a):a}}),JV=K("$ZodObjectJIT",(e,t)=>{MSe.init(e,t);let r=e._zod.parse,n=hk(()=>OSe(t)),o=f=>{let m=new z0(["shape","payload","ctx"]),b=n.value,S=A=>{let $=R$(A);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};m.write("const input = payload.value;");let _=Object.create(null),E=0;for(let A of b.keys)_[A]=`key_${E++}`;m.write("const newResult = {};");for(let A of b.keys){let $=_[A],M=R$(A),L=f[A],F=L?._zod?.optin==="optional",H=L?._zod?.optout==="optional";m.write(`const ${$} = ${S(A)};`),F&&H?m.write(`