xmcp 0.2.1-canary.2 → 0.2.1

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 (2) hide show
  1. package/dist/cli.js +1 -1
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -21,4 +21,4 @@ if (!isNaN(pid)) {
21
21
  })
22
22
  process.on('SIGHUP', bark)
23
23
  }
24
- `,lr=e=>{let t=!1;const r=(0,cr.spawn)(process.execPath,["-e",ur,String(e.pid)],{stdio:"ignore"});return r.on("exit",()=>t=!0),e.on("exit",()=>{t||r.kill("SIGKILL")}),r},pr=nt.bold.green("✔"),dr=nt.bold.black.bgWhite(" XMCP "),fr=nt.bold.yellow("❯");let hr=null;function mr(){const e=(0,cr.spawn)("node",["dist/http.js"],{stdio:"inherit",shell:!0});return lr(e),e}function vr(e,t){if(null!=e&&!1!==e){if(""===e&&gr(`${t} path cannot be an empty string`),"string"==typeof(r=e)&&r.length>0)return function(e){return/[*?\[\]{}]/.test(e)}(e)&&gr(`If you are using a glob pattern, please use a string for the ${t} path`),function(e){const r=function(e){return e.split(/\\|\//).join("/")}(e),a=m().resolve(g,r);return j().existsSync(a)||gr(`The path set in xmcp.config.ts for ${t} does not exist: ${a}.\n If you're not using this folder, set the ${t} path to false`),r}(e);var r;gr(`${t} path must be a non-empty string`)}}function gr(e){console.log(""),console.log(nt.red.bold(e)),console.log(""),process.exit(1)}async function yr({onBuild:e}={}){const{mode:t,toolPaths:r,promptPaths:a}=w.getContext(),n=Date.now();let s=!1;const i=await async function(){const e=await async function(){const e=_t("xmcp.config.json");if(e)return bt(JSON.parse(e));if(_t(xt))try{return await async function(){const e=m().resolve(process.cwd(),xt),t=(0,st.createFsFromVolume)(new st.Volume),r={mode:"production",entry:e,target:"node",output:{path:"/",filename:"config.js",library:{type:"commonjs2"}},resolve:{extensions:[".ts",".js"]},module:{rules:[{test:/\.ts$/,use:{loader:"swc-loader",options:{jsc:{parser:{syntax:"typescript"},target:"es2020"},module:{type:"commonjs"}}},exclude:/node_modules/}]},externals:{webpack:"commonjs2 webpack"}};return new Promise((a,n)=>{const s=(0,f.webpack)(r);s?(s.outputFileSystem=t,s.run((r,s)=>{if(r)n(r);else if(s?.hasErrors())n(new Error(s.toString({colors:!1,errors:!0})));else try{const r=t.readFileSync("/config.js","utf8"),n={exports:{}},s=e=>{if("webpack"===e)return f.webpack;throw new Error(`Cannot resolve module: ${e}`)};new Function("module","exports","require","__filename","__dirname",r)(n,n.exports,s,e,m().dirname(e));const i=n.exports.default||n.exports,o="function"==typeof i?i():i;a(bt(o))}catch(e){n(e)}})):n(new Error("Failed to create webpack compiler"))})}()}catch(e){throw new Error(`Failed to compile xmcp.config.ts:\n${e}`)}return{stdio:!0,http:!0,paths:R}}(),{platforms:t}=w.getContext();return t.vercel&&delete e.stdio,e}();w.setContext({xmcpConfig:i});let o=Te(i);i.webpack&&(o=i.webpack(o));const c=new or({persistent:"development"===t,ignored:/(^|[\/\\])\../,ignoreInitial:!1});let u=vr(O(i).tools,"tools");u&&c.watch(`${u}/**/*.ts`,{onAdd:e=>{r.add(e),s&&br()},onUnlink:e=>{r.delete(e),s&&br()}});let l=vr(O(i).prompts,"prompts");l&&c.watch(`${l}/**/*.ts`,{onAdd:e=>{a.add(e),s&&br()},onUnlink:e=>{a.delete(e),s&&br()}}),i.experimental?.adapter||c.watch("./src/middleware.ts",{onAdd:()=>{w.setContext({hasMiddleware:!0}),s&&br()},onUnlink:()=>{w.setContext({hasMiddleware:!1}),s&&br()}}),c.onReady(()=>{let r=!0;var a;s=!0,function(e,{force:t,dryRun:r,cwd:a=je.cwd(),...n}={}){n={expandDirectories:!1,onlyFiles:!1,followSymbolicLinks:!1,cwd:a,...n},e=function(e){return(e=Array.isArray(e)?e:[e]).map(e=>"win32"===je.platform&&!1===Qt(e)?Ot(e):e)}(e);const s=Wt(e,n).sort((e,t)=>t.localeCompare(e)).map(e=>(e=wt.resolve(a,e),t||function(e,t){if(function(e){let t=je.cwd();return e=wt.resolve(e),"win32"===je.platform&&(t=t.toLowerCase(),e=e.toLowerCase()),e===t}(e))throw new Error("Cannot delete the current working directory. Can be overridden with the `force` option.");if(!function(e,t){const r=wt.relative(t,e);return Boolean(r&&".."!==r&&!r.startsWith(`..${wt.sep}`)&&r!==wt.resolve(e))}(e,t))throw new Error("Cannot delete files/directories outside the current working directory. Can be overridden with the `force` option.")}(e,a),r||er.sync(e,rr),e));s.sort((e,t)=>e.localeCompare(t))}(v),a=v,j().existsSync(a)||j().mkdirSync(a,{recursive:!0}),br(),(0,f.webpack)(o,(a,s)=>{if(a&&console.error(a),s?.hasErrors())return void console.error(s.toString({colors:!0,chunks:!1}));let o;r?(function(e,t){const r=[];t.stdio&&r.push(`${pr} Built STDIO server`),t.http&&(t.experimental?.adapter?r.push(`${pr} Built Adapter`):r.push(`${pr} Built HTTP server`)),r.forEach(e=>{console.log(e)})}(0,i),e?.()):"development"===t&&i.http&&!i.experimental?.adapter&&async function(){hr?(console.log(`${fr} Restarting http server`),await async function(e){e.kill("SIGKILL"),await new Promise(t=>{e.on("exit",t)})}(hr),hr=mr()):(console.log(`${fr} Starting http server`),hr=mr())}(),o=s?.endTime&&s?.startTime?s.endTime-s.startTime:Date.now()-n;let c=e=>e;"development"===t&&(o>1e3?c=nt.bold.red:o>500&&(c=nt.bold.yellow)),console.log(`${pr} Compiled in ${c(`${o}ms`)}`),r=!1})})}function br(){const e=function(){const{toolPaths:e,promptPaths:t,hasMiddleware:r}=w.getContext();return`\nexport const tools = {\n${Array.from(e).map(e=>{const t=e.replace(/\\/g,"/");return`"${t}": () => import("../${t}"),`}).join("\n")}\n};\n\nexport const prompts = {\n${Array.from(t).map(e=>{const t=e.replace(/\\/g,"/");return`"${t}": () => import("../${t}"),`}).join("\n")}\n};\n\n${r?'export const middleware = () => import("../src/middleware");':""}\n`}();j().writeFileSync(m().join(v,"import-map.js"),e);const t=m().join(g,"xmcp-env.d.ts");j().existsSync(t)&&j().unlinkSync(t),j().writeFileSync(t,'/// <reference types="xmcp" />\n\n// Do not edit this file');const{xmcpConfig:r}=w.getContext();if("nextjs"===r?.experimental?.adapter){const e=function(){const{toolPaths:e}=w.getContext();return`import { z } from "zod";\n\n${Array.from(e).map((e,t)=>`import * as tool${t} from "../${e.replace(/\\/g,"/")}";`).join("\n")}\n\n/** \n * Runtime-accessible tools function that works from any context.\n * Generated at build time - always up to date with discovered tools.\n */\nexport async function getTools() {\n const toolsData = [\n ${Array.from(e).map((e,t)=>{const r=e.replace(/\\/g,"/"),a=r.split("/").pop()||r;return`{\n path: "${r}",\n name: "${a.replace(/\.[^/.]+$/,"")}",\n module: tool${t}\n }`}).join(",\n ")}\n ];\n\n const registry = {};\n\n for (const toolData of toolsData) {\n const { path, name: defaultName, module } = toolData;\n const { default: handler, metadata, schema } = module;\n\n const toolConfig = {\n name: defaultName,\n description: "No description provided",\n ...((typeof metadata === "object" && metadata !== null) ? metadata : {})\n };\n\n // Determine the actual schema to use\n let toolSchema = {};\n if (schema && typeof schema === "object" && schema !== null) {\n // Basic validation for Zod schema object\n const isValidSchema = Object.entries(schema).every(([key, val]) => {\n if (typeof key !== "string") return false;\n if (typeof val !== "object" || val === null) return false;\n if (!("parse" in val) || typeof val.parse !== "function") return false;\n return true;\n });\n \n if (isValidSchema) {\n toolSchema = schema;\n } else {\n console.warn(\`Invalid schema for tool "\${toolConfig.name}" at \${path}. Expected Record<string, z.ZodType>\`);\n }\n }\n\n // Make sure tools has annotations with a title\n if (toolConfig.annotations === undefined) {\n toolConfig.annotations = {};\n }\n if (toolConfig.annotations.title === undefined) {\n toolConfig.annotations.title = toolConfig.name;\n }\n\n // Add to registry in the formatted structure\n registry[toolConfig.name] = {\n description: toolConfig.description,\n inputSchema: z.object(toolSchema || {}),\n execute: async (args, extra) => {\n const result = await handler(args, extra);\n return result;\n },\n };\n }\n\n return registry;\n}\n\nexport const tools = await getTools();\n`}();j().writeFileSync(m().join(v,"tools.js"),e);const t=function(){const{toolPaths:e}=w.getContext(),t=Array.from(e).map(e=>{const t=e.replace(/\\/g,"/");return(t.split("/").pop()||t).replace(/\.[^/.]+$/,"")});return`import { z } from "zod";\n\nexport interface ToolMetadata {\n name: string;\n description: string;\n annotations?: {\n title?: string;\n [key: string]: any;\n };\n [key: string]: any;\n}\n\nexport interface ToolItem {\n path: string;\n name: string;\n metadata: ToolMetadata;\n schema: Record<string, z.ZodType>;\n handler: (args: any) => Promise<any>;\n}\n\nexport interface ToolRegistryItem {\n description: string;\n inputSchema: z.ZodObject<any>;\n execute: (args: any) => Promise<any>;\n}\n\nexport type ToolRegistry = Record<string, ToolRegistryItem>;\n\nexport type ToolNames = ${t.length>0?t.map(e=>`"${e}"`).join(" | "):"never"};\n\ndeclare global {\n namespace XMCP {\n interface Tools extends ToolRegistry {}\n }\n}\n\nexport declare function getTools(): Promise<ToolRegistry>;\nexport declare const tools: ToolRegistry;\n`}();j().writeFileSync(m().join(v,"tools.d.ts"),t)}}nr().config();const _r=process.cwd(),xr=new u;xr.name("xmcp").description("The MCP framework CLI").version("0.0.1"),xr.command("dev").description("Start development mode").action(()=>{console.log(`${dr} Starting development mode...`),S({mode:"development",platforms:{}},()=>{yr()})}),xr.command("build").description("Build for production").option("--vercel","Build for Vercel deployment").action(async e=>{console.log(`${dr} Building for production...`);const t=e.vercel||"1"===process.env.VERCEL;S({mode:"production",platforms:{vercel:t}},()=>{yr({onBuild:async()=>{if(t){console.log(`${dr} Building for Vercel...`);try{await async function(){const e=m().join(_r,".vercel","output"),t=m().join(e,"functions","api","index.func");console.log("🚀 Building Vercel output structure..."),j().mkdirSync(e,{recursive:!0}),j().mkdirSync(t,{recursive:!0});const r=m().join(_r,"dist"),a=m().join(r,"http.js"),n=m().join(t,"index.js");if(!j().existsSync(r))throw new Error("❌ Dist directory not found. Run build first.");if(!j().existsSync(a))throw new Error("❌ Application server file not found in dist/. Run build first.");j().copyFileSync(a,n);const s=j().readdirSync(r);for(const e of s){const a=m().join(r,e),n=m().join(t,e);if("http.js"===e||"stdio.js"===e||"auth-ui"===e)continue;const s=j().statSync(a);s.isFile()?j().copyFileSync(a,n):s.isDirectory()&&j().cpSync(a,n,{recursive:!0})}const i=m().join(_r,"package.json"),o=m().join(t,"package.json");j().copyFileSync(i,o),console.log("Server and dependency files copied to function directory");const c=m().join(e,"static");j().mkdirSync(c,{recursive:!0});let u=m().join(r,"auth-ui");if(j().existsSync(u)||(u=m().join(_r,"node_modules","@xmcp-dev","better-auth","dist","auth-ui")),j().existsSync(u)){const e=m().join(c,"auth");j().cpSync(u,e,{recursive:!0}),console.log("Auth UI assets copied to static directory");const r=m().join(t,"auth-ui");j().existsSync(r)&&(j().rmSync(r,{recursive:!0}),console.log("Auth UI assets removed from function directory"))}j().writeFileSync(m().join(t,".vc-config.json"),JSON.stringify({handler:"index.js",runtime:"nodejs22.x",launcherType:"Nodejs",shouldAddHelpers:!0},null,2)),j().writeFileSync(m().join(e,"config.json"),JSON.stringify({version:3,routes:[{src:"^/auth/assets/(.*)$",dest:"/auth/assets/$1"},{handle:"filesystem"},{src:"^/auth/(sign-in|callback/.*|index\\.html)?$",dest:"/auth/index.html"},{src:"^/(.*)$",dest:"/api"}]},null,2)),console.log("✅ Vercel output structure created successfully")}()}catch(e){console.error(nt.red("❌ Failed to create Vercel output structure:"),e)}}}})})}),xr.parse()})(),{}})());
24
+ `,lr=e=>{let t=!1;const r=(0,cr.spawn)(process.execPath,["-e",ur,String(e.pid)],{stdio:"ignore"});return r.on("exit",()=>t=!0),e.on("exit",()=>{t||r.kill("SIGKILL")}),r},pr=nt.bold.green("✔"),dr=nt.bold.black.bgWhite(" XMCP "),fr=nt.bold.yellow("❯");let hr=null;function mr(){const e=(0,cr.spawn)("node",["dist/http.js"],{stdio:"inherit",shell:!0});return lr(e),e}function vr(e,t){if(null!=e&&!1!==e){if(""===e&&gr(`${t} path cannot be an empty string`),"string"==typeof(r=e)&&r.length>0)return function(e){return/[*?\[\]{}]/.test(e)}(e)&&gr(`If you are using a glob pattern, please use a string for the ${t} path`),function(e){const r=function(e){return e.split(/\\|\//).join("/")}(e),a=m().resolve(g,r);return j().existsSync(a)||gr(`The path set in xmcp.config.ts for ${t} does not exist: ${a}.\n If you're not using this folder, set the ${t} path to false`),r}(e);var r;gr(`${t} path must be a non-empty string`)}}function gr(e){console.log(""),console.log(nt.red.bold(e)),console.log(""),process.exit(1)}async function yr({onBuild:e}={}){const{mode:t,toolPaths:r,promptPaths:a}=w.getContext(),n=Date.now();let s=!1;const i=await async function(){const e=await async function(){const e=_t("xmcp.config.json");if(e)return bt(JSON.parse(e));if(_t(xt))try{return await async function(){const e=m().resolve(process.cwd(),xt),t=(0,st.createFsFromVolume)(new st.Volume),r={mode:"production",entry:e,target:"node",output:{path:"/",filename:"config.js",library:{type:"commonjs2"}},resolve:{extensions:[".ts",".js"]},module:{rules:[{test:/\.ts$/,use:{loader:"swc-loader",options:{jsc:{parser:{syntax:"typescript"},target:"es2020"},module:{type:"commonjs"}}},exclude:/node_modules/}]},externals:{webpack:"commonjs2 webpack"}};return new Promise((a,n)=>{const s=(0,f.webpack)(r);s?(s.outputFileSystem=t,s.run((r,s)=>{if(r)n(r);else if(s?.hasErrors())n(new Error(s.toString({colors:!1,errors:!0})));else try{const r=t.readFileSync("/config.js","utf8"),n={exports:{}},s=e=>{if("webpack"===e)return f.webpack;throw new Error(`Cannot resolve module: ${e}`)};new Function("module","exports","require","__filename","__dirname",r)(n,n.exports,s,e,m().dirname(e));const i=n.exports.default||n.exports,o="function"==typeof i?i():i;a(bt(o))}catch(e){n(e)}})):n(new Error("Failed to create webpack compiler"))})}()}catch(e){throw new Error(`Failed to compile xmcp.config.ts:\n${e}`)}return{stdio:!0,http:!0,paths:R}}(),{platforms:t}=w.getContext();return t.vercel&&delete e.stdio,e}();w.setContext({xmcpConfig:i});let o=Te(i);i.webpack&&(o=i.webpack(o));const c=new or({persistent:"development"===t,ignored:/(^|[\/\\])\../,ignoreInitial:!1});let u=vr(O(i).tools,"tools");u&&c.watch(`${u}/**/*.ts`,{onAdd:e=>{r.add(e),s&&br()},onUnlink:e=>{r.delete(e),s&&br()}});let l=vr(O(i).prompts,"prompts");l&&c.watch(`${l}/**/*.ts`,{onAdd:e=>{a.add(e),s&&br()},onUnlink:e=>{a.delete(e),s&&br()}}),i.experimental?.adapter||c.watch("./src/middleware.ts",{onAdd:()=>{w.setContext({hasMiddleware:!0}),s&&br()},onUnlink:()=>{w.setContext({hasMiddleware:!1}),s&&br()}}),c.onReady(()=>{let r=!0;var a;s=!0,function(e,{force:t,dryRun:r,cwd:a=je.cwd(),...n}={}){n={expandDirectories:!1,onlyFiles:!1,followSymbolicLinks:!1,cwd:a,...n},e=function(e){return(e=Array.isArray(e)?e:[e]).map(e=>"win32"===je.platform&&!1===Qt(e)?Ot(e):e)}(e);const s=Wt(e,n).sort((e,t)=>t.localeCompare(e)).map(e=>(e=wt.resolve(a,e),t||function(e,t){if(function(e){let t=je.cwd();return e=wt.resolve(e),"win32"===je.platform&&(t=t.toLowerCase(),e=e.toLowerCase()),e===t}(e))throw new Error("Cannot delete the current working directory. Can be overridden with the `force` option.");if(!function(e,t){const r=wt.relative(t,e);return Boolean(r&&".."!==r&&!r.startsWith(`..${wt.sep}`)&&r!==wt.resolve(e))}(e,t))throw new Error("Cannot delete files/directories outside the current working directory. Can be overridden with the `force` option.")}(e,a),r||er.sync(e,rr),e));s.sort((e,t)=>e.localeCompare(t))}(v),a=v,j().existsSync(a)||j().mkdirSync(a,{recursive:!0}),br(),(0,f.webpack)(o,(a,s)=>{if(a&&console.error(a),s?.hasErrors())return void console.error(s.toString({colors:!0,chunks:!1}));let o;r?(function(e,t){const r=[];t.stdio&&r.push(`${pr} Built STDIO server`),t.http&&(t.experimental?.adapter?r.push(`${pr} Built Adapter`):r.push(`${pr} Built HTTP server`)),r.forEach(e=>{console.log(e)})}(0,i),e?.()):"development"===t&&i.http&&!i.experimental?.adapter&&async function(){hr?(console.log(`${fr} Restarting http server`),await async function(e){e.kill("SIGKILL"),await new Promise(t=>{e.on("exit",t)})}(hr),hr=mr()):(console.log(`${fr} Starting http server`),hr=mr())}(),o=s?.endTime&&s?.startTime?s.endTime-s.startTime:Date.now()-n;let c=e=>e;"development"===t&&(o>1e3?c=nt.bold.red:o>500&&(c=nt.bold.yellow)),console.log(`${pr} Compiled in ${c(`${o}ms`)}`),r=!1})})}function br(){const e=function(){const{toolPaths:e,promptPaths:t,hasMiddleware:r}=w.getContext();return`\nexport const tools = {\n${Array.from(e).map(e=>{const t=e.replace(/\\/g,"/");return`"${t}": () => import("../${t}"),`}).join("\n")}\n};\n\nexport const prompts = {\n${Array.from(t).map(e=>{const t=e.replace(/\\/g,"/");return`"${t}": () => import("../${t}"),`}).join("\n")}\n};\n\n${r?'export const middleware = () => import("../src/middleware");':""}\n`}();j().writeFileSync(m().join(v,"import-map.js"),e);const t=m().join(g,"xmcp-env.d.ts");j().existsSync(t)&&j().unlinkSync(t),j().writeFileSync(t,'/// <reference types="xmcp" />\n\n// Do not edit this file');const{xmcpConfig:r}=w.getContext();if("nextjs"===r?.experimental?.adapter){const e=function(){const{toolPaths:e}=w.getContext();return`import { z } from "zod";\n\n${Array.from(e).map((e,t)=>`import * as tool${t} from "../${e.replace(/\\/g,"/")}";`).join("\n")}\n\n/** \n * Runtime-accessible tools function that works from any context.\n * Generated at build time - always up to date with discovered tools.\n * @returns {Promise<ToolRegistry>}\n */\nexport async function getTools() {\n const toolsData = [\n ${Array.from(e).map((e,t)=>{const r=e.replace(/\\/g,"/"),a=r.split("/").pop()||r;return`{\n path: "${r}",\n name: "${a.replace(/\.[^/.]+$/,"")}",\n module: tool${t}\n }`}).join(",\n ")}\n ];\n\n const registry = {};\n\n for (const toolData of toolsData) {\n const { path, name: defaultName, module } = toolData;\n const { default: handler, metadata, schema } = module;\n\n const toolConfig = {\n name: defaultName,\n description: "No description provided",\n ...((typeof metadata === "object" && metadata !== null) ? metadata : {})\n };\n\n // Determine the actual schema to use\n let toolSchema = {};\n if (schema && typeof schema === "object" && schema !== null) {\n // Basic validation for Zod schema object\n const isValidSchema = Object.entries(schema).every(([key, val]) => {\n if (typeof key !== "string") return false;\n if (typeof val !== "object" || val === null) return false;\n if (!("parse" in val) || typeof val.parse !== "function") return false;\n return true;\n });\n \n if (isValidSchema) {\n toolSchema = schema;\n } else {\n console.warn(\`Invalid schema for tool "\${toolConfig.name}" at \${path}. Expected Record<string, z.ZodType>\`);\n }\n }\n\n // Make sure tools has annotations with a title\n if (toolConfig.annotations === undefined) {\n toolConfig.annotations = {};\n }\n if (toolConfig.annotations.title === undefined) {\n toolConfig.annotations.title = toolConfig.name;\n }\n\n // Add to registry in the formatted structure\n registry[toolConfig.name] = {\n description: toolConfig.description,\n inputSchema: z.object(toolSchema || {}),\n execute: async (args, extra) => {\n const result = await handler(args, extra);\n return result;\n },\n };\n }\n\n return registry;\n}\n\nexport const tools = await getTools();`}();j().writeFileSync(m().join(v,"tools.js"),e);const t=function(){const{toolPaths:e}=w.getContext(),t=Array.from(e).map(e=>{const t=e.replace(/\\/g,"/");return(t.split("/").pop()||t).replace(/\.[^/.]+$/,"")});return`import { z } from "zod";\n\nexport interface ToolMetadata {\n name: string;\n description: string;\n annotations?: {\n title?: string;\n [key: string]: any;\n };\n [key: string]: any;\n}\n\nexport interface ToolItem {\n path: string;\n name: string;\n metadata: ToolMetadata;\n schema: Record<string, z.ZodType>;\n handler: (args: any) => Promise<any>;\n}\n\nexport interface ToolRegistryItem {\n description: string;\n inputSchema: z.ZodObject<any>;\n execute: (args: any) => Promise<any>;\n}\n\nexport type ToolNames = ${t.length>0?t.map(e=>`"${e}"`).join(" | "):"never"};\n\nexport type ToolRegistry = {\n [k in ToolNames]: ToolRegistryItem;\n};\n\ndeclare global {\n namespace XMCP {\n interface Tools extends ToolRegistry {}\n }\n}\n\nexport declare function getTools(): Promise<ToolRegistry>;\nexport declare const tools: ToolRegistry;\n`}();j().writeFileSync(m().join(v,"tools.d.ts"),t)}}nr().config();const _r=process.cwd(),xr=new u;xr.name("xmcp").description("The MCP framework CLI").version("0.0.1"),xr.command("dev").description("Start development mode").action(()=>{console.log(`${dr} Starting development mode...`),S({mode:"development",platforms:{}},()=>{yr()})}),xr.command("build").description("Build for production").option("--vercel","Build for Vercel deployment").action(async e=>{console.log(`${dr} Building for production...`);const t=e.vercel||"1"===process.env.VERCEL;S({mode:"production",platforms:{vercel:t}},()=>{yr({onBuild:async()=>{if(t){console.log(`${dr} Building for Vercel...`);try{await async function(){const e=m().join(_r,".vercel","output"),t=m().join(e,"functions","api","index.func");console.log("🚀 Building Vercel output structure..."),j().mkdirSync(e,{recursive:!0}),j().mkdirSync(t,{recursive:!0});const r=m().join(_r,"dist"),a=m().join(r,"http.js"),n=m().join(t,"index.js");if(!j().existsSync(r))throw new Error("❌ Dist directory not found. Run build first.");if(!j().existsSync(a))throw new Error("❌ Application server file not found in dist/. Run build first.");j().copyFileSync(a,n);const s=j().readdirSync(r);for(const e of s){const a=m().join(r,e),n=m().join(t,e);if("http.js"===e||"stdio.js"===e||"auth-ui"===e)continue;const s=j().statSync(a);s.isFile()?j().copyFileSync(a,n):s.isDirectory()&&j().cpSync(a,n,{recursive:!0})}const i=m().join(_r,"package.json"),o=m().join(t,"package.json");j().copyFileSync(i,o),console.log("Server and dependency files copied to function directory");const c=m().join(e,"static");j().mkdirSync(c,{recursive:!0});let u=m().join(r,"auth-ui");if(j().existsSync(u)||(u=m().join(_r,"node_modules","@xmcp-dev","better-auth","dist","auth-ui")),j().existsSync(u)){const e=m().join(c,"auth");j().cpSync(u,e,{recursive:!0}),console.log("Auth UI assets copied to static directory");const r=m().join(t,"auth-ui");j().existsSync(r)&&(j().rmSync(r,{recursive:!0}),console.log("Auth UI assets removed from function directory"))}j().writeFileSync(m().join(t,".vc-config.json"),JSON.stringify({handler:"index.js",runtime:"nodejs22.x",launcherType:"Nodejs",shouldAddHelpers:!0},null,2)),j().writeFileSync(m().join(e,"config.json"),JSON.stringify({version:3,routes:[{src:"^/auth/assets/(.*)$",dest:"/auth/assets/$1"},{handle:"filesystem"},{src:"^/auth/(sign-in|callback/.*|index\\.html)?$",dest:"/auth/index.html"},{src:"^/(.*)$",dest:"/api"}]},null,2)),console.log("✅ Vercel output structure created successfully")}()}catch(e){console.error(nt.red("❌ Failed to create Vercel output structure:"),e)}}}})})}),xr.parse()})(),{}})());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "xmcp",
3
3
  "description": "The MCP framework",
4
- "version": "0.2.1-canary.2",
4
+ "version": "0.2.1",
5
5
  "author": {
6
6
  "name": "Basement Studio",
7
7
  "email": "hello@basement.studio",