xmcp 0.1.8 → 0.1.9-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- 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
|
-
`,or=e=>{let t=!1;const r=(0,sr.spawn)(process.execPath,["-e",ir,String(e.pid)],{stdio:"ignore"});return r.on("exit",()=>t=!0),e.on("exit",()=>{t||r.kill("SIGKILL")}),r},cr=rt.bold.green("✔"),ur=rt.bold.black.bgWhite(" XMCP "),lr=rt.bold.yellow("❯");let pr=null;function dr(){const e=(0,sr.spawn)("node",["dist/http.js"],{stdio:"inherit",shell:!0});return or(e),e}function fr(e){console.log(""),console.log(rt.red.bold(e)),console.log(""),process.exit(1)}async function hr({onBuild:e}={}){const{mode:t,toolPaths:r}=w.getContext(),a=Date.now();let n=!1;const s=await async function(){const e=await async function(){const e=gt("xmcp.config.json");if(e)return vt(JSON.parse(e));if(gt(yt))try{return await async function(){const e=m().resolve(process.cwd(),yt),t=(0,at.createFsFromVolume)(new at.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.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(vt(o))}catch(e){n(e)}})})}()}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:s});let i=Pe(s);s.webpack&&(i=s.webpack(i));const o=new nr({persistent:"development"===t,ignored:/(^|[\/\\])\../,ignoreInitial:!1});let c=function(e,t){if(void 0!==e){if(""===e&&fr(`${t} path cannot be an empty string`),"string"==typeof(r=e)&&r.length>0)return function(e){return/[*?\[\]{}]/.test(e)}(e)&&fr(`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 D().existsSync(a)||fr(`The path set in xmcp config for ${t} does not exist: ${a}`),r}(e);var r;fr(`${t} path must be a non-empty string`)}}(O(s).tools,"tools");o.watch(`${c}/**/*.ts`,{onAdd:e=>{r.add(e),n&&mr()},onUnlink:e=>{r.delete(e),n&&mr()}}),s.experimental?.adapter||o.watch("./src/middleware.ts",{onAdd:()=>{w.setContext({hasMiddleware:!0}),n&&mr()},onUnlink:()=>{w.setContext({hasMiddleware:!1}),n&&mr()}}),o.onReady(()=>{let r=!0;var o;n=!0,function(e,{force:t,dryRun:r,cwd:a=De.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"===De.platform&&!1===Xt(e)?Pt(e):e)}(e);const s=Vt(e,n).sort((e,t)=>t.localeCompare(e)).map(e=>(e=_t.resolve(a,e),t||function(e,t){if(function(e){let t=De.cwd();return e=_t.resolve(e),"win32"===De.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=_t.relative(t,e);return Boolean(r&&".."!==r&&!r.startsWith(`..${_t.sep}`)&&r!==_t.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||Wt.sync(e,Qt),e));s.sort((e,t)=>e.localeCompare(t))}(v),o=v,D().existsSync(o)||D().mkdirSync(o,{recursive:!0}),mr(),(0,f.webpack)(i,(n,i)=>{if(n&&console.error(n),i?.hasErrors())console.error(i.toString({colors:!0,chunks:!1}));else if(r){r=!1;const t=Date.now()-a;console.log(`${cr} Compiled in ${rt.bold.green(`${t}ms`)}`),function(e,t){const r=[];t.stdio&&r.push(`${cr} Built STDIO server`),t.http&&(t.experimental?.adapter?r.push(`${cr} Built Adapter`):r.push(`${cr} Built HTTP server`)),r.forEach(e=>{console.log(e)})}(0,s),e?.()}else"development"===t&&s.http&&!s.experimental?.adapter&&async function(){pr?(console.log(`${lr} Restarting http server`),await async function(e){e.kill("SIGKILL"),await new Promise(t=>{e.on("exit",t)})}(pr),pr=dr()):(console.log(`${lr} Starting http server`),pr=dr())}()})})}function mr(){const e=function(){const{toolPaths:e,hasMiddleware:t}=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\n${t?'export const middleware = () => import("../src/middleware");':""}\n`}();D().writeFileSync(m().join(v,"import-map.js"),e);const t=m().join(g,"xmcp-env.d.ts");D().existsSync(t)&&D().unlinkSync(t),D().writeFileSync(t,'/// <reference types="xmcp" />\n\n// Do not edit this file')}tr().config();const vr=process.cwd(),gr=new u;gr.name("xmcp").description("The MCP framework CLI").version("0.0.1"),gr.command("dev").description("Start development mode").action(()=>{console.log(`${ur} Starting development mode...`),S({mode:"development",platforms:{}},()=>{hr()})}),gr.command("build").description("Build for production").option("--vercel","Build for Vercel deployment").action(async e=>{console.log(`${ur} Building for production...`),S({mode:"production",platforms:{vercel:e.vercel}},()=>{hr({onBuild:async()=>{if(e.vercel){console.log(`${ur} Building for Vercel...`);try{await async function(){const e=m().join(vr,".vercel","output"),t=m().join(e,"functions","api","index.func");console.log("🚀 Building Vercel output structure..."),D().mkdirSync(e,{recursive:!0}),D().mkdirSync(t,{recursive:!0});const r=m().join(vr,"dist"),a=m().join(r,"http.js"),n=m().join(t,"index.js");if(!D().existsSync(r))throw new Error("❌ Dist directory not found. Run build first.");if(!D().existsSync(a))throw new Error("❌ Application server file not found in dist/. Run build first.");D().copyFileSync(a,n);const s=D().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)continue;const s=D().statSync(a);s.isFile()?D().copyFileSync(a,n):s.isDirectory()&&D().cpSync(a,n,{recursive:!0})}const i=m().join(vr,"package.json"),o=m().join(t,"package.json");D().copyFileSync(i,o),console.log("Server and dependency files copied to function directory"),D().writeFileSync(m().join(t,".vc-config.json"),JSON.stringify({handler:"index.js",runtime:"nodejs22.x",launcherType:"Nodejs",shouldAddHelpers:!0},null,2)),D().writeFileSync(m().join(e,"config.json"),JSON.stringify({version:3,routes:[{src:"^/(.*)$",dest:"/
|
|
24
|
+
`,or=e=>{let t=!1;const r=(0,sr.spawn)(process.execPath,["-e",ir,String(e.pid)],{stdio:"ignore"});return r.on("exit",()=>t=!0),e.on("exit",()=>{t||r.kill("SIGKILL")}),r},cr=rt.bold.green("✔"),ur=rt.bold.black.bgWhite(" XMCP "),lr=rt.bold.yellow("❯");let pr=null;function dr(){const e=(0,sr.spawn)("node",["dist/http.js"],{stdio:"inherit",shell:!0});return or(e),e}function fr(e){console.log(""),console.log(rt.red.bold(e)),console.log(""),process.exit(1)}async function hr({onBuild:e}={}){const{mode:t,toolPaths:r}=w.getContext(),a=Date.now();let n=!1;const s=await async function(){const e=await async function(){const e=gt("xmcp.config.json");if(e)return vt(JSON.parse(e));if(gt(yt))try{return await async function(){const e=m().resolve(process.cwd(),yt),t=(0,at.createFsFromVolume)(new at.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.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(vt(o))}catch(e){n(e)}})})}()}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:s});let i=Pe(s);s.webpack&&(i=s.webpack(i));const o=new nr({persistent:"development"===t,ignored:/(^|[\/\\])\../,ignoreInitial:!1});let c=function(e,t){if(void 0!==e){if(""===e&&fr(`${t} path cannot be an empty string`),"string"==typeof(r=e)&&r.length>0)return function(e){return/[*?\[\]{}]/.test(e)}(e)&&fr(`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 D().existsSync(a)||fr(`The path set in xmcp config for ${t} does not exist: ${a}`),r}(e);var r;fr(`${t} path must be a non-empty string`)}}(O(s).tools,"tools");o.watch(`${c}/**/*.ts`,{onAdd:e=>{r.add(e),n&&mr()},onUnlink:e=>{r.delete(e),n&&mr()}}),s.experimental?.adapter||o.watch("./src/middleware.ts",{onAdd:()=>{w.setContext({hasMiddleware:!0}),n&&mr()},onUnlink:()=>{w.setContext({hasMiddleware:!1}),n&&mr()}}),o.onReady(()=>{let r=!0;var o;n=!0,function(e,{force:t,dryRun:r,cwd:a=De.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"===De.platform&&!1===Xt(e)?Pt(e):e)}(e);const s=Vt(e,n).sort((e,t)=>t.localeCompare(e)).map(e=>(e=_t.resolve(a,e),t||function(e,t){if(function(e){let t=De.cwd();return e=_t.resolve(e),"win32"===De.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=_t.relative(t,e);return Boolean(r&&".."!==r&&!r.startsWith(`..${_t.sep}`)&&r!==_t.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||Wt.sync(e,Qt),e));s.sort((e,t)=>e.localeCompare(t))}(v),o=v,D().existsSync(o)||D().mkdirSync(o,{recursive:!0}),mr(),(0,f.webpack)(i,(n,i)=>{if(n&&console.error(n),i?.hasErrors())console.error(i.toString({colors:!0,chunks:!1}));else if(r){r=!1;const t=Date.now()-a;console.log(`${cr} Compiled in ${rt.bold.green(`${t}ms`)}`),function(e,t){const r=[];t.stdio&&r.push(`${cr} Built STDIO server`),t.http&&(t.experimental?.adapter?r.push(`${cr} Built Adapter`):r.push(`${cr} Built HTTP server`)),r.forEach(e=>{console.log(e)})}(0,s),e?.()}else"development"===t&&s.http&&!s.experimental?.adapter&&async function(){pr?(console.log(`${lr} Restarting http server`),await async function(e){e.kill("SIGKILL"),await new Promise(t=>{e.on("exit",t)})}(pr),pr=dr()):(console.log(`${lr} Starting http server`),pr=dr())}()})})}function mr(){const e=function(){const{toolPaths:e,hasMiddleware:t}=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\n${t?'export const middleware = () => import("../src/middleware");':""}\n`}();D().writeFileSync(m().join(v,"import-map.js"),e);const t=m().join(g,"xmcp-env.d.ts");D().existsSync(t)&&D().unlinkSync(t),D().writeFileSync(t,'/// <reference types="xmcp" />\n\n// Do not edit this file')}tr().config();const vr=process.cwd(),gr=new u;gr.name("xmcp").description("The MCP framework CLI").version("0.0.1"),gr.command("dev").description("Start development mode").action(()=>{console.log(`${ur} Starting development mode...`),S({mode:"development",platforms:{}},()=>{hr()})}),gr.command("build").description("Build for production").option("--vercel","Build for Vercel deployment").action(async e=>{console.log(`${ur} Building for production...`),S({mode:"production",platforms:{vercel:e.vercel}},()=>{hr({onBuild:async()=>{if(e.vercel){console.log(`${ur} Building for Vercel...`);try{await async function(){const e=m().join(vr,".vercel","output"),t=m().join(e,"functions","api","index.func");console.log("🚀 Building Vercel output structure..."),D().mkdirSync(e,{recursive:!0}),D().mkdirSync(t,{recursive:!0});const r=m().join(vr,"dist"),a=m().join(r,"http.js"),n=m().join(t,"index.js");if(!D().existsSync(r))throw new Error("❌ Dist directory not found. Run build first.");if(!D().existsSync(a))throw new Error("❌ Application server file not found in dist/. Run build first.");D().copyFileSync(a,n);const s=D().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=D().statSync(a);s.isFile()?D().copyFileSync(a,n):s.isDirectory()&&D().cpSync(a,n,{recursive:!0})}const i=m().join(vr,"package.json"),o=m().join(t,"package.json");D().copyFileSync(i,o),console.log("Server and dependency files copied to function directory");const c=m().join(e,"static");D().mkdirSync(c,{recursive:!0});let u=m().join(r,"auth-ui");if(D().existsSync(u)||(u=m().join(vr,"node_modules","@xmcp-dev","better-auth","dist","auth-ui")),D().existsSync(u)){const e=m().join(c,"auth");D().cpSync(u,e,{recursive:!0}),console.log("Auth UI assets copied to static directory");const r=m().join(t,"auth-ui");D().existsSync(r)&&(D().rmSync(r,{recursive:!0}),console.log("Auth UI assets removed from function directory"))}D().writeFileSync(m().join(t,".vc-config.json"),JSON.stringify({handler:"index.js",runtime:"nodejs22.x",launcherType:"Nodejs",shouldAddHelpers:!0},null,2)),D().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(rt.red("❌ Failed to create Vercel output structure:"),e)}}}})})}),gr.parse()})(),{}})());
|