@typescape-ai/mcp 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +38 -29
  2. package/dist/mcp.js +4 -0
  3. package/package.json +33 -6
package/README.md CHANGED
@@ -1,45 +1,54 @@
1
1
  # @typescape-ai/mcp
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ Typescape MCP Server - Model Context Protocol integration for AI agents like Claude.
4
4
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
5
+ ## Requirements
6
6
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
7
+ - [Bun](https://bun.sh/) >= 1.0.0
8
8
 
9
- ## Purpose
9
+ ## Installation
10
10
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@typescape-ai/mcp`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
11
+ ```bash
12
+ # Using bun
13
+ bun add -D @typescape-ai/mcp
15
14
 
16
- ## What is OIDC Trusted Publishing?
15
+ # Using npm/pnpm/yarn (still requires Bun runtime)
16
+ npm install -D @typescape-ai/mcp
17
+ ```
17
18
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
+ ## Usage with Claude Code
19
20
 
20
- ## Setup Instructions
21
+ Add to your Claude Code MCP settings (`~/.claude/mcp.json`):
21
22
 
22
- To properly configure OIDC trusted publishing for this package:
23
+ ```json
24
+ {
25
+ "mcpServers": {
26
+ "typescape": {
27
+ "command": "bunx",
28
+ "args": ["@typescape-ai/mcp"],
29
+ "env": {
30
+ "TYPESCAPE_API_TOKEN": "your-token-here",
31
+ "TYPESCAPE_BASE_URL": "https://your-typescape-instance.com"
32
+ }
33
+ }
34
+ }
35
+ }
36
+ ```
23
37
 
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
38
+ ## Available Tools
28
39
 
29
- ## DO NOT USE THIS PACKAGE
40
+ | Tool | Description |
41
+ | ----------------- | ---------------------------------- |
42
+ | `create_session` | Create a review session for a file |
43
+ | `export_feedback` | Export feedback from a session |
30
44
 
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
45
+ ## Environment Variables
36
46
 
37
- ## More Information
47
+ | Variable | Required | Description |
48
+ | --------------------- | -------- | -------------------- |
49
+ | `TYPESCAPE_API_TOKEN` | Yes | Operator API token |
50
+ | `TYPESCAPE_BASE_URL` | Yes | Typescape server URL |
38
51
 
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
52
+ ## License
42
53
 
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
54
+ MIT
package/dist/mcp.js ADDED
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ var m1=Object.create;var{getPrototypeOf:Z1,defineProperty:J1,getOwnPropertyNames:c1}=Object;var u1=Object.prototype.hasOwnProperty;var p1=($,W,X)=>{X=$!=null?m1(Z1($)):{};let G=W||!$||!$.__esModule?J1(X,"default",{value:$,enumerable:!0}):X;for(let Q of c1($))if(!u1.call(G,Q))J1(G,Q,{get:()=>$[Q],enumerable:!0});return G};var n1=($,W)=>()=>(W||$((W={exports:{}}).exports,W),W.exports);var g1=n1((R8,i6)=>{i6.exports={name:"@typescape-ai/mcp",version:"0.0.1",description:"Typescape MCP Server - Model Context Protocol integration for AI agents",type:"module",bin:{"typescape-mcp":"./dist/mcp.js"},files:["dist","README.md"],exports:{".":"./dist/mcp.js"},publishConfig:{access:"public"},scripts:{build:"bun build src/index.ts --outfile=dist/mcp.js --target=bun --bundle --minify",dev:"bun run --watch src/index.ts",test:"bun test",typecheck:"tsc --noEmit",lint:"eslint src",prepublishOnly:"bun run build"},dependencies:{},devDependencies:{"@modelcontextprotocol/sdk":"1.0.4","@types/bun":"1.1.14","@typescape/schemas":"workspace:*",zod:"4.3.0"},engines:{bun:">=1.0.0"},keywords:["typescape","mcp","model-context-protocol","ai","claude","review","bun"],repository:{type:"git",url:"https://github.com/voidserf/typescape-docs.git",directory:"apps/mcp"},license:"MIT"}});function Y1(){let $=new Map;return{register(W,X){$.set(W.name,{definition:W,handler:X})},getTools(){return Array.from($.values()).map((W)=>W.definition)},getHandler(W){return $.get(W)?.handler}}}class T extends Error{status;code;requestId;constructor($,W,X,G){super(X);this.status=$;this.code=W;this.requestId=G;this.name="ApiError"}}function w1($,W){let G=$.replace(/\/$/,"");async function Q(J,Y,w={}){let z=`${G}/v1${Y}`;if(w.query&&Object.keys(w.query).length>0){let K=new URLSearchParams(w.query);z+=`?${K.toString()}`}let V={Authorization:`Bearer ${W}`,Accept:"application/json",...w.headers};if(w.body!==void 0)V["Content-Type"]="application/json";let U;try{U=await fetch(z,{method:J,headers:V,body:w.body!==void 0?JSON.stringify(w.body):void 0})}catch(K){let f=K instanceof Error?K.message:String(K);throw new T(0,"network_error",`Network error: ${f}`,"unknown")}let S;if((U.headers.get("Content-Type")||"").includes("application/json"))try{S=await U.json()}catch{S={}}else S={};let A0=S?.request_id||U.headers.get("X-Request-Id")||"unknown";if(!U.ok){let K=S,f=K.error?.code||"api_error",r=K.error?.message||`API request failed with status ${U.status}`;throw new T(U.status,f,r,A0)}return{status:U.status,body:S,requestId:A0}}return{async get(J,Y){return Q("GET",J,Y)},async post(J,Y){return Q("POST",J,Y)},request:Q}}var F;(function($){$.assertEqual=(Q)=>Q;function W(Q){}$.assertIs=W;function X(Q){throw Error()}$.assertNever=X,$.arrayToEnum=(Q)=>{let J={};for(let Y of Q)J[Y]=Y;return J},$.getValidEnumValues=(Q)=>{let J=$.objectKeys(Q).filter((w)=>typeof Q[Q[w]]!=="number"),Y={};for(let w of J)Y[w]=Q[w];return $.objectValues(Y)},$.objectValues=(Q)=>{return $.objectKeys(Q).map(function(J){return Q[J]})},$.objectKeys=typeof Object.keys==="function"?(Q)=>Object.keys(Q):(Q)=>{let J=[];for(let Y in Q)if(Object.prototype.hasOwnProperty.call(Q,Y))J.push(Y);return J},$.find=(Q,J)=>{for(let Y of Q)if(J(Y))return Y;return},$.isInteger=typeof Number.isInteger==="function"?(Q)=>Number.isInteger(Q):(Q)=>typeof Q==="number"&&isFinite(Q)&&Math.floor(Q)===Q;function G(Q,J=" | "){return Q.map((Y)=>typeof Y==="string"?`'${Y}'`:Y).join(J)}$.joinValues=G,$.jsonStringifyReplacer=(Q,J)=>{if(typeof J==="bigint")return J.toString();return J}})(F||(F={}));var n0;(function($){$.mergeShapes=(W,X)=>{return{...W,...X}}})(n0||(n0={}));var q=F.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Z=($)=>{switch(typeof $){case"undefined":return q.undefined;case"string":return q.string;case"number":return isNaN($)?q.nan:q.number;case"boolean":return q.boolean;case"function":return q.function;case"bigint":return q.bigint;case"symbol":return q.symbol;case"object":if(Array.isArray($))return q.array;if($===null)return q.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return q.promise;if(typeof Map<"u"&&$ instanceof Map)return q.map;if(typeof Set<"u"&&$ instanceof Set)return q.set;if(typeof Date<"u"&&$ instanceof Date)return q.date;return q.object;default:return q.unknown}},B=F.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),i1=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class E extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};let W=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,W);else this.__proto__=W;this.name="ZodError",this.issues=$}format($){let W=$||function(Q){return Q.message},X={_errors:[]},G=(Q)=>{for(let J of Q.issues)if(J.code==="invalid_union")J.unionErrors.map(G);else if(J.code==="invalid_return_type")G(J.returnTypeError);else if(J.code==="invalid_arguments")G(J.argumentsError);else if(J.path.length===0)X._errors.push(W(J));else{let Y=X,w=0;while(w<J.path.length){let z=J.path[w];if(w!==J.path.length-1)Y[z]=Y[z]||{_errors:[]};else Y[z]=Y[z]||{_errors:[]},Y[z]._errors.push(W(J));Y=Y[z],w++}}};return G(this),X}static assert($){if(!($ instanceof E))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,F.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(W)=>W.message){let W={},X=[];for(let G of this.issues)if(G.path.length>0)W[G.path[0]]=W[G.path[0]]||[],W[G.path[0]].push($(G));else X.push($(G));return{formErrors:X,fieldErrors:W}}get formErrors(){return this.flatten()}}E.create=($)=>{return new E($)};var G0=($,W)=>{let X;switch($.code){case B.invalid_type:if($.received===q.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case B.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,F.jsonStringifyReplacer)}`;break;case B.unrecognized_keys:X=`Unrecognized key(s) in object: ${F.joinValues($.keys,", ")}`;break;case B.invalid_union:X="Invalid input";break;case B.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${F.joinValues($.options)}`;break;case B.invalid_enum_value:X=`Invalid enum value. Expected ${F.joinValues($.options)}, received '${$.received}'`;break;case B.invalid_arguments:X="Invalid function arguments";break;case B.invalid_return_type:X="Invalid function return type";break;case B.invalid_date:X="Invalid date";break;case B.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else F.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case B.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case B.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case B.custom:X="Invalid input";break;case B.invalid_intersection_types:X="Intersection results could not be merged";break;case B.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case B.not_finite:X="Number must be finite";break;default:X=W.defaultError,F.assertNever($)}return{message:X}},M1=G0;function d1($){M1=$}function f0(){return M1}var C0=($)=>{let{data:W,path:X,errorMaps:G,issueData:Q}=$,J=[...X,...Q.path||[]],Y={...Q,path:J};if(Q.message!==void 0)return{...Q,path:J,message:Q.message};let w="",z=G.filter((V)=>!!V).slice().reverse();for(let V of z)w=V(Y,{data:W,defaultError:w}).message;return{...Q,path:J,message:w}},r1=[];function M($,W){let X=f0(),G=C0({issueData:W,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===G0?void 0:G0].filter((Q)=>!!Q)});$.common.issues.push(G)}class N{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,W){let X=[];for(let G of W){if(G.status==="aborted")return L;if(G.status==="dirty")$.dirty();X.push(G.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,W){let X=[];for(let G of W){let Q=await G.key,J=await G.value;X.push({key:Q,value:J})}return N.mergeObjectSync($,X)}static mergeObjectSync($,W){let X={};for(let G of W){let{key:Q,value:J}=G;if(Q.status==="aborted")return L;if(J.status==="aborted")return L;if(Q.status==="dirty")$.dirty();if(J.status==="dirty")$.dirty();if(Q.value!=="__proto__"&&(typeof J.value<"u"||G.alwaysSet))X[Q.value]=J.value}return{status:$.value,value:X}}}var L=Object.freeze({status:"aborted"}),X0=($)=>({status:"dirty",value:$}),_=($)=>({status:"valid",value:$}),i0=($)=>$.status==="aborted",d0=($)=>$.status==="dirty",o=($)=>$.status==="valid",F0=($)=>typeof Promise<"u"&&$ instanceof Promise;function k0($,W,X,G){if(X==="a"&&!G)throw TypeError("Private accessor was defined without a getter");if(typeof W==="function"?$!==W||!G:!W.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?G:X==="a"?G.call($):G?G.value:W.get($)}function q1($,W,X,G,Q){if(G==="m")throw TypeError("Private method is not writable");if(G==="a"&&!Q)throw TypeError("Private accessor was defined without a setter");if(typeof W==="function"?$!==W||!Q:!W.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return G==="a"?Q.call($,X):Q?Q.value=X:W.set($,X),X}var O;(function($){$.errToObj=(W)=>typeof W==="string"?{message:W}:W||{},$.toString=(W)=>typeof W==="string"?W:W===null||W===void 0?void 0:W.message})(O||(O={}));var D0,U0;class P{constructor($,W,X,G){this._cachedPath=[],this.parent=$,this.data=W,this._path=X,this._key=G}get path(){if(!this._cachedPath.length)if(this._key instanceof Array)this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var z1=($,W)=>{if(o(W))return{success:!0,data:W.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let X=new E($.common.issues);return this._error=X,this._error}}}};function A($){if(!$)return{};let{errorMap:W,invalid_type_error:X,required_error:G,description:Q}=$;if(W&&(X||G))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(W)return{errorMap:W,description:Q};return{errorMap:(Y,w)=>{var z,V;let{message:U}=$;if(Y.code==="invalid_enum_value")return{message:U!==null&&U!==void 0?U:w.defaultError};if(typeof w.data>"u")return{message:(z=U!==null&&U!==void 0?U:G)!==null&&z!==void 0?z:w.defaultError};if(Y.code!=="invalid_type")return{message:w.defaultError};return{message:(V=U!==null&&U!==void 0?U:X)!==null&&V!==void 0?V:w.defaultError}},description:Q}}class D{get description(){return this._def.description}_getType($){return Z($.data)}_getOrReturnCtx($,W){return W||{common:$.parent.common,data:$.data,parsedType:Z($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new N,ctx:{common:$.parent.common,data:$.data,parsedType:Z($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let W=this._parse($);if(F0(W))throw Error("Synchronous parse encountered promise.");return W}_parseAsync($){let W=this._parse($);return Promise.resolve(W)}parse($,W){let X=this.safeParse($,W);if(X.success)return X.data;throw X.error}safeParse($,W){var X;let G={common:{issues:[],async:(X=W===null||W===void 0?void 0:W.async)!==null&&X!==void 0?X:!1,contextualErrorMap:W===null||W===void 0?void 0:W.errorMap},path:(W===null||W===void 0?void 0:W.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:Z($)},Q=this._parseSync({data:$,path:G.path,parent:G});return z1(G,Q)}"~validate"($){var W,X;let G={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:Z($)};if(!this["~standard"].async)try{let Q=this._parseSync({data:$,path:[],parent:G});return o(Q)?{value:Q.value}:{issues:G.common.issues}}catch(Q){if((X=(W=Q===null||Q===void 0?void 0:Q.message)===null||W===void 0?void 0:W.toLowerCase())===null||X===void 0?void 0:X.includes("encountered"))this["~standard"].async=!0;G.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:G}).then((Q)=>o(Q)?{value:Q.value}:{issues:G.common.issues})}async parseAsync($,W){let X=await this.safeParseAsync($,W);if(X.success)return X.data;throw X.error}async safeParseAsync($,W){let X={common:{issues:[],contextualErrorMap:W===null||W===void 0?void 0:W.errorMap,async:!0},path:(W===null||W===void 0?void 0:W.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:Z($)},G=this._parse({data:$,path:X.path,parent:X}),Q=await(F0(G)?G:Promise.resolve(G));return z1(X,Q)}refine($,W){let X=(G)=>{if(typeof W==="string"||typeof W>"u")return{message:W};else if(typeof W==="function")return W(G);else return W};return this._refinement((G,Q)=>{let J=$(G),Y=()=>Q.addIssue({code:B.custom,...X(G)});if(typeof Promise<"u"&&J instanceof Promise)return J.then((w)=>{if(!w)return Y(),!1;else return!0});if(!J)return Y(),!1;else return!0})}refinement($,W){return this._refinement((X,G)=>{if(!$(X))return G.addIssue(typeof W==="function"?W(X,G):W),!1;else return!0})}_refinement($){return new v({schema:this,typeName:j.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(W)=>this["~validate"](W)}}optional(){return I.create(this,this._def)}nullable(){return c.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return k.create(this)}promise(){return e.create(this,this._def)}or($){return w0.create([this,$],this._def)}and($){return z0.create(this,$,this._def)}transform($){return new v({...A(this._def),schema:this,typeName:j.ZodEffects,effect:{type:"transform",transform:$}})}default($){let W=typeof $==="function"?$:()=>$;return new O0({...A(this._def),innerType:this,defaultValue:W,typeName:j.ZodDefault})}brand(){return new P0({typeName:j.ZodBranded,type:this,...A(this._def)})}catch($){let W=typeof $==="function"?$:()=>$;return new V0({...A(this._def),innerType:this,catchValue:W,typeName:j.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return E0.create(this,$)}readonly(){return j0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var o1=/^c[^\s-]{8,}$/i,a1=/^[0-9a-z]+$/,t1=/^[0-9A-HJKMNP-TV-Z]{26}$/i,s1=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,e1=/^[a-z0-9_-]{21}$/i,$4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,W4=/^[-+]?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)?)??$/,X4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Q4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",p0,G4=/^(?:(?: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])$/,H4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,J4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Y4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,w4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,z4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,O1="((\\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])))",B4=new RegExp(`^${O1}$`);function V1($){let W="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";if($.precision)W=`${W}\\.\\d{${$.precision}}`;else if($.precision==null)W=`${W}(\\.\\d+)?`;return W}function M4($){return new RegExp(`^${V1($)}$`)}function j1($){let W=`${O1}T${V1($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return W=`${W}(${X.join("|")})`,new RegExp(`^${W}$`)}function q4($,W){if((W==="v4"||!W)&&G4.test($))return!0;if((W==="v6"||!W)&&J4.test($))return!0;return!1}function O4($,W){if(!$4.test($))return!1;try{let[X]=$.split("."),G=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),Q=JSON.parse(atob(G));if(typeof Q!=="object"||Q===null)return!1;if(!Q.typ||!Q.alg)return!1;if(W&&Q.alg!==W)return!1;return!0}catch(X){return!1}}function V4($,W){if((W==="v4"||!W)&&H4.test($))return!0;if((W==="v6"||!W)&&Y4.test($))return!0;return!1}class C extends D{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==q.string){let Q=this._getOrReturnCtx($);return M(Q,{code:B.invalid_type,expected:q.string,received:Q.parsedType}),L}let X=new N,G=void 0;for(let Q of this._def.checks)if(Q.kind==="min"){if($.data.length<Q.value)G=this._getOrReturnCtx($,G),M(G,{code:B.too_small,minimum:Q.value,type:"string",inclusive:!0,exact:!1,message:Q.message}),X.dirty()}else if(Q.kind==="max"){if($.data.length>Q.value)G=this._getOrReturnCtx($,G),M(G,{code:B.too_big,maximum:Q.value,type:"string",inclusive:!0,exact:!1,message:Q.message}),X.dirty()}else if(Q.kind==="length"){let J=$.data.length>Q.value,Y=$.data.length<Q.value;if(J||Y){if(G=this._getOrReturnCtx($,G),J)M(G,{code:B.too_big,maximum:Q.value,type:"string",inclusive:!0,exact:!0,message:Q.message});else if(Y)M(G,{code:B.too_small,minimum:Q.value,type:"string",inclusive:!0,exact:!0,message:Q.message});X.dirty()}}else if(Q.kind==="email"){if(!X4.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"email",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="emoji"){if(!p0)p0=new RegExp(Q4,"u");if(!p0.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"emoji",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="uuid"){if(!s1.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"uuid",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="nanoid"){if(!e1.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"nanoid",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="cuid"){if(!o1.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"cuid",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="cuid2"){if(!a1.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"cuid2",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="ulid"){if(!t1.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"ulid",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="url")try{new URL($.data)}catch(J){G=this._getOrReturnCtx($,G),M(G,{validation:"url",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="regex"){if(Q.regex.lastIndex=0,!Q.regex.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"regex",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="trim")$.data=$.data.trim();else if(Q.kind==="includes"){if(!$.data.includes(Q.value,Q.position))G=this._getOrReturnCtx($,G),M(G,{code:B.invalid_string,validation:{includes:Q.value,position:Q.position},message:Q.message}),X.dirty()}else if(Q.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(Q.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(Q.kind==="startsWith"){if(!$.data.startsWith(Q.value))G=this._getOrReturnCtx($,G),M(G,{code:B.invalid_string,validation:{startsWith:Q.value},message:Q.message}),X.dirty()}else if(Q.kind==="endsWith"){if(!$.data.endsWith(Q.value))G=this._getOrReturnCtx($,G),M(G,{code:B.invalid_string,validation:{endsWith:Q.value},message:Q.message}),X.dirty()}else if(Q.kind==="datetime"){if(!j1(Q).test($.data))G=this._getOrReturnCtx($,G),M(G,{code:B.invalid_string,validation:"datetime",message:Q.message}),X.dirty()}else if(Q.kind==="date"){if(!B4.test($.data))G=this._getOrReturnCtx($,G),M(G,{code:B.invalid_string,validation:"date",message:Q.message}),X.dirty()}else if(Q.kind==="time"){if(!M4(Q).test($.data))G=this._getOrReturnCtx($,G),M(G,{code:B.invalid_string,validation:"time",message:Q.message}),X.dirty()}else if(Q.kind==="duration"){if(!W4.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"duration",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="ip"){if(!q4($.data,Q.version))G=this._getOrReturnCtx($,G),M(G,{validation:"ip",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="jwt"){if(!O4($.data,Q.alg))G=this._getOrReturnCtx($,G),M(G,{validation:"jwt",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="cidr"){if(!V4($.data,Q.version))G=this._getOrReturnCtx($,G),M(G,{validation:"cidr",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="base64"){if(!w4.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"base64",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="base64url"){if(!z4.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"base64url",code:B.invalid_string,message:Q.message}),X.dirty()}else F.assertNever(Q);return{status:X.value,value:$.data}}_regex($,W,X){return this.refinement((G)=>$.test(G),{validation:W,code:B.invalid_string,...O.errToObj(X)})}_addCheck($){return new C({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...O.errToObj($)})}url($){return this._addCheck({kind:"url",...O.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...O.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...O.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...O.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...O.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...O.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...O.errToObj($)})}base64($){return this._addCheck({kind:"base64",...O.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...O.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...O.errToObj($)})}ip($){return this._addCheck({kind:"ip",...O.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...O.errToObj($)})}datetime($){var W,X;if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof($===null||$===void 0?void 0:$.precision)>"u"?null:$===null||$===void 0?void 0:$.precision,offset:(W=$===null||$===void 0?void 0:$.offset)!==null&&W!==void 0?W:!1,local:(X=$===null||$===void 0?void 0:$.local)!==null&&X!==void 0?X:!1,...O.errToObj($===null||$===void 0?void 0:$.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof($===null||$===void 0?void 0:$.precision)>"u"?null:$===null||$===void 0?void 0:$.precision,...O.errToObj($===null||$===void 0?void 0:$.message)})}duration($){return this._addCheck({kind:"duration",...O.errToObj($)})}regex($,W){return this._addCheck({kind:"regex",regex:$,...O.errToObj(W)})}includes($,W){return this._addCheck({kind:"includes",value:$,position:W===null||W===void 0?void 0:W.position,...O.errToObj(W===null||W===void 0?void 0:W.message)})}startsWith($,W){return this._addCheck({kind:"startsWith",value:$,...O.errToObj(W)})}endsWith($,W){return this._addCheck({kind:"endsWith",value:$,...O.errToObj(W)})}min($,W){return this._addCheck({kind:"min",value:$,...O.errToObj(W)})}max($,W){return this._addCheck({kind:"max",value:$,...O.errToObj(W)})}length($,W){return this._addCheck({kind:"length",value:$,...O.errToObj(W)})}nonempty($){return this.min(1,O.errToObj($))}trim(){return new C({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new C({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new C({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $}get maxLength(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $}}C.create=($)=>{var W;return new C({checks:[],typeName:j.ZodString,coerce:(W=$===null||$===void 0?void 0:$.coerce)!==null&&W!==void 0?W:!1,...A($)})};function j4($,W){let X=($.toString().split(".")[1]||"").length,G=(W.toString().split(".")[1]||"").length,Q=X>G?X:G,J=parseInt($.toFixed(Q).replace(".","")),Y=parseInt(W.toFixed(Q).replace(".",""));return J%Y/Math.pow(10,Q)}class p extends D{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==q.number){let Q=this._getOrReturnCtx($);return M(Q,{code:B.invalid_type,expected:q.number,received:Q.parsedType}),L}let X=void 0,G=new N;for(let Q of this._def.checks)if(Q.kind==="int"){if(!F.isInteger($.data))X=this._getOrReturnCtx($,X),M(X,{code:B.invalid_type,expected:"integer",received:"float",message:Q.message}),G.dirty()}else if(Q.kind==="min"){if(Q.inclusive?$.data<Q.value:$.data<=Q.value)X=this._getOrReturnCtx($,X),M(X,{code:B.too_small,minimum:Q.value,type:"number",inclusive:Q.inclusive,exact:!1,message:Q.message}),G.dirty()}else if(Q.kind==="max"){if(Q.inclusive?$.data>Q.value:$.data>=Q.value)X=this._getOrReturnCtx($,X),M(X,{code:B.too_big,maximum:Q.value,type:"number",inclusive:Q.inclusive,exact:!1,message:Q.message}),G.dirty()}else if(Q.kind==="multipleOf"){if(j4($.data,Q.value)!==0)X=this._getOrReturnCtx($,X),M(X,{code:B.not_multiple_of,multipleOf:Q.value,message:Q.message}),G.dirty()}else if(Q.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),M(X,{code:B.not_finite,message:Q.message}),G.dirty()}else F.assertNever(Q);return{status:G.value,value:$.data}}gte($,W){return this.setLimit("min",$,!0,O.toString(W))}gt($,W){return this.setLimit("min",$,!1,O.toString(W))}lte($,W){return this.setLimit("max",$,!0,O.toString(W))}lt($,W){return this.setLimit("max",$,!1,O.toString(W))}setLimit($,W,X,G){return new p({...this._def,checks:[...this._def.checks,{kind:$,value:W,inclusive:X,message:O.toString(G)}]})}_addCheck($){return new p({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:O.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:O.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:O.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:O.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:O.toString($)})}multipleOf($,W){return this._addCheck({kind:"multipleOf",value:$,message:O.toString(W)})}finite($){return this._addCheck({kind:"finite",message:O.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:O.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:O.toString($)})}get minValue(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $}get maxValue(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&F.isInteger($.value))}get isFinite(){let $=null,W=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(W===null||X.value>W)W=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(W)&&Number.isFinite($)}}p.create=($)=>{return new p({checks:[],typeName:j.ZodNumber,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...A($)})};class n extends D{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch(Q){return this._getInvalidInput($)}if(this._getType($)!==q.bigint)return this._getInvalidInput($);let X=void 0,G=new N;for(let Q of this._def.checks)if(Q.kind==="min"){if(Q.inclusive?$.data<Q.value:$.data<=Q.value)X=this._getOrReturnCtx($,X),M(X,{code:B.too_small,type:"bigint",minimum:Q.value,inclusive:Q.inclusive,message:Q.message}),G.dirty()}else if(Q.kind==="max"){if(Q.inclusive?$.data>Q.value:$.data>=Q.value)X=this._getOrReturnCtx($,X),M(X,{code:B.too_big,type:"bigint",maximum:Q.value,inclusive:Q.inclusive,message:Q.message}),G.dirty()}else if(Q.kind==="multipleOf"){if($.data%Q.value!==BigInt(0))X=this._getOrReturnCtx($,X),M(X,{code:B.not_multiple_of,multipleOf:Q.value,message:Q.message}),G.dirty()}else F.assertNever(Q);return{status:G.value,value:$.data}}_getInvalidInput($){let W=this._getOrReturnCtx($);return M(W,{code:B.invalid_type,expected:q.bigint,received:W.parsedType}),L}gte($,W){return this.setLimit("min",$,!0,O.toString(W))}gt($,W){return this.setLimit("min",$,!1,O.toString(W))}lte($,W){return this.setLimit("max",$,!0,O.toString(W))}lt($,W){return this.setLimit("max",$,!1,O.toString(W))}setLimit($,W,X,G){return new n({...this._def,checks:[...this._def.checks,{kind:$,value:W,inclusive:X,message:O.toString(G)}]})}_addCheck($){return new n({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:O.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:O.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:O.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:O.toString($)})}multipleOf($,W){return this._addCheck({kind:"multipleOf",value:$,message:O.toString(W)})}get minValue(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $}get maxValue(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $}}n.create=($)=>{var W;return new n({checks:[],typeName:j.ZodBigInt,coerce:(W=$===null||$===void 0?void 0:$.coerce)!==null&&W!==void 0?W:!1,...A($)})};class H0 extends D{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==q.boolean){let X=this._getOrReturnCtx($);return M(X,{code:B.invalid_type,expected:q.boolean,received:X.parsedType}),L}return _($.data)}}H0.create=($)=>{return new H0({typeName:j.ZodBoolean,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...A($)})};class a extends D{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==q.date){let Q=this._getOrReturnCtx($);return M(Q,{code:B.invalid_type,expected:q.date,received:Q.parsedType}),L}if(isNaN($.data.getTime())){let Q=this._getOrReturnCtx($);return M(Q,{code:B.invalid_date}),L}let X=new N,G=void 0;for(let Q of this._def.checks)if(Q.kind==="min"){if($.data.getTime()<Q.value)G=this._getOrReturnCtx($,G),M(G,{code:B.too_small,message:Q.message,inclusive:!0,exact:!1,minimum:Q.value,type:"date"}),X.dirty()}else if(Q.kind==="max"){if($.data.getTime()>Q.value)G=this._getOrReturnCtx($,G),M(G,{code:B.too_big,message:Q.message,inclusive:!0,exact:!1,maximum:Q.value,type:"date"}),X.dirty()}else F.assertNever(Q);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new a({...this._def,checks:[...this._def.checks,$]})}min($,W){return this._addCheck({kind:"min",value:$.getTime(),message:O.toString(W)})}max($,W){return this._addCheck({kind:"max",value:$.getTime(),message:O.toString(W)})}get minDate(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $!=null?new Date($):null}}a.create=($)=>{return new a({checks:[],coerce:($===null||$===void 0?void 0:$.coerce)||!1,typeName:j.ZodDate,...A($)})};class R0 extends D{_parse($){if(this._getType($)!==q.symbol){let X=this._getOrReturnCtx($);return M(X,{code:B.invalid_type,expected:q.symbol,received:X.parsedType}),L}return _($.data)}}R0.create=($)=>{return new R0({typeName:j.ZodSymbol,...A($)})};class J0 extends D{_parse($){if(this._getType($)!==q.undefined){let X=this._getOrReturnCtx($);return M(X,{code:B.invalid_type,expected:q.undefined,received:X.parsedType}),L}return _($.data)}}J0.create=($)=>{return new J0({typeName:j.ZodUndefined,...A($)})};class Y0 extends D{_parse($){if(this._getType($)!==q.null){let X=this._getOrReturnCtx($);return M(X,{code:B.invalid_type,expected:q.null,received:X.parsedType}),L}return _($.data)}}Y0.create=($)=>{return new Y0({typeName:j.ZodNull,...A($)})};class t extends D{constructor(){super(...arguments);this._any=!0}_parse($){return _($.data)}}t.create=($)=>{return new t({typeName:j.ZodAny,...A($)})};class u extends D{constructor(){super(...arguments);this._unknown=!0}_parse($){return _($.data)}}u.create=($)=>{return new u({typeName:j.ZodUnknown,...A($)})};class x extends D{_parse($){let W=this._getOrReturnCtx($);return M(W,{code:B.invalid_type,expected:q.never,received:W.parsedType}),L}}x.create=($)=>{return new x({typeName:j.ZodNever,...A($)})};class K0 extends D{_parse($){if(this._getType($)!==q.undefined){let X=this._getOrReturnCtx($);return M(X,{code:B.invalid_type,expected:q.void,received:X.parsedType}),L}return _($.data)}}K0.create=($)=>{return new K0({typeName:j.ZodVoid,...A($)})};class k extends D{_parse($){let{ctx:W,status:X}=this._processInputParams($),G=this._def;if(W.parsedType!==q.array)return M(W,{code:B.invalid_type,expected:q.array,received:W.parsedType}),L;if(G.exactLength!==null){let J=W.data.length>G.exactLength.value,Y=W.data.length<G.exactLength.value;if(J||Y)M(W,{code:J?B.too_big:B.too_small,minimum:Y?G.exactLength.value:void 0,maximum:J?G.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:G.exactLength.message}),X.dirty()}if(G.minLength!==null){if(W.data.length<G.minLength.value)M(W,{code:B.too_small,minimum:G.minLength.value,type:"array",inclusive:!0,exact:!1,message:G.minLength.message}),X.dirty()}if(G.maxLength!==null){if(W.data.length>G.maxLength.value)M(W,{code:B.too_big,maximum:G.maxLength.value,type:"array",inclusive:!0,exact:!1,message:G.maxLength.message}),X.dirty()}if(W.common.async)return Promise.all([...W.data].map((J,Y)=>{return G.type._parseAsync(new P(W,J,W.path,Y))})).then((J)=>{return N.mergeArray(X,J)});let Q=[...W.data].map((J,Y)=>{return G.type._parseSync(new P(W,J,W.path,Y))});return N.mergeArray(X,Q)}get element(){return this._def.type}min($,W){return new k({...this._def,minLength:{value:$,message:O.toString(W)}})}max($,W){return new k({...this._def,maxLength:{value:$,message:O.toString(W)}})}length($,W){return new k({...this._def,exactLength:{value:$,message:O.toString(W)}})}nonempty($){return this.min(1,$)}}k.create=($,W)=>{return new k({type:$,minLength:null,maxLength:null,exactLength:null,typeName:j.ZodArray,...A(W)})};function W0($){if($ instanceof R){let W={};for(let X in $.shape){let G=$.shape[X];W[X]=I.create(W0(G))}return new R({...$._def,shape:()=>W})}else if($ instanceof k)return new k({...$._def,type:W0($.element)});else if($ instanceof I)return I.create(W0($.unwrap()));else if($ instanceof c)return c.create(W0($.unwrap()));else if($ instanceof y)return y.create($.items.map((W)=>W0(W)));else return $}class R extends D{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),W=F.objectKeys($);return this._cached={shape:$,keys:W}}_parse($){if(this._getType($)!==q.object){let z=this._getOrReturnCtx($);return M(z,{code:B.invalid_type,expected:q.object,received:z.parsedType}),L}let{status:X,ctx:G}=this._processInputParams($),{shape:Q,keys:J}=this._getCached(),Y=[];if(!(this._def.catchall instanceof x&&this._def.unknownKeys==="strip")){for(let z in G.data)if(!J.includes(z))Y.push(z)}let w=[];for(let z of J){let V=Q[z],U=G.data[z];w.push({key:{status:"valid",value:z},value:V._parse(new P(G,U,G.path,z)),alwaysSet:z in G.data})}if(this._def.catchall instanceof x){let z=this._def.unknownKeys;if(z==="passthrough")for(let V of Y)w.push({key:{status:"valid",value:V},value:{status:"valid",value:G.data[V]}});else if(z==="strict"){if(Y.length>0)M(G,{code:B.unrecognized_keys,keys:Y}),X.dirty()}else if(z==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let z=this._def.catchall;for(let V of Y){let U=G.data[V];w.push({key:{status:"valid",value:V},value:z._parse(new P(G,U,G.path,V)),alwaysSet:V in G.data})}}if(G.common.async)return Promise.resolve().then(async()=>{let z=[];for(let V of w){let U=await V.key,S=await V.value;z.push({key:U,value:S,alwaysSet:V.alwaysSet})}return z}).then((z)=>{return N.mergeObjectSync(X,z)});else return N.mergeObjectSync(X,w)}get shape(){return this._def.shape()}strict($){return O.errToObj,new R({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(W,X)=>{var G,Q,J,Y;let w=(J=(Q=(G=this._def).errorMap)===null||Q===void 0?void 0:Q.call(G,W,X).message)!==null&&J!==void 0?J:X.defaultError;if(W.code==="unrecognized_keys")return{message:(Y=O.errToObj($).message)!==null&&Y!==void 0?Y:w};return{message:w}}}:{}})}strip(){return new R({...this._def,unknownKeys:"strip"})}passthrough(){return new R({...this._def,unknownKeys:"passthrough"})}extend($){return new R({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new R({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:j.ZodObject})}setKey($,W){return this.augment({[$]:W})}catchall($){return new R({...this._def,catchall:$})}pick($){let W={};return F.objectKeys($).forEach((X)=>{if($[X]&&this.shape[X])W[X]=this.shape[X]}),new R({...this._def,shape:()=>W})}omit($){let W={};return F.objectKeys(this.shape).forEach((X)=>{if(!$[X])W[X]=this.shape[X]}),new R({...this._def,shape:()=>W})}deepPartial(){return W0(this)}partial($){let W={};return F.objectKeys(this.shape).forEach((X)=>{let G=this.shape[X];if($&&!$[X])W[X]=G;else W[X]=G.optional()}),new R({...this._def,shape:()=>W})}required($){let W={};return F.objectKeys(this.shape).forEach((X)=>{if($&&!$[X])W[X]=this.shape[X];else{let Q=this.shape[X];while(Q instanceof I)Q=Q._def.innerType;W[X]=Q}}),new R({...this._def,shape:()=>W})}keyof(){return L1(F.objectKeys(this.shape))}}R.create=($,W)=>{return new R({shape:()=>$,unknownKeys:"strip",catchall:x.create(),typeName:j.ZodObject,...A(W)})};R.strictCreate=($,W)=>{return new R({shape:()=>$,unknownKeys:"strict",catchall:x.create(),typeName:j.ZodObject,...A(W)})};R.lazycreate=($,W)=>{return new R({shape:$,unknownKeys:"strip",catchall:x.create(),typeName:j.ZodObject,...A(W)})};class w0 extends D{_parse($){let{ctx:W}=this._processInputParams($),X=this._def.options;function G(Q){for(let Y of Q)if(Y.result.status==="valid")return Y.result;for(let Y of Q)if(Y.result.status==="dirty")return W.common.issues.push(...Y.ctx.common.issues),Y.result;let J=Q.map((Y)=>new E(Y.ctx.common.issues));return M(W,{code:B.invalid_union,unionErrors:J}),L}if(W.common.async)return Promise.all(X.map(async(Q)=>{let J={...W,common:{...W.common,issues:[]},parent:null};return{result:await Q._parseAsync({data:W.data,path:W.path,parent:J}),ctx:J}})).then(G);else{let Q=void 0,J=[];for(let w of X){let z={...W,common:{...W.common,issues:[]},parent:null},V=w._parseSync({data:W.data,path:W.path,parent:z});if(V.status==="valid")return V;else if(V.status==="dirty"&&!Q)Q={result:V,ctx:z};if(z.common.issues.length)J.push(z.common.issues)}if(Q)return W.common.issues.push(...Q.ctx.common.issues),Q.result;let Y=J.map((w)=>new E(w));return M(W,{code:B.invalid_union,unionErrors:Y}),L}}get options(){return this._def.options}}w0.create=($,W)=>{return new w0({options:$,typeName:j.ZodUnion,...A(W)})};var m=($)=>{if($ instanceof B0)return m($.schema);else if($ instanceof v)return m($.innerType());else if($ instanceof M0)return[$.value];else if($ instanceof i)return $.options;else if($ instanceof q0)return F.objectValues($.enum);else if($ instanceof O0)return m($._def.innerType);else if($ instanceof J0)return[void 0];else if($ instanceof Y0)return[null];else if($ instanceof I)return[void 0,...m($.unwrap())];else if($ instanceof c)return[null,...m($.unwrap())];else if($ instanceof P0)return m($.unwrap());else if($ instanceof j0)return m($.unwrap());else if($ instanceof V0)return m($._def.innerType);else return[]};class I0 extends D{_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==q.object)return M(W,{code:B.invalid_type,expected:q.object,received:W.parsedType}),L;let X=this.discriminator,G=W.data[X],Q=this.optionsMap.get(G);if(!Q)return M(W,{code:B.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),L;if(W.common.async)return Q._parseAsync({data:W.data,path:W.path,parent:W});else return Q._parseSync({data:W.data,path:W.path,parent:W})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,W,X){let G=new Map;for(let Q of W){let J=m(Q.shape[$]);if(!J.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let Y of J){if(G.has(Y))throw Error(`Discriminator property ${String($)} has duplicate value ${String(Y)}`);G.set(Y,Q)}}return new I0({typeName:j.ZodDiscriminatedUnion,discriminator:$,options:W,optionsMap:G,...A(X)})}}function r0($,W){let X=Z($),G=Z(W);if($===W)return{valid:!0,data:$};else if(X===q.object&&G===q.object){let Q=F.objectKeys(W),J=F.objectKeys($).filter((w)=>Q.indexOf(w)!==-1),Y={...$,...W};for(let w of J){let z=r0($[w],W[w]);if(!z.valid)return{valid:!1};Y[w]=z.data}return{valid:!0,data:Y}}else if(X===q.array&&G===q.array){if($.length!==W.length)return{valid:!1};let Q=[];for(let J=0;J<$.length;J++){let Y=$[J],w=W[J],z=r0(Y,w);if(!z.valid)return{valid:!1};Q.push(z.data)}return{valid:!0,data:Q}}else if(X===q.date&&G===q.date&&+$===+W)return{valid:!0,data:$};else return{valid:!1}}class z0 extends D{_parse($){let{status:W,ctx:X}=this._processInputParams($),G=(Q,J)=>{if(i0(Q)||i0(J))return L;let Y=r0(Q.value,J.value);if(!Y.valid)return M(X,{code:B.invalid_intersection_types}),L;if(d0(Q)||d0(J))W.dirty();return{status:W.value,value:Y.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([Q,J])=>G(Q,J));else return G(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}z0.create=($,W,X)=>{return new z0({left:$,right:W,typeName:j.ZodIntersection,...A(X)})};class y extends D{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==q.array)return M(X,{code:B.invalid_type,expected:q.array,received:X.parsedType}),L;if(X.data.length<this._def.items.length)return M(X,{code:B.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),L;if(!this._def.rest&&X.data.length>this._def.items.length)M(X,{code:B.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),W.dirty();let Q=[...X.data].map((J,Y)=>{let w=this._def.items[Y]||this._def.rest;if(!w)return null;return w._parse(new P(X,J,X.path,Y))}).filter((J)=>!!J);if(X.common.async)return Promise.all(Q).then((J)=>{return N.mergeArray(W,J)});else return N.mergeArray(W,Q)}get items(){return this._def.items}rest($){return new y({...this._def,rest:$})}}y.create=($,W)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new y({items:$,typeName:j.ZodTuple,rest:null,...A(W)})};class S0 extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==q.object)return M(X,{code:B.invalid_type,expected:q.object,received:X.parsedType}),L;let G=[],Q=this._def.keyType,J=this._def.valueType;for(let Y in X.data)G.push({key:Q._parse(new P(X,Y,X.path,Y)),value:J._parse(new P(X,X.data[Y],X.path,Y)),alwaysSet:Y in X.data});if(X.common.async)return N.mergeObjectAsync(W,G);else return N.mergeObjectSync(W,G)}get element(){return this._def.valueType}static create($,W,X){if(W instanceof D)return new S0({keyType:$,valueType:W,typeName:j.ZodRecord,...A(X)});return new S0({keyType:C.create(),valueType:$,typeName:j.ZodRecord,...A(W)})}}class N0 extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==q.map)return M(X,{code:B.invalid_type,expected:q.map,received:X.parsedType}),L;let G=this._def.keyType,Q=this._def.valueType,J=[...X.data.entries()].map(([Y,w],z)=>{return{key:G._parse(new P(X,Y,X.path,[z,"key"])),value:Q._parse(new P(X,w,X.path,[z,"value"]))}});if(X.common.async){let Y=new Map;return Promise.resolve().then(async()=>{for(let w of J){let z=await w.key,V=await w.value;if(z.status==="aborted"||V.status==="aborted")return L;if(z.status==="dirty"||V.status==="dirty")W.dirty();Y.set(z.value,V.value)}return{status:W.value,value:Y}})}else{let Y=new Map;for(let w of J){let{key:z,value:V}=w;if(z.status==="aborted"||V.status==="aborted")return L;if(z.status==="dirty"||V.status==="dirty")W.dirty();Y.set(z.value,V.value)}return{status:W.value,value:Y}}}}N0.create=($,W,X)=>{return new N0({valueType:W,keyType:$,typeName:j.ZodMap,...A(X)})};class s extends D{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==q.set)return M(X,{code:B.invalid_type,expected:q.set,received:X.parsedType}),L;let G=this._def;if(G.minSize!==null){if(X.data.size<G.minSize.value)M(X,{code:B.too_small,minimum:G.minSize.value,type:"set",inclusive:!0,exact:!1,message:G.minSize.message}),W.dirty()}if(G.maxSize!==null){if(X.data.size>G.maxSize.value)M(X,{code:B.too_big,maximum:G.maxSize.value,type:"set",inclusive:!0,exact:!1,message:G.maxSize.message}),W.dirty()}let Q=this._def.valueType;function J(w){let z=new Set;for(let V of w){if(V.status==="aborted")return L;if(V.status==="dirty")W.dirty();z.add(V.value)}return{status:W.value,value:z}}let Y=[...X.data.values()].map((w,z)=>Q._parse(new P(X,w,X.path,z)));if(X.common.async)return Promise.all(Y).then((w)=>J(w));else return J(Y)}min($,W){return new s({...this._def,minSize:{value:$,message:O.toString(W)}})}max($,W){return new s({...this._def,maxSize:{value:$,message:O.toString(W)}})}size($,W){return this.min($,W).max($,W)}nonempty($){return this.min(1,$)}}s.create=($,W)=>{return new s({valueType:$,minSize:null,maxSize:null,typeName:j.ZodSet,...A(W)})};class Q0 extends D{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==q.function)return M(W,{code:B.invalid_type,expected:q.function,received:W.parsedType}),L;function X(Y,w){return C0({data:Y,path:W.path,errorMaps:[W.common.contextualErrorMap,W.schemaErrorMap,f0(),G0].filter((z)=>!!z),issueData:{code:B.invalid_arguments,argumentsError:w}})}function G(Y,w){return C0({data:Y,path:W.path,errorMaps:[W.common.contextualErrorMap,W.schemaErrorMap,f0(),G0].filter((z)=>!!z),issueData:{code:B.invalid_return_type,returnTypeError:w}})}let Q={errorMap:W.common.contextualErrorMap},J=W.data;if(this._def.returns instanceof e){let Y=this;return _(async function(...w){let z=new E([]),V=await Y._def.args.parseAsync(w,Q).catch((d)=>{throw z.addIssue(X(w,d)),z}),U=await Reflect.apply(J,this,V);return await Y._def.returns._def.type.parseAsync(U,Q).catch((d)=>{throw z.addIssue(G(U,d)),z})})}else{let Y=this;return _(function(...w){let z=Y._def.args.safeParse(w,Q);if(!z.success)throw new E([X(w,z.error)]);let V=Reflect.apply(J,this,z.data),U=Y._def.returns.safeParse(V,Q);if(!U.success)throw new E([G(V,U.error)]);return U.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new Q0({...this._def,args:y.create($).rest(u.create())})}returns($){return new Q0({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,W,X){return new Q0({args:$?$:y.create([]).rest(u.create()),returns:W||u.create(),typeName:j.ZodFunction,...A(X)})}}class B0 extends D{get schema(){return this._def.getter()}_parse($){let{ctx:W}=this._processInputParams($);return this._def.getter()._parse({data:W.data,path:W.path,parent:W})}}B0.create=($,W)=>{return new B0({getter:$,typeName:j.ZodLazy,...A(W)})};class M0 extends D{_parse($){if($.data!==this._def.value){let W=this._getOrReturnCtx($);return M(W,{received:W.data,code:B.invalid_literal,expected:this._def.value}),L}return{status:"valid",value:$.data}}get value(){return this._def.value}}M0.create=($,W)=>{return new M0({value:$,typeName:j.ZodLiteral,...A(W)})};function L1($,W){return new i({values:$,typeName:j.ZodEnum,...A(W)})}class i extends D{constructor(){super(...arguments);D0.set(this,void 0)}_parse($){if(typeof $.data!=="string"){let W=this._getOrReturnCtx($),X=this._def.values;return M(W,{expected:F.joinValues(X),received:W.parsedType,code:B.invalid_type}),L}if(!k0(this,D0,"f"))q1(this,D0,new Set(this._def.values),"f");if(!k0(this,D0,"f").has($.data)){let W=this._getOrReturnCtx($),X=this._def.values;return M(W,{received:W.data,code:B.invalid_enum_value,options:X}),L}return _($.data)}get options(){return this._def.values}get enum(){let $={};for(let W of this._def.values)$[W]=W;return $}get Values(){let $={};for(let W of this._def.values)$[W]=W;return $}get Enum(){let $={};for(let W of this._def.values)$[W]=W;return $}extract($,W=this._def){return i.create($,{...this._def,...W})}exclude($,W=this._def){return i.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...W})}}D0=new WeakMap;i.create=L1;class q0 extends D{constructor(){super(...arguments);U0.set(this,void 0)}_parse($){let W=F.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==q.string&&X.parsedType!==q.number){let G=F.objectValues(W);return M(X,{expected:F.joinValues(G),received:X.parsedType,code:B.invalid_type}),L}if(!k0(this,U0,"f"))q1(this,U0,new Set(F.getValidEnumValues(this._def.values)),"f");if(!k0(this,U0,"f").has($.data)){let G=F.objectValues(W);return M(X,{received:X.data,code:B.invalid_enum_value,options:G}),L}return _($.data)}get enum(){return this._def.values}}U0=new WeakMap;q0.create=($,W)=>{return new q0({values:$,typeName:j.ZodNativeEnum,...A(W)})};class e extends D{unwrap(){return this._def.type}_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==q.promise&&W.common.async===!1)return M(W,{code:B.invalid_type,expected:q.promise,received:W.parsedType}),L;let X=W.parsedType===q.promise?W.data:Promise.resolve(W.data);return _(X.then((G)=>{return this._def.type.parseAsync(G,{path:W.path,errorMap:W.common.contextualErrorMap})}))}}e.create=($,W)=>{return new e({type:$,typeName:j.ZodPromise,...A(W)})};class v extends D{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===j.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:W,ctx:X}=this._processInputParams($),G=this._def.effect||null,Q={addIssue:(J)=>{if(M(X,J),J.fatal)W.abort();else W.dirty()},get path(){return X.path}};if(Q.addIssue=Q.addIssue.bind(Q),G.type==="preprocess"){let J=G.transform(X.data,Q);if(X.common.async)return Promise.resolve(J).then(async(Y)=>{if(W.value==="aborted")return L;let w=await this._def.schema._parseAsync({data:Y,path:X.path,parent:X});if(w.status==="aborted")return L;if(w.status==="dirty")return X0(w.value);if(W.value==="dirty")return X0(w.value);return w});else{if(W.value==="aborted")return L;let Y=this._def.schema._parseSync({data:J,path:X.path,parent:X});if(Y.status==="aborted")return L;if(Y.status==="dirty")return X0(Y.value);if(W.value==="dirty")return X0(Y.value);return Y}}if(G.type==="refinement"){let J=(Y)=>{let w=G.refinement(Y,Q);if(X.common.async)return Promise.resolve(w);if(w instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return Y};if(X.common.async===!1){let Y=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(Y.status==="aborted")return L;if(Y.status==="dirty")W.dirty();return J(Y.value),{status:W.value,value:Y.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((Y)=>{if(Y.status==="aborted")return L;if(Y.status==="dirty")W.dirty();return J(Y.value).then(()=>{return{status:W.value,value:Y.value}})})}if(G.type==="transform")if(X.common.async===!1){let J=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!o(J))return J;let Y=G.transform(J.value,Q);if(Y instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:W.value,value:Y}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((J)=>{if(!o(J))return J;return Promise.resolve(G.transform(J.value,Q)).then((Y)=>({status:W.value,value:Y}))});F.assertNever(G)}}v.create=($,W,X)=>{return new v({schema:$,typeName:j.ZodEffects,effect:W,...A(X)})};v.createWithPreprocess=($,W,X)=>{return new v({schema:W,effect:{type:"preprocess",transform:$},typeName:j.ZodEffects,...A(X)})};class I extends D{_parse($){if(this._getType($)===q.undefined)return _(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}I.create=($,W)=>{return new I({innerType:$,typeName:j.ZodOptional,...A(W)})};class c extends D{_parse($){if(this._getType($)===q.null)return _(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}c.create=($,W)=>{return new c({innerType:$,typeName:j.ZodNullable,...A(W)})};class O0 extends D{_parse($){let{ctx:W}=this._processInputParams($),X=W.data;if(W.parsedType===q.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:W.path,parent:W})}removeDefault(){return this._def.innerType}}O0.create=($,W)=>{return new O0({innerType:$,typeName:j.ZodDefault,defaultValue:typeof W.default==="function"?W.default:()=>W.default,...A(W)})};class V0 extends D{_parse($){let{ctx:W}=this._processInputParams($),X={...W,common:{...W.common,issues:[]}},G=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(F0(G))return G.then((Q)=>{return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new E(X.common.issues)},input:X.data})}});else return{status:"valid",value:G.status==="valid"?G.value:this._def.catchValue({get error(){return new E(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}V0.create=($,W)=>{return new V0({innerType:$,typeName:j.ZodCatch,catchValue:typeof W.catch==="function"?W.catch:()=>W.catch,...A(W)})};class _0 extends D{_parse($){if(this._getType($)!==q.nan){let X=this._getOrReturnCtx($);return M(X,{code:B.invalid_type,expected:q.nan,received:X.parsedType}),L}return{status:"valid",value:$.data}}}_0.create=($)=>{return new _0({typeName:j.ZodNaN,...A($)})};var L4=Symbol("zod_brand");class P0 extends D{_parse($){let{ctx:W}=this._processInputParams($),X=W.data;return this._def.type._parse({data:X,path:W.path,parent:W})}unwrap(){return this._def.type}}class E0 extends D{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let Q=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(Q.status==="aborted")return L;if(Q.status==="dirty")return W.dirty(),X0(Q.value);else return this._def.out._parseAsync({data:Q.value,path:X.path,parent:X})})();else{let G=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(G.status==="aborted")return L;if(G.status==="dirty")return W.dirty(),{status:"dirty",value:G.value};else return this._def.out._parseSync({data:G.value,path:X.path,parent:X})}}static create($,W){return new E0({in:$,out:W,typeName:j.ZodPipeline})}}class j0 extends D{_parse($){let W=this._def.innerType._parse($),X=(G)=>{if(o(G))G.value=Object.freeze(G.value);return G};return F0(W)?W.then((G)=>X(G)):X(W)}unwrap(){return this._def.innerType}}j0.create=($,W)=>{return new j0({innerType:$,typeName:j.ZodReadonly,...A(W)})};function A1($,W={},X){if($)return t.create().superRefine((G,Q)=>{var J,Y;if(!$(G)){let w=typeof W==="function"?W(G):typeof W==="string"?{message:W}:W,z=(Y=(J=w.fatal)!==null&&J!==void 0?J:X)!==null&&Y!==void 0?Y:!0,V=typeof w==="string"?{message:w}:w;Q.addIssue({code:"custom",...V,fatal:z})}});return t.create()}var A4={object:R.lazycreate},j;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(j||(j={}));var D4=($,W={message:`Input not instance of ${$.name}`})=>A1((X)=>X instanceof $,W),D1=C.create,U1=p.create,U4=_0.create,F4=n.create,F1=H0.create,R4=a.create,K4=R0.create,S4=J0.create,N4=Y0.create,_4=t.create,E4=u.create,b4=x.create,v4=K0.create,f4=k.create,C4=R.create,k4=R.strictCreate,I4=w0.create,P4=I0.create,g4=z0.create,h4=y.create,T4=S0.create,x4=N0.create,y4=s.create,l4=Q0.create,m4=B0.create,Z4=M0.create,c4=i.create,u4=q0.create,p4=e.create,B1=v.create,n4=I.create,i4=c.create,d4=v.createWithPreprocess,r4=E0.create,o4=()=>D1().optional(),a4=()=>U1().optional(),t4=()=>F1().optional(),s4={string:($)=>C.create({...$,coerce:!0}),number:($)=>p.create({...$,coerce:!0}),boolean:($)=>H0.create({...$,coerce:!0}),bigint:($)=>n.create({...$,coerce:!0}),date:($)=>a.create({...$,coerce:!0})},e4=L,H=Object.freeze({__proto__:null,defaultErrorMap:G0,setErrorMap:d1,getErrorMap:f0,makeIssue:C0,EMPTY_PATH:r1,addIssueToContext:M,ParseStatus:N,INVALID:L,DIRTY:X0,OK:_,isAborted:i0,isDirty:d0,isValid:o,isAsync:F0,get util(){return F},get objectUtil(){return n0},ZodParsedType:q,getParsedType:Z,ZodType:D,datetimeRegex:j1,ZodString:C,ZodNumber:p,ZodBigInt:n,ZodBoolean:H0,ZodDate:a,ZodSymbol:R0,ZodUndefined:J0,ZodNull:Y0,ZodAny:t,ZodUnknown:u,ZodNever:x,ZodVoid:K0,ZodArray:k,ZodObject:R,ZodUnion:w0,ZodDiscriminatedUnion:I0,ZodIntersection:z0,ZodTuple:y,ZodRecord:S0,ZodMap:N0,ZodSet:s,ZodFunction:Q0,ZodLazy:B0,ZodLiteral:M0,ZodEnum:i,ZodNativeEnum:q0,ZodPromise:e,ZodEffects:v,ZodTransformer:v,ZodOptional:I,ZodNullable:c,ZodDefault:O0,ZodCatch:V0,ZodNaN:_0,BRAND:L4,ZodBranded:P0,ZodPipeline:E0,ZodReadonly:j0,custom:A1,Schema:D,ZodSchema:D,late:A4,get ZodFirstPartyTypeKind(){return j},coerce:s4,any:_4,array:f4,bigint:F4,boolean:F1,date:R4,discriminatedUnion:P4,effect:B1,enum:c4,function:l4,instanceof:D4,intersection:g4,lazy:m4,literal:Z4,map:x4,nan:U4,nativeEnum:u4,never:b4,null:N4,nullable:i4,number:U1,object:C4,oboolean:t4,onumber:a4,optional:n4,ostring:o4,pipeline:r4,preprocess:d4,promise:p4,record:T4,set:y4,strictObject:k4,string:D1,symbol:K4,transformer:B1,tuple:h4,undefined:S4,union:I4,unknown:E4,void:v4,NEVER:e4,ZodIssueCode:B,quotelessJson:i1,ZodError:E});var o0="2024-11-05",R1=[o0,"2024-10-07"],g0="2.0",K1=H.union([H.string(),H.number().int()]),S1=H.string(),g=H.object({_meta:H.optional(H.object({progressToken:H.optional(K1)}).passthrough())}).passthrough(),b=H.object({method:H.string(),params:H.optional(g)}),b0=H.object({_meta:H.optional(H.object({}).passthrough())}).passthrough(),l=H.object({method:H.string(),params:H.optional(b0)}),h=H.object({_meta:H.optional(H.object({}).passthrough())}).passthrough(),h0=H.union([H.string(),H.number().int()]),$6=H.object({jsonrpc:H.literal(g0),id:h0}).merge(b).strict(),W6=H.object({jsonrpc:H.literal(g0)}).merge(l).strict(),X6=H.object({jsonrpc:H.literal(g0),id:h0,result:h}).strict(),$0;(function($){$[$.ConnectionClosed=-1]="ConnectionClosed",$[$.RequestTimeout=-2]="RequestTimeout",$[$.ParseError=-32700]="ParseError",$[$.InvalidRequest=-32600]="InvalidRequest",$[$.MethodNotFound=-32601]="MethodNotFound",$[$.InvalidParams=-32602]="InvalidParams",$[$.InternalError=-32603]="InternalError"})($0||($0={}));var Q6=H.object({jsonrpc:H.literal(g0),id:h0,error:H.object({code:H.number().int(),message:H.string(),data:H.optional(H.unknown())})}).strict(),N1=H.union([$6,W6,X6,Q6]),T0=h.strict(),x0=l.extend({method:H.literal("notifications/cancelled"),params:b0.extend({requestId:h0,reason:H.string().optional()})}),_1=H.object({name:H.string(),version:H.string()}).passthrough(),G6=H.object({experimental:H.optional(H.object({}).passthrough()),sampling:H.optional(H.object({}).passthrough()),roots:H.optional(H.object({listChanged:H.optional(H.boolean())}).passthrough())}).passthrough(),a0=b.extend({method:H.literal("initialize"),params:g.extend({protocolVersion:H.string(),capabilities:G6,clientInfo:_1})}),H6=H.object({experimental:H.optional(H.object({}).passthrough()),logging:H.optional(H.object({}).passthrough()),prompts:H.optional(H.object({listChanged:H.optional(H.boolean())}).passthrough()),resources:H.optional(H.object({subscribe:H.optional(H.boolean()),listChanged:H.optional(H.boolean())}).passthrough()),tools:H.optional(H.object({listChanged:H.optional(H.boolean())}).passthrough())}).passthrough(),J6=h.extend({protocolVersion:H.string(),capabilities:H6,serverInfo:_1}),t0=l.extend({method:H.literal("notifications/initialized")}),y0=b.extend({method:H.literal("ping")}),Y6=H.object({progress:H.number(),total:H.optional(H.number())}).passthrough(),l0=l.extend({method:H.literal("notifications/progress"),params:b0.merge(Y6).extend({progressToken:K1})}),m0=b.extend({params:g.extend({cursor:H.optional(S1)}).optional()}),Z0=h.extend({nextCursor:H.optional(S1)}),E1=H.object({uri:H.string(),mimeType:H.optional(H.string())}).passthrough(),b1=E1.extend({text:H.string()}),v1=E1.extend({blob:H.string().base64()}),w6=H.object({uri:H.string(),name:H.string(),description:H.optional(H.string()),mimeType:H.optional(H.string())}).passthrough(),z6=H.object({uriTemplate:H.string(),name:H.string(),description:H.optional(H.string()),mimeType:H.optional(H.string())}).passthrough(),B6=m0.extend({method:H.literal("resources/list")}),M6=Z0.extend({resources:H.array(w6)}),q6=m0.extend({method:H.literal("resources/templates/list")}),O6=Z0.extend({resourceTemplates:H.array(z6)}),V6=b.extend({method:H.literal("resources/read"),params:g.extend({uri:H.string()})}),j6=h.extend({contents:H.array(H.union([b1,v1]))}),L6=l.extend({method:H.literal("notifications/resources/list_changed")}),A6=b.extend({method:H.literal("resources/subscribe"),params:g.extend({uri:H.string()})}),D6=b.extend({method:H.literal("resources/unsubscribe"),params:g.extend({uri:H.string()})}),U6=l.extend({method:H.literal("notifications/resources/updated"),params:b0.extend({uri:H.string()})}),F6=H.object({name:H.string(),description:H.optional(H.string()),required:H.optional(H.boolean())}).passthrough(),R6=H.object({name:H.string(),description:H.optional(H.string()),arguments:H.optional(H.array(F6))}).passthrough(),K6=m0.extend({method:H.literal("prompts/list")}),S6=Z0.extend({prompts:H.array(R6)}),N6=b.extend({method:H.literal("prompts/get"),params:g.extend({name:H.string(),arguments:H.optional(H.record(H.string()))})}),c0=H.object({type:H.literal("text"),text:H.string()}).passthrough(),u0=H.object({type:H.literal("image"),data:H.string().base64(),mimeType:H.string()}).passthrough(),f1=H.object({type:H.literal("resource"),resource:H.union([b1,v1])}).passthrough(),_6=H.object({role:H.enum(["user","assistant"]),content:H.union([c0,u0,f1])}).passthrough(),E6=h.extend({description:H.optional(H.string()),messages:H.array(_6)}),b6=l.extend({method:H.literal("notifications/prompts/list_changed")}),v6=H.object({name:H.string(),description:H.optional(H.string()),inputSchema:H.object({type:H.literal("object"),properties:H.optional(H.object({}).passthrough())}).passthrough()}).passthrough(),s0=m0.extend({method:H.literal("tools/list")}),f6=Z0.extend({tools:H.array(v6)}),C1=h.extend({content:H.array(H.union([c0,u0,f1])),isError:H.boolean().default(!1).optional()}),Q8=C1.or(h.extend({toolResult:H.unknown()})),e0=b.extend({method:H.literal("tools/call"),params:g.extend({name:H.string(),arguments:H.optional(H.record(H.unknown()))})}),C6=l.extend({method:H.literal("notifications/tools/list_changed")}),k1=H.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),k6=b.extend({method:H.literal("logging/setLevel"),params:g.extend({level:k1})}),I6=l.extend({method:H.literal("notifications/message"),params:b0.extend({level:k1,logger:H.optional(H.string()),data:H.unknown()})}),P6=H.object({name:H.string().optional()}).passthrough(),g6=H.object({hints:H.optional(H.array(P6)),costPriority:H.optional(H.number().min(0).max(1)),speedPriority:H.optional(H.number().min(0).max(1)),intelligencePriority:H.optional(H.number().min(0).max(1))}).passthrough(),h6=H.object({role:H.enum(["user","assistant"]),content:H.union([c0,u0])}).passthrough(),T6=b.extend({method:H.literal("sampling/createMessage"),params:g.extend({messages:H.array(h6),systemPrompt:H.optional(H.string()),includeContext:H.optional(H.enum(["none","thisServer","allServers"])),temperature:H.optional(H.number()),maxTokens:H.number().int(),stopSequences:H.optional(H.array(H.string())),metadata:H.optional(H.object({}).passthrough()),modelPreferences:H.optional(g6)})}),$1=h.extend({model:H.string(),stopReason:H.optional(H.enum(["endTurn","stopSequence","maxTokens"]).or(H.string())),role:H.enum(["user","assistant"]),content:H.discriminatedUnion("type",[c0,u0])}),x6=H.object({type:H.literal("ref/resource"),uri:H.string()}).passthrough(),y6=H.object({type:H.literal("ref/prompt"),name:H.string()}).passthrough(),l6=b.extend({method:H.literal("completion/complete"),params:g.extend({ref:H.union([y6,x6]),argument:H.object({name:H.string(),value:H.string()}).passthrough()})}),m6=h.extend({completion:H.object({values:H.array(H.string()).max(100),total:H.optional(H.number().int()),hasMore:H.optional(H.boolean())}).passthrough()}),Z6=H.object({uri:H.string().startsWith("file://"),name:H.optional(H.string())}).passthrough(),c6=b.extend({method:H.literal("roots/list")}),W1=h.extend({roots:H.array(Z6)}),u6=l.extend({method:H.literal("notifications/roots/list_changed")}),G8=H.union([y0,a0,l6,k6,N6,K6,B6,q6,V6,A6,D6,e0,s0]),H8=H.union([x0,l0,t0,u6]),J8=H.union([T0,$1,W1]),Y8=H.union([y0,T6,c6]),w8=H.union([x0,l0,I6,U6,L6,C6,b6]),z8=H.union([T0,J6,m6,E6,S6,M6,O6,j6,C1,f6]);class v0 extends Error{constructor($,W,X){super(`MCP error ${$}: ${W}`);this.code=$,this.data=X}}var p6=60000;class X1{constructor($){this._options=$,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this.setNotificationHandler(x0,(W)=>{let X=this._requestHandlerAbortControllers.get(W.params.requestId);X===null||X===void 0||X.abort(W.params.reason)}),this.setNotificationHandler(l0,(W)=>{this._onprogress(W)}),this.setRequestHandler(y0,(W)=>({}))}async connect($){this._transport=$,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=(W)=>{this._onerror(W)},this._transport.onmessage=(W)=>{if(!("method"in W))this._onresponse(W);else if("id"in W)this._onrequest(W);else this._onnotification(W)},await this._transport.start()}_onclose(){var $;let W=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,($=this.onclose)===null||$===void 0||$.call(this);let X=new v0($0.ConnectionClosed,"Connection closed");for(let G of W.values())G(X)}_onerror($){var W;(W=this.onerror)===null||W===void 0||W.call(this,$)}_onnotification($){var W;let X=(W=this._notificationHandlers.get($.method))!==null&&W!==void 0?W:this.fallbackNotificationHandler;if(X===void 0)return;Promise.resolve().then(()=>X($)).catch((G)=>this._onerror(Error(`Uncaught error in notification handler: ${G}`)))}_onrequest($){var W,X;let G=(W=this._requestHandlers.get($.method))!==null&&W!==void 0?W:this.fallbackRequestHandler;if(G===void 0){(X=this._transport)===null||X===void 0||X.send({jsonrpc:"2.0",id:$.id,error:{code:$0.MethodNotFound,message:"Method not found"}}).catch((J)=>this._onerror(Error(`Failed to send an error response: ${J}`)));return}let Q=new AbortController;this._requestHandlerAbortControllers.set($.id,Q),Promise.resolve().then(()=>G($,{signal:Q.signal})).then((J)=>{var Y;if(Q.signal.aborted)return;return(Y=this._transport)===null||Y===void 0?void 0:Y.send({result:J,jsonrpc:"2.0",id:$.id})},(J)=>{var Y,w;if(Q.signal.aborted)return;return(Y=this._transport)===null||Y===void 0?void 0:Y.send({jsonrpc:"2.0",id:$.id,error:{code:Number.isSafeInteger(J.code)?J.code:$0.InternalError,message:(w=J.message)!==null&&w!==void 0?w:"Internal error"}})}).catch((J)=>this._onerror(Error(`Failed to send response: ${J}`))).finally(()=>{this._requestHandlerAbortControllers.delete($.id)})}_onprogress($){let{progressToken:W,...X}=$.params,G=this._progressHandlers.get(Number(W));if(G===void 0){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify($)}`));return}G(X)}_onresponse($){let W=$.id,X=this._responseHandlers.get(Number(W));if(X===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify($)}`));return}if(this._responseHandlers.delete(Number(W)),this._progressHandlers.delete(Number(W)),"result"in $)X($);else{let G=new v0($.error.code,$.error.message,$.error.data);X(G)}}get transport(){return this._transport}async close(){var $;await(($=this._transport)===null||$===void 0?void 0:$.close())}request($,W,X){return new Promise((G,Q)=>{var J,Y,w,z;if(!this._transport){Q(Error("Not connected"));return}if(((J=this._options)===null||J===void 0?void 0:J.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod($.method);(Y=X===null||X===void 0?void 0:X.signal)===null||Y===void 0||Y.throwIfAborted();let V=this._requestMessageId++,U={...$,jsonrpc:"2.0",id:V};if(X===null||X===void 0?void 0:X.onprogress)this._progressHandlers.set(V,X.onprogress),U.params={...$.params,_meta:{progressToken:V}};let S=void 0;this._responseHandlers.set(V,(K)=>{var f;if(S!==void 0)clearTimeout(S);if((f=X===null||X===void 0?void 0:X.signal)===null||f===void 0?void 0:f.aborted)return;if(K instanceof Error)return Q(K);try{let r=W.parse(K.result);G(r)}catch(r){Q(r)}});let d=(K)=>{var f;this._responseHandlers.delete(V),this._progressHandlers.delete(V),(f=this._transport)===null||f===void 0||f.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:V,reason:String(K)}}).catch((r)=>this._onerror(Error(`Failed to send cancellation: ${r}`))),Q(K)};(w=X===null||X===void 0?void 0:X.signal)===null||w===void 0||w.addEventListener("abort",()=>{var K;if(S!==void 0)clearTimeout(S);d((K=X===null||X===void 0?void 0:X.signal)===null||K===void 0?void 0:K.reason)});let A0=(z=X===null||X===void 0?void 0:X.timeout)!==null&&z!==void 0?z:p6;S=setTimeout(()=>d(new v0($0.RequestTimeout,"Request timed out",{timeout:A0})),A0),this._transport.send(U).catch((K)=>{if(S!==void 0)clearTimeout(S);Q(K)})})}async notification($){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability($.method);let W={...$,jsonrpc:"2.0"};await this._transport.send(W)}setRequestHandler($,W){let X=$.shape.method.value;this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(G,Q)=>Promise.resolve(W($.parse(G),Q)))}removeRequestHandler($){this._requestHandlers.delete($)}setNotificationHandler($,W){this._notificationHandlers.set($.shape.method.value,(X)=>Promise.resolve(W($.parse(X))))}removeNotificationHandler($){this._notificationHandlers.delete($)}}class Q1 extends X1{constructor($,W){super(W);this._serverInfo=$,this._capabilities=W.capabilities,this.setRequestHandler(a0,(X)=>this._oninitialize(X)),this.setNotificationHandler(t0,()=>{var X;return(X=this.oninitialized)===null||X===void 0?void 0:X.call(this)})}assertCapabilityForMethod($){var W,X;switch($){case"sampling/createMessage":if(!((W=this._clientCapabilities)===null||W===void 0?void 0:W.sampling))throw Error(`Client does not support sampling (required for ${$})`);break;case"roots/list":if(!((X=this._clientCapabilities)===null||X===void 0?void 0:X.roots))throw Error(`Client does not support listing roots (required for ${$})`);break;case"ping":break}}assertNotificationCapability($){switch($){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${$})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${$})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${$})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${$})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability($){switch($){case"sampling/createMessage":if(!this._capabilities.sampling)throw Error(`Server does not support sampling (required for ${$})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${$})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${$})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${$})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${$})`);break;case"ping":case"initialize":break}}async _oninitialize($){let W=$.params.protocolVersion;return this._clientCapabilities=$.params.capabilities,this._clientVersion=$.params.clientInfo,{protocolVersion:R1.includes(W)?W:o0,capabilities:this.getCapabilities(),serverInfo:this._serverInfo}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},T0)}async createMessage($,W){return this.request({method:"sampling/createMessage",params:$},$1,W)}async listRoots($,W){return this.request({method:"roots/list",params:$},W1,W)}async sendLoggingMessage($){return this.notification({method:"notifications/message",params:$})}async sendResourceUpdated($){return this.notification({method:"notifications/resources/updated",params:$})}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"})}}import P1 from"process";class G1{append($){this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){if(!this._buffer)return null;let $=this._buffer.indexOf(`
3
+ `);if($===-1)return null;let W=this._buffer.toString("utf8",0,$);return this._buffer=this._buffer.subarray($+1),n6(W)}clear(){this._buffer=void 0}}function n6($){return N1.parse(JSON.parse($))}function I1($){return JSON.stringify($)+`
4
+ `}class H1{constructor($=P1.stdin,W=P1.stdout){this._stdin=$,this._stdout=W,this._readBuffer=new G1,this._started=!1,this._ondata=(X)=>{this._readBuffer.append(X),this.processReadBuffer()},this._onerror=(X)=>{var G;(G=this.onerror)===null||G===void 0||G.call(this,X)}}async start(){if(this._started)throw 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(){var $,W;while(!0)try{let X=this._readBuffer.readMessage();if(X===null)break;($=this.onmessage)===null||$===void 0||$.call(this,X)}catch(X){(W=this.onerror)===null||W===void 0||W.call(this,X)}}async close(){var $;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._readBuffer.clear(),($=this.onclose)===null||$===void 0||$.call(this)}send($){return new Promise((W)=>{let X=I1($);if(this._stdout.write(X))W();else this._stdout.once("drain",W)})}}var d6=await Promise.resolve().then(() => p1(g1(),1)),h1=d6.version;async function T1($){let W=new Q1({name:"typescape",version:h1},{capabilities:{tools:{}}});W.setRequestHandler(s0,async()=>{return{tools:$.getTools().map((Q)=>({name:Q.name,description:Q.description,inputSchema:Q.inputSchema}))}}),W.setRequestHandler(e0,async(G)=>{let{name:Q,arguments:J}=G.params,Y=$.getHandler(Q);if(!Y)return{content:[{type:"text",text:`Unknown tool: ${Q}`}],isError:!0};try{let w=await Y(J||{});return{content:w.content.map((z)=>({type:z.type,text:z.text})),isError:w.isError}}catch(w){return{content:[{type:"text",text:`Error: ${w instanceof Error?w.message:String(w)}`}],isError:!0}}});let X=new H1;await W.connect(X),console.error(`Typescape MCP server v${h1} started`)}var r6={type:"object",properties:{repo_id:{type:"string",description:"Repository identifier"},git_sha:{type:"string",description:"Concrete 40-hex Git commit SHA (agent must resolve; no symbolic refs)"},file_path:{type:"string",description:"Path to Markdown file within the repo"},title:{type:"string",description:"Session title (optional)"},participants:{type:"array",items:{type:"object",properties:{email:{type:"string"},roles:{type:"array",items:{type:"string",enum:["reviewer","approver"]}}},required:["email","roles"]},description:"Participants to invite (optional)"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"},expected_version:{type:"string",description:"Expected version for optimistic concurrency (If-Match header, optional)"}},required:["repo_id","git_sha","file_path"]},o6={type:"object",properties:{session_id:{type:"string",description:"Session ID to export (e.g., sess_01HXYZ...)"},schema:{type:"string",default:"v1",description:"Export schema version (default: v1)"},expected_version:{type:"string",description:"Expected version for optimistic concurrency (If-Match header, optional)"}},required:["session_id"]};function x1($,W){return{content:[{type:"text",text:JSON.stringify({...$,request_id:W},null,2)}]}}function L0($){let W=$.status===0||$.status>=500||$.status===429;return{content:[{type:"text",text:JSON.stringify({error:{code:$.code,message:$.message,retryable:W,request_id:$.requestId}},null,2)}],isError:!0}}function y1($,W){let X={name:"typescape_create_session",description:"Create a new Typescape review session for a Markdown file. Returns the session ID and any invitations sent. The agent must provide a concrete 40-hex Git SHA; no symbolic ref resolution is performed.",inputSchema:r6};$.register(X,async(Q)=>{let J=Q;if(!J.repo_id)return L0(new T(400,"missing_param","Missing required parameter: repo_id","local"));if(!J.git_sha)return L0(new T(400,"missing_param","Missing required parameter: git_sha","local"));if(!J.file_path)return L0(new T(400,"missing_param","Missing required parameter: file_path","local"));let Y={source:{source_type:"git",repo_id:J.repo_id,git_sha:J.git_sha,file_path:J.file_path}};if(J.title!==void 0)Y.title=J.title;if(J.participants!==void 0&&J.participants.length>0)Y.participants=J.participants;let w={};if(J.idempotency_key)w["Idempotency-Key"]=J.idempotency_key;if(J.expected_version)w["If-Match"]=J.expected_version;try{let z=await W.post("/sessions",{body:Y,headers:w});return x1({session:z.body.session,invitations:z.body.invitations??[]},z.requestId)}catch(z){if(z instanceof T)return L0(z);throw z}});let G={name:"typescape_export_feedback",description:"Export all feedback from a Typescape review session as structured JSON. Returns the full export document including threads, comments, and anchors.",inputSchema:o6};$.register(G,async(Q)=>{let J=Q;if(!J.session_id)return L0(new T(400,"missing_param","Missing required parameter: session_id","local"));let Y={schema:J.schema||"v1"},w={};if(J.expected_version)w["If-Match"]=J.expected_version;try{let z=await W.get(`/sessions/${J.session_id}/export`,{query:Y,headers:w});return x1(z.body,z.requestId)}catch(z){if(z instanceof T)return L0(z);throw z}})}var l1={TYPESCAPE_API_TOKEN:"Operator API token for authenticating with the Typescape API",TYPESCAPE_BASE_URL:"Base URL of the Typescape API server (e.g., https://review.example.com)"};function a6(){let $=process.env.TYPESCAPE_API_TOKEN,W=process.env.TYPESCAPE_BASE_URL,X=[];if(!$)X.push(`TYPESCAPE_API_TOKEN: ${l1.TYPESCAPE_API_TOKEN}`);if(!W)X.push(`TYPESCAPE_BASE_URL: ${l1.TYPESCAPE_BASE_URL}`);if(X.length>0){console.error("Error: Missing required environment variables:");for(let G of X)console.error(` - ${G}`);process.exit(1)}return{apiToken:$,baseUrl:W}}async function t6(){let{apiToken:$,baseUrl:W}=a6(),X=w1(W,$),G=Y1();y1(G,X),await T1(G)}t6().catch(($)=>{console.error("Fatal error:",$ instanceof Error?$.message:String($)),process.exit(1)});
package/package.json CHANGED
@@ -1,10 +1,37 @@
1
1
  {
2
2
  "name": "@typescape-ai/mcp",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @typescape-ai/mcp",
3
+ "version": "0.1.0",
4
+ "description": "Typescape MCP Server - Model Context Protocol integration for AI agents",
5
+ "type": "module",
6
+ "bin": {
7
+ "typescape-mcp": "./dist/mcp.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "README.md"
12
+ ],
13
+ "exports": {
14
+ ".": "./dist/mcp.js"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "engines": {
20
+ "bun": ">=1.0.0"
21
+ },
5
22
  "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
23
+ "typescape",
24
+ "mcp",
25
+ "model-context-protocol",
26
+ "ai",
27
+ "claude",
28
+ "review",
29
+ "bun"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/voidserf/typescape-docs.git",
34
+ "directory": "apps/mcp"
35
+ },
36
+ "license": "MIT"
10
37
  }